Merge lp:~tintou/switchboard/fix-1016155 into lp:~elementary-pantheon/switchboard/switchboard
- fix-1016155
- Merge into switchboard
Proposed by
Corentin Noël
Status: | Merged | ||||||||
---|---|---|---|---|---|---|---|---|---|
Merged at revision: | 310 | ||||||||
Proposed branch: | lp:~tintou/switchboard/fix-1016155 | ||||||||
Merge into: | lp:~elementary-pantheon/switchboard/switchboard | ||||||||
Diff against target: |
318 lines (+89/-79) 3 files modified
CMakeLists.txt (+1/-2) Switchboard/switchboard-app.vala (+40/-30) Switchboard/switchboard-categoryview.vala (+48/-47) |
||||||||
To merge this branch: | bzr merge lp:~tintou/switchboard/fix-1016155 | ||||||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
elementary Pantheon team | Pending | ||
Review via email: mp+125847@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
- 310. By Corentin Noël
-
Removed redundant copyright, avi romanoff is already listed as developer
- 311. By Corentin Noël
-
Reverse to 32px Icons
- 312. By Corentin Noël
-
Forgotted to change the sorting column
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'CMakeLists.txt' |
2 | --- CMakeLists.txt 2012-06-18 04:21:47 +0000 |
3 | +++ CMakeLists.txt 2012-09-22 17:35:24 +0000 |
4 | @@ -61,7 +61,7 @@ |
5 | # |
6 | |
7 | find_package(PkgConfig) |
8 | -pkg_check_modules(DEPS REQUIRED granite gio-2.0 gee-1.0 clutter-gtk-1.0 unity) |
9 | +pkg_check_modules(DEPS REQUIRED granite gio-2.0 gee-1.0 unity) |
10 | add_definitions(${DEPS_CFLAGS}) |
11 | link_directories(${DEPS_LIBRARY_DIRS}) |
12 | find_package(Vala REQUIRED) |
13 | @@ -76,7 +76,6 @@ |
14 | Switchboard/granite-embedded-alert.vala |
15 | PACKAGES |
16 | granite |
17 | - clutter-gtk-1.0 |
18 | gee-1.0 |
19 | gio-2.0 |
20 | unity |
21 | |
22 | === modified file 'Switchboard/switchboard-app.vala' |
23 | --- Switchboard/switchboard-app.vala 2012-09-13 21:21:13 +0000 |
24 | +++ Switchboard/switchboard-app.vala 2012-09-22 17:35:24 +0000 |
25 | @@ -37,7 +37,6 @@ |
26 | translate_url = TRANSLATE_URL; |
27 | about_authors = AUTHORS; |
28 | |
29 | - about_comments = COPYRIGHT; |
30 | about_license_type = Gtk.License.GPL_3_0; |
31 | } |
32 | |
33 | @@ -59,8 +58,9 @@ |
34 | |
35 | // Content area widgets |
36 | Gtk.Socket socket; |
37 | - Gtk.VBox vbox; |
38 | + Gtk.Grid grid; |
39 | Granite.Widgets.EmbeddedAlert alert_view; |
40 | + Gtk.ScrolledWindow scrollable_view; |
41 | Switchboard.CategoryView category_view; |
42 | |
43 | // Plug data |
44 | @@ -93,6 +93,8 @@ |
45 | // Set up socket |
46 | socket = new Gtk.Socket (); |
47 | socket.plug_removed.connect(switch_to_icons); |
48 | + socket.set_hexpand(true); |
49 | + socket.set_vexpand(true); |
50 | |
51 | // Set up accelerators (hotkeys) |
52 | var accel_group = new Gtk.AccelGroup (); |
53 | @@ -110,19 +112,26 @@ |
54 | current_plug["title"] = ""; |
55 | current_plug["executable"] = ""; |
56 | |
57 | - category_view = new Switchboard.CategoryView(); |
58 | - category_view.plug_selected.connect((title, executable, @extern) => load_plug (title, executable, @extern)); |
59 | + category_view = new Switchboard.CategoryView (); |
60 | + category_view.plug_selected.connect ((title, executable, @extern) => load_plug (title, executable, @extern)); |
61 | category_view.margin_top = 12; |
62 | |
63 | + scrollable_view = new Gtk.ScrolledWindow (null, null); |
64 | + |
65 | // Set up UI |
66 | - vbox = new Gtk.VBox (false, 0); |
67 | - vbox.pack_start (toolbar, false, false); |
68 | + grid = new Gtk.Grid (); |
69 | + grid.set_hexpand (true); |
70 | + grid.set_vexpand (true); |
71 | + grid.attach (toolbar, 0, 0, 1, 1); |
72 | + toolbar.set_hexpand (true); |
73 | |
74 | alert_view = new Granite.Widgets.EmbeddedAlert (); |
75 | - vbox.pack_end (alert_view); |
76 | + grid.attach (alert_view, 0, 2, 1, 1); |
77 | |
78 | - main_window.add (vbox); |
79 | - vbox.pack_start (category_view); |
80 | + main_window.add (grid); |
81 | + scrollable_view.add_with_viewport (category_view); |
82 | + scrollable_view.set_vexpand (true); |
83 | + grid.attach (scrollable_view, 0, 1, 1, 1); |
84 | |
85 | main_window.set_application (this); |
86 | main_window.resizable = false; |
87 | @@ -136,15 +145,16 @@ |
88 | alert_view.hide(); |
89 | |
90 | loading = new Gtk.Spinner (); |
91 | + loading.set_vexpand(true); |
92 | loading.halign = Gtk.Align.CENTER; |
93 | loading.valign = Gtk.Align.CENTER; |
94 | loading.width_request = 72; |
95 | loading.height_request = 72; |
96 | loading.start (); |
97 | |
98 | - vbox.pack_start (socket); |
99 | + grid.attach (socket, 0, 1, 1, 1); |
100 | socket.hide (); |
101 | - vbox.pack_start (loading); |
102 | + grid.attach (loading, 0, 1, 1, 1); |
103 | loading.hide (); |
104 | |
105 | var any_plugs = false; |
106 | @@ -217,11 +227,11 @@ |
107 | |
108 | // ensure the button is sensitive; it might be the first plug loaded |
109 | if (!@extern) { |
110 | - navigation_button.set_sensitive(true); |
111 | - navigation_button.stock_id = Gtk.Stock.HOME; |
112 | - current_plug["title"] = title; |
113 | - current_plug["executable"] = executable; |
114 | - } |
115 | + navigation_button.set_sensitive(true); |
116 | + navigation_button.stock_id = Gtk.Stock.HOME; |
117 | + current_plug["title"] = title; |
118 | + current_plug["executable"] = executable; |
119 | + } |
120 | } catch { warning(_("Failed to launch plug: title %s | executable %s"), title, executable); } |
121 | } else { |
122 | navigation_button.set_sensitive(true); |
123 | @@ -229,9 +239,9 @@ |
124 | } |
125 | |
126 | if (!@extern) { |
127 | - switch_to_socket (); |
128 | - main_window.title = @"$APP_TITLE - $title"; |
129 | - } |
130 | + switch_to_socket (); |
131 | + main_window.title = @"$APP_TITLE - $title"; |
132 | + } |
133 | } |
134 | |
135 | // Change Switchboard title back to "Switchboard" |
136 | @@ -303,17 +313,17 @@ |
137 | } catch (Error e) { warning("Couldn't load this keyfile, %s (path: %s)", e.message, keyfile); } |
138 | plug["id"] = kf.get_start_group(); |
139 | try { |
140 | - var exec = kf.get_string (head, "exec"); |
141 | - //if a path starts with a double slash, we take it as an absolute path |
142 | - if (exec.substring (0, 2) == "//") { |
143 | - exec = exec.substring (1); |
144 | - plug["extern"] = "1"; |
145 | - } else { |
146 | - exec = Path.build_filename(parent, exec); |
147 | - plug["extern"] = "0"; |
148 | - } |
149 | - |
150 | - plug["exec"] = exec; |
151 | + var exec = kf.get_string (head, "exec"); |
152 | + //if a path starts with a double slash, we take it as an absolute path |
153 | + if (exec.substring (0, 2) == "//") { |
154 | + exec = exec.substring (1); |
155 | + plug["extern"] = "1"; |
156 | + } else { |
157 | + exec = Path.build_filename(parent, exec); |
158 | + plug["extern"] = "0"; |
159 | + } |
160 | + |
161 | + plug["exec"] = exec; |
162 | } catch (Error e) { warning("Couldn't read exec field in file %s, %s", keyfile, e.message); } |
163 | try { plug["icon"] = kf.get_string (head, "icon"); |
164 | } catch (Error e) { warning("Couldn't read icon field in file %s, %s", keyfile, e.message); } |
165 | |
166 | === modified file 'Switchboard/switchboard-categoryview.vala' |
167 | --- Switchboard/switchboard-categoryview.vala 2012-09-05 14:54:07 +0000 |
168 | +++ Switchboard/switchboard-categoryview.vala 2012-09-22 17:35:24 +0000 |
169 | @@ -17,9 +17,9 @@ |
170 | |
171 | namespace Switchboard { |
172 | |
173 | - public class CategoryView : Gtk.VBox { |
174 | + public class CategoryView : Gtk.Grid { |
175 | |
176 | - public Gee.HashMap<string, Gtk.VBox> category_labels = new Gee.HashMap<string, Gtk.VBox> (); |
177 | + public Gee.HashMap<string, Gtk.Grid> category_labels = new Gee.HashMap<string, Gtk.Grid> (); |
178 | public Gee.HashMap<string, Gtk.ListStore> category_store = new Gee.HashMap<string, Gtk.ListStore> (); |
179 | public Gee.HashMap<string, Gtk.IconView> category_views = new Gee.HashMap<string, Gtk.IconView> (); |
180 | Gtk.IconTheme theme = Gtk.IconTheme.get_default (); |
181 | @@ -30,76 +30,77 @@ |
182 | |
183 | public CategoryView () { |
184 | for (int i = 0; i < category_ids.length; i++) { |
185 | - var store = new Gtk.ListStore (5, typeof (string), typeof (Gdk.Pixbuf), |
186 | + var store = new Gtk.ListStore (5, typeof (Gdk.Pixbuf), typeof (string), |
187 | typeof(string), typeof(bool), typeof(string)); |
188 | + store.set_sort_column_id (1, Gtk.SortType.ASCENDING); |
189 | |
190 | - var label = new Gtk.Label ("<big><b>" + _(category_names[i]) + "</b></big>"); |
191 | - label.margin_left = 12; |
192 | + var category_label = new Gtk.Label ("<big><b>" + _(category_names[i]) + "</b></big>"); |
193 | + category_label.margin_left = 12; |
194 | var filtered = new Gtk.TreeModelFilter(store, null); |
195 | filtered.set_visible_column(3); |
196 | filtered.refilter(); |
197 | |
198 | var category_plugs = new Gtk.IconView.with_model (filtered); |
199 | - // category_plugs. |
200 | - category_plugs.column_spacing = -5; |
201 | - category_plugs.item_width = 72; |
202 | - category_plugs.set_text_column (0); |
203 | - category_plugs.set_pixbuf_column (1); |
204 | + category_plugs.set_item_width(96); |
205 | + category_plugs.set_text_column (1); |
206 | + category_plugs.set_pixbuf_column (0); |
207 | + category_plugs.set_hexpand (true); |
208 | category_plugs.selection_changed.connect(() => on_selection_changed(category_plugs, filtered)); |
209 | |
210 | (category_plugs.get_cells ().nth_data (0) as Gtk.CellRendererText).wrap_mode = Pango.WrapMode.WORD; |
211 | + (category_plugs.get_cells ().nth_data (0) as Gtk.CellRendererText).ellipsize_set = true; |
212 | |
213 | var bg_css = new Gtk.CssProvider (); |
214 | try { |
215 | bg_css.load_from_data ("*{background-color:@background_color;}", -1); |
216 | } catch (Error e) { warning (e.message); } |
217 | category_plugs.get_style_context ().add_provider (bg_css, 20000); |
218 | - label.xalign = (float) 0.02; |
219 | + category_label.xalign = (float) 0.02; |
220 | |
221 | - var vbox = new Gtk.VBox (false, 0); // not homogeneous, 0 spacing |
222 | - var headbox = new Gtk.HBox (false, 0); |
223 | - label.use_markup = true; |
224 | + var grid = new Gtk.Grid (); |
225 | + category_label.use_markup = true; |
226 | |
227 | // Always add a Seperator |
228 | - var hsep = new Gtk.HSeparator (); |
229 | - headbox.pack_end(hsep, true, true); // expand, fill, padding´ |
230 | - headbox.pack_start(label, false, false, 0); |
231 | - |
232 | - vbox.pack_start(headbox, false, true, 0); |
233 | - vbox.pack_end(category_plugs, true, true); |
234 | - |
235 | - category_labels[category_ids[i]] = vbox; |
236 | + var h_separator = new Gtk.Separator (Gtk.Orientation.HORIZONTAL); |
237 | + h_separator.set_hexpand (true); |
238 | + grid.attach (category_label, 0, 0, 1, 1); |
239 | + grid.attach (h_separator, 1, 0, 1, 1); // expand, fill, padding´ |
240 | + |
241 | + grid.attach(category_plugs, 0, 1, 2, 1); |
242 | + |
243 | + category_labels[category_ids[i]] = grid; |
244 | category_store[category_ids[i]] = store; |
245 | category_views[category_ids[i]] = category_plugs; |
246 | |
247 | - pack_start(vbox); |
248 | + attach (grid, 0, i, 1, 1); |
249 | } |
250 | } |
251 | |
252 | public void add_plug (Gee.HashMap<string, string> plug) { |
253 | |
254 | - Gtk.TreeIter root; |
255 | - string plug_down = plug["category"].down(); |
256 | - |
257 | - if (!(plug_down in category_ids)) { |
258 | - warning (_("Keyfile \"%s\" contains an invalid category: \"%s\", and will not be added"), |
259 | - plug["title"], plug["category"]); |
260 | - return; |
261 | - } |
262 | - |
263 | - Gdk.Pixbuf icon_pixbuf = null; |
264 | - try { |
265 | - icon_pixbuf = theme.load_icon (plug["icon"], 32, Gtk.IconLookupFlags.GENERIC_FALLBACK); |
266 | - } catch { |
267 | - warning(_("Unable to load plug %s's icon: %s"), plug["title"], plug["icon"]); |
268 | - return; // FIXME: if we get no icon, we probably dont want that one.. |
269 | - } |
270 | - category_store[plug_down].append(out root); |
271 | - |
272 | - category_store[plug_down].set(root, 0, plug["title"], 1, icon_pixbuf, 2, plug["exec"], |
273 | - 3, true, 4, plug["extern"]); |
274 | - category_labels[plug_down].show_all (); |
275 | - category_views[plug_down].show_all (); |
276 | + Gtk.TreeIter root; |
277 | + string plug_down = plug["category"].down(); |
278 | + |
279 | + if (!(plug_down in category_ids)) { |
280 | + warning (_("Keyfile \"%s\" contains an invalid category: \"%s\", and will not be added"), |
281 | + plug["title"], plug["category"]); |
282 | + return; |
283 | + } |
284 | + |
285 | + Gdk.Pixbuf icon_pixbuf = null; |
286 | + try { |
287 | + icon_pixbuf = theme.load_icon (plug["icon"], 32, Gtk.IconLookupFlags.GENERIC_FALLBACK); |
288 | + } catch { |
289 | + warning(_("Unable to load plug %s's icon: %s"), plug["title"], plug["icon"]); |
290 | + return; // FIXME: if we get no icon, we probably dont want that one.. |
291 | + } |
292 | + category_store[plug_down].append(out root); |
293 | + |
294 | + category_store[plug_down].set(root, 0, icon_pixbuf, 1, plug["title"], 2, plug["exec"], |
295 | + 3, true, 4, plug["extern"]); |
296 | + category_labels[plug_down].show_all (); |
297 | + category_views[plug_down].show_all (); |
298 | + |
299 | } |
300 | |
301 | public void filter_plugs (string filter, SwitchboardApp switchboard) { |
302 | @@ -115,7 +116,7 @@ |
303 | store.foreach((model, path, iter) => { |
304 | string title; |
305 | |
306 | - store.get (iter, 0, out title); |
307 | + store.get (iter, 1, out title); |
308 | |
309 | if (filter.down () in title.down ()) { |
310 | store.set_value (iter, 3, true); |
311 | @@ -155,7 +156,7 @@ |
312 | return; |
313 | |
314 | store.get_iter (out selected_plug, item); |
315 | - store.get_value (selected_plug, 0, out title); |
316 | + store.get_value (selected_plug, 1, out title); |
317 | store.get_value (selected_plug, 2, out executable); |
318 | store.get_value (selected_plug, 4, out @extern); |
319 |