diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2015-05-03 07:25:38 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2015-05-03 07:25:38 +0200 |
commit | daab38595df60c0ef3e142c195382cb35d448203 (patch) | |
tree | 4186938621912272570b4187a4d8ef8e3ca87b47 /src/gui | |
parent | fbd5a9eb0d29bdfd9f5f0892190452e17871afd9 (diff) | |
parent | a1c05d93bbb3c1bdb0c0fed9d7110804037cfd55 (diff) |
Merge tag 'upstream/0.6.2'
Upstream version 0.6.2
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/aboutWindow.vala | 3 | ||||
-rw-r--r-- | src/gui/newSliceWindow.vala | 2 | ||||
-rw-r--r-- | src/gui/pieList.vala | 14 | ||||
-rw-r--r-- | src/gui/pieOptionsWindow.vala (renamed from src/gui/triggerSelectWindow.vala) | 153 | ||||
-rw-r--r-- | src/gui/piePreviewAddSign.vala | 2 | ||||
-rw-r--r-- | src/gui/piePreviewDeleteSign.vala | 2 | ||||
-rw-r--r-- | src/gui/preferencesWindow.vala | 325 | ||||
-rw-r--r-- | src/gui/renameWindow.vala | 109 | ||||
-rw-r--r-- | src/gui/settingsWindow.vala | 222 | ||||
-rw-r--r-- | src/gui/sliceTypeList.vala | 9 | ||||
-rw-r--r-- | src/gui/themeList.vala | 17 | ||||
-rw-r--r-- | src/gui/triggerSelectButton.vala | 6 |
12 files changed, 356 insertions, 508 deletions
diff --git a/src/gui/aboutWindow.vala b/src/gui/aboutWindow.vala index cf1ce8a..b4d1e5e 100644 --- a/src/gui/aboutWindow.vala +++ b/src/gui/aboutWindow.vala @@ -32,7 +32,8 @@ public class AboutWindow: Gtk.AboutDialog { string[] devs = { "Simon Schneegans <code@simonschneegans.de>", "Gabriel Dubatti <gdubatti@gmail.com>", - "Francesco Piccinno <stack.box@gmail.com>" + "Francesco Piccinno <stack.box@gmail.com>", + "György Balló <ballogyor@gmail.com>" }; string[] artists = { "Simon Schneegans <code@simonschneegans.de>" diff --git a/src/gui/newSliceWindow.vala b/src/gui/newSliceWindow.vala index a17c819..6066e57 100644 --- a/src/gui/newSliceWindow.vala +++ b/src/gui/newSliceWindow.vala @@ -122,6 +122,7 @@ public class NewSliceWindow : GLib.Object { switch (type) { case "bookmarks": case "clipboard": case "devices": case "menu": case "session": case "window_list": + case "workspace_window_list": this.no_options_box.show(); this.set_icon(icon); break; @@ -318,6 +319,7 @@ public class NewSliceWindow : GLib.Object { case "menu": group = new MenuGroup(this.current_id); break; case "session": group = new SessionGroup(this.current_id); break; case "window_list": group = new WindowListGroup(this.current_id); break; + case "workspace_window_list": group = new WorkspaceWindowListGroup(this.current_id); break; case "app": group = new ActionGroup(this.current_id); diff --git a/src/gui/pieList.vala b/src/gui/pieList.vala index 29c0a1e..77f833b 100644 --- a/src/gui/pieList.vala +++ b/src/gui/pieList.vala @@ -28,6 +28,7 @@ class PieList : Gtk.TreeView { ///////////////////////////////////////////////////////////////////// public signal void on_select(string id); + public signal void on_activate(); ///////////////////////////////////////////////////////////////////// /// Stores the data internally. @@ -65,7 +66,7 @@ class PieList : Gtk.TreeView { this.data.set_sort_column_id(DataPos.NAME, Gtk.SortType.ASCENDING); this.set_model(this.data); - this.set_headers_visible(false); + this.set_headers_visible(true); this.set_grid_lines(Gtk.TreeViewGridLines.NONE); this.width_request = 170; this.set_enable_search(false); @@ -73,12 +74,14 @@ class PieList : Gtk.TreeView { this.set_events(Gdk.EventMask.POINTER_MOTION_MASK); var main_column = new Gtk.TreeViewColumn(); + main_column.title = _("Pies"); var icon_render = new Gtk.CellRendererPixbuf(); icon_render.xpad = 4; icon_render.ypad = 4; main_column.pack_start(icon_render, false); var name_render = new Gtk.CellRendererText(); + name_render.xpad = 6; name_render.ellipsize = Pango.EllipsizeMode.END; name_render.ellipsize_set = true; main_column.pack_start(name_render, true); @@ -86,7 +89,7 @@ class PieList : Gtk.TreeView { base.append_column(main_column); main_column.add_attribute(icon_render, "pixbuf", DataPos.ICON); - main_column.add_attribute(name_render, "text", DataPos.NAME); + main_column.add_attribute(name_render, "markup", DataPos.NAME); // setup drag'n'drop Gtk.TargetEntry uri_source = {"text/uri-list", 0, 0}; @@ -101,6 +104,10 @@ class PieList : Gtk.TreeView { this.last_hover = 0; }); + this.row_activated.connect(() => { + this.on_activate(); + }); + this.get_selection().changed.connect(() => { Gtk.TreeIter active; if (this.get_selection().get_selected(null, out active)) { @@ -177,7 +184,8 @@ class PieList : Gtk.TreeView { var icon = new Icon(pie.icon, 24); this.data.set(last, DataPos.ICON, icon.to_pixbuf(), DataPos.ICON_NAME, pie.icon, - DataPos.NAME, pie.name, + DataPos.NAME,GLib.Markup.escape_text(pie.name) + "\n" + + "<span font-size='x-small'>" + PieManager.get_accelerator_label_of(pie.id) + "</span>", DataPos.ID, pie.id); } } diff --git a/src/gui/triggerSelectWindow.vala b/src/gui/pieOptionsWindow.vala index 56781b4..2f9cadf 100644 --- a/src/gui/triggerSelectWindow.vala +++ b/src/gui/pieOptionsWindow.vala @@ -23,13 +23,13 @@ namespace GnomePie { /// a mouse based hotkey. ///////////////////////////////////////////////////////////////////////// -public class TriggerSelectWindow : GLib.Object { +public class PieOptionsWindow : GLib.Object { ///////////////////////////////////////////////////////////////////// /// This signal is emitted when the user selects a new hot key. ///////////////////////////////////////////////////////////////////// - public signal void on_ok(Trigger trigger); + public signal void on_ok(Trigger trigger, string pie_name, string icon_name); ///////////////////////////////////////////////////////////////////// /// Some private members which are needed by other methods. @@ -41,7 +41,13 @@ public class TriggerSelectWindow : GLib.Object { private Gtk.CheckButton centered; private Gtk.CheckButton warp; private Gtk.RadioButton rshape[10]; - private TriggerSelectButton button; + private TriggerSelectButton trigger_button; + private Gtk.Entry name_entry = null; + private Gtk.Button? icon_button = null; + private Gtk.Image? icon = null; + private Gtk.Label? pie_id = null; + + private IconSelectWindow? icon_window = null; ///////////////////////////////////////////////////////////////////// /// The currently configured trigger. @@ -58,39 +64,53 @@ public class TriggerSelectWindow : GLib.Object { private Trigger original_trigger = null; ///////////////////////////////////////////////////////////////////// + /// Stores the current icon name of the pie. + ///////////////////////////////////////////////////////////////////// + + private string icon_name = ""; + + ///////////////////////////////////////////////////////////////////// + /// Stores the id of the current pie. + ///////////////////////////////////////////////////////////////////// + + private string id = ""; + + ///////////////////////////////////////////////////////////////////// /// Radioboxes call toggled() twice per selection change. /// This flag is used to discard one of the two notifications. ///////////////////////////////////////////////////////////////////// - private static int notify_toggle= 0; + private static int notify_toggle = 0; ///////////////////////////////////////////////////////////////////// - /// C'tor, constructs a new TriggerSelectWindow. + /// C'tor, constructs a new PieOptionsWindow. ///////////////////////////////////////////////////////////////////// - public TriggerSelectWindow() { + public PieOptionsWindow() { try { Gtk.Builder builder = new Gtk.Builder(); - builder.add_from_file (Paths.ui_files + "/trigger_select.ui"); + builder.add_from_file (Paths.ui_files + "/pie_options.ui"); this.window = builder.get_object("window") as Gtk.Dialog; - this.button = new TriggerSelectButton(true); - this.button.show(); - - this.button.on_select.connect((trigger) => { - this.trigger = new Trigger.from_values(trigger.key_sym, - trigger.modifiers, - trigger.with_mouse, - this.turbo.active, - this.delayed.active, - this.centered.active, - this.warp.active, - this.get_radio_shape()); + this.trigger_button = new TriggerSelectButton(true); + this.trigger_button.show(); + + this.trigger_button.on_select.connect((trigger) => { + this.trigger = new Trigger.from_values( + trigger.key_sym, + trigger.modifiers, + trigger.with_mouse, + this.turbo.active, + this.delayed.active, + this.centered.active, + this.warp.active, + this.get_radio_shape() + ); }); - (builder.get_object("trigger-box") as Gtk.Box).pack_start(this.button, true, true); + (builder.get_object("trigger-box") as Gtk.Box).pack_start(this.trigger_button, true, true); (builder.get_object("ok-button") as Gtk.Button).clicked.connect(this.on_ok_button_clicked); (builder.get_object("cancel-button") as Gtk.Button).clicked.connect(this.on_cancel_button_clicked); @@ -112,6 +132,15 @@ public class TriggerSelectWindow : GLib.Object { this.rshape[i].toggled.connect(this.on_radio_toggled); } + this.name_entry = builder.get_object("name-entry") as Gtk.Entry; + this.name_entry.activate.connect(this.on_ok_button_clicked); + + this.pie_id = builder.get_object("pie-id") as Gtk.Label; + + this.icon = builder.get_object("icon") as Gtk.Image; + this.icon_button = builder.get_object("icon-button") as Gtk.Button; + this.icon_button.clicked.connect(on_icon_button_clicked); + this.window.delete_event.connect(this.window.hide_on_delete); } catch (GLib.Error e) { @@ -143,6 +172,9 @@ public class TriggerSelectWindow : GLib.Object { public void set_pie(string id) { var trigger = new Trigger.from_string(PieManager.get_accelerator_of(id)); + var pie = PieManager.all_pies[id]; + + this.id = id; this.turbo.active = trigger.turbo; this.delayed.active = trigger.delayed; @@ -151,8 +183,10 @@ public class TriggerSelectWindow : GLib.Object { this.set_radio_shape( trigger.shape ); this.original_trigger = trigger; this.trigger = trigger; - - this.button.set_trigger(trigger); + this.name_entry.text = PieManager.get_name_of(id); + this.pie_id.label = "Pie-ID: " + id; + this.trigger_button.set_trigger(trigger); + this.set_icon(pie.icon); } ///////////////////////////////////////////////////////////////////// @@ -160,12 +194,15 @@ public class TriggerSelectWindow : GLib.Object { ///////////////////////////////////////////////////////////////////// private void on_check_toggled() { - if (this.trigger != null) - this.trigger = new Trigger.from_values(this.trigger.key_sym, this.trigger.modifiers, - this.trigger.with_mouse, this.turbo.active, - this.delayed.active, this.centered.active, - this.warp.active, - this.get_radio_shape()); + if (this.trigger != null) { + this.trigger = new Trigger.from_values( + this.trigger.key_sym, this.trigger.modifiers, + this.trigger.with_mouse, this.turbo.active, + this.delayed.active, this.centered.active, + this.warp.active, + this.get_radio_shape() + ); + } } ///////////////////////////////////////////////////////////////////// @@ -178,9 +215,11 @@ public class TriggerSelectWindow : GLib.Object { private int get_radio_shape() { int rs; - for (rs= 0; rs < 10; rs++) - if (this.rshape[rs].active) + for (rs= 0; rs < 10; rs++) { + if (this.rshape[rs].active) { break; + } + } return rs; } @@ -190,8 +229,9 @@ public class TriggerSelectWindow : GLib.Object { ///////////////////////////////////////////////////////////////////// private void set_radio_shape(int rs) { - if (rs < 0 || rs > 9) + if (rs < 0 || rs > 9) { rs= 5; //replace invalid value with default= full pie + } this.rshape[rs].active= true; } @@ -201,8 +241,25 @@ public class TriggerSelectWindow : GLib.Object { private void on_radio_toggled() { notify_toggle= 1 - notify_toggle; - if (notify_toggle == 1) + if (notify_toggle == 1) { on_check_toggled(); //just call once + } + } + + ///////////////////////////////////////////////////////////////////// + /// Called when the icon button is clicked. + ///////////////////////////////////////////////////////////////////// + + private void on_icon_button_clicked(Gtk.Button button) { + if (this.icon_window == null) { + this.icon_window = new IconSelectWindow(this.window); + this.icon_window.on_ok.connect((icon) => { + set_icon(icon); + }); + } + + this.icon_window.show(); + this.icon_window.set_icon(this.icon_name); } ///////////////////////////////////////////////////////////////////// @@ -212,16 +269,7 @@ public class TriggerSelectWindow : GLib.Object { private void on_ok_button_clicked() { var assigned_id = PieManager.get_assigned_id(this.trigger); - if (this.trigger == this.original_trigger) { - // nothing did change - this.window.hide(); - } else if (this.trigger.key_code == this.original_trigger.key_code - && this.trigger.modifiers == this.original_trigger.modifiers - && this.trigger.with_mouse == this.original_trigger.with_mouse) { - // only turbo and/or delayed mode changed, no need to check for double assignment - this.on_ok(this.trigger); - this.window.hide(); - } else if (assigned_id != "") { + if (assigned_id != "" && assigned_id != this.id) { // it's already assigned var error = _("This hotkey is already assigned to the pie \"%s\"! \n\nPlease select " + "another one or cancel your selection.").printf(PieManager.get_name_of(assigned_id)); @@ -231,12 +279,31 @@ public class TriggerSelectWindow : GLib.Object { dialog.destroy(); } else { // a unused hot key has been chosen, great! - this.on_ok(this.trigger); + this.on_ok(this.trigger, this.name_entry.text, this.icon_name); this.window.hide(); } } ///////////////////////////////////////////////////////////////////// + /// Sets the icon of the icon_button + ///////////////////////////////////////////////////////////////////// + + private void set_icon(string name) { + this.icon_name = name; + + if (name.contains("/")) { + try { + this.icon.pixbuf = new Gdk.Pixbuf.from_file_at_scale(name, + this.icon.get_pixel_size(), this.icon.get_pixel_size(), true); + } catch (GLib.Error error) { + warning(error.message); + } + } else { + this.icon.icon_name = name; + } + } + + ///////////////////////////////////////////////////////////////////// /// Called when the cancel button is pressed. ///////////////////////////////////////////////////////////////////// diff --git a/src/gui/piePreviewAddSign.vala b/src/gui/piePreviewAddSign.vala index fb5e9fa..4a92067 100644 --- a/src/gui/piePreviewAddSign.vala +++ b/src/gui/piePreviewAddSign.vala @@ -87,7 +87,7 @@ public class PiePreviewAddSign : GLib.Object { ///////////////////////////////////////////////////////////////////// public void load() { - this.icon = new Icon("add", 36); + this.icon = new Icon("list-add", 36); } ///////////////////////////////////////////////////////////////////// diff --git a/src/gui/piePreviewDeleteSign.vala b/src/gui/piePreviewDeleteSign.vala index 6ba4dcb..a830002 100644 --- a/src/gui/piePreviewDeleteSign.vala +++ b/src/gui/piePreviewDeleteSign.vala @@ -85,7 +85,7 @@ public class PiePreviewDeleteSign : GLib.Object { ///////////////////////////////////////////////////////////////////// public void load() { - this.icon = new Icon("stock_delete", PiePreviewDeleteSign.radius*2); + this.icon = new Icon("edit-delete", PiePreviewDeleteSign.radius*2); } ///////////////////////////////////////////////////////////////////// diff --git a/src/gui/preferencesWindow.vala b/src/gui/preferencesWindow.vala index 29b5250..a1dacac 100644 --- a/src/gui/preferencesWindow.vala +++ b/src/gui/preferencesWindow.vala @@ -33,19 +33,21 @@ public class PreferencesWindow : GLib.Object { /// Some Gtk widgets used by this window. ///////////////////////////////////////////////////////////////////// + private Gtk.Stack? stack = null; + private Gtk.Notebook? notebook = null; + private Gtk.Window? window = null; - private Gtk.Label? id_label = null; - private Gtk.Label? name_label = null; - private Gtk.Label? hotkey_label = null; private Gtk.Label? no_pie_label = null; private Gtk.Label? no_slice_label = null; private Gtk.Box? preview_box = null; - private Gtk.Image? icon = null; private Gtk.EventBox? preview_background = null; - private Gtk.Button? icon_button = null; - private Gtk.Button? name_button = null; - private Gtk.Button? hotkey_button = null; - private Gtk.ToolButton? remove_pie_button = null; + private Gtk.Button? remove_pie_button = null; + private Gtk.Button? edit_pie_button = null; + + private ThemeList? theme_list = null; + private Gtk.ToggleButton? indicator = null; + private Gtk.ToggleButton? autostart = null; + private Gtk.ToggleButton? captions = null; ///////////////////////////////////////////////////////////////////// /// Some custom widgets and dialogs used by this window. @@ -53,10 +55,7 @@ public class PreferencesWindow : GLib.Object { private PiePreview? preview = null; private PieList? pie_list = null; - private SettingsWindow? settings_window = null; - private TriggerSelectWindow? trigger_window = null; - private IconSelectWindow? icon_window = null; - private RenameWindow? rename_window = null; + private PieOptionsWindow? pie_options_window = null; ///////////////////////////////////////////////////////////////////// /// C'tor, creates the window. @@ -71,14 +70,49 @@ public class PreferencesWindow : GLib.Object { Gdk.EventMask.KEY_PRESS_MASK | Gdk.EventMask.POINTER_MOTION_MASK); - var toolbar = builder.get_object ("toolbar") as Gtk.Widget; - toolbar.get_style_context().add_class("primary-toolbar"); + if (Deamon.header_bar) { + var headerbar = new Gtk.HeaderBar(); + headerbar.show_close_button = true; + headerbar.title = _("Gnome-Pie Settings"); + headerbar.subtitle = _("bake your pies!"); + window.set_titlebar(headerbar); + } + + this.notebook = builder.get_object("notebook") as Gtk.Notebook; + + if (Deamon.stack_switcher) { + var main_box = builder.get_object("main-box") as Gtk.Box; + var pie_settings = builder.get_object("pie-settings") as Gtk.Box; + var general_settings = builder.get_object("general-settings") as Gtk.Box; - var inline_toolbar = builder.get_object ("pies-toolbar") as Gtk.Widget; - inline_toolbar.get_style_context().add_class("inline-toolbar"); + pie_settings.parent.remove(pie_settings); + general_settings.parent.remove(general_settings); + + main_box.remove(this.notebook); + + Gtk.StackSwitcher switcher = new Gtk.StackSwitcher(); + switcher.margin_top = 10; + switcher.set_halign(Gtk.Align.CENTER); + main_box.pack_start(switcher, false, true, 0); + + this.stack = new Gtk.Stack(); + this.stack.transition_duration = 500; + this.stack.transition_type = Gtk.StackTransitionType.SLIDE_LEFT_RIGHT; + this.stack.homogeneous = true; + this.stack.halign = Gtk.Align.FILL; + this.stack.expand = true; + main_box.add(stack); + switcher.set_stack(stack); + + this.stack.add_with_properties(general_settings, "name", "1", "title", _("General Settings"), null); + this.stack.add_with_properties(pie_settings, "name", "2", "title", _("Pie Settings"), null); + } this.pie_list = new PieList(); this.pie_list.on_select.connect(this.on_pie_select); + this.pie_list.on_activate.connect(() => { + this.on_edit_pie_button_clicked(); + }); var scroll_area = builder.get_object("pies-scrolledwindow") as Gtk.ScrolledWindow; scroll_area.add(this.pie_list); @@ -94,29 +128,82 @@ public class PreferencesWindow : GLib.Object { preview_box = builder.get_object("preview-box") as Gtk.Box; this.preview_box.pack_start(preview, true, true); - this.id_label = builder.get_object("id-label") as Gtk.Label; - this.name_label = builder.get_object("pie-name-label") as Gtk.Label; - this.hotkey_label = builder.get_object("hotkey-label") as Gtk.Label; this.no_pie_label = builder.get_object("no-pie-label") as Gtk.Label; this.no_slice_label = builder.get_object("no-slice-label") as Gtk.Label; - this.icon = builder.get_object("icon") as Gtk.Image; this.preview_background = builder.get_object("preview-background") as Gtk.EventBox; - (builder.get_object("settings-button") as Gtk.ToolButton).clicked.connect(on_settings_button_clicked); + this.remove_pie_button = builder.get_object("remove-pie-button") as Gtk.Button; + this.remove_pie_button.clicked.connect(on_remove_pie_button_clicked); - this.hotkey_button = builder.get_object("key-button") as Gtk.Button; - this.hotkey_button.clicked.connect(on_key_button_clicked); + this.edit_pie_button = builder.get_object("edit-pie-button") as Gtk.Button; + this.edit_pie_button.clicked.connect(on_edit_pie_button_clicked); - this.icon_button = builder.get_object("icon-button") as Gtk.Button; - this.icon_button.clicked.connect(on_icon_button_clicked); + (builder.get_object("add-pie-button") as Gtk.Button).clicked.connect(on_add_pie_button_clicked); - this.name_button = builder.get_object("rename-button") as Gtk.Button; - this.name_button.clicked.connect(on_rename_button_clicked); + this.theme_list = new ThemeList(); + this.theme_list.on_select_new.connect(() => { + this.captions.active = Config.global.show_captions; + if (Config.global.theme.has_slice_captions) { + this.captions.sensitive = true; + } else { + this.captions.sensitive = false; + } + }); - this.remove_pie_button = builder.get_object("remove-pie-button") as Gtk.ToolButton; - this.remove_pie_button.clicked.connect(on_remove_pie_button_clicked); + scroll_area = builder.get_object("theme-scrolledwindow") as Gtk.ScrolledWindow; + scroll_area.add(this.theme_list); + + this.autostart = (builder.get_object("autostart-checkbox") as Gtk.ToggleButton); + this.autostart.toggled.connect(on_autostart_toggled); + + this.indicator = (builder.get_object("indicator-checkbox") as Gtk.ToggleButton); + this.indicator.toggled.connect(on_indicator_toggled); + + this.captions = (builder.get_object("captions-checkbox") as Gtk.ToggleButton); + this.captions.toggled.connect(on_captions_toggled); + + var scale_slider = (builder.get_object("scale-hscale") as Gtk.Scale); + scale_slider.set_range(0.5, 2.0); + scale_slider.set_increments(0.05, 0.25); + scale_slider.set_value(Config.global.global_scale); + + bool changing = false; + bool changed_again = false; + + scale_slider.value_changed.connect(() => { + if (!changing) { + changing = true; + Timeout.add(300, () => { + if (changed_again) { + changed_again = false; + return true; + } + + Config.global.global_scale = scale_slider.get_value(); + Config.global.load_themes(Config.global.theme.name); + changing = false; + return false; + }); + } else { + changed_again = true; + } + }); - (builder.get_object("add-pie-button") as Gtk.ToolButton).clicked.connect(on_add_pie_button_clicked); + var range_slider = (builder.get_object("range-hscale") as Gtk.Scale); + range_slider.set_range(0, 2000); + range_slider.set_increments(10, 100); + range_slider.set_value(Config.global.activation_range); + range_slider.value_changed.connect(() => { + Config.global.activation_range = (int)range_slider.get_value(); + }); + + var range_slices = (builder.get_object("range-slices") as Gtk.Scale); + range_slices.set_range(12, 96); + range_slices.set_increments(4, 12); + range_slices.set_value(Config.global.max_visible_slices); + range_slices.value_changed.connect(() => { + Config.global.max_visible_slices = (int)range_slices.get_value(); + }); this.window.hide.connect(() => { // save settings on close @@ -143,6 +230,85 @@ public class PreferencesWindow : GLib.Object { var style = this.preview_background.get_style_context(); this.preview_background.override_background_color(Gtk.StateFlags.NORMAL, style.get_background_color(Gtk.StateFlags.NORMAL)); + + this.indicator.active = Config.global.show_indicator; + this.autostart.active = Config.global.auto_start; + this.captions.active = Config.global.show_captions; + + if (Config.global.theme.has_slice_captions) { + this.captions.sensitive = true; + } else { + this.captions.sensitive = false; + } + + if (Deamon.stack_switcher) { + this.stack.set_visible_child_full("2", Gtk.StackTransitionType.NONE); + } else { + this.notebook.set_current_page(1); + } + this.pie_list.has_focus = true; + } + + ///////////////////////////////////////////////////////////////////// + /// Creates or deletes the autostart file. This code is inspired + /// by project synapse as well. + ///////////////////////////////////////////////////////////////////// + + private void on_autostart_toggled(Gtk.ToggleButton check_box) { + + bool active = check_box.active; + if (!active && FileUtils.test(Paths.autostart, FileTest.EXISTS)) { + Config.global.auto_start = false; + // delete the autostart file + FileUtils.remove (Paths.autostart); + } + else if (active && !FileUtils.test(Paths.autostart, FileTest.EXISTS)) { + Config.global.auto_start = true; + + string autostart_entry = + "#!/usr/bin/env xdg-open\n" + + "[Desktop Entry]\n" + + "Name=Gnome-Pie\n" + + "Exec=" + Paths.executable + "\n" + + "Encoding=UTF-8\n" + + "Type=Application\n" + + "X-GNOME-Autostart-enabled=true\n" + + "Icon=gnome-pie\n"; + + // create the autostart file + string autostart_dir = GLib.Path.get_dirname(Paths.autostart); + if (!FileUtils.test(autostart_dir, FileTest.EXISTS | FileTest.IS_DIR)) { + DirUtils.create_with_parents(autostart_dir, 0755); + } + + try { + FileUtils.set_contents(Paths.autostart, autostart_entry); + FileUtils.chmod(Paths.autostart, 0755); + } catch (Error e) { + var d = new Gtk.MessageDialog (this.window, 0, Gtk.MessageType.ERROR, Gtk.ButtonsType.CLOSE, + "%s", e.message); + d.run (); + d.destroy (); + } + } + } + + ///////////////////////////////////////////////////////////////////// + /// Shows or hides the indicator. + ///////////////////////////////////////////////////////////////////// + + private void on_indicator_toggled(Gtk.ToggleButton check_box) { + var check = check_box as Gtk.CheckButton; + Config.global.show_indicator = check.active; + } + + ///////////////////////////////////////////////////////////////////// + /// Shows or hides the captions of Slices. + ///////////////////////////////////////////////////////////////////// + + private void on_captions_toggled(Gtk.ToggleButton check_box) { + var check = check_box as Gtk.CheckButton; + Config.global.show_captions = check.active; } ///////////////////////////////////////////////////////////////////// @@ -156,33 +322,13 @@ public class PreferencesWindow : GLib.Object { this.no_pie_label.hide(); this.preview_box.hide(); - this.name_button.sensitive = false; - this.hotkey_button.sensitive = false; - this.icon_button.sensitive = false; this.remove_pie_button.sensitive = false; + this.edit_pie_button.sensitive = false; if (id == "") { - this.id_label.label = ""; - this.name_label.label = _("No Pie selected."); - this.hotkey_label.set_markup(""); - this.icon.icon_name = "stock_unknown"; - this.no_pie_label.show(); } else { var pie = PieManager.all_pies[selected_id]; - this.id_label.label = ("ID: %s").printf(pie.id); - this.name_label.label = PieManager.get_name_of(pie.id); - this.hotkey_label.set_markup(PieManager.get_accelerator_label_of(pie.id)); - - if (pie.icon.contains("/")) - try { - this.icon.pixbuf = new Gdk.Pixbuf.from_file_at_scale(pie.icon, - this.icon.get_pixel_size(), this.icon.get_pixel_size(), true); - } catch (GLib.Error error) { - warning(error.message); - } - else - this.icon.icon_name = pie.icon; this.preview.set_pie(id); this.preview_box.show(); @@ -191,10 +337,8 @@ public class PreferencesWindow : GLib.Object { this.no_slice_label.show(); } - this.name_button.sensitive = true; - this.hotkey_button.sensitive = true; - this.icon_button.sensitive = true; this.remove_pie_button.sensitive = true; + this.edit_pie_button.sensitive = true; } } @@ -202,17 +346,19 @@ public class PreferencesWindow : GLib.Object { /// Called when the add Pie button is clicked. ///////////////////////////////////////////////////////////////////// - private void on_add_pie_button_clicked(Gtk.ToolButton button) { + private void on_add_pie_button_clicked(Gtk.Button button) { var new_pie = PieManager.create_persistent_pie(_("New Pie"), "stock_unknown", null); this.pie_list.reload_all(); this.pie_list.select(new_pie.id); + + this.on_edit_pie_button_clicked(); } ///////////////////////////////////////////////////////////////////// /// Called when the remove Pie button is clicked. ///////////////////////////////////////////////////////////////////// - private void on_remove_pie_button_clicked(Gtk.ToolButton button) { + private void on_remove_pie_button_clicked(Gtk.Button button) { if (this.selected_id != "") { var dialog = new Gtk.MessageDialog((Gtk.Window)this.window.get_toplevel(), Gtk.DialogFlags.MODAL, Gtk.MessageType.QUESTION, Gtk.ButtonsType.YES_NO, @@ -232,74 +378,25 @@ public class PreferencesWindow : GLib.Object { } ///////////////////////////////////////////////////////////////////// - /// Called when rename Pie button is clicked. + /// Called when the edit pie button is clicked. ///////////////////////////////////////////////////////////////////// - private void on_rename_button_clicked(Gtk.Button button) { - if (this.rename_window == null) { - this.rename_window = new RenameWindow(); - this.rename_window.set_parent(window); - this.rename_window.on_ok.connect((name) => { + private void on_edit_pie_button_clicked(Gtk.Button? button = null) { + if (this.pie_options_window == null) { + this.pie_options_window = new PieOptionsWindow(); + this.pie_options_window.set_parent(window); + this.pie_options_window.on_ok.connect((trigger, name, icon) => { var pie = PieManager.all_pies[selected_id]; pie.name = name; - PieManager.create_launcher(pie.id); - this.name_label.label = name; - this.pie_list.reload_all(); - }); - } - - this.rename_window.set_pie(selected_id); - this.rename_window.show(); - } - - ///////////////////////////////////////////////////////////////////// - /// Called when the hotkey button is clicked. - ///////////////////////////////////////////////////////////////////// - - private void on_key_button_clicked(Gtk.Button button) { - if (this.trigger_window == null) { - this.trigger_window = new TriggerSelectWindow(); - this.trigger_window.set_parent(window); - this.trigger_window.on_ok.connect((trigger) => { - PieManager.bind_trigger(trigger, selected_id); - this.hotkey_label.set_markup(trigger.label_with_specials); - }); - } - - this.trigger_window.set_pie(selected_id); - this.trigger_window.show(); - } - - ///////////////////////////////////////////////////////////////////// - /// Called when the general settings button is clicked. - ///////////////////////////////////////////////////////////////////// - - private void on_settings_button_clicked(Gtk.ToolButton button) { - if (this.settings_window == null) { - this.settings_window = new SettingsWindow(); - this.settings_window.set_parent(this.window.get_toplevel() as Gtk.Window); - } - - this.settings_window.show(); - } - - ///////////////////////////////////////////////////////////////////// - /// Called when the icon button is clicked. - ///////////////////////////////////////////////////////////////////// - - private void on_icon_button_clicked(Gtk.Button button) { - if (this.icon_window == null) { - this.icon_window = new IconSelectWindow(this.window); - this.icon_window.on_ok.connect((icon) => { - var pie = PieManager.all_pies[selected_id]; pie.icon = icon; + PieManager.bind_trigger(trigger, selected_id); PieManager.create_launcher(pie.id); this.pie_list.reload_all(); }); } - this.icon_window.show(); - this.icon_window.set_icon(PieManager.all_pies[selected_id].icon); + this.pie_options_window.set_pie(selected_id); + this.pie_options_window.show(); } } diff --git a/src/gui/renameWindow.vala b/src/gui/renameWindow.vala deleted file mode 100644 index de65069..0000000 --- a/src/gui/renameWindow.vala +++ /dev/null @@ -1,109 +0,0 @@ -///////////////////////////////////////////////////////////////////////// -// Copyright (c) 2011-2015 by Simon Schneegans -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or (at -// your option) any later version. -// -// This program is distributed in the hope that it will be useful, but -// WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see <http://www.gnu.org/licenses/>. -///////////////////////////////////////////////////////////////////////// - -namespace GnomePie { - -///////////////////////////////////////////////////////////////////////// -/// A window which allows selection of a new name for a Pie. -///////////////////////////////////////////////////////////////////////// - -public class RenameWindow : GLib.Object { - - ///////////////////////////////////////////////////////////////////// - /// Gets emitted when the user selects a new name. - ///////////////////////////////////////////////////////////////////// - - public signal void on_ok(string new_name); - - ///////////////////////////////////////////////////////////////////// - /// Some Widgets used by this dialog. - ///////////////////////////////////////////////////////////////////// - - private Gtk.Dialog window = null; - private Gtk.Entry entry = null; - - ///////////////////////////////////////////////////////////////////// - /// C'tor, constructs the Widget. - ///////////////////////////////////////////////////////////////////// - - public RenameWindow() { - try { - - Gtk.Builder builder = new Gtk.Builder(); - - builder.add_from_file (Paths.ui_files + "/rename_pie.ui"); - - window = builder.get_object("window") as Gtk.Dialog; - entry = builder.get_object("name-entry") as Gtk.Entry; - - entry.activate.connect(this.on_ok_button_clicked); - - (builder.get_object("ok-button") as Gtk.Button).clicked.connect(on_ok_button_clicked); - (builder.get_object("cancel-button") as Gtk.Button).clicked.connect(on_cancel_button_clicked); - - this.window.delete_event.connect(this.window.hide_on_delete); - - } catch (GLib.Error e) { - error("Could not load UI: %s\n", e.message); - } - } - - ///////////////////////////////////////////////////////////////////// - /// Sets the parent window, in order to make this window stay in - /// front. - ///////////////////////////////////////////////////////////////////// - - public void set_parent(Gtk.Window parent) { - this.window.set_transient_for(parent); - } - - ///////////////////////////////////////////////////////////////////// - /// Displays the window on the screen. - ///////////////////////////////////////////////////////////////////// - - public void show() { - this.window.show_all(); - this.entry.is_focus = true; - } - - ///////////////////////////////////////////////////////////////////// - /// Make the text entry display the name of the Pie with given ID. - ///////////////////////////////////////////////////////////////////// - - public void set_pie(string id) { - entry.text = PieManager.get_name_of(id); - } - - ///////////////////////////////////////////////////////////////////// - /// Called when the ok button is pressed. - ///////////////////////////////////////////////////////////////////// - - private void on_ok_button_clicked() { - this.on_ok(entry.text); - this.window.hide(); - } - - ///////////////////////////////////////////////////////////////////// - /// Called when the cancel button is pressed. - ///////////////////////////////////////////////////////////////////// - - private void on_cancel_button_clicked() { - this.window.hide(); - } -} - -} diff --git a/src/gui/settingsWindow.vala b/src/gui/settingsWindow.vala deleted file mode 100644 index 6bb10c1..0000000 --- a/src/gui/settingsWindow.vala +++ /dev/null @@ -1,222 +0,0 @@ -///////////////////////////////////////////////////////////////////////// -// Copyright (c) 2011-2015 by Simon Schneegans -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or (at -// your option) any later version. -// -// This program is distributed in the hope that it will be useful, but -// WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see <http://www.gnu.org/licenses/>. -///////////////////////////////////////////////////////////////////////// - -namespace GnomePie { - -///////////////////////////////////////////////////////////////////////// -/// The settings menu of Gnome-Pie, with options for theme switching and -/// some general options. -///////////////////////////////////////////////////////////////////////// - -public class SettingsWindow : GLib.Object { - - ///////////////////////////////////////////////////////////////////// - /// Some widgets. - ///////////////////////////////////////////////////////////////////// - - private Gtk.Dialog? window = null; - private ThemeList? theme_list = null; - private Gtk.ToggleButton? indicator = null; - private Gtk.ToggleButton? autostart = null; - private Gtk.ToggleButton? captions = null; - - ///////////////////////////////////////////////////////////////////// - /// C'tor creates, the dialog. - ///////////////////////////////////////////////////////////////////// - - public SettingsWindow() { - try { - - Gtk.Builder builder = new Gtk.Builder(); - - builder.add_from_file (Paths.ui_files + "/settings.ui"); - - this.window = builder.get_object("window") as Gtk.Dialog; - - this.theme_list = new ThemeList(); - this.theme_list.on_select_new.connect(() => { - this.captions.active = Config.global.show_captions; - if (Config.global.theme.has_slice_captions) { - this.captions.sensitive = true; - } else { - this.captions.sensitive = false; - } - }); - - var scroll_area = builder.get_object("theme-scrolledwindow") as Gtk.ScrolledWindow; - scroll_area.add(this.theme_list); - - (builder.get_object("close-button") as Gtk.Button).clicked.connect(on_close_button_clicked); - - this.autostart = (builder.get_object("autostart-checkbox") as Gtk.ToggleButton); - this.autostart.toggled.connect(on_autostart_toggled); - - this.indicator = (builder.get_object("indicator-checkbox") as Gtk.ToggleButton); - this.indicator.toggled.connect(on_indicator_toggled); - - this.captions = (builder.get_object("captions-checkbox") as Gtk.ToggleButton); - this.captions.toggled.connect(on_captions_toggled); - - var scale_slider = (builder.get_object("scale-hscale") as Gtk.Scale); - scale_slider.set_range(0.5, 2.0); - scale_slider.set_increments(0.05, 0.25); - scale_slider.set_value(Config.global.global_scale); - - bool changing = false; - bool changed_again = false; - - scale_slider.value_changed.connect(() => { - if (!changing) { - changing = true; - Timeout.add(300, () => { - if (changed_again) { - changed_again = false; - return true; - } - - Config.global.global_scale = scale_slider.get_value(); - Config.global.load_themes(Config.global.theme.name); - changing = false; - return false; - }); - } else { - changed_again = true; - } - }); - - var range_slider = (builder.get_object("range-hscale") as Gtk.Scale); - range_slider.set_range(0, 2000); - range_slider.set_increments(10, 100); - range_slider.set_value(Config.global.activation_range); - range_slider.value_changed.connect(() => { - Config.global.activation_range = (int)range_slider.get_value(); - }); - - var range_slices = (builder.get_object("range-slices") as Gtk.Scale); - range_slices.set_range(12, 96); - range_slices.set_increments(4, 12); - range_slices.set_value(Config.global.max_visible_slices); - range_slices.value_changed.connect(() => { - Config.global.max_visible_slices = (int)range_slices.get_value(); - }); - - this.window.delete_event.connect(this.window.hide_on_delete); - - } catch (GLib.Error e) { - error("Could not load UI: %s\n", e.message); - } - } - - ///////////////////////////////////////////////////////////////////// - /// Sets the parent window, in order to make this window stay in - /// front. - ///////////////////////////////////////////////////////////////////// - - public void set_parent(Gtk.Window parent) { - this.window.set_transient_for(parent); - } - - ///////////////////////////////////////////////////////////////////// - /// Displays the window on the screen. - ///////////////////////////////////////////////////////////////////// - - public void show() { - this.indicator.active = Config.global.show_indicator; - this.autostart.active = Config.global.auto_start; - this.captions.active = Config.global.show_captions; - - if (Config.global.theme.has_slice_captions) { - this.captions.sensitive = true; - } else { - this.captions.sensitive = false; - } - - this.window.show_all(); - } - - ///////////////////////////////////////////////////////////////////// - /// Called when the close button is clicked. - ///////////////////////////////////////////////////////////////////// - - private void on_close_button_clicked() { - this.window.hide(); - } - - ///////////////////////////////////////////////////////////////////// - /// Creates or deletes the autostart file. This code is inspired - /// by project synapse as well. - ///////////////////////////////////////////////////////////////////// - - private void on_autostart_toggled(Gtk.ToggleButton check_box) { - - bool active = check_box.active; - if (!active && FileUtils.test(Paths.autostart, FileTest.EXISTS)) { - Config.global.auto_start = false; - // delete the autostart file - FileUtils.remove (Paths.autostart); - } - else if (active && !FileUtils.test(Paths.autostart, FileTest.EXISTS)) { - Config.global.auto_start = true; - - string autostart_entry = - "#!/usr/bin/env xdg-open\n" + - "[Desktop Entry]\n" + - "Name=Gnome-Pie\n" + - "Exec=" + Paths.executable + "\n" + - "Encoding=UTF-8\n" + - "Type=Application\n" + - "X-GNOME-Autostart-enabled=true\n" + - "Icon=gnome-pie\n"; - - // create the autostart file - string autostart_dir = GLib.Path.get_dirname(Paths.autostart); - if (!FileUtils.test(autostart_dir, FileTest.EXISTS | FileTest.IS_DIR)) { - DirUtils.create_with_parents(autostart_dir, 0755); - } - - try { - FileUtils.set_contents(Paths.autostart, autostart_entry); - FileUtils.chmod(Paths.autostart, 0755); - } catch (Error e) { - var d = new Gtk.MessageDialog (this.window, 0, Gtk.MessageType.ERROR, Gtk.ButtonsType.CLOSE, - "%s", e.message); - d.run (); - d.destroy (); - } - } - } - - ///////////////////////////////////////////////////////////////////// - /// Shows or hides the indicator. - ///////////////////////////////////////////////////////////////////// - - private void on_indicator_toggled(Gtk.ToggleButton check_box) { - var check = check_box as Gtk.CheckButton; - Config.global.show_indicator = check.active; - } - - ///////////////////////////////////////////////////////////////////// - /// Shows or hides the captions of Slices. - ///////////////////////////////////////////////////////////////////// - - private void on_captions_toggled(Gtk.ToggleButton check_box) { - var check = check_box as Gtk.CheckButton; - Config.global.show_captions = check.active; - } -} - -} diff --git a/src/gui/sliceTypeList.vala b/src/gui/sliceTypeList.vala index e164dea..1a9ecc4 100644 --- a/src/gui/sliceTypeList.vala +++ b/src/gui/sliceTypeList.vala @@ -62,6 +62,7 @@ class SliceTypeList : Gtk.TreeView { main_column.pack_start(icon_render, false); var name_render = new Gtk.CellRendererText(); + name_render.xpad = 6; main_column.pack_start(name_render, true); base.append_column(main_column); @@ -103,8 +104,8 @@ class SliceTypeList : Gtk.TreeView { var icon = new Icon(description.icon, 36); data.set(current, DataPos.ICON, icon.to_pixbuf()); data.set(current, DataPos.ICON_NAME, description.icon); - data.set(current, DataPos.NAME, "<b>" + GLib.Markup.escape_text(description.name) + "</b>\n" - + "<small>" + GLib.Markup.escape_text(description.description) + "</small>"); + data.set(current, DataPos.NAME, GLib.Markup.escape_text(description.name) + "\n" + + "<span font-size='x-small'>" + GLib.Markup.escape_text(description.description) + "</span>"); data.set(current, DataPos.ID, description.id); } @@ -116,8 +117,8 @@ class SliceTypeList : Gtk.TreeView { var icon = new Icon(description.icon, 36); data.set(current, DataPos.ICON, icon.to_pixbuf()); data.set(current, DataPos.ICON_NAME, description.icon); - data.set(current, DataPos.NAME, "<b>" + GLib.Markup.escape_text(description.name) + "</b>\n" - + "<small>" + GLib.Markup.escape_text(description.description) + "</small>"); + data.set(current, DataPos.NAME, GLib.Markup.escape_text(description.name) + "\n" + + "<span font-size='x-small'>" + GLib.Markup.escape_text(description.description) + "</span>"); data.set(current, DataPos.ID, description.id); } diff --git a/src/gui/themeList.vala b/src/gui/themeList.vala index 4173819..517c6d5 100644 --- a/src/gui/themeList.vala +++ b/src/gui/themeList.vala @@ -62,15 +62,18 @@ class ThemeList : Gtk.TreeView { main_column.title = _("Themes"); main_column.set_sizing(Gtk.TreeViewColumnSizing.FIXED); var icon_render = new Gtk.CellRendererPixbuf(); + icon_render.xpad = 4; + icon_render.ypad = 4; main_column.pack_start(icon_render, false); - var theme_render = new Gtk.CellRendererText(); - main_column.pack_start(theme_render, true); + var name_render = new Gtk.CellRendererText(); + name_render.xpad = 6; + main_column.pack_start(name_render, true); this.append_column(main_column); main_column.add_attribute(icon_render, "pixbuf", DataPos.ICON); - main_column.add_attribute(theme_render, "markup", DataPos.NAME); + main_column.add_attribute(name_render, "markup", DataPos.NAME); this.get_selection().changed.connect(() => { Gtk.TreeIter active; @@ -94,10 +97,10 @@ class ThemeList : Gtk.TreeView { Gtk.TreeIter current; data.append(out current); data.set(current, DataPos.ICON, theme.preview_icon.to_pixbuf()); - data.set(current, DataPos.NAME, "<b>"+GLib.Markup.escape_text(theme.name)+"</b><small> - " - +GLib.Markup.escape_text(theme.description)+"\n" - +"<i>"+GLib.Markup.escape_text(_("By")+" "+theme.author) - +"</i></small>"); + data.set(current, DataPos.NAME, GLib.Markup.escape_text(theme.name)+"\n" + + "<span font-size='x-small'>" + GLib.Markup.escape_text(theme.description) + + " - <i>"+GLib.Markup.escape_text(_("By")+" "+theme.author) + + "</i></span>"); if(theme == Config.global.theme) get_selection().select_iter(current); } diff --git a/src/gui/triggerSelectButton.vala b/src/gui/triggerSelectButton.vala index 92cd8a3..eb34066 100644 --- a/src/gui/triggerSelectButton.vala +++ b/src/gui/triggerSelectButton.vala @@ -48,9 +48,9 @@ public class TriggerSelectButton : Gtk.ToggleButton { ///////////////////////////////////////////////////////////////////// private Gdk.ModifierType lock_modifiers = Gdk.ModifierType.MOD2_MASK - |Gdk.ModifierType.SUPER_MASK - |Gdk.ModifierType.LOCK_MASK - |Gdk.ModifierType.MOD5_MASK; + |Gdk.ModifierType.MOD4_MASK + |Gdk.ModifierType.MOD5_MASK + |Gdk.ModifierType.LOCK_MASK; ///////////////////////////////////////////////////////////////////// /// C'tor, constructs a new TriggerSelectWindow. |