summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2016-09-22 19:16:49 +0200
committerJörg Frings-Fürst <debian@jff-webhosting.net>2016-09-22 19:16:49 +0200
commitc59cef2ee7de5c2dc882c496deb569affb03bad8 (patch)
treedacf15d7bbedfe397a60387fde1dda3fbd68d92e /src
parent5e23ab97cea2ac130e20ac46911cab0d9356f33d (diff)
parent45a3d7f0e2783d9898f017772583d31c1c9e0f03 (diff)
Merge tag 'upstream/0.7.0'
Upstream version 0.7.0
Diffstat (limited to 'src')
-rw-r--r--src/actionGroups/windowListGroup.vala9
-rw-r--r--src/daemon.vala2
-rw-r--r--src/gui/commandComboList.vala120
-rw-r--r--src/gui/newSliceWindow.vala17
-rw-r--r--src/gui/piePreview.vala13
-rw-r--r--src/utilities/bindingManager.vala79
6 files changed, 189 insertions, 51 deletions
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;
- });
}
}
}