Merge lp:~fabianthoma/wingpanel/wingpanel-improvements into lp:~elementary-pantheon/wingpanel/old-trunk

Proposed by Fabian Thoma
Status: Merged
Merged at revision: 88
Proposed branch: lp:~fabianthoma/wingpanel/wingpanel-improvements
Merge into: lp:~elementary-pantheon/wingpanel/old-trunk
Diff against target: 104 lines (+55/-21)
2 files modified
src/Widgets/AppsButton.vala (+52/-0)
src/Widgets/Panel.vala (+3/-21)
To merge this branch: bzr merge lp:~fabianthoma/wingpanel/wingpanel-improvements
Reviewer Review Type Date Requested Status
Cody Garver (community) Approve
Review via email: mp+114639@code.launchpad.net

Description of the change

Moved the Application Launcher Logic to the AppsButton, as well as improved the Launching code

To post a comment you must log in.
89. By Fabian Thoma

Spelling fix, man I gotta learn how to spell program right ;)

Revision history for this message
Cody Garver (codygarver) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/Widgets/AppsButton.vala'
--- src/Widgets/AppsButton.vala 2012-02-12 16:51:10 +0000
+++ src/Widgets/AppsButton.vala 2012-07-12 13:35:22 +0000
@@ -42,6 +42,58 @@
42 get_style_context ().add_class ("composited-indicator");42 get_style_context ().add_class ("composited-indicator");
43 app_label.get_style_context ().add_class ("wingpanel-app-button");43 app_label.get_style_context ().add_class ("wingpanel-app-button");
4444
45 this.button_press_event.connect (launch_launcher);
46
47 Wingpanel.app.settings.changed.connect(on_settings_update);
48
49 this.show.connect(on_settings_update);
50 }
51
52 private void on_settings_update () {
53 if (this.visible && !(Wingpanel.app.settings.show_launcher)) {
54 this.hide();
55 }
56 if (!(this.visible) && Wingpanel.app.settings.show_launcher) {
57 this.show();
58 }
59 }
60
61 private bool launch_launcher (Gtk.Widget widget, Gdk.EventButton event) {
62
63 debug ("Starting launcher!");
64
65 var flags = GLib.SpawnFlags.SEARCH_PATH |
66 GLib.SpawnFlags.DO_NOT_REAP_CHILD |
67 GLib.SpawnFlags.STDOUT_TO_DEV_NULL;
68
69 GLib.Pid process_id;
70
71 // Parse Arguments
72 string[] argvp = null;
73 try {
74 GLib.Shell.parse_argv (Wingpanel.app.settings.default_launcher, out argvp);
75 }
76 catch (GLib.ShellError error) {
77 warning ("Not passing any args to %s : %s", Wingpanel.app.settings.default_launcher, error.message);
78 argvp = {Wingpanel.app.settings.default_launcher, null}; // fix value in case it's corrupted
79 }
80 // Check if the program is actually there
81 string? launcher = Environment.find_program_in_path (argvp[0]);
82 if (launcher != null) {
83 // Spawn process asynchronously
84 try {
85 GLib.Process.spawn_async (null, argvp, null, flags, null, out process_id);
86 }
87 catch (GLib.Error err) {
88 warning (err.message);
89 return false;
90 }
91 } else {
92 Granite.Services.System.open_uri ("file:///usr/share/applications");
93 }
94
95 return true;
96
45 }97 }
4698
47 }99 }
48100
=== modified file 'src/Widgets/Panel.vala'
--- src/Widgets/Panel.vala 2012-07-10 23:28:04 +0000
+++ src/Widgets/Panel.vala 2012-07-12 13:35:22 +0000
@@ -230,13 +230,9 @@
230230
231 private void add_defaults () {231 private void add_defaults () {
232232
233 // Only show Apps button if enabled in the settings233 // Add Apps button
234 if(this.app.settings.show_launcher) {234 var apps = new Widgets.AppsButton ();
235 var apps = new Widgets.AppsButton ();235 left_wrapper.pack_start (apps, false, true, 0);
236 apps.button_press_event.connect (launch_launcher);
237
238 left_wrapper.pack_start (apps, false, true, 0);
239 }
240 container.pack_start (left_wrapper);236 container.pack_start (left_wrapper);
241237
242 clock = new Gtk.MenuBar ();238 clock = new Gtk.MenuBar ();
@@ -263,20 +259,6 @@
263259
264 }260 }
265261
266 private bool launch_launcher (Gtk.Widget widget, Gdk.EventButton event) {
267
268 debug ("Starting launcher!");
269
270 string? launcher = Environment.find_program_in_path (app.settings.default_launcher);
271 if (launcher != null)
272 System.execute_command (launcher);
273 else
274 System.open_uri ("file:///usr/share/applications");
275
276 return true;
277
278 }
279
280 protected override bool draw (Context cr) {262 protected override bool draw (Context cr) {
281263
282 Allocation size;264 Allocation size;

Subscribers

People subscribed via source and target branches

to all changes: