Merge lp:~unity-team/unity/places-bar into lp:unity

Proposed by Neil J. Patel
Status: Merged
Merged at revision: 341
Proposed branch: lp:~unity-team/unity/places-bar
Merge into: lp:unity
Diff against target: 6700 lines (+2775/-3200)
51 files modified
.bzrignore (+39/-0)
targets/mutter/plugin.vala (+55/-66)
tests/ui/test-home-button.vala (+1/-1)
tests/unit/Makefile.am (+3/-0)
tests/unit/data/Makefile.am (+6/-1)
tests/unit/data/place0.badplace (+3/-0)
tests/unit/data/place0.place (+3/-0)
tests/unit/data/place1.badplace (+19/-0)
tests/unit/data/place1.place (+27/-0)
tests/unit/test-places-place-file-model.vala (+43/-0)
tests/unit/test-places-place.vala (+161/-0)
tests/unit/test-unit.vala (+13/-4)
unity-private/Makefile.am (+11/-14)
unity-private/launcher/launcher-child.vala (+4/-1)
unity-private/launcher/scroller-controller.vala (+2/-1)
unity-private/panel/panel-background.vala (+1/-1)
unity-private/panel/panel-home-button.vala (+19/-11)
unity-private/panel/panel-indicators.vala (+0/-659)
unity-private/panel/panel-menubar.vala (+3/-1)
unity-private/panel/panel-view.vala (+16/-45)
unity-private/places/application-place.vala (+0/-297)
unity-private/places/bar-model.vala (+0/-43)
unity-private/places/bar-view.vala (+0/-253)
unity-private/places/cairo-drawing.vala (+0/-474)
unity-private/places/default-model.vala (+0/-43)
unity-private/places/default-view.vala (+0/-203)
unity-private/places/file-place.vala (+0/-239)
unity-private/places/places-controller.vala (+4/-119)
unity-private/places/places-default-renderer-group.vala (+187/-0)
unity-private/places/places-default-renderer.vala (+86/-0)
unity-private/places/places-model.vala (+0/-64)
unity-private/places/places-place-bar.vala (+276/-0)
unity-private/places/places-place-entry-view.vala (+51/-0)
unity-private/places/places-place-entry.vala (+408/-0)
unity-private/places/places-place-model.vala (+155/-0)
unity-private/places/places-place-proxy.vala (+0/-119)
unity-private/places/places-place-search-bar.vala (+299/-0)
unity-private/places/places-place-search-entry.vala (+93/-0)
unity-private/places/places-place-search-sections-bar.vala (+277/-0)
unity-private/places/places-place-view.vala (+36/-12)
unity-private/places/places-place.vala (+241/-29)
unity-private/places/places-results-view.vala (+0/-293)
unity-private/places/places-view.vala (+78/-73)
unity-private/places/search-field.vala (+0/-104)
unity-private/testing/test-window.vala (+15/-25)
unity/Makefile.am (+2/-0)
unity/icon-postprocessor.vala (+2/-1)
unity/shell.vala (+3/-3)
unity/unity-cairo-canvas.vala (+99/-0)
unity/unity-place-renderer.vala (+33/-0)
vapi/clutter-1.0.vapi (+1/-1)
To merge this branch: bzr merge lp:~unity-team/unity/places-bar
Reviewer Review Type Date Requested Status
Mikkel Kamstrup Erlandsen (community) Approve
Unity Team Pending
Review via email: mp+28221@code.launchpad.net

Description of the change

Wow, where to start?

- Basically re-architects the places for the new specs (as much as possible, balancing between delievering something for A2 and pushing somethings for next week)
- Removes all the old code
- Introduces a bunch of new models (with tests) and views (pending design before finalising tests) which all come together in a place-fuelled love-fest
- Wraps the place and place-entry dbus objects and reads-from and writes-to them
- Removes the expose in favour of always-places mode for the Ubuntu icon
- Adds some animations to switching to/from places, removes the effect that doesn't work
- Adds about_to_show_places API to the shell, for very lazy loading of places
- Fixes a bunch of warnings from other components too (only quicklist's warnings left now to fix)
- Some more general clean ups

Things to be handled in a separate merge-request:
- If there are no places, then show expose instead of blank places
- Handle the case of places not being found on the bus better (may crash right now)
- Clean up the dynamic loading of the renderers to make it, well, dynamic :)
- Same with the group renderers
- Lot's of fixes to the UI such as only showing the first row of group results initially, better icons, better text, animations etc

Code will change still a bit, so I guess testing of what's there with some place daemons would be better.

To post a comment you must log in.
Revision history for this message
Mikkel Kamstrup Erlandsen (kamstrup) wrote :

Hey, super nice work. Only nitpickings:

unity-private/panel/panel-home-button.vala:

 * "along with this program" -> "along with program" in the GNU header. A s/this// on the lose? :-)

unity-private/panel/panel-view.vala:

 * public void set_indicator_mode (bool mode) could be set_indicator_hidden(bool hidden) to make the code clearer

unity-private/places/places-place-model.vala:

 * private async void load_place_files() calls load_place() which does sync io. You'd need to async load data into a buffer (fx. GInputStream -> GMemoryOutputStream) and do g_key_file_load_from_data(). Either add FIXME or do it fully async.

unity-private/places/places-place-search-bar.vala:

 * Timeout.add (0, bg.update_background); - why not Idle.add() then? A code comment to clarify why we need it in the first place perhaps?

 * Define const int for 400?

 * Hard coded BG in PlaceSearchBarBackground. Should be something like Config.DATADIR + "/unity/dash_background.png"

 * Sync io when loading pixbuf. Nontrivial fix. Perhaps add a code comment or FIXME and consider it for later

Regressions? We seem to no longer have:

 * Trash, Home screen

File bugs for missing work items to ensure we don't forget some details?

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file '.bzrignore'
--- .bzrignore 2010-06-03 17:13:55 +0000
+++ .bzrignore 2010-06-24 07:45:42 +0000
@@ -275,3 +275,42 @@
275tests/ui/test-home-button.c275tests/ui/test-home-button.c
276tests/unit/test-panel-indicator-object-entry-view.c276tests/unit/test-panel-indicator-object-entry-view.c
277po/unity.pot277po/unity.pot
278tests/unit/test-panel-indicator-object-view.c
279tests/unit/test-place.c
280tests/unit/test-places-place-file-model.c
281unity/unity-place.c
282unity-private/places/places-place-entry.c
283unity-private/places/places-place-model.c
284tests/unit/test-places-place.c
285unity.pc
286tests/ui/test-indicators.c
287places/application-place.c
288places/bar-model.c
289places/bar-view.c
290places/cairo-drawing.c
291places/default-model.c
292places/default-view.c
293places/file-place.c
294places/places-controller.c
295places/places-model.c
296places/places-place-bar.c
297places/places-place.c
298places/places-place-entry.c
299places/places-place-entry-view.c
300places/places-place-model.c
301places/places-place-proxy.c
302places/places-place-view.c
303places/places-results-view.c
304places/places-view.c
305places/search-field.c
306unity-private/panel/panel-indicator-background.c
307unity-private/places/places-place-bar.c
308unity-private/places/places-place-entry-view.c
309unity-private/places/places-place-search-bar.cunity-private/places/places-place-search-bar.c
310unity-private/places/places-place-search-bar.c
311unity/unity-cairo-canvas.c
312unity-private/places/places-place-search-entry.c
313unity-private/places/places-place-search-sections-bar.c
314unity/unity-place-renderer.c
315unity-private/places/places-default-renderer-group.c
316unity-private/places/places-default-renderer.c
278317
=== modified file 'targets/mutter/plugin.vala'
--- targets/mutter/plugin.vala 2010-06-17 16:13:00 +0000
+++ targets/mutter/plugin.vala 2010-06-24 07:45:42 +0000
@@ -131,8 +131,6 @@
131 private unowned Mutter.MetaWindow? focus_window = null;131 private unowned Mutter.MetaWindow? focus_window = null;
132 private unowned Mutter.MetaDisplay? display = null;132 private unowned Mutter.MetaDisplay? display = null;
133133
134 private bool places_enabled = false;
135
136 private DragDest drag_dest;134 private DragDest drag_dest;
137 private bool places_showing;135 private bool places_showing;
138 private bool _fullscreen_obstruction;136 private bool _fullscreen_obstruction;
@@ -229,8 +227,6 @@
229227
230 Ctk.dnd_init ((Gtk.Widget)this.drag_dest, target_list);228 Ctk.dnd_init ((Gtk.Widget)this.drag_dest, target_list);
231229
232 this.places_enabled = envvar_is_enabled ("UNITY_ENABLE_PLACES");
233
234 Clutter.Group window_group = (Clutter.Group) this.plugin.get_window_group ();230 Clutter.Group window_group = (Clutter.Group) this.plugin.get_window_group ();
235231
236 this.background = new Background ();232 this.background = new Background ();
@@ -256,19 +252,16 @@
256 this.launcher.get_view ().animate (Clutter.AnimationMode.EASE_IN_SINE, 400,252 this.launcher.get_view ().animate (Clutter.AnimationMode.EASE_IN_SINE, 400,
257 "opacity", 255);253 "opacity", 255);
258254
259 if (this.places_enabled)255 this.places_controller = new Places.Controller (this);
260 {256 this.places = this.places_controller.get_view ();
261 this.places_controller = new Places.Controller (this);
262 this.places = this.places_controller.get_view ();
263257
264 window_group.add_actor (this.places);258 window_group.add_actor (this.places);
265 window_group.raise_child (this.places,259 window_group.raise_child (this.places,
266 this.launcher.get_view ());260 this.launcher.get_view ());
267 this.places.opacity = 0;261 this.places.opacity = 0;
268 this.places.reactive = false;262 this.places.reactive = false;
269 this.places.hide ();263 this.places.hide ();
270 this.places_showing = false;264 this.places_showing = false;
271 }
272265
273 this.panel = new Panel.View (this);266 this.panel = new Panel.View (this);
274 window_group.add_actor (this.panel);267 window_group.add_actor (this.panel);
@@ -293,20 +286,20 @@
293 this.ensure_input_region ();286 this.ensure_input_region ();
294 return false;287 return false;
295 }288 }
296 289
297 private void on_focus_window_changed ()290 private void on_focus_window_changed ()
298 {291 {
299 check_fullscreen_obstruction ();292 check_fullscreen_obstruction ();
300 293
301 if (focus_window != null)294 if (focus_window != null)
302 {295 {
303 focus_window.notify["fullscreen"].disconnect (on_focus_window_fullscreen_changed);296 focus_window.notify["fullscreen"].disconnect (on_focus_window_fullscreen_changed);
304 }297 }
305 298
306 display.get ("focus-window", ref focus_window);299 display.get ("focus-window", ref focus_window);
307 focus_window.notify["fullscreen"].connect (on_focus_window_fullscreen_changed);300 focus_window.notify["fullscreen"].connect (on_focus_window_fullscreen_changed);
308 }301 }
309 302
310 private void on_focus_window_fullscreen_changed ()303 private void on_focus_window_fullscreen_changed ()
311 {304 {
312 warning ("FOCUS WINDOW FULLSCREEN CHANGED");305 warning ("FOCUS WINDOW FULLSCREEN CHANGED");
@@ -336,26 +329,26 @@
336 {329 {
337 Mutter.Window focus = null;330 Mutter.Window focus = null;
338 bool fullscreen = false;331 bool fullscreen = false;
339 332
340 // prevent segfault when mutter beats us to the initialization punch333 // prevent segfault when mutter beats us to the initialization punch
341 if (!(launcher is Launcher.Launcher) || !(panel is Clutter.Actor))334 if (!(launcher is Launcher.Launcher) || !(panel is Clutter.Actor))
342 return;335 return;
343 336
344 unowned GLib.List<Mutter.Window> mutter_windows = plugin.get_windows ();337 unowned GLib.List<Mutter.Window> mutter_windows = plugin.get_windows ();
345 foreach (Mutter.Window w in mutter_windows)338 foreach (Mutter.Window w in mutter_windows)
346 {339 {
347 unowned Mutter.MetaWindow meta = w.get_meta_window ();340 unowned Mutter.MetaWindow meta = w.get_meta_window ();
348 341
349 if (meta != null && Mutter.MetaWindow.has_focus (w.get_meta_window ()))342 if (meta != null && Mutter.MetaWindow.has_focus (w.get_meta_window ()))
350 { 343 {
351 focus = w;344 focus = w;
352 break;345 break;
353 }346 }
354 }347 }
355 348
356 if (focus == null)349 if (focus == null)
357 return;350 return;
358 351
359 (focus.get_meta_window () as GLib.Object).get ("fullscreen", ref fullscreen);352 (focus.get_meta_window () as GLib.Object).get ("fullscreen", ref fullscreen);
360 if (fullscreen)353 if (fullscreen)
361 {354 {
@@ -395,11 +388,8 @@
395 this.QUICKLAUNCHER_WIDTH - 1, 0, (uint32)height,388 this.QUICKLAUNCHER_WIDTH - 1, 0, (uint32)height,
396 PANEL_HEIGHT, 0, (uint32)width);389 PANEL_HEIGHT, 0, (uint32)width);
397390
398 if (this.places_enabled)391 this.places.set_size (width, height);
399 {392 this.places.set_position (0, 0);
400 this.places.set_size (width, height);
401 this.places.set_position (0, 0);
402 }
403393
404 this.panel.set_size (width, 24);394 this.panel.set_size (width, 24);
405 this.panel.set_position (0, 0);395 this.panel.set_position (0, 0);
@@ -465,11 +455,10 @@
465 * SHELL IMPLEMENTATION455 * SHELL IMPLEMENTATION
466 */456 */
467457
458 /*
468 public void show_window_picker ()459 public void show_window_picker ()
469 {460 {
470 if (this.places_enabled == true)461 this.show_unity ();
471 {
472 this.show_unity ();
473 return;462 return;
474 }463 }
475464
@@ -489,6 +478,7 @@
489478
490 this.expose_windows (windows, 80);479 this.expose_windows (windows, 80);
491 }480 }
481 */
492482
493 public Clutter.Stage get_stage ()483 public Clutter.Stage get_stage ()
494 {484 {
@@ -500,7 +490,7 @@
500 for (int i = 0; i < xids.length; i++)490 for (int i = 0; i < xids.length; i++)
501 {491 {
502 uint32 xid = xids.index (i);492 uint32 xid = xids.index (i);
503 493
504 unowned GLib.List<Mutter.Window> mutter_windows = this.plugin.get_windows ();494 unowned GLib.List<Mutter.Window> mutter_windows = this.plugin.get_windows ();
505 foreach (Mutter.Window window in mutter_windows)495 foreach (Mutter.Window window in mutter_windows)
506 {496 {
@@ -519,7 +509,7 @@
519 for (int i = 0; i < xids.length; i++)509 for (int i = 0; i < xids.length; i++)
520 {510 {
521 uint32 xid = xids.index (i);511 uint32 xid = xids.index (i);
522 512
523 unowned GLib.List<Mutter.Window> mutter_windows = plugin.get_windows ();513 unowned GLib.List<Mutter.Window> mutter_windows = plugin.get_windows ();
524 foreach (Mutter.Window w in mutter_windows)514 foreach (Mutter.Window w in mutter_windows)
525 {515 {
@@ -531,7 +521,7 @@
531 }521 }
532 }522 }
533 }523 }
534 524
535 expose_windows (windows);525 expose_windows (windows);
536 }526 }
537527
@@ -549,14 +539,14 @@
549 ulong window_xid = (ulong) Mutter.MetaWindow.get_xwindow (mutter_window.get_meta_window ());539 ulong window_xid = (ulong) Mutter.MetaWindow.get_xwindow (mutter_window.get_meta_window ());
550 if (window_xid != xid)540 if (window_xid != xid)
551 continue;541 continue;
552 542
553 int type = mutter_window.get_window_type ();543 int type = mutter_window.get_window_type ();
554544
555 if (type != Mutter.MetaWindowType.NORMAL &&545 if (type != Mutter.MetaWindowType.NORMAL &&
556 type != Mutter.MetaWindowType.DIALOG &&546 type != Mutter.MetaWindowType.DIALOG &&
557 type != Mutter.MetaWindowType.MODAL_DIALOG)547 type != Mutter.MetaWindowType.MODAL_DIALOG)
558 continue;548 continue;
559 549
560 uint32 time_;550 uint32 time_;
561 unowned Mutter.MetaWindow meta = mutter_window.get_meta_window ();551 unowned Mutter.MetaWindow meta = mutter_window.get_meta_window ();
562552
@@ -590,23 +580,24 @@
590580
591 public void show_unity ()581 public void show_unity ()
592 {582 {
593 if (this.places_enabled == false)
594 {
595 show_window_picker ();
596 return;
597 }
598 if (this.places_showing)583 if (this.places_showing)
599 {584 {
600 this.places_showing = false;585 this.places_showing = false;
601586
602 this.places.hide ();587 var anim = dark_box.animate (Clutter.AnimationMode.EASE_IN_QUAD, 100, "opacity", 0);
603 this.places.opacity = 0;588 anim.completed.connect ((an) => {
604 this.places.reactive = false;589 (an.get_object () as Clutter.Actor).destroy ();
605590 });
606 this.actor_blur.destroy ();591
607 this.dark_box.destroy ();592 plugin.get_normal_window_group ().animate (Clutter.AnimationMode.EASE_OUT_QUAD, 100, "opacity", 255);
593
594 anim = places.animate (Clutter.AnimationMode.EASE_OUT_QUAD, 100,
595 "opacity", 0);
596 anim.completed.connect ((an) => {
597 (an.get_object () as Clutter.Actor).hide ();
598 });
599
608 this.panel.set_indicator_mode (false);600 this.panel.set_indicator_mode (false);
609
610 this.ensure_input_region ();601 this.ensure_input_region ();
611 }602 }
612 else603 else
@@ -614,26 +605,17 @@
614 this.places_showing = true;605 this.places_showing = true;
615606
616 this.places.show ();607 this.places.show ();
617 this.places.opacity = 255;608 this.places.opacity = 0;
618 this.places.reactive = true;
619
620 this.actor_blur = new ActorBlur (this.plugin.get_normal_window_group ());
621
622 (this.plugin.get_window_group () as Clutter.Container).add_actor (this.actor_blur);
623 (this.actor_blur as Clutter.Actor).raise (this.plugin.get_normal_window_group ());
624
625 this.actor_blur.set_position (0, 0);
626
627 this.dark_box = new Clutter.Rectangle.with_color ({0, 0, 0, 255});609 this.dark_box = new Clutter.Rectangle.with_color ({0, 0, 0, 255});
628610
629 (this.plugin.get_window_group () as Clutter.Container).add_actor (this.dark_box);611 (this.plugin.get_window_group () as Clutter.Container).add_actor (this.dark_box);
630 this.dark_box.raise (this.actor_blur);612 this.dark_box.raise (plugin.get_normal_window_group ());
631613
632 this.dark_box.set_position (0, 0);614 this.dark_box.set_position (0, 0);
633 this.dark_box.set_size (this.stage.width, this.stage.height);615 this.dark_box.set_size (this.stage.width, this.stage.height);
634616
635 this.dark_box.show ();617 this.dark_box.show ();
636 this.actor_blur.show ();618
637 this.panel.set_indicator_mode (true);619 this.panel.set_indicator_mode (true);
638620
639 this.ensure_input_region ();621 this.ensure_input_region ();
@@ -641,12 +623,19 @@
641 new X.Display (null).flush ();623 new X.Display (null).flush ();
642624
643 this.dark_box.opacity = 0;625 this.dark_box.opacity = 0;
644 this.actor_blur.opacity = 255;
645626
646 this.dark_box.animate (Clutter.AnimationMode.EASE_IN_SINE, 250, "opacity", 180);627 this.dark_box.animate (Clutter.AnimationMode.EASE_IN_QUAD, 100, "opacity", 180);
628 plugin.get_normal_window_group ().animate (Clutter.AnimationMode.EASE_OUT_QUAD, 100, "opacity", 0);
629 places.animate (Clutter.AnimationMode.EASE_OUT_QUAD, 100,
630 "opacity", 255);
647 }631 }
648 }632 }
649633
634 public void about_to_show_places ()
635 {
636 places.about_to_show ();
637 }
638
650 public void grab_keyboard (bool grab, uint32 timestamp)639 public void grab_keyboard (bool grab, uint32 timestamp)
651 {640 {
652 if (this.grab_enabled == grab)641 if (this.grab_enabled == grab)
@@ -703,7 +692,7 @@
703 {692 {
704 this.maximus.process_window (window);693 this.maximus.process_window (window);
705 this.window_mapped (this, window);694 this.window_mapped (this, window);
706 695
707 if (display == null)696 if (display == null)
708 {697 {
709 display = Mutter.MetaWindow.get_display (window.get_meta_window ());698 display = Mutter.MetaWindow.get_display (window.get_meta_window ());
710699
=== modified file 'tests/ui/test-home-button.vala'
--- tests/ui/test-home-button.vala 2010-06-03 13:14:06 +0000
+++ tests/ui/test-home-button.vala 2010-06-24 07:45:42 +0000
@@ -132,7 +132,7 @@
132 }132 }
133133
134 public void134 public void
135 show_window_picker ()135 about_to_show_places ()
136 {136 {
137 // stub137 // stub
138 }138 }
139139
=== modified file 'tests/unit/Makefile.am'
--- tests/unit/Makefile.am 2010-06-10 00:17:10 +0000
+++ tests/unit/Makefile.am 2010-06-24 07:45:42 +0000
@@ -39,6 +39,7 @@
39 --pkg indicator \39 --pkg indicator \
40 --pkg clutk-0.3 \40 --pkg clutk-0.3 \
41 --pkg launcher-0.3 \41 --pkg launcher-0.3 \
42 --pkg posix \
42 --pkg test-const \43 --pkg test-const \
43 --pkg unique-1.0 \44 --pkg unique-1.0 \
44 --pkg unity \45 --pkg unity \
@@ -50,6 +51,8 @@
50 test-launcher.vala \51 test-launcher.vala \
51 test-panel-indicator-object-entry-view.vala \52 test-panel-indicator-object-entry-view.vala \
52 test-panel-indicator-object-view.vala \53 test-panel-indicator-object-view.vala \
54 test-places-place-file-model.vala \
55 test-places-place.vala \
53 test-places.vala \56 test-places.vala \
54 test-place.vala \57 test-place.vala \
55 test-unit.vala58 test-unit.vala
5659
=== modified file 'tests/unit/data/Makefile.am'
--- tests/unit/data/Makefile.am 2010-06-10 11:28:37 +0000
+++ tests/unit/data/Makefile.am 2010-06-24 07:45:42 +0000
@@ -1,1 +1,6 @@
1EXTRA_DIST = test_desktop_file.desktop1EXTRA_DIST = \
2 place0.badplace \
3 place0.place \
4 place1.badplace \
5 place1.place \
6 test_desktop_file.desktop
27
=== added file 'tests/unit/data/place0.badplace'
--- tests/unit/data/place0.badplace 1970-01-01 00:00:00 +0000
+++ tests/unit/data/place0.badplace 2010-06-24 07:45:42 +0000
@@ -0,0 +1,3 @@
1[PlaceGroup]
2DBusName=org.ayatana.Unity.Place0
3DBusObjectPath=/org/ayatana/Unity/Place0
04
=== added file 'tests/unit/data/place0.place'
--- tests/unit/data/place0.place 1970-01-01 00:00:00 +0000
+++ tests/unit/data/place0.place 2010-06-24 07:45:42 +0000
@@ -0,0 +1,3 @@
1[Place]
2DBusName=org.ayatana.Unity.Place0
3DBusObjectPath=/org/ayatana/Unity/Place0
04
=== added file 'tests/unit/data/place1.badplace'
--- tests/unit/data/place1.badplace 1970-01-01 00:00:00 +0000
+++ tests/unit/data/place1.badplace 2010-06-24 07:45:42 +0000
@@ -0,0 +1,19 @@
1[Place]
2DBusName=org.ayatana.Unity.Place1
3DBusObjectPath=/org/ayatana/Unity/Place1
4
5[Entry:One]
6DBusObjectPath=org/ayatana/Unity/Place1/Entry1
7Icon=gtk-apply
8Name=One
9Description=One Description
10ShowGlobal=true
11ShowEntry=false
12
13[Entry:Two]
14DBusObjectPath=
15Icon=gtk-close
16Name=Two
17Description=Two Description
18ShowGlobal=false
19ShowEntry=true
020
=== added file 'tests/unit/data/place1.place'
--- tests/unit/data/place1.place 1970-01-01 00:00:00 +0000
+++ tests/unit/data/place1.place 2010-06-24 07:45:42 +0000
@@ -0,0 +1,27 @@
1[Place]
2DBusName=org.ayatana.Unity.Place1
3DBusObjectPath=/org/ayatana/Unity/Place1
4
5[Entry:One]
6DBusObjectPath=/org/ayatana/Unity/Place1/Entry1
7Icon=gtk-apply
8Name=One
9Description=One Description
10ShowGlobal=true
11ShowEntry=false
12
13[Entry:Two]
14DBusObjectPath=/org/ayatana/Unity/Place1/Entry2
15Icon=gtk-close
16Name=Two
17Description=Two Description
18ShowGlobal=false
19ShowEntry=true
20
21[Entry:Three]
22DBusObjectPath=/org/ayatana/Unity/Place1/Entry3
23Icon=gtk-cancel
24Name=Three
25Description=Three Description
26ShowGlobal=false
27ShowEntry=false
028
=== added file 'tests/unit/test-places-place-file-model.vala'
--- tests/unit/test-places-place-file-model.vala 1970-01-01 00:00:00 +0000
+++ tests/unit/test-places-place-file-model.vala 2010-06-24 07:45:42 +0000
@@ -0,0 +1,43 @@
1/*
2 * Copyright (C) 2010 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by Neil Jagdish Patel <neil.patel@canonical.com>
17 *
18 */
19using Unity;
20using Unity.Testing;
21using Unity.Places;
22
23namespace Unity.Tests.Unit
24{
25 public class PlacesPlaceFileModelSuite : Object
26 {
27 public const string DOMAIN = "/Unit/Places/PlaceFileModel";
28
29 public PlacesPlaceFileModelSuite ()
30 {
31 Logging.init_fatal_handler ();
32
33 Test.add_data_func (DOMAIN + "/Allocation", test_allocation);
34 }
35
36 private void test_allocation ()
37 {
38 var model = new PlaceFileModel.with_directory (TESTDIR+"/data");
39 assert (model is PlaceFileModel);
40 assert (model.size == 2);
41 }
42 }
43}
044
=== added file 'tests/unit/test-places-place.vala'
--- tests/unit/test-places-place.vala 1970-01-01 00:00:00 +0000
+++ tests/unit/test-places-place.vala 2010-06-24 07:45:42 +0000
@@ -0,0 +1,161 @@
1/*
2 * Copyright (C) 2010 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by Neil Jagdish Patel <neil.patel@canonical.com>
17 *
18 */
19using Unity;
20using Unity.Testing;
21using Unity.Places;
22using GLib.Test;
23
24namespace Unity.Tests.Unit
25{
26 public class PlacesPlaceSuite : Object
27 {
28 public const string DOMAIN = "/Unit/Places/Place";
29
30 public PlacesPlaceSuite ()
31 {
32 Logging.init_fatal_handler ();
33
34 Test.add_data_func (DOMAIN + "/Allocation", test_allocation);
35 Test.add_data_func (DOMAIN + "/SimplePlaceFile", test_simple_placefile);
36 Test.add_data_func (DOMAIN + "/AdvancedPlaceFile", test_advanced_place_file);
37 Test.add_data_func (DOMAIN + "/BadSimplePlaceFile", test_bad_simple_place_file);
38 Test.add_data_func (DOMAIN + "/BadAdvancedPlaceFile", test_bad_advanced_place_file);
39 }
40
41 private void test_allocation ()
42 {
43 var place = new Places.Place ("__name__", "__path__");
44 assert (place is Places.Place);
45 assert (place.dbus_name == "__name__");
46 assert (place.dbus_path == "__path__");
47 }
48
49 private void test_simple_placefile ()
50 {
51 var file = new KeyFile ();
52 try {
53 file.load_from_file (TESTDIR + "/data/place0.place",
54 KeyFileFlags.NONE);
55 } catch (Error e) {
56 error ("Unable to load test place: %s", e.message);
57 }
58
59 var place = Places.Place.new_from_keyfile (file);
60 assert (place is Places.Place);
61
62 /* Test Place group was loaded properly */
63 assert (place.dbus_name == "org.ayatana.Unity.Place0");
64 assert (place.dbus_path == "/org/ayatana/Unity/Place0");
65
66 /* Test entries were loaded properly */
67 assert (place.n_entries == 0);
68 }
69
70 private void test_advanced_place_file ()
71 {
72 var file = new KeyFile ();
73 try {
74 file.load_from_file (TESTDIR + "/data/place1.place",
75 KeyFileFlags.NONE);
76 } catch (Error error) {
77 warning ("Unable to load test place: %s", error.message);
78 }
79
80 var place = Places.Place.new_from_keyfile (file);
81 assert (place is Places.Place);
82
83 /* Test Place group was loaded properly */
84 assert (place.dbus_name == "org.ayatana.Unity.Place1");
85 assert (place.dbus_path == "/org/ayatana/Unity/Place1");
86
87 /* Test entries were loaded properly */
88 assert (place.n_entries == 3);
89
90 /* Test individual entry's properties were loaded correctly */
91 PlaceEntry? e;
92
93 e = place.get_nth_entry (0);
94 assert (e is PlaceEntry);
95 assert (e.dbus_path == "/org/ayatana/Unity/Place1/Entry1");
96 assert (e.name == "One");
97 assert (e.icon == "gtk-apply");
98 assert (e.description == "One Description");
99 assert (e.show_global == true);
100 assert (e.show_entry == false);
101
102 e = place.get_nth_entry (1);
103 assert (e is PlaceEntry);
104 assert (e.dbus_path == "/org/ayatana/Unity/Place1/Entry2");
105 assert (e.name == "Two");
106 assert (e.icon == "gtk-close");
107 assert (e.description == "Two Description");
108 assert (e.show_global == false);
109 assert (e.show_entry == true);
110
111 e = place.get_nth_entry (2);
112 assert (e is PlaceEntry);
113 assert (e.dbus_path == "/org/ayatana/Unity/Place1/Entry3");
114 assert (e.name == "Three");
115 assert (e.icon == "gtk-cancel");
116 assert (e.description == "Three Description");
117 assert (e.show_global == false);
118 assert (e.show_entry == false);
119 }
120
121 private void test_bad_simple_place_file ()
122 {
123 var file = new KeyFile ();
124 try {
125 file.load_from_file (TESTDIR + "/data/place0.badplace",
126 KeyFileFlags.NONE);
127 } catch (Error error) {
128 warning ("Unable to load test place: %s", error.message);
129 }
130
131 if (trap_fork (0, TestTrapFlags.SILENCE_STDOUT | TestTrapFlags.SILENCE_STDERR))
132 {
133 var place = Places.Place.new_from_keyfile (file);
134 assert (place is Places.Place);
135 Posix.exit (0);
136 }
137 trap_has_passed ();
138 trap_assert_stderr ("*Does not contain 'Place' grou*");
139 }
140
141 private void test_bad_advanced_place_file ()
142 {
143 var file = new KeyFile ();
144 try {
145 file.load_from_file (TESTDIR + "/data/place1.badplace",
146 KeyFileFlags.NONE);
147 } catch (Error error) {
148 warning ("Unable to load test place: %s", error.message);
149 }
150
151 if (trap_fork (0, TestTrapFlags.SILENCE_STDOUT | TestTrapFlags.SILENCE_STDERR))
152 {
153 var place = Places.Place.new_from_keyfile (file);
154 assert (place is Places.Place);
155 Posix.exit (0);
156 }
157 trap_has_passed ();
158 trap_assert_stderr ("*Does not contain valid DBusObjectPat*");
159 }
160 }
161}
0162
=== modified file 'tests/unit/test-unit.vala'
--- tests/unit/test-unit.vala 2010-06-04 17:03:39 +0000
+++ tests/unit/test-unit.vala 2010-06-24 07:45:42 +0000
@@ -24,21 +24,30 @@
24{24{
25 public static int main (string[] args)25 public static int main (string[] args)
26 {26 {
27 LauncherSuite launcher;
28
27 PanelIndicatorObjectEntryViewSuite panel_object_entry_view_suite;29 PanelIndicatorObjectEntryViewSuite panel_object_entry_view_suite;
28 PanelIndicatorObjectViewSuite panel_object_view_suite;30 PanelIndicatorObjectViewSuite panel_object_view_suite;
29 31
32 PlacesPlaceFileModelSuite place_file_model;
33 PlacesPlaceSuite places_place;
30 PlacesSuite places;34 PlacesSuite places;
31 LauncherSuite launcher;
32 PlaceSuite place;35 PlaceSuite place;
3336
34 Gtk.init (ref args);37 Gtk.init (ref args);
35 Ctk.init (ref args);38 Ctk.init (ref args);
36 Test.init (ref args);39 Test.init (ref args);
3740
41 /* Launcher tests */
42 launcher = new LauncherSuite ();
43
44 /* Panel tests */
38 panel_object_entry_view_suite = new PanelIndicatorObjectEntryViewSuite ();45 panel_object_entry_view_suite = new PanelIndicatorObjectEntryViewSuite ();
39 panel_object_view_suite = new PanelIndicatorObjectViewSuite ();46 panel_object_view_suite = new PanelIndicatorObjectViewSuite ();
40 47 place_file_model = new PlacesPlaceFileModelSuite ();
41 launcher = new LauncherSuite ();48 places_place = new PlacesPlaceSuite ();
49
50 /* Places tests */
42 places = new PlacesSuite ();51 places = new PlacesSuite ();
43 place = new PlaceSuite ();52 place = new PlaceSuite ();
4453
4554
=== modified file 'unity-private/Makefile.am'
--- unity-private/Makefile.am 2010-06-10 16:42:49 +0000
+++ unity-private/Makefile.am 2010-06-24 07:45:42 +0000
@@ -79,28 +79,25 @@
79 panel/panel-indicator-model.vala \79 panel/panel-indicator-model.vala \
80 panel/panel-indicator-object-entry-view.vala \80 panel/panel-indicator-object-entry-view.vala \
81 panel/panel-indicator-object-view.vala \81 panel/panel-indicator-object-view.vala \
82 panel/panel-indicators.vala \
83 panel/panel-menu-manager.vala \82 panel/panel-menu-manager.vala \
84 panel/panel-menubar.vala \83 panel/panel-menubar.vala \
85 panel/panel-tray.vala \84 panel/panel-tray.vala \
86 panel/panel-view.vala85 panel/panel-view.vala
8786
88places_sources = \87places_sources = \
89 places/application-place.vala \
90 places/bar-model.vala \
91 places/bar-view.vala \
92 places/cairo-drawing.vala \
93 places/default-model.vala \
94 places/default-view.vala \
95 places/file-place.vala \
96 places/places-controller.vala \88 places/places-controller.vala \
97 places/places-model.vala \89 places/places-default-renderer-group.vala \
90 places/places-default-renderer.vala \
91 places/places-place-bar.vala \
92 places/places-place-entry-view.vala \
93 places/places-place-entry.vala \
94 places/places-place-model.vala \
95 places/places-place-view.vala \
98 places/places-place.vala \96 places/places-place.vala \
99 places/places-place-proxy.vala \97 places/places-place-search-bar.vala \
100 places/places-place-view.vala \98 places/places-place-search-entry.vala \
101 places/places-results-view.vala \99 places/places-place-search-sections-bar.vala \
102 places/places-view.vala \100 places/places-view.vala
103 places/search-field.vala
104101
105launcher_sources = \102launcher_sources = \
106 launcher/application-controller.vala \103 launcher/application-controller.vala \
107104
=== modified file 'unity-private/launcher/launcher-child.vala'
--- unity-private/launcher/launcher-child.vala 2010-06-16 17:10:50 +0000
+++ unity-private/launcher/launcher-child.vala 2010-06-24 07:45:42 +0000
@@ -407,6 +407,10 @@
407 private void on_rotation_changed ()407 private void on_rotation_changed ()
408 {408 {
409 old_rotate_value = processed_icon.rotation;409 old_rotate_value = processed_icon.rotation;
410
411 if (rotate_timeline is Clutter.Timeline == false)
412 return;
413
410 if (rotate_timeline.is_playing ())414 if (rotate_timeline.is_playing ())
411 {415 {
412 rotate_timeline.stop ();416 rotate_timeline.stop ();
@@ -488,7 +492,6 @@
488 out float minimum_height,492 out float minimum_height,
489 out float natural_height)493 out float natural_height)
490 {494 {
491 float nat, min;
492 natural_height = 48;495 natural_height = 48;
493 minimum_height = 48;496 minimum_height = 48;
494 }497 }
495498
=== modified file 'unity-private/launcher/scroller-controller.vala'
--- unity-private/launcher/scroller-controller.vala 2010-06-03 10:17:02 +0000
+++ unity-private/launcher/scroller-controller.vala 2010-06-24 07:45:42 +0000
@@ -171,6 +171,7 @@
171 }171 }
172 }172 }
173173
174 /*
174 public void on_favorite_removed (string uid)175 public void on_favorite_removed (string uid)
175 {176 {
176 }177 }
@@ -195,7 +196,7 @@
195196
196 return false;197 return false;
197 }198 }
198199 */
199 private ApplicationController? find_controller_by_desktop_file (string desktop_file)200 private ApplicationController? find_controller_by_desktop_file (string desktop_file)
200 {201 {
201 foreach (ScrollerChildController controller in childcontrollers)202 foreach (ScrollerChildController controller in childcontrollers)
202203
=== modified file 'unity-private/panel/panel-background.vala'
--- unity-private/panel/panel-background.vala 2010-06-03 09:53:03 +0000
+++ unity-private/panel/panel-background.vala 2010-06-24 07:45:42 +0000
@@ -60,7 +60,7 @@
60 last_width = width;60 last_width = width;
61 last_height = height;61 last_height = height;
6262
63 Idle.add (update_background);63 Timeout.add (0, update_background);
64 }64 }
65 }65 }
6666
6767
=== modified file 'unity-private/panel/panel-home-button.vala'
--- unity-private/panel/panel-home-button.vala 2010-06-21 09:14:43 +0000
+++ unity-private/panel/panel-home-button.vala 2010-06-24 07:45:42 +0000
@@ -42,9 +42,9 @@
42 float pheight;42 float pheight;
43 Ctk.Padding pad = { 0 };43 Ctk.Padding pad = { 0 };
4444
45 lwidth = (float) this.shell.get_launcher_width_foobar ();45 lwidth = (float) shell.get_launcher_width_foobar ();
46 pheight = (float) this.shell.get_panel_height_foobar ();46 pheight = (float) shell.get_panel_height_foobar ();
47 this.theme_image.get_preferred_size (out cwidth, out cheight,47 theme_image.get_preferred_size (out cwidth, out cheight,
48 out cwidth, out cheight);48 out cwidth, out cheight);
4949
50 /* adapt icon-width to launcher-width with padding */50 /* adapt icon-width to launcher-width with padding */
@@ -75,19 +75,20 @@
75 pad.bottom = pad.top;75 pad.bottom = pad.top;
76 }76 }
7777
78 this.padding = pad;78 padding = pad;
7979
80 base.allocate (box, flags);80 base.allocate (box, flags);
81 }81 }
8282
83 construct83 construct
84 {84 {
85 this.theme_image = new ThemeImage ("distributor-logo");85 theme_image = new ThemeImage ("distributor-logo");
86 this.add_actor (this.theme_image);86 add_actor (theme_image);
87 this.theme_image.show ();87 theme_image.show ();
8888
89 this.button_press_event.connect (this.on_button_press);89 button_press_event.connect (on_button_press);
90 this.button_release_event.connect (this.on_button_release);90 button_release_event.connect (on_button_release);
91 motion_event.connect (on_motion_event);
91 }92 }
9293
93 /* We always want to be the width of the launcher */94 /* We always want to be the width of the launcher */
@@ -95,8 +96,8 @@
95 out float min_width,96 out float min_width,
96 out float nat_width)97 out float nat_width)
97 {98 {
98 min_width = this.shell.get_launcher_width_foobar ();99 min_width = shell.get_launcher_width_foobar ();
99 nat_width = this.shell.get_launcher_width_foobar ();100 nat_width = shell.get_launcher_width_foobar ();
100 }101 }
101102
102 private bool on_button_press (Clutter.Event event)103 private bool on_button_press (Clutter.Event event)
@@ -111,6 +112,13 @@
111 manager.popdown_current_menu ();112 manager.popdown_current_menu ();
112 return true;113 return true;
113 }114 }
115
116 private bool on_motion_event (Clutter.Event event)
117 {
118 shell.about_to_show_places ();
119
120 return true;
121 }
114 }122 }
115}123}
116124
117125
=== removed file 'unity-private/panel/panel-indicators.vala'
--- unity-private/panel/panel-indicators.vala 2010-06-03 10:17:02 +0000
+++ unity-private/panel/panel-indicators.vala 1970-01-01 00:00:00 +0000
@@ -1,659 +0,0 @@
1/* -*- Mode: vala; indent-tabs-mode: nil; c-basic-offset: 2; tab-width: 2 -*- */
2/*
3 * Copyright (C) 2010 Canonical Ltd
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 *
17 * Authored by Neil Jagdish Patel <neil.patel@canonical.com>
18 *
19 */
20
21using Gee;
22using Utils;
23
24namespace Unity.Panel.Indicators
25{
26 public class View : Ctk.Box
27 {
28 private HashMap<string, int> indicator_order;
29
30 private Gtk.Menu? popped;
31 private uint32 click_time;
32 private float last_found_entry_x = 0.0f;
33
34 public View ()
35 {
36 Object (orientation:Ctk.Orientation.HORIZONTAL,
37 spacing:0,
38 homogeneous:false,
39 reactive:true);
40
41 Unity.Testing.ObjectRegistry.get_default ().register ("PanelIndicators",
42 this);
43 }
44
45 construct
46 {
47 this.indicator_order = new HashMap<string, int> ();
48
49 this.button_press_event.connect (this.on_button_press_event);
50 this.button_release_event.connect (this.on_button_release_event);
51 this.motion_event.connect (this.on_motion_event);
52 this.scroll_event.connect (on_scroll_event);
53
54 if (Environment.get_variable ("UNITY_DISABLE_IDLES") != null)
55 this.load_indicators ();
56 else
57 Idle.add (this.load_indicators);
58 }
59
60 private bool load_indicators ()
61 {
62 string skip_list;
63
64 /* Create the order */
65 this.indicator_order.set ("libapplication.so", 1);
66 this.indicator_order.set ("libsoundmenu.so", 2);
67 this.indicator_order.set ("libmessaging.so", 3);
68 this.indicator_order.set ("libdatetime.so", 4);
69 this.indicator_order.set ("libme.so", 5);
70 this.indicator_order.set ("libsession.so", 6);
71
72 /* The ones we don't want to load */
73 skip_list = Environment.get_variable ("UNITY_PANEL_INDICATORS_SKIP");
74 if (skip_list == null)
75 skip_list = "";
76
77 if (skip_list == "all")
78 return false;
79
80 /* We need to look for icons in an specific location */
81 Gtk.IconTheme.get_default ().append_search_path (INDICATORICONSDIR);
82
83 /* Start loading 'em in */
84 var dir = File.new_for_path (INDICATORDIR);
85 try
86 {
87 var e = dir.enumerate_children (FILE_ATTRIBUTE_STANDARD_NAME,
88 0,
89 null);
90
91 FileInfo file_info;
92 while ((file_info = e.next_file (null)) != null)
93 {
94 string leaf = file_info.get_name ();
95
96 if (leaf in skip_list || skip_list == "all")
97 continue;
98
99 if (leaf[leaf.len()-2:leaf.len()] == "so")
100 this.load_indicator (INDICATORDIR + file_info.get_name (),
101 file_info.get_name ());
102 }
103 }
104 catch (Error error)
105 {
106 print ("Unable to read indicators: %s\n", error.message); }
107
108 this.sort_children ((CompareFunc)reorder_icons);
109
110 return false;
111 }
112
113 public static int reorder_icons (IndicatorItem a, IndicatorItem b)
114 {
115 return a.position - b.position;
116 }
117
118 private void load_indicator (string filename, string leaf)
119 {
120 Indicator.Object o;
121
122 o = new Indicator.Object.from_file (filename);
123
124 if (o is Indicator.Object)
125 {
126 var i = new IndicatorItem ();
127 i.set_object (o);
128 this.add_actor (i);
129 i.show ();
130
131 i.menu_moved.connect (this.on_menu_moved);
132
133 i.position = (int)this.indicator_order[leaf];
134 }
135 else
136 {
137 warning ("Unable to load %s\n", filename);
138 }
139 }
140
141 private void position_menu (Gtk.Menu menu,
142 out int x,
143 out int y,
144 out bool push_in)
145 {
146 y = (int)this.height;
147 x = (int)this.last_found_entry_x;
148 }
149
150 private unowned IndicatorEntry? entry_for_event (float root_x)
151 {
152 unowned IndicatorItem? item = null;
153 unowned IndicatorEntry? entry = null;
154 float x = root_x - this.x;
155
156 /* Find which entry has the button press, pop it up */
157 unowned GLib.List<IndicatorItem> list = this.get_children ();
158 for (int i = 0; i < list.length (); i++)
159 {
160 unowned IndicatorItem it = (IndicatorItem)list.nth_data (i);
161
162 if (it.x < x && x < (it.x + it.width))
163 {
164 item = it;
165 break;
166 }
167 }
168
169 if (item == null)
170 return null;
171
172 x -= item.x;
173 list = item.get_children ();
174 for (int i = 0; i < list.length (); i++)
175 {
176 unowned IndicatorEntry ent = (IndicatorEntry)list.nth_data (i);
177
178 if (ent.x < x && x < (ent.x + ent.width))
179 {
180 this.last_found_entry_x = ent.x + item.x + this.x;
181 entry = ent;
182 }
183 }
184
185 return entry;
186 }
187
188 public void show_entry (IndicatorEntry entry)
189 {
190 if (this.popped is Gtk.Menu
191 && (this.popped.get_flags () & Gtk.WidgetFlags.VISIBLE) !=0)
192 {
193 this.popped.popdown ();
194 this.popped = null;
195 }
196
197 this.last_found_entry_x = entry.x + entry.get_parent ().x + this.x;
198
199 entry.menu.popup (null,
200 null,
201 this.position_menu,
202 1,
203 Clutter.get_current_event_time ());
204 click_time = Clutter.get_current_event_time ();
205 this.popped = entry.menu;
206 entry.menu_shown ();
207 }
208
209 private bool on_button_press_event (Clutter.Event e)
210 {
211 if (this.popped is Gtk.Menu
212 && (this.popped.get_flags () & Gtk.WidgetFlags.VISIBLE) !=0)
213 {
214 this.popped.popdown ();
215 this.popped = null;
216 }
217
218 unowned IndicatorEntry? entry = this.entry_for_event (e.button.x);
219 if (entry is IndicatorEntry)
220 {
221 entry.menu.popup (null,
222 null,
223 this.position_menu,
224 e.button.button,
225 e.button.time);
226 click_time = e.button.time;
227 this.popped = entry.menu;
228 entry.menu_shown ();
229 }
230 return true;
231 }
232
233 private bool on_button_release_event (Clutter.Event e)
234 {
235 if (e.button.time - click_time < 300)
236 return true;
237
238 if (this.popped is Gtk.Menu
239 && (this.popped.get_flags () & Gtk.WidgetFlags.VISIBLE) !=0)
240 {
241 this.popped.popdown ();
242 this.popped = null;
243 }
244
245 return true;
246 }
247
248 private bool on_motion_event (Clutter.Event e)
249 {
250 if (this.popped is Gtk.Menu
251 && (this.popped.get_flags () & Gtk.WidgetFlags.VISIBLE) !=0)
252 {
253 unowned IndicatorEntry? entry;
254
255 entry = entry_for_event (e.motion.x);
256
257 if (entry == null)
258 return true;
259
260 if (entry.menu != this.popped)
261 {
262 this.popped.popdown ();
263 this.popped = entry.menu;
264 this.popped.popup (null,
265 null,
266 this.position_menu,
267 e.button.button,
268 e.button.time);
269 entry.menu_shown ();
270 }
271 }
272
273 return true;
274 }
275
276 private bool on_scroll_event (Clutter.Event e)
277 {
278 Clutter.ScrollEvent event = e.scroll;
279
280 unowned IndicatorEntry? entry = this.entry_for_event (e.scroll.x);
281 if (entry is IndicatorEntry)
282 {
283 unowned Indicator.Object object = entry.get_data<Indicator.Object> ("Indicator.Object");
284
285 Signal.emit_by_name (object, "scroll", 1, event.direction);
286 }
287 return true;
288 }
289
290 private void on_menu_moved (IndicatorItem item,
291 Gtk.MenuDirectionType type)
292 {
293 unowned GLib.List<IndicatorItem> list = this.get_children ();
294
295 int pos = list.index (item);
296
297 if (pos == -1)
298 return;
299
300 /* For us, PARENT = previous menu, CHILD = next menu */
301 if (type == Gtk.MenuDirectionType.PARENT)
302 {
303 if (pos == 0)
304 return;
305 pos -= 1;
306 }
307 else if (type == Gtk.MenuDirectionType.CHILD)
308 {
309 if (pos == list.length ()-1)
310 return;
311 pos +=1;
312 }
313
314 /* Get the prev/next item */
315 IndicatorItem new_item = list.nth_data (pos) as IndicatorItem;
316
317 /* Find the right entry to activate */
318 unowned GLib.List<IndicatorEntry> l = new_item.get_children ();
319 int p = type == Gtk.MenuDirectionType.PARENT ? (int)l.length ()-1 : 0;
320 IndicatorEntry? new_entry = l.nth_data (p) as IndicatorEntry;
321
322 if (new_entry is IndicatorEntry)
323 this.show_entry (new_entry);
324 }
325 }
326
327 public class IndicatorItem : Ctk.Box
328 {
329 /**
330 * Represents one Indicator.Object
331 **/
332 private Indicator.Object object;
333 public int position;
334
335 public signal void menu_moved (Gtk.MenuDirectionType type);
336
337 public IndicatorItem ()
338 {
339 Object (orientation:Ctk.Orientation.HORIZONTAL,
340 spacing:0,
341 homogeneous:false);
342 }
343
344 construct
345 {
346 }
347
348 private void remove_entry (Indicator.ObjectEntry entry)
349 {
350 unowned GLib.List<IndicatorEntry> list = this.get_children ();
351
352 for (int i = 0; i < list.length (); i++)
353 {
354 IndicatorEntry e;
355
356 e = (IndicatorEntry) list.nth_data (i);
357
358 if (e.entry == entry)
359 {
360 this.remove_actor (e);
361 }
362 }
363 }
364
365 private void create_entry (Indicator.ObjectEntry entry,
366 Indicator.Object object)
367 {
368 IndicatorEntry e = new IndicatorEntry (entry);
369 e.set_data ("Indicator.Object", object);
370 this.add_actor (e);
371 this.show ();
372
373 e.menu_moved.connect (this.on_menu_moved);
374 }
375
376 private void on_menu_moved (IndicatorEntry entry,
377 Gtk.MenuDirectionType type)
378 {
379 unowned GLib.List<IndicatorEntry> list = this.get_children ();
380
381 int pos = list.index (entry);
382
383 if (pos == -1)
384 {
385 this.menu_moved (type);
386 return;
387 }
388
389 /* For us, PARENT = previous menu, CHILD = next menu */
390 if (type == Gtk.MenuDirectionType.PARENT)
391 {
392 if (pos == 0)
393 {
394 this.menu_moved (type);
395 return;
396 }
397 pos -= 1;
398 }
399 else if (type == Gtk.MenuDirectionType.CHILD)
400 {
401 if (pos == list.length ()-1)
402 {
403 this.menu_moved (type);
404 return;
405 }
406 pos +=1;
407 }
408
409 IndicatorEntry new_entry = list.nth_data (pos) as IndicatorEntry;
410
411 Indicators.View parent = this.get_parent () as Indicators.View;
412 parent.show_entry (new_entry);
413 }
414
415 private void on_entry_added (Indicator.Object object,
416 Indicator.ObjectEntry entry)
417 {
418 create_entry (entry, object);
419 }
420
421 public void set_object (Indicator.Object object)
422 {
423 this.object = object;
424
425 object.entry_added.connect (this.on_entry_added);
426 object.entry_removed.connect (this.remove_entry);
427
428 unowned GLib.List<Indicator.ObjectEntry> list = object.get_entries ();
429
430 for (int i = 0; i < list.length (); i++)
431 {
432 unowned Indicator.ObjectEntry entry;
433
434 entry = (Indicator.ObjectEntry) list.nth_data (i);
435
436 this.create_entry (entry, object);
437 }
438 }
439
440 public Indicator.Object get_object ()
441 {
442 return this.object;
443 }
444 }
445
446 public class IndicatorEntry : Ctk.Box
447 {
448 public unowned Indicator.ObjectEntry entry { get; construct; }
449
450 private Clutter.CairoTexture bg;
451
452 private Ctk.Image image;
453 private Ctk.Text text;
454
455 public Gtk.Menu menu { get { return this.entry.menu; } }
456
457 public signal void menu_moved (Gtk.MenuDirectionType type);
458
459 public IndicatorEntry (Indicator.ObjectEntry entry)
460 {
461 Object (entry:entry,
462 orientation:Ctk.Orientation.HORIZONTAL,
463 spacing:4,
464 reactive:false);
465 }
466
467 construct
468 {
469 this.padding = { 0, 3.0f, 0, 3.0f };
470
471 this.bg = new Clutter.CairoTexture (10, 10);
472 this.bg.set_parent (this);
473 this.bg.opacity = 0;
474 this.bg.show ();
475
476 if (this.entry.image is Gtk.Image)
477 {
478 this.image = new Ctk.Image (22);
479 this.add_actor (this.image);
480 this.image.show ();
481
482 if (this.entry.image.icon_name != null)
483 {
484
485 this.image.stock_id = this.entry.image.icon_name;
486
487 this.entry.image.notify["icon-name"].connect (() =>
488 {
489 this.image.stock_id = this.entry.image.icon_name;
490 });
491
492 unowned Gtk.IconTheme theme = Gtk.IconTheme.get_default ();
493 theme.changed.connect (() =>
494 {
495 this.image.stock_id = this.entry.image.icon_name;
496 });
497 }
498
499 if (this.entry.image.pixbuf != null)
500 {
501 this.image.pixbuf = this.entry.image.pixbuf;
502 this.image.size = this.entry.image.pixbuf.width;
503
504 this.entry.image.notify["pixbuf"].connect (() =>
505 {
506 this.image.pixbuf = this.entry.image.pixbuf;
507 this.image.size = this.entry.image.pixbuf.width;
508 });
509 }
510 }
511
512 if (this.entry.label is Gtk.Label)
513 {
514 this.text = new Ctk.Text ("");
515 this.text.color = { 233, 216, 200, 255 };
516 this.add_actor (this.text);
517 this.text.show ();
518
519 this.text.text = this.entry.label.label;
520
521 this.entry.label.notify["label"].connect (() =>
522 {
523 this.text.text = this.entry.label.label;
524 });
525 }
526 }
527
528 public void menu_shown ()
529 {
530 if (this.entry.menu is Gtk.Menu)
531 {
532 this.entry.menu.move_current.connect (this.menu_key_moved);
533 this.entry.menu.notify["visible"].connect (this.menu_vis_changed);
534 this.bg.animate (Clutter.AnimationMode.EASE_OUT_QUAD, 200,
535 "opacity", 255);
536
537 Clutter.Color col = { 255, 249, 233, 255 };
538 this.text.animate (Clutter.AnimationMode.EASE_OUT_QUAD, 200,
539 "color", ref col);
540 }
541 }
542
543 public void menu_vis_changed ()
544 {
545 bool vis = (this.entry.menu.get_flags () & Gtk.WidgetFlags.VISIBLE) != 0;
546
547 if (vis == false)
548 {
549 this.bg.animate (Clutter.AnimationMode.EASE_OUT_QUAD, 200,
550 "opacity", 0);
551
552 Clutter.Color col = { 233, 216, 200, 255 };
553 this.text.animate (Clutter.AnimationMode.EASE_OUT_QUAD, 200,
554 "color", ref col);
555 this.entry.menu.move_current.disconnect (this.menu_key_moved);
556 this.entry.menu.notify["visible"].disconnect (this.menu_vis_changed);
557 }
558 }
559
560 public void menu_key_moved (Gtk.MenuDirectionType type)
561 {
562 if (type != Gtk.MenuDirectionType.PARENT &&
563 type != Gtk.MenuDirectionType.CHILD)
564 return;
565
566 this.menu_moved (type);
567 }
568
569 private void update_bg (int width, int height)
570 {
571 Cairo.Context cr;
572
573 this.bg.set_surface_size (width, height);
574
575 cr = this.bg.create ();
576
577 cr.set_operator (Cairo.Operator.CLEAR);
578 cr.paint ();
579
580 cr.set_operator (Cairo.Operator.OVER);
581
582 cr.set_line_width (1.0);
583
584 cr.set_source_rgba (1.0, 1.0, 1.0, 0.2);
585
586 cr.move_to (1, height);
587
588 cr.line_to (1, 7);
589
590 cr.curve_to (1, 2,
591 1, 2,
592 10, 2);
593
594 cr.line_to (width-10, 2);
595
596 cr.curve_to (width, 2,
597 width, 2,
598 width, 7);
599
600 cr.line_to (width, height);
601
602 cr.line_to (1, height);
603
604 var pat = new Cairo.Pattern.linear (1, 0, 1, height);
605 pat.add_color_stop_rgba (0.0, 0.8509f, 0.8196f, 0.7294f, 1.0f);
606 pat.add_color_stop_rgba (1.0, 0.7019f, 0.6509f, 0.5137f, 1.0f);
607
608 cr.set_source (pat);
609 cr.fill ();
610 }
611
612 /*
613 * CLUTTER OVERRIDES
614 */
615 private override void allocate (Clutter.ActorBox box,
616 Clutter.AllocationFlags flags)
617 {
618 float width;
619 float height;
620
621 base.allocate (box, flags);
622
623 width = Math.floorf (box.x2 - box.x1);
624 height = Math.floorf (box.y2 - box.y1) - 1;
625
626 Clutter.ActorBox child_box = { 0 };
627 child_box.x1 = 0;
628 child_box.x2 = width;
629 child_box.y1 = 0;
630 child_box.y2 = height;
631
632 if (width != this.bg.width ||
633 height != this.bg.height)
634 {
635 this.update_bg ((int)width, (int)height);
636 }
637
638 this.bg.allocate (child_box, flags);
639 }
640
641 private override void paint ()
642 {
643 this.bg.paint ();
644 base.paint ();
645 }
646
647 private override void map ()
648 {
649 base.map ();
650 this.bg.map ();
651 }
652
653 private override void unmap ()
654 {
655 base.unmap ();
656 this.bg.unmap ();
657 }
658 }
659}
6600
=== modified file 'unity-private/panel/panel-menubar.vala'
--- unity-private/panel/panel-menubar.vala 2010-06-02 13:48:28 +0000
+++ unity-private/panel/panel-menubar.vala 2010-06-24 07:45:42 +0000
@@ -22,6 +22,8 @@
22{22{
23 public class MenuBar : Ctk.Box23 public class MenuBar : Ctk.Box
24 {24 {
25 public IndicatorObjectView indicator_object_view;
26
25 public MenuBar ()27 public MenuBar ()
26 {28 {
27 Object (spacing:0,29 Object (spacing:0,
@@ -40,7 +42,7 @@
4042
41 if (name == "libappmenu.so")43 if (name == "libappmenu.so")
42 {44 {
43 IndicatorObjectView indicator_object_view = new IndicatorObjectView (o);45 indicator_object_view = new IndicatorObjectView (o);
44 indicator_object_view.menu_moved.connect (this.on_menu_moved);46 indicator_object_view.menu_moved.connect (this.on_menu_moved);
4547
46 pack (indicator_object_view, false, true);48 pack (indicator_object_view, false, true);
4749
=== modified file 'unity-private/panel/panel-view.vala'
--- unity-private/panel/panel-view.vala 2010-06-18 15:42:52 +0000
+++ unity-private/panel/panel-view.vala 2010-06-24 07:45:42 +0000
@@ -56,7 +56,7 @@
56 bground = new Background ();56 bground = new Background ();
57 set_background (bground);57 set_background (bground);
58 bground.show ();58 bground.show ();
59 59
60 /* Create the views and add them to the box */60 /* Create the views and add them to the box */
61 home_button = new HomeButton (shell);61 home_button = new HomeButton (shell);
62 pack (home_button, false, true);62 pack (home_button, false, true);
@@ -74,7 +74,7 @@
74 pack (indicator_bar, false, true);74 pack (indicator_bar, false, true);
75 indicator_bar.show ();75 indicator_bar.show ();
7676
77 this.button_release_event.connect (this.on_button_release_event);77 button_release_event.connect (on_button_release_event);
7878
79 END_FUNCTION ();79 END_FUNCTION ();
80 }80 }
@@ -89,50 +89,17 @@
8989
90 public int get_indicators_width ()90 public int get_indicators_width ()
91 {91 {
92 return (int) this.indicator_bar.get_width ();92 return (int) indicator_bar.get_width ();
93 //this.system_tray.width + this.indicator_bar.width;93 //system_tray.width + indicator_bar.width;
94 }94 }
9595
96 public void set_expanded (bool _expanded)96 public void set_expanded (bool _expanded)
97 {97 {
98 // Hide menubar98 // Hide menubar
99 // Put background into expanded mode99 // Put background into expanded mode
100 this.expanded = _expanded;100 expanded = _expanded;
101 }101 }
102102
103// private override void allocate (Clutter.ActorBox box,
104// Clutter.AllocationFlags flags)
105// {
106// Clutter.ActorBox child_box = { 0, 0, box.x2 - box.x1, box.y2 - box.y1 };
107// float width;
108// float child_width;
109//
110// base.allocate (box, flags);
111//
112// width = box.x2 - box.x1;
113//
114// this.rect.set_clip (0, 0, width, box.y2 - box.y1);
115//
116// First the background
117// child_box.y2 += 3.0f;
118// this.rect.allocate (child_box, flags);
119// //
120// // Home button
121// // child_box.x1 = 0;
122// // child_box.x2 = 60;
123// // child_box.y1 = 0;
124// // child_box.y2 = PANEL_HEIGHT;
125// // this.home.allocate (child_box, flags);
126//
127// this.indicator_bar.get_preferred_width (PANEL_HEIGHT,
128// out child_width,
129// out child_width);
130// child_box.x1 = width - child_width;
131// child_box.x2 = width;
132// this.indicator_bar.allocate (child_box, flags);
133// }
134
135
136 public int get_panel_height ()103 public int get_panel_height ()
137 {104 {
138 return Unity.Panel.PANEL_HEIGHT;105 return Unity.Panel.PANEL_HEIGHT;
@@ -140,20 +107,24 @@
140107
141 public void set_indicator_mode (bool mode)108 public void set_indicator_mode (bool mode)
142 {109 {
143 if (mode)110 if (mode)
144 {111 {
145 menu_bar.hide ();112 if (menu_bar.indicator_object_view is Clutter.Actor)
113 menu_bar.indicator_object_view.hide ();
146 bground.hide ();114 bground.hide ();
147 system_tray.hide ();115 system_tray.hide ();
148 indicator_bar.set_indicator_mode (mode);116 indicator_bar.set_indicator_mode (mode);
149 }117 reactive = false;
150 else118 }
119 else
151 {120 {
152 menu_bar.show ();121 if (menu_bar.indicator_object_view is Clutter.Actor)
122 menu_bar.indicator_object_view.show ();
153 bground.show ();123 bground.show ();
154 system_tray.show ();124 system_tray.show ();
155 indicator_bar.set_indicator_mode (mode);125 indicator_bar.set_indicator_mode (mode);
156 }126 reactive = true;
127 }
157 }128 }
158 }129 }
159}130}
160131
=== removed file 'unity-private/places/application-place.vala'
--- unity-private/places/application-place.vala 2010-05-31 17:58:13 +0000
+++ unity-private/places/application-place.vala 1970-01-01 00:00:00 +0000
@@ -1,297 +0,0 @@
1/*
2 * Copyright (C) 2010 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by Jay Taoko <jay.taoko@canonical.com>
17 *
18 */
19
20namespace Unity.Places.Application
21{
22
23 const string APP_ICON = Unity.PKGDATADIR + "/applications.png";
24 const string FAVOURITES_ICON = Unity.PKGDATADIR + "/favourites.png";
25 const string MINIMIZE_ICON = Unity.PKGDATADIR + "/minimize_up.png";
26 const string MAXIMIZE_ICON = Unity.PKGDATADIR + "/maximize_up.png";
27
28 public class ApplicationIcon
29 {
30 private Unity.Places.Bar.Model model;
31 public Ctk.Image view;
32 public Ctk.Text label;
33
34 public ApplicationIcon (int width, /*int height,*/ string name, string icon_name, string tooltip)
35 {
36 model = new Unity.Places.Bar.Model (name, icon_name, tooltip);
37
38 if (icon_name[0] == '/')
39 view = new Ctk.Image.from_filename (width, icon_name);
40 else if (icon_name[-4] == '.')
41 view = new Ctk.Image.from_filename (width,
42 "/usr/share/pixmaps/" + icon_name);
43 else if (icon_name[0] == '.')
44 {
45 GLib.Icon icon;
46
47 try
48 {
49 icon = GLib.Icon.new_for_string(icon_name);
50 Gtk.IconInfo info = Gtk.IconTheme.get_default().lookup_by_gicon (icon, 48, 0);
51 if (info != null)
52 view = new Ctk.Image.from_filename (width, info.get_filename());
53 else
54 view = new Ctk.Image.from_stock (width, icon_name);
55 if (view == null)
56 warning (@"Failed to load icon for $icon_name");
57 }
58 catch (GLib.Error error)
59 {
60 warning (@"Failed to load icon: %s", error.message);
61 }
62 }
63 else
64 view = new Ctk.Image.from_stock (width, icon_name);
65
66 view.set_reactive (true);
67 label = new Ctk.Text (name);
68 label.set_line_wrap (true);
69 label.set_line_alignment (Pango.Alignment.CENTER);
70 }
71 }
72
73 public class ApplicationGroup : Ctk.Box
74 {
75 public int n_items = 0;
76
77 private Ctk.Text GroupName;
78 private Ctk.Image Star;
79 private Unity.Places.CairoDrawing.PlacesHSeparator Separator;
80 private Ctk.Image maximize_button;
81 private Ctk.Image minimize_button;
82 private bool is_open;
83 private Gee.ArrayList<ApplicationIcon> application_icon_array;
84
85
86 public override void allocate (Clutter.ActorBox box,
87 Clutter.AllocationFlags flags)
88 {
89 int width = (int)(box.x2 - box.x1);
90 int IconWidth = 120;
91 int IconHeight = 48;
92 int ApplicationIconSpacing = 24;
93
94 int HeaderBorderPositionX = 0;
95 int HeaderBorderPositionY = 0;
96 int IconBorderPositionX = 15;
97 int IconBorderPositionY = 30;
98 int LineBorderPositionX = 0;
99 int LineBorderPositionY = 20;
100
101 Clutter.ActorBox child_box = { 0.0f, 0.0f, 0.0f, 0.0f };
102
103 base.allocate (box, flags);
104
105 child_box.x1 = IconBorderPositionX;
106 child_box.x2 = IconWidth;
107 child_box.y1 = IconBorderPositionY;
108 child_box.y2 = child_box.y1 + IconHeight;
109
110 int i;
111 for (i = 0; i < this.application_icon_array.size; i++)
112 {
113 child_box.x2 = child_box.x1 + IconWidth;
114 this.application_icon_array[i].view.allocate(child_box, flags);
115
116 Clutter.ActorBox label_box = { 0.0f, 0.0f, 0.0f, 0.0f };
117 label_box.x1 = child_box.x1;
118 label_box.x2 = child_box.x2;
119 label_box.y1 = IconBorderPositionY + IconHeight + 12.0f;
120 label_box.y2 = label_box.y1 + 64;
121 this.application_icon_array[i].label.allocate(label_box, flags);
122
123 child_box.x1 += IconWidth + ApplicationIconSpacing;
124 }
125
126 if (this.Separator.Width != width)
127 {
128 this.Separator.CreateSeparator ( width, 5);
129 }
130 child_box.x1 = LineBorderPositionX;
131 child_box.x2 = child_box.x1 + width;
132 child_box.y1 = LineBorderPositionY;
133 child_box.y2 = LineBorderPositionY + 5;
134 this.Separator.allocate (child_box, flags);
135
136 child_box.x1 = HeaderBorderPositionX;
137 child_box.x2 = child_box.x1 + 22;
138 child_box.y1 = HeaderBorderPositionY;
139 child_box.y2 = HeaderBorderPositionY+ 23;
140 this.Star.allocate (child_box, flags);
141
142 child_box.x1 = HeaderBorderPositionX + 22;
143 child_box.x2 = child_box.x1 + 100;
144 child_box.y1 = HeaderBorderPositionY;
145 child_box.y2 = HeaderBorderPositionY + 23;
146 this.GroupName.allocate (child_box, flags);
147
148 child_box.x1 += width - 50;
149 child_box.x2 = child_box.x1 + 16;
150 child_box.y1 = HeaderBorderPositionY;
151 child_box.y2 = HeaderBorderPositionY + 19;
152 this.maximize_button.allocate (child_box, flags);
153 this.minimize_button.allocate (child_box, flags);
154 }
155
156 public override void get_preferred_width (float for_height,
157 out float minimum_width,
158 out float natural_width)
159 {
160 minimum_width = 800.0f;
161 natural_width = 800.0f;
162 }
163
164 public override void get_preferred_height (float for_width,
165 out float minimum_height,
166 out float natural_height)
167 {
168 minimum_height = 135.0f;
169 natural_height = 135.0f;
170 }
171
172 public ApplicationGroup (string group_name)
173 {
174 this.homogeneous = false;
175 this.orientation = Ctk.Orientation.HORIZONTAL;
176
177 this.GroupName = new Ctk.Text (group_name);
178 this.Star = new Ctk.Image.from_filename (23, FAVOURITES_ICON);
179 this.Separator = new Unity.Places.CairoDrawing.PlacesHSeparator ();
180 this.maximize_button = new Ctk.Image.from_filename (16, MAXIMIZE_ICON);
181 this.minimize_button = new Ctk.Image.from_filename (16, MINIMIZE_ICON);
182
183 application_icon_array = new Gee.ArrayList<ApplicationIcon> ();
184 /*
185 for (int i = 0; i < 5; i++)
186 {
187 ApplicationIcon app = new ApplicationIcon (48, "App",
188 APP_ICON,
189 "Your apps stored locally");
190 this.application_icon_array.add (app);
191 this.add_actor (app.view);
192 this.add_actor (app.label);
193 }
194*/
195 this.add_actor (this.Star);
196 this.add_actor (this.Separator);
197 this.add_actor (this.GroupName);
198 this.add_actor (this.maximize_button);
199 this.add_actor (this.minimize_button);
200
201 this.is_open = true;
202 this.show_all ();
203
204 this.maximize_button.set_reactive (true);
205 this.minimize_button.set_reactive (true);
206 this.maximize_button.hide();
207 this.minimize_button.show();
208
209 this.maximize_button.button_release_event.connect (this.on_maximize);
210 this.minimize_button.button_release_event.connect (this.on_minimize);
211 }
212
213 public void add_icon (ApplicationIcon app)
214 {
215 this.application_icon_array.add (app);
216 this.add_actor (app.view);
217 this.add_actor (app.label);
218
219 this.n_items++;
220 }
221
222 construct
223 {
224 }
225
226 public bool on_minimize (Clutter.Event event)
227 {
228 this.maximize_button.show();
229 this.minimize_button.hide();
230 this.is_open = false;
231 return false;
232 }
233
234 public bool on_maximize (Clutter.Event event)
235 {
236 this.maximize_button.hide();
237 this.minimize_button.show();
238 this.is_open = true;
239 return false;
240 }
241 }
242
243 public class ApplicationView : Ctk.Box
244 {
245 public ApplicationGroup recent_app_group;
246 public ApplicationGroup yesterday_app_group;
247 public ApplicationGroup lastweek_app_group;
248 public override void allocate (Clutter.ActorBox box,
249 Clutter.AllocationFlags flags)
250 {
251 Clutter.ActorBox child_box = { 0.0f, 0.0f, 0.0f, 0.0f };
252 float width, height;
253 float child_width, child_height;
254
255 base.allocate (box, flags);
256
257 width = box.x2 - box.x1;
258 height = box.y2 - box.y1;
259
260 this.recent_app_group.get_preferred_width (height,
261 out child_width,
262 out child_width);
263 this.recent_app_group.get_preferred_height (width,
264 out child_height,
265 out child_height);
266 child_box.x1 = (width - child_width)/2.0f;
267 child_box.x2 = child_box.x1 + child_width;
268 child_box.y1 = 0.0f;
269 child_box.y2 = child_height;
270 recent_app_group.allocate (child_box, flags);
271
272 child_box.y1 += child_height;
273 child_box.y2 = child_box.y1 + child_height;
274 yesterday_app_group.allocate (child_box, flags);
275
276 child_box.y1 += child_height;
277 child_box.y2 = child_box.y1 + child_height;
278 lastweek_app_group.allocate (child_box, flags);
279 }
280
281 public ApplicationView ()
282 {
283 recent_app_group = new ApplicationGroup ("Recent apps");
284 yesterday_app_group = new ApplicationGroup ("Yesterday apps");
285 lastweek_app_group = new ApplicationGroup ("Last week apps");
286
287 this.add_actor (recent_app_group);
288 this.add_actor (yesterday_app_group);
289 this.add_actor (lastweek_app_group);
290 this.show_all ();
291 }
292
293 construct
294 {
295 }
296 }
297}
2980
=== removed file 'unity-private/places/bar-model.vala'
--- unity-private/places/bar-model.vala 2009-12-14 14:14:37 +0000
+++ unity-private/places/bar-model.vala 1970-01-01 00:00:00 +0000
@@ -1,43 +0,0 @@
1/*
2 * Copyright (C) 2009 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by Mirco "MacSlow" Müller <mirco.mueller@canonical.com>
17 *
18 */
19
20using GLib;
21
22namespace Unity.Places.Bar
23{
24 public class Model : Object
25 {
26 public string name;
27 public string icon_name;
28 public string tooltip;
29
30 public Model (string name,
31 string icon_name,
32 string tooltip)
33 {
34 this.name = name;
35 this.icon_name = icon_name;
36 this.tooltip = tooltip;
37 }
38
39 construct
40 {
41 }
42 }
43}
440
=== removed file 'unity-private/places/bar-view.vala'
--- unity-private/places/bar-view.vala 2010-01-24 20:13:39 +0000
+++ unity-private/places/bar-view.vala 1970-01-01 00:00:00 +0000
@@ -1,253 +0,0 @@
1/*
2 * Copyright (C) 2009 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by Mirco "MacSlow" Müller <mirco.mueller@canonical.com>
17 * Neil Jagdish Patel <neil.patel@canonical.com>
18 *
19 */
20
21namespace Unity.Places.Bar
22{
23 const float PANEL_HEIGHT = 24;
24 const int ICON_SIZE = 48;
25 const float ICON_VIEW_WIDTH = 80.0f;
26 const float ICON_VIEW_Y1 = 8.0f;
27 const float QL_PAD = 12.0f;
28
29 const string TRASH_FILE = Unity.PKGDATADIR + "/trash.png";
30
31 public class View : Ctk.Box
32 {
33 public Places.Model model { get; construct; }
34 public Shell shell { get; construct; }
35
36 private Gee.ArrayList<PlaceIcon> places_icons;
37 private PlaceIcon trash_icon;
38
39 private Unity.Places.CairoDrawing.PlacesVSeparator separator;
40 private Unity.Places.CairoDrawing.PlacesBackground bg;
41
42 public View (Places.Model model, Shell shell)
43 {
44 Ctk.EffectGlow glow;
45 Clutter.Color white = {255, 255, 255, 255};
46
47 Object (model:model, shell:shell);
48
49 /* We do our own allocation, but this doesn't hurt */
50 this.homogeneous = false;
51 this.orientation = Ctk.Orientation.HORIZONTAL;
52
53 /* The background of the entire places bar */
54 this.bg = new Unity.Places.CairoDrawing.PlacesBackground ();
55 this.bg.set_parent (this);
56 this.bg.show ();
57 /* Make sure the bg is updated when the indicators change */
58 this.shell.indicators_changed.connect (this.on_indicators_changed);
59
60 /* This'll be populated in an idle by the model */
61 this.places_icons = new Gee.ArrayList<PlaceIcon> ();
62 this.model.place_added.connect (this.on_place_added);
63
64 /* Create trash icon */
65 this.trash_icon = new PlaceIcon (ICON_SIZE,
66 "Trash",
67 TRASH_FILE,
68 "Your piece of waste");
69 glow = new Ctk.EffectGlow ();
70 glow.set_color (white);
71 glow.set_factor (1.0f);
72 glow.set_margin (6);
73 this.trash_icon.add_effect (glow);
74
75 this.pack (this.trash_icon, false, false);
76 this.trash_icon.button_release_event.connect (this.on_button_release);
77
78 /* Create the separator */
79 this.separator = new Unity.Places.CairoDrawing.PlacesVSeparator ();
80 this.pack (this.separator, false, false);
81
82 this.show_all ();
83 }
84
85 private void on_place_added (Place place)
86 {
87 Clutter.Color white = {255, 255, 255, 255};
88
89 var icon = new PlaceIcon.from_place (ICON_SIZE, place);
90 this.places_icons.add (icon);
91
92 var glow = new Ctk.EffectGlow ();
93 glow.set_color (white);
94 glow.set_factor (1.0f);
95 glow.set_margin (6);
96 icon.add_effect (glow);
97
98 this.pack (icon, false, false);
99 icon.button_release_event.connect (this.on_button_release);
100
101 if (this.places_icons.size == 1)
102 {
103 Clutter.Actor stage = icon.get_stage ();
104 this.bg.create_places_background ((int)stage.width,
105 (int)stage.height,
106 (int)(this.padding.left + QL_PAD),
107 (int)ICON_VIEW_WIDTH,
108 this.shell.get_indicators_width());
109
110 icon.place.active = true;
111 }
112 }
113
114 private void on_indicators_changed (int width)
115 {
116 Clutter.Actor stage = this.get_stage ();
117 this.bg.create_places_background ((int)stage.width,
118 (int)stage.height,
119 (int)(this.padding.left + QL_PAD),
120 (int)ICON_VIEW_WIDTH,
121 width);
122 this.queue_relayout ();
123 }
124
125 public override void map ()
126 {
127 base.map ();
128 this.bg.map ();
129 }
130
131 public override void unmap ()
132 {
133 base.unmap ();
134 this.bg.unmap ();
135 }
136
137 public override void paint ()
138 {
139 this.bg.paint ();
140 base.paint ();
141 }
142
143 public override void allocate (Clutter.ActorBox box,
144 Clutter.AllocationFlags flags)
145 {
146 Clutter.ActorBox child_box = {0, 0, 0, 0};
147 child_box.x1 = 0.0f;
148 child_box.x2 = box.x2 - box.x1;
149 child_box.y1 = 0.0f;
150 child_box.y2 = box.y2 - box.y1;
151
152 this.bg.allocate (child_box, flags);
153
154 /* Allocate the places icons */
155 var n_places = 0;
156 var lpadding = this.padding.left + QL_PAD;
157
158 child_box.y1 = ICON_VIEW_Y1;
159 child_box.y2 = child_box.y1 + ICON_SIZE;
160
161 foreach (PlaceIcon place in this.places_icons)
162 {
163 child_box.x1 = lpadding + (ICON_VIEW_WIDTH * n_places);
164 child_box.x2 = child_box.x1 + ICON_VIEW_WIDTH;
165
166 place.allocate (child_box, flags);
167
168 n_places++;
169 }
170
171 /* Allocate the Trash (24 = Padding) */
172 var i_width = this.shell.get_indicators_width () + 8;
173 child_box.x1 = box.x2 - box.x1 - i_width - ICON_VIEW_WIDTH;
174 child_box.x2 = child_box.x1 + ICON_VIEW_WIDTH;
175 this.trash_icon.allocate (child_box, flags);
176
177 /* Allocate the seperator */
178 child_box.x1 -= 12.0f;
179 child_box.x2 = child_box.x1 + 5;
180 child_box.y1 = 10;
181 child_box.y2 = ICON_SIZE;
182 this.separator.allocate (child_box, flags);
183 }
184
185 public bool on_button_release (Clutter.Event event)
186 {
187 Clutter.Actor actor;
188 actor = event.button.source;
189
190 if (actor is PlaceIcon)
191 {
192 PlaceIcon icon = actor as PlaceIcon;
193
194 /* Do something with the click */
195 if (actor == this.trash_icon)
196 {
197 try
198 {
199 Process.spawn_command_line_async ("xdg-open trash:///");
200 }
201 catch (SpawnError e)
202 {
203 warning ("Unable to show Trash: %s", e.message);
204 }
205 }
206 else if (icon.place is Place)
207 {
208 Clutter.Actor stage = actor.get_stage ();
209
210 /* Update the background */
211 this.bg.create_places_background ((int)stage.width,
212 (int)stage.height,
213 (int)actor.x,
214 80,
215 this.shell.get_indicators_width());
216
217 /* Set the place as active, unset the others */
218 foreach (PlaceIcon picon in this.places_icons)
219 {
220 if (picon.place is Place)
221 picon.place.active = (picon == icon) ? true : false;
222 }
223 }
224
225 return true;
226 }
227
228 return false;
229 }
230 }
231
232 public class PlaceIcon : Ctk.Image
233 {
234 public Place? place { get; set; }
235
236 public PlaceIcon (int width,
237 string name,
238 string icon_name,
239 string tooltip)
240 {
241 Object (size:width);
242
243 this.set_from_filename (icon_name);
244 this.reactive = true;
245 }
246
247 public PlaceIcon.from_place (int size, Place place)
248 {
249 this(size, place.name, place.icon_name, "");
250 this.place = place;
251 }
252 }
253}
2540
=== removed file 'unity-private/places/cairo-drawing.vala'
--- unity-private/places/cairo-drawing.vala 2010-04-07 21:28:27 +0000
+++ unity-private/places/cairo-drawing.vala 1970-01-01 00:00:00 +0000
@@ -1,474 +0,0 @@
1/*
2 * Copyright (C) 2009 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by Jay Taoko <jay.taoko@canonical.com>
17 *
18 */
19
20namespace Unity.Places.CairoDrawing
21{
22 /* Margin outside of the cairo texture. We draw outside to complete the line loop
23 * and we don't want the line loop to be visible in some parts of the screen.
24 * */
25 private int Margin = 5;
26
27 public class PlacesBackground : Ctk.Bin
28 {
29 public Clutter.CairoTexture cairotxt;
30
31 private Ctk.EffectGlow effect_glow;
32
33 /* (X, Y) origine of Places Bar: The top-left corner of the screen */
34 private int PlaceX = 0;
35 private int PlaceY = 0;
36
37 /* Places Bar width and height. The width is set the the width of the window. */
38 private int PlaceW = 760;
39 private int PlaceH = 55;
40
41 private int PlaceBottom; /* PlaceY + PlaceH */
42
43 /* Menu area width and height */
44 private int MenuH = 22;
45 private int MenuW = 100;
46
47 private int MenuBottom; /* PlaceY + MenuH */
48
49 private int TabH = 50;
50
51 /* The squirl area width */
52 private int SquirlW = 66;
53
54 public struct TabRect
55 {
56 int left;
57 int right;
58 int top;
59 int bottom;
60 }
61
62 public int PlaceWidth;
63
64 void DrawAroundMenu (Cairo.Context cairoctx)
65 {
66 int radius = 8;
67 cairoctx.line_to (PlaceX + PlaceW + Margin, PlaceY + MenuH);
68 cairoctx.line_to (PlaceX + PlaceW - MenuW + radius, PlaceY + MenuH);
69
70 int arc_center_x = PlaceX + PlaceW - MenuW + radius;
71 int arc_center_y = PlaceY + MenuH + radius;
72
73 cairoctx.arc_negative ( (double)arc_center_x, (double)arc_center_y, radius, 3.0*Math.PI/2.0, Math.PI);
74
75 cairoctx.line_to (PlaceX + PlaceW - MenuW, PlaceY + PlaceH - radius);
76
77 arc_center_x = PlaceX + PlaceW - MenuW - radius;
78 arc_center_y = PlaceY + PlaceH - radius;
79 cairoctx.arc ( (double)arc_center_x, (double)arc_center_y, radius, 0.0, Math.PI/2.0);
80 }
81
82 void DrawTab(Cairo.Context cairoctx, TabRect tab)
83 {
84 int radius = 5;
85 int radius_small = 5;
86 int arc_center_x;
87 int arc_center_y;
88
89 cairoctx.line_to (tab.right + radius_small, PlaceBottom );
90
91 arc_center_x = tab.right + radius_small;
92 arc_center_y = PlaceBottom - radius_small;
93 cairoctx.arc ( (double)arc_center_x, (double)arc_center_y, radius_small, Math.PI/2.0, Math.PI);
94
95 cairoctx.line_to (tab.right, tab.top + radius);
96
97 arc_center_x = tab.right - radius;
98 arc_center_y = tab.top + radius;
99 cairoctx.arc_negative ( (double)arc_center_x, (double)arc_center_y, radius, 0.0, 3.0*Math.PI/2.0);
100
101 cairoctx.line_to (tab.left + radius, tab.top);
102
103 arc_center_x = tab.left + radius;
104 arc_center_y = tab.top + radius;
105 cairoctx.arc_negative ( (double)arc_center_x, (double)arc_center_y, radius, 3.0*Math.PI/2.0, Math.PI);
106
107 cairoctx.line_to (tab.left, PlaceBottom - radius_small);
108
109 arc_center_x = tab.left - radius_small;
110 arc_center_y = PlaceBottom - radius_small;
111 cairoctx.arc ( (double)arc_center_x, (double)arc_center_y, radius_small, 0.0, Math.PI/2.0);
112 }
113
114 void DrawSquirl(Cairo.Context cairoctx)
115 {
116 int radius_small = 5;
117 int arc_center_x;
118 int arc_center_y;
119
120 cairoctx.line_to (PlaceX + SquirlW + radius_small, PlaceBottom);
121
122 arc_center_x = PlaceX + SquirlW + radius_small;
123 arc_center_y = PlaceBottom - radius_small;
124 cairoctx.arc ( (double)arc_center_x, (double)arc_center_y, radius_small, Math.PI/2.0, Math.PI);
125
126 cairoctx.line_to (PlaceX + SquirlW, MenuBottom + radius_small );
127
128 arc_center_x = PlaceX + SquirlW - radius_small;
129 arc_center_y = MenuBottom + radius_small;
130 cairoctx.arc_negative ( (double)arc_center_x, (double)arc_center_y, radius_small, 0, 3.0*Math.PI/2.0);
131
132 cairoctx.line_to (PlaceX - Margin, MenuBottom);
133 }
134
135 public PlacesBackground ()
136 {
137 PlaceWidth = 0;
138 }
139
140 public void create_places_background (int WindowWidth,
141 int WindowHeight,
142 int TabPositionX,
143 int TabWidth,
144 int menu_width)
145 {
146 PlaceWidth = WindowWidth;
147 PlaceW = WindowWidth;
148 PlaceBottom = PlaceY + PlaceH;
149 MenuBottom = PlaceY + MenuH;
150
151 MenuW = menu_width;
152
153 if (this.get_child () is Clutter.Actor)
154 {
155 this.remove_actor (this.get_child ());
156 }
157
158 cairotxt = new Clutter.CairoTexture(PlaceW, PlaceH + Margin);
159 Cairo.Context cairoctx = cairotxt.create();
160 {
161 cairoctx.set_operator (Cairo.Operator.CLEAR);
162 cairoctx.paint ();
163 cairoctx.set_operator (Cairo.Operator.OVER);
164 cairoctx.translate (0.5f, 0.5f);
165
166 cairoctx.set_source_rgba (1, 1, 1, 1.0);
167 cairoctx.set_line_width (1.0);
168
169 cairoctx.move_to (PlaceX - Margin, PlaceY - Margin);
170 cairoctx.line_to (PlaceX + PlaceW + Margin, PlaceY - Margin);
171
172 DrawAroundMenu (cairoctx);
173
174 TabRect tab = TabRect();
175 tab.left = TabPositionX;
176 tab.right = tab.left + TabWidth;
177 tab.top = PlaceY + PlaceH - TabH;
178 tab.bottom = PlaceY + PlaceH;
179
180 DrawTab(cairoctx, tab);
181
182 DrawSquirl (cairoctx);
183
184 /* close the path */
185 cairoctx.line_to (PlaceX - Margin, PlaceY - Margin);
186
187 cairoctx.stroke_preserve ();
188
189 cairoctx.clip ();
190
191 Cairo.Surface surface = new Cairo.ImageSurface.from_png (Unity.PKGDATADIR + "/dash_background.png");
192 Cairo.Pattern pattern = new Cairo.Pattern.for_surface (surface);
193 pattern.set_extend (Cairo.Extend.REPEAT);
194 cairoctx.set_source (pattern);
195
196 cairoctx.paint_with_alpha (0.1);
197 }
198
199 cairotxt.set_opacity (0xFF);
200 this.add_actor (cairotxt);
201
202 /* Remove all effects set on this actor */
203 this.remove_all_effects ();
204
205 /* Create a new effect and add it to this actor */
206 /* The new effect will use the newly created drawing as a base */
207 effect_glow = new Ctk.EffectGlow ();
208 Clutter.Color c = Clutter.Color ()
209 {
210 red = 255,
211 green = 255,
212 blue = 255,
213 alpha = 255
214 };
215
216 effect_glow.set_color (c);
217 effect_glow.set_factor (1.0f);
218 effect_glow.set_margin (5);
219 this.add_effect (effect_glow);
220 }
221
222 construct
223 {
224 }
225 }
226
227
228 public class PlacesVSeparator : Ctk.Bin
229 {
230 public int Width = 0;
231 public int Height = 0;
232
233 public Clutter.CairoTexture cairotxt;
234 public PlacesVSeparator ()
235 {
236 }
237
238 public void CreateSeparator (int W, int H)
239 {
240 Width = W;
241 Height = H;
242
243 if (this.get_child () is Clutter.Actor)
244 {
245 this.remove_actor (this.get_child ());
246 }
247
248 cairotxt = new Clutter.CairoTexture(Width, Height);
249 Cairo.Context cairoctx = cairotxt.create();
250 {
251 cairoctx.set_source_rgba (1, 1, 1, 1.0);
252 cairoctx.set_line_width (1.0);
253
254 cairoctx.move_to (Width/2.0, 0);
255 cairoctx.line_to (Width/2.0, Height);
256
257 cairoctx.stroke ();
258 cairoctx.set_source_rgba (1, 1, 1, 0.15);
259 }
260
261 cairotxt.set_opacity (0xFF);
262 this.add_actor (cairotxt);
263
264 /* Remove all effects set on this actor */
265 this.remove_all_effects ();
266
267 /* Create a new effect and add it to this actor */
268 /* The new effect will use the newly created drawing as a base */
269 Ctk.EffectGlow effect_glow = new Ctk.EffectGlow ();
270 Clutter.Color c = Clutter.Color ()
271 {
272 red = 255,
273 green = 255,
274 blue = 255,
275 alpha = 255
276 };
277
278 effect_glow.set_color (c);
279 effect_glow.set_factor (1.0f);
280 effect_glow.set_margin (5);
281 this.add_effect (effect_glow);
282 }
283
284 construct
285 {
286 }
287 }
288
289 public class PlacesHSeparator : Ctk.Bin
290 {
291 public int Width = 0;
292 public int Height = 0;
293
294 public Clutter.CairoTexture cairotxt;
295 public PlacesHSeparator ()
296 {
297 }
298
299 public void CreateSeparator (int W, int H)
300 {
301 Width = W;
302 Height = H;
303
304 if (this.get_child () is Clutter.Actor)
305 {
306 this.remove_actor (this.get_child ());
307 }
308
309 cairotxt = new Clutter.CairoTexture(Width, Height);
310 Cairo.Context cairoctx = cairotxt.create();
311 {
312 cairoctx.set_source_rgba (1, 1, 1, 1.0);
313 cairoctx.set_line_width (1.0);
314
315 cairoctx.move_to (0, Height/2.0);
316 cairoctx.line_to (Width, Height/2.0);
317
318 cairoctx.stroke ();
319 cairoctx.set_source_rgba (1, 1, 1, 0.15);
320 }
321
322 cairotxt.set_opacity (0xFF);
323 this.add_actor (cairotxt);
324
325 /* Remove all effects set on this actor */
326 this.remove_all_effects ();
327
328 /* Create a new effect and add it to this actor */
329 /* The new effect will use the newly created drawing as a base */
330
331 Ctk.EffectGlow effect_glow = new Ctk.EffectGlow ();
332 Clutter.Color c = Clutter.Color ()
333 {
334 red = 255,
335 green = 255,
336 blue = 255,
337 alpha = 255
338 };
339
340 effect_glow.set_color (c);
341 effect_glow.set_factor (1.0f);
342 effect_glow.set_margin (5);
343 this.add_effect (effect_glow);
344 }
345
346 construct
347 {
348 }
349 }
350
351 public class RectangleBox : Ctk.Bin
352 {
353 public int Width = 0;
354 public int Height = 0;
355
356 public Clutter.CairoTexture cairotxt;
357 public RectangleBox ()
358 {
359 }
360
361 public void CreateRectangleBox (int W, int H)
362 {
363 Width = W;
364 Height = H;
365
366 if (this.get_child () is Clutter.Actor)
367 {
368 this.remove_actor (this.get_child ());
369 }
370
371 cairotxt = new Clutter.CairoTexture(Width, Height);
372 Cairo.Context cairoctx = cairotxt.create();
373 {
374 cairoctx.set_operator (Cairo.Operator.CLEAR);
375 cairoctx.paint ();
376 cairoctx.set_operator (Cairo.Operator.OVER);
377 cairoctx.translate (0.5f, 0.5f);
378
379 cairoctx.set_source_rgba (1, 1, 1, 1.0);
380 cairoctx.set_line_width (1.0);
381
382 cairoctx.move_to (1, 1);
383 cairoctx.line_to (Width-1, 1);
384 cairoctx.line_to (Width-1, Height-1);
385 cairoctx.line_to (1, Height-1);
386 cairoctx.line_to (1, 1);
387 cairoctx.stroke ();
388 }
389
390 cairotxt.set_opacity (0xFF);
391 this.add_actor (cairotxt);
392
393 /* Remove all effects set on this actor */
394 this.remove_all_effects ();
395
396 /* Create a new effect and add it to this actor */
397 /* The new effect will use the newly created drawing as a base */
398 Ctk.EffectGlow effect_glow = new Ctk.EffectGlow ();
399 Clutter.Color c = Clutter.Color ()
400 {
401 red = 255,
402 green = 255,
403 blue = 255,
404 alpha = 255
405 };
406
407 effect_glow.set_color (c);
408 effect_glow.set_factor (1.0f);
409 effect_glow.set_margin (5);
410 this.add_effect (effect_glow);
411 }
412
413 construct
414 {
415 }
416 }
417
418 public class EntryBackground : Ctk.Bin
419 {
420 public int Width = 0;
421 public int Height = 0;
422
423 public Clutter.CairoTexture cairotxt;
424 public EntryBackground ()
425 {
426 cairotxt = new Clutter.CairoTexture (120, 24);
427 add_actor (cairotxt);
428 }
429
430 public void create_search_entry_background (int W, int H)
431 {
432 Width = W;
433 Height = H;
434
435 Cairo.Context cairoctx = cairotxt.create();
436 {
437 cairoctx.set_operator (Cairo.Operator.CLEAR);
438 cairoctx.paint ();
439 cairoctx.set_operator (Cairo.Operator.OVER);
440 cairoctx.translate (-0.5f, -0.5f);
441
442 cairoctx.set_source_rgba (1.0, 1.0, 1.0, 0.9);
443 cairoctx.set_line_width (1.0);
444
445 cairoctx.move_to (10, 1);
446 cairoctx.line_to (Width-10, 1);
447
448 cairoctx.curve_to ((double)(Width-5), 1.0, (double)(Width-1), 5.0, (double)(Width-1), (double)(Height/2.0));
449 cairoctx.curve_to ((double)(Width-1), (double)(Height/2.0 + 5.0), (double)(Width-5), (double)(Height-2), (double)(Width-10), (double)(Height-2));
450
451 cairoctx.line_to (10, Height-2);
452
453 cairoctx.curve_to (5.0, (double)(Height-2), 1.0, (double)(Height/2.0 + 5.0), 1.0, (double)(Height/2.0));
454 cairoctx.curve_to (1.0, 5.0, 5.0, 1.0, 10.0, 1.0);
455
456
457 cairoctx.fill ();
458 }
459 cairotxt.set_opacity (0xFF);
460 }
461
462 /*private override void allocate (Clutter.ActorBox box,
463 Clutter.AllocationFlags flags)
464 {
465 base.allocate (box, flags);
466 create_search_entry_background ((int)(box.x2 - box.x1), (int)(box.y2 - box.y1));
467 }*/
468
469 construct
470 {
471 }
472 }
473}
474
4750
=== removed file 'unity-private/places/default-model.vala'
--- unity-private/places/default-model.vala 2009-12-14 14:14:37 +0000
+++ unity-private/places/default-model.vala 1970-01-01 00:00:00 +0000
@@ -1,43 +0,0 @@
1/*
2 * Copyright (C) 2009 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by Mirco "MacSlow" Müller <mirco.mueller@canonical.com>
17 *
18 */
19
20using GLib;
21
22namespace Unity.Places.Default
23{
24 public class Model : Object
25 {
26 public string icon_name;
27 public string primary_text;
28 public string secondary_text;
29
30 public Model (string icon_name,
31 string primary_text,
32 string secondary_text)
33 {
34 this.icon_name = icon_name;
35 this.primary_text = primary_text;
36 this.secondary_text = secondary_text;
37 }
38
39 construct
40 {
41 }
42 }
43}
440
=== removed file 'unity-private/places/default-view.vala'
--- unity-private/places/default-view.vala 2010-01-07 23:43:48 +0000
+++ unity-private/places/default-view.vala 1970-01-01 00:00:00 +0000
@@ -1,203 +0,0 @@
1/*
2 * Copyright (C) 2009 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by Mirco "MacSlow" Müller <mirco.mueller@canonical.com>
17 *
18 */
19
20namespace Unity.Places.Default
21{
22 public class ActivityWidget : Ctk.Box
23 {
24 private Ctk.Image icon;
25 private Clutter.Text primary_label;
26 private Clutter.Text secondary_label;
27
28 public ActivityWidget (int spacing,
29 int size,
30 string icon_name,
31 string primary_text,
32 string secondary_text)
33 {
34 string process_name = "activity_widget" + icon_name;
35 LOGGER_START_PROCESS (process_name);
36 Clutter.Color color = {255, 255, 255, 255};
37
38 this.homogeneous = false;
39 this.orientation = Ctk.Orientation.VERTICAL;
40 this.set_reactive (true);
41 //this.padding = pad;
42 this.spacing = spacing;
43 //this.width = size + 32;
44 this.icon = new Ctk.Image.from_stock (size, icon_name);
45 this.icon.set_reactive (true);
46
47 this.primary_label = new Clutter.Text ();
48 this.primary_label.set_reactive (true);
49 this.primary_label.width = size;
50 this.primary_label.set_markup (primary_text);
51 this.primary_label.justify = true;
52 this.primary_label.color = color;
53 this.primary_label.ellipsize = Pango.EllipsizeMode.NONE;
54 this.primary_label.line_wrap = true;
55 this.primary_label.line_alignment = Pango.Alignment.CENTER;
56
57 this.secondary_label = new Clutter.Text ();
58 this.secondary_label.set_reactive (true);
59 this.secondary_label.width = size + spacing;
60 //this.secondary_label.get_layout().set_height (-2);
61 this.secondary_label.text = secondary_text;
62 this.secondary_label.justify = false;
63 this.secondary_label.color = color;
64 //this.secondary_label.ellipsize = Pango.EllipsizeMode.END;
65 this.secondary_label.line_wrap = true;
66 this.secondary_label.line_alignment = Pango.Alignment.CENTER;
67 this.secondary_label.line_wrap_mode = Pango.WrapMode.WORD_CHAR;
68 this.enter_event.connect (this.on_enter);
69 this.leave_event.connect (this.on_leave);
70 this.secondary_label.opacity = 0;
71
72 this.pack (this.icon, false, false);
73 this.pack (this.primary_label, false, false);
74 this.pack (this.secondary_label, false, false);
75 LOGGER_END_PROCESS (process_name);
76 }
77
78 construct
79 {
80 }
81
82 public bool on_enter ()
83 {
84 this.secondary_label.opacity = 255;
85 return false;
86 }
87
88 public bool on_leave ()
89 {
90 this.secondary_label.opacity = 0;
91 return false;
92 }
93
94 public bool on_clicked ()
95 {
96 stdout.printf ("on_clicked() called\n");
97 return false;
98 }
99
100 }
101
102 public class View : Ctk.IconView
103 {
104 private Gee.ArrayList<Unity.Places.Default.Model> activities;
105
106 public override void allocate (Clutter.ActorBox box,
107 Clutter.AllocationFlags flags)
108 {
109 Ctk.Padding padding = { 0.0f, 0.0f, 0.0f, 0.0f };
110 float real_width;
111 float real_height;
112 float min_height_p;
113 float natural_height_p;
114 int hor_spacing;
115
116 hor_spacing = this.get_spacing ();
117 real_width = box.x2 - box.x1;
118 real_height = box.y2 - box.y1;
119 padding.left = (real_width - 4*128 -3*hor_spacing) / 2.0f; /* HARDCODED: 4 colum matrix */
120 padding.right = padding.left;
121
122 this.get_preferred_height (real_width,
123 out min_height_p,
124 out natural_height_p);
125
126 padding.top = (real_height - 400) / 2.0f; /* HARDCODED */
127 padding.bottom = padding.top;
128
129 this.set_padding (padding);
130 base.allocate (box, flags);
131 }
132
133 public View ()
134 {
135 START_FUNCTION ();
136 Unity.Places.Default.Model activity;
137 int i;
138 ActivityWidget widget;
139 int widget_size = 128; /* HARDCODED */
140
141 this.activities = new Gee.ArrayList<Unity.Places.Default.Model> ();
142
143 // populate defaultview with hard-coded contents for the moment
144 activity = new Unity.Places.Default.Model ("applications-internet",
145 "<b>Web</b>",
146 "Search, Suft & Download");
147 this.activities.add (activity);
148
149 activity = new Unity.Places.Default.Model ("rhythmbox",
150 "<b>Music</b>",
151 "Jukebox, Radio & Podcasts");
152 this.activities.add (activity);
153
154 activity = new Unity.Places.Default.Model ("applications-multimedia",
155 "<b>Videos</b>",
156 "YouTube & More");
157 this.activities.add (activity);
158
159 activity = new Unity.Places.Default.Model ("applications-graphics",
160 "<b>Photos</b>",
161 "Organize, Edit & Share");
162 this.activities.add (activity);
163
164 activity = new Unity.Places.Default.Model ("applications-office",
165 "<b>Work</b>",
166 "Office Documents, Spreadsheets & Presentations");
167 this.activities.add (activity);
168
169 activity = new Unity.Places.Default.Model ("evolution",
170 "<b>Email</b>",
171 "Read & Write Email");
172 this.activities.add (activity);
173
174 activity = new Unity.Places.Default.Model ("empathy",
175 "<b>Chat</b>",
176 "AIM, Yahoo, Skype & MSN");
177 this.activities.add (activity);
178
179 activity = new Unity.Places.Default.Model ("softwarecenter",
180 "<b>Get New Apps</b>",
181 "Ubuntu Software Center");
182 this.activities.add (activity);
183
184 // create image-actors now
185 for (i = 0; i < this.activities.size; i++)
186 {
187 widget = new ActivityWidget (0,
188 widget_size,
189 this.activities[i].icon_name,
190 this.activities[i].primary_text,
191 this.activities[i].secondary_text);
192 this.add_actor (widget);
193 }
194
195 this.show_all ();
196 END_FUNCTION ();
197 }
198
199 construct
200 {
201 }
202 }
203}
2040
=== removed file 'unity-private/places/file-place.vala'
--- unity-private/places/file-place.vala 2010-01-20 17:57:50 +0000
+++ unity-private/places/file-place.vala 1970-01-01 00:00:00 +0000
@@ -1,239 +0,0 @@
1
2namespace Unity.Places.File
3{
4
5 const string FILES_FILE = Unity.PKGDATADIR + "/files.png";
6 const string FAVOURITES_ICON = Unity.PKGDATADIR + "/favourites.png";
7 const string MINIMIZE_ICON = Unity.PKGDATADIR + "/minimize_up.png";
8 const string MAXIMIZE_ICON = Unity.PKGDATADIR + "/maximize_up.png";
9
10 public class FileIcon
11 {
12 private Unity.Places.Bar.Model model;
13 public Ctk.Image view;
14 public Ctk.Text label;
15
16 public FileIcon (int width, /*int height,*/ string name, string icon_name, string tooltip)
17 {
18 model = new Unity.Places.Bar.Model (name, icon_name, tooltip);
19 view = new Ctk.Image.from_filename (width, icon_name);
20 view.set_reactive (true);
21 label = new Ctk.Text (name);
22 }
23 }
24
25 public class FileGroup : Ctk.Box
26 {
27 private Ctk.Text GroupName;
28 private Ctk.Image Star;
29 private Unity.Places.CairoDrawing.PlacesHSeparator Separator;
30 private Ctk.Image maximize_button;
31 private Ctk.Image minimize_button;
32 private bool is_open;
33 private Gee.ArrayList<FileIcon> file_icon_array;
34
35
36 public override void allocate (Clutter.ActorBox box,
37 Clutter.AllocationFlags flags)
38 {
39 int IconWidth = 48;
40 int IconHeight = 48;
41 int FileIconSpacing = 100;
42
43 int HeaderBorderPositionX = 0;
44 int HeaderBorderPositionY = 60;
45 int IconBorderPositionX = 0;
46 int IconBorderPositionY = 100;
47 int LineBorderPositionX = 0;
48 int LineBorderPositionY = 90;
49
50 Clutter.ActorBox child_box = { 0.0f, 0.0f, 0.0f, 0.0f };
51
52 base.allocate (box, flags);
53
54 child_box.x1 = IconBorderPositionX;
55 child_box.x2 = 0;
56 child_box.y1 = IconBorderPositionY;
57 child_box.y2 = child_box.y1 + IconHeight;
58
59 int i;
60 for (i = 0; i < this.file_icon_array.size; i++)
61 {
62 child_box.x2 = child_box.x1 + IconWidth;
63 this.file_icon_array[i].view.allocate(child_box, flags);
64
65 Clutter.ActorBox label_box = { 0.0f, 0.0f, 0.0f, 0.0f };
66 label_box.x1 = child_box.x1;
67 label_box.x2 = child_box.x2;
68 label_box.y1 = IconBorderPositionY + IconHeight;
69 label_box.y2 = label_box.y1 + 64;
70 this.file_icon_array[i].label.allocate(label_box, flags);
71
72 child_box.x1 += IconWidth + FileIconSpacing;
73 }
74
75 if (this.Separator.Width != 800)
76 {
77 this.Separator.CreateSeparator ( 800, 5);
78 }
79 child_box.x1 = LineBorderPositionX;
80 child_box.x2 = child_box.x1 + 800;
81 child_box.y1 = LineBorderPositionY;
82 child_box.y2 = LineBorderPositionY + 5;
83 this.Separator.allocate (child_box, flags);
84
85 child_box.x1 = HeaderBorderPositionX;
86 child_box.x2 = child_box.x1 + 22;
87 child_box.y1 = HeaderBorderPositionY;
88 child_box.y2 = HeaderBorderPositionY+ 23;
89 this.Star.allocate (child_box, flags);
90
91 child_box.x1 = HeaderBorderPositionX + 22;
92 child_box.x2 = child_box.x1 + 100;
93 child_box.y1 = HeaderBorderPositionY;
94 child_box.y2 = HeaderBorderPositionY + 23;
95 this.GroupName.allocate (child_box, flags);
96
97 child_box.x1 += 750;
98 child_box.x2 = child_box.x1 + 16;
99 child_box.y1 = HeaderBorderPositionY;
100 child_box.y2 = HeaderBorderPositionY + 19;
101 this.maximize_button.allocate (child_box, flags);
102 this.minimize_button.allocate (child_box, flags);
103 }
104
105 public override void get_preferred_width (float for_height,
106 out float minimum_width,
107 out float natural_width)
108 {
109 minimum_width = 800.0f;
110 natural_width = 800.0f;
111 }
112
113 public override void get_preferred_height (float for_width,
114 out float minimum_height,
115 out float natural_height)
116 {
117 minimum_height = 150.0f;
118 natural_height = 150.0f;
119 }
120
121
122 public FileGroup (string group_name)
123 {
124 this.homogeneous = false;
125 this.orientation = Ctk.Orientation.HORIZONTAL;
126
127 this.GroupName = new Ctk.Text (group_name);
128 this.Star = new Ctk.Image.from_filename (23, FAVOURITES_ICON);
129 this.Separator = new Unity.Places.CairoDrawing.PlacesHSeparator ();
130 this.maximize_button = new Ctk.Image.from_filename (16, MAXIMIZE_ICON);
131 this.minimize_button = new Ctk.Image.from_filename (16, MINIMIZE_ICON);
132
133 file_icon_array = new Gee.ArrayList<FileIcon> ();
134 for (int i = 0; i < 5; i++)
135 {
136 FileIcon file = new FileIcon (48, "Files",
137 FILES_FILE,
138 "Your files stored locally");
139 this.file_icon_array.add (file);
140 this.add_actor (file.view);
141 this.add_actor (file.label);
142 }
143
144 this.add_actor (this.Star);
145 this.add_actor (this.Separator);
146 this.add_actor (this.GroupName);
147 this.add_actor (this.maximize_button);
148 this.add_actor (this.minimize_button);
149
150 this.is_open = true;
151 this.show_all ();
152
153 this.maximize_button.set_reactive (true);
154 this.minimize_button.set_reactive (true);
155 this.maximize_button.hide();
156 this.minimize_button.show();
157
158 this.maximize_button.button_release_event.connect (this.on_maximize);
159 this.minimize_button.button_release_event.connect (this.on_minimize);
160
161
162 }
163
164 construct
165 {
166 }
167
168 public bool on_minimize (Clutter.Event event)
169 {
170 this.maximize_button.show();
171 this.minimize_button.hide();
172 this.is_open = false;
173 return false;
174 }
175
176 public bool on_maximize (Clutter.Event event)
177 {
178 this.maximize_button.hide();
179 this.minimize_button.show();
180 this.is_open = true;
181 return false;
182 }
183 }
184
185 public class FileView : Ctk.Box
186 {
187 public FileGroup recent_file_group;
188 public FileGroup favourite_folder_group;
189 public FileGroup downloaded_file_group;
190 public override void allocate (Clutter.ActorBox box,
191 Clutter.AllocationFlags flags)
192 {
193 Clutter.ActorBox child_box = { 0.0f, 0.0f, 0.0f, 0.0f };
194 float width, height;
195 float child_width, child_height;
196
197 base.allocate (box, flags);
198
199 width = box.x2 - box.x1;
200 height = box.y2 - box.y1;
201
202 this.recent_file_group.get_preferred_width (height,
203 out child_width,
204 out child_width);
205 this.recent_file_group.get_preferred_height (width,
206 out child_height,
207 out child_height);
208 child_box.x1 = (width - child_width)/2.0f;
209 child_box.x2 = child_box.x1 + child_width;
210 child_box.y1 = 0.0f;
211 child_box.y2 = child_height;
212 recent_file_group.allocate (child_box, flags);
213
214 child_box.y1 += child_height;
215 child_box.y2 = child_box.y1 + child_height;
216 favourite_folder_group.allocate (child_box, flags);
217
218 child_box.y1 += child_height;
219 child_box.y2 = child_box.y1 + child_height;
220 downloaded_file_group.allocate (child_box, flags);
221 }
222
223 public FileView ()
224 {
225 recent_file_group = new FileGroup ("Recent Files");
226 favourite_folder_group = new FileGroup ("Favourite Files");
227 downloaded_file_group = new FileGroup ("Downloaded Files");
228
229 this.add_actor (recent_file_group);
230 this.add_actor (favourite_folder_group);
231 this.add_actor (downloaded_file_group);
232 this.show_all ();
233 }
234
235 construct
236 {
237 }
238 }
239}
2400
=== modified file 'unity-private/places/places-controller.vala'
--- unity-private/places/places-controller.vala 2010-04-27 12:04:34 +0000
+++ unity-private/places/places-controller.vala 2010-06-24 07:45:42 +0000
@@ -28,7 +28,6 @@
28 * keeping it up-to-date28 * keeping it up-to-date
29 **/29 **/
30 public Shell shell { get; construct; }30 public Shell shell { get; construct; }
31 private Model model;
32 private View view;31 private View view;
3332
34 public Controller (Shell shell)33 public Controller (Shell shell)
@@ -38,126 +37,12 @@
3837
39 construct38 construct
40 {39 {
41 this.model = new Model ();40 view = new View (shell);
42 this.view = new View (this.model, this.shell);41 }
4342
44 Idle.add (this.load_places);
45 }
46
47 private bool load_places ()
48 {
49 var homeplace = new HomePlace ();
50 homeplace.activated.connect (this.on_place_activated);
51 this.model.add (homeplace);
52
53 this.load_remote_places ();
54
55 var place = new FakePlace ("Files & Folders", PKGDATADIR + "/files.png");
56 place.activated.connect (this.on_place_activated);
57 this.model.add (place);
58
59 return false;
60 }
61
62 public void load_remote_places ()
63 {
64 string placesdir = PKGDATADIR + "/places";
65
66 var dir = GLib.File.new_for_path (placesdir);
67 try
68 {
69 var enumerator = dir.enumerate_children (FILE_ATTRIBUTE_STANDARD_NAME,
70 0,
71 null);
72 FileInfo file_info;
73 while ((file_info = enumerator.next_file (null)) != null)
74 {
75 var filename = placesdir + "/" + file_info.get_name ();
76 this.load_place (filename);
77 }
78 }
79 catch (Error error)
80 {
81 message (@"Unable to read places from $placesdir: %s", error.message);
82 }
83 }
84
85 private void load_place (string filename)
86 {
87 string group = "Place";
88
89 var file = new KeyFile ();
90
91 try
92 {
93 file.load_from_file (filename,
94 KeyFileFlags.KEEP_COMMENTS
95 | KeyFileFlags.KEEP_TRANSLATIONS);
96
97 var name = file.get_string (group, "Name");
98 var comment = file.get_string (group, "Comment");
99 var icon_name = file.get_string (group, "Icon");
100 var dbus_name = file.get_string (group, "DBusName");
101 var dbus_path = file.get_string (group, "DBusObjectPath");
102
103 Place place = new PlaceProxy (name,
104 icon_name,
105 comment,
106 dbus_name,
107 dbus_path);
108
109 if (place is Place)
110 {
111 place.activated.connect (this.on_place_activated);
112 this.model.add (place);
113 }
114 }
115 catch (Error e)
116 {
117 warning (@"Unable to load place '$filename': %s", e.message);
118 }
119 }
120
121 private void on_place_activated (Place place)
122 {
123 this.view.set_content_view (place.get_view ());
124 }
125
126 /* Public Methods */
127 public View get_view ()43 public View get_view ()
128 {44 {
129 return this.view;45 return view;
130 }
131 }
132
133 private class HomePlace : Place
134 {
135 public HomePlace ()
136 {
137 Object (name:"Home",
138 icon_name:PKGDATADIR + "/home.png",
139 comment:"");
140 }
141
142 public override Clutter.Actor get_view ()
143 {
144 return new Default.View ();
145 }
146 }
147
148 private class FakePlace : Place
149 {
150 public FakePlace (string name, string icon_name)
151 {
152 Object (name:name, icon_name:icon_name, comment:"");
153 }
154
155 public override Clutter.Actor get_view ()
156 {
157 if (this.name == "Applications")
158 return new Application.ApplicationView ();
159
160 return new File.FileView ();
161 }46 }
162 }47 }
163}48}
16449
=== added file 'unity-private/places/places-default-renderer-group.vala'
--- unity-private/places/places-default-renderer-group.vala 1970-01-01 00:00:00 +0000
+++ unity-private/places/places-default-renderer-group.vala 2010-06-24 07:45:42 +0000
@@ -0,0 +1,187 @@
1/*
2 * Copyright (C) 2010 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by Neil Jagdish Patel <neil.patel@canonical.com>
17 *
18 */
19
20namespace Unity.Places
21{
22 public class DefaultRendererGroup : Ctk.Box
23 {
24 static const float PADDING = 0.0f;
25 static const int SPACING = 0;
26
27 public uint group_id { get; construct; }
28 public string group_renderer { get; construct; }
29 public string display_name { get; construct; }
30 public string icon_hint { get; construct; }
31 public Dee.Model results { get; construct; }
32
33 private Ctk.HBox title_box;
34 private Ctk.Image icon;
35 private Ctk.Text text;
36 private Ctk.Image expander;
37 private Ctk.IconView renderer;
38
39 public DefaultRendererGroup (uint group_id,
40 string group_renderer,
41 string display_name,
42 string icon_hint,
43 Dee.Model results)
44 {
45 Object (group_id:group_id,
46 group_renderer:group_renderer,
47 display_name:display_name,
48 icon_hint:icon_hint,
49 results:results);
50 }
51
52 construct
53 {
54 padding = { PADDING, PADDING, PADDING , PADDING};
55 orientation = Ctk.Orientation.VERTICAL;
56 spacing = SPACING;
57 homogeneous = false;
58 hide ();
59
60 title_box = new Ctk.HBox (12);
61 pack (title_box, false, true);
62 title_box.show ();
63
64 icon = new Ctk.Image (24);
65 //title_box.pack (icon, false, true);
66 icon.show ();
67
68 text = new Ctk.Text (display_name);
69 title_box.pack (text, true, true);
70 text.show ();
71
72 expander = new Ctk.Image (24);
73 //title_box.pack (expander, false, true);
74 expander.show ();
75
76 var sep = new Clutter.Rectangle.with_color ({ 255, 255, 255, 255 });
77 sep.set_height (1);
78 pack (sep, false, false);
79 sep.show ();
80
81 renderer = new Ctk.IconView ();
82 renderer.padding = { 12.0f, 0.0f, 0.0f, 0.0f };
83 //renderer.spacing = 30;
84 pack (renderer, true, true);
85 renderer.show ();
86
87 results.row_added.connect (on_result_added);
88 results.row_removed.connect (on_result_removed);
89 }
90
91 private override void get_preferred_height (float for_width,
92 out float min_height,
93 out float nat_height)
94 {
95 var children = renderer.get_children ();
96 if (children.length () > 0)
97 {
98 base.get_preferred_height (for_width, out min_height, out nat_height);
99 show ();
100 }
101 else
102 {
103 min_height = 0;
104 nat_height = 0;
105 hide ();
106 }
107 }
108
109 /*
110 * Private Methods
111 */
112 private void on_result_added (Dee.ModelIter iter)
113 {
114 if (!interesting (iter))
115 return;
116
117 var button = new Tile ();
118 button.set_label (results.get_string (iter, 4));
119 unowned Ctk.Text text = button.get_text ();
120 text.ellipsize = Pango.EllipsizeMode.END;
121 button.get_image ().set_from_stock ("text-x-preview");
122 renderer.add_actor (button);
123 button.show ();
124
125 button.set_data<unowned Dee.ModelIter> ("model-iter", iter);
126 button.set_data<string> ("uri", "%s".printf (results.get_string (iter, 0)));
127 button.clicked.connect ((b) => {
128 unowned string uri = b.get_data<unowned string> ("uri");
129
130 print (@"Launching $uri\n");
131 try {
132 Gtk.show_uri (Gdk.Screen.get_default (),
133 uri,
134 0);
135 } catch (GLib.Error e) {
136 warning ("Unable to launch: %s", e.message);
137 }
138 });
139
140 show ();
141 }
142
143 private void on_result_removed (Dee.ModelIter iter)
144 {
145 if (!interesting (iter))
146 return;
147
148 var children = renderer.get_children ();
149 foreach (Clutter.Actor actor in children)
150 {
151 unowned Dee.ModelIter i;
152
153 i = actor.get_data<unowned Dee.ModelIter> ("model-iter");
154 if (i == iter)
155 {
156 actor.destroy ();
157 break;
158 }
159 }
160
161 if (children.length () <= 1)
162 hide ();
163 }
164
165 private bool interesting (Dee.ModelIter iter)
166 {
167 return (results.get_uint (iter, 2) == group_id);
168 }
169 }
170
171 public class Tile : Ctk.Button
172 {
173 public Tile ()
174 {
175 Object (orientation:Ctk.Orientation.VERTICAL);
176 }
177
178 private override void get_preferred_width (float for_height,
179 out float mwidth,
180 out float nwidth)
181 {
182 mwidth = 160.0f;
183 nwidth = 160.0f;
184 }
185 }
186}
187
0188
=== added file 'unity-private/places/places-default-renderer.vala'
--- unity-private/places/places-default-renderer.vala 1970-01-01 00:00:00 +0000
+++ unity-private/places/places-default-renderer.vala 2010-06-24 07:45:42 +0000
@@ -0,0 +1,86 @@
1/*
2 * Copyright (C) 2010 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by Neil Jagdish Patel <neil.patel@canonical.com>
17 *
18 */
19
20namespace Unity.Places
21{
22 public class DefaultRenderer : Ctk.ScrollView, Unity.Place.Renderer
23 {
24 static const float PADDING = 12.0f;
25 static const int SPACING = 12;
26
27 private Ctk.VBox box;
28 private Dee.Model groups_model;
29 private Dee.Model results_model;
30
31 public DefaultRenderer ()
32 {
33 Object ();
34 }
35
36 construct
37 {
38 padding = { 0.0f, 0.0f, PADDING, 0.0f };
39 box = new Ctk.VBox (SPACING);
40 box.padding = { PADDING, PADDING, PADDING , PADDING};
41 box.homogeneous = false;
42 add_actor (box);
43 box.show ();
44 }
45
46 /*
47 * Private Methods
48 */
49 public void set_models (Dee.Model groups,
50 Dee.Model results,
51 Gee.HashMap<string, string> hints)
52 {
53 groups_model = groups;
54 results_model = results;
55
56 groups_model.row_added.connect (on_group_added);
57 groups_model.row_removed.connect (on_group_removed);
58 }
59
60 private void on_group_added (Dee.Model model, Dee.ModelIter iter)
61 {
62 var group = new DefaultRendererGroup (model.get_position (iter),
63 model.get_string (iter, 0),
64 model.get_string (iter, 1),
65 model.get_string (iter, 2),
66 results_model);
67 group.set_data<unowned Dee.ModelIter> ("model-iter", iter);
68 box.pack (group, false, true);
69 }
70
71 private void on_group_removed (Dee.Model model, Dee.ModelIter iter)
72 {
73 GLib.List<Clutter.Actor> children = box.get_children ();
74 foreach (Clutter.Actor actor in children)
75 {
76 unowned Dee.ModelIter i = (Dee.ModelIter)actor.get_data<Dee.ModelIter> ("model-iter");
77 if (i == iter)
78 {
79 actor.destroy ();
80 break;
81 }
82 }
83 }
84 }
85}
86
087
=== removed file 'unity-private/places/places-model.vala'
--- unity-private/places/places-model.vala 2010-01-19 16:10:14 +0000
+++ unity-private/places/places-model.vala 1970-01-01 00:00:00 +0000
@@ -1,64 +0,0 @@
1/*
2 * Copyright (C) 2009 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by Neil Jagdish Patel <neil.patel@canonical.com>
17 *
18 */
19
20using Gee;
21
22namespace Unity.Places
23{
24 public class Model : Object
25 {
26 /**
27 * Contains a list of places
28 **/
29
30 /* Properties */
31 public ArrayList<Place> list;
32
33 /* Signals */
34 public signal void place_added (Place place);
35 public signal void place_removed (Place place);
36 public signal void place_changed (Place place);
37
38 public Model ()
39 {
40 Object ();
41 }
42
43 construct
44 {
45 list = new ArrayList<Place> ();
46 }
47
48 public void add (Place place)
49 {
50 this.list.add (place);
51
52 this.place_added (place);
53 }
54
55 public void remove (Place place)
56 {
57 this.list.remove (place);
58
59 this.place_removed (place);
60 }
61
62 }
63}
64
650
=== added file 'unity-private/places/places-place-bar.vala'
--- unity-private/places/places-place-bar.vala 1970-01-01 00:00:00 +0000
+++ unity-private/places/places-place-bar.vala 2010-06-24 07:45:42 +0000
@@ -0,0 +1,276 @@
1/*
2 * Copyright (C) 2010 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by Neil Jagdish Patel <neil.patel@canonical.com>
17 *
18 */
19
20namespace Unity.Places
21{
22 public class PlaceBar : Ctk.Box
23 {
24 /* Properties */
25 public Shell shell { get; construct; }
26 public PlaceModel model { get; set construct; }
27
28 private PlaceBarBackground bg;
29 private Ctk.EffectGlow glow;
30 private PlaceEntryView active_view = null;
31
32 public signal void entry_view_activated (PlaceEntryView view, int x);
33
34 public PlaceBar (Shell shell, PlaceModel model)
35 {
36 Object (shell:shell,
37 model:model,
38 orientation:Ctk.Orientation.HORIZONTAL,
39 homogeneous:false,
40 spacing:0);
41 }
42
43 construct
44 {
45 bg = new PlaceBarBackground (shell);
46 set_background (bg);
47 bg.show ();
48
49 /* Enable once clutk bug is fixed */
50 glow = new Ctk.EffectGlow ();
51 glow.set_color ({ 255, 255, 255, 255 });
52 glow.set_factor (1.0f);
53 glow.set_margin (5);
54 add_effect (glow);
55
56 foreach (Place place in model)
57 {
58 var view = new PlaceView (place);
59 pack (view, false, true);
60 view.show ();
61
62 view.entry_activated.connect (on_entry_activated);
63 }
64 model.place_added.connect ((p) => {
65 var view = new PlaceView (p);
66 pack (view, false, true);
67 view.show ();
68
69 view.entry_activated.connect (on_entry_activated);
70 });
71 }
72
73 private override void allocate (Clutter.ActorBox box,
74 Clutter.AllocationFlags flags)
75 {
76 padding = {
77 0.0f,
78 (float)shell.get_indicators_width (),
79 0.0f,
80 (float)shell.get_launcher_width_foobar ()};
81
82 base.allocate (box, flags);
83 }
84
85 private override void get_preferred_height (float for_width,
86 out float min_height,
87 out float nat_height)
88 {
89 min_height = 56.0f;
90 nat_height = 56.0f;
91 }
92
93 private void on_entry_activated (PlaceView view, PlaceEntryView entry_view)
94 {
95 if (active_view == entry_view)
96 return;
97
98 if (active_view is PlaceEntryView)
99 {
100 active_view.entry.active = false;
101 }
102
103 active_view = entry_view;
104 active_view.entry.active = true;
105 bg.entry_position = (int)(view.x + entry_view.x);
106
107 glow.set_invalidate_effect_cache (true);
108
109 entry_view_activated (entry_view,
110 bg.entry_position + (PlaceEntryView.WIDTH/2));
111 }
112 }
113
114 public class PlaceBarBackground : Clutter.CairoTexture
115 {
116 public const string BG = "/usr/share/unity/dash_background.png";
117
118 public Shell shell { get; construct; }
119
120 private int last_width = 0;
121 private int last_height = 0;
122
123 Gdk.Pixbuf tile = null;
124
125 private int _entry_position = 0;
126 public int entry_position {
127 get { return _entry_position; }
128 set {
129 if (_entry_position != value)
130 {
131 _entry_position = value;
132 update_background ();
133 }
134 }
135 }
136
137 public PlaceBarBackground (Shell shell)
138 {
139 Object (shell:shell);
140 }
141
142 construct
143 {
144 try
145 {
146 /* I've loaded this in directly and not through theme due to use
147 * not having a good loader for pixbufs from the theme right now
148 */
149 tile = new Gdk.Pixbuf.from_file (BG);
150 }
151 catch (Error e)
152 {
153 warning ("Unable to load dash background");
154 }
155 }
156
157 private override void allocate (Clutter.ActorBox box,
158 Clutter.AllocationFlags flags)
159 {
160 int width = (int)(box.x2 - box.x1);
161 int height = (int)(box.y2 - box.y1);
162
163 base.allocate (box, flags);
164
165 if (width != last_width || height != last_height)
166 {
167 last_width = width;
168 last_height = height;
169
170 Timeout.add (0, update_background);
171 }
172 }
173
174 private bool update_background ()
175 {
176 Cairo.Context cr;
177
178 set_surface_size (last_width, last_height);
179
180 cr = create ();
181
182 cr.set_operator (Cairo.Operator.CLEAR);
183 cr.paint ();
184
185 cr.set_operator (Cairo.Operator.OVER);
186 cr.set_line_width (1.5);
187 cr.set_source_rgba (1.0, 1.0, 1.0, 0.0);
188
189 cr.translate (-0.5, -0.5);
190
191 /* Basic variables */
192 var x = -1;
193 var y = -1;
194 var width = last_width + 2;
195 var height = last_height;
196 var radius = 13;
197 var launcher_width = shell.get_launcher_width_foobar ();
198 var panel_height = shell.get_panel_height_foobar ();
199 var entry_width = PlaceEntryView.WIDTH;
200 var top_padding = 3;
201
202 /* Draw the top outline */
203 cr.move_to (x, y);
204 cr.line_to (width, y);
205 cr.line_to (width, height);
206
207 if (entry_position != 0)
208 {
209 /* This is when we have an active place entry */
210 var x1 = entry_position;
211 var x2 = entry_position + entry_width;
212
213 cr.line_to (x2 + radius, height);
214 cr.curve_to (x2, height,
215 x2, height,
216 x2, height - radius);
217 cr.line_to (x2, radius + top_padding);
218 cr.curve_to (x2, top_padding,
219 x2, top_padding,
220 x2 - radius, top_padding);
221 cr.line_to (x1 + radius, top_padding);
222 cr.curve_to (x1, top_padding,
223 x1, top_padding,
224 x1, top_padding + radius);
225
226 if (x1 < launcher_width + entry_width) /* first entry */
227 {
228 cr.line_to (launcher_width, panel_height);
229 }
230 else
231 {
232 cr.line_to (x1, height - radius);
233 cr.curve_to (x1, height,
234 x1, height,
235 x1-radius, height);
236 cr.line_to (launcher_width + radius, height);
237 cr.curve_to (launcher_width, height,
238 launcher_width, height,
239 launcher_width, height - radius);
240 cr.line_to (launcher_width, panel_height);
241 }
242 }
243 else
244 {
245 cr.line_to (launcher_width + radius, height);
246 cr.curve_to (launcher_width, height,
247 launcher_width, height,
248 launcher_width, height - radius);
249 cr.line_to (launcher_width, panel_height);
250 }
251
252 cr.line_to (x, panel_height);
253 cr.close_path ();
254
255 cr.stroke_preserve ();
256 cr.clip_preserve ();
257
258 /* Tile the background */
259 if (tile is Gdk.Pixbuf)
260 {
261 Gdk.cairo_set_source_pixbuf (cr, tile, 0, 0);
262 var pat = cr.get_source ();
263 pat.set_extend (Cairo.Extend.REPEAT);
264 cr.paint_with_alpha (0.25);
265 }
266
267 /* Add the outline */
268 cr.reset_clip ();
269 cr.set_source_rgba (1.0, 1.0, 1.0, 0.6);
270 cr.stroke ();
271
272 return false;
273 }
274 }
275}
276
0277
=== added file 'unity-private/places/places-place-entry-view.vala'
--- unity-private/places/places-place-entry-view.vala 1970-01-01 00:00:00 +0000
+++ unity-private/places/places-place-entry-view.vala 2010-06-24 07:45:42 +0000
@@ -0,0 +1,51 @@
1/*
2 * Copyright (C) 2010 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by Neil Jagdish Patel <neil.patel@canonical.com>
17 *
18 */
19
20namespace Unity.Places
21{
22 public class PlaceEntryView : Ctk.Image
23 {
24 static const int WIDTH = 80;
25
26 /* Properties */
27 public PlaceEntry entry { get; construct; }
28
29 public PlaceEntryView (PlaceEntry entry)
30 {
31 Object (entry:entry,
32 size:48,
33 reactive:true);
34
35 set_from_filename (entry.icon);
36 }
37
38 construct
39 {
40 }
41
42 private override void get_preferred_width (float for_height,
43 out float min_width,
44 out float nat_width)
45 {
46 min_width = (float) WIDTH;
47 nat_width = (float) WIDTH;
48 }
49 }
50}
51
052
=== added file 'unity-private/places/places-place-entry.vala'
--- unity-private/places/places-place-entry.vala 1970-01-01 00:00:00 +0000
+++ unity-private/places/places-place-entry.vala 2010-06-24 07:45:42 +0000
@@ -0,0 +1,408 @@
1/*
2 * Copyright (C) 2010 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by Neil Jagdish Patel <neil.patel@canonical.com>
17 *
18 */
19
20namespace Unity.Places
21{
22 /**
23 * Represents a PlaceEntry through a .place file ("offline") and then through
24 * DBus ("online").
25 **/
26 public class PlaceEntry : Object
27 {
28 /* FIXME: Use what's in libunity. We only need this so vala allows us to
29 * connect to the signal
30 */
31 public struct RendererInfo
32 {
33 string default_renderer;
34 string groups_model;
35 string results_model;
36 HashTable<string, string> renderer_hints;
37 }
38
39 /*
40 * Properties
41 */
42 public string? dbus_name { get; construct; }
43 public string? dbus_path { get; construct; }
44 public string name { get; construct set; }
45 public string icon { get; construct set; }
46 public string description { get; construct set; }
47
48 public uint position { get; set; }
49 public string[] mimetypes { get; set; }
50 public bool sensitive { get; set; }
51
52 public Gee.HashMap<string, string> hints { get; set; }
53
54 /* Whether the Entry is available on the bus, this is only when we want to
55 * do optimisations for startup (showing the entries before actually
56 * starting the daemon. We can also abuse this for testing :)
57 */
58 public bool online { get; construct set; }
59
60 /* This is loaded from the desktop file, isn't useful when the entry
61 * is online
62 */
63 public bool show_global { get; construct set; }
64 public bool show_entry { get; construct set; }
65
66 /* This is relayed to the service, in case it needs to do something special
67 * when it's activated
68 */
69 private bool _active = false;
70 public bool active {
71 get { return _active; }
72 set {
73 if (_active != value)
74 {
75 _active = value;
76 service.set_active (_active);
77 }
78 }
79 }
80
81 /* We store the name of the sections model, and we provide the actual
82 * model too. The reason for this is that for testing, we can easily inject
83 * a fake model into a fake entry and test the views. It also keeps things
84 * cleaner for the views (they aren't creating their own models).
85 */
86 public string sections_model_name { get; set; }
87 private Dee.Model? _sections_model = null;
88 public Dee.Model? sections_model {
89 get {
90 if (_sections_model is Dee.Model == false)
91 {
92 if (sections_model_name != null)
93 {
94 _sections_model = new Dee.SharedModel.with_name (sections_model_name);
95 (_sections_model as Dee.SharedModel).connect ();
96 }
97 }
98 return _sections_model;
99 }
100 set {
101 _sections_model = value;
102 }
103 }
104
105 /* Entry rendering info */
106 public string entry_renderer_name;
107
108 public string entry_groups_model_name;
109 private Dee.Model? _entry_groups_model;
110 public Dee.Model? entry_groups_model {
111 get {
112 if (_entry_groups_model is Dee.Model == false)
113 {
114 if (entry_groups_model_name != null)
115 {
116 _entry_groups_model = new Dee.SharedModel.with_name (entry_groups_model_name);
117 (_entry_groups_model as Dee.SharedModel).connect ();
118 }
119 }
120 return _entry_groups_model;
121 }
122 set {
123 _entry_groups_model = value;
124 }
125 }
126
127 public string entry_results_model_name;
128 private Dee.Model? _entry_results_model;
129 public Dee.Model? entry_results_model {
130 get {
131 if (_entry_results_model is Dee.Model == false)
132 {
133 if (entry_results_model_name != null)
134 {
135 _entry_results_model = new Dee.SharedModel.with_name (entry_results_model_name);
136 (_entry_results_model as Dee.SharedModel).connect ();
137 }
138 }
139 return _entry_results_model;
140 }
141 set {
142 _entry_results_model = value;
143 }
144 }
145
146 public Gee.HashMap<string, string>? entry_renderer_hints;
147
148 /* Global rendering info */
149 public string global_renderer_name;
150
151 public string global_groups_model_name;
152 private Dee.Model? _global_groups_model;
153 public Dee.Model? global_groups_model {
154 get {
155 if (_global_groups_model is Dee.Model == false)
156 {
157 if (global_groups_model_name != null)
158 {
159 _global_groups_model = new Dee.SharedModel.with_name (global_groups_model_name);
160 (_global_groups_model as Dee.SharedModel).connect ();
161 }
162 }
163 return _global_groups_model;
164 }
165 set {
166 _global_groups_model = value;
167 }
168 }
169
170 public string global_results_model_name;
171 private Dee.Model? _global_results_model;
172 public Dee.Model? global_results_model {
173 get {
174 if (_global_results_model is Dee.Model == false)
175 {
176 if (global_results_model_name != null)
177 {
178 _global_results_model = new Dee.SharedModel.with_name (global_results_model_name);
179 (_global_results_model as Dee.SharedModel).connect ();
180 }
181 }
182 return _global_results_model;
183 }
184 set {
185 _global_results_model = value;
186 }
187 }
188
189 public Gee.HashMap<string, string>? global_renderer_hints;
190
191 /* Our connection to the place-entry over dbus */
192 private DBus.Connection? connection;
193 private dynamic DBus.Object? service;
194
195 /*
196 * Signals
197 */
198 public signal void updated ();
199 public signal void renderer_info_changed ();
200
201 /*
202 * Constructors
203 */
204 public PlaceEntry (string dbus_name, string dbus_path)
205 {
206 Object (dbus_name:dbus_name, dbus_path:dbus_path);
207 }
208
209 public PlaceEntry.with_info (string dbus_name,
210 string dbus_path,
211 string name,
212 string icon,
213 string description,
214 bool show_global,
215 bool show_entry)
216 {
217 Object (dbus_name:dbus_name,
218 dbus_path:dbus_path,
219 name:name,
220 icon:icon,
221 description:description,
222 show_global:show_global,
223 show_entry:show_entry);
224 }
225
226 construct
227 {
228 online = false;
229 }
230
231 /*
232 * Public Methods
233 */
234 public void update_info (GLib.ValueArray value_array)
235 requires (value_array.n_values == 10)
236 {
237 /* Un-marshal the array and update our information */
238 name = value_array.get_nth (1).get_string ();
239 icon = value_array.get_nth (2).get_string ();
240 position = value_array.get_nth (3).get_uint ();
241
242 /* FIXME: Unmarshall string[] mimetypes */
243
244 sensitive = value_array.get_nth (5).get_boolean ();
245 sections_model_name = value_array.get_nth (6).get_string ();
246
247 HashTable<string, string> hash = (HashTable<string, string>)(value_array.get_nth (7).get_boxed ());
248 if (hints != null)
249 hints = map_from_hash (hash);
250 else
251 hints = null;
252
253 /* Unmarshal the Entry RenderInfo */
254 unowned ValueArray ea = (ValueArray)(value_array.get_nth (8).get_boxed ());
255 if (ea != null)
256 {
257 entry_renderer_name = ea.get_nth (0).get_string ();
258
259 var str = ea.get_nth (1).get_string ();
260 if (entry_groups_model_name != str)
261 {
262 entry_groups_model_name = str;
263 entry_groups_model = null;
264 }
265
266 str = ea.get_nth (2).get_string ();
267 if (entry_results_model_name != str)
268 {
269 entry_results_model_name = str;
270 entry_results_model = null;
271 }
272
273 hash = (HashTable<string, string>)(ea.get_nth (3).get_boxed ());
274 if (hash != null)
275 entry_renderer_hints = map_from_hash (hash);
276 else
277 entry_renderer_hints = null;
278 }
279
280 /* Unmarshal the Global RenderInfo */
281 unowned ValueArray ga = (ValueArray)(value_array.get_nth (9).get_boxed ());
282 if (ga != null)
283 {
284 global_renderer_name = ga.get_nth (0).get_string ();
285
286 var str = ga.get_nth (1).get_string ();
287 if (global_groups_model_name != str)
288 {
289 global_groups_model_name = str;
290 global_groups_model = null;
291 }
292
293 str = ga.get_nth (2).get_string ();
294 if (global_results_model_name != str)
295 {
296 global_results_model_name = str;
297 global_results_model = null;
298 }
299
300 hash = (HashTable<string, string>)(ga.get_nth (3).get_boxed ());
301 if (hash != null)
302 global_renderer_hints = map_from_hash (hash);
303 else
304 global_renderer_hints = null;
305 }
306
307 updated ();
308 renderer_info_changed ();
309 }
310
311 public new void connect ()
312 {
313 if (online == true)
314 return;
315
316 /* Grab the entry off DBus */
317 try {
318 connection = DBus.Bus.get (DBus.BusType.SESSION);
319 service = connection.get_object (dbus_name,
320 dbus_path,
321 "com.canonical.Unity.PlaceEntry");
322 } catch (Error e) {
323 warning (@"Unable to connect to $dbus_path on $dbus_name: %s",
324 e.message);
325 return;
326 }
327
328 service.RendererInfoChanged.connect (on_renderer_info_changed);
329
330 online = true;
331 }
332
333 public void set_search (string search, HashTable<string, string> hints)
334 {
335 uint id;
336
337 id = service.set_search (search, hints);
338 }
339
340 public void set_active_section (uint section_id)
341 {
342 service.set_active_section (section_id);
343 }
344
345 public void set_global_search (string search,
346 HashTable<string, string> hints)
347 {
348 service.set_global_search (search, hints);
349 }
350
351 /*
352 * Private Methods
353 */
354
355 private void on_renderer_info_changed (dynamic DBus.Object dbus_object,
356 RendererInfo info)
357 {
358 RendererInfo *i = &info;
359 unowned ValueArray ea = (ValueArray)i;
360
361 if (ea != null)
362 {
363 entry_renderer_name = ea.get_nth (0).get_string ();
364
365 var str = ea.get_nth (1).get_string ();
366 if (entry_groups_model_name != str)
367 {
368 entry_groups_model_name = str;
369 entry_groups_model = null;
370 }
371
372 str = ea.get_nth (2).get_string ();
373 if (entry_results_model_name != str)
374 {
375 entry_results_model_name = str;
376 entry_results_model = null;
377 }
378
379 HashTable<string, string>hash = (HashTable<string, string>)(ea.get_nth (3).get_boxed ());
380 if (hash != null)
381 entry_renderer_hints = map_from_hash (hash);
382 else
383 entry_renderer_hints = null;
384
385 updated ();
386 renderer_info_changed ();
387 }
388 }
389
390 private Gee.HashMap<string, string> map_from_hash (HashTable<string, string>hash)
391 {
392 Gee.HashMap<string, string> map = new Gee.HashMap<string, string> ();
393
394 HashTableIter<string, string> iter = HashTableIter<string, string> (hash);
395 unowned void* key, val;
396 while (iter.next (out key, out val))
397 {
398 unowned string k = (string)key;
399 unowned string v = (string)val;
400
401 map[k] = v;
402 }
403
404 return map;
405 }
406 }
407}
408
0409
=== added file 'unity-private/places/places-place-model.vala'
--- unity-private/places/places-place-model.vala 1970-01-01 00:00:00 +0000
+++ unity-private/places/places-place-model.vala 2010-06-24 07:45:42 +0000
@@ -0,0 +1,155 @@
1/*
2 * Copyright (C) 2010 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by Neil Jagdish Patel <neil.patel@canonical.com>
17 *
18 */
19
20namespace Unity.Places
21{
22 /**
23 * PlaceModel:
24 *
25 * Contains the loaded Place objects. Abstract class so views can be
26 * tested with fake model
27 **/
28 public abstract class PlaceModel : Gee.ArrayList<Place>
29 {
30 public signal void place_added (Place place);
31 }
32
33
34 /**
35 * PlaceFileModel:
36 *
37 * Reads in .place files and creates the offline model, ready for representing
38 * to the user without actually initing any of the places
39 **/
40 public class PlaceFileModel : PlaceModel
41 {
42 /* Properties */
43 public string directory { get; construct; }
44 public bool async { get; construct; }
45
46 /* Constructors */
47 public PlaceFileModel ()
48 {
49 Object (directory:PKGDATADIR + "/places", async:true);
50 }
51
52 /* Allows loading places files from a non-install directory */
53 public PlaceFileModel.with_directory (string _directory)
54 {
55 Object (directory: _directory, async:false);
56 }
57
58 construct
59 {
60 /* Start asyncly reading in place files */
61 if (async)
62 load_place_files.begin ();
63 else
64 load_place_files_sync ();
65 }
66
67 /* Private Methods */
68
69 /*
70 * Read in all the .place files from the directory and convert them to
71 * Place objects, with the initial set of Entries, if that information
72 * was included inside the .place file
73 */
74 private async void load_place_files ()
75 {
76 var dir = File.new_for_path (directory);
77 try {
78 var e = yield dir.enumerate_children_async (FILE_ATTRIBUTE_STANDARD_NAME,
79 0,
80 Priority.DEFAULT, null);
81 while (true)
82 {
83 var files = yield e.next_files_async (10, Priority.DEFAULT, null);
84 if (files == null)
85 break;
86
87 foreach (var info in files)
88 {
89 if (info.get_name ().has_suffix (".place") == false)
90 continue;
91
92 /* FIXME: load_place needs to be async */
93 var place = load_place (Path.build_filename (directory,
94 info.get_name ()));
95 if (place is Place)
96 {
97 place.connect ();
98 (place as GLib.Object).ref ();
99 add (place);
100 place_added (place);
101 }
102 }
103 }
104
105 } catch (Error error) {
106 warning (@"Unable to read place files from directory '$directory': %s",
107 error.message);
108 }
109 }
110
111 private void load_place_files_sync ()
112 {
113 var dir = File.new_for_path (directory);
114 try {
115 var e = dir.enumerate_children (FILE_ATTRIBUTE_STANDARD_NAME, 0, null);
116 FileInfo info;
117 while ((info = e.next_file (null)) != null)
118 {
119 string leaf = info.get_name ();
120 if (leaf.has_suffix (".place") == false)
121 continue;
122
123 var place = load_place (Path.build_filename (directory, leaf));
124 if (place is Place)
125 {
126 add (place);
127 place_added (place);
128 }
129 }
130
131 } catch (Error error) {
132 warning (@"Unable to read place files from directory '$directory': %s",
133 error.message);
134 }
135 }
136
137 /*
138 * Reads in the place file (which is a key file) and creates and inits
139 * a UnityPlacesPlace object to represent it.
140 */
141 private Place? load_place (string path)
142 {
143 var file = new KeyFile ();
144 try {
145 file.load_from_file (path, KeyFileFlags.NONE);
146
147 return Place.new_from_keyfile (file, path);
148
149 } catch (Error e) {
150 warning (@"Unable to load place file '$path': %s", e.message);
151 return null;
152 }
153 }
154 }
155}
0156
=== removed file 'unity-private/places/places-place-proxy.vala'
--- unity-private/places/places-place-proxy.vala 2010-04-28 12:19:01 +0000
+++ unity-private/places/places-place-proxy.vala 1970-01-01 00:00:00 +0000
@@ -1,119 +0,0 @@
1/*
2 * Copyright (C) 2010 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by Neil Jagdish Patel <neil.patel@canonical.com>
17 *
18 */
19
20namespace Unity.Places
21{
22 public class PlaceProxy : Place
23 {
24 /**
25 * Represents a Remote Place (icon, view etc).
26 **/
27
28 /* Properties */
29 public string dbus_name { get; construct; }
30 public string dbus_path { get; construct; }
31
32 private DBus.Connection? conn;
33 private dynamic DBus.Object? service;
34
35 private Ctk.Box view;
36
37 public PlaceProxy (string name,
38 string icon_name,
39 string comment,
40 string dbus_name,
41 string dbus_path)
42 {
43 Object (name:name,
44 icon_name:PKGDATADIR + "/applications.png",
45 comment:comment,
46 dbus_name:dbus_name,
47 dbus_path:dbus_path);
48 }
49
50 construct
51 {
52
53 }
54
55 private void setup_service ()
56 {
57 try
58 {
59 // FIXME: Sync dbus calls all over the place!
60 this.conn = DBus.Bus.get (DBus.BusType.SESSION);
61 this.service = conn.get_object (this.dbus_name,
62 this.dbus_path,
63 "com.canonical.Unity.Place");
64
65 this.service.ViewChanged += this.on_view_changed;
66
67 this.service.set_active (false);
68 }
69 catch (Error e)
70 {
71 warning ("Unable to start service %s: %s",
72 this.dbus_name,
73 e.message);
74 }
75 }
76
77 private void on_view_changed (dynamic DBus.Object s,
78 HashTable<string, string> view_properties)
79 {
80 /**
81 * This is just to get something working, in the future they'll be a
82 * view_loader class that handles loading internal and extenal views
83 * (from models), and doing the string => GType conversion. Views just
84 * need to implement PlaceView interface
85 **/
86 var view_name = view_properties.lookup ("view-name");
87
88 debug (@"View changed: $view_name");
89 if (view_name == "ResultsView")
90 {
91 var new_view = new Views.ResultsView ();
92 new_view.init_with_properties (view_properties);
93
94 this.view.add_actor (new_view);
95 }
96 else
97 {
98 warning (@"Unknown view: $view_name");
99 }
100 }
101
102 public override Clutter.Actor get_view ()
103 {
104 /* Dump this in here for the moment */
105 if (!(this.service is DBus.Object))
106 {
107 this.setup_service ();
108 }
109
110 if (!(this.view is Ctk.Box))
111 {
112 this.view = new Ctk.VBox (0);
113 }
114
115 return this.view;
116 }
117 }
118}
119
1200
=== added file 'unity-private/places/places-place-search-bar.vala'
--- unity-private/places/places-place-search-bar.vala 1970-01-01 00:00:00 +0000
+++ unity-private/places/places-place-search-bar.vala 2010-06-24 07:45:42 +0000
@@ -0,0 +1,299 @@
1/*
2 * Copyright (C) 2010 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by Neil Jagdish Patel <neil.patel@canonical.com>
17 *
18 */
19
20namespace Unity.Places
21{
22 public class PlaceSearchBar : Ctk.Box
23 {
24 static const int SPACING = 10;
25 static const int RANDOM_TEXT_WIDTH = 400;
26
27 /* Properties */
28 private PlaceEntry? active_entry = null;
29
30 private PlaceSearchBarBackground bg;
31
32 private PlaceSearchEntry entry;
33 private PlaceSearchSectionsBar sections;
34
35 public PlaceSearchBar ()
36 {
37 Object (orientation:Ctk.Orientation.HORIZONTAL,
38 homogeneous:false,
39 spacing:8);
40 }
41
42 construct
43 {
44 padding = {
45 SPACING * 2.0f,
46 SPACING * 1.0f,
47 SPACING * 1.0f,
48 SPACING * 1.0f
49 };
50
51 entry = new PlaceSearchEntry ();
52 pack (entry, true, true);
53 entry.show ();
54 entry.text_changed.connect (on_search_text_changed);
55
56 sections = new PlaceSearchSectionsBar ();
57 pack (sections, false, true);
58 entry.show ();
59
60 bg = new PlaceSearchBarBackground (entry);
61 set_background (bg);
62 bg.show ();
63 }
64
65 private override void allocate (Clutter.ActorBox box,
66 Clutter.AllocationFlags flags)
67 {
68 float ex = entry.x;
69 float ewidth = entry.width;
70
71 base.allocate (box, flags);
72
73 if (entry.x != ex || entry.width != ewidth)
74 {
75 /* After discussion with upstream Clutter guys, it seems like the
76 * warning when resizing a CairoTexture is a bug in Clutter, however
77 * the fix is not trivial, so it was suggested to use a 0-sec timeout.
78 * We don't use an idle as it seems to have a lower priority and the
79 * user will see a jump between states, the 0-sec timeout seems to be
80 * dealt with immediately in the text iteration.
81 */
82 Timeout.add (0, bg.update_background);
83 }
84 }
85
86 private override void get_preferred_height (float for_width,
87 out float min_height,
88 out float nat_height)
89 {
90 float mheight, nheight;
91
92 entry.get_preferred_height (RANDOM_TEXT_WIDTH, out mheight, out nheight);
93 min_height = mheight + SPACING * 3;
94 nat_height = nheight + SPACING * 3;
95 }
96
97 private void on_search_text_changed (string text)
98 {
99 if (active_entry is PlaceEntry)
100 {
101 var hints = new HashTable<string, string> (str_hash, str_equal);
102 active_entry.set_search (text, hints);
103 }
104 }
105
106 /*
107 * Public Methods
108 */
109 public void set_active_entry_view (PlaceEntry entry, int x)
110 {
111 active_entry = entry;
112 bg.entry_position = x;
113 sections.set_active_entry (entry);
114 }
115 }
116
117 public class PlaceSearchBarBackground : Ctk.Bin
118 {
119 /* This is a full path right now as we get this asset from the assets
120 * package that is not installable (easily) normally. Will change to
121 * Config.DATADIR as soon as this is fixed in the other package.
122 */
123 public const string BG = "/usr/share/unity/dash_background.png";
124
125 private int last_width = 0;
126 private int last_height = 0;
127
128 Gdk.Pixbuf tile = null;
129
130 private int _entry_position = 0;
131 public int entry_position {
132 get { return _entry_position; }
133 set {
134 if (_entry_position != value)
135 {
136 _entry_position = value;
137 update_background ();
138 }
139 }
140 }
141
142 private Clutter.CairoTexture texture;
143 private Ctk.EffectGlow glow;
144
145 public PlaceSearchEntry search_entry { get; construct; }
146
147 public PlaceSearchBarBackground (PlaceSearchEntry search_entry)
148 {
149 Object (search_entry:search_entry);
150 }
151
152 construct
153 {
154 try
155 {
156 /* I've loaded this in directly and not through theme due to use
157 * not having a good loader for pixbufs from the theme right now
158 */
159 tile = new Gdk.Pixbuf.from_file (BG);
160 }
161 catch (Error e)
162 {
163 warning ("Unable to load dash background");
164 }
165
166 texture = new Clutter.CairoTexture (10, 10);
167 add_actor (texture);
168 texture.show ();
169
170 /* Enable once clutk bug is fixed */
171 glow = new Ctk.EffectGlow ();
172 glow.set_color ({ 255, 255, 255, 255 });
173 glow.set_factor (1.0f);
174 glow.set_margin (5);
175 add_effect (glow);
176 }
177
178 private override void allocate (Clutter.ActorBox box,
179 Clutter.AllocationFlags flags)
180 {
181 int width = (int)(box.x2 - box.x1);
182 int height = (int)(box.y2 - box.y1);
183
184 base.allocate (box, flags);
185
186 if (width != last_width || height != last_height)
187 {
188 last_width = width;
189 last_height = height;
190
191 Timeout.add (0, update_background);
192 }
193 }
194
195 public bool update_background ()
196 {
197 Cairo.Context cr;
198
199 texture.set_surface_size (last_width, last_height);
200
201 cr = texture.create ();
202
203 cr.set_operator (Cairo.Operator.CLEAR);
204 cr.paint ();
205
206 cr.set_operator (Cairo.Operator.OVER);
207 cr.set_line_width (1.5);
208 cr.set_source_rgba (1.0, 1.0, 1.0, 0.0);
209
210 cr.translate (0.5, 0.5);
211
The diff has been truncated for viewing.