diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2016-09-22 19:16:49 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2016-09-22 19:16:49 +0200 |
commit | c59cef2ee7de5c2dc882c496deb569affb03bad8 (patch) | |
tree | dacf15d7bbedfe397a60387fde1dda3fbd68d92e | |
parent | 5e23ab97cea2ac130e20ac46911cab0d9356f33d (diff) | |
parent | 45a3d7f0e2783d9898f017772583d31c1c9e0f03 (diff) |
Merge tag 'upstream/0.7.0'
Upstream version 0.7.0
-rw-r--r-- | CMakeLists.txt | 16 | ||||
-rw-r--r-- | resources/ui/slice_select.ui | 78 | ||||
-rw-r--r-- | src/actionGroups/windowListGroup.vala | 9 | ||||
-rw-r--r-- | src/daemon.vala | 2 | ||||
-rw-r--r-- | src/gui/commandComboList.vala | 120 | ||||
-rw-r--r-- | src/gui/newSliceWindow.vala | 17 | ||||
-rw-r--r-- | src/gui/piePreview.vala | 13 | ||||
-rw-r--r-- | src/utilities/bindingManager.vala | 79 |
8 files changed, 225 insertions, 109 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index b2696ab..c5e5fa5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,7 +35,6 @@ pkg_check_modules(X11 REQUIRED x11) pkg_check_modules(XML REQUIRED libxml-2.0) pkg_check_modules(XTST REQUIRED xtst) pkg_check_modules(GMENU3 libgnome-menu-3.0) -pkg_check_modules(BAMF libbamf3) find_library(M_LIB m) find_library(GTHREAD_LIB gthread-2.0) @@ -54,11 +53,6 @@ set(CFLAGS # -g ) -# use bamf if available for better icon handling -if (${BAMF_FOUND}) - LIST(APPEND CFLAGS -DHAVE_BAMF) -endif (${BAMF_FOUND}) - # fallback to gnome-menus2 if gnome-menus3 wasn't found if (${GMENU3_FOUND}) LIST(APPEND CFLAGS -DHAVE_GMENU_3) @@ -89,7 +83,6 @@ set(LIBS ${GMENU3_LIBRARIES} ${X11_LIBRARIES} ${WNCK_LIBRARIES} - ${BAMF_LIBRARIES} ${ARCHIVE_LIB} ${M_LIB} ${GTHREAD_LIB} @@ -109,7 +102,6 @@ set(LIB_PATHS ${GMENU3_LIBRARY_DIRS} ${X11_LIBRARY_DIRS} ${WNCK_LIBRARY_DIRS} - ${BAMF_LIBRARY_DIRS} ) link_directories(${LIB_PATHS}) @@ -125,8 +117,7 @@ set(INCLUDE_PATHS ${GMENU_INCLUDE_DIRS} ${GMENU3_INCLUDE_DIRS} ${X11_INCLUDE_DIRS} - ${BAMF_INCLUDE_DIRS} - ${WNCK_INCLUDE_DIRS} + ${WNCK_INCLUDE_DIRS} ) include_directories(${INCLUDE_PATHS}) @@ -150,10 +141,6 @@ set(VALA_PKGS libarchive ) -if (${BAMF_FOUND}) - LIST(APPEND VALA_PKGS libbamf3) -endif (${BAMF_FOUND}) - if (${INDICATOR_FOUND}) LIST(APPEND VALA_PKGS appindicator-0.1) endif (${INDICATOR_FOUND}) @@ -201,7 +188,6 @@ message( " XTST_LIBRARIES = ${XTST_LIBRARIES}" ) message( " GMENU_LIBRARIES = ${GMENU_LIBRARIES}" ) message( " GMENU3_LIBRARIES = ${GMENU3_LIBRARIES}" ) message( " X11_LIBRARIES = ${X11_LIBRARIES}" ) -message( " BAMF_LIBRARIES = ${BAMF_LIBRARIES}" ) message( " WNCK_LIBRARIES = ${WNCK_LIBRARIES}" ) message( " ARCHIVE_LIBRARIES = ${ARCHIVE_LIB}" ) message( "" ) diff --git a/resources/ui/slice_select.ui b/resources/ui/slice_select.ui index 14f5bd3..6db2adf 100644 --- a/resources/ui/slice_select.ui +++ b/resources/ui/slice_select.ui @@ -126,6 +126,7 @@ <property name="visible">True</property> <property name="can_focus">False</property> <property name="orientation">vertical</property> + <property name="spacing">6</property> <property name="homogeneous">True</property> <child> <object class="GtkBox" id="no-options-box"> @@ -136,8 +137,8 @@ <object class="GtkLabel" id="label1"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">0</property> <property name="label" translatable="yes">There are no options for this Slice type.</property> + <property name="xalign">0</property> </object> <packing> <property name="expand">True</property> @@ -153,17 +154,17 @@ </packing> </child> <child> - <object class="GtkBox" id="name-box"> + <object class="GtkBox" id="uri-box"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="spacing">6</property> <property name="homogeneous">True</property> <child> - <object class="GtkLabel" id="label10"> + <object class="GtkLabel" id="label11"> <property name="visible">True</property> <property name="can_focus">False</property> + <property name="label" translatable="yes">URI to open</property> <property name="xalign">0</property> - <property name="label" translatable="yes">Name of the Slice </property> </object> <packing> <property name="expand">True</property> @@ -172,7 +173,7 @@ </packing> </child> <child> - <object class="GtkEntry" id="name-entry"> + <object class="GtkEntry" id="uri-entry"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="invisible_char">•</property> @@ -186,22 +187,22 @@ </object> <packing> <property name="expand">False</property> - <property name="fill">True</property> + <property name="fill">False</property> <property name="position">1</property> </packing> </child> <child> - <object class="GtkBox" id="uri-box"> + <object class="GtkBox" id="command-box"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="spacing">6</property> <property name="homogeneous">True</property> <child> - <object class="GtkLabel" id="label11"> + <object class="GtkLabel" id="label12"> <property name="visible">True</property> <property name="can_focus">False</property> + <property name="label" translatable="yes">Command to execute</property> <property name="xalign">0</property> - <property name="label" translatable="yes">URI to open</property> </object> <packing> <property name="expand">True</property> @@ -210,16 +211,7 @@ </packing> </child> <child> - <object class="GtkEntry" id="uri-entry"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="invisible_char">•</property> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">1</property> - </packing> + <placeholder/> </child> </object> <packing> @@ -229,17 +221,17 @@ </packing> </child> <child> - <object class="GtkBox" id="command-box"> + <object class="GtkBox" id="hotkey-box"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="spacing">6</property> <property name="homogeneous">True</property> <child> - <object class="GtkLabel" id="label12"> + <object class="GtkLabel" id="label13"> <property name="visible">True</property> <property name="can_focus">False</property> + <property name="label" translatable="yes">Hotkey to press</property> <property name="xalign">0</property> - <property name="label" translatable="yes">Command to execute</property> </object> <packing> <property name="expand">True</property> @@ -248,36 +240,27 @@ </packing> </child> <child> - <object class="GtkEntry" id="command-entry"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="invisible_char">•</property> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">1</property> - </packing> + <placeholder/> </child> </object> <packing> <property name="expand">False</property> - <property name="fill">False</property> + <property name="fill">True</property> <property name="position">3</property> </packing> </child> <child> - <object class="GtkBox" id="hotkey-box"> + <object class="GtkBox" id="pie-box"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="spacing">6</property> <property name="homogeneous">True</property> <child> - <object class="GtkLabel" id="label13"> + <object class="GtkLabel" id="label14"> <property name="visible">True</property> <property name="can_focus">False</property> + <property name="label" translatable="yes">Pie to open</property> <property name="xalign">0</property> - <property name="label" translatable="yes">Hotkey to press</property> </object> <packing> <property name="expand">True</property> @@ -296,17 +279,17 @@ </packing> </child> <child> - <object class="GtkBox" id="pie-box"> + <object class="GtkBox" id="name-box"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="spacing">6</property> <property name="homogeneous">True</property> <child> - <object class="GtkLabel" id="label14"> + <object class="GtkLabel" id="label10"> <property name="visible">True</property> <property name="can_focus">False</property> + <property name="label" translatable="yes">Name of the Slice </property> <property name="xalign">0</property> - <property name="label" translatable="yes">Pie to open</property> </object> <packing> <property name="expand">True</property> @@ -315,7 +298,16 @@ </packing> </child> <child> - <placeholder/> + <object class="GtkEntry" id="name-entry"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="invisible_char">•</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> </child> </object> <packing> @@ -334,8 +326,8 @@ <object class="GtkLabel" id="label15"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">0</property> <property name="label" translatable="yes">Is Quick Action</property> + <property name="xalign">0</property> </object> <packing> <property name="expand">True</property> @@ -373,8 +365,8 @@ <object class="GtkLabel" id="label3"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">0</property> <property name="label" translatable="yes">Clipboard history length</property> + <property name="xalign">0</property> </object> <packing> <property name="expand">True</property> @@ -413,8 +405,8 @@ <object class="GtkLabel" id="label4"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">0</property> <property name="label" translatable="yes">Current workspace only</property> + <property name="xalign">0</property> </object> <packing> <property name="expand">True</property> diff --git a/src/actionGroups/windowListGroup.vala b/src/actionGroups/windowListGroup.vala index 363b8b8..c3560af 100644 --- a/src/actionGroups/windowListGroup.vala +++ b/src/actionGroups/windowListGroup.vala @@ -111,14 +111,7 @@ public class WindowListGroup : ActionGroup { var application = window.get_application(); var icon = application.get_icon_name().down(); - - #if HAVE_BAMF - var matcher = Bamf.Matcher.get_default(); - var bamf_app = matcher.get_application_for_xid((uint32)window.get_xid()); - icon = bamf_app.get_icon(); - #endif - - string name = window.get_name(); + var name = window.get_name(); if (name.length > 30) { name = name.substring(0, 30) + "..."; diff --git a/src/daemon.vala b/src/daemon.vala index 640ba0d..0d111de 100644 --- a/src/daemon.vala +++ b/src/daemon.vala @@ -49,7 +49,7 @@ public class Daemon : GLib.Application { ///////////////////////////////////////////////////////////////////// public static int main(string[] args) { - version = "0.6.9"; + version = "0.7.0"; // disable overlay scrollbar --- hacky workaround for black / // transparent background diff --git a/src/gui/commandComboList.vala b/src/gui/commandComboList.vala new file mode 100644 index 0000000..3f157ce --- /dev/null +++ b/src/gui/commandComboList.vala @@ -0,0 +1,120 @@ +///////////////////////////////////////////////////////////////////////// +// Copyright (c) 2011-2016 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 drop-down list, containing one entry for each +/// installed application. +///////////////////////////////////////////////////////////////////////// + +class CommandComboList : Gtk.ComboBox { + + ///////////////////////////////////////////////////////////////////// + /// Called when something is selected from the drop down. + ///////////////////////////////////////////////////////////////////// + + public signal void on_select(string name, string command, string icon); + + ///////////////////////////////////////////////////////////////////// + /// The currently selected item. + ///////////////////////////////////////////////////////////////////// + + public string text { + get { return (this.get_child() as Gtk.Entry).get_text();} + set { (this.get_child() as Gtk.Entry).set_text(value);} + } + + ///////////////////////////////////////////////////////////////////// + /// Stores the data internally. + ///////////////////////////////////////////////////////////////////// + + private Gtk.ListStore data; + private enum DataPos {ICON, NAME, COMMAND} + + ///////////////////////////////////////////////////////////////////// + /// C'tor, constructs the Widget. + ///////////////////////////////////////////////////////////////////// + + public CommandComboList() { + GLib.Object(has_entry : true); + + this.data = new Gtk.ListStore(3, typeof(string), + typeof(string), + typeof(string)); + + this.data.set_sort_column_id(1, Gtk.SortType.ASCENDING); + this.entry_text_column = 2; + this.id_column = 2; + + base.set_model(this.data); + + // hide default renderer + this.get_cells().nth_data(0).visible = false; + + var icon_render = new Gtk.CellRendererPixbuf(); + icon_render.xpad = 4; + this.pack_start(icon_render, false); + + var name_render = new Gtk.CellRendererText(); + this.pack_start(name_render, true); + + this.add_attribute(icon_render, "icon_name", DataPos.ICON); + this.add_attribute(name_render, "text", DataPos.NAME); + + this.changed.connect(() => { + Gtk.TreeIter active; + if (this.get_active_iter(out active)) { + string name = ""; + string command = ""; + string icon = ""; + this.data.get(active, DataPos.NAME, out name); + this.data.get(active, DataPos.COMMAND, out command); + this.data.get(active, DataPos.ICON, out icon); + on_select(name, command, icon); + } + }); + + reload(); + } + + ///////////////////////////////////////////////////////////////////// + /// Loads all existing applications to the list. + ///////////////////////////////////////////////////////////////////// + + public void reload() { + var apps = GLib.AppInfo.get_all(); + foreach (var app in apps) { + if (app.should_show()) { + Gtk.TreeIter last; + var icon_name = "application-x-executable"; + var icon = app.get_icon(); + + if (icon != null) { + icon_name = icon.to_string(); + } + + this.data.append(out last); + this.data.set(last, DataPos.ICON, icon_name, + DataPos.NAME, app.get_display_name(), + DataPos.COMMAND, app.get_commandline()); + } + } + } +} + +} diff --git a/src/gui/newSliceWindow.vala b/src/gui/newSliceWindow.vala index d719213..3133e34 100644 --- a/src/gui/newSliceWindow.vala +++ b/src/gui/newSliceWindow.vala @@ -61,7 +61,7 @@ public class NewSliceWindow : GLib.Object { private Gtk.Box workspace_only_box = null; private Gtk.Image icon = null; private Gtk.Entry name_entry = null; - private Gtk.Entry command_entry = null; + private CommandComboList command_list = null; private Gtk.Entry uri_entry = null; private Gtk.Switch quickaction_checkbutton = null; private Gtk.Switch workspace_only_checkbutton = null; @@ -195,11 +195,18 @@ public class NewSliceWindow : GLib.Object { 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.Switch; this.quickaction_box = builder.get_object("quickaction-box") as Gtk.Box; this.icon = builder.get_object("icon") as Gtk.Image; + this.command_list = new CommandComboList(); + this.command_list.on_select.connect((name, command, icon) => { + this.set_icon(icon); + this.name_entry.text = name; + }); + + this.command_box.pack_start(this.command_list, true, true); + this.workspace_only_checkbutton = builder.get_object("workspace-only-checkbutton") as Gtk.Switch; this.workspace_only_box = builder.get_object("workspace-only-box") as Gtk.Box; @@ -275,7 +282,7 @@ public class NewSliceWindow : GLib.Object { switch (type) { case "app": this.current_custom_icon = action.icon; - this.command_entry.text = action.real_command; + this.command_list.text = action.real_command; break; case "key": this.current_custom_icon = action.icon; @@ -319,7 +326,7 @@ public class NewSliceWindow : GLib.Object { this.key_select.set_trigger(new Trigger()); this.pie_select.select_first(); this.name_entry.text = _("Rename me!"); - this.command_entry.text = ""; + this.command_list.text = ""; this.uri_entry.text = ""; } @@ -359,7 +366,7 @@ 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, + this.command_list.text, this.quickaction_checkbutton.active)); break; case "key": diff --git a/src/gui/piePreview.vala b/src/gui/piePreview.vala index eadaa8e..540ab51 100644 --- a/src/gui/piePreview.vala +++ b/src/gui/piePreview.vala @@ -87,8 +87,9 @@ class PiePreview : Gtk.DrawingArea { this.enable_drag_source(); Gtk.TargetEntry uri_dest = {"text/uri-list", 0, 0}; + Gtk.TargetEntry text_dest = {"text/plain", 0, 0}; Gtk.TargetEntry slice_dest = {"text/plain", Gtk.TargetFlags.SAME_WIDGET, 0}; - Gtk.TargetEntry[] destinations = { uri_dest, slice_dest }; + Gtk.TargetEntry[] destinations = { uri_dest, text_dest, slice_dest }; Gtk.drag_dest_set(this, Gtk.DestDefaults.ALL, destinations, Gdk.DragAction.COPY | Gdk.DragAction.MOVE | Gdk.DragAction.LINK); this.drag_begin.connect(this.on_start_drag); @@ -349,6 +350,16 @@ class PiePreview : Gtk.DrawingArea { int position = this.renderer.get_active_slice(); this.renderer.set_dnd_mode(false); + var text = selection_data.get_text(); + if (text != null && GLib.Uri.parse_scheme(text) != null) { + pie.add_action(ActionRegistry.new_for_uri(text), position); + this.renderer.add_group(pie.action_groups[position], position); + + if (this.renderer.slices.size == 1) + this.on_first_slice_added(); + } + + foreach (var uri in selection_data.get_uris()) { pie.add_action(ActionRegistry.new_for_uri(uri), position); this.renderer.add_group(pie.action_groups[position], position); diff --git a/src/utilities/bindingManager.vala b/src/utilities/bindingManager.vala index 38ae1e0..a21c0a1 100644 --- a/src/utilities/bindingManager.vala +++ b/src/utilities/bindingManager.vala @@ -332,10 +332,7 @@ public class BindingManager : GLib.Object { #endif - if (xevent->type == X.EventType.KeyRelease) { - on_release((uint32)xevent.xkey.time); - } else if (xevent->type == X.EventType.KeyPress) { - + if (xevent->type == X.EventType.KeyPress) { // remove NumLock, CapsLock and ScrollLock from key state var event_mods = prepare_modifiers((Gdk.ModifierType)xevent.xkey.state); @@ -351,9 +348,7 @@ public class BindingManager : GLib.Object { } } } - } else if(xevent->type == X.EventType.ButtonRelease) { - on_release((uint32)xevent.xkey.time); - } else if(xevent->type == X.EventType.ButtonPress) { + } else if(xevent->type == X.EventType.ButtonPress) { // remove NumLock, CapsLock and ScrollLock from key state var event_mods = prepare_modifiers((Gdk.ModifierType)xevent.xbutton.state); @@ -369,33 +364,61 @@ public class BindingManager : GLib.Object { } } } - } - else if(xevent->type == X.EventType.ButtonRelease || xevent->type == X.EventType.KeyRelease) { - this.activate_delayed(null, *xevent); - } + } + else if(xevent->type == X.EventType.ButtonRelease || xevent->type == X.EventType.KeyRelease) { + on_release((uint32)xevent.xkey.time); + this.cancel_activate_delayed(); + } return Gdk.FilterReturn.CONTINUE; } ///////////////////////////////////////////////////////////////////// /// This method is always called when a trigger is activated which is - /// delayed. Therefore on_press() is only emitted, when this method - /// is not called again within 300 milliseconds. Else a fake event is - /// sent in order to simulate the actual key which has been pressed. + /// delayed. Therefore on_press() is only emitted, when + /// cancel_activate_delayed is not called again 300 milliseconds. + /// Else a fake event is sent in order to simulate the actual key + /// which has been pressed. ///////////////////////////////////////////////////////////////////// - private void activate_delayed(Keybinding? binding , X.Event event) { - // increase event count, so any waiting event will realize that - // something happened in the meantime - var current_count = ++this.delayed_count; + private void activate_delayed(Keybinding binding, X.Event event) { + + if (this.delayed_binding == null) { + // the current event count is captured in the lambda below. If + // cancel_activate_delayed is not called within 300 milliseconds, + // the binding can be activated + var current_count = this.delayed_count; + + // if the trigger has been pressed, store it and wait for any interuption + // within the next 300 milliseconds + this.delayed_event = event; + this.delayed_binding = binding; + + Timeout.add(300, () => { + // if nothing has been pressed in the meantime + if (current_count == this.delayed_count) { + this.delayed_binding = null; + this.delayed_event = null; + on_press(binding.id); + } + return false; + }); + } + } + + private void cancel_activate_delayed() { + + if (this.delayed_event != null) { + // increase event count, so any waiting event will realize that + // something happened in the meantime + ++this.delayed_count; - if (binding == null && this.delayed_event != null) { // if the trigger is released and an event is currently waiting // simulate that the trigger has been pressed without any inter- // ference of Gnome-Pie unowned X.Display display = Gdk.X11.get_default_xdisplay(); - // unbind the trigger, else we'll capture that event again ;) + // unbind the trigger, else we'll capture that event again ;-) unbind(delayed_binding.id); if (this.delayed_binding.trigger.with_mouse) { @@ -420,22 +443,6 @@ public class BindingManager : GLib.Object { this.delayed_binding = null; this.delayed_event = null; - - } else if (binding != null) { - // if the trigger has been pressed, store it and wait for any interuption - // within the next 300 milliseconds - this.delayed_event = event; - this.delayed_binding = binding; - - Timeout.add(300, () => { - // if nothing has been pressed in the meantime - if (current_count == this.delayed_count) { - this.delayed_binding = null; - this.delayed_event = null; - on_press(binding.id); - } - return false; - }); } } } |