Merge lp:~mathijshenquet/slingshot/indicator-animations into lp:~elementary-pantheon/slingshot/slingshot
- indicator-animations
- Merge into slingshot
Proposed by
Mathijs Henquet
Status: | Rejected |
---|---|
Rejected by: | Victor Martinez |
Proposed branch: | lp:~mathijshenquet/slingshot/indicator-animations |
Merge into: | lp:~elementary-pantheon/slingshot/slingshot |
Diff against target: |
744 lines (+282/-95) (has conflicts) 2 files modified
frontend/widgets/Indicators.vala (+95/-38) slingshot.vala (+187/-57) Text conflict in frontend/widgets/Indicators.vala Text conflict in slingshot.vala |
To merge this branch: | bzr merge lp:~mathijshenquet/slingshot/indicator-animations |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Victor Martinez (community) | Disapprove | ||
Maxwell Barvian | Pending | ||
Review via email:
|
Commit message
Description of the change
Rewritten animation code, it now uses a easeOutQuint (or easeInOutQuing) alogorithm as can be seen here[1]. I also changed the FPS to a bit higher, as it runs smoothly on my computer, but that can ofcourse be changed.
I'll be on #elementary if you want to discuss anything.
To post a comment you must log in.
Unmerged revisions
- 46. By Mathijs Henquet
-
Smooth Indicator animations, and general Indicator animation fixes
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'frontend/widgets/Indicators.vala' |
2 | --- frontend/widgets/Indicators.vala 2011-02-19 14:56:50 +0000 |
3 | +++ frontend/widgets/Indicators.vala 2011-02-20 13:42:52 +0000 |
4 | @@ -1,16 +1,16 @@ |
5 | /*** |
6 | BEGIN LICENSE |
7 | Copyright (C) 2011 Maxwell Barvian <mbarvian@gmail.com> |
8 | -This program is free software: you can redistribute it and/or modify it |
9 | -under the terms of the GNU Lesser General Public License version 2.1, as published |
10 | +This program is free software: you can redistribute it and/or modify it |
11 | +under the terms of the GNU Lesser General Public License version 2.1, as published |
12 | by the Free Software Foundation. |
13 | |
14 | -This program is distributed in the hope that it will be useful, but |
15 | -WITHOUT ANY WARRANTY; without even the implied warranties of |
16 | -MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
17 | +This program is distributed in the hope that it will be useful, but |
18 | +WITHOUT ANY WARRANTY; without even the implied warranties of |
19 | +MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
20 | PURPOSE.\ See the GNU General Public License for more details. |
21 | - |
22 | -You should have received a copy of the GNU General Public License along |
23 | + |
24 | +You should have received a copy of the GNU General Public License along |
25 | with this program. If not, see <http://www.gnu.org/licenses/>. |
26 | END LICENSE |
27 | ***/ |
28 | @@ -18,32 +18,40 @@ |
29 | namespace Slingshot.Frontend { |
30 | |
31 | public class Indicators : Gtk.HBox { |
32 | - |
33 | + |
34 | // Animation constants |
35 | +<<<<<<< TREE |
36 | const int FPS = 30; |
37 | private int duration; |
38 | private int run_length; // total number of frames |
39 | +======= |
40 | + const int FPS = 55; |
41 | + private int animation_duration; |
42 | + private int animation_frames; // total number of frames |
43 | +>>>>>>> MERGE-SOURCE |
44 | private int current_frame = 1; |
45 | - |
46 | + private uint animation_loop_id = 0; |
47 | + private bool animation_active = false; |
48 | + |
49 | // Signals |
50 | public signal void child_activated (); |
51 | - |
52 | + |
53 | // Properties |
54 | public new GLib.List<Gtk.Widget> children; |
55 | public int active = -1; |
56 | private int old_active = -1; |
57 | - |
58 | + |
59 | public Indicators () { |
60 | - |
61 | + |
62 | this.homogeneous = false; |
63 | this.spacing = 0; |
64 | - |
65 | + |
66 | } |
67 | - |
68 | + |
69 | public void append (string thelabel) { |
70 | var indicator = new Gtk.EventBox(); |
71 | indicator.set_visible_window (false); |
72 | - |
73 | + |
74 | var label = new Gtk.Label(thelabel); |
75 | Gdk.Color white; |
76 | Gdk.Color.parse("#FFFFFF", out white); |
77 | @@ -52,76 +60,124 @@ |
78 | font.set_size (9500); |
79 | font.set_weight (Pango.Weight.HEAVY); |
80 | label.modify_font (font); |
81 | - |
82 | + |
83 | indicator.add(Slingshot.Frontend.Utilities.wrap_alignment(label, 5, 15, 5, 15)); // make sure the child widget is added with padding |
84 | this.children.append(indicator); |
85 | - |
86 | - |
87 | + |
88 | + |
89 | this.expose_event.connect(draw_background); |
90 | indicator.button_release_event.connect( () => { |
91 | - |
92 | + |
93 | this.set_active(this.children.index(indicator)); |
94 | - |
95 | + |
96 | return true; |
97 | - |
98 | + |
99 | } ); |
100 | - |
101 | + |
102 | this.pack_start(indicator, false, false, 0); |
103 | - |
104 | + |
105 | } |
106 | - |
107 | + |
108 | public void set_active_no_signal (int index) { |
109 | - |
110 | + |
111 | if (index <= ((int)this.children.length - 1)) { // make sure the requested active item is in the children list |
112 | this.old_active = this.active; |
113 | this.active = index; |
114 | this.change_focus (); |
115 | } |
116 | - |
117 | + |
118 | } |
119 | - |
120 | + |
121 | public void set_active (int index) { |
122 | this.set_active_no_signal (index); |
123 | this.child_activated (); // send signal |
124 | } |
125 | - |
126 | + |
127 | public void change_focus () { |
128 | - |
129 | + //make sure no other animation is running, if so kill it with fire |
130 | + if(animation_active){ |
131 | + GLib.Source.remove(animation_loop_id); |
132 | + end_animation(); |
133 | + } |
134 | + |
135 | + // definie animation_duration, base is 250 millisecionds for which 50 ms is added for each item to span |
136 | + this.animation_duration = 240; |
137 | int difference = (this.old_active - this.active).abs (); |
138 | +<<<<<<< TREE |
139 | difference > 1 ? this.duration = difference * 75 : this.duration = 150; |
140 | this.run_length = (int)(duration/FPS); |
141 | |
142 | GLib.Timeout.add (((int)(1000/this.FPS)), () => { |
143 | if (this.current_frame >= this.run_length) { |
144 | current_frame = 1; |
145 | +======= |
146 | + this.animation_duration += (int) (Math.pow(difference, 0.5) * 80); |
147 | + |
148 | + |
149 | + this.animation_frames = (int)((double) animation_duration / 1000 * FPS); |
150 | + |
151 | + // initial conditions for animation. |
152 | + this.current_frame = 0; |
153 | + this.animation_active = true; |
154 | + |
155 | + this.animation_loop_id = GLib.Timeout.add (((int)(1000 / this.FPS)), () => { |
156 | + stdout.printf("%i / %i\n", this.current_frame, this.animation_frames); |
157 | + if (this.current_frame >= this.animation_frames) { |
158 | + end_animation(); |
159 | +>>>>>>> MERGE-SOURCE |
160 | return false; // stop animation |
161 | } |
162 | + |
163 | + this.current_frame++; |
164 | this.queue_draw (); |
165 | - this.current_frame++; |
166 | return true; |
167 | }); |
168 | - |
169 | - } |
170 | - |
171 | + } |
172 | + |
173 | + private void end_animation(){ |
174 | + animation_active = false; |
175 | + current_frame = 0; |
176 | + } |
177 | + |
178 | protected bool draw_background (Gtk.Widget widget, Gdk.EventExpose event) { |
179 | Gtk.Allocation size; |
180 | widget.get_allocation (out size); |
181 | var context = Gdk.cairo_create (widget.window); |
182 | +<<<<<<< TREE |
183 | |
184 | // Percentage of progress |
185 | double progress = (double)this.run_length/(double)this.current_frame; |
186 | |
187 | +======= |
188 | + |
189 | + |
190 | + double d = (double) this.animation_frames; |
191 | + double t = (double) this.current_frame; |
192 | + |
193 | + double progress; |
194 | + |
195 | + // easeOutQuint algorithm - aka - start normal end slow |
196 | + progress = ((t=t/d-1)*t*t*t*t + 1); |
197 | + |
198 | + // easeInOutQuint algorithm - aka - start slow, fast in middle and slow in the end |
199 | + //if (( t /= d/2) < 1) { |
200 | + // progress = 0.5*t*t*t*t; |
201 | + //}else{ |
202 | + // progress = -0.5*((t-=2)*t*t*t - 2); |
203 | + //} |
204 | + |
205 | +>>>>>>> MERGE-SOURCE |
206 | // Get allocations of old rectangle |
207 | Gtk.Allocation size_old, size_new; |
208 | this.get_children ().nth_data (this.old_active).get_allocation(out size_old); |
209 | - |
210 | + |
211 | // Get allocations for the new rectangle |
212 | this.get_children ().nth_data (this.active).get_allocation(out size_new); |
213 | - |
214 | + |
215 | // Move and make a new rectangle, according to progress |
216 | - double x = size_old.x - (size_old.x - (double) size_new.x)/progress; |
217 | - double width = size_old.width - (size_old.width - (double) size_new.width)/progress; |
218 | - |
219 | + double x = size_old.x + (size_new.x - (double) size_old.x) * progress; |
220 | + double width = size_old.width + (size_new.width - (double) size_old.width) * progress; |
221 | + |
222 | context.set_source_rgba (0.0, 0.0, 0.0, 0.70); |
223 | double offset = 0.0; |
224 | double radius = 3.0; |
225 | @@ -136,3 +192,4 @@ |
226 | } |
227 | } |
228 | } |
229 | + |
230 | |
231 | === modified file 'slingshot.vala' |
232 | --- slingshot.vala 2011-02-19 14:51:06 +0000 |
233 | +++ slingshot.vala 2011-02-20 13:42:52 +0000 |
234 | @@ -3,11 +3,11 @@ |
235 | public GLib.List<Slingshot.Frontend.AppItem> children = new GLib.List<Slingshot.Frontend.AppItem> (); |
236 | public Slingshot.Frontend.Searchbar searchbar; |
237 | public Slingshot.Frontend.Grid grid; |
238 | - |
239 | + |
240 | public Gee.ArrayList<Gee.HashMap<string, string>> apps = new Gee.ArrayList<Gee.HashMap<string, string>> (); |
241 | public Gee.HashMap<string, Gdk.Pixbuf> icons = new Gee.HashMap<string, Gdk.Pixbuf>(); |
242 | public Gee.ArrayList<Gee.HashMap<string, string>> filtered = new Gee.ArrayList<Gee.HashMap<string, string>> (); |
243 | - |
244 | + |
245 | public Slingshot.Frontend.Indicators pages; |
246 | public Slingshot.Frontend.Indicators categories; |
247 | public Gee.ArrayList<GMenu.TreeDirectory> all_categories = Slingshot.Backend.GMenuEntries.get_categories (); |
248 | @@ -16,10 +16,10 @@ |
249 | public Gtk.HBox top_spacer; |
250 | |
251 | public SlingshotWindow () { |
252 | - |
253 | + |
254 | // Show desktop |
255 | Wnck.Screen.get_default().toggle_showing_desktop (true); |
256 | - |
257 | + |
258 | // Window properties |
259 | this.title = "Slingshot"; |
260 | this.skip_pager_hint = true; |
261 | @@ -28,13 +28,19 @@ |
262 | this.maximize (); |
263 | this.stick (); |
264 | this.set_keep_above (true); |
265 | - |
266 | + |
267 | // Set icon size |
268 | Gdk.Rectangle monitor_dimensions; |
269 | Gdk.Screen screen = Gdk.Screen.get_default(); |
270 | screen.get_monitor_geometry(screen.get_primary_monitor(), out monitor_dimensions); |
271 | +<<<<<<< TREE |
272 | |
273 | double suggested_size = (Math.pow (monitor_dimensions.width * monitor_dimensions.height, ((double) (1.0/3.0))) / 1.6); |
274 | +======= |
275 | + |
276 | + // Set icon size |
277 | + double suggested_size = (Math.pow (monitor_dimensions.width * monitor_dimensions.height, ((double)(1.0/3.0))) / 1.6); |
278 | +>>>>>>> MERGE-SOURCE |
279 | if (suggested_size < 27) { |
280 | this.icon_size = 24; |
281 | } else if (suggested_size >= 27 && suggested_size < 40) { |
282 | @@ -44,22 +50,45 @@ |
283 | } else if (suggested_size >= 56) { |
284 | this.icon_size = 64; |
285 | } |
286 | - |
287 | + |
288 | // Get all apps |
289 | +<<<<<<< TREE |
290 | Slingshot.Backend.GMenuEntries.enumerate_apps (Slingshot.Backend.GMenuEntries.get_all (), this.icons, this.icon_size, out this.apps); |
291 | |
292 | +======= |
293 | + Slingshot.Backend.GMenuEntries.enumerate_apps(Slingshot.Backend.GMenuEntries.get_all (), this.icons, this.icon_size, out this.apps); |
294 | + |
295 | +>>>>>>> MERGE-SOURCE |
296 | // Add container wrapper |
297 | +<<<<<<< TREE |
298 | var wrapper = new Gtk.EventBox (); // used for the scrolling and button press events |
299 | wrapper.set_visible_window (false); |
300 | this.add (wrapper); |
301 | |
302 | +======= |
303 | + var wrapper = new Gtk.EventBox(); // used for the scrolling and button press event |
304 | + wrapper.set_visible_window(false); |
305 | + this.add(wrapper); |
306 | + |
307 | +>>>>>>> MERGE-SOURCE |
308 | // Add container |
309 | +<<<<<<< TREE |
310 | var container = new Gtk.VBox (false, 15); |
311 | wrapper.add (container); |
312 | |
313 | +======= |
314 | + this.container = new Gtk.VBox(false, 15); |
315 | + wrapper.add (this.container); |
316 | + |
317 | +>>>>>>> MERGE-SOURCE |
318 | // Add top bar |
319 | +<<<<<<< TREE |
320 | var top = new Gtk.HBox (false, 0); |
321 | |
322 | +======= |
323 | + var top = new Gtk.HBox(false, 0); |
324 | + |
325 | +>>>>>>> MERGE-SOURCE |
326 | this.categories = new Slingshot.Frontend.Indicators (); |
327 | this.categories.child_activated.connect (this.change_category); |
328 | this.categories.append ("All"); |
329 | @@ -68,96 +97,139 @@ |
330 | } |
331 | this.categories.set_active (0); |
332 | top.pack_start (this.categories, true, true, 15); |
333 | - |
334 | + |
335 | this.top_spacer = new Gtk.HBox (false, 0); |
336 | this.top_spacer.realize.connect ( () => { this.top_spacer.visible = false; } ); |
337 | this.top_spacer.can_focus = true; |
338 | top.pack_start (this.top_spacer, false, false, 0); |
339 | - |
340 | + |
341 | this.searchbar = new Slingshot.Frontend.Searchbar ("Start typing to search..."); |
342 | this.searchbar.changed.connect (this.search); |
343 | top.pack_start (this.searchbar, false, true, 15); |
344 | +<<<<<<< TREE |
345 | |
346 | container.pack_start (top, false, true, 15); |
347 | |
348 | +======= |
349 | + |
350 | + this.container.pack_start(top, false, true, 15); |
351 | + |
352 | +>>>>>>> MERGE-SOURCE |
353 | // Make icon grid and populate |
354 | if (monitor_dimensions.width > monitor_dimensions.height) { // normal landscape orientation |
355 | this.grid = new Slingshot.Frontend.Grid (4, 6); |
356 | } else { // most likely a portrait orientation |
357 | this.grid = new Slingshot.Frontend.Grid (6, 4); |
358 | } |
359 | +<<<<<<< TREE |
360 | container.pack_start (this.grid, true, true, 0); |
361 | |
362 | +======= |
363 | + this.container.pack_start (this.grid, true, true, 0); |
364 | + |
365 | +>>>>>>> MERGE-SOURCE |
366 | this.populate_grid (); |
367 | - |
368 | + |
369 | // Add pages |
370 | this.pages = new Slingshot.Frontend.Indicators (); |
371 | this.pages.child_activated.connect ( () => { this.update_grid (this.filtered); } ); |
372 | +<<<<<<< TREE |
373 | |
374 | var pages_wrapper = new Gtk.HBox (false, 0); |
375 | pages_wrapper.set_size_request (-1, 30); |
376 | container.pack_end (pages_wrapper, false, true, 15); |
377 | |
378 | +======= |
379 | + |
380 | + var pages_wrapper = new Gtk.HBox(false, 0); |
381 | + pages_wrapper.set_size_request (-1, 30); |
382 | + pages_wrapper.pack_start(new Gtk.HBox(false, 0), true, true, 0); //left padding |
383 | + pages_wrapper.pack_end(new Gtk.HBox(false, 0), true, true, 0); //left padding |
384 | + |
385 | + this.container.pack_end(pages_wrapper, false, true, 15); |
386 | + |
387 | +>>>>>>> MERGE-SOURCE |
388 | // Find number of pages and populate |
389 | this.update_pages (this.apps); |
390 | if (this.total_pages > 1) { |
391 | pages_wrapper.pack_start (this.pages, true, false, 0); |
392 | for (int p = 1; p <= this.total_pages; p++) { |
393 | this.pages.append (p.to_string ()); |
394 | - } |
395 | + } |
396 | } |
397 | this.pages.set_active (0); |
398 | - |
399 | + |
400 | // Signals and callbacks |
401 | this.button_release_event.connect ( () => { this.destroy(); return false; }); |
402 | this.expose_event.connect (this.draw_background); |
403 | this.focus_out_event.connect ( () => { this.destroy(); return true; } ); // close slingshot when the window loses focus |
404 | } |
405 | +<<<<<<< TREE |
406 | |
407 | private void populate_grid () { |
408 | |
409 | +======= |
410 | + |
411 | + private void populate_grid() { |
412 | + |
413 | +>>>>>>> MERGE-SOURCE |
414 | for (int r = 0; r < this.grid.n_rows; r++) { |
415 | - |
416 | + |
417 | for (int c = 0; c < this.grid.n_columns; c++) { |
418 | +<<<<<<< TREE |
419 | |
420 | var item = new Slingshot.Frontend.AppItem (this.icon_size); |
421 | this.children.append (item); |
422 | |
423 | +======= |
424 | + |
425 | + var item = new Slingshot.Frontend.AppItem(this.icon_size); |
426 | + this.children.append(item); |
427 | + |
428 | +>>>>>>> MERGE-SOURCE |
429 | item.button_press_event.connect ( () => { item.grab_focus (); return true; } ); |
430 | item.enter_notify_event.connect ( () => { item.grab_focus (); return true; } ); |
431 | item.leave_notify_event.connect ( () => { this.top_spacer.grab_focus (); return true; } ); |
432 | item.button_release_event.connect ( () => { |
433 | - |
434 | + |
435 | try { |
436 | 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); |
437 | this.destroy(); |
438 | } catch (GLib.Error e) { |
439 | stdout.printf("Error! Load application: " + e.message); |
440 | } |
441 | - |
442 | + |
443 | return true; |
444 | - |
445 | + |
446 | }); |
447 | +<<<<<<< TREE |
448 | |
449 | this.grid.attach (item, c, c + 1, r, r + 1, Gtk.AttachOptions.EXPAND, Gtk.AttachOptions.EXPAND, 0, 0); |
450 | |
451 | } |
452 | } |
453 | +======= |
454 | + |
455 | + this.grid.attach(item, c, c + 1, r, r + 1, Gtk.AttachOptions.EXPAND, Gtk.AttachOptions.EXPAND, 0, 0); |
456 | + |
457 | + } |
458 | + } |
459 | +>>>>>>> MERGE-SOURCE |
460 | } |
461 | - |
462 | - private void update_grid (Gee.ArrayList<Gee.HashMap<string, string>> apps) { |
463 | - |
464 | + |
465 | + private void update_grid (Gee.ArrayList<Gee.HashMap<string, string>> apps) { |
466 | + |
467 | int item_iter = (int)(this.pages.active * this.grid.n_columns * this.grid.n_rows); |
468 | for (int r = 0; r < this.grid.n_rows; r++) { |
469 | - |
470 | + |
471 | for (int c = 0; c < this.grid.n_columns; c++) { |
472 | - |
473 | + |
474 | int table_pos = c + (r * (int)this.grid.n_columns); // position in table right now |
475 | - |
476 | + |
477 | var item = this.children.nth_data(table_pos); |
478 | if (item_iter < apps.size) { |
479 | var current_item = apps.get(item_iter); |
480 | - |
481 | + |
482 | // Update app |
483 | if (current_item["description"] == null || current_item["description"] == "") { |
484 | item.change_app (icons[current_item["command"]], current_item["name"], current_item["name"]); |
485 | @@ -169,80 +241,117 @@ |
486 | } else { // fill with a blank one |
487 | item.visible = false; |
488 | } |
489 | - |
490 | + |
491 | item_iter++; |
492 | - |
493 | + |
494 | } |
495 | } |
496 | - |
497 | + |
498 | // Update number of pages |
499 | this.update_pages (apps); |
500 | - |
501 | + |
502 | // Grab first one's focus |
503 | this.children.nth_data (0).grab_focus (); |
504 | } |
505 | - |
506 | + |
507 | private void change_category () { |
508 | this.filtered.clear (); |
509 | +<<<<<<< TREE |
510 | |
511 | +======= |
512 | + |
513 | + |
514 | +>>>>>>> MERGE-SOURCE |
515 | if (this.categories.active != 0) { |
516 | 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); |
517 | } else { |
518 | this.filtered.add_all (this.apps); |
519 | } |
520 | +<<<<<<< TREE |
521 | |
522 | this.pages.set_active (0); // go back to first page in category |
523 | +======= |
524 | + |
525 | + this.pages.set_active (0); |
526 | +>>>>>>> MERGE-SOURCE |
527 | } |
528 | - |
529 | + |
530 | private void update_pages (Gee.ArrayList<Gee.HashMap<string, string>> apps) { |
531 | // Find current number of pages and update count |
532 | +<<<<<<< TREE |
533 | var num_pages = (int) (apps.size / (this.grid.n_columns * this.grid.n_rows)); |
534 | (double) apps.size % (double) (this.grid.n_columns * this.grid.n_rows) > 0 ? this.total_pages = num_pages + 1 : this.total_pages = num_pages; |
535 | |
536 | +======= |
537 | + var num_pages = (int)(apps.size / (this.grid.n_columns * this.grid.n_rows)); |
538 | + if ((double)apps.size % (double)(this.grid.n_columns * this.grid.n_rows) > 0) { |
539 | + this.total_pages = num_pages + 1; |
540 | + } else { |
541 | + this.total_pages = num_pages; |
542 | + } |
543 | + |
544 | +>>>>>>> MERGE-SOURCE |
545 | // Update pages |
546 | if (this.total_pages > 1) { |
547 | this.pages.visible = true; |
548 | +<<<<<<< TREE |
549 | for (int p = 1; p <= this.pages.children.length (); p++) { |
550 | p > this.total_pages ? this.pages.children.nth_data (p - 1).visible = false : this.pages.children.nth_data (p - 1).visible = true; |
551 | +======= |
552 | + for (int p = 1; p <= this.pages.children.length(); p++) { |
553 | + |
554 | + if (p > this.total_pages) { |
555 | + this.pages.children.nth_data(p - 1).visible = false; |
556 | + } else { |
557 | + this.pages.children.nth_data(p - 1).visible = true; |
558 | + } |
559 | + |
560 | +>>>>>>> MERGE-SOURCE |
561 | } |
562 | } else { |
563 | this.pages.visible = false; |
564 | } |
565 | - |
566 | + |
567 | } |
568 | - |
569 | + |
570 | private void search() { |
571 | +<<<<<<< TREE |
572 | |
573 | var current_text = this.searchbar.text.down (); |
574 | |
575 | +======= |
576 | + |
577 | + var current_text = this.searchbar.text.down(); |
578 | + |
579 | +>>>>>>> MERGE-SOURCE |
580 | this.categories.set_active_no_signal (0); // switch to first page |
581 | this.filtered.clear (); |
582 | - |
583 | + |
584 | foreach (Gee.HashMap<string, string> app in this.apps) { |
585 | if (current_text in app["name"].down () || current_text in app["description"].down () || current_text in app["command"].down ()) { |
586 | this.filtered.add (app); |
587 | } |
588 | - } |
589 | - |
590 | - this.pages.set_active (0); |
591 | - |
592 | + } |
593 | + |
594 | + this.pages.set_active (0); |
595 | + |
596 | this.queue_draw (); |
597 | } |
598 | - |
599 | + |
600 | private void page_left() { |
601 | - |
602 | + |
603 | if (this.pages.active >= 1) { |
604 | this.pages.set_active (this.pages.active - 1); |
605 | } |
606 | - |
607 | + |
608 | } |
609 | - |
610 | + |
611 | private void page_right() { |
612 | - |
613 | + |
614 | if ((this.pages.active + 1) < this.total_pages) { |
615 | this.pages.set_active (this.pages.active + 1); |
616 | } |
617 | - |
618 | + |
619 | } |
620 | |
621 | private bool draw_background (Gtk.Widget widget, Gdk.EventExpose event) { |
622 | @@ -255,17 +364,23 @@ |
623 | linear_gradient.add_color_stop_rgba (0.0, 0.0, 0.0, 0.0, 0.65); |
624 | linear_gradient.add_color_stop_rgba (0.85, 0.0, 0.0, 0.0, 0.65); |
625 | linear_gradient.add_color_stop_rgba (0.99, 0.0, 0.0, 0.0, 0.0); |
626 | - |
627 | + |
628 | context.set_source (linear_gradient); |
629 | context.paint (); |
630 | - |
631 | + |
632 | return false; |
633 | } |
634 | - |
635 | + |
636 | // Keyboard shortcuts |
637 | +<<<<<<< TREE |
638 | public override bool key_press_event (Gdk.EventKey event) { |
639 | switch (Gdk.keyval_name (event.keyval)) { |
640 | |
641 | +======= |
642 | + public override bool key_press_event(Gdk.EventKey event) { |
643 | + switch (Gdk.keyval_name(event.keyval)) { |
644 | + |
645 | +>>>>>>> MERGE-SOURCE |
646 | case "Escape": |
647 | this.destroy (); |
648 | return true; |
649 | @@ -292,7 +407,7 @@ |
650 | this.page_left (); |
651 | return true; |
652 | } |
653 | - |
654 | + |
655 | break; |
656 | case "Right": |
657 | var current_item = this.grid.get_children ().index (this.get_focus ()); |
658 | @@ -308,16 +423,16 @@ |
659 | this.searchbar.text = this.searchbar.text + event.str; |
660 | break; |
661 | } |
662 | - |
663 | + |
664 | base.key_press_event (event); |
665 | return false; |
666 | - |
667 | + |
668 | } |
669 | - |
670 | + |
671 | // Scrolling left/right for pages |
672 | public override bool scroll_event (Gdk.EventScroll event) { |
673 | switch (event.direction.to_string()) { |
674 | - |
675 | + |
676 | case "GDK_SCROLL_UP": |
677 | case "GDK_SCROLL_LEFT": |
678 | this.page_left (); |
679 | @@ -326,21 +441,26 @@ |
680 | case "GDK_SCROLL_RIGHT": |
681 | this.page_right (); |
682 | break; |
683 | - |
684 | + |
685 | } |
686 | - |
687 | + |
688 | return false; |
689 | } |
690 | - |
691 | + |
692 | // Override destroy for fade out and stuff |
693 | public new void destroy () { |
694 | // Restore windows |
695 | +<<<<<<< TREE |
696 | Wnck.Screen.get_default ().toggle_showing_desktop (false); |
697 | |
698 | +======= |
699 | + Wnck.Screen.get_default().toggle_showing_desktop (false); |
700 | + |
701 | +>>>>>>> MERGE-SOURCE |
702 | base.destroy(); |
703 | Gtk.main_quit(); |
704 | } |
705 | - |
706 | + |
707 | } |
708 | |
709 | int main (string[] args) { |
710 | @@ -348,21 +468,31 @@ |
711 | Gtk.init (ref args); |
712 | |
713 | Unique.App app = new Unique.App ("org.elementary.slingshot", null); |
714 | - |
715 | + |
716 | if (app.is_running) { //close if already running |
717 | Unique.Command command = Unique.Command.NEW; |
718 | app.send_message (command, new Unique.MessageData()); |
719 | } else { |
720 | - |
721 | + |
722 | var main_win = new SlingshotWindow (); |
723 | +<<<<<<< TREE |
724 | main_win.show_all (); |
725 | |
726 | +======= |
727 | + main_win.show_all(); |
728 | + |
729 | +>>>>>>> MERGE-SOURCE |
730 | app.watch_window (main_win); |
731 | +<<<<<<< TREE |
732 | |
733 | Gtk.main (); |
734 | +======= |
735 | + |
736 | + Gtk.main(); |
737 | +>>>>>>> MERGE-SOURCE |
738 | } |
739 | - |
740 | + |
741 | return 1; |
742 | - |
743 | + |
744 | } |
745 |
This was submitted a long time ago (Feb. 20, 2011). I will reject it since there was no final decision. Feel free to change the status if it was actually merged.