Merge lp:~david4dev/slingshot/fix-804518 into lp:~elementary-pantheon/slingshot/slingshot
- fix-804518
- Merge into slingshot
Status: | Merged |
---|---|
Merged at revision: | 128 |
Proposed branch: | lp:~david4dev/slingshot/fix-804518 |
Merge into: | lp:~elementary-pantheon/slingshot/slingshot |
Diff against target: |
777 lines (+260/-154) 6 files modified
backend/AppMonitor.vala (+37/-0) build (+3/-0) build_run (+3/-5) frontend/widgets/AppItem.vala (+37/-37) install (+5/-0) slingshot.vala (+175/-112) |
To merge this branch: | bzr merge lp:~david4dev/slingshot/fix-804518 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Danielle Foré | Approve | ||
Review via email: mp+68154@code.launchpad.net |
Commit message
Description of the change
Fixes bug 804518:
- Slingshot now launches in the background. This makes it suitable for auto starting.
- If the slingshot executable is run and an instance of slingshot is already running, the slingshot window will be activated. This shows the launcher without much delay.
- Slingshot now monitors /usr/share/
- Slingshot no longer shows/unshows the desktop. This is because I couldn't work out how to this with the new functionality. IMO this is actually better because you can still look at the windows you have open. This may be useful, for example, if one of them is a guide telling you which application to run.
- Removed gradient to improve readability when running slingshot over windows (or light coloured wallpapers).
- 60. By David Green
-
If slinshot is already running, it now shows the existing instance if it is hidden and hides the existing instance if it is showing.
- 61. By David Green
-
fixed issue with slingshot showing behind windows
- 62. By David Green
-
Now shows/hides the desktop again
xapantu (xapantu) wrote : | # |
Danielle Foré (danrabbit) : | # |
Preview Diff
1 | === added file 'backend/AppMonitor.vala' | |||
2 | --- backend/AppMonitor.vala 1970-01-01 00:00:00 +0000 | |||
3 | +++ backend/AppMonitor.vala 2011-08-10 18:49:27 +0000 | |||
4 | @@ -0,0 +1,37 @@ | |||
5 | 1 | namespace Slingshot.Backend { | ||
6 | 2 | |||
7 | 3 | public class AppMonitor : GLib.Object { | ||
8 | 4 | |||
9 | 5 | public GLib.File system_applications; | ||
10 | 6 | public GLib.File user_applications; | ||
11 | 7 | |||
12 | 8 | public GLib.FileMonitor system_monitor; | ||
13 | 9 | public GLib.FileMonitor user_monitor; | ||
14 | 10 | |||
15 | 11 | public signal void changed (GLib.File file, GLib.File? other_file, GLib.FileMonitorEvent event_type); | ||
16 | 12 | |||
17 | 13 | public void trigger_changed (GLib.File file, GLib.File? other_file, GLib.FileMonitorEvent event_type) { | ||
18 | 14 | this.changed(file, other_file, event_type); | ||
19 | 15 | } | ||
20 | 16 | |||
21 | 17 | construct { | ||
22 | 18 | this.system_applications = File.new_for_path("/usr/share/applications"); | ||
23 | 19 | this.user_applications = File.new_for_path(GLib.Environment.get_user_data_dir() + "/applications"); | ||
24 | 20 | try { | ||
25 | 21 | this.system_monitor = this.system_applications.monitor_directory(GLib.FileMonitorFlags.NONE); | ||
26 | 22 | this.system_monitor.changed.connect(this.trigger_changed); | ||
27 | 23 | } catch (GLib.Error e) { | ||
28 | 24 | print("Error: "+e.message+"\n"); | ||
29 | 25 | } | ||
30 | 26 | try { | ||
31 | 27 | this.user_monitor = this.user_applications.monitor_directory(GLib.FileMonitorFlags.NONE); | ||
32 | 28 | this.user_monitor.changed.connect(this.trigger_changed); | ||
33 | 29 | } catch (GLib.Error e) { | ||
34 | 30 | print("Error: "+e.message+"\n"); | ||
35 | 31 | } | ||
36 | 32 | } | ||
37 | 33 | |||
38 | 34 | } | ||
39 | 35 | |||
40 | 36 | |||
41 | 37 | } | ||
42 | 0 | 38 | ||
43 | === added file 'build' | |||
44 | --- build 1970-01-01 00:00:00 +0000 | |||
45 | +++ build 2011-08-10 18:49:27 +0000 | |||
46 | @@ -0,0 +1,3 @@ | |||
47 | 1 | #!/bin/sh | ||
48 | 2 | |||
49 | 3 | valac --pkg gtk+-2.0 --pkg unique-1.0 --pkg gee-1.0 --pkg gio-unix-2.0 --pkg gio-2.0 --pkg libgnome-menu --Xcc='-DGMENU_I_KNOW_THIS_IS_UNSTABLE' --pkg libwnck-1.0 --Xcc='-DWNCK_I_KNOW_THIS_IS_UNSTABLE' slingshot.vala frontend/widgets/*.vala frontend/*.vala backend/*.vala | ||
50 | 0 | 4 | ||
51 | === modified file 'build_run' | |||
52 | --- build_run 2011-02-12 12:16:02 +0000 | |||
53 | +++ build_run 2011-08-10 18:49:27 +0000 | |||
54 | @@ -1,7 +1,5 @@ | |||
55 | 1 | #!/bin/sh | 1 | #!/bin/sh |
56 | 2 | 2 | ||
62 | 3 | valac --pkg gtk+-2.0 --pkg unique-1.0 --pkg gee-1.0 --pkg gio-unix-2.0 --pkg libgnome-menu --Xcc='-DGMENU_I_KNOW_THIS_IS_UNSTABLE' --pkg libwnck-1.0 --Xcc='-DWNCK_I_KNOW_THIS_IS_UNSTABLE' slingshot.vala frontend/widgets/*.vala frontend/*.vala backend/*.vala | 3 | ./build |
63 | 4 | 4 | ||
64 | 5 | sudo mv slingshot /usr/bin | 5 | killall slingshot ; ./slingshot |
60 | 6 | |||
61 | 7 | slingshot | ||
65 | 8 | 6 | ||
66 | === modified file 'frontend/widgets/AppItem.vala' | |||
67 | --- frontend/widgets/AppItem.vala 2011-02-12 13:16:08 +0000 | |||
68 | +++ frontend/widgets/AppItem.vala 2011-08-10 18:49:27 +0000 | |||
69 | @@ -2,13 +2,13 @@ | |||
70 | 2 | namespace Slingshot.Frontend { | 2 | namespace Slingshot.Frontend { |
71 | 3 | 3 | ||
72 | 4 | public class AppItem : Gtk.EventBox { | 4 | public class AppItem : Gtk.EventBox { |
74 | 5 | 5 | ||
75 | 6 | private Gdk.Pixbuf icon; | 6 | private Gdk.Pixbuf icon; |
76 | 7 | private Slingshot.Frontend.Color prominent; | 7 | private Slingshot.Frontend.Color prominent; |
77 | 8 | private string label; | 8 | private string label; |
78 | 9 | private Gtk.VBox wrapper; | 9 | private Gtk.VBox wrapper; |
79 | 10 | private int icon_size; | 10 | private int icon_size; |
81 | 11 | 11 | ||
82 | 12 | const int FPS = 24; | 12 | const int FPS = 24; |
83 | 13 | const int DURATION = 200; | 13 | const int DURATION = 200; |
84 | 14 | const int RUN_LENGTH = (int)(DURATION/FPS); // total number of frames | 14 | const int RUN_LENGTH = (int)(DURATION/FPS); // total number of frames |
85 | @@ -16,44 +16,44 @@ | |||
86 | 16 | 16 | ||
87 | 17 | public AppItem (int size) { | 17 | public AppItem (int size) { |
88 | 18 | this.icon_size = size; | 18 | this.icon_size = size; |
90 | 19 | 19 | ||
91 | 20 | // EventBox Properties | 20 | // EventBox Properties |
92 | 21 | this.set_visible_window(false); | 21 | this.set_visible_window(false); |
93 | 22 | this.can_focus = true; | 22 | this.can_focus = true; |
94 | 23 | this.set_size_request (icon_size * 2, icon_size + 30); // 30 is the padding between icon and label and label's height | 23 | this.set_size_request (icon_size * 2, icon_size + 30); // 30 is the padding between icon and label and label's height |
96 | 24 | 24 | ||
97 | 25 | // VBox properties | 25 | // VBox properties |
98 | 26 | this.wrapper = new Gtk.VBox (false, 0); | 26 | this.wrapper = new Gtk.VBox (false, 0); |
99 | 27 | this.wrapper.expose_event.connect (this.draw_icon); | 27 | this.wrapper.expose_event.connect (this.draw_icon); |
100 | 28 | this.add (this.wrapper); | 28 | this.add (this.wrapper); |
103 | 29 | 29 | ||
104 | 30 | 30 | ||
105 | 31 | // Focused signals | 31 | // Focused signals |
106 | 32 | this.expose_event.connect (this.draw_background); | 32 | this.expose_event.connect (this.draw_background); |
107 | 33 | this.focus_in_event.connect ( () => { this.focus_in (); return true;} ); | 33 | this.focus_in_event.connect ( () => { this.focus_in (); return true;} ); |
108 | 34 | this.focus_out_event.connect ( () => { this.focus_out (); return true;} ); | 34 | this.focus_out_event.connect ( () => { this.focus_out (); return true;} ); |
110 | 35 | 35 | ||
111 | 36 | } | 36 | } |
113 | 37 | 37 | ||
114 | 38 | public void change_app (Gdk.Pixbuf new_icon, string new_name, string new_tooltip) { | 38 | public void change_app (Gdk.Pixbuf new_icon, string new_name, string new_tooltip) { |
115 | 39 | this.current_frame = 1; | 39 | this.current_frame = 1; |
117 | 40 | 40 | ||
118 | 41 | // Icon | 41 | // Icon |
119 | 42 | this.icon = new_icon; | 42 | this.icon = new_icon; |
120 | 43 | this.prominent = Slingshot.Frontend.Utilities.average_color (this.icon); | 43 | this.prominent = Slingshot.Frontend.Utilities.average_color (this.icon); |
122 | 44 | 44 | ||
123 | 45 | // Label | 45 | // Label |
124 | 46 | this.label = new_name; | 46 | this.label = new_name; |
126 | 47 | 47 | ||
127 | 48 | // Tooltip | 48 | // Tooltip |
128 | 49 | this.set_tooltip_text (new_tooltip); | 49 | this.set_tooltip_text (new_tooltip); |
130 | 50 | 50 | ||
131 | 51 | // Redraw | 51 | // Redraw |
132 | 52 | this.wrapper.queue_draw (); | 52 | this.wrapper.queue_draw (); |
133 | 53 | } | 53 | } |
135 | 54 | 54 | ||
136 | 55 | public new void focus_in () { | 55 | public new void focus_in () { |
138 | 56 | 56 | ||
139 | 57 | GLib.Timeout.add (((int)(1000/this.FPS)), () => { | 57 | GLib.Timeout.add (((int)(1000/this.FPS)), () => { |
140 | 58 | if (this.current_frame >= this.RUN_LENGTH || !this.has_focus) { | 58 | if (this.current_frame >= this.RUN_LENGTH || !this.has_focus) { |
141 | 59 | current_frame = 1; | 59 | current_frame = 1; |
142 | @@ -63,11 +63,11 @@ | |||
143 | 63 | this.current_frame++; | 63 | this.current_frame++; |
144 | 64 | return true; | 64 | return true; |
145 | 65 | }); | 65 | }); |
147 | 66 | 66 | ||
148 | 67 | } | 67 | } |
150 | 68 | 68 | ||
151 | 69 | public new void focus_out () { | 69 | public new void focus_out () { |
153 | 70 | 70 | ||
154 | 71 | GLib.Timeout.add (((int)(1000/this.FPS)), () => { | 71 | GLib.Timeout.add (((int)(1000/this.FPS)), () => { |
155 | 72 | if (this.current_frame >= this.RUN_LENGTH || this.has_focus) { | 72 | if (this.current_frame >= this.RUN_LENGTH || this.has_focus) { |
156 | 73 | current_frame = 1; | 73 | current_frame = 1; |
157 | @@ -77,76 +77,76 @@ | |||
158 | 77 | this.current_frame++; | 77 | this.current_frame++; |
159 | 78 | return true; | 78 | return true; |
160 | 79 | }); | 79 | }); |
162 | 80 | 80 | ||
163 | 81 | } | 81 | } |
165 | 82 | 82 | ||
166 | 83 | private bool draw_icon (Gtk.Widget widget, Gdk.EventExpose event) { | 83 | private bool draw_icon (Gtk.Widget widget, Gdk.EventExpose event) { |
167 | 84 | Gtk.Allocation size; | 84 | Gtk.Allocation size; |
168 | 85 | widget.get_allocation (out size); | 85 | widget.get_allocation (out size); |
169 | 86 | var context = Gdk.cairo_create (widget.window); | 86 | var context = Gdk.cairo_create (widget.window); |
171 | 87 | 87 | ||
172 | 88 | // Draw icon | 88 | // Draw icon |
173 | 89 | Gdk.cairo_set_source_pixbuf (context, this.icon, size.x + ((this.icon.width - size.width) / -2.0), size.y); | 89 | Gdk.cairo_set_source_pixbuf (context, this.icon, size.x + ((this.icon.width - size.width) / -2.0), size.y); |
174 | 90 | context.paint (); | 90 | context.paint (); |
176 | 91 | 91 | ||
177 | 92 | // Truncate text | 92 | // Truncate text |
178 | 93 | Cairo.TextExtents extents; | 93 | Cairo.TextExtents extents; |
179 | 94 | context.select_font_face ("Sans", Cairo.FontSlant.NORMAL, Cairo.FontWeight.NORMAL); | 94 | context.select_font_face ("Sans", Cairo.FontSlant.NORMAL, Cairo.FontWeight.NORMAL); |
180 | 95 | context.set_font_size (11.5); | 95 | context.set_font_size (11.5); |
181 | 96 | Slingshot.Frontend.Utilities.truncate_text (context, size, 10, this.label, out this.label, out extents); // truncate text | 96 | Slingshot.Frontend.Utilities.truncate_text (context, size, 10, this.label, out this.label, out extents); // truncate text |
183 | 97 | 97 | ||
184 | 98 | // Draw text shadow | 98 | // Draw text shadow |
185 | 99 | context.move_to ((size.x + size.width/2 - extents.width/2) + 1, (size.y + size.height - 10) + 1); | 99 | context.move_to ((size.x + size.width/2 - extents.width/2) + 1, (size.y + size.height - 10) + 1); |
186 | 100 | context.set_source_rgba (0.0, 0.0, 0.0, 0.8); | 100 | context.set_source_rgba (0.0, 0.0, 0.0, 0.8); |
187 | 101 | context.show_text (this.label); | 101 | context.show_text (this.label); |
191 | 102 | 102 | ||
192 | 103 | // Draw normal text | 103 | // Draw normal text |
193 | 104 | context.set_source_rgba (1.0, 1.0, 1.0, 1.0); | 104 | context.set_source_rgba (1.0, 1.0, 1.0, 1.0); |
194 | 105 | context.move_to (size.x + size.width/2 - extents.width/2, size.y + size.height - 10); | 105 | context.move_to (size.x + size.width/2 - extents.width/2, size.y + size.height - 10); |
195 | 106 | context.show_text (this.label); | 106 | context.show_text (this.label); |
197 | 107 | 107 | ||
198 | 108 | return false; | 108 | return false; |
199 | 109 | } | 109 | } |
201 | 110 | 110 | ||
202 | 111 | private bool draw_background (Gtk.Widget widget, Gdk.EventExpose event) { | 111 | private bool draw_background (Gtk.Widget widget, Gdk.EventExpose event) { |
203 | 112 | Gtk.Allocation size; | 112 | Gtk.Allocation size; |
204 | 113 | widget.get_allocation (out size); | 113 | widget.get_allocation (out size); |
205 | 114 | var context = Gdk.cairo_create (widget.window); | 114 | var context = Gdk.cairo_create (widget.window); |
207 | 115 | 115 | ||
208 | 116 | double progress; | 116 | double progress; |
209 | 117 | if (this.current_frame > 1) { | 117 | if (this.current_frame > 1) { |
210 | 118 | progress = (double)this.RUN_LENGTH/(double)this.current_frame; | 118 | progress = (double)this.RUN_LENGTH/(double)this.current_frame; |
211 | 119 | } else { | 119 | } else { |
212 | 120 | progress = 1; | 120 | progress = 1; |
213 | 121 | } | 121 | } |
215 | 122 | 122 | ||
216 | 123 | if (this.has_focus) { | 123 | if (this.has_focus) { |
218 | 124 | 124 | ||
219 | 125 | var linear_gradient = new Cairo.Pattern.linear (size.x, size.y, size.x, size.y + size.height); | 125 | var linear_gradient = new Cairo.Pattern.linear (size.x, size.y, size.x, size.y + size.height); |
220 | 126 | linear_gradient.add_color_stop_rgba (0.0, this.prominent.R, this.prominent.G, this.prominent.B, 0.0); | 126 | linear_gradient.add_color_stop_rgba (0.0, this.prominent.R, this.prominent.G, this.prominent.B, 0.0); |
221 | 127 | linear_gradient.add_color_stop_rgba (0.5, this.prominent.R, this.prominent.G, this.prominent.B, 0.25/progress); | 127 | linear_gradient.add_color_stop_rgba (0.5, this.prominent.R, this.prominent.G, this.prominent.B, 0.25/progress); |
222 | 128 | linear_gradient.add_color_stop_rgba (1.0, this.prominent.R, this.prominent.G, this.prominent.B, 0.4/progress); | 128 | linear_gradient.add_color_stop_rgba (1.0, this.prominent.R, this.prominent.G, this.prominent.B, 0.4/progress); |
224 | 129 | 129 | ||
225 | 130 | context.set_source (linear_gradient); | 130 | context.set_source (linear_gradient); |
226 | 131 | Slingshot.Frontend.Utilities.draw_rounded_rectangle (context, 10, 0.5, size); | 131 | Slingshot.Frontend.Utilities.draw_rounded_rectangle (context, 10, 0.5, size); |
227 | 132 | context.fill (); | 132 | context.fill (); |
229 | 133 | 133 | ||
230 | 134 | } else { | 134 | } else { |
232 | 135 | if (this.current_frame > 1) { | 135 | if (this.current_frame > 1) { |
233 | 136 | var linear_gradient = new Cairo.Pattern.linear (size.x, size.y, size.x, size.y + size.height); | 136 | var linear_gradient = new Cairo.Pattern.linear (size.x, size.y, size.x, size.y + size.height); |
234 | 137 | linear_gradient.add_color_stop_rgba (0.0, this.prominent.R, this.prominent.G, this.prominent.B, 0.0); | 137 | linear_gradient.add_color_stop_rgba (0.0, this.prominent.R, this.prominent.G, this.prominent.B, 0.0); |
235 | 138 | linear_gradient.add_color_stop_rgba (0.5, this.prominent.R, this.prominent.G, this.prominent.B, 0.25 - 0.25/progress); | 138 | linear_gradient.add_color_stop_rgba (0.5, this.prominent.R, this.prominent.G, this.prominent.B, 0.25 - 0.25/progress); |
236 | 139 | linear_gradient.add_color_stop_rgba (1.0, this.prominent.R, this.prominent.G, this.prominent.B, 0.4 - 0.4/progress); | 139 | linear_gradient.add_color_stop_rgba (1.0, this.prominent.R, this.prominent.G, this.prominent.B, 0.4 - 0.4/progress); |
238 | 140 | 140 | ||
239 | 141 | context.set_source (linear_gradient); | 141 | context.set_source (linear_gradient); |
240 | 142 | Slingshot.Frontend.Utilities.draw_rounded_rectangle (context, 10, 0.5, size); | 142 | Slingshot.Frontend.Utilities.draw_rounded_rectangle (context, 10, 0.5, size); |
241 | 143 | context.fill (); | 143 | context.fill (); |
242 | 144 | } | 144 | } |
243 | 145 | } | 145 | } |
245 | 146 | 146 | ||
246 | 147 | return false; | 147 | return false; |
247 | 148 | } | 148 | } |
250 | 149 | 149 | ||
251 | 150 | 150 | ||
252 | 151 | } | 151 | } |
253 | 152 | } | 152 | } |
254 | 153 | 153 | ||
255 | === added file 'install' | |||
256 | --- install 1970-01-01 00:00:00 +0000 | |||
257 | +++ install 2011-08-10 18:49:27 +0000 | |||
258 | @@ -0,0 +1,5 @@ | |||
259 | 1 | #!/bin/sh | ||
260 | 2 | |||
261 | 3 | ./build | ||
262 | 4 | |||
263 | 5 | sudo mv slingshot /usr/bin/ | ||
264 | 0 | 6 | ||
265 | === modified file 'slingshot.vala' | |||
266 | --- slingshot.vala 2011-02-19 14:51:06 +0000 | |||
267 | +++ slingshot.vala 2011-08-10 18:49:27 +0000 | |||
268 | @@ -3,11 +3,11 @@ | |||
269 | 3 | public GLib.List<Slingshot.Frontend.AppItem> children = new GLib.List<Slingshot.Frontend.AppItem> (); | 3 | public GLib.List<Slingshot.Frontend.AppItem> children = new GLib.List<Slingshot.Frontend.AppItem> (); |
270 | 4 | public Slingshot.Frontend.Searchbar searchbar; | 4 | public Slingshot.Frontend.Searchbar searchbar; |
271 | 5 | public Slingshot.Frontend.Grid grid; | 5 | public Slingshot.Frontend.Grid grid; |
273 | 6 | 6 | ||
274 | 7 | public Gee.ArrayList<Gee.HashMap<string, string>> apps = new Gee.ArrayList<Gee.HashMap<string, string>> (); | 7 | public Gee.ArrayList<Gee.HashMap<string, string>> apps = new Gee.ArrayList<Gee.HashMap<string, string>> (); |
275 | 8 | public Gee.HashMap<string, Gdk.Pixbuf> icons = new Gee.HashMap<string, Gdk.Pixbuf>(); | 8 | public Gee.HashMap<string, Gdk.Pixbuf> icons = new Gee.HashMap<string, Gdk.Pixbuf>(); |
276 | 9 | public Gee.ArrayList<Gee.HashMap<string, string>> filtered = new Gee.ArrayList<Gee.HashMap<string, string>> (); | 9 | public Gee.ArrayList<Gee.HashMap<string, string>> filtered = new Gee.ArrayList<Gee.HashMap<string, string>> (); |
278 | 10 | 10 | ||
279 | 11 | public Slingshot.Frontend.Indicators pages; | 11 | public Slingshot.Frontend.Indicators pages; |
280 | 12 | public Slingshot.Frontend.Indicators categories; | 12 | public Slingshot.Frontend.Indicators categories; |
281 | 13 | public Gee.ArrayList<GMenu.TreeDirectory> all_categories = Slingshot.Backend.GMenuEntries.get_categories (); | 13 | public Gee.ArrayList<GMenu.TreeDirectory> all_categories = Slingshot.Backend.GMenuEntries.get_categories (); |
282 | @@ -15,11 +15,13 @@ | |||
283 | 15 | public int total_pages; | 15 | public int total_pages; |
284 | 16 | public Gtk.HBox top_spacer; | 16 | public Gtk.HBox top_spacer; |
285 | 17 | 17 | ||
286 | 18 | Slingshot.Backend.AppMonitor monitor; | ||
287 | 19 | public bool is_showing; | ||
288 | 20 | |||
289 | 18 | public SlingshotWindow () { | 21 | public SlingshotWindow () { |
294 | 19 | 22 | ||
295 | 20 | // Show desktop | 23 | this.is_showing = false; |
296 | 21 | Wnck.Screen.get_default().toggle_showing_desktop (true); | 24 | |
293 | 22 | |||
297 | 23 | // Window properties | 25 | // Window properties |
298 | 24 | this.title = "Slingshot"; | 26 | this.title = "Slingshot"; |
299 | 25 | this.skip_pager_hint = true; | 27 | this.skip_pager_hint = true; |
300 | @@ -27,13 +29,13 @@ | |||
301 | 27 | this.set_type_hint (Gdk.WindowTypeHint.NORMAL); | 29 | this.set_type_hint (Gdk.WindowTypeHint.NORMAL); |
302 | 28 | this.maximize (); | 30 | this.maximize (); |
303 | 29 | this.stick (); | 31 | this.stick (); |
306 | 30 | this.set_keep_above (true); | 32 | this.set_keep_above(true); |
307 | 31 | 33 | ||
308 | 32 | // Set icon size | 34 | // Set icon size |
309 | 33 | Gdk.Rectangle monitor_dimensions; | 35 | Gdk.Rectangle monitor_dimensions; |
310 | 34 | Gdk.Screen screen = Gdk.Screen.get_default(); | 36 | Gdk.Screen screen = Gdk.Screen.get_default(); |
311 | 35 | screen.get_monitor_geometry(screen.get_primary_monitor(), out monitor_dimensions); | 37 | screen.get_monitor_geometry(screen.get_primary_monitor(), out monitor_dimensions); |
313 | 36 | 38 | ||
314 | 37 | double suggested_size = (Math.pow (monitor_dimensions.width * monitor_dimensions.height, ((double) (1.0/3.0))) / 1.6); | 39 | double suggested_size = (Math.pow (monitor_dimensions.width * monitor_dimensions.height, ((double) (1.0/3.0))) / 1.6); |
315 | 38 | if (suggested_size < 27) { | 40 | if (suggested_size < 27) { |
316 | 39 | this.icon_size = 24; | 41 | this.icon_size = 24; |
317 | @@ -44,22 +46,22 @@ | |||
318 | 44 | } else if (suggested_size >= 56) { | 46 | } else if (suggested_size >= 56) { |
319 | 45 | this.icon_size = 64; | 47 | this.icon_size = 64; |
320 | 46 | } | 48 | } |
322 | 47 | 49 | ||
323 | 48 | // Get all apps | 50 | // Get all apps |
326 | 49 | Slingshot.Backend.GMenuEntries.enumerate_apps (Slingshot.Backend.GMenuEntries.get_all (), this.icons, this.icon_size, out this.apps); | 51 | this.refresh_apps(); |
327 | 50 | 52 | ||
328 | 51 | // Add container wrapper | 53 | // Add container wrapper |
329 | 52 | var wrapper = new Gtk.EventBox (); // used for the scrolling and button press events | 54 | var wrapper = new Gtk.EventBox (); // used for the scrolling and button press events |
330 | 53 | wrapper.set_visible_window (false); | 55 | wrapper.set_visible_window (false); |
331 | 54 | this.add (wrapper); | 56 | this.add (wrapper); |
333 | 55 | 57 | ||
334 | 56 | // Add container | 58 | // Add container |
335 | 57 | var container = new Gtk.VBox (false, 15); | 59 | var container = new Gtk.VBox (false, 15); |
336 | 58 | wrapper.add (container); | 60 | wrapper.add (container); |
338 | 59 | 61 | ||
339 | 60 | // Add top bar | 62 | // Add top bar |
340 | 61 | var top = new Gtk.HBox (false, 0); | 63 | var top = new Gtk.HBox (false, 0); |
342 | 62 | 64 | ||
343 | 63 | this.categories = new Slingshot.Frontend.Indicators (); | 65 | this.categories = new Slingshot.Frontend.Indicators (); |
344 | 64 | this.categories.child_activated.connect (this.change_category); | 66 | this.categories.child_activated.connect (this.change_category); |
345 | 65 | this.categories.append ("All"); | 67 | this.categories.append ("All"); |
346 | @@ -68,18 +70,18 @@ | |||
347 | 68 | } | 70 | } |
348 | 69 | this.categories.set_active (0); | 71 | this.categories.set_active (0); |
349 | 70 | top.pack_start (this.categories, true, true, 15); | 72 | top.pack_start (this.categories, true, true, 15); |
351 | 71 | 73 | ||
352 | 72 | this.top_spacer = new Gtk.HBox (false, 0); | 74 | this.top_spacer = new Gtk.HBox (false, 0); |
353 | 73 | this.top_spacer.realize.connect ( () => { this.top_spacer.visible = false; } ); | 75 | this.top_spacer.realize.connect ( () => { this.top_spacer.visible = false; } ); |
354 | 74 | this.top_spacer.can_focus = true; | 76 | this.top_spacer.can_focus = true; |
355 | 75 | top.pack_start (this.top_spacer, false, false, 0); | 77 | top.pack_start (this.top_spacer, false, false, 0); |
357 | 76 | 78 | ||
358 | 77 | this.searchbar = new Slingshot.Frontend.Searchbar ("Start typing to search..."); | 79 | this.searchbar = new Slingshot.Frontend.Searchbar ("Start typing to search..."); |
359 | 78 | this.searchbar.changed.connect (this.search); | 80 | this.searchbar.changed.connect (this.search); |
360 | 79 | top.pack_start (this.searchbar, false, true, 15); | 81 | top.pack_start (this.searchbar, false, true, 15); |
364 | 80 | 82 | ||
365 | 81 | container.pack_start (top, false, true, 15); | 83 | container.pack_start (top, false, true, 15); |
366 | 82 | 84 | ||
367 | 83 | // Make icon grid and populate | 85 | // Make icon grid and populate |
368 | 84 | if (monitor_dimensions.width > monitor_dimensions.height) { // normal landscape orientation | 86 | if (monitor_dimensions.width > monitor_dimensions.height) { // normal landscape orientation |
369 | 85 | this.grid = new Slingshot.Frontend.Grid (4, 6); | 87 | this.grid = new Slingshot.Frontend.Grid (4, 6); |
370 | @@ -87,77 +89,82 @@ | |||
371 | 87 | this.grid = new Slingshot.Frontend.Grid (6, 4); | 89 | this.grid = new Slingshot.Frontend.Grid (6, 4); |
372 | 88 | } | 90 | } |
373 | 89 | container.pack_start (this.grid, true, true, 0); | 91 | container.pack_start (this.grid, true, true, 0); |
375 | 90 | 92 | ||
376 | 91 | this.populate_grid (); | 93 | this.populate_grid (); |
378 | 92 | 94 | ||
379 | 93 | // Add pages | 95 | // Add pages |
380 | 94 | this.pages = new Slingshot.Frontend.Indicators (); | 96 | this.pages = new Slingshot.Frontend.Indicators (); |
381 | 95 | this.pages.child_activated.connect ( () => { this.update_grid (this.filtered); } ); | 97 | this.pages.child_activated.connect ( () => { this.update_grid (this.filtered); } ); |
383 | 96 | 98 | ||
384 | 97 | var pages_wrapper = new Gtk.HBox (false, 0); | 99 | var pages_wrapper = new Gtk.HBox (false, 0); |
386 | 98 | pages_wrapper.set_size_request (-1, 30); | 100 | pages_wrapper.set_size_request (-1, 30); |
387 | 99 | container.pack_end (pages_wrapper, false, true, 15); | 101 | container.pack_end (pages_wrapper, false, true, 15); |
389 | 100 | 102 | ||
390 | 101 | // Find number of pages and populate | 103 | // Find number of pages and populate |
391 | 102 | this.update_pages (this.apps); | 104 | this.update_pages (this.apps); |
392 | 103 | if (this.total_pages > 1) { | 105 | if (this.total_pages > 1) { |
393 | 104 | pages_wrapper.pack_start (this.pages, true, false, 0); | 106 | pages_wrapper.pack_start (this.pages, true, false, 0); |
394 | 105 | for (int p = 1; p <= this.total_pages; p++) { | 107 | for (int p = 1; p <= this.total_pages; p++) { |
395 | 106 | this.pages.append (p.to_string ()); | 108 | this.pages.append (p.to_string ()); |
397 | 107 | } | 109 | } |
398 | 108 | } | 110 | } |
399 | 109 | this.pages.set_active (0); | 111 | this.pages.set_active (0); |
401 | 110 | 112 | ||
402 | 111 | // Signals and callbacks | 113 | // Signals and callbacks |
404 | 112 | this.button_release_event.connect ( () => { this.destroy(); return false; }); | 114 | this.button_release_event.connect ( () => { this.hide_slingshot(); return false; }); |
405 | 113 | this.expose_event.connect (this.draw_background); | 115 | this.expose_event.connect (this.draw_background); |
407 | 114 | this.focus_out_event.connect ( () => { this.destroy(); return true; } ); // close slingshot when the window loses focus | 116 | this.focus_out_event.connect ( () => { this.hide_slingshot(); return true; } ); // close slingshot when the window loses focus |
408 | 117 | |||
409 | 118 | //set up app monitor | ||
410 | 119 | //refreshes when apps are added/removed | ||
411 | 120 | this.monitor = new Slingshot.Backend.AppMonitor(); | ||
412 | 121 | this.monitor.changed.connect(this.refresh_apps); | ||
413 | 115 | } | 122 | } |
417 | 116 | 123 | ||
418 | 117 | private void populate_grid () { | 124 | private void populate_grid () { |
419 | 118 | 125 | ||
420 | 119 | for (int r = 0; r < this.grid.n_rows; r++) { | 126 | for (int r = 0; r < this.grid.n_rows; r++) { |
422 | 120 | 127 | ||
423 | 121 | for (int c = 0; c < this.grid.n_columns; c++) { | 128 | for (int c = 0; c < this.grid.n_columns; c++) { |
425 | 122 | 129 | ||
426 | 123 | var item = new Slingshot.Frontend.AppItem (this.icon_size); | 130 | var item = new Slingshot.Frontend.AppItem (this.icon_size); |
427 | 124 | this.children.append (item); | 131 | this.children.append (item); |
429 | 125 | 132 | ||
430 | 126 | item.button_press_event.connect ( () => { item.grab_focus (); return true; } ); | 133 | item.button_press_event.connect ( () => { item.grab_focus (); return true; } ); |
431 | 127 | item.enter_notify_event.connect ( () => { item.grab_focus (); return true; } ); | 134 | item.enter_notify_event.connect ( () => { item.grab_focus (); return true; } ); |
432 | 128 | item.leave_notify_event.connect ( () => { this.top_spacer.grab_focus (); return true; } ); | 135 | item.leave_notify_event.connect ( () => { this.top_spacer.grab_focus (); return true; } ); |
433 | 129 | item.button_release_event.connect ( () => { | 136 | item.button_release_event.connect ( () => { |
435 | 130 | 137 | ||
436 | 131 | try { | 138 | try { |
437 | 132 | new GLib.DesktopAppInfo.from_filename (this.filtered.get((int) (this.children.index(item) + (this.pages.active * this.grid.n_columns * this.grid.n_rows)))["desktop_file"]).launch (null, null); | 139 | new GLib.DesktopAppInfo.from_filename (this.filtered.get((int) (this.children.index(item) + (this.pages.active * this.grid.n_columns * this.grid.n_rows)))["desktop_file"]).launch (null, null); |
439 | 133 | this.destroy(); | 140 | this.hide_slingshot(); |
440 | 134 | } catch (GLib.Error e) { | 141 | } catch (GLib.Error e) { |
441 | 135 | stdout.printf("Error! Load application: " + e.message); | 142 | stdout.printf("Error! Load application: " + e.message); |
442 | 136 | } | 143 | } |
444 | 137 | 144 | ||
445 | 138 | return true; | 145 | return true; |
447 | 139 | 146 | ||
448 | 140 | }); | 147 | }); |
450 | 141 | 148 | ||
451 | 142 | this.grid.attach (item, c, c + 1, r, r + 1, Gtk.AttachOptions.EXPAND, Gtk.AttachOptions.EXPAND, 0, 0); | 149 | this.grid.attach (item, c, c + 1, r, r + 1, Gtk.AttachOptions.EXPAND, Gtk.AttachOptions.EXPAND, 0, 0); |
455 | 143 | 150 | ||
456 | 144 | } | 151 | } |
457 | 145 | } | 152 | } |
458 | 146 | } | 153 | } |
462 | 147 | 154 | ||
463 | 148 | private void update_grid (Gee.ArrayList<Gee.HashMap<string, string>> apps) { | 155 | private void update_grid (Gee.ArrayList<Gee.HashMap<string, string>> apps) { |
464 | 149 | 156 | ||
465 | 150 | int item_iter = (int)(this.pages.active * this.grid.n_columns * this.grid.n_rows); | 157 | int item_iter = (int)(this.pages.active * this.grid.n_columns * this.grid.n_rows); |
466 | 151 | for (int r = 0; r < this.grid.n_rows; r++) { | 158 | for (int r = 0; r < this.grid.n_rows; r++) { |
468 | 152 | 159 | ||
469 | 153 | for (int c = 0; c < this.grid.n_columns; c++) { | 160 | for (int c = 0; c < this.grid.n_columns; c++) { |
471 | 154 | 161 | ||
472 | 155 | int table_pos = c + (r * (int)this.grid.n_columns); // position in table right now | 162 | int table_pos = c + (r * (int)this.grid.n_columns); // position in table right now |
474 | 156 | 163 | ||
475 | 157 | var item = this.children.nth_data(table_pos); | 164 | var item = this.children.nth_data(table_pos); |
476 | 158 | if (item_iter < apps.size) { | 165 | if (item_iter < apps.size) { |
477 | 159 | var current_item = apps.get(item_iter); | 166 | var current_item = apps.get(item_iter); |
479 | 160 | 167 | ||
480 | 161 | // Update app | 168 | // Update app |
481 | 162 | if (current_item["description"] == null || current_item["description"] == "") { | 169 | if (current_item["description"] == null || current_item["description"] == "") { |
482 | 163 | item.change_app (icons[current_item["command"]], current_item["name"], current_item["name"]); | 170 | item.change_app (icons[current_item["command"]], current_item["name"], current_item["name"]); |
483 | @@ -169,36 +176,36 @@ | |||
484 | 169 | } else { // fill with a blank one | 176 | } else { // fill with a blank one |
485 | 170 | item.visible = false; | 177 | item.visible = false; |
486 | 171 | } | 178 | } |
488 | 172 | 179 | ||
489 | 173 | item_iter++; | 180 | item_iter++; |
491 | 174 | 181 | ||
492 | 175 | } | 182 | } |
493 | 176 | } | 183 | } |
495 | 177 | 184 | ||
496 | 178 | // Update number of pages | 185 | // Update number of pages |
497 | 179 | this.update_pages (apps); | 186 | this.update_pages (apps); |
499 | 180 | 187 | ||
500 | 181 | // Grab first one's focus | 188 | // Grab first one's focus |
501 | 182 | this.children.nth_data (0).grab_focus (); | 189 | this.children.nth_data (0).grab_focus (); |
502 | 183 | } | 190 | } |
504 | 184 | 191 | ||
505 | 185 | private void change_category () { | 192 | private void change_category () { |
506 | 186 | this.filtered.clear (); | 193 | this.filtered.clear (); |
508 | 187 | 194 | ||
509 | 188 | if (this.categories.active != 0) { | 195 | if (this.categories.active != 0) { |
510 | 189 | Slingshot.Backend.GMenuEntries.enumerate_apps (Slingshot.Backend.GMenuEntries.get_applications_for_category (this.all_categories.get (this.categories.active - 1)), this.icons, this.icon_size, out this.filtered); | 196 | Slingshot.Backend.GMenuEntries.enumerate_apps (Slingshot.Backend.GMenuEntries.get_applications_for_category (this.all_categories.get (this.categories.active - 1)), this.icons, this.icon_size, out this.filtered); |
511 | 190 | } else { | 197 | } else { |
512 | 191 | this.filtered.add_all (this.apps); | 198 | this.filtered.add_all (this.apps); |
513 | 192 | } | 199 | } |
515 | 193 | 200 | ||
516 | 194 | this.pages.set_active (0); // go back to first page in category | 201 | this.pages.set_active (0); // go back to first page in category |
517 | 195 | } | 202 | } |
519 | 196 | 203 | ||
520 | 197 | private void update_pages (Gee.ArrayList<Gee.HashMap<string, string>> apps) { | 204 | private void update_pages (Gee.ArrayList<Gee.HashMap<string, string>> apps) { |
521 | 198 | // Find current number of pages and update count | 205 | // Find current number of pages and update count |
522 | 199 | var num_pages = (int) (apps.size / (this.grid.n_columns * this.grid.n_rows)); | 206 | var num_pages = (int) (apps.size / (this.grid.n_columns * this.grid.n_rows)); |
523 | 200 | (double) apps.size % (double) (this.grid.n_columns * this.grid.n_rows) > 0 ? this.total_pages = num_pages + 1 : this.total_pages = num_pages; | 207 | (double) apps.size % (double) (this.grid.n_columns * this.grid.n_rows) > 0 ? this.total_pages = num_pages + 1 : this.total_pages = num_pages; |
525 | 201 | 208 | ||
526 | 202 | // Update pages | 209 | // Update pages |
527 | 203 | if (this.total_pages > 1) { | 210 | if (this.total_pages > 1) { |
528 | 204 | this.pages.visible = true; | 211 | this.pages.visible = true; |
529 | @@ -208,41 +215,41 @@ | |||
530 | 208 | } else { | 215 | } else { |
531 | 209 | this.pages.visible = false; | 216 | this.pages.visible = false; |
532 | 210 | } | 217 | } |
534 | 211 | 218 | ||
535 | 212 | } | 219 | } |
537 | 213 | 220 | ||
538 | 214 | private void search() { | 221 | private void search() { |
540 | 215 | 222 | ||
541 | 216 | var current_text = this.searchbar.text.down (); | 223 | var current_text = this.searchbar.text.down (); |
543 | 217 | 224 | ||
544 | 218 | this.categories.set_active_no_signal (0); // switch to first page | 225 | this.categories.set_active_no_signal (0); // switch to first page |
545 | 219 | this.filtered.clear (); | 226 | this.filtered.clear (); |
547 | 220 | 227 | ||
548 | 221 | foreach (Gee.HashMap<string, string> app in this.apps) { | 228 | foreach (Gee.HashMap<string, string> app in this.apps) { |
549 | 222 | if (current_text in app["name"].down () || current_text in app["description"].down () || current_text in app["command"].down ()) { | 229 | if (current_text in app["name"].down () || current_text in app["description"].down () || current_text in app["command"].down ()) { |
550 | 223 | this.filtered.add (app); | 230 | this.filtered.add (app); |
551 | 224 | } | 231 | } |
556 | 225 | } | 232 | } |
557 | 226 | 233 | ||
558 | 227 | this.pages.set_active (0); | 234 | this.pages.set_active (0); |
559 | 228 | 235 | ||
560 | 229 | this.queue_draw (); | 236 | this.queue_draw (); |
561 | 230 | } | 237 | } |
563 | 231 | 238 | ||
564 | 232 | private void page_left() { | 239 | private void page_left() { |
566 | 233 | 240 | ||
567 | 234 | if (this.pages.active >= 1) { | 241 | if (this.pages.active >= 1) { |
568 | 235 | this.pages.set_active (this.pages.active - 1); | 242 | this.pages.set_active (this.pages.active - 1); |
569 | 236 | } | 243 | } |
571 | 237 | 244 | ||
572 | 238 | } | 245 | } |
574 | 239 | 246 | ||
575 | 240 | private void page_right() { | 247 | private void page_right() { |
577 | 241 | 248 | ||
578 | 242 | if ((this.pages.active + 1) < this.total_pages) { | 249 | if ((this.pages.active + 1) < this.total_pages) { |
579 | 243 | this.pages.set_active (this.pages.active + 1); | 250 | this.pages.set_active (this.pages.active + 1); |
580 | 244 | } | 251 | } |
582 | 245 | 252 | ||
583 | 246 | } | 253 | } |
584 | 247 | 254 | ||
585 | 248 | private bool draw_background (Gtk.Widget widget, Gdk.EventExpose event) { | 255 | private bool draw_background (Gtk.Widget widget, Gdk.EventExpose event) { |
586 | @@ -253,21 +260,19 @@ | |||
587 | 253 | // Semi-dark background | 260 | // Semi-dark background |
588 | 254 | var linear_gradient = new Cairo.Pattern.linear (size.x, size.y, size.x, size.y + size.height); | 261 | var linear_gradient = new Cairo.Pattern.linear (size.x, size.y, size.x, size.y + size.height); |
589 | 255 | linear_gradient.add_color_stop_rgba (0.0, 0.0, 0.0, 0.0, 0.65); | 262 | linear_gradient.add_color_stop_rgba (0.0, 0.0, 0.0, 0.0, 0.65); |
593 | 256 | linear_gradient.add_color_stop_rgba (0.85, 0.0, 0.0, 0.0, 0.65); | 263 | |
591 | 257 | linear_gradient.add_color_stop_rgba (0.99, 0.0, 0.0, 0.0, 0.0); | ||
592 | 258 | |||
594 | 259 | context.set_source (linear_gradient); | 264 | context.set_source (linear_gradient); |
595 | 260 | context.paint (); | 265 | context.paint (); |
597 | 261 | 266 | ||
598 | 262 | return false; | 267 | return false; |
599 | 263 | } | 268 | } |
601 | 264 | 269 | ||
602 | 265 | // Keyboard shortcuts | 270 | // Keyboard shortcuts |
603 | 266 | public override bool key_press_event (Gdk.EventKey event) { | 271 | public override bool key_press_event (Gdk.EventKey event) { |
604 | 267 | switch (Gdk.keyval_name (event.keyval)) { | 272 | switch (Gdk.keyval_name (event.keyval)) { |
606 | 268 | 273 | ||
607 | 269 | case "Escape": | 274 | case "Escape": |
609 | 270 | this.destroy (); | 275 | this.hide_slingshot (); |
610 | 271 | return true; | 276 | return true; |
611 | 272 | case "ISO_Left_Tab": | 277 | case "ISO_Left_Tab": |
612 | 273 | this.page_left (); | 278 | this.page_left (); |
613 | @@ -284,7 +289,10 @@ | |||
614 | 284 | } | 289 | } |
615 | 285 | return true; | 290 | return true; |
616 | 286 | case "BackSpace": | 291 | case "BackSpace": |
618 | 287 | this.searchbar.text = this.searchbar.text.slice (0, (int) this.searchbar.text.length - 1); | 292 | int len = (int) this.searchbar.text.length; |
619 | 293 | if (len > 0) { | ||
620 | 294 | this.searchbar.text = this.searchbar.text.slice (0,len - 1); | ||
621 | 295 | } | ||
622 | 288 | return true; | 296 | return true; |
623 | 289 | case "Left": | 297 | case "Left": |
624 | 290 | var current_item = this.grid.get_children ().index (this.get_focus ()); | 298 | var current_item = this.grid.get_children ().index (this.get_focus ()); |
625 | @@ -292,7 +300,7 @@ | |||
626 | 292 | this.page_left (); | 300 | this.page_left (); |
627 | 293 | return true; | 301 | return true; |
628 | 294 | } | 302 | } |
630 | 295 | 303 | ||
631 | 296 | break; | 304 | break; |
632 | 297 | case "Right": | 305 | case "Right": |
633 | 298 | var current_item = this.grid.get_children ().index (this.get_focus ()); | 306 | var current_item = this.grid.get_children ().index (this.get_focus ()); |
634 | @@ -308,16 +316,16 @@ | |||
635 | 308 | this.searchbar.text = this.searchbar.text + event.str; | 316 | this.searchbar.text = this.searchbar.text + event.str; |
636 | 309 | break; | 317 | break; |
637 | 310 | } | 318 | } |
639 | 311 | 319 | ||
640 | 312 | base.key_press_event (event); | 320 | base.key_press_event (event); |
641 | 313 | return false; | 321 | return false; |
643 | 314 | 322 | ||
644 | 315 | } | 323 | } |
646 | 316 | 324 | ||
647 | 317 | // Scrolling left/right for pages | 325 | // Scrolling left/right for pages |
648 | 318 | public override bool scroll_event (Gdk.EventScroll event) { | 326 | public override bool scroll_event (Gdk.EventScroll event) { |
649 | 319 | switch (event.direction.to_string()) { | 327 | switch (event.direction.to_string()) { |
651 | 320 | 328 | ||
652 | 321 | case "GDK_SCROLL_UP": | 329 | case "GDK_SCROLL_UP": |
653 | 322 | case "GDK_SCROLL_LEFT": | 330 | case "GDK_SCROLL_LEFT": |
654 | 323 | this.page_left (); | 331 | this.page_left (); |
655 | @@ -326,43 +334,98 @@ | |||
656 | 326 | case "GDK_SCROLL_RIGHT": | 334 | case "GDK_SCROLL_RIGHT": |
657 | 327 | this.page_right (); | 335 | this.page_right (); |
658 | 328 | break; | 336 | break; |
660 | 329 | 337 | ||
661 | 330 | } | 338 | } |
663 | 331 | 339 | ||
664 | 332 | return false; | 340 | return false; |
665 | 333 | } | 341 | } |
667 | 334 | 342 | ||
668 | 343 | public void refresh_apps () { | ||
669 | 344 | print("Refreshing applications list\n"); | ||
670 | 345 | Slingshot.Backend.GMenuEntries.enumerate_apps (Slingshot.Backend.GMenuEntries.get_all (), this.icons, this.icon_size, out this.apps); | ||
671 | 346 | } | ||
672 | 347 | |||
673 | 348 | public void hide_slingshot () { | ||
674 | 349 | this.iconify(); | ||
675 | 350 | this.categories.set_active (0); | ||
676 | 351 | this.change_category(); | ||
677 | 352 | this.searchbar.text = ""; | ||
678 | 353 | this.is_showing = false; | ||
679 | 354 | Wnck.Screen.get_default().toggle_showing_desktop(false); | ||
680 | 355 | } | ||
681 | 356 | |||
682 | 357 | public void show_slingshot () { | ||
683 | 358 | Wnck.Screen.get_default().toggle_showing_desktop(true); | ||
684 | 359 | this.deiconify(); | ||
685 | 360 | this.is_showing = true; | ||
686 | 361 | } | ||
687 | 362 | |||
688 | 363 | public void toggle_slingshot () { | ||
689 | 364 | if (this.is_showing) { | ||
690 | 365 | print("Hiding slingshot.\n"); | ||
691 | 366 | this.hide_slingshot(); | ||
692 | 367 | } else { | ||
693 | 368 | print("Showing slingshot.\n"); | ||
694 | 369 | this.show_slingshot(); | ||
695 | 370 | } | ||
696 | 371 | } | ||
697 | 372 | |||
698 | 335 | // Override destroy for fade out and stuff | 373 | // Override destroy for fade out and stuff |
699 | 336 | public new void destroy () { | 374 | public new void destroy () { |
700 | 337 | // Restore windows | 375 | // Restore windows |
703 | 338 | Wnck.Screen.get_default ().toggle_showing_desktop (false); | 376 | //Wnck.Screen.get_default ().toggle_showing_desktop (false); |
704 | 339 | 377 | ||
705 | 340 | base.destroy(); | 378 | base.destroy(); |
706 | 341 | Gtk.main_quit(); | 379 | Gtk.main_quit(); |
707 | 342 | } | 380 | } |
710 | 343 | 381 | ||
711 | 344 | } | 382 | } |
712 | 383 | |||
713 | 384 | |||
714 | 385 | public class SlingshotApp : GLib.Object { | ||
715 | 386 | |||
716 | 387 | Unique.App app; | ||
717 | 388 | SlingshotWindow main_win; | ||
718 | 389 | |||
719 | 390 | public SlingshotApp (/*string[] args*/) { | ||
720 | 391 | this.app = new Unique.App("org.elementary.slingshot", null); | ||
721 | 392 | if (this.app.is_running) { | ||
722 | 393 | print("Slingshot is already running.\n"); | ||
723 | 394 | Unique.Command command = Unique.Command.ACTIVATE; | ||
724 | 395 | this.app.send_message (command, new Unique.MessageData()); | ||
725 | 396 | } else { | ||
726 | 397 | this.app.message_received.connect(this.toggle); | ||
727 | 398 | this.create(/*args*/); | ||
728 | 399 | } | ||
729 | 400 | } | ||
730 | 401 | |||
731 | 402 | public Unique.Response toggle (int command, Unique.MessageData message_data, uint time_) { | ||
732 | 403 | if (command == Unique.Command.ACTIVATE) { | ||
733 | 404 | print("Toggling slingshot.\n"); | ||
734 | 405 | this.main_win.toggle_slingshot(); | ||
735 | 406 | } | ||
736 | 407 | return Unique.Response.OK; | ||
737 | 408 | } | ||
738 | 409 | |||
739 | 410 | void create (/*string[] args*/) { | ||
740 | 411 | //Gtk.init(ref args); | ||
741 | 412 | print("Starting new slingshot instance.\n"); | ||
742 | 413 | this.main_win = new SlingshotWindow(); | ||
743 | 414 | this.main_win.show_all(); | ||
744 | 415 | this.main_win.iconify(); | ||
745 | 416 | Gtk.main(); | ||
746 | 417 | } | ||
747 | 418 | |||
748 | 419 | } | ||
749 | 420 | |||
750 | 345 | 421 | ||
751 | 346 | int main (string[] args) { | 422 | int main (string[] args) { |
752 | 347 | 423 | ||
770 | 348 | Gtk.init (ref args); | 424 | Gtk.init(ref args); //~ |
771 | 349 | 425 | ||
772 | 350 | Unique.App app = new Unique.App ("org.elementary.slingshot", null); | 426 | new SlingshotApp(/*args*/); |
773 | 351 | 427 | ||
757 | 352 | if (app.is_running) { //close if already running | ||
758 | 353 | Unique.Command command = Unique.Command.NEW; | ||
759 | 354 | app.send_message (command, new Unique.MessageData()); | ||
760 | 355 | } else { | ||
761 | 356 | |||
762 | 357 | var main_win = new SlingshotWindow (); | ||
763 | 358 | main_win.show_all (); | ||
764 | 359 | |||
765 | 360 | app.watch_window (main_win); | ||
766 | 361 | |||
767 | 362 | Gtk.main (); | ||
768 | 363 | } | ||
769 | 364 | |||
774 | 365 | return 1; | 428 | return 1; |
776 | 366 | 429 | ||
777 | 367 | } | 430 | } |
778 | 368 | 431 |
Apparently, this branch has been merged separately (i.e. the branch hasn't been merged directly but parts were taken) so we have these features in the trunk now.
Thanks for your work :)