diff --git a/src/candy/video.vala b/src/candy/video.vala
index 82b9adf..50e62fc 100644
--- a/src/candy/video.vala
+++ b/src/candy/video.vala
@@ -1,5 +1,5 @@
namespace Deskcandy.Candy {
- class Video : BaseCandy {
+ public class Video : BaseCandy {
public bool loop { get; set; default = true; }
public double speed { get; set; default = 100.0; }
diff --git a/src/candy/xscreensaver.vala b/src/candy/xscreensaver.vala
index 140cf52..6ab177f 100644
--- a/src/candy/xscreensaver.vala
+++ b/src/candy/xscreensaver.vala
@@ -1,5 +1,5 @@
namespace Deskcandy.Candy {
- class XScreensaver : BaseCandy {
+ public class XScreensaver : BaseCandy {
public string config_path { get; private set; }
public string saver_path { get; private set; }
diff --git a/src/candy/xscreensaver_config.vala b/src/candy/xscreensaver_config.vala
index 222802c..3477b39 100644
--- a/src/candy/xscreensaver_config.vala
+++ b/src/candy/xscreensaver_config.vala
@@ -22,7 +22,7 @@ namespace Deskcandy.Candy {
tag = this.get_child("_description");
this.description = tag.text_content.strip();
- message(@"Loaded $this");
+ debug(@"Loaded $this");
}
public string to_string() {
diff --git a/src/deskcandy.gresource.xml b/src/deskcandy.gresource.xml
index e955b28..e378f95 100644
--- a/src/deskcandy.gresource.xml
+++ b/src/deskcandy.gresource.xml
@@ -4,5 +4,9 @@
window.ui
desktop_window.ui
main_menu.ui
+ editor_page.ui
+ presets_page.ui
+ screensaver_form.ui
+ video_form.ui
diff --git a/src/editor_page.ui b/src/editor_page.ui
index 7bc649e..02e9601 100644
--- a/src/editor_page.ui
+++ b/src/editor_page.ui
@@ -264,176 +264,9 @@
-
- True
- False
-
-
-
-
-
- True
- False
-
-
- True
- False
- vertical
-
-
- True
- False
- start
- video_file_filter
- Select Video
-
-
-
- False
- True
- 0
-
-
-
-
- True
- False
- 5
-
-
- True
- False
- Speed
-
-
- False
- True
- 0
-
-
-
-
- True
- True
- video_speed_adjustment
- 2
- 2
- left
-
-
-
- True
- True
- 1
-
-
-
-
- False
- True
- 1
-
-
-
-
- Loop
- True
- True
- False
- True
- True
-
-
-
- False
- True
- 2
-
-
-
-
-
100
1
10
-
-
-
-
-
-
-
-
-
-
-
-
- video/*
-
-
-
- 0.01
- 5
- 0.01
- 0.10
-
diff --git a/src/editor_page.vala b/src/editor_page.vala
new file mode 100644
index 0000000..f22c719
--- /dev/null
+++ b/src/editor_page.vala
@@ -0,0 +1,47 @@
+using Deskcandy.Candy;
+
+namespace Deskcandy {
+
+ [GtkTemplate(ui = "/moe/solarpunk/Deskcandy/editor_page.ui")]
+ public class EditorPage : Gtk.Bin {
+ public signal void preset_type_changed(string type);
+
+ [GtkChild]
+ private unowned Gtk.Stack preset_type_stack;
+
+ private new unowned Window parent;
+ private ScreensaverForm screensaver_form;
+ private VideoForm video_form;
+
+ public EditorPage(Window parent) {
+ this.parent = parent;
+
+ this.screensaver_form = new ScreensaverForm();
+ this.preset_type_stack.add_titled(screensaver_form, "screensaver", "Screen Saver");
+
+ this.video_form = new VideoForm();
+ this.preset_type_stack.add_titled(video_form, "video", "Video");
+ }
+
+ public void on_initialized(BaseCandy[] candies) {
+ // TODO: clean this up
+ this.screensaver_form.on_initialized((XScreensaver)candies[0]);
+ this.video_form.on_initialized((Video)candies[1]);
+ }
+
+ [GtkCallback]
+ private void on_preset_type_stack_visible_child_name_notify(Object o, ParamSpec param) {
+ if (this.preset_type_stack.visible_child_name == null) {
+ return;
+ }
+
+ message(@"preset type: $(this.preset_type_stack.visible_child_name)");
+ preset_type_changed(this.preset_type_stack.visible_child_name);
+ }
+
+ [GtkCallback]
+ private void on_cancel_edit_preset_button_clicked(Gtk.Widget w) {
+ this.parent.main_stack.visible_child_name = "presets";
+ }
+ }
+}
diff --git a/src/meson.build b/src/meson.build
index fe679da..f6836a3 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -3,6 +3,10 @@ deskcandy_sources = [
'window.vala',
'desktop_window.vala',
'application.vala',
+ 'editor_page.vala',
+ 'presets_page.vala',
+ 'screensaver_form.vala',
+ 'video_form.vala',
'candy/base.vala',
'candy/xscreensaver.vala',
'candy/xscreensaver_config.vala',
diff --git a/src/presets_page.vala b/src/presets_page.vala
new file mode 100644
index 0000000..225c8fd
--- /dev/null
+++ b/src/presets_page.vala
@@ -0,0 +1,44 @@
+
+namespace Deskcandy {
+ [GtkTemplate(ui = "/moe/solarpunk/Deskcandy/presets_page.ui")]
+ public class PresetsPage : Gtk.Bin {
+ private new unowned Window parent;
+
+ public PresetsPage(Window parent) {
+ this.parent = parent;
+
+ var preset_action_group = new SimpleActionGroup();
+ var create_preset = new SimpleAction("create", null);
+ preset_action_group.add_action(create_preset);
+ create_preset.activate.connect(this.on_create_preset);
+
+ var delete_preset = new SimpleAction("delete", null);
+ delete_preset.activate.connect(this.on_delete_preset);
+ preset_action_group.add_action(delete_preset);
+
+ this.insert_action_group("presets", preset_action_group);
+
+ }
+
+ private void on_create_preset(SimpleAction a, Variant? v) {
+ this.parent.main_stack.visible_child_name = "editor";
+ }
+
+ private void on_delete_preset(SimpleAction a, Variant? v) {
+ message("delete");
+ }
+
+ [GtkCallback]
+ private void on_cancel_new_preset_button_clicked(Gtk.Widget w) {
+ var popover = (Gtk.Popover)w.get_ancestor(typeof(Gtk.Popover));
+ popover.popdown();
+ this.parent.main_stack.visible_child_name = "presets";
+ }
+
+ [GtkCallback]
+ private void on_cancel_delete_preset_button_clicked(Gtk.Widget w) {
+ var popover = (Gtk.Popover)w.get_ancestor(typeof(Gtk.Popover));
+ popover.popdown();
+ }
+ }
+}
diff --git a/src/screensaver_form.ui b/src/screensaver_form.ui
new file mode 100644
index 0000000..dad534c
--- /dev/null
+++ b/src/screensaver_form.ui
@@ -0,0 +1,76 @@
+
+
+
+
+
+ True
+ False
+
+
+ True
+ False
+ vertical
+ 5
+
+
+ True
+ True
+ in
+
+
+ True
+ True
+ screensavers_liststore
+ False
+ 0
+ True
+
+
+
+ True
+ Name
+
+
+
+ 0
+
+
+
+
+
+
+ True
+ Description
+
+
+ True
+
+
+ 1
+
+
+
+
+
+
+
+
+ True
+ True
+ 1
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/screensaver_form.vala b/src/screensaver_form.vala
new file mode 100644
index 0000000..1a36345
--- /dev/null
+++ b/src/screensaver_form.vala
@@ -0,0 +1,32 @@
+using Deskcandy.Candy;
+
+namespace Deskcandy {
+ [GtkTemplate(ui = "/moe/solarpunk/Deskcandy/screensaver_form.ui")]
+ public class ScreensaverForm : Gtk.Bin {
+ [GtkChild]
+ private unowned Gtk.ListStore screensavers_liststore;
+
+ private unowned XScreensaver xss;
+
+ public void on_initialized(XScreensaver xss) {
+ this.xss = xss;
+
+ Gtk.TreeIter iter;
+ this.screensavers_liststore.clear();
+ foreach (XScreensaverConfig config in xss.configs) {
+ this.screensavers_liststore.append(out iter);
+ this.screensavers_liststore.set(iter, 0, config.label, 1, config.description, 2, config.name);
+ }
+ }
+
+ [GtkCallback]
+ private void on_screensaver_chooser_row_activated(Gtk.TreeView treeview, Gtk.TreePath path, Gtk.TreeViewColumn col) {
+ Gtk.TreeIter iter;
+ if (treeview.model.get_iter(out iter, path)) {
+ string name;
+ treeview.model.get(iter, 2, out name);
+ this.xss.name = name;
+ }
+ }
+ }
+}
diff --git a/src/video_form.ui b/src/video_form.ui
new file mode 100644
index 0000000..96bccbb
--- /dev/null
+++ b/src/video_form.ui
@@ -0,0 +1,99 @@
+
+
+
+
+
+ True
+ False
+
+
+ True
+ False
+ vertical
+
+
+ True
+ False
+ start
+ video_file_filter
+ Select Video
+
+
+
+ False
+ True
+ 0
+
+
+
+
+ True
+ False
+ 5
+
+
+ True
+ False
+ Speed
+
+
+ False
+ True
+ 0
+
+
+
+
+ True
+ True
+ video_speed_adjustment
+ 2
+ 2
+ left
+
+
+
+ True
+ True
+ 1
+
+
+
+
+ False
+ True
+ 1
+
+
+
+
+ Loop
+ True
+ True
+ False
+ True
+ True
+
+
+
+ False
+ True
+ 2
+
+
+
+
+
+
+
+ video/*
+
+
+
+ 0.01
+ 5
+ 1
+ 0.01
+ 0.10
+
+
diff --git a/src/video_form.vala b/src/video_form.vala
new file mode 100644
index 0000000..23dee4f
--- /dev/null
+++ b/src/video_form.vala
@@ -0,0 +1,27 @@
+using Deskcandy.Candy;
+
+namespace Deskcandy {
+ [GtkTemplate(ui = "/moe/solarpunk/Deskcandy/video_form.ui")]
+ public class VideoForm : Gtk.Bin {
+ [GtkChild]
+ private unowned Gtk.FileChooserButton video_chooser;
+ [GtkChild]
+ private unowned Gtk.CheckButton video_loop_checkbox;
+ [GtkChild]
+ private unowned Gtk.Range video_speed_slider;
+
+ private unowned Video video;
+
+ public void on_initialized(Video video) {
+ this.video = video;
+ }
+
+ [GtkCallback]
+ private void on_video_property_changed() {
+ this.video.name = this.video_chooser.get_filename();
+ this.video.loop = this.video_loop_checkbox.get_active();
+ this.video.speed = this.video_speed_slider.get_value();
+ }
+ }
+}
+
diff --git a/src/window.vala b/src/window.vala
index e26b6d8..35085d4 100644
--- a/src/window.vala
+++ b/src/window.vala
@@ -11,59 +11,59 @@ namespace Deskcandy {
[GtkChild]
private unowned Gtk.Bin preview;
[GtkChild]
- private unowned Gtk.Stack main_stack;
- [GtkChild]
- private unowned Gtk.Stack preset_type_stack;
+ public unowned Gtk.Stack main_stack { get; private set; }
[GtkChild]
private unowned Gtk.Label candy_status;
- [GtkChild]
- private unowned Gtk.ListStore screensavers_liststore;
- [GtkChild]
- private unowned Gtk.FileChooserButton video_chooser;
- [GtkChild]
- private unowned Gtk.CheckButton video_loop_checkbox;
- [GtkChild]
- private unowned Gtk.Range video_speed_slider;
-
private BaseCandy active_candy;
private Subprocess proc;
private XScreensaver xss;
private Video video;
+ private EditorPage editor_page;
public Window (Application app) {
Object (application: app);
- var preset_action_group = new SimpleActionGroup();
- var create_preset = new SimpleAction("create", null);
- preset_action_group.add_action(create_preset);
- create_preset.activate.connect(this.on_create_preset);
-
- var delete_preset = new SimpleAction("delete", null);
- delete_preset.activate.connect(this.on_delete_preset);
- preset_action_group.add_action(delete_preset);
-
- this.insert_action_group("presets", preset_action_group);
-
var builder = new Gtk.Builder.from_resource("/moe/solarpunk/Deskcandy/main_menu.ui");
var menu = (GLib.MenuModel)builder.get_object("main_menu");
this.open_menu_button.menu_model = menu;
app.initialized.connect(this.on_initialized);
app.notify["enabled"].connect(this.on_notify_enabled);
+
+ var presets_page = new PresetsPage(this);
+ this.main_stack.add_titled(presets_page, "presets", "Presets");
+
+ this.editor_page = new EditorPage(this);
+ this.editor_page.preset_type_changed.connect(this.on_preset_type_changed);
+ this.main_stack.add_titled(this.editor_page, "editor", "Edit Preset");
}
public void on_initialized(BaseCandy[] candies) {
this.xss = (XScreensaver)candies[0];
- Gtk.TreeIter iter;
- this.screensavers_liststore.clear();
- foreach (XScreensaverConfig config in this.xss.configs) {
- this.screensavers_liststore.append(out iter);
- this.screensavers_liststore.set(iter, 0, config.label, 1, config.description, 2, config.name);
- }
-
this.video = (Video)candies[1];
this.active_candy = this.xss;
+
+ foreach (BaseCandy candy in candies) {
+ candy.notify.connect(this.refresh_socket);
+ }
+
+ this.editor_page.on_initialized(candies);
+ }
+
+ private void on_preset_type_changed(string type) {
+ switch (type) {
+ case "video":
+ this.active_candy = this.video;
+ break;
+ case "screensaver":
+ this.active_candy = this.xss;
+ break;
+ }
+
+ if (this.active_candy.name != null && this.active_candy.name != "") {
+ this.refresh_socket();
+ }
}
private void refresh_socket() {
@@ -89,73 +89,15 @@ namespace Deskcandy {
this.application.quit();
}
- [GtkCallback]
- private void on_screensaver_chooser_row_activated(Gtk.TreeView treeview, Gtk.TreePath path, Gtk.TreeViewColumn col) {
- Gtk.TreeIter iter;
- if (treeview.model.get_iter(out iter, path)) {
- string name;
- treeview.model.get(iter, 2, out name);
- this.xss.name = name;
- this.refresh_socket();
- }
- }
-
- [GtkCallback]
- private void on_video_property_changed() {
- this.video.name = this.video_chooser.get_filename();
- this.video.loop = this.video_loop_checkbox.get_active();
- this.video.speed = this.video_speed_slider.get_value();
- this.refresh_socket();
- }
-
- private void on_create_preset(SimpleAction a, Variant? v) {
- this.main_stack.visible_child_name = "editor_page";
- }
-
- [GtkCallback]
- private void on_cancel_edit_preset_button_clicked(Gtk.Widget w) {
- this.main_stack.visible_child_name = "presets_page";
- }
-
- [GtkCallback]
- private void on_cancel_new_preset_button_clicked(Gtk.Widget w) {
- var popover = (Gtk.Popover)w.get_ancestor(typeof(Gtk.Popover));
- popover.popdown();
- this.main_stack.visible_child_name = "presets_page";
- }
-
- [GtkCallback]
- private void on_cancel_delete_preset_button_clicked(Gtk.Widget w) {
- var popover = (Gtk.Popover)w.get_ancestor(typeof(Gtk.Popover));
- popover.popdown();
- }
-
[GtkCallback]
private void on_main_stack_visible_child_name_notify(Object o, ParamSpec param) {
+ if (this.main_stack.visible_child_name == null) {
+ return;
+ }
+
message(@"page: $(this.main_stack.visible_child_name)");
}
- [GtkCallback]
- private void on_preset_type_stack_visible_child_name_notify(Object o, ParamSpec param) {
- message(@"preset type: $(this.preset_type_stack.visible_child_name)");
- switch (this.preset_type_stack.visible_child_name) {
- case "video_page":
- this.active_candy = this.video;
- break;
- case "screensaver_page":
- this.active_candy = this.xss;
- break;
- }
-
- if (this.active_candy.name != null && this.active_candy.name != "") {
- this.refresh_socket();
- }
- }
-
- private void on_delete_preset(SimpleAction a, Variant? v) {
- message("delete");
- }
-
private void on_notify_enabled(Object o, GLib.ParamSpec param) {
var val = ((Application)o).enabled;
this.candy_status.label = val ? "Candy started" : "Candy stopped";