Compare commits
3 commits
64ba90c802
...
708caa431f
Author | SHA1 | Date | |
---|---|---|---|
708caa431f | |||
568db5e8dd | |||
eb186056bd |
7 changed files with 61 additions and 21 deletions
|
@ -39,10 +39,12 @@ namespace Deskcandy {
|
||||||
private void set_up_actions() {
|
private void set_up_actions() {
|
||||||
var a_about = new SimpleAction("about", null);
|
var a_about = new SimpleAction("about", null);
|
||||||
a_about.activate.connect((widget) => {
|
a_about.activate.connect((widget) => {
|
||||||
|
message("about...");
|
||||||
var about_dialog = new Gtk.AboutDialog();
|
var about_dialog = new Gtk.AboutDialog();
|
||||||
about_dialog.destroy_with_parent = true;
|
about_dialog.destroy_with_parent = true;
|
||||||
about_dialog.transient_for = this.window;
|
about_dialog.transient_for = this.window;
|
||||||
about_dialog.modal = true;
|
about_dialog.modal = true;
|
||||||
|
about_dialog.present();
|
||||||
});
|
});
|
||||||
this.add_action(a_about);
|
this.add_action(a_about);
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
namespace Deskcandy.Candy {
|
namespace Deskcandy.Candy {
|
||||||
public abstract class BaseCandy : Object {
|
public abstract class BaseCandy : Object {
|
||||||
|
public string name { get; set; }
|
||||||
|
|
||||||
protected BaseCandy() {
|
protected BaseCandy() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract async void initialize() throws Error;
|
public abstract async void initialize() throws Error;
|
||||||
|
|
||||||
public abstract Subprocess launch(uint socket_id, string path) throws Error;
|
public abstract Subprocess launch(uint socket_id) throws Error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,9 +6,9 @@ namespace Deskcandy.Candy {
|
||||||
public override async void initialize() throws Error {
|
public override async void initialize() throws Error {
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Subprocess launch(uint socket_id, string path) throws Error {
|
public override Subprocess launch(uint socket_id) throws Error {
|
||||||
message("Launching mpv video...");
|
message("Launching mpv video...");
|
||||||
return new Subprocess(SubprocessFlags.NONE, "mpv", @"--wid=$socket_id", "--no-audio", "--video-unscaled=downscale-big", "--video-zoom=20", path);
|
return new Subprocess(SubprocessFlags.NONE, "mpv", @"--wid=$socket_id", "--no-audio", "--video-unscaled=downscale-big", "--video-zoom=20", this.name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,9 +28,9 @@ namespace Deskcandy.Candy {
|
||||||
message(@"Found $(this.configs.length()) screensavers.");
|
message(@"Found $(this.configs.length()) screensavers.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Subprocess launch(uint socket_id, string saver) throws Error {
|
public override Subprocess launch(uint socket_id) throws Error {
|
||||||
message("Launching XScreensaver...");
|
message("Launching XScreensaver...");
|
||||||
return new Subprocess(SubprocessFlags.NONE, @"$(this.saver_path)/$saver", "-window-id", socket_id.to_string());
|
return new Subprocess(SubprocessFlags.NONE, @"$(this.saver_path)/$(this.name)", "-window-id", socket_id.to_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void hacky_determine_directories() {
|
private async void hacky_determine_directories() {
|
||||||
|
|
|
@ -28,7 +28,7 @@ namespace Deskcandy {
|
||||||
this.visible = true;
|
this.visible = true;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this.proc = candy.launch((uint)this.socket.get_id(), "unknownpleasures");
|
//this.proc = candy.launch((uint)this.socket.get_id());
|
||||||
} catch (Error e) {
|
} catch (Error e) {
|
||||||
error(e.message);
|
error(e.message);
|
||||||
}
|
}
|
||||||
|
|
|
@ -314,7 +314,8 @@
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can-focus">False</property>
|
<property name="can-focus">False</property>
|
||||||
<property name="margin-end">5</property>
|
<property name="margin-end">5</property>
|
||||||
<property name="transition-type">slide-left-right</property>
|
<property name="transition-type">over-up-down</property>
|
||||||
|
<signal name="notify::visible-child-name" handler="on_main_stack_visible_child_name_notify" swapped="no"/>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkBox" id="presets_page">
|
<object class="GtkBox" id="presets_page">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
|
@ -579,6 +580,7 @@
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can-focus">False</property>
|
<property name="can-focus">False</property>
|
||||||
<property name="transition-type">slide-left-right</property>
|
<property name="transition-type">slide-left-right</property>
|
||||||
|
<signal name="notify::visible-child-name" handler="on_preset_type_stack_visible_child_name_notify" swapped="no"/>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkBox">
|
<object class="GtkBox">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
|
@ -649,6 +651,7 @@
|
||||||
<property name="valign">start</property>
|
<property name="valign">start</property>
|
||||||
<property name="filter">video_file_filter</property>
|
<property name="filter">video_file_filter</property>
|
||||||
<property name="title" translatable="yes">Select Video</property>
|
<property name="title" translatable="yes">Select Video</property>
|
||||||
|
<signal name="file-set" handler="on_video_chooser_file_set" swapped="no"/>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="name">video_page</property>
|
<property name="name">video_page</property>
|
||||||
|
|
|
@ -13,13 +13,18 @@ namespace Deskcandy {
|
||||||
[GtkChild]
|
[GtkChild]
|
||||||
private unowned Gtk.Stack main_stack;
|
private unowned Gtk.Stack main_stack;
|
||||||
[GtkChild]
|
[GtkChild]
|
||||||
|
private unowned Gtk.Stack preset_type_stack;
|
||||||
|
[GtkChild]
|
||||||
private unowned Gtk.Label candy_status;
|
private unowned Gtk.Label candy_status;
|
||||||
|
|
||||||
[GtkChild]
|
[GtkChild]
|
||||||
private unowned Gtk.ListStore screensavers_liststore;
|
private unowned Gtk.ListStore screensavers_liststore;
|
||||||
|
[GtkChild]
|
||||||
|
private unowned Gtk.FileChooserButton video_chooser;
|
||||||
|
|
||||||
|
private BaseCandy active_candy;
|
||||||
private Subprocess proc;
|
private Subprocess proc;
|
||||||
private XScreensaver xss;
|
private XScreensaver xss;
|
||||||
|
private Video video;
|
||||||
|
|
||||||
public Window (Application app) {
|
public Window (Application app) {
|
||||||
Object (application: app);
|
Object (application: app);
|
||||||
|
@ -44,20 +49,19 @@ namespace Deskcandy {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void on_initialized(BaseCandy[] candies) {
|
public void on_initialized(BaseCandy[] candies) {
|
||||||
foreach (BaseCandy candy in candies) {
|
this.xss = (XScreensaver)candies[0];
|
||||||
if (candy is XScreensaver) {
|
|
||||||
this.xss = (XScreensaver)candy;
|
|
||||||
Gtk.TreeIter iter;
|
Gtk.TreeIter iter;
|
||||||
this.screensavers_liststore.clear();
|
this.screensavers_liststore.clear();
|
||||||
foreach (XScreensaverConfig config in this.xss.configs) {
|
foreach (XScreensaverConfig config in this.xss.configs) {
|
||||||
this.screensavers_liststore.append(out iter);
|
this.screensavers_liststore.append(out iter);
|
||||||
this.screensavers_liststore.set(iter, 0, config.label, 1, config.description, 2, config.name);
|
this.screensavers_liststore.set(iter, 0, config.label, 1, config.description, 2, config.name);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
this.video = (Video)candies[1];
|
||||||
|
this.active_candy = this.xss;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void refresh_socket(BaseCandy candy, string name) {
|
private void refresh_socket() {
|
||||||
if (this.socket != null) {
|
if (this.socket != null) {
|
||||||
this.preview.remove(this.socket);
|
this.preview.remove(this.socket);
|
||||||
this.proc.send_signal(15);
|
this.proc.send_signal(15);
|
||||||
|
@ -68,7 +72,7 @@ namespace Deskcandy {
|
||||||
this.preview.add(this.socket);
|
this.preview.add(this.socket);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this.proc = candy.launch((uint)this.socket.get_id(), name);
|
this.proc = this.active_candy.launch((uint)this.socket.get_id());
|
||||||
} catch (Error e) {
|
} catch (Error e) {
|
||||||
error(e.message);
|
error(e.message);
|
||||||
}
|
}
|
||||||
|
@ -86,10 +90,17 @@ namespace Deskcandy {
|
||||||
if (treeview.model.get_iter(out iter, path)) {
|
if (treeview.model.get_iter(out iter, path)) {
|
||||||
string name;
|
string name;
|
||||||
treeview.model.get(iter, 2, out name);
|
treeview.model.get(iter, 2, out name);
|
||||||
this.refresh_socket(this.xss, name);
|
this.xss.name = name;
|
||||||
|
this.refresh_socket();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[GtkCallback]
|
||||||
|
private void on_video_chooser_file_set() {
|
||||||
|
this.video.name = this.video_chooser.get_filename();
|
||||||
|
this.refresh_socket();
|
||||||
|
}
|
||||||
|
|
||||||
private void on_create_preset(SimpleAction a, Variant? v) {
|
private void on_create_preset(SimpleAction a, Variant? v) {
|
||||||
this.main_stack.visible_child_name = "editor_page";
|
this.main_stack.visible_child_name = "editor_page";
|
||||||
}
|
}
|
||||||
|
@ -112,6 +123,28 @@ namespace Deskcandy {
|
||||||
popover.popdown();
|
popover.popdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[GtkCallback]
|
||||||
|
private void on_main_stack_visible_child_name_notify(Object o, ParamSpec param) {
|
||||||
|
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) {
|
private void on_delete_preset(SimpleAction a, Variant? v) {
|
||||||
message("delete");
|
message("delete");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue