From b683ce2789d95b2e9f221e75adc30efd91cfb901 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Sat, 24 Jan 2015 11:03:06 +0100 Subject: Imported Upstream version 0.5.7 --- src/gui/newSliceWindow.vala | 178 ++++++++++++++++++++++---------------------- 1 file changed, 89 insertions(+), 89 deletions(-) (limited to 'src/gui/newSliceWindow.vala') diff --git a/src/gui/newSliceWindow.vala b/src/gui/newSliceWindow.vala index ade6432..92c7701 100644 --- a/src/gui/newSliceWindow.vala +++ b/src/gui/newSliceWindow.vala @@ -1,4 +1,4 @@ -/* +/* Copyright (c) 2011 by Simon Schneegans This program is free software: you can redistribute it and/or modify it @@ -12,12 +12,12 @@ 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 . +this program. If not, see . */ namespace GnomePie { -///////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////// /// A window which allows selection of a new Slice which is about to be /// added to a Pie. It can be also used to edit an existing Slice ///////////////////////////////////////////////////////////////////////// @@ -28,7 +28,7 @@ public class NewSliceWindow : GLib.Object { /// This signal gets emitted when the user confirms his selection. ///////////////////////////////////////////////////////////////////// - public signal void on_select(ActionGroup action, bool as_new_slice, int at_position); + public signal void on_select(ActionGroup action, bool as_new_slice, int at_position); ///////////////////////////////////////////////////////////////////// /// The contained list of slice types. It contains both: Groups and @@ -36,78 +36,78 @@ public class NewSliceWindow : GLib.Object { ///////////////////////////////////////////////////////////////////// private SliceTypeList slice_type_list = null; - + ///////////////////////////////////////////////////////////////////// /// The IconSelectWindow used for icon selection for a Slice. ///////////////////////////////////////////////////////////////////// - + private IconSelectWindow? icon_window = null; - + ///////////////////////////////////////////////////////////////////// /// Some widgets of this window. Loaded by a ui-builder and stored /// for later access. ///////////////////////////////////////////////////////////////////// - + private Gtk.Dialog window = null; - private Gtk.HBox name_box = null; - private Gtk.HBox command_box = null; + private Gtk.Box name_box = null; + private Gtk.Box command_box = null; private Gtk.Button icon_button = null; - private Gtk.VBox no_options_box = null; - private Gtk.HBox pie_box = null; - private Gtk.HBox hotkey_box = null; - private Gtk.HBox uri_box = null; - private Gtk.HBox quickaction_box = null; + private Gtk.Box no_options_box = null; + private Gtk.Box pie_box = null; + private Gtk.Box hotkey_box = null; + private Gtk.Box uri_box = null; + private Gtk.Box quickaction_box = null; private Gtk.Image icon = null; private Gtk.Entry name_entry = null; private Gtk.Entry command_entry = null; private Gtk.Entry uri_entry = null; private Gtk.CheckButton quickaction_checkbutton = null; - + ///////////////////////////////////////////////////////////////////// /// Two custom widgets. For Pie and hotkey selection respectively. ///////////////////////////////////////////////////////////////////// - + private PieComboList pie_select = null; private TriggerSelectButton key_select = null; - + ///////////////////////////////////////////////////////////////////// /// These members store information on the currently selected Slice. ///////////////////////////////////////////////////////////////////// - + private string current_type = ""; private string current_icon = ""; private string current_id = ""; private string current_custom_icon = ""; private string current_hotkey = ""; private string current_pie_to_open = ""; - + ///////////////////////////////////////////////////////////////////// /// The position of the edited Slice in its parent Pie. ///////////////////////////////////////////////////////////////////// - + private int slice_position = 0; - + ///////////////////////////////////////////////////////////////////// /// True, if the Slice i going to be added as a new Slice. Else it /// will edit the Slice at slice_position in its parent Pie. ///////////////////////////////////////////////////////////////////// - + private bool add_as_new_slice = true; - + ///////////////////////////////////////////////////////////////////// /// C'tor creates a new window. ///////////////////////////////////////////////////////////////////// - + public NewSliceWindow() { try { - + Gtk.Builder builder = new Gtk.Builder(); builder.add_from_file (Paths.ui_files + "/slice_select.ui"); - + this.slice_type_list = new SliceTypeList(); this.slice_type_list.on_select.connect((type, icon) => { - + this.name_box.hide(); this.command_box.hide(); this.icon_button.sensitive = false; @@ -116,9 +116,9 @@ public class NewSliceWindow : GLib.Object { this.hotkey_box.hide(); this.uri_box.hide(); this.quickaction_box.hide(); - + this.current_type = type; - + switch (type) { case "bookmarks": case "clipboard": case "devices": case "menu": case "session": case "window_list": @@ -156,101 +156,101 @@ public class NewSliceWindow : GLib.Object { break; } }); - - this.name_box = builder.get_object("name-box") as Gtk.HBox; - this.command_box = builder.get_object("command-box") as Gtk.HBox; + + this.name_box = builder.get_object("name-box") as Gtk.Box; + this.command_box = builder.get_object("command-box") as Gtk.Box; this.icon_button = builder.get_object("icon-button") as Gtk.Button; - this.no_options_box = builder.get_object("no-options-box") as Gtk.VBox; - this.pie_box = builder.get_object("pie-box") as Gtk.HBox; + this.no_options_box = builder.get_object("no-options-box") as Gtk.Box; + this.pie_box = builder.get_object("pie-box") as Gtk.Box; this.pie_select = new PieComboList(); this.pie_select.on_select.connect((id) => { this.current_pie_to_open = id; this.set_icon(PieManager.all_pies[id].icon); }); - + this.pie_box.pack_start(this.pie_select, true, true); - - this.hotkey_box = builder.get_object("hotkey-box") as Gtk.HBox; + + this.hotkey_box = builder.get_object("hotkey-box") as Gtk.Box; this.key_select = new TriggerSelectButton(false); this.hotkey_box.pack_start(this.key_select, false, true); this.key_select.on_select.connect((trigger) => { this.current_hotkey = trigger.name; }); - - this.uri_box = builder.get_object("uri-box") as Gtk.HBox; - + + this.uri_box = builder.get_object("uri-box") as Gtk.Box; + this.name_entry = builder.get_object("name-entry") as Gtk.Entry; this.uri_entry = builder.get_object("uri-entry") as Gtk.Entry; this.command_entry = builder.get_object("command-entry") as Gtk.Entry; this.quickaction_checkbutton = builder.get_object("quick-action-checkbutton") as Gtk.CheckButton; - - this.quickaction_box = builder.get_object("quickaction-box") as Gtk.HBox; - this.icon = builder.get_object("icon") as Gtk.Image; - + + this.quickaction_box = builder.get_object("quickaction-box") as Gtk.Box; + this.icon = builder.get_object("icon") as Gtk.Image; + this.icon_button.clicked.connect(on_icon_button_clicked); - + var scroll_area = builder.get_object("slice-scrolledwindow") as Gtk.ScrolledWindow; scroll_area.add(this.slice_type_list); this.window = builder.get_object("window") as Gtk.Dialog; - + (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); } - + ///////////////////////////////////////////////////////////////////// /// Sows the window on the screen. ///////////////////////////////////////////////////////////////////// - + public void show() { this.slice_type_list.select_first(); this.pie_select.select_first(); this.key_select.set_trigger(new Trigger()); this.window.show_all(); } - + ///////////////////////////////////////////////////////////////////// /// Reloads the window. ///////////////////////////////////////////////////////////////////// - + public void reload() { this.pie_select.reload(); } - + ///////////////////////////////////////////////////////////////////// /// Makes all widgets display stuff according to the given action. ///////////////////////////////////////////////////////////////////// - + public void set_action(ActionGroup group, int position) { this.set_default(group.parent_id, position); - + this.add_as_new_slice = false; string type = ""; - + if (group.get_type().depth() == 2) { var action = group.actions[0]; type = ActionRegistry.descriptions[action.get_type().name()].id; this.select_type(type); - + this.set_icon(action.icon); this.quickaction_checkbutton.active = action.is_quickaction; this.name_entry.text = action.name; - + switch (type) { case "app": this.current_custom_icon = action.icon; @@ -269,17 +269,17 @@ public class NewSliceWindow : GLib.Object { this.uri_entry.text = action.real_command; break; } - + } else { type = GroupRegistry.descriptions[group.get_type().name()].id; this.select_type(type); } } - + ///////////////////////////////////////////////////////////////////// /// Selects a default action. ///////////////////////////////////////////////////////////////////// - + public void set_default(string pie_id, int position) { this.slice_position = position; this.add_as_new_slice = true; @@ -292,25 +292,25 @@ public class NewSliceWindow : GLib.Object { this.command_entry.text = ""; this.uri_entry.text = ""; } - + ///////////////////////////////////////////////////////////////////// /// Selects a specific action type. ///////////////////////////////////////////////////////////////////// - + private void select_type(string type) { this.current_type = type; this.slice_type_list.select(type); } - + ///////////////////////////////////////////////////////////////////// /// Called, when the user presses the ok button. ///////////////////////////////////////////////////////////////////// - + private void on_ok_button_clicked() { this.window.hide(); - + ActionGroup group = null; - + switch (this.current_type) { case "bookmarks": group = new BookmarkGroup(this.current_id); break; case "clipboard": group = new ClipboardGroup(this.current_id); break; @@ -321,44 +321,44 @@ public class NewSliceWindow : GLib.Object { case "app": group = new ActionGroup(this.current_id); - group.add_action(new AppAction(this.name_entry.text, this.current_icon, - this.command_entry.text, + group.add_action(new AppAction(this.name_entry.text, this.current_icon, + this.command_entry.text, this.quickaction_checkbutton.active)); break; case "key": group = new ActionGroup(this.current_id); - group.add_action(new KeyAction(this.name_entry.text, this.current_icon, - this.current_hotkey, + group.add_action(new KeyAction(this.name_entry.text, this.current_icon, + this.current_hotkey, this.quickaction_checkbutton.active)); break; case "pie": group = new ActionGroup(this.current_id); - group.add_action(new PieAction(this.current_pie_to_open, + group.add_action(new PieAction(this.current_pie_to_open, this.quickaction_checkbutton.active)); break; case "uri": group = new ActionGroup(this.current_id); - group.add_action(new UriAction(this.name_entry.text, this.current_icon, - this.uri_entry.text, + group.add_action(new UriAction(this.name_entry.text, this.current_icon, + this.uri_entry.text, this.quickaction_checkbutton.active)); break; } - + this.on_select(group, this.add_as_new_slice, this.slice_position); } - + ///////////////////////////////////////////////////////////////////// /// Called when the user presses the cancel button. ///////////////////////////////////////////////////////////////////// - + private void on_cancel_button_clicked() { this.window.hide(); - } - + } + ///////////////////////////////////////////////////////////////////// /// Called when the user presses the icon select button. ///////////////////////////////////////////////////////////////////// - + private void on_icon_button_clicked(Gtk.Button button) { if (this.icon_window == null) { this.icon_window = new IconSelectWindow(this.window); @@ -367,30 +367,30 @@ public class NewSliceWindow : GLib.Object { this.set_icon(icon); }); } - + this.icon_window.show(); this.icon_window.set_icon(this.current_icon); } - + ///////////////////////////////////////////////////////////////////// /// Helper method which sets the icon of the icon select button. /// It assures that both can be displayed: A customly chosen image /// from or an icon from the current theme. ///////////////////////////////////////////////////////////////////// - + private void set_icon(string icon) { if (icon.contains("/")) try { - this.icon.pixbuf = new Gdk.Pixbuf.from_file_at_scale(icon, this.icon.get_pixel_size(), + this.icon.pixbuf = new Gdk.Pixbuf.from_file_at_scale(icon, this.icon.get_pixel_size(), this.icon.get_pixel_size(), true); } catch (GLib.Error error) { warning(error.message); } else this.icon.icon_name = icon; - + this.current_icon = icon; - } + } } } -- cgit v1.2.3