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
1=== modified file 'src/Widgets/AppsButton.vala'
2--- src/Widgets/AppsButton.vala 2012-02-12 16:51:10 +0000
3+++ src/Widgets/AppsButton.vala 2012-07-12 13:35:22 +0000
4@@ -42,6 +42,58 @@
5 get_style_context ().add_class ("composited-indicator");
6 app_label.get_style_context ().add_class ("wingpanel-app-button");
7
8+ this.button_press_event.connect (launch_launcher);
9+
10+ Wingpanel.app.settings.changed.connect(on_settings_update);
11+
12+ this.show.connect(on_settings_update);
13+ }
14+
15+ private void on_settings_update () {
16+ if (this.visible && !(Wingpanel.app.settings.show_launcher)) {
17+ this.hide();
18+ }
19+ if (!(this.visible) && Wingpanel.app.settings.show_launcher) {
20+ this.show();
21+ }
22+ }
23+
24+ private bool launch_launcher (Gtk.Widget widget, Gdk.EventButton event) {
25+
26+ debug ("Starting launcher!");
27+
28+ var flags = GLib.SpawnFlags.SEARCH_PATH |
29+ GLib.SpawnFlags.DO_NOT_REAP_CHILD |
30+ GLib.SpawnFlags.STDOUT_TO_DEV_NULL;
31+
32+ GLib.Pid process_id;
33+
34+ // Parse Arguments
35+ string[] argvp = null;
36+ try {
37+ GLib.Shell.parse_argv (Wingpanel.app.settings.default_launcher, out argvp);
38+ }
39+ catch (GLib.ShellError error) {
40+ warning ("Not passing any args to %s : %s", Wingpanel.app.settings.default_launcher, error.message);
41+ argvp = {Wingpanel.app.settings.default_launcher, null}; // fix value in case it's corrupted
42+ }
43+ // Check if the program is actually there
44+ string? launcher = Environment.find_program_in_path (argvp[0]);
45+ if (launcher != null) {
46+ // Spawn process asynchronously
47+ try {
48+ GLib.Process.spawn_async (null, argvp, null, flags, null, out process_id);
49+ }
50+ catch (GLib.Error err) {
51+ warning (err.message);
52+ return false;
53+ }
54+ } else {
55+ Granite.Services.System.open_uri ("file:///usr/share/applications");
56+ }
57+
58+ return true;
59+
60 }
61
62 }
63
64=== modified file 'src/Widgets/Panel.vala'
65--- src/Widgets/Panel.vala 2012-07-10 23:28:04 +0000
66+++ src/Widgets/Panel.vala 2012-07-12 13:35:22 +0000
67@@ -230,13 +230,9 @@
68
69 private void add_defaults () {
70
71- // Only show Apps button if enabled in the settings
72- if(this.app.settings.show_launcher) {
73- var apps = new Widgets.AppsButton ();
74- apps.button_press_event.connect (launch_launcher);
75-
76- left_wrapper.pack_start (apps, false, true, 0);
77- }
78+ // Add Apps button
79+ var apps = new Widgets.AppsButton ();
80+ left_wrapper.pack_start (apps, false, true, 0);
81 container.pack_start (left_wrapper);
82
83 clock = new Gtk.MenuBar ();
84@@ -263,20 +259,6 @@
85
86 }
87
88- private bool launch_launcher (Gtk.Widget widget, Gdk.EventButton event) {
89-
90- debug ("Starting launcher!");
91-
92- string? launcher = Environment.find_program_in_path (app.settings.default_launcher);
93- if (launcher != null)
94- System.execute_command (launcher);
95- else
96- System.open_uri ("file:///usr/share/applications");
97-
98- return true;
99-
100- }
101-
102 protected override bool draw (Context cr) {
103
104 Allocation size;

Subscribers

People subscribed via source and target branches

to all changes: