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
1=== modified file 'src/Backend/App.vala'
2--- src/Backend/App.vala 2014-10-17 01:18:02 +0000
3+++ src/Backend/App.vala 2014-10-18 01:58:33 +0000
4@@ -49,7 +49,6 @@
5 public Synapse.Match? target { get; private set; default = null; }
6 public Gee.ArrayList<string> actions { get; private set; default = null; }
7 public Gee.HashMap<string, string> actions_map { get; private set; default = null; }
8- public Gdk.Pixbuf? quicklist_icon { get; private set; default = null; }
9
10 public signal void icon_changed ();
11 public signal void launched (App app);
12@@ -295,10 +294,10 @@
13 return true;
14 }
15
16+ // Quicklist code from Plank
17 public void init_actions () throws KeyFileError {
18 actions = new Gee.ArrayList<string> ();
19 actions_map = new Gee.HashMap<string, string> ();
20- quicklist_icon = load_icon (16);
21
22 // get FDO Desktop Actions
23 // see http://standards.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html#extra-actions
24
25=== modified file 'src/Widgets/AppEntry.vala'
26--- src/Widgets/AppEntry.vala 2014-10-17 01:18:02 +0000
27+++ src/Widgets/AppEntry.vala 2014-10-18 01:58:33 +0000
28@@ -38,7 +38,7 @@
29 this.view = view;
30 Gtk.TargetEntry dnd = {"text/uri-list", 0, 0};
31 Gtk.drag_source_set (this, Gdk.ModifierType.BUTTON1_MASK, {dnd},
32- Gdk.DragAction.COPY);
33+ Gdk.DragAction.COPY);
34
35 desktop_id = app.desktop_id;
36 desktop_path = app.desktop_path;
37@@ -133,8 +133,19 @@
38 var menu = new PopoverMenu ();
39 foreach (var action in application.actions) {
40 var values = application.actions_map.get (action).split (";;");
41- var menuitem = new Widgets.PopoverMenuItem (action, application.quicklist_icon);
42+ Gdk.Pixbuf? icon = null;
43+ var flags = Gtk.IconLookupFlags.FORCE_SIZE;
44+
45+ try {
46+ if (values.length > 1 && values[1] != "" && values[1] != null)
47+ icon = Slingshot.icon_theme.load_icon (values[1], 16, flags);
48+ } catch (Error e) {
49+ error ("Error loading quicklist icon");
50+ }
51+
52+ var menuitem = new Widgets.PopoverMenuItem (action, icon);
53 menu.add_menu_item (menuitem);
54+
55 menuitem.activated.connect (() => {
56 try {
57 AppInfo.create_from_commandline (values[0], null, AppInfoCreateFlags.NONE).launch (null, null);
58
59=== modified file 'src/Widgets/PopoverMenu.vala'
60--- src/Widgets/PopoverMenu.vala 2014-10-17 01:18:02 +0000
61+++ src/Widgets/PopoverMenu.vala 2014-10-18 01:58:33 +0000
62@@ -39,11 +39,30 @@
63 public int get_size () {
64 return items.size;
65 }
66+
67+ public override void show () {
68+ base.show ();
69+ bool has_image = false;
70+ foreach (PopoverMenuItem item in items) {
71+ if (item.image != null)
72+ has_image = true;
73+ }
74+
75+ if (!has_image) {
76+ foreach (PopoverMenuItem item in items) {
77+ item.label_widget.margin_left = item.label_widget.margin_right = 8;
78+ item.space_box.hide ();
79+ }
80+ }
81+ }
82 }
83
84 public class PopoverMenuItem : Object {
85 public Gtk.Widget child = null;
86 public signal void activated ();
87+ public Gtk.Image? image;
88+ public Gtk.Box? space_box;
89+ public Gtk.Label label_widget;
90
91 public PopoverMenuItem (string label, Gdk.Pixbuf? icon) {
92 var button = new Gtk.Button ();
93@@ -51,18 +70,18 @@
94
95 var grid = new Gtk.Grid ();
96 if (icon != null) {
97- var image = new Gtk.Image.from_pixbuf (icon);
98+ image = new Gtk.Image.from_pixbuf (icon);
99 image.margin_left = 2;
100- image.margin_right = 2;
101 image.halign = Gtk.Align.START;
102 grid.attach (image, 0, 0, 1, 1);
103 } else {
104- var space_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
105- space_box.set_size_request (16, 16);
106+ space_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
107+ space_box.set_size_request (24, 16);
108 grid.attach (space_box, 0, 0, 1, 1);
109 }
110
111- var label_widget = new Gtk.Label.with_mnemonic (label);
112+ label_widget = new Gtk.Label.with_mnemonic (label);
113+ label_widget.margin_left = 2;
114 label_widget.margin_right = 16;
115 label_widget.justify = Gtk.Justification.LEFT;
116 label_widget.set_alignment (0, 0);

Subscribers

People subscribed via source and target branches