Merge lp:~meese/slingshot/fix-quicklisticons into lp:~elementary-pantheon/slingshot/trunk

Proposed by meese
Status: Merged
Approved by: Cody Garver
Approved revision: 458
Merged at revision: 472
Proposed branch: lp:~meese/slingshot/fix-quicklisticons
Merge into: lp:~elementary-pantheon/slingshot/trunk
Diff against target: 116 lines (+38/-9)
3 files modified
src/Backend/App.vala (+1/-2)
src/Widgets/AppEntry.vala (+13/-2)
src/Widgets/PopoverMenu.vala (+24/-5)
To merge this branch: bzr merge lp:~meese/slingshot/fix-quicklisticons
Reviewer Review Type Date Requested Status
Danielle Foré ux Approve
elementary Pantheon team code Pending
Review via email: mp+238653@code.launchpad.net

Commit message

fix quicklist icons showing up when they are not supposed to

To post a comment you must log in.
Revision history for this message
Cody Garver (codygarver) wrote :

Is it possible/clean/easy to avoid the left margin reserved for icons in quicklists that have no icons at all?

Revision history for this message
meese (meese) wrote :

Not a quick fix but I'll do it tomorrow night.

458. By meese

fix spacing when no image is present

Revision history for this message
Danielle Foré (danrabbit) wrote :

Seems to work as expected

review: Approve (ux)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/Backend/App.vala'
--- src/Backend/App.vala 2014-10-17 01:18:02 +0000
+++ src/Backend/App.vala 2014-10-18 01:58:33 +0000
@@ -49,7 +49,6 @@
49 public Synapse.Match? target { get; private set; default = null; }49 public Synapse.Match? target { get; private set; default = null; }
50 public Gee.ArrayList<string> actions { get; private set; default = null; }50 public Gee.ArrayList<string> actions { get; private set; default = null; }
51 public Gee.HashMap<string, string> actions_map { get; private set; default = null; }51 public Gee.HashMap<string, string> actions_map { get; private set; default = null; }
52 public Gdk.Pixbuf? quicklist_icon { get; private set; default = null; }
53 52
54 public signal void icon_changed ();53 public signal void icon_changed ();
55 public signal void launched (App app);54 public signal void launched (App app);
@@ -295,10 +294,10 @@
295 return true;294 return true;
296 }295 }
297296
297 // Quicklist code from Plank
298 public void init_actions () throws KeyFileError {298 public void init_actions () throws KeyFileError {
299 actions = new Gee.ArrayList<string> ();299 actions = new Gee.ArrayList<string> ();
300 actions_map = new Gee.HashMap<string, string> ();300 actions_map = new Gee.HashMap<string, string> ();
301 quicklist_icon = load_icon (16);
302301
303 // get FDO Desktop Actions302 // get FDO Desktop Actions
304 // see http://standards.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html#extra-actions303 // see http://standards.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html#extra-actions
305304
=== modified file 'src/Widgets/AppEntry.vala'
--- src/Widgets/AppEntry.vala 2014-10-17 01:18:02 +0000
+++ src/Widgets/AppEntry.vala 2014-10-18 01:58:33 +0000
@@ -38,7 +38,7 @@
38 this.view = view;38 this.view = view;
39 Gtk.TargetEntry dnd = {"text/uri-list", 0, 0};39 Gtk.TargetEntry dnd = {"text/uri-list", 0, 0};
40 Gtk.drag_source_set (this, Gdk.ModifierType.BUTTON1_MASK, {dnd},40 Gtk.drag_source_set (this, Gdk.ModifierType.BUTTON1_MASK, {dnd},
41 Gdk.DragAction.COPY);41 Gdk.DragAction.COPY);
4242
43 desktop_id = app.desktop_id;43 desktop_id = app.desktop_id;
44 desktop_path = app.desktop_path;44 desktop_path = app.desktop_path;
@@ -133,8 +133,19 @@
133 var menu = new PopoverMenu ();133 var menu = new PopoverMenu ();
134 foreach (var action in application.actions) {134 foreach (var action in application.actions) {
135 var values = application.actions_map.get (action).split (";;");135 var values = application.actions_map.get (action).split (";;");
136 var menuitem = new Widgets.PopoverMenuItem (action, application.quicklist_icon);136 Gdk.Pixbuf? icon = null;
137 var flags = Gtk.IconLookupFlags.FORCE_SIZE;
138
139 try {
140 if (values.length > 1 && values[1] != "" && values[1] != null)
141 icon = Slingshot.icon_theme.load_icon (values[1], 16, flags);
142 } catch (Error e) {
143 error ("Error loading quicklist icon");
144 }
145
146 var menuitem = new Widgets.PopoverMenuItem (action, icon);
137 menu.add_menu_item (menuitem);147 menu.add_menu_item (menuitem);
148
138 menuitem.activated.connect (() => {149 menuitem.activated.connect (() => {
139 try {150 try {
140 AppInfo.create_from_commandline (values[0], null, AppInfoCreateFlags.NONE).launch (null, null);151 AppInfo.create_from_commandline (values[0], null, AppInfoCreateFlags.NONE).launch (null, null);
141152
=== modified file 'src/Widgets/PopoverMenu.vala'
--- src/Widgets/PopoverMenu.vala 2014-10-17 01:18:02 +0000
+++ src/Widgets/PopoverMenu.vala 2014-10-18 01:58:33 +0000
@@ -39,11 +39,30 @@
39 public int get_size () {39 public int get_size () {
40 return items.size;40 return items.size;
41 }41 }
42
43 public override void show () {
44 base.show ();
45 bool has_image = false;
46 foreach (PopoverMenuItem item in items) {
47 if (item.image != null)
48 has_image = true;
49 }
50
51 if (!has_image) {
52 foreach (PopoverMenuItem item in items) {
53 item.label_widget.margin_left = item.label_widget.margin_right = 8;
54 item.space_box.hide ();
55 }
56 }
57 }
42}58}
4359
44public class PopoverMenuItem : Object {60public class PopoverMenuItem : Object {
45 public Gtk.Widget child = null;61 public Gtk.Widget child = null;
46 public signal void activated ();62 public signal void activated ();
63 public Gtk.Image? image;
64 public Gtk.Box? space_box;
65 public Gtk.Label label_widget;
4766
48 public PopoverMenuItem (string label, Gdk.Pixbuf? icon) {67 public PopoverMenuItem (string label, Gdk.Pixbuf? icon) {
49 var button = new Gtk.Button ();68 var button = new Gtk.Button ();
@@ -51,18 +70,18 @@
5170
52 var grid = new Gtk.Grid ();71 var grid = new Gtk.Grid ();
53 if (icon != null) {72 if (icon != null) {
54 var image = new Gtk.Image.from_pixbuf (icon);73 image = new Gtk.Image.from_pixbuf (icon);
55 image.margin_left = 2;74 image.margin_left = 2;
56 image.margin_right = 2;
57 image.halign = Gtk.Align.START;75 image.halign = Gtk.Align.START;
58 grid.attach (image, 0, 0, 1, 1);76 grid.attach (image, 0, 0, 1, 1);
59 } else {77 } else {
60 var space_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);78 space_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
61 space_box.set_size_request (16, 16);79 space_box.set_size_request (24, 16);
62 grid.attach (space_box, 0, 0, 1, 1);80 grid.attach (space_box, 0, 0, 1, 1);
63 }81 }
6482
65 var label_widget = new Gtk.Label.with_mnemonic (label);83 label_widget = new Gtk.Label.with_mnemonic (label);
84 label_widget.margin_left = 2;
66 label_widget.margin_right = 16;85 label_widget.margin_right = 16;
67 label_widget.justify = Gtk.Justification.LEFT;86 label_widget.justify = Gtk.Justification.LEFT;
68 label_widget.set_alignment (0, 0);87 label_widget.set_alignment (0, 0);

Subscribers

People subscribed via source and target branches