...
 
Commits (4)
......@@ -28,5 +28,11 @@ if appstream_util.found()
args: ['validate', appstream_file]
)
endif
install_subdir(
'wallpapers',
install_dir: wallpapers_dir,
strip_directory: true
)
subdir('icons')
subdir('wallpapers')
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
wallpapers = [
'3-0.jpg',
'3-4.jpg',
'3-6.jpg',
'3-10.jpg',
'3-12.jpg',
'3-14.jpg',
'3-16.jpg',
'3-18.jpg',
'3-20.jpg',
'3-22.jpg',
'3-24.jpg',
'3-26.jpg',
'3-28.jpg',
'3-30.jpg',
]
install_data (wallpapers, install_dir: wallpapers_dir)
<background>
<starttime>
<year>2011</year>
<month>11</month>
<day>24</day>
<hour>7</hour>
<minute>00</minute>
<second>00</second>
</starttime>
<!-- This animation will start at 7 AM. -->
<!-- We start with sunrise at 7 AM. It will remain up for 1 hour. -->
<static>
<duration>3600.0</duration>
<file>@datadir@/@morning@.jpg</file>
</static>
<!-- Sunrise starts to transition to day at 8 AM. The transition lasts for 5 hours, ending at 1 PM. -->
<transition type="overlay">
<duration>18000.0</duration>
<from>@datadir@/@morning@.jpg</from>
<to>@datadir@/@day@.jpg</to>
</transition>
<!-- It's 1 PM, we're showing the day image in full force now, for 5 hours ending at 6 PM. -->
<static>
<duration>18000.0</duration>
<file>@datadir@/@day@.jpg</file>
</static>
<!-- It's 7 PM and it's going to start to get darker. This will transition for 6 hours up until midnight. -->
<transition type="overlay">
<duration>21600.0</duration>
<from>@datadir@/@day@.jpg</from>
<to>@datadir@/@night@.jpg</to>
</transition>
<!-- It's midnight. It'll stay dark for 5 hours up until 5 AM. -->
<static>
<duration>18000.0</duration>
<file>@datadir@/@night@.jpg</file>
</static>
<!-- It's 5 AM. We'll start transitioning to sunrise for 2 hours up until 7 AM. -->
<transition type="overlay">
<duration>7200.0</duration>
<from>@datadir@/@night@.jpg</from>
<to>@datadir@/@morning@.jpg</to>
</transition>
</background>
......@@ -19,7 +19,7 @@
namespace Nostalgia {
[GtkTemplate (ui = "/org/gnome/Nostalgia/wallpaper-row.ui")]
public class WallpaperRow : Gtk.Box {
public signal void wallpaper_clicked (string filename);
public signal void wallpaper_clicked ();
[GtkChild]
private Gtk.Image wallpaper;
......@@ -28,10 +28,7 @@ namespace Nostalgia {
[GtkChild]
private Gtk.Label date_label;
private string filepath;
public WallpaperRow (string filepath, string version, string date) {
this.filepath = filepath;
version_label.label = version;
date_label.label = date;
......@@ -45,7 +42,7 @@ namespace Nostalgia {
[GtkCallback]
private bool on_button_press_event () {
wallpaper_clicked (filepath);
wallpaper_clicked ();
return false;
}
}
......
......@@ -32,53 +32,113 @@ namespace Nostalgia {
provider.load_from_resource ("org/gnome/Nostalgia/style.css");
Gtk.StyleContext.add_provider_for_screen (Gdk.Screen.get_default (), provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
add_wallpaper("3-0.jpg", "3.0", "April 6, 2011");
add_wallpaper("3-0.jpg", "3.2", "September 28, 2011"); // identical to 3.0
add_wallpaper("3-4.jpg", "3.4", "March 28, 2012");
add_wallpaper("3-6.jpg", "3.6", "September 26, 2012");
add_wallpaper("3-6.jpg", "3.8", "March 27, 2013"); // identical to 3.6
add_wallpaper("3-10.jpg", "3.10", "September 25, 2013");
add_wallpaper("3-12.jpg", "3.12", "March 26, 2014");
add_wallpaper("3-14.jpg", "3.14", "September 24, 2014");
add_wallpaper("3-16.jpg", "3.16", "March 25, 2015");
add_wallpaper("3-18.jpg", "3.18", "September 23, 2015");
add_wallpaper("3-20.jpg", "3.20", "March 23, 2016");
add_wallpaper("3-22.jpg", "3.22", "September 21, 2016");
add_wallpaper("3-24.jpg", "3.24", "March 22, 2017");
add_wallpaper("3-26.jpg", "3.26", "September 13, 2017");
add_wallpaper("3-28.jpg", "3.28", "March 14, 2018");
add_wallpaper("3-30.jpg", "3.30", "September 5, 2018");
add_static_wallpaper("3-0.jpg", "3.0", "April 6, 2011");
add_static_wallpaper("3-0.jpg", "3.2", "September 28, 2011"); // identical to 3.0
add_dynamic_wallpaper("3-4", "3.4", "March 28, 2012");
add_dynamic_wallpaper("3-6", "3.6", "September 26, 2012");
add_dynamic_wallpaper("3-6", "3.8", "March 27, 2013"); // identical to 3.6
add_dynamic_wallpaper("3-10", "3.10", "September 25, 2013");
add_dynamic_wallpaper("3-12", "3.12", "March 26, 2014");
add_dynamic_wallpaper("3-14", "3.14", "September 24, 2014");
add_dynamic_wallpaper("3-16", "3.16", "March 25, 2015");
add_dynamic_wallpaper("3-18", "3.18", "September 23, 2015");
add_dynamic_wallpaper("3-20", "3.20", "March 23, 2016");
add_dynamic_wallpaper("3-22", "3.22", "September 21, 2016");
add_dynamic_wallpaper("3-24", "3.24", "March 22, 2017");
add_dynamic_wallpaper("3-26", "3.26", "September 13, 2017");
add_dynamic_wallpaper("3-28", "3.28", "March 14, 2018");
add_dynamic_wallpaper("3-30", "3.30", "September 5, 2018");
this.show_all();
}
public void add_wallpaper(string filename, string version, string date){
string filepath = Config.WALLPAPERS_DIR + "/" + filename;
public void add_static_wallpaper (string filename, string version, string date) {
var filepath = Config.WALLPAPERS_DIR + "/" + filename;
var row = new WallpaperRow (filepath, version, date);
row.wallpaper_clicked.connect (wallpaper_clicked);
row.wallpaper_clicked.connect (() => {
save_static_wallpaper.begin (filename, (obj, res) => {
set_wallpaper ("wallpaper.jpg");
});
});
layout.add (row);
}
private async void save_wallpaper (string filepath) throws Error {
message("Saving wallpaper to: " + Environment.get_user_data_dir());
public void add_dynamic_wallpaper (string dir, string version, string date) {
var filepath = Config.WALLPAPERS_DIR + "/" + dir + "/day.jpg";
File src = File.new_for_path (filepath);
File dest = File.new_for_path (Environment.get_user_data_dir() + "/wallpaper.jpg");
var row = new WallpaperRow (filepath, version, date);
row.wallpaper_clicked.connect (() => {
save_dynamic_wallpaper.begin (dir, (obj, res) => {
save_dynamic_wallpaper.end (res);
set_wallpaper (dir + ".xml");
});
});
yield src.copy_async (dest, FileCopyFlags.OVERWRITE, Priority.DEFAULT_IDLE);
layout.add (row);
}
private void set_wallpaper(){
var settings = new GLib.Settings ("org.gnome.desktop.background");
settings.set_string("picture-uri", Environment.get_user_data_dir() + "/wallpaper.jpg");
private async void save_static_wallpaper (string filename) {
try {
yield copy_file (filename, "wallpaper.jpg");
} catch (Error e) {
critical (e.message);
}
}
private void wallpaper_clicked(string filename){
save_wallpaper.begin (filename, (obj, res) => {
set_wallpaper();
});
private async void save_dynamic_wallpaper (string dir) {
try {
yield copy_file (dir + "/day.jpg", "day.jpg");
yield copy_file (dir + "/morning.jpg", "morning.jpg");
yield copy_file (dir + "/night.jpg", "night.jpg");
yield copy_xml (dir);
} catch (Error e) {
critical (e.message);
}
}
private async string read_file (string filename) throws Error {
var file = File.new_for_path (filename);
var @is = file.read ();
var dis = new DataInputStream (@is);
var line = "";
var contents = "";
while ((line = yield dis.read_line_async ()) != null)
contents += line + "\n";
yield dis.close_async ();
return contents;
}
private async void copy_xml (string version) throws Error {
var dest_dir = Environment.get_user_data_dir ();
var contents = yield read_file (Config.WALLPAPERS_DIR + "/wallpaper-timed.xml");
contents = contents.replace ("@datadir@", dest_dir);
contents = contents.replace ("@morning@", "morning");
contents = contents.replace ("@day@", "day");
contents = contents.replace ("@night@", "night");
var dest = File.new_for_path (dest_dir + "/" + version + ".xml");
yield dest.replace_contents_async (contents.data, null, false, FileCreateFlags.NONE, null, null);
}
private async void copy_file (string srcname, string destname) throws Error {
message("Saving " + srcname + " as: " + Environment.get_user_data_dir() + "/" + destname);
var src = File.new_for_path (Config.WALLPAPERS_DIR + "/" + srcname);
var dest = File.new_for_path (Environment.get_user_data_dir() + "/" + destname);
yield src.copy_async (dest, FileCopyFlags.OVERWRITE, Priority.DEFAULT_IDLE);
}
private void set_wallpaper (string filename) {
var settings = new GLib.Settings ("org.gnome.desktop.background");
settings.set_string("picture-uri", Environment.get_user_data_dir() + "/" + filename);
}
public void show_about () {
......