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
1=== modified file '.bzrignore'
2--- .bzrignore 2010-06-03 17:13:55 +0000
3+++ .bzrignore 2010-06-24 07:45:42 +0000
4@@ -275,3 +275,42 @@
5 tests/ui/test-home-button.c
6 tests/unit/test-panel-indicator-object-entry-view.c
7 po/unity.pot
8+tests/unit/test-panel-indicator-object-view.c
9+tests/unit/test-place.c
10+tests/unit/test-places-place-file-model.c
11+unity/unity-place.c
12+unity-private/places/places-place-entry.c
13+unity-private/places/places-place-model.c
14+tests/unit/test-places-place.c
15+unity.pc
16+tests/ui/test-indicators.c
17+places/application-place.c
18+places/bar-model.c
19+places/bar-view.c
20+places/cairo-drawing.c
21+places/default-model.c
22+places/default-view.c
23+places/file-place.c
24+places/places-controller.c
25+places/places-model.c
26+places/places-place-bar.c
27+places/places-place.c
28+places/places-place-entry.c
29+places/places-place-entry-view.c
30+places/places-place-model.c
31+places/places-place-proxy.c
32+places/places-place-view.c
33+places/places-results-view.c
34+places/places-view.c
35+places/search-field.c
36+unity-private/panel/panel-indicator-background.c
37+unity-private/places/places-place-bar.c
38+unity-private/places/places-place-entry-view.c
39+unity-private/places/places-place-search-bar.cunity-private/places/places-place-search-bar.c
40+unity-private/places/places-place-search-bar.c
41+unity/unity-cairo-canvas.c
42+unity-private/places/places-place-search-entry.c
43+unity-private/places/places-place-search-sections-bar.c
44+unity/unity-place-renderer.c
45+unity-private/places/places-default-renderer-group.c
46+unity-private/places/places-default-renderer.c
47
48=== modified file 'targets/mutter/plugin.vala'
49--- targets/mutter/plugin.vala 2010-06-17 16:13:00 +0000
50+++ targets/mutter/plugin.vala 2010-06-24 07:45:42 +0000
51@@ -131,8 +131,6 @@
52 private unowned Mutter.MetaWindow? focus_window = null;
53 private unowned Mutter.MetaDisplay? display = null;
54
55- private bool places_enabled = false;
56-
57 private DragDest drag_dest;
58 private bool places_showing;
59 private bool _fullscreen_obstruction;
60@@ -229,8 +227,6 @@
61
62 Ctk.dnd_init ((Gtk.Widget)this.drag_dest, target_list);
63
64- this.places_enabled = envvar_is_enabled ("UNITY_ENABLE_PLACES");
65-
66 Clutter.Group window_group = (Clutter.Group) this.plugin.get_window_group ();
67
68 this.background = new Background ();
69@@ -256,19 +252,16 @@
70 this.launcher.get_view ().animate (Clutter.AnimationMode.EASE_IN_SINE, 400,
71 "opacity", 255);
72
73- if (this.places_enabled)
74- {
75- this.places_controller = new Places.Controller (this);
76- this.places = this.places_controller.get_view ();
77+ this.places_controller = new Places.Controller (this);
78+ this.places = this.places_controller.get_view ();
79
80- window_group.add_actor (this.places);
81- window_group.raise_child (this.places,
82- this.launcher.get_view ());
83- this.places.opacity = 0;
84- this.places.reactive = false;
85- this.places.hide ();
86- this.places_showing = false;
87- }
88+ window_group.add_actor (this.places);
89+ window_group.raise_child (this.places,
90+ this.launcher.get_view ());
91+ this.places.opacity = 0;
92+ this.places.reactive = false;
93+ this.places.hide ();
94+ this.places_showing = false;
95
96 this.panel = new Panel.View (this);
97 window_group.add_actor (this.panel);
98@@ -293,20 +286,20 @@
99 this.ensure_input_region ();
100 return false;
101 }
102-
103+
104 private void on_focus_window_changed ()
105 {
106 check_fullscreen_obstruction ();
107-
108+
109 if (focus_window != null)
110 {
111 focus_window.notify["fullscreen"].disconnect (on_focus_window_fullscreen_changed);
112 }
113-
114+
115 display.get ("focus-window", ref focus_window);
116 focus_window.notify["fullscreen"].connect (on_focus_window_fullscreen_changed);
117 }
118-
119+
120 private void on_focus_window_fullscreen_changed ()
121 {
122 warning ("FOCUS WINDOW FULLSCREEN CHANGED");
123@@ -336,26 +329,26 @@
124 {
125 Mutter.Window focus = null;
126 bool fullscreen = false;
127-
128+
129 // prevent segfault when mutter beats us to the initialization punch
130 if (!(launcher is Launcher.Launcher) || !(panel is Clutter.Actor))
131 return;
132-
133+
134 unowned GLib.List<Mutter.Window> mutter_windows = plugin.get_windows ();
135 foreach (Mutter.Window w in mutter_windows)
136 {
137 unowned Mutter.MetaWindow meta = w.get_meta_window ();
138-
139+
140 if (meta != null && Mutter.MetaWindow.has_focus (w.get_meta_window ()))
141- {
142+ {
143 focus = w;
144 break;
145 }
146 }
147-
148+
149 if (focus == null)
150 return;
151-
152+
153 (focus.get_meta_window () as GLib.Object).get ("fullscreen", ref fullscreen);
154 if (fullscreen)
155 {
156@@ -395,11 +388,8 @@
157 this.QUICKLAUNCHER_WIDTH - 1, 0, (uint32)height,
158 PANEL_HEIGHT, 0, (uint32)width);
159
160- if (this.places_enabled)
161- {
162- this.places.set_size (width, height);
163- this.places.set_position (0, 0);
164- }
165+ this.places.set_size (width, height);
166+ this.places.set_position (0, 0);
167
168 this.panel.set_size (width, 24);
169 this.panel.set_position (0, 0);
170@@ -465,11 +455,10 @@
171 * SHELL IMPLEMENTATION
172 */
173
174+ /*
175 public void show_window_picker ()
176 {
177- if (this.places_enabled == true)
178- {
179- this.show_unity ();
180+ this.show_unity ();
181 return;
182 }
183
184@@ -489,6 +478,7 @@
185
186 this.expose_windows (windows, 80);
187 }
188+ */
189
190 public Clutter.Stage get_stage ()
191 {
192@@ -500,7 +490,7 @@
193 for (int i = 0; i < xids.length; i++)
194 {
195 uint32 xid = xids.index (i);
196-
197+
198 unowned GLib.List<Mutter.Window> mutter_windows = this.plugin.get_windows ();
199 foreach (Mutter.Window window in mutter_windows)
200 {
201@@ -519,7 +509,7 @@
202 for (int i = 0; i < xids.length; i++)
203 {
204 uint32 xid = xids.index (i);
205-
206+
207 unowned GLib.List<Mutter.Window> mutter_windows = plugin.get_windows ();
208 foreach (Mutter.Window w in mutter_windows)
209 {
210@@ -531,7 +521,7 @@
211 }
212 }
213 }
214-
215+
216 expose_windows (windows);
217 }
218
219@@ -549,14 +539,14 @@
220 ulong window_xid = (ulong) Mutter.MetaWindow.get_xwindow (mutter_window.get_meta_window ());
221 if (window_xid != xid)
222 continue;
223-
224+
225 int type = mutter_window.get_window_type ();
226
227 if (type != Mutter.MetaWindowType.NORMAL &&
228 type != Mutter.MetaWindowType.DIALOG &&
229 type != Mutter.MetaWindowType.MODAL_DIALOG)
230 continue;
231-
232+
233 uint32 time_;
234 unowned Mutter.MetaWindow meta = mutter_window.get_meta_window ();
235
236@@ -590,23 +580,24 @@
237
238 public void show_unity ()
239 {
240- if (this.places_enabled == false)
241- {
242- show_window_picker ();
243- return;
244- }
245 if (this.places_showing)
246 {
247 this.places_showing = false;
248
249- this.places.hide ();
250- this.places.opacity = 0;
251- this.places.reactive = false;
252-
253- this.actor_blur.destroy ();
254- this.dark_box.destroy ();
255+ var anim = dark_box.animate (Clutter.AnimationMode.EASE_IN_QUAD, 100, "opacity", 0);
256+ anim.completed.connect ((an) => {
257+ (an.get_object () as Clutter.Actor).destroy ();
258+ });
259+
260+ plugin.get_normal_window_group ().animate (Clutter.AnimationMode.EASE_OUT_QUAD, 100, "opacity", 255);
261+
262+ anim = places.animate (Clutter.AnimationMode.EASE_OUT_QUAD, 100,
263+ "opacity", 0);
264+ anim.completed.connect ((an) => {
265+ (an.get_object () as Clutter.Actor).hide ();
266+ });
267+
268 this.panel.set_indicator_mode (false);
269-
270 this.ensure_input_region ();
271 }
272 else
273@@ -614,26 +605,17 @@
274 this.places_showing = true;
275
276 this.places.show ();
277- this.places.opacity = 255;
278- this.places.reactive = true;
279-
280- this.actor_blur = new ActorBlur (this.plugin.get_normal_window_group ());
281-
282- (this.plugin.get_window_group () as Clutter.Container).add_actor (this.actor_blur);
283- (this.actor_blur as Clutter.Actor).raise (this.plugin.get_normal_window_group ());
284-
285- this.actor_blur.set_position (0, 0);
286-
287+ this.places.opacity = 0;
288 this.dark_box = new Clutter.Rectangle.with_color ({0, 0, 0, 255});
289
290 (this.plugin.get_window_group () as Clutter.Container).add_actor (this.dark_box);
291- this.dark_box.raise (this.actor_blur);
292+ this.dark_box.raise (plugin.get_normal_window_group ());
293
294 this.dark_box.set_position (0, 0);
295 this.dark_box.set_size (this.stage.width, this.stage.height);
296
297 this.dark_box.show ();
298- this.actor_blur.show ();
299+
300 this.panel.set_indicator_mode (true);
301
302 this.ensure_input_region ();
303@@ -641,12 +623,19 @@
304 new X.Display (null).flush ();
305
306 this.dark_box.opacity = 0;
307- this.actor_blur.opacity = 255;
308
309- this.dark_box.animate (Clutter.AnimationMode.EASE_IN_SINE, 250, "opacity", 180);
310+ this.dark_box.animate (Clutter.AnimationMode.EASE_IN_QUAD, 100, "opacity", 180);
311+ plugin.get_normal_window_group ().animate (Clutter.AnimationMode.EASE_OUT_QUAD, 100, "opacity", 0);
312+ places.animate (Clutter.AnimationMode.EASE_OUT_QUAD, 100,
313+ "opacity", 255);
314 }
315 }
316
317+ public void about_to_show_places ()
318+ {
319+ places.about_to_show ();
320+ }
321+
322 public void grab_keyboard (bool grab, uint32 timestamp)
323 {
324 if (this.grab_enabled == grab)
325@@ -703,7 +692,7 @@
326 {
327 this.maximus.process_window (window);
328 this.window_mapped (this, window);
329-
330+
331 if (display == null)
332 {
333 display = Mutter.MetaWindow.get_display (window.get_meta_window ());
334
335=== modified file 'tests/ui/test-home-button.vala'
336--- tests/ui/test-home-button.vala 2010-06-03 13:14:06 +0000
337+++ tests/ui/test-home-button.vala 2010-06-24 07:45:42 +0000
338@@ -132,7 +132,7 @@
339 }
340
341 public void
342- show_window_picker ()
343+ about_to_show_places ()
344 {
345 // stub
346 }
347
348=== modified file 'tests/unit/Makefile.am'
349--- tests/unit/Makefile.am 2010-06-10 00:17:10 +0000
350+++ tests/unit/Makefile.am 2010-06-24 07:45:42 +0000
351@@ -39,6 +39,7 @@
352 --pkg indicator \
353 --pkg clutk-0.3 \
354 --pkg launcher-0.3 \
355+ --pkg posix \
356 --pkg test-const \
357 --pkg unique-1.0 \
358 --pkg unity \
359@@ -50,6 +51,8 @@
360 test-launcher.vala \
361 test-panel-indicator-object-entry-view.vala \
362 test-panel-indicator-object-view.vala \
363+ test-places-place-file-model.vala \
364+ test-places-place.vala \
365 test-places.vala \
366 test-place.vala \
367 test-unit.vala
368
369=== modified file 'tests/unit/data/Makefile.am'
370--- tests/unit/data/Makefile.am 2010-06-10 11:28:37 +0000
371+++ tests/unit/data/Makefile.am 2010-06-24 07:45:42 +0000
372@@ -1,1 +1,6 @@
373-EXTRA_DIST = test_desktop_file.desktop
374+EXTRA_DIST = \
375+ place0.badplace \
376+ place0.place \
377+ place1.badplace \
378+ place1.place \
379+ test_desktop_file.desktop
380
381=== added file 'tests/unit/data/place0.badplace'
382--- tests/unit/data/place0.badplace 1970-01-01 00:00:00 +0000
383+++ tests/unit/data/place0.badplace 2010-06-24 07:45:42 +0000
384@@ -0,0 +1,3 @@
385+[PlaceGroup]
386+DBusName=org.ayatana.Unity.Place0
387+DBusObjectPath=/org/ayatana/Unity/Place0
388
389=== added file 'tests/unit/data/place0.place'
390--- tests/unit/data/place0.place 1970-01-01 00:00:00 +0000
391+++ tests/unit/data/place0.place 2010-06-24 07:45:42 +0000
392@@ -0,0 +1,3 @@
393+[Place]
394+DBusName=org.ayatana.Unity.Place0
395+DBusObjectPath=/org/ayatana/Unity/Place0
396
397=== added file 'tests/unit/data/place1.badplace'
398--- tests/unit/data/place1.badplace 1970-01-01 00:00:00 +0000
399+++ tests/unit/data/place1.badplace 2010-06-24 07:45:42 +0000
400@@ -0,0 +1,19 @@
401+[Place]
402+DBusName=org.ayatana.Unity.Place1
403+DBusObjectPath=/org/ayatana/Unity/Place1
404+
405+[Entry:One]
406+DBusObjectPath=org/ayatana/Unity/Place1/Entry1
407+Icon=gtk-apply
408+Name=One
409+Description=One Description
410+ShowGlobal=true
411+ShowEntry=false
412+
413+[Entry:Two]
414+DBusObjectPath=
415+Icon=gtk-close
416+Name=Two
417+Description=Two Description
418+ShowGlobal=false
419+ShowEntry=true
420
421=== added file 'tests/unit/data/place1.place'
422--- tests/unit/data/place1.place 1970-01-01 00:00:00 +0000
423+++ tests/unit/data/place1.place 2010-06-24 07:45:42 +0000
424@@ -0,0 +1,27 @@
425+[Place]
426+DBusName=org.ayatana.Unity.Place1
427+DBusObjectPath=/org/ayatana/Unity/Place1
428+
429+[Entry:One]
430+DBusObjectPath=/org/ayatana/Unity/Place1/Entry1
431+Icon=gtk-apply
432+Name=One
433+Description=One Description
434+ShowGlobal=true
435+ShowEntry=false
436+
437+[Entry:Two]
438+DBusObjectPath=/org/ayatana/Unity/Place1/Entry2
439+Icon=gtk-close
440+Name=Two
441+Description=Two Description
442+ShowGlobal=false
443+ShowEntry=true
444+
445+[Entry:Three]
446+DBusObjectPath=/org/ayatana/Unity/Place1/Entry3
447+Icon=gtk-cancel
448+Name=Three
449+Description=Three Description
450+ShowGlobal=false
451+ShowEntry=false
452
453=== added file 'tests/unit/test-places-place-file-model.vala'
454--- tests/unit/test-places-place-file-model.vala 1970-01-01 00:00:00 +0000
455+++ tests/unit/test-places-place-file-model.vala 2010-06-24 07:45:42 +0000
456@@ -0,0 +1,43 @@
457+/*
458+ * Copyright (C) 2010 Canonical Ltd
459+ *
460+ * This program is free software: you can redistribute it and/or modify
461+ * it under the terms of the GNU General Public License version 3 as
462+ * published by the Free Software Foundation.
463+ *
464+ * This program is distributed in the hope that it will be useful,
465+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
466+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
467+ * GNU General Public License for more details.
468+ *
469+ * You should have received a copy of the GNU General Public License
470+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
471+ *
472+ * Authored by Neil Jagdish Patel <neil.patel@canonical.com>
473+ *
474+ */
475+using Unity;
476+using Unity.Testing;
477+using Unity.Places;
478+
479+namespace Unity.Tests.Unit
480+{
481+ public class PlacesPlaceFileModelSuite : Object
482+ {
483+ public const string DOMAIN = "/Unit/Places/PlaceFileModel";
484+
485+ public PlacesPlaceFileModelSuite ()
486+ {
487+ Logging.init_fatal_handler ();
488+
489+ Test.add_data_func (DOMAIN + "/Allocation", test_allocation);
490+ }
491+
492+ private void test_allocation ()
493+ {
494+ var model = new PlaceFileModel.with_directory (TESTDIR+"/data");
495+ assert (model is PlaceFileModel);
496+ assert (model.size == 2);
497+ }
498+ }
499+}
500
501=== added file 'tests/unit/test-places-place.vala'
502--- tests/unit/test-places-place.vala 1970-01-01 00:00:00 +0000
503+++ tests/unit/test-places-place.vala 2010-06-24 07:45:42 +0000
504@@ -0,0 +1,161 @@
505+/*
506+ * Copyright (C) 2010 Canonical Ltd
507+ *
508+ * This program is free software: you can redistribute it and/or modify
509+ * it under the terms of the GNU General Public License version 3 as
510+ * published by the Free Software Foundation.
511+ *
512+ * This program is distributed in the hope that it will be useful,
513+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
514+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
515+ * GNU General Public License for more details.
516+ *
517+ * You should have received a copy of the GNU General Public License
518+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
519+ *
520+ * Authored by Neil Jagdish Patel <neil.patel@canonical.com>
521+ *
522+ */
523+using Unity;
524+using Unity.Testing;
525+using Unity.Places;
526+using GLib.Test;
527+
528+namespace Unity.Tests.Unit
529+{
530+ public class PlacesPlaceSuite : Object
531+ {
532+ public const string DOMAIN = "/Unit/Places/Place";
533+
534+ public PlacesPlaceSuite ()
535+ {
536+ Logging.init_fatal_handler ();
537+
538+ Test.add_data_func (DOMAIN + "/Allocation", test_allocation);
539+ Test.add_data_func (DOMAIN + "/SimplePlaceFile", test_simple_placefile);
540+ Test.add_data_func (DOMAIN + "/AdvancedPlaceFile", test_advanced_place_file);
541+ Test.add_data_func (DOMAIN + "/BadSimplePlaceFile", test_bad_simple_place_file);
542+ Test.add_data_func (DOMAIN + "/BadAdvancedPlaceFile", test_bad_advanced_place_file);
543+ }
544+
545+ private void test_allocation ()
546+ {
547+ var place = new Places.Place ("__name__", "__path__");
548+ assert (place is Places.Place);
549+ assert (place.dbus_name == "__name__");
550+ assert (place.dbus_path == "__path__");
551+ }
552+
553+ private void test_simple_placefile ()
554+ {
555+ var file = new KeyFile ();
556+ try {
557+ file.load_from_file (TESTDIR + "/data/place0.place",
558+ KeyFileFlags.NONE);
559+ } catch (Error e) {
560+ error ("Unable to load test place: %s", e.message);
561+ }
562+
563+ var place = Places.Place.new_from_keyfile (file);
564+ assert (place is Places.Place);
565+
566+ /* Test Place group was loaded properly */
567+ assert (place.dbus_name == "org.ayatana.Unity.Place0");
568+ assert (place.dbus_path == "/org/ayatana/Unity/Place0");
569+
570+ /* Test entries were loaded properly */
571+ assert (place.n_entries == 0);
572+ }
573+
574+ private void test_advanced_place_file ()
575+ {
576+ var file = new KeyFile ();
577+ try {
578+ file.load_from_file (TESTDIR + "/data/place1.place",
579+ KeyFileFlags.NONE);
580+ } catch (Error error) {
581+ warning ("Unable to load test place: %s", error.message);
582+ }
583+
584+ var place = Places.Place.new_from_keyfile (file);
585+ assert (place is Places.Place);
586+
587+ /* Test Place group was loaded properly */
588+ assert (place.dbus_name == "org.ayatana.Unity.Place1");
589+ assert (place.dbus_path == "/org/ayatana/Unity/Place1");
590+
591+ /* Test entries were loaded properly */
592+ assert (place.n_entries == 3);
593+
594+ /* Test individual entry's properties were loaded correctly */
595+ PlaceEntry? e;
596+
597+ e = place.get_nth_entry (0);
598+ assert (e is PlaceEntry);
599+ assert (e.dbus_path == "/org/ayatana/Unity/Place1/Entry1");
600+ assert (e.name == "One");
601+ assert (e.icon == "gtk-apply");
602+ assert (e.description == "One Description");
603+ assert (e.show_global == true);
604+ assert (e.show_entry == false);
605+
606+ e = place.get_nth_entry (1);
607+ assert (e is PlaceEntry);
608+ assert (e.dbus_path == "/org/ayatana/Unity/Place1/Entry2");
609+ assert (e.name == "Two");
610+ assert (e.icon == "gtk-close");
611+ assert (e.description == "Two Description");
612+ assert (e.show_global == false);
613+ assert (e.show_entry == true);
614+
615+ e = place.get_nth_entry (2);
616+ assert (e is PlaceEntry);
617+ assert (e.dbus_path == "/org/ayatana/Unity/Place1/Entry3");
618+ assert (e.name == "Three");
619+ assert (e.icon == "gtk-cancel");
620+ assert (e.description == "Three Description");
621+ assert (e.show_global == false);
622+ assert (e.show_entry == false);
623+ }
624+
625+ private void test_bad_simple_place_file ()
626+ {
627+ var file = new KeyFile ();
628+ try {
629+ file.load_from_file (TESTDIR + "/data/place0.badplace",
630+ KeyFileFlags.NONE);
631+ } catch (Error error) {
632+ warning ("Unable to load test place: %s", error.message);
633+ }
634+
635+ if (trap_fork (0, TestTrapFlags.SILENCE_STDOUT | TestTrapFlags.SILENCE_STDERR))
636+ {
637+ var place = Places.Place.new_from_keyfile (file);
638+ assert (place is Places.Place);
639+ Posix.exit (0);
640+ }
641+ trap_has_passed ();
642+ trap_assert_stderr ("*Does not contain 'Place' grou*");
643+ }
644+
645+ private void test_bad_advanced_place_file ()
646+ {
647+ var file = new KeyFile ();
648+ try {
649+ file.load_from_file (TESTDIR + "/data/place1.badplace",
650+ KeyFileFlags.NONE);
651+ } catch (Error error) {
652+ warning ("Unable to load test place: %s", error.message);
653+ }
654+
655+ if (trap_fork (0, TestTrapFlags.SILENCE_STDOUT | TestTrapFlags.SILENCE_STDERR))
656+ {
657+ var place = Places.Place.new_from_keyfile (file);
658+ assert (place is Places.Place);
659+ Posix.exit (0);
660+ }
661+ trap_has_passed ();
662+ trap_assert_stderr ("*Does not contain valid DBusObjectPat*");
663+ }
664+ }
665+}
666
667=== modified file 'tests/unit/test-unit.vala'
668--- tests/unit/test-unit.vala 2010-06-04 17:03:39 +0000
669+++ tests/unit/test-unit.vala 2010-06-24 07:45:42 +0000
670@@ -24,21 +24,30 @@
671 {
672 public static int main (string[] args)
673 {
674+ LauncherSuite launcher;
675+
676 PanelIndicatorObjectEntryViewSuite panel_object_entry_view_suite;
677 PanelIndicatorObjectViewSuite panel_object_view_suite;
678-
679+
680+ PlacesPlaceFileModelSuite place_file_model;
681+ PlacesPlaceSuite places_place;
682 PlacesSuite places;
683- LauncherSuite launcher;
684 PlaceSuite place;
685
686 Gtk.init (ref args);
687 Ctk.init (ref args);
688 Test.init (ref args);
689
690+ /* Launcher tests */
691+ launcher = new LauncherSuite ();
692+
693+ /* Panel tests */
694 panel_object_entry_view_suite = new PanelIndicatorObjectEntryViewSuite ();
695 panel_object_view_suite = new PanelIndicatorObjectViewSuite ();
696-
697- launcher = new LauncherSuite ();
698+ place_file_model = new PlacesPlaceFileModelSuite ();
699+ places_place = new PlacesPlaceSuite ();
700+
701+ /* Places tests */
702 places = new PlacesSuite ();
703 place = new PlaceSuite ();
704
705
706=== modified file 'unity-private/Makefile.am'
707--- unity-private/Makefile.am 2010-06-10 16:42:49 +0000
708+++ unity-private/Makefile.am 2010-06-24 07:45:42 +0000
709@@ -79,28 +79,25 @@
710 panel/panel-indicator-model.vala \
711 panel/panel-indicator-object-entry-view.vala \
712 panel/panel-indicator-object-view.vala \
713- panel/panel-indicators.vala \
714 panel/panel-menu-manager.vala \
715 panel/panel-menubar.vala \
716 panel/panel-tray.vala \
717 panel/panel-view.vala
718
719 places_sources = \
720- places/application-place.vala \
721- places/bar-model.vala \
722- places/bar-view.vala \
723- places/cairo-drawing.vala \
724- places/default-model.vala \
725- places/default-view.vala \
726- places/file-place.vala \
727 places/places-controller.vala \
728- places/places-model.vala \
729+ places/places-default-renderer-group.vala \
730+ places/places-default-renderer.vala \
731+ places/places-place-bar.vala \
732+ places/places-place-entry-view.vala \
733+ places/places-place-entry.vala \
734+ places/places-place-model.vala \
735+ places/places-place-view.vala \
736 places/places-place.vala \
737- places/places-place-proxy.vala \
738- places/places-place-view.vala \
739- places/places-results-view.vala \
740- places/places-view.vala \
741- places/search-field.vala
742+ places/places-place-search-bar.vala \
743+ places/places-place-search-entry.vala \
744+ places/places-place-search-sections-bar.vala \
745+ places/places-view.vala
746
747 launcher_sources = \
748 launcher/application-controller.vala \
749
750=== modified file 'unity-private/launcher/launcher-child.vala'
751--- unity-private/launcher/launcher-child.vala 2010-06-16 17:10:50 +0000
752+++ unity-private/launcher/launcher-child.vala 2010-06-24 07:45:42 +0000
753@@ -407,6 +407,10 @@
754 private void on_rotation_changed ()
755 {
756 old_rotate_value = processed_icon.rotation;
757+
758+ if (rotate_timeline is Clutter.Timeline == false)
759+ return;
760+
761 if (rotate_timeline.is_playing ())
762 {
763 rotate_timeline.stop ();
764@@ -488,7 +492,6 @@
765 out float minimum_height,
766 out float natural_height)
767 {
768- float nat, min;
769 natural_height = 48;
770 minimum_height = 48;
771 }
772
773=== modified file 'unity-private/launcher/scroller-controller.vala'
774--- unity-private/launcher/scroller-controller.vala 2010-06-03 10:17:02 +0000
775+++ unity-private/launcher/scroller-controller.vala 2010-06-24 07:45:42 +0000
776@@ -171,6 +171,7 @@
777 }
778 }
779
780+ /*
781 public void on_favorite_removed (string uid)
782 {
783 }
784@@ -195,7 +196,7 @@
785
786 return false;
787 }
788-
789+ */
790 private ApplicationController? find_controller_by_desktop_file (string desktop_file)
791 {
792 foreach (ScrollerChildController controller in childcontrollers)
793
794=== modified file 'unity-private/panel/panel-background.vala'
795--- unity-private/panel/panel-background.vala 2010-06-03 09:53:03 +0000
796+++ unity-private/panel/panel-background.vala 2010-06-24 07:45:42 +0000
797@@ -60,7 +60,7 @@
798 last_width = width;
799 last_height = height;
800
801- Idle.add (update_background);
802+ Timeout.add (0, update_background);
803 }
804 }
805
806
807=== modified file 'unity-private/panel/panel-home-button.vala'
808--- unity-private/panel/panel-home-button.vala 2010-06-21 09:14:43 +0000
809+++ unity-private/panel/panel-home-button.vala 2010-06-24 07:45:42 +0000
810@@ -42,9 +42,9 @@
811 float pheight;
812 Ctk.Padding pad = { 0 };
813
814- lwidth = (float) this.shell.get_launcher_width_foobar ();
815- pheight = (float) this.shell.get_panel_height_foobar ();
816- this.theme_image.get_preferred_size (out cwidth, out cheight,
817+ lwidth = (float) shell.get_launcher_width_foobar ();
818+ pheight = (float) shell.get_panel_height_foobar ();
819+ theme_image.get_preferred_size (out cwidth, out cheight,
820 out cwidth, out cheight);
821
822 /* adapt icon-width to launcher-width with padding */
823@@ -75,19 +75,20 @@
824 pad.bottom = pad.top;
825 }
826
827- this.padding = pad;
828+ padding = pad;
829
830 base.allocate (box, flags);
831 }
832
833 construct
834 {
835- this.theme_image = new ThemeImage ("distributor-logo");
836- this.add_actor (this.theme_image);
837- this.theme_image.show ();
838+ theme_image = new ThemeImage ("distributor-logo");
839+ add_actor (theme_image);
840+ theme_image.show ();
841
842- this.button_press_event.connect (this.on_button_press);
843- this.button_release_event.connect (this.on_button_release);
844+ button_press_event.connect (on_button_press);
845+ button_release_event.connect (on_button_release);
846+ motion_event.connect (on_motion_event);
847 }
848
849 /* We always want to be the width of the launcher */
850@@ -95,8 +96,8 @@
851 out float min_width,
852 out float nat_width)
853 {
854- min_width = this.shell.get_launcher_width_foobar ();
855- nat_width = this.shell.get_launcher_width_foobar ();
856+ min_width = shell.get_launcher_width_foobar ();
857+ nat_width = shell.get_launcher_width_foobar ();
858 }
859
860 private bool on_button_press (Clutter.Event event)
861@@ -111,6 +112,13 @@
862 manager.popdown_current_menu ();
863 return true;
864 }
865+
866+ private bool on_motion_event (Clutter.Event event)
867+ {
868+ shell.about_to_show_places ();
869+
870+ return true;
871+ }
872 }
873 }
874
875
876=== removed file 'unity-private/panel/panel-indicators.vala'
877--- unity-private/panel/panel-indicators.vala 2010-06-03 10:17:02 +0000
878+++ unity-private/panel/panel-indicators.vala 1970-01-01 00:00:00 +0000
879@@ -1,659 +0,0 @@
880-/* -*- Mode: vala; indent-tabs-mode: nil; c-basic-offset: 2; tab-width: 2 -*- */
881-/*
882- * Copyright (C) 2010 Canonical Ltd
883- *
884- * This program is free software: you can redistribute it and/or modify
885- * it under the terms of the GNU General Public License version 3 as
886- * published by the Free Software Foundation.
887- *
888- * This program is distributed in the hope that it will be useful,
889- * but WITHOUT ANY WARRANTY; without even the implied warranty of
890- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
891- * GNU General Public License for more details.
892- *
893- * You should have received a copy of the GNU General Public License
894- * along with this program. If not, see <http://www.gnu.org/licenses/>.
895- *
896- * Authored by Neil Jagdish Patel <neil.patel@canonical.com>
897- *
898- */
899-
900-using Gee;
901-using Utils;
902-
903-namespace Unity.Panel.Indicators
904-{
905- public class View : Ctk.Box
906- {
907- private HashMap<string, int> indicator_order;
908-
909- private Gtk.Menu? popped;
910- private uint32 click_time;
911- private float last_found_entry_x = 0.0f;
912-
913- public View ()
914- {
915- Object (orientation:Ctk.Orientation.HORIZONTAL,
916- spacing:0,
917- homogeneous:false,
918- reactive:true);
919-
920- Unity.Testing.ObjectRegistry.get_default ().register ("PanelIndicators",
921- this);
922- }
923-
924- construct
925- {
926- this.indicator_order = new HashMap<string, int> ();
927-
928- this.button_press_event.connect (this.on_button_press_event);
929- this.button_release_event.connect (this.on_button_release_event);
930- this.motion_event.connect (this.on_motion_event);
931- this.scroll_event.connect (on_scroll_event);
932-
933- if (Environment.get_variable ("UNITY_DISABLE_IDLES") != null)
934- this.load_indicators ();
935- else
936- Idle.add (this.load_indicators);
937- }
938-
939- private bool load_indicators ()
940- {
941- string skip_list;
942-
943- /* Create the order */
944- this.indicator_order.set ("libapplication.so", 1);
945- this.indicator_order.set ("libsoundmenu.so", 2);
946- this.indicator_order.set ("libmessaging.so", 3);
947- this.indicator_order.set ("libdatetime.so", 4);
948- this.indicator_order.set ("libme.so", 5);
949- this.indicator_order.set ("libsession.so", 6);
950-
951- /* The ones we don't want to load */
952- skip_list = Environment.get_variable ("UNITY_PANEL_INDICATORS_SKIP");
953- if (skip_list == null)
954- skip_list = "";
955-
956- if (skip_list == "all")
957- return false;
958-
959- /* We need to look for icons in an specific location */
960- Gtk.IconTheme.get_default ().append_search_path (INDICATORICONSDIR);
961-
962- /* Start loading 'em in */
963- var dir = File.new_for_path (INDICATORDIR);
964- try
965- {
966- var e = dir.enumerate_children (FILE_ATTRIBUTE_STANDARD_NAME,
967- 0,
968- null);
969-
970- FileInfo file_info;
971- while ((file_info = e.next_file (null)) != null)
972- {
973- string leaf = file_info.get_name ();
974-
975- if (leaf in skip_list || skip_list == "all")
976- continue;
977-
978- if (leaf[leaf.len()-2:leaf.len()] == "so")
979- this.load_indicator (INDICATORDIR + file_info.get_name (),
980- file_info.get_name ());
981- }
982- }
983- catch (Error error)
984- {
985- print ("Unable to read indicators: %s\n", error.message); }
986-
987- this.sort_children ((CompareFunc)reorder_icons);
988-
989- return false;
990- }
991-
992- public static int reorder_icons (IndicatorItem a, IndicatorItem b)
993- {
994- return a.position - b.position;
995- }
996-
997- private void load_indicator (string filename, string leaf)
998- {
999- Indicator.Object o;
1000-
1001- o = new Indicator.Object.from_file (filename);
1002-
1003- if (o is Indicator.Object)
1004- {
1005- var i = new IndicatorItem ();
1006- i.set_object (o);
1007- this.add_actor (i);
1008- i.show ();
1009-
1010- i.menu_moved.connect (this.on_menu_moved);
1011-
1012- i.position = (int)this.indicator_order[leaf];
1013- }
1014- else
1015- {
1016- warning ("Unable to load %s\n", filename);
1017- }
1018- }
1019-
1020- private void position_menu (Gtk.Menu menu,
1021- out int x,
1022- out int y,
1023- out bool push_in)
1024- {
1025- y = (int)this.height;
1026- x = (int)this.last_found_entry_x;
1027- }
1028-
1029- private unowned IndicatorEntry? entry_for_event (float root_x)
1030- {
1031- unowned IndicatorItem? item = null;
1032- unowned IndicatorEntry? entry = null;
1033- float x = root_x - this.x;
1034-
1035- /* Find which entry has the button press, pop it up */
1036- unowned GLib.List<IndicatorItem> list = this.get_children ();
1037- for (int i = 0; i < list.length (); i++)
1038- {
1039- unowned IndicatorItem it = (IndicatorItem)list.nth_data (i);
1040-
1041- if (it.x < x && x < (it.x + it.width))
1042- {
1043- item = it;
1044- break;
1045- }
1046- }
1047-
1048- if (item == null)
1049- return null;
1050-
1051- x -= item.x;
1052- list = item.get_children ();
1053- for (int i = 0; i < list.length (); i++)
1054- {
1055- unowned IndicatorEntry ent = (IndicatorEntry)list.nth_data (i);
1056-
1057- if (ent.x < x && x < (ent.x + ent.width))
1058- {
1059- this.last_found_entry_x = ent.x + item.x + this.x;
1060- entry = ent;
1061- }
1062- }
1063-
1064- return entry;
1065- }
1066-
1067- public void show_entry (IndicatorEntry entry)
1068- {
1069- if (this.popped is Gtk.Menu
1070- && (this.popped.get_flags () & Gtk.WidgetFlags.VISIBLE) !=0)
1071- {
1072- this.popped.popdown ();
1073- this.popped = null;
1074- }
1075-
1076- this.last_found_entry_x = entry.x + entry.get_parent ().x + this.x;
1077-
1078- entry.menu.popup (null,
1079- null,
1080- this.position_menu,
1081- 1,
1082- Clutter.get_current_event_time ());
1083- click_time = Clutter.get_current_event_time ();
1084- this.popped = entry.menu;
1085- entry.menu_shown ();
1086- }
1087-
1088- private bool on_button_press_event (Clutter.Event e)
1089- {
1090- if (this.popped is Gtk.Menu
1091- && (this.popped.get_flags () & Gtk.WidgetFlags.VISIBLE) !=0)
1092- {
1093- this.popped.popdown ();
1094- this.popped = null;
1095- }
1096-
1097- unowned IndicatorEntry? entry = this.entry_for_event (e.button.x);
1098- if (entry is IndicatorEntry)
1099- {
1100- entry.menu.popup (null,
1101- null,
1102- this.position_menu,
1103- e.button.button,
1104- e.button.time);
1105- click_time = e.button.time;
1106- this.popped = entry.menu;
1107- entry.menu_shown ();
1108- }
1109- return true;
1110- }
1111-
1112- private bool on_button_release_event (Clutter.Event e)
1113- {
1114- if (e.button.time - click_time < 300)
1115- return true;
1116-
1117- if (this.popped is Gtk.Menu
1118- && (this.popped.get_flags () & Gtk.WidgetFlags.VISIBLE) !=0)
1119- {
1120- this.popped.popdown ();
1121- this.popped = null;
1122- }
1123-
1124- return true;
1125- }
1126-
1127- private bool on_motion_event (Clutter.Event e)
1128- {
1129- if (this.popped is Gtk.Menu
1130- && (this.popped.get_flags () & Gtk.WidgetFlags.VISIBLE) !=0)
1131- {
1132- unowned IndicatorEntry? entry;
1133-
1134- entry = entry_for_event (e.motion.x);
1135-
1136- if (entry == null)
1137- return true;
1138-
1139- if (entry.menu != this.popped)
1140- {
1141- this.popped.popdown ();
1142- this.popped = entry.menu;
1143- this.popped.popup (null,
1144- null,
1145- this.position_menu,
1146- e.button.button,
1147- e.button.time);
1148- entry.menu_shown ();
1149- }
1150- }
1151-
1152- return true;
1153- }
1154-
1155- private bool on_scroll_event (Clutter.Event e)
1156- {
1157- Clutter.ScrollEvent event = e.scroll;
1158-
1159- unowned IndicatorEntry? entry = this.entry_for_event (e.scroll.x);
1160- if (entry is IndicatorEntry)
1161- {
1162- unowned Indicator.Object object = entry.get_data<Indicator.Object> ("Indicator.Object");
1163-
1164- Signal.emit_by_name (object, "scroll", 1, event.direction);
1165- }
1166- return true;
1167- }
1168-
1169- private void on_menu_moved (IndicatorItem item,
1170- Gtk.MenuDirectionType type)
1171- {
1172- unowned GLib.List<IndicatorItem> list = this.get_children ();
1173-
1174- int pos = list.index (item);
1175-
1176- if (pos == -1)
1177- return;
1178-
1179- /* For us, PARENT = previous menu, CHILD = next menu */
1180- if (type == Gtk.MenuDirectionType.PARENT)
1181- {
1182- if (pos == 0)
1183- return;
1184- pos -= 1;
1185- }
1186- else if (type == Gtk.MenuDirectionType.CHILD)
1187- {
1188- if (pos == list.length ()-1)
1189- return;
1190- pos +=1;
1191- }
1192-
1193- /* Get the prev/next item */
1194- IndicatorItem new_item = list.nth_data (pos) as IndicatorItem;
1195-
1196- /* Find the right entry to activate */
1197- unowned GLib.List<IndicatorEntry> l = new_item.get_children ();
1198- int p = type == Gtk.MenuDirectionType.PARENT ? (int)l.length ()-1 : 0;
1199- IndicatorEntry? new_entry = l.nth_data (p) as IndicatorEntry;
1200-
1201- if (new_entry is IndicatorEntry)
1202- this.show_entry (new_entry);
1203- }
1204- }
1205-
1206- public class IndicatorItem : Ctk.Box
1207- {
1208- /**
1209- * Represents one Indicator.Object
1210- **/
1211- private Indicator.Object object;
1212- public int position;
1213-
1214- public signal void menu_moved (Gtk.MenuDirectionType type);
1215-
1216- public IndicatorItem ()
1217- {
1218- Object (orientation:Ctk.Orientation.HORIZONTAL,
1219- spacing:0,
1220- homogeneous:false);
1221- }
1222-
1223- construct
1224- {
1225- }
1226-
1227- private void remove_entry (Indicator.ObjectEntry entry)
1228- {
1229- unowned GLib.List<IndicatorEntry> list = this.get_children ();
1230-
1231- for (int i = 0; i < list.length (); i++)
1232- {
1233- IndicatorEntry e;
1234-
1235- e = (IndicatorEntry) list.nth_data (i);
1236-
1237- if (e.entry == entry)
1238- {
1239- this.remove_actor (e);
1240- }
1241- }
1242- }
1243-
1244- private void create_entry (Indicator.ObjectEntry entry,
1245- Indicator.Object object)
1246- {
1247- IndicatorEntry e = new IndicatorEntry (entry);
1248- e.set_data ("Indicator.Object", object);
1249- this.add_actor (e);
1250- this.show ();
1251-
1252- e.menu_moved.connect (this.on_menu_moved);
1253- }
1254-
1255- private void on_menu_moved (IndicatorEntry entry,
1256- Gtk.MenuDirectionType type)
1257- {
1258- unowned GLib.List<IndicatorEntry> list = this.get_children ();
1259-
1260- int pos = list.index (entry);
1261-
1262- if (pos == -1)
1263- {
1264- this.menu_moved (type);
1265- return;
1266- }
1267-
1268- /* For us, PARENT = previous menu, CHILD = next menu */
1269- if (type == Gtk.MenuDirectionType.PARENT)
1270- {
1271- if (pos == 0)
1272- {
1273- this.menu_moved (type);
1274- return;
1275- }
1276- pos -= 1;
1277- }
1278- else if (type == Gtk.MenuDirectionType.CHILD)
1279- {
1280- if (pos == list.length ()-1)
1281- {
1282- this.menu_moved (type);
1283- return;
1284- }
1285- pos +=1;
1286- }
1287-
1288- IndicatorEntry new_entry = list.nth_data (pos) as IndicatorEntry;
1289-
1290- Indicators.View parent = this.get_parent () as Indicators.View;
1291- parent.show_entry (new_entry);
1292- }
1293-
1294- private void on_entry_added (Indicator.Object object,
1295- Indicator.ObjectEntry entry)
1296- {
1297- create_entry (entry, object);
1298- }
1299-
1300- public void set_object (Indicator.Object object)
1301- {
1302- this.object = object;
1303-
1304- object.entry_added.connect (this.on_entry_added);
1305- object.entry_removed.connect (this.remove_entry);
1306-
1307- unowned GLib.List<Indicator.ObjectEntry> list = object.get_entries ();
1308-
1309- for (int i = 0; i < list.length (); i++)
1310- {
1311- unowned Indicator.ObjectEntry entry;
1312-
1313- entry = (Indicator.ObjectEntry) list.nth_data (i);
1314-
1315- this.create_entry (entry, object);
1316- }
1317- }
1318-
1319- public Indicator.Object get_object ()
1320- {
1321- return this.object;
1322- }
1323- }
1324-
1325- public class IndicatorEntry : Ctk.Box
1326- {
1327- public unowned Indicator.ObjectEntry entry { get; construct; }
1328-
1329- private Clutter.CairoTexture bg;
1330-
1331- private Ctk.Image image;
1332- private Ctk.Text text;
1333-
1334- public Gtk.Menu menu { get { return this.entry.menu; } }
1335-
1336- public signal void menu_moved (Gtk.MenuDirectionType type);
1337-
1338- public IndicatorEntry (Indicator.ObjectEntry entry)
1339- {
1340- Object (entry:entry,
1341- orientation:Ctk.Orientation.HORIZONTAL,
1342- spacing:4,
1343- reactive:false);
1344- }
1345-
1346- construct
1347- {
1348- this.padding = { 0, 3.0f, 0, 3.0f };
1349-
1350- this.bg = new Clutter.CairoTexture (10, 10);
1351- this.bg.set_parent (this);
1352- this.bg.opacity = 0;
1353- this.bg.show ();
1354-
1355- if (this.entry.image is Gtk.Image)
1356- {
1357- this.image = new Ctk.Image (22);
1358- this.add_actor (this.image);
1359- this.image.show ();
1360-
1361- if (this.entry.image.icon_name != null)
1362- {
1363-
1364- this.image.stock_id = this.entry.image.icon_name;
1365-
1366- this.entry.image.notify["icon-name"].connect (() =>
1367- {
1368- this.image.stock_id = this.entry.image.icon_name;
1369- });
1370-
1371- unowned Gtk.IconTheme theme = Gtk.IconTheme.get_default ();
1372- theme.changed.connect (() =>
1373- {
1374- this.image.stock_id = this.entry.image.icon_name;
1375- });
1376- }
1377-
1378- if (this.entry.image.pixbuf != null)
1379- {
1380- this.image.pixbuf = this.entry.image.pixbuf;
1381- this.image.size = this.entry.image.pixbuf.width;
1382-
1383- this.entry.image.notify["pixbuf"].connect (() =>
1384- {
1385- this.image.pixbuf = this.entry.image.pixbuf;
1386- this.image.size = this.entry.image.pixbuf.width;
1387- });
1388- }
1389- }
1390-
1391- if (this.entry.label is Gtk.Label)
1392- {
1393- this.text = new Ctk.Text ("");
1394- this.text.color = { 233, 216, 200, 255 };
1395- this.add_actor (this.text);
1396- this.text.show ();
1397-
1398- this.text.text = this.entry.label.label;
1399-
1400- this.entry.label.notify["label"].connect (() =>
1401- {
1402- this.text.text = this.entry.label.label;
1403- });
1404- }
1405- }
1406-
1407- public void menu_shown ()
1408- {
1409- if (this.entry.menu is Gtk.Menu)
1410- {
1411- this.entry.menu.move_current.connect (this.menu_key_moved);
1412- this.entry.menu.notify["visible"].connect (this.menu_vis_changed);
1413- this.bg.animate (Clutter.AnimationMode.EASE_OUT_QUAD, 200,
1414- "opacity", 255);
1415-
1416- Clutter.Color col = { 255, 249, 233, 255 };
1417- this.text.animate (Clutter.AnimationMode.EASE_OUT_QUAD, 200,
1418- "color", ref col);
1419- }
1420- }
1421-
1422- public void menu_vis_changed ()
1423- {
1424- bool vis = (this.entry.menu.get_flags () & Gtk.WidgetFlags.VISIBLE) != 0;
1425-
1426- if (vis == false)
1427- {
1428- this.bg.animate (Clutter.AnimationMode.EASE_OUT_QUAD, 200,
1429- "opacity", 0);
1430-
1431- Clutter.Color col = { 233, 216, 200, 255 };
1432- this.text.animate (Clutter.AnimationMode.EASE_OUT_QUAD, 200,
1433- "color", ref col);
1434- this.entry.menu.move_current.disconnect (this.menu_key_moved);
1435- this.entry.menu.notify["visible"].disconnect (this.menu_vis_changed);
1436- }
1437- }
1438-
1439- public void menu_key_moved (Gtk.MenuDirectionType type)
1440- {
1441- if (type != Gtk.MenuDirectionType.PARENT &&
1442- type != Gtk.MenuDirectionType.CHILD)
1443- return;
1444-
1445- this.menu_moved (type);
1446- }
1447-
1448- private void update_bg (int width, int height)
1449- {
1450- Cairo.Context cr;
1451-
1452- this.bg.set_surface_size (width, height);
1453-
1454- cr = this.bg.create ();
1455-
1456- cr.set_operator (Cairo.Operator.CLEAR);
1457- cr.paint ();
1458-
1459- cr.set_operator (Cairo.Operator.OVER);
1460-
1461- cr.set_line_width (1.0);
1462-
1463- cr.set_source_rgba (1.0, 1.0, 1.0, 0.2);
1464-
1465- cr.move_to (1, height);
1466-
1467- cr.line_to (1, 7);
1468-
1469- cr.curve_to (1, 2,
1470- 1, 2,
1471- 10, 2);
1472-
1473- cr.line_to (width-10, 2);
1474-
1475- cr.curve_to (width, 2,
1476- width, 2,
1477- width, 7);
1478-
1479- cr.line_to (width, height);
1480-
1481- cr.line_to (1, height);
1482-
1483- var pat = new Cairo.Pattern.linear (1, 0, 1, height);
1484- pat.add_color_stop_rgba (0.0, 0.8509f, 0.8196f, 0.7294f, 1.0f);
1485- pat.add_color_stop_rgba (1.0, 0.7019f, 0.6509f, 0.5137f, 1.0f);
1486-
1487- cr.set_source (pat);
1488- cr.fill ();
1489- }
1490-
1491- /*
1492- * CLUTTER OVERRIDES
1493- */
1494- private override void allocate (Clutter.ActorBox box,
1495- Clutter.AllocationFlags flags)
1496- {
1497- float width;
1498- float height;
1499-
1500- base.allocate (box, flags);
1501-
1502- width = Math.floorf (box.x2 - box.x1);
1503- height = Math.floorf (box.y2 - box.y1) - 1;
1504-
1505- Clutter.ActorBox child_box = { 0 };
1506- child_box.x1 = 0;
1507- child_box.x2 = width;
1508- child_box.y1 = 0;
1509- child_box.y2 = height;
1510-
1511- if (width != this.bg.width ||
1512- height != this.bg.height)
1513- {
1514- this.update_bg ((int)width, (int)height);
1515- }
1516-
1517- this.bg.allocate (child_box, flags);
1518- }
1519-
1520- private override void paint ()
1521- {
1522- this.bg.paint ();
1523- base.paint ();
1524- }
1525-
1526- private override void map ()
1527- {
1528- base.map ();
1529- this.bg.map ();
1530- }
1531-
1532- private override void unmap ()
1533- {
1534- base.unmap ();
1535- this.bg.unmap ();
1536- }
1537- }
1538-}
1539
1540=== modified file 'unity-private/panel/panel-menubar.vala'
1541--- unity-private/panel/panel-menubar.vala 2010-06-02 13:48:28 +0000
1542+++ unity-private/panel/panel-menubar.vala 2010-06-24 07:45:42 +0000
1543@@ -22,6 +22,8 @@
1544 {
1545 public class MenuBar : Ctk.Box
1546 {
1547+ public IndicatorObjectView indicator_object_view;
1548+
1549 public MenuBar ()
1550 {
1551 Object (spacing:0,
1552@@ -40,7 +42,7 @@
1553
1554 if (name == "libappmenu.so")
1555 {
1556- IndicatorObjectView indicator_object_view = new IndicatorObjectView (o);
1557+ indicator_object_view = new IndicatorObjectView (o);
1558 indicator_object_view.menu_moved.connect (this.on_menu_moved);
1559
1560 pack (indicator_object_view, false, true);
1561
1562=== modified file 'unity-private/panel/panel-view.vala'
1563--- unity-private/panel/panel-view.vala 2010-06-18 15:42:52 +0000
1564+++ unity-private/panel/panel-view.vala 2010-06-24 07:45:42 +0000
1565@@ -56,7 +56,7 @@
1566 bground = new Background ();
1567 set_background (bground);
1568 bground.show ();
1569-
1570+
1571 /* Create the views and add them to the box */
1572 home_button = new HomeButton (shell);
1573 pack (home_button, false, true);
1574@@ -74,7 +74,7 @@
1575 pack (indicator_bar, false, true);
1576 indicator_bar.show ();
1577
1578- this.button_release_event.connect (this.on_button_release_event);
1579+ button_release_event.connect (on_button_release_event);
1580
1581 END_FUNCTION ();
1582 }
1583@@ -89,50 +89,17 @@
1584
1585 public int get_indicators_width ()
1586 {
1587- return (int) this.indicator_bar.get_width ();
1588- //this.system_tray.width + this.indicator_bar.width;
1589+ return (int) indicator_bar.get_width ();
1590+ //system_tray.width + indicator_bar.width;
1591 }
1592
1593 public void set_expanded (bool _expanded)
1594 {
1595 // Hide menubar
1596 // Put background into expanded mode
1597- this.expanded = _expanded;
1598+ expanded = _expanded;
1599 }
1600
1601-// private override void allocate (Clutter.ActorBox box,
1602-// Clutter.AllocationFlags flags)
1603-// {
1604-// Clutter.ActorBox child_box = { 0, 0, box.x2 - box.x1, box.y2 - box.y1 };
1605-// float width;
1606-// float child_width;
1607-//
1608-// base.allocate (box, flags);
1609-//
1610-// width = box.x2 - box.x1;
1611-//
1612-// this.rect.set_clip (0, 0, width, box.y2 - box.y1);
1613-//
1614-// First the background
1615-// child_box.y2 += 3.0f;
1616-// this.rect.allocate (child_box, flags);
1617-// //
1618-// // Home button
1619-// // child_box.x1 = 0;
1620-// // child_box.x2 = 60;
1621-// // child_box.y1 = 0;
1622-// // child_box.y2 = PANEL_HEIGHT;
1623-// // this.home.allocate (child_box, flags);
1624-//
1625-// this.indicator_bar.get_preferred_width (PANEL_HEIGHT,
1626-// out child_width,
1627-// out child_width);
1628-// child_box.x1 = width - child_width;
1629-// child_box.x2 = width;
1630-// this.indicator_bar.allocate (child_box, flags);
1631-// }
1632-
1633-
1634 public int get_panel_height ()
1635 {
1636 return Unity.Panel.PANEL_HEIGHT;
1637@@ -140,20 +107,24 @@
1638
1639 public void set_indicator_mode (bool mode)
1640 {
1641- if (mode)
1642- {
1643- menu_bar.hide ();
1644+ if (mode)
1645+ {
1646+ if (menu_bar.indicator_object_view is Clutter.Actor)
1647+ menu_bar.indicator_object_view.hide ();
1648 bground.hide ();
1649 system_tray.hide ();
1650 indicator_bar.set_indicator_mode (mode);
1651- }
1652- else
1653+ reactive = false;
1654+ }
1655+ else
1656 {
1657- menu_bar.show ();
1658+ if (menu_bar.indicator_object_view is Clutter.Actor)
1659+ menu_bar.indicator_object_view.show ();
1660 bground.show ();
1661 system_tray.show ();
1662 indicator_bar.set_indicator_mode (mode);
1663- }
1664+ reactive = true;
1665+ }
1666 }
1667 }
1668 }
1669
1670=== removed file 'unity-private/places/application-place.vala'
1671--- unity-private/places/application-place.vala 2010-05-31 17:58:13 +0000
1672+++ unity-private/places/application-place.vala 1970-01-01 00:00:00 +0000
1673@@ -1,297 +0,0 @@
1674-/*
1675- * Copyright (C) 2010 Canonical Ltd
1676- *
1677- * This program is free software: you can redistribute it and/or modify
1678- * it under the terms of the GNU General Public License version 3 as
1679- * published by the Free Software Foundation.
1680- *
1681- * This program is distributed in the hope that it will be useful,
1682- * but WITHOUT ANY WARRANTY; without even the implied warranty of
1683- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1684- * GNU General Public License for more details.
1685- *
1686- * You should have received a copy of the GNU General Public License
1687- * along with this program. If not, see <http://www.gnu.org/licenses/>.
1688- *
1689- * Authored by Jay Taoko <jay.taoko@canonical.com>
1690- *
1691- */
1692-
1693-namespace Unity.Places.Application
1694-{
1695-
1696- const string APP_ICON = Unity.PKGDATADIR + "/applications.png";
1697- const string FAVOURITES_ICON = Unity.PKGDATADIR + "/favourites.png";
1698- const string MINIMIZE_ICON = Unity.PKGDATADIR + "/minimize_up.png";
1699- const string MAXIMIZE_ICON = Unity.PKGDATADIR + "/maximize_up.png";
1700-
1701- public class ApplicationIcon
1702- {
1703- private Unity.Places.Bar.Model model;
1704- public Ctk.Image view;
1705- public Ctk.Text label;
1706-
1707- public ApplicationIcon (int width, /*int height,*/ string name, string icon_name, string tooltip)
1708- {
1709- model = new Unity.Places.Bar.Model (name, icon_name, tooltip);
1710-
1711- if (icon_name[0] == '/')
1712- view = new Ctk.Image.from_filename (width, icon_name);
1713- else if (icon_name[-4] == '.')
1714- view = new Ctk.Image.from_filename (width,
1715- "/usr/share/pixmaps/" + icon_name);
1716- else if (icon_name[0] == '.')
1717- {
1718- GLib.Icon icon;
1719-
1720- try
1721- {
1722- icon = GLib.Icon.new_for_string(icon_name);
1723- Gtk.IconInfo info = Gtk.IconTheme.get_default().lookup_by_gicon (icon, 48, 0);
1724- if (info != null)
1725- view = new Ctk.Image.from_filename (width, info.get_filename());
1726- else
1727- view = new Ctk.Image.from_stock (width, icon_name);
1728- if (view == null)
1729- warning (@"Failed to load icon for $icon_name");
1730- }
1731- catch (GLib.Error error)
1732- {
1733- warning (@"Failed to load icon: %s", error.message);
1734- }
1735- }
1736- else
1737- view = new Ctk.Image.from_stock (width, icon_name);
1738-
1739- view.set_reactive (true);
1740- label = new Ctk.Text (name);
1741- label.set_line_wrap (true);
1742- label.set_line_alignment (Pango.Alignment.CENTER);
1743- }
1744- }
1745-
1746- public class ApplicationGroup : Ctk.Box
1747- {
1748- public int n_items = 0;
1749-
1750- private Ctk.Text GroupName;
1751- private Ctk.Image Star;
1752- private Unity.Places.CairoDrawing.PlacesHSeparator Separator;
1753- private Ctk.Image maximize_button;
1754- private Ctk.Image minimize_button;
1755- private bool is_open;
1756- private Gee.ArrayList<ApplicationIcon> application_icon_array;
1757-
1758-
1759- public override void allocate (Clutter.ActorBox box,
1760- Clutter.AllocationFlags flags)
1761- {
1762- int width = (int)(box.x2 - box.x1);
1763- int IconWidth = 120;
1764- int IconHeight = 48;
1765- int ApplicationIconSpacing = 24;
1766-
1767- int HeaderBorderPositionX = 0;
1768- int HeaderBorderPositionY = 0;
1769- int IconBorderPositionX = 15;
1770- int IconBorderPositionY = 30;
1771- int LineBorderPositionX = 0;
1772- int LineBorderPositionY = 20;
1773-
1774- Clutter.ActorBox child_box = { 0.0f, 0.0f, 0.0f, 0.0f };
1775-
1776- base.allocate (box, flags);
1777-
1778- child_box.x1 = IconBorderPositionX;
1779- child_box.x2 = IconWidth;
1780- child_box.y1 = IconBorderPositionY;
1781- child_box.y2 = child_box.y1 + IconHeight;
1782-
1783- int i;
1784- for (i = 0; i < this.application_icon_array.size; i++)
1785- {
1786- child_box.x2 = child_box.x1 + IconWidth;
1787- this.application_icon_array[i].view.allocate(child_box, flags);
1788-
1789- Clutter.ActorBox label_box = { 0.0f, 0.0f, 0.0f, 0.0f };
1790- label_box.x1 = child_box.x1;
1791- label_box.x2 = child_box.x2;
1792- label_box.y1 = IconBorderPositionY + IconHeight + 12.0f;
1793- label_box.y2 = label_box.y1 + 64;
1794- this.application_icon_array[i].label.allocate(label_box, flags);
1795-
1796- child_box.x1 += IconWidth + ApplicationIconSpacing;
1797- }
1798-
1799- if (this.Separator.Width != width)
1800- {
1801- this.Separator.CreateSeparator ( width, 5);
1802- }
1803- child_box.x1 = LineBorderPositionX;
1804- child_box.x2 = child_box.x1 + width;
1805- child_box.y1 = LineBorderPositionY;
1806- child_box.y2 = LineBorderPositionY + 5;
1807- this.Separator.allocate (child_box, flags);
1808-
1809- child_box.x1 = HeaderBorderPositionX;
1810- child_box.x2 = child_box.x1 + 22;
1811- child_box.y1 = HeaderBorderPositionY;
1812- child_box.y2 = HeaderBorderPositionY+ 23;
1813- this.Star.allocate (child_box, flags);
1814-
1815- child_box.x1 = HeaderBorderPositionX + 22;
1816- child_box.x2 = child_box.x1 + 100;
1817- child_box.y1 = HeaderBorderPositionY;
1818- child_box.y2 = HeaderBorderPositionY + 23;
1819- this.GroupName.allocate (child_box, flags);
1820-
1821- child_box.x1 += width - 50;
1822- child_box.x2 = child_box.x1 + 16;
1823- child_box.y1 = HeaderBorderPositionY;
1824- child_box.y2 = HeaderBorderPositionY + 19;
1825- this.maximize_button.allocate (child_box, flags);
1826- this.minimize_button.allocate (child_box, flags);
1827- }
1828-
1829- public override void get_preferred_width (float for_height,
1830- out float minimum_width,
1831- out float natural_width)
1832- {
1833- minimum_width = 800.0f;
1834- natural_width = 800.0f;
1835- }
1836-
1837- public override void get_preferred_height (float for_width,
1838- out float minimum_height,
1839- out float natural_height)
1840- {
1841- minimum_height = 135.0f;
1842- natural_height = 135.0f;
1843- }
1844-
1845- public ApplicationGroup (string group_name)
1846- {
1847- this.homogeneous = false;
1848- this.orientation = Ctk.Orientation.HORIZONTAL;
1849-
1850- this.GroupName = new Ctk.Text (group_name);
1851- this.Star = new Ctk.Image.from_filename (23, FAVOURITES_ICON);
1852- this.Separator = new Unity.Places.CairoDrawing.PlacesHSeparator ();
1853- this.maximize_button = new Ctk.Image.from_filename (16, MAXIMIZE_ICON);
1854- this.minimize_button = new Ctk.Image.from_filename (16, MINIMIZE_ICON);
1855-
1856- application_icon_array = new Gee.ArrayList<ApplicationIcon> ();
1857- /*
1858- for (int i = 0; i < 5; i++)
1859- {
1860- ApplicationIcon app = new ApplicationIcon (48, "App",
1861- APP_ICON,
1862- "Your apps stored locally");
1863- this.application_icon_array.add (app);
1864- this.add_actor (app.view);
1865- this.add_actor (app.label);
1866- }
1867-*/
1868- this.add_actor (this.Star);
1869- this.add_actor (this.Separator);
1870- this.add_actor (this.GroupName);
1871- this.add_actor (this.maximize_button);
1872- this.add_actor (this.minimize_button);
1873-
1874- this.is_open = true;
1875- this.show_all ();
1876-
1877- this.maximize_button.set_reactive (true);
1878- this.minimize_button.set_reactive (true);
1879- this.maximize_button.hide();
1880- this.minimize_button.show();
1881-
1882- this.maximize_button.button_release_event.connect (this.on_maximize);
1883- this.minimize_button.button_release_event.connect (this.on_minimize);
1884- }
1885-
1886- public void add_icon (ApplicationIcon app)
1887- {
1888- this.application_icon_array.add (app);
1889- this.add_actor (app.view);
1890- this.add_actor (app.label);
1891-
1892- this.n_items++;
1893- }
1894-
1895- construct
1896- {
1897- }
1898-
1899- public bool on_minimize (Clutter.Event event)
1900- {
1901- this.maximize_button.show();
1902- this.minimize_button.hide();
1903- this.is_open = false;
1904- return false;
1905- }
1906-
1907- public bool on_maximize (Clutter.Event event)
1908- {
1909- this.maximize_button.hide();
1910- this.minimize_button.show();
1911- this.is_open = true;
1912- return false;
1913- }
1914- }
1915-
1916- public class ApplicationView : Ctk.Box
1917- {
1918- public ApplicationGroup recent_app_group;
1919- public ApplicationGroup yesterday_app_group;
1920- public ApplicationGroup lastweek_app_group;
1921- public override void allocate (Clutter.ActorBox box,
1922- Clutter.AllocationFlags flags)
1923- {
1924- Clutter.ActorBox child_box = { 0.0f, 0.0f, 0.0f, 0.0f };
1925- float width, height;
1926- float child_width, child_height;
1927-
1928- base.allocate (box, flags);
1929-
1930- width = box.x2 - box.x1;
1931- height = box.y2 - box.y1;
1932-
1933- this.recent_app_group.get_preferred_width (height,
1934- out child_width,
1935- out child_width);
1936- this.recent_app_group.get_preferred_height (width,
1937- out child_height,
1938- out child_height);
1939- child_box.x1 = (width - child_width)/2.0f;
1940- child_box.x2 = child_box.x1 + child_width;
1941- child_box.y1 = 0.0f;
1942- child_box.y2 = child_height;
1943- recent_app_group.allocate (child_box, flags);
1944-
1945- child_box.y1 += child_height;
1946- child_box.y2 = child_box.y1 + child_height;
1947- yesterday_app_group.allocate (child_box, flags);
1948-
1949- child_box.y1 += child_height;
1950- child_box.y2 = child_box.y1 + child_height;
1951- lastweek_app_group.allocate (child_box, flags);
1952- }
1953-
1954- public ApplicationView ()
1955- {
1956- recent_app_group = new ApplicationGroup ("Recent apps");
1957- yesterday_app_group = new ApplicationGroup ("Yesterday apps");
1958- lastweek_app_group = new ApplicationGroup ("Last week apps");
1959-
1960- this.add_actor (recent_app_group);
1961- this.add_actor (yesterday_app_group);
1962- this.add_actor (lastweek_app_group);
1963- this.show_all ();
1964- }
1965-
1966- construct
1967- {
1968- }
1969- }
1970-}
1971
1972=== removed file 'unity-private/places/bar-model.vala'
1973--- unity-private/places/bar-model.vala 2009-12-14 14:14:37 +0000
1974+++ unity-private/places/bar-model.vala 1970-01-01 00:00:00 +0000
1975@@ -1,43 +0,0 @@
1976-/*
1977- * Copyright (C) 2009 Canonical Ltd
1978- *
1979- * This program is free software: you can redistribute it and/or modify
1980- * it under the terms of the GNU General Public License version 3 as
1981- * published by the Free Software Foundation.
1982- *
1983- * This program is distributed in the hope that it will be useful,
1984- * but WITHOUT ANY WARRANTY; without even the implied warranty of
1985- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1986- * GNU General Public License for more details.
1987- *
1988- * You should have received a copy of the GNU General Public License
1989- * along with this program. If not, see <http://www.gnu.org/licenses/>.
1990- *
1991- * Authored by Mirco "MacSlow" Müller <mirco.mueller@canonical.com>
1992- *
1993- */
1994-
1995-using GLib;
1996-
1997-namespace Unity.Places.Bar
1998-{
1999- public class Model : Object
2000- {
2001- public string name;
2002- public string icon_name;
2003- public string tooltip;
2004-
2005- public Model (string name,
2006- string icon_name,
2007- string tooltip)
2008- {
2009- this.name = name;
2010- this.icon_name = icon_name;
2011- this.tooltip = tooltip;
2012- }
2013-
2014- construct
2015- {
2016- }
2017- }
2018-}
2019
2020=== removed file 'unity-private/places/bar-view.vala'
2021--- unity-private/places/bar-view.vala 2010-01-24 20:13:39 +0000
2022+++ unity-private/places/bar-view.vala 1970-01-01 00:00:00 +0000
2023@@ -1,253 +0,0 @@
2024-/*
2025- * Copyright (C) 2009 Canonical Ltd
2026- *
2027- * This program is free software: you can redistribute it and/or modify
2028- * it under the terms of the GNU General Public License version 3 as
2029- * published by the Free Software Foundation.
2030- *
2031- * This program is distributed in the hope that it will be useful,
2032- * but WITHOUT ANY WARRANTY; without even the implied warranty of
2033- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2034- * GNU General Public License for more details.
2035- *
2036- * You should have received a copy of the GNU General Public License
2037- * along with this program. If not, see <http://www.gnu.org/licenses/>.
2038- *
2039- * Authored by Mirco "MacSlow" Müller <mirco.mueller@canonical.com>
2040- * Neil Jagdish Patel <neil.patel@canonical.com>
2041- *
2042- */
2043-
2044-namespace Unity.Places.Bar
2045-{
2046- const float PANEL_HEIGHT = 24;
2047- const int ICON_SIZE = 48;
2048- const float ICON_VIEW_WIDTH = 80.0f;
2049- const float ICON_VIEW_Y1 = 8.0f;
2050- const float QL_PAD = 12.0f;
2051-
2052- const string TRASH_FILE = Unity.PKGDATADIR + "/trash.png";
2053-
2054- public class View : Ctk.Box
2055- {
2056- public Places.Model model { get; construct; }
2057- public Shell shell { get; construct; }
2058-
2059- private Gee.ArrayList<PlaceIcon> places_icons;
2060- private PlaceIcon trash_icon;
2061-
2062- private Unity.Places.CairoDrawing.PlacesVSeparator separator;
2063- private Unity.Places.CairoDrawing.PlacesBackground bg;
2064-
2065- public View (Places.Model model, Shell shell)
2066- {
2067- Ctk.EffectGlow glow;
2068- Clutter.Color white = {255, 255, 255, 255};
2069-
2070- Object (model:model, shell:shell);
2071-
2072- /* We do our own allocation, but this doesn't hurt */
2073- this.homogeneous = false;
2074- this.orientation = Ctk.Orientation.HORIZONTAL;
2075-
2076- /* The background of the entire places bar */
2077- this.bg = new Unity.Places.CairoDrawing.PlacesBackground ();
2078- this.bg.set_parent (this);
2079- this.bg.show ();
2080- /* Make sure the bg is updated when the indicators change */
2081- this.shell.indicators_changed.connect (this.on_indicators_changed);
2082-
2083- /* This'll be populated in an idle by the model */
2084- this.places_icons = new Gee.ArrayList<PlaceIcon> ();
2085- this.model.place_added.connect (this.on_place_added);
2086-
2087- /* Create trash icon */
2088- this.trash_icon = new PlaceIcon (ICON_SIZE,
2089- "Trash",
2090- TRASH_FILE,
2091- "Your piece of waste");
2092- glow = new Ctk.EffectGlow ();
2093- glow.set_color (white);
2094- glow.set_factor (1.0f);
2095- glow.set_margin (6);
2096- this.trash_icon.add_effect (glow);
2097-
2098- this.pack (this.trash_icon, false, false);
2099- this.trash_icon.button_release_event.connect (this.on_button_release);
2100-
2101- /* Create the separator */
2102- this.separator = new Unity.Places.CairoDrawing.PlacesVSeparator ();
2103- this.pack (this.separator, false, false);
2104-
2105- this.show_all ();
2106- }
2107-
2108- private void on_place_added (Place place)
2109- {
2110- Clutter.Color white = {255, 255, 255, 255};
2111-
2112- var icon = new PlaceIcon.from_place (ICON_SIZE, place);
2113- this.places_icons.add (icon);
2114-
2115- var glow = new Ctk.EffectGlow ();
2116- glow.set_color (white);
2117- glow.set_factor (1.0f);
2118- glow.set_margin (6);
2119- icon.add_effect (glow);
2120-
2121- this.pack (icon, false, false);
2122- icon.button_release_event.connect (this.on_button_release);
2123-
2124- if (this.places_icons.size == 1)
2125- {
2126- Clutter.Actor stage = icon.get_stage ();
2127- this.bg.create_places_background ((int)stage.width,
2128- (int)stage.height,
2129- (int)(this.padding.left + QL_PAD),
2130- (int)ICON_VIEW_WIDTH,
2131- this.shell.get_indicators_width());
2132-
2133- icon.place.active = true;
2134- }
2135- }
2136-
2137- private void on_indicators_changed (int width)
2138- {
2139- Clutter.Actor stage = this.get_stage ();
2140- this.bg.create_places_background ((int)stage.width,
2141- (int)stage.height,
2142- (int)(this.padding.left + QL_PAD),
2143- (int)ICON_VIEW_WIDTH,
2144- width);
2145- this.queue_relayout ();
2146- }
2147-
2148- public override void map ()
2149- {
2150- base.map ();
2151- this.bg.map ();
2152- }
2153-
2154- public override void unmap ()
2155- {
2156- base.unmap ();
2157- this.bg.unmap ();
2158- }
2159-
2160- public override void paint ()
2161- {
2162- this.bg.paint ();
2163- base.paint ();
2164- }
2165-
2166- public override void allocate (Clutter.ActorBox box,
2167- Clutter.AllocationFlags flags)
2168- {
2169- Clutter.ActorBox child_box = {0, 0, 0, 0};
2170- child_box.x1 = 0.0f;
2171- child_box.x2 = box.x2 - box.x1;
2172- child_box.y1 = 0.0f;
2173- child_box.y2 = box.y2 - box.y1;
2174-
2175- this.bg.allocate (child_box, flags);
2176-
2177- /* Allocate the places icons */
2178- var n_places = 0;
2179- var lpadding = this.padding.left + QL_PAD;
2180-
2181- child_box.y1 = ICON_VIEW_Y1;
2182- child_box.y2 = child_box.y1 + ICON_SIZE;
2183-
2184- foreach (PlaceIcon place in this.places_icons)
2185- {
2186- child_box.x1 = lpadding + (ICON_VIEW_WIDTH * n_places);
2187- child_box.x2 = child_box.x1 + ICON_VIEW_WIDTH;
2188-
2189- place.allocate (child_box, flags);
2190-
2191- n_places++;
2192- }
2193-
2194- /* Allocate the Trash (24 = Padding) */
2195- var i_width = this.shell.get_indicators_width () + 8;
2196- child_box.x1 = box.x2 - box.x1 - i_width - ICON_VIEW_WIDTH;
2197- child_box.x2 = child_box.x1 + ICON_VIEW_WIDTH;
2198- this.trash_icon.allocate (child_box, flags);
2199-
2200- /* Allocate the seperator */
2201- child_box.x1 -= 12.0f;
2202- child_box.x2 = child_box.x1 + 5;
2203- child_box.y1 = 10;
2204- child_box.y2 = ICON_SIZE;
2205- this.separator.allocate (child_box, flags);
2206- }
2207-
2208- public bool on_button_release (Clutter.Event event)
2209- {
2210- Clutter.Actor actor;
2211- actor = event.button.source;
2212-
2213- if (actor is PlaceIcon)
2214- {
2215- PlaceIcon icon = actor as PlaceIcon;
2216-
2217- /* Do something with the click */
2218- if (actor == this.trash_icon)
2219- {
2220- try
2221- {
2222- Process.spawn_command_line_async ("xdg-open trash:///");
2223- }
2224- catch (SpawnError e)
2225- {
2226- warning ("Unable to show Trash: %s", e.message);
2227- }
2228- }
2229- else if (icon.place is Place)
2230- {
2231- Clutter.Actor stage = actor.get_stage ();
2232-
2233- /* Update the background */
2234- this.bg.create_places_background ((int)stage.width,
2235- (int)stage.height,
2236- (int)actor.x,
2237- 80,
2238- this.shell.get_indicators_width());
2239-
2240- /* Set the place as active, unset the others */
2241- foreach (PlaceIcon picon in this.places_icons)
2242- {
2243- if (picon.place is Place)
2244- picon.place.active = (picon == icon) ? true : false;
2245- }
2246- }
2247-
2248- return true;
2249- }
2250-
2251- return false;
2252- }
2253- }
2254-
2255- public class PlaceIcon : Ctk.Image
2256- {
2257- public Place? place { get; set; }
2258-
2259- public PlaceIcon (int width,
2260- string name,
2261- string icon_name,
2262- string tooltip)
2263- {
2264- Object (size:width);
2265-
2266- this.set_from_filename (icon_name);
2267- this.reactive = true;
2268- }
2269-
2270- public PlaceIcon.from_place (int size, Place place)
2271- {
2272- this(size, place.name, place.icon_name, "");
2273- this.place = place;
2274- }
2275- }
2276-}
2277
2278=== removed file 'unity-private/places/cairo-drawing.vala'
2279--- unity-private/places/cairo-drawing.vala 2010-04-07 21:28:27 +0000
2280+++ unity-private/places/cairo-drawing.vala 1970-01-01 00:00:00 +0000
2281@@ -1,474 +0,0 @@
2282-/*
2283- * Copyright (C) 2009 Canonical Ltd
2284- *
2285- * This program is free software: you can redistribute it and/or modify
2286- * it under the terms of the GNU General Public License version 3 as
2287- * published by the Free Software Foundation.
2288- *
2289- * This program is distributed in the hope that it will be useful,
2290- * but WITHOUT ANY WARRANTY; without even the implied warranty of
2291- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2292- * GNU General Public License for more details.
2293- *
2294- * You should have received a copy of the GNU General Public License
2295- * along with this program. If not, see <http://www.gnu.org/licenses/>.
2296- *
2297- * Authored by Jay Taoko <jay.taoko@canonical.com>
2298- *
2299- */
2300-
2301-namespace Unity.Places.CairoDrawing
2302-{
2303- /* Margin outside of the cairo texture. We draw outside to complete the line loop
2304- * and we don't want the line loop to be visible in some parts of the screen.
2305- * */
2306- private int Margin = 5;
2307-
2308- public class PlacesBackground : Ctk.Bin
2309- {
2310- public Clutter.CairoTexture cairotxt;
2311-
2312- private Ctk.EffectGlow effect_glow;
2313-
2314- /* (X, Y) origine of Places Bar: The top-left corner of the screen */
2315- private int PlaceX = 0;
2316- private int PlaceY = 0;
2317-
2318- /* Places Bar width and height. The width is set the the width of the window. */
2319- private int PlaceW = 760;
2320- private int PlaceH = 55;
2321-
2322- private int PlaceBottom; /* PlaceY + PlaceH */
2323-
2324- /* Menu area width and height */
2325- private int MenuH = 22;
2326- private int MenuW = 100;
2327-
2328- private int MenuBottom; /* PlaceY + MenuH */
2329-
2330- private int TabH = 50;
2331-
2332- /* The squirl area width */
2333- private int SquirlW = 66;
2334-
2335- public struct TabRect
2336- {
2337- int left;
2338- int right;
2339- int top;
2340- int bottom;
2341- }
2342-
2343- public int PlaceWidth;
2344-
2345- void DrawAroundMenu (Cairo.Context cairoctx)
2346- {
2347- int radius = 8;
2348- cairoctx.line_to (PlaceX + PlaceW + Margin, PlaceY + MenuH);
2349- cairoctx.line_to (PlaceX + PlaceW - MenuW + radius, PlaceY + MenuH);
2350-
2351- int arc_center_x = PlaceX + PlaceW - MenuW + radius;
2352- int arc_center_y = PlaceY + MenuH + radius;
2353-
2354- cairoctx.arc_negative ( (double)arc_center_x, (double)arc_center_y, radius, 3.0*Math.PI/2.0, Math.PI);
2355-
2356- cairoctx.line_to (PlaceX + PlaceW - MenuW, PlaceY + PlaceH - radius);
2357-
2358- arc_center_x = PlaceX + PlaceW - MenuW - radius;
2359- arc_center_y = PlaceY + PlaceH - radius;
2360- cairoctx.arc ( (double)arc_center_x, (double)arc_center_y, radius, 0.0, Math.PI/2.0);
2361- }
2362-
2363- void DrawTab(Cairo.Context cairoctx, TabRect tab)
2364- {
2365- int radius = 5;
2366- int radius_small = 5;
2367- int arc_center_x;
2368- int arc_center_y;
2369-
2370- cairoctx.line_to (tab.right + radius_small, PlaceBottom );
2371-
2372- arc_center_x = tab.right + radius_small;
2373- arc_center_y = PlaceBottom - radius_small;
2374- cairoctx.arc ( (double)arc_center_x, (double)arc_center_y, radius_small, Math.PI/2.0, Math.PI);
2375-
2376- cairoctx.line_to (tab.right, tab.top + radius);
2377-
2378- arc_center_x = tab.right - radius;
2379- arc_center_y = tab.top + radius;
2380- cairoctx.arc_negative ( (double)arc_center_x, (double)arc_center_y, radius, 0.0, 3.0*Math.PI/2.0);
2381-
2382- cairoctx.line_to (tab.left + radius, tab.top);
2383-
2384- arc_center_x = tab.left + radius;
2385- arc_center_y = tab.top + radius;
2386- cairoctx.arc_negative ( (double)arc_center_x, (double)arc_center_y, radius, 3.0*Math.PI/2.0, Math.PI);
2387-
2388- cairoctx.line_to (tab.left, PlaceBottom - radius_small);
2389-
2390- arc_center_x = tab.left - radius_small;
2391- arc_center_y = PlaceBottom - radius_small;
2392- cairoctx.arc ( (double)arc_center_x, (double)arc_center_y, radius_small, 0.0, Math.PI/2.0);
2393- }
2394-
2395- void DrawSquirl(Cairo.Context cairoctx)
2396- {
2397- int radius_small = 5;
2398- int arc_center_x;
2399- int arc_center_y;
2400-
2401- cairoctx.line_to (PlaceX + SquirlW + radius_small, PlaceBottom);
2402-
2403- arc_center_x = PlaceX + SquirlW + radius_small;
2404- arc_center_y = PlaceBottom - radius_small;
2405- cairoctx.arc ( (double)arc_center_x, (double)arc_center_y, radius_small, Math.PI/2.0, Math.PI);
2406-
2407- cairoctx.line_to (PlaceX + SquirlW, MenuBottom + radius_small );
2408-
2409- arc_center_x = PlaceX + SquirlW - radius_small;
2410- arc_center_y = MenuBottom + radius_small;
2411- cairoctx.arc_negative ( (double)arc_center_x, (double)arc_center_y, radius_small, 0, 3.0*Math.PI/2.0);
2412-
2413- cairoctx.line_to (PlaceX - Margin, MenuBottom);
2414- }
2415-
2416- public PlacesBackground ()
2417- {
2418- PlaceWidth = 0;
2419- }
2420-
2421- public void create_places_background (int WindowWidth,
2422- int WindowHeight,
2423- int TabPositionX,
2424- int TabWidth,
2425- int menu_width)
2426- {
2427- PlaceWidth = WindowWidth;
2428- PlaceW = WindowWidth;
2429- PlaceBottom = PlaceY + PlaceH;
2430- MenuBottom = PlaceY + MenuH;
2431-
2432- MenuW = menu_width;
2433-
2434- if (this.get_child () is Clutter.Actor)
2435- {
2436- this.remove_actor (this.get_child ());
2437- }
2438-
2439- cairotxt = new Clutter.CairoTexture(PlaceW, PlaceH + Margin);
2440- Cairo.Context cairoctx = cairotxt.create();
2441- {
2442- cairoctx.set_operator (Cairo.Operator.CLEAR);
2443- cairoctx.paint ();
2444- cairoctx.set_operator (Cairo.Operator.OVER);
2445- cairoctx.translate (0.5f, 0.5f);
2446-
2447- cairoctx.set_source_rgba (1, 1, 1, 1.0);
2448- cairoctx.set_line_width (1.0);
2449-
2450- cairoctx.move_to (PlaceX - Margin, PlaceY - Margin);
2451- cairoctx.line_to (PlaceX + PlaceW + Margin, PlaceY - Margin);
2452-
2453- DrawAroundMenu (cairoctx);
2454-
2455- TabRect tab = TabRect();
2456- tab.left = TabPositionX;
2457- tab.right = tab.left + TabWidth;
2458- tab.top = PlaceY + PlaceH - TabH;
2459- tab.bottom = PlaceY + PlaceH;
2460-
2461- DrawTab(cairoctx, tab);
2462-
2463- DrawSquirl (cairoctx);
2464-
2465- /* close the path */
2466- cairoctx.line_to (PlaceX - Margin, PlaceY - Margin);
2467-
2468- cairoctx.stroke_preserve ();
2469-
2470- cairoctx.clip ();
2471-
2472- Cairo.Surface surface = new Cairo.ImageSurface.from_png (Unity.PKGDATADIR + "/dash_background.png");
2473- Cairo.Pattern pattern = new Cairo.Pattern.for_surface (surface);
2474- pattern.set_extend (Cairo.Extend.REPEAT);
2475- cairoctx.set_source (pattern);
2476-
2477- cairoctx.paint_with_alpha (0.1);
2478- }
2479-
2480- cairotxt.set_opacity (0xFF);
2481- this.add_actor (cairotxt);
2482-
2483- /* Remove all effects set on this actor */
2484- this.remove_all_effects ();
2485-
2486- /* Create a new effect and add it to this actor */
2487- /* The new effect will use the newly created drawing as a base */
2488- effect_glow = new Ctk.EffectGlow ();
2489- Clutter.Color c = Clutter.Color ()
2490- {
2491- red = 255,
2492- green = 255,
2493- blue = 255,
2494- alpha = 255
2495- };
2496-
2497- effect_glow.set_color (c);
2498- effect_glow.set_factor (1.0f);
2499- effect_glow.set_margin (5);
2500- this.add_effect (effect_glow);
2501- }
2502-
2503- construct
2504- {
2505- }
2506- }
2507-
2508-
2509- public class PlacesVSeparator : Ctk.Bin
2510- {
2511- public int Width = 0;
2512- public int Height = 0;
2513-
2514- public Clutter.CairoTexture cairotxt;
2515- public PlacesVSeparator ()
2516- {
2517- }
2518-
2519- public void CreateSeparator (int W, int H)
2520- {
2521- Width = W;
2522- Height = H;
2523-
2524- if (this.get_child () is Clutter.Actor)
2525- {
2526- this.remove_actor (this.get_child ());
2527- }
2528-
2529- cairotxt = new Clutter.CairoTexture(Width, Height);
2530- Cairo.Context cairoctx = cairotxt.create();
2531- {
2532- cairoctx.set_source_rgba (1, 1, 1, 1.0);
2533- cairoctx.set_line_width (1.0);
2534-
2535- cairoctx.move_to (Width/2.0, 0);
2536- cairoctx.line_to (Width/2.0, Height);
2537-
2538- cairoctx.stroke ();
2539- cairoctx.set_source_rgba (1, 1, 1, 0.15);
2540- }
2541-
2542- cairotxt.set_opacity (0xFF);
2543- this.add_actor (cairotxt);
2544-
2545- /* Remove all effects set on this actor */
2546- this.remove_all_effects ();
2547-
2548- /* Create a new effect and add it to this actor */
2549- /* The new effect will use the newly created drawing as a base */
2550- Ctk.EffectGlow effect_glow = new Ctk.EffectGlow ();
2551- Clutter.Color c = Clutter.Color ()
2552- {
2553- red = 255,
2554- green = 255,
2555- blue = 255,
2556- alpha = 255
2557- };
2558-
2559- effect_glow.set_color (c);
2560- effect_glow.set_factor (1.0f);
2561- effect_glow.set_margin (5);
2562- this.add_effect (effect_glow);
2563- }
2564-
2565- construct
2566- {
2567- }
2568- }
2569-
2570- public class PlacesHSeparator : Ctk.Bin
2571- {
2572- public int Width = 0;
2573- public int Height = 0;
2574-
2575- public Clutter.CairoTexture cairotxt;
2576- public PlacesHSeparator ()
2577- {
2578- }
2579-
2580- public void CreateSeparator (int W, int H)
2581- {
2582- Width = W;
2583- Height = H;
2584-
2585- if (this.get_child () is Clutter.Actor)
2586- {
2587- this.remove_actor (this.get_child ());
2588- }
2589-
2590- cairotxt = new Clutter.CairoTexture(Width, Height);
2591- Cairo.Context cairoctx = cairotxt.create();
2592- {
2593- cairoctx.set_source_rgba (1, 1, 1, 1.0);
2594- cairoctx.set_line_width (1.0);
2595-
2596- cairoctx.move_to (0, Height/2.0);
2597- cairoctx.line_to (Width, Height/2.0);
2598-
2599- cairoctx.stroke ();
2600- cairoctx.set_source_rgba (1, 1, 1, 0.15);
2601- }
2602-
2603- cairotxt.set_opacity (0xFF);
2604- this.add_actor (cairotxt);
2605-
2606- /* Remove all effects set on this actor */
2607- this.remove_all_effects ();
2608-
2609- /* Create a new effect and add it to this actor */
2610- /* The new effect will use the newly created drawing as a base */
2611-
2612- Ctk.EffectGlow effect_glow = new Ctk.EffectGlow ();
2613- Clutter.Color c = Clutter.Color ()
2614- {
2615- red = 255,
2616- green = 255,
2617- blue = 255,
2618- alpha = 255
2619- };
2620-
2621- effect_glow.set_color (c);
2622- effect_glow.set_factor (1.0f);
2623- effect_glow.set_margin (5);
2624- this.add_effect (effect_glow);
2625- }
2626-
2627- construct
2628- {
2629- }
2630- }
2631-
2632- public class RectangleBox : Ctk.Bin
2633- {
2634- public int Width = 0;
2635- public int Height = 0;
2636-
2637- public Clutter.CairoTexture cairotxt;
2638- public RectangleBox ()
2639- {
2640- }
2641-
2642- public void CreateRectangleBox (int W, int H)
2643- {
2644- Width = W;
2645- Height = H;
2646-
2647- if (this.get_child () is Clutter.Actor)
2648- {
2649- this.remove_actor (this.get_child ());
2650- }
2651-
2652- cairotxt = new Clutter.CairoTexture(Width, Height);
2653- Cairo.Context cairoctx = cairotxt.create();
2654- {
2655- cairoctx.set_operator (Cairo.Operator.CLEAR);
2656- cairoctx.paint ();
2657- cairoctx.set_operator (Cairo.Operator.OVER);
2658- cairoctx.translate (0.5f, 0.5f);
2659-
2660- cairoctx.set_source_rgba (1, 1, 1, 1.0);
2661- cairoctx.set_line_width (1.0);
2662-
2663- cairoctx.move_to (1, 1);
2664- cairoctx.line_to (Width-1, 1);
2665- cairoctx.line_to (Width-1, Height-1);
2666- cairoctx.line_to (1, Height-1);
2667- cairoctx.line_to (1, 1);
2668- cairoctx.stroke ();
2669- }
2670-
2671- cairotxt.set_opacity (0xFF);
2672- this.add_actor (cairotxt);
2673-
2674- /* Remove all effects set on this actor */
2675- this.remove_all_effects ();
2676-
2677- /* Create a new effect and add it to this actor */
2678- /* The new effect will use the newly created drawing as a base */
2679- Ctk.EffectGlow effect_glow = new Ctk.EffectGlow ();
2680- Clutter.Color c = Clutter.Color ()
2681- {
2682- red = 255,
2683- green = 255,
2684- blue = 255,
2685- alpha = 255
2686- };
2687-
2688- effect_glow.set_color (c);
2689- effect_glow.set_factor (1.0f);
2690- effect_glow.set_margin (5);
2691- this.add_effect (effect_glow);
2692- }
2693-
2694- construct
2695- {
2696- }
2697- }
2698-
2699- public class EntryBackground : Ctk.Bin
2700- {
2701- public int Width = 0;
2702- public int Height = 0;
2703-
2704- public Clutter.CairoTexture cairotxt;
2705- public EntryBackground ()
2706- {
2707- cairotxt = new Clutter.CairoTexture (120, 24);
2708- add_actor (cairotxt);
2709- }
2710-
2711- public void create_search_entry_background (int W, int H)
2712- {
2713- Width = W;
2714- Height = H;
2715-
2716- Cairo.Context cairoctx = cairotxt.create();
2717- {
2718- cairoctx.set_operator (Cairo.Operator.CLEAR);
2719- cairoctx.paint ();
2720- cairoctx.set_operator (Cairo.Operator.OVER);
2721- cairoctx.translate (-0.5f, -0.5f);
2722-
2723- cairoctx.set_source_rgba (1.0, 1.0, 1.0, 0.9);
2724- cairoctx.set_line_width (1.0);
2725-
2726- cairoctx.move_to (10, 1);
2727- cairoctx.line_to (Width-10, 1);
2728-
2729- cairoctx.curve_to ((double)(Width-5), 1.0, (double)(Width-1), 5.0, (double)(Width-1), (double)(Height/2.0));
2730- cairoctx.curve_to ((double)(Width-1), (double)(Height/2.0 + 5.0), (double)(Width-5), (double)(Height-2), (double)(Width-10), (double)(Height-2));
2731-
2732- cairoctx.line_to (10, Height-2);
2733-
2734- cairoctx.curve_to (5.0, (double)(Height-2), 1.0, (double)(Height/2.0 + 5.0), 1.0, (double)(Height/2.0));
2735- cairoctx.curve_to (1.0, 5.0, 5.0, 1.0, 10.0, 1.0);
2736-
2737-
2738- cairoctx.fill ();
2739- }
2740- cairotxt.set_opacity (0xFF);
2741- }
2742-
2743- /*private override void allocate (Clutter.ActorBox box,
2744- Clutter.AllocationFlags flags)
2745- {
2746- base.allocate (box, flags);
2747- create_search_entry_background ((int)(box.x2 - box.x1), (int)(box.y2 - box.y1));
2748- }*/
2749-
2750- construct
2751- {
2752- }
2753- }
2754-}
2755-
2756
2757=== removed file 'unity-private/places/default-model.vala'
2758--- unity-private/places/default-model.vala 2009-12-14 14:14:37 +0000
2759+++ unity-private/places/default-model.vala 1970-01-01 00:00:00 +0000
2760@@ -1,43 +0,0 @@
2761-/*
2762- * Copyright (C) 2009 Canonical Ltd
2763- *
2764- * This program is free software: you can redistribute it and/or modify
2765- * it under the terms of the GNU General Public License version 3 as
2766- * published by the Free Software Foundation.
2767- *
2768- * This program is distributed in the hope that it will be useful,
2769- * but WITHOUT ANY WARRANTY; without even the implied warranty of
2770- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2771- * GNU General Public License for more details.
2772- *
2773- * You should have received a copy of the GNU General Public License
2774- * along with this program. If not, see <http://www.gnu.org/licenses/>.
2775- *
2776- * Authored by Mirco "MacSlow" Müller <mirco.mueller@canonical.com>
2777- *
2778- */
2779-
2780-using GLib;
2781-
2782-namespace Unity.Places.Default
2783-{
2784- public class Model : Object
2785- {
2786- public string icon_name;
2787- public string primary_text;
2788- public string secondary_text;
2789-
2790- public Model (string icon_name,
2791- string primary_text,
2792- string secondary_text)
2793- {
2794- this.icon_name = icon_name;
2795- this.primary_text = primary_text;
2796- this.secondary_text = secondary_text;
2797- }
2798-
2799- construct
2800- {
2801- }
2802- }
2803-}
2804
2805=== removed file 'unity-private/places/default-view.vala'
2806--- unity-private/places/default-view.vala 2010-01-07 23:43:48 +0000
2807+++ unity-private/places/default-view.vala 1970-01-01 00:00:00 +0000
2808@@ -1,203 +0,0 @@
2809-/*
2810- * Copyright (C) 2009 Canonical Ltd
2811- *
2812- * This program is free software: you can redistribute it and/or modify
2813- * it under the terms of the GNU General Public License version 3 as
2814- * published by the Free Software Foundation.
2815- *
2816- * This program is distributed in the hope that it will be useful,
2817- * but WITHOUT ANY WARRANTY; without even the implied warranty of
2818- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2819- * GNU General Public License for more details.
2820- *
2821- * You should have received a copy of the GNU General Public License
2822- * along with this program. If not, see <http://www.gnu.org/licenses/>.
2823- *
2824- * Authored by Mirco "MacSlow" Müller <mirco.mueller@canonical.com>
2825- *
2826- */
2827-
2828-namespace Unity.Places.Default
2829-{
2830- public class ActivityWidget : Ctk.Box
2831- {
2832- private Ctk.Image icon;
2833- private Clutter.Text primary_label;
2834- private Clutter.Text secondary_label;
2835-
2836- public ActivityWidget (int spacing,
2837- int size,
2838- string icon_name,
2839- string primary_text,
2840- string secondary_text)
2841- {
2842- string process_name = "activity_widget" + icon_name;
2843- LOGGER_START_PROCESS (process_name);
2844- Clutter.Color color = {255, 255, 255, 255};
2845-
2846- this.homogeneous = false;
2847- this.orientation = Ctk.Orientation.VERTICAL;
2848- this.set_reactive (true);
2849- //this.padding = pad;
2850- this.spacing = spacing;
2851- //this.width = size + 32;
2852- this.icon = new Ctk.Image.from_stock (size, icon_name);
2853- this.icon.set_reactive (true);
2854-
2855- this.primary_label = new Clutter.Text ();
2856- this.primary_label.set_reactive (true);
2857- this.primary_label.width = size;
2858- this.primary_label.set_markup (primary_text);
2859- this.primary_label.justify = true;
2860- this.primary_label.color = color;
2861- this.primary_label.ellipsize = Pango.EllipsizeMode.NONE;
2862- this.primary_label.line_wrap = true;
2863- this.primary_label.line_alignment = Pango.Alignment.CENTER;
2864-
2865- this.secondary_label = new Clutter.Text ();
2866- this.secondary_label.set_reactive (true);
2867- this.secondary_label.width = size + spacing;
2868- //this.secondary_label.get_layout().set_height (-2);
2869- this.secondary_label.text = secondary_text;
2870- this.secondary_label.justify = false;
2871- this.secondary_label.color = color;
2872- //this.secondary_label.ellipsize = Pango.EllipsizeMode.END;
2873- this.secondary_label.line_wrap = true;
2874- this.secondary_label.line_alignment = Pango.Alignment.CENTER;
2875- this.secondary_label.line_wrap_mode = Pango.WrapMode.WORD_CHAR;
2876- this.enter_event.connect (this.on_enter);
2877- this.leave_event.connect (this.on_leave);
2878- this.secondary_label.opacity = 0;
2879-
2880- this.pack (this.icon, false, false);
2881- this.pack (this.primary_label, false, false);
2882- this.pack (this.secondary_label, false, false);
2883- LOGGER_END_PROCESS (process_name);
2884- }
2885-
2886- construct
2887- {
2888- }
2889-
2890- public bool on_enter ()
2891- {
2892- this.secondary_label.opacity = 255;
2893- return false;
2894- }
2895-
2896- public bool on_leave ()
2897- {
2898- this.secondary_label.opacity = 0;
2899- return false;
2900- }
2901-
2902- public bool on_clicked ()
2903- {
2904- stdout.printf ("on_clicked() called\n");
2905- return false;
2906- }
2907-
2908- }
2909-
2910- public class View : Ctk.IconView
2911- {
2912- private Gee.ArrayList<Unity.Places.Default.Model> activities;
2913-
2914- public override void allocate (Clutter.ActorBox box,
2915- Clutter.AllocationFlags flags)
2916- {
2917- Ctk.Padding padding = { 0.0f, 0.0f, 0.0f, 0.0f };
2918- float real_width;
2919- float real_height;
2920- float min_height_p;
2921- float natural_height_p;
2922- int hor_spacing;
2923-
2924- hor_spacing = this.get_spacing ();
2925- real_width = box.x2 - box.x1;
2926- real_height = box.y2 - box.y1;
2927- padding.left = (real_width - 4*128 -3*hor_spacing) / 2.0f; /* HARDCODED: 4 colum matrix */
2928- padding.right = padding.left;
2929-
2930- this.get_preferred_height (real_width,
2931- out min_height_p,
2932- out natural_height_p);
2933-
2934- padding.top = (real_height - 400) / 2.0f; /* HARDCODED */
2935- padding.bottom = padding.top;
2936-
2937- this.set_padding (padding);
2938- base.allocate (box, flags);
2939- }
2940-
2941- public View ()
2942- {
2943- START_FUNCTION ();
2944- Unity.Places.Default.Model activity;
2945- int i;
2946- ActivityWidget widget;
2947- int widget_size = 128; /* HARDCODED */
2948-
2949- this.activities = new Gee.ArrayList<Unity.Places.Default.Model> ();
2950-
2951- // populate defaultview with hard-coded contents for the moment
2952- activity = new Unity.Places.Default.Model ("applications-internet",
2953- "<b>Web</b>",
2954- "Search, Suft & Download");
2955- this.activities.add (activity);
2956-
2957- activity = new Unity.Places.Default.Model ("rhythmbox",
2958- "<b>Music</b>",
2959- "Jukebox, Radio & Podcasts");
2960- this.activities.add (activity);
2961-
2962- activity = new Unity.Places.Default.Model ("applications-multimedia",
2963- "<b>Videos</b>",
2964- "YouTube & More");
2965- this.activities.add (activity);
2966-
2967- activity = new Unity.Places.Default.Model ("applications-graphics",
2968- "<b>Photos</b>",
2969- "Organize, Edit & Share");
2970- this.activities.add (activity);
2971-
2972- activity = new Unity.Places.Default.Model ("applications-office",
2973- "<b>Work</b>",
2974- "Office Documents, Spreadsheets & Presentations");
2975- this.activities.add (activity);
2976-
2977- activity = new Unity.Places.Default.Model ("evolution",
2978- "<b>Email</b>",
2979- "Read & Write Email");
2980- this.activities.add (activity);
2981-
2982- activity = new Unity.Places.Default.Model ("empathy",
2983- "<b>Chat</b>",
2984- "AIM, Yahoo, Skype & MSN");
2985- this.activities.add (activity);
2986-
2987- activity = new Unity.Places.Default.Model ("softwarecenter",
2988- "<b>Get New Apps</b>",
2989- "Ubuntu Software Center");
2990- this.activities.add (activity);
2991-
2992- // create image-actors now
2993- for (i = 0; i < this.activities.size; i++)
2994- {
2995- widget = new ActivityWidget (0,
2996- widget_size,
2997- this.activities[i].icon_name,
2998- this.activities[i].primary_text,
2999- this.activities[i].secondary_text);
3000- this.add_actor (widget);
3001- }
3002-
3003- this.show_all ();
3004- END_FUNCTION ();
3005- }
3006-
3007- construct
3008- {
3009- }
3010- }
3011-}
3012
3013=== removed file 'unity-private/places/file-place.vala'
3014--- unity-private/places/file-place.vala 2010-01-20 17:57:50 +0000
3015+++ unity-private/places/file-place.vala 1970-01-01 00:00:00 +0000
3016@@ -1,239 +0,0 @@
3017-
3018-namespace Unity.Places.File
3019-{
3020-
3021- const string FILES_FILE = Unity.PKGDATADIR + "/files.png";
3022- const string FAVOURITES_ICON = Unity.PKGDATADIR + "/favourites.png";
3023- const string MINIMIZE_ICON = Unity.PKGDATADIR + "/minimize_up.png";
3024- const string MAXIMIZE_ICON = Unity.PKGDATADIR + "/maximize_up.png";
3025-
3026- public class FileIcon
3027- {
3028- private Unity.Places.Bar.Model model;
3029- public Ctk.Image view;
3030- public Ctk.Text label;
3031-
3032- public FileIcon (int width, /*int height,*/ string name, string icon_name, string tooltip)
3033- {
3034- model = new Unity.Places.Bar.Model (name, icon_name, tooltip);
3035- view = new Ctk.Image.from_filename (width, icon_name);
3036- view.set_reactive (true);
3037- label = new Ctk.Text (name);
3038- }
3039- }
3040-
3041- public class FileGroup : Ctk.Box
3042- {
3043- private Ctk.Text GroupName;
3044- private Ctk.Image Star;
3045- private Unity.Places.CairoDrawing.PlacesHSeparator Separator;
3046- private Ctk.Image maximize_button;
3047- private Ctk.Image minimize_button;
3048- private bool is_open;
3049- private Gee.ArrayList<FileIcon> file_icon_array;
3050-
3051-
3052- public override void allocate (Clutter.ActorBox box,
3053- Clutter.AllocationFlags flags)
3054- {
3055- int IconWidth = 48;
3056- int IconHeight = 48;
3057- int FileIconSpacing = 100;
3058-
3059- int HeaderBorderPositionX = 0;
3060- int HeaderBorderPositionY = 60;
3061- int IconBorderPositionX = 0;
3062- int IconBorderPositionY = 100;
3063- int LineBorderPositionX = 0;
3064- int LineBorderPositionY = 90;
3065-
3066- Clutter.ActorBox child_box = { 0.0f, 0.0f, 0.0f, 0.0f };
3067-
3068- base.allocate (box, flags);
3069-
3070- child_box.x1 = IconBorderPositionX;
3071- child_box.x2 = 0;
3072- child_box.y1 = IconBorderPositionY;
3073- child_box.y2 = child_box.y1 + IconHeight;
3074-
3075- int i;
3076- for (i = 0; i < this.file_icon_array.size; i++)
3077- {
3078- child_box.x2 = child_box.x1 + IconWidth;
3079- this.file_icon_array[i].view.allocate(child_box, flags);
3080-
3081- Clutter.ActorBox label_box = { 0.0f, 0.0f, 0.0f, 0.0f };
3082- label_box.x1 = child_box.x1;
3083- label_box.x2 = child_box.x2;
3084- label_box.y1 = IconBorderPositionY + IconHeight;
3085- label_box.y2 = label_box.y1 + 64;
3086- this.file_icon_array[i].label.allocate(label_box, flags);
3087-
3088- child_box.x1 += IconWidth + FileIconSpacing;
3089- }
3090-
3091- if (this.Separator.Width != 800)
3092- {
3093- this.Separator.CreateSeparator ( 800, 5);
3094- }
3095- child_box.x1 = LineBorderPositionX;
3096- child_box.x2 = child_box.x1 + 800;
3097- child_box.y1 = LineBorderPositionY;
3098- child_box.y2 = LineBorderPositionY + 5;
3099- this.Separator.allocate (child_box, flags);
3100-
3101- child_box.x1 = HeaderBorderPositionX;
3102- child_box.x2 = child_box.x1 + 22;
3103- child_box.y1 = HeaderBorderPositionY;
3104- child_box.y2 = HeaderBorderPositionY+ 23;
3105- this.Star.allocate (child_box, flags);
3106-
3107- child_box.x1 = HeaderBorderPositionX + 22;
3108- child_box.x2 = child_box.x1 + 100;
3109- child_box.y1 = HeaderBorderPositionY;
3110- child_box.y2 = HeaderBorderPositionY + 23;
3111- this.GroupName.allocate (child_box, flags);
3112-
3113- child_box.x1 += 750;
3114- child_box.x2 = child_box.x1 + 16;
3115- child_box.y1 = HeaderBorderPositionY;
3116- child_box.y2 = HeaderBorderPositionY + 19;
3117- this.maximize_button.allocate (child_box, flags);
3118- this.minimize_button.allocate (child_box, flags);
3119- }
3120-
3121- public override void get_preferred_width (float for_height,
3122- out float minimum_width,
3123- out float natural_width)
3124- {
3125- minimum_width = 800.0f;
3126- natural_width = 800.0f;
3127- }
3128-
3129- public override void get_preferred_height (float for_width,
3130- out float minimum_height,
3131- out float natural_height)
3132- {
3133- minimum_height = 150.0f;
3134- natural_height = 150.0f;
3135- }
3136-
3137-
3138- public FileGroup (string group_name)
3139- {
3140- this.homogeneous = false;
3141- this.orientation = Ctk.Orientation.HORIZONTAL;
3142-
3143- this.GroupName = new Ctk.Text (group_name);
3144- this.Star = new Ctk.Image.from_filename (23, FAVOURITES_ICON);
3145- this.Separator = new Unity.Places.CairoDrawing.PlacesHSeparator ();
3146- this.maximize_button = new Ctk.Image.from_filename (16, MAXIMIZE_ICON);
3147- this.minimize_button = new Ctk.Image.from_filename (16, MINIMIZE_ICON);
3148-
3149- file_icon_array = new Gee.ArrayList<FileIcon> ();
3150- for (int i = 0; i < 5; i++)
3151- {
3152- FileIcon file = new FileIcon (48, "Files",
3153- FILES_FILE,
3154- "Your files stored locally");
3155- this.file_icon_array.add (file);
3156- this.add_actor (file.view);
3157- this.add_actor (file.label);
3158- }
3159-
3160- this.add_actor (this.Star);
3161- this.add_actor (this.Separator);
3162- this.add_actor (this.GroupName);
3163- this.add_actor (this.maximize_button);
3164- this.add_actor (this.minimize_button);
3165-
3166- this.is_open = true;
3167- this.show_all ();
3168-
3169- this.maximize_button.set_reactive (true);
3170- this.minimize_button.set_reactive (true);
3171- this.maximize_button.hide();
3172- this.minimize_button.show();
3173-
3174- this.maximize_button.button_release_event.connect (this.on_maximize);
3175- this.minimize_button.button_release_event.connect (this.on_minimize);
3176-
3177-
3178- }
3179-
3180- construct
3181- {
3182- }
3183-
3184- public bool on_minimize (Clutter.Event event)
3185- {
3186- this.maximize_button.show();
3187- this.minimize_button.hide();
3188- this.is_open = false;
3189- return false;
3190- }
3191-
3192- public bool on_maximize (Clutter.Event event)
3193- {
3194- this.maximize_button.hide();
3195- this.minimize_button.show();
3196- this.is_open = true;
3197- return false;
3198- }
3199- }
3200-
3201- public class FileView : Ctk.Box
3202- {
3203- public FileGroup recent_file_group;
3204- public FileGroup favourite_folder_group;
3205- public FileGroup downloaded_file_group;
3206- public override void allocate (Clutter.ActorBox box,
3207- Clutter.AllocationFlags flags)
3208- {
3209- Clutter.ActorBox child_box = { 0.0f, 0.0f, 0.0f, 0.0f };
3210- float width, height;
3211- float child_width, child_height;
3212-
3213- base.allocate (box, flags);
3214-
3215- width = box.x2 - box.x1;
3216- height = box.y2 - box.y1;
3217-
3218- this.recent_file_group.get_preferred_width (height,
3219- out child_width,
3220- out child_width);
3221- this.recent_file_group.get_preferred_height (width,
3222- out child_height,
3223- out child_height);
3224- child_box.x1 = (width - child_width)/2.0f;
3225- child_box.x2 = child_box.x1 + child_width;
3226- child_box.y1 = 0.0f;
3227- child_box.y2 = child_height;
3228- recent_file_group.allocate (child_box, flags);
3229-
3230- child_box.y1 += child_height;
3231- child_box.y2 = child_box.y1 + child_height;
3232- favourite_folder_group.allocate (child_box, flags);
3233-
3234- child_box.y1 += child_height;
3235- child_box.y2 = child_box.y1 + child_height;
3236- downloaded_file_group.allocate (child_box, flags);
3237- }
3238-
3239- public FileView ()
3240- {
3241- recent_file_group = new FileGroup ("Recent Files");
3242- favourite_folder_group = new FileGroup ("Favourite Files");
3243- downloaded_file_group = new FileGroup ("Downloaded Files");
3244-
3245- this.add_actor (recent_file_group);
3246- this.add_actor (favourite_folder_group);
3247- this.add_actor (downloaded_file_group);
3248- this.show_all ();
3249- }
3250-
3251- construct
3252- {
3253- }
3254- }
3255-}
3256
3257=== modified file 'unity-private/places/places-controller.vala'
3258--- unity-private/places/places-controller.vala 2010-04-27 12:04:34 +0000
3259+++ unity-private/places/places-controller.vala 2010-06-24 07:45:42 +0000
3260@@ -28,7 +28,6 @@
3261 * keeping it up-to-date
3262 **/
3263 public Shell shell { get; construct; }
3264- private Model model;
3265 private View view;
3266
3267 public Controller (Shell shell)
3268@@ -38,126 +37,12 @@
3269
3270 construct
3271 {
3272- this.model = new Model ();
3273- this.view = new View (this.model, this.shell);
3274-
3275- Idle.add (this.load_places);
3276- }
3277-
3278- private bool load_places ()
3279- {
3280- var homeplace = new HomePlace ();
3281- homeplace.activated.connect (this.on_place_activated);
3282- this.model.add (homeplace);
3283-
3284- this.load_remote_places ();
3285-
3286- var place = new FakePlace ("Files & Folders", PKGDATADIR + "/files.png");
3287- place.activated.connect (this.on_place_activated);
3288- this.model.add (place);
3289-
3290- return false;
3291- }
3292-
3293- public void load_remote_places ()
3294- {
3295- string placesdir = PKGDATADIR + "/places";
3296-
3297- var dir = GLib.File.new_for_path (placesdir);
3298- try
3299- {
3300- var enumerator = dir.enumerate_children (FILE_ATTRIBUTE_STANDARD_NAME,
3301- 0,
3302- null);
3303- FileInfo file_info;
3304- while ((file_info = enumerator.next_file (null)) != null)
3305- {
3306- var filename = placesdir + "/" + file_info.get_name ();
3307- this.load_place (filename);
3308- }
3309- }
3310- catch (Error error)
3311- {
3312- message (@"Unable to read places from $placesdir: %s", error.message);
3313- }
3314- }
3315-
3316- private void load_place (string filename)
3317- {
3318- string group = "Place";
3319-
3320- var file = new KeyFile ();
3321-
3322- try
3323- {
3324- file.load_from_file (filename,
3325- KeyFileFlags.KEEP_COMMENTS
3326- | KeyFileFlags.KEEP_TRANSLATIONS);
3327-
3328- var name = file.get_string (group, "Name");
3329- var comment = file.get_string (group, "Comment");
3330- var icon_name = file.get_string (group, "Icon");
3331- var dbus_name = file.get_string (group, "DBusName");
3332- var dbus_path = file.get_string (group, "DBusObjectPath");
3333-
3334- Place place = new PlaceProxy (name,
3335- icon_name,
3336- comment,
3337- dbus_name,
3338- dbus_path);
3339-
3340- if (place is Place)
3341- {
3342- place.activated.connect (this.on_place_activated);
3343- this.model.add (place);
3344- }
3345- }
3346- catch (Error e)
3347- {
3348- warning (@"Unable to load place '$filename': %s", e.message);
3349- }
3350- }
3351-
3352- private void on_place_activated (Place place)
3353- {
3354- this.view.set_content_view (place.get_view ());
3355- }
3356-
3357- /* Public Methods */
3358+ view = new View (shell);
3359+ }
3360+
3361 public View get_view ()
3362 {
3363- return this.view;
3364- }
3365- }
3366-
3367- private class HomePlace : Place
3368- {
3369- public HomePlace ()
3370- {
3371- Object (name:"Home",
3372- icon_name:PKGDATADIR + "/home.png",
3373- comment:"");
3374- }
3375-
3376- public override Clutter.Actor get_view ()
3377- {
3378- return new Default.View ();
3379- }
3380- }
3381-
3382- private class FakePlace : Place
3383- {
3384- public FakePlace (string name, string icon_name)
3385- {
3386- Object (name:name, icon_name:icon_name, comment:"");
3387- }
3388-
3389- public override Clutter.Actor get_view ()
3390- {
3391- if (this.name == "Applications")
3392- return new Application.ApplicationView ();
3393-
3394- return new File.FileView ();
3395+ return view;
3396 }
3397 }
3398 }
3399
3400=== added file 'unity-private/places/places-default-renderer-group.vala'
3401--- unity-private/places/places-default-renderer-group.vala 1970-01-01 00:00:00 +0000
3402+++ unity-private/places/places-default-renderer-group.vala 2010-06-24 07:45:42 +0000
3403@@ -0,0 +1,187 @@
3404+/*
3405+ * Copyright (C) 2010 Canonical Ltd
3406+ *
3407+ * This program is free software: you can redistribute it and/or modify
3408+ * it under the terms of the GNU General Public License version 3 as
3409+ * published by the Free Software Foundation.
3410+ *
3411+ * This program is distributed in the hope that it will be useful,
3412+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
3413+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3414+ * GNU General Public License for more details.
3415+ *
3416+ * You should have received a copy of the GNU General Public License
3417+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
3418+ *
3419+ * Authored by Neil Jagdish Patel <neil.patel@canonical.com>
3420+ *
3421+ */
3422+
3423+namespace Unity.Places
3424+{
3425+ public class DefaultRendererGroup : Ctk.Box
3426+ {
3427+ static const float PADDING = 0.0f;
3428+ static const int SPACING = 0;
3429+
3430+ public uint group_id { get; construct; }
3431+ public string group_renderer { get; construct; }
3432+ public string display_name { get; construct; }
3433+ public string icon_hint { get; construct; }
3434+ public Dee.Model results { get; construct; }
3435+
3436+ private Ctk.HBox title_box;
3437+ private Ctk.Image icon;
3438+ private Ctk.Text text;
3439+ private Ctk.Image expander;
3440+ private Ctk.IconView renderer;
3441+
3442+ public DefaultRendererGroup (uint group_id,
3443+ string group_renderer,
3444+ string display_name,
3445+ string icon_hint,
3446+ Dee.Model results)
3447+ {
3448+ Object (group_id:group_id,
3449+ group_renderer:group_renderer,
3450+ display_name:display_name,
3451+ icon_hint:icon_hint,
3452+ results:results);
3453+ }
3454+
3455+ construct
3456+ {
3457+ padding = { PADDING, PADDING, PADDING , PADDING};
3458+ orientation = Ctk.Orientation.VERTICAL;
3459+ spacing = SPACING;
3460+ homogeneous = false;
3461+ hide ();
3462+
3463+ title_box = new Ctk.HBox (12);
3464+ pack (title_box, false, true);
3465+ title_box.show ();
3466+
3467+ icon = new Ctk.Image (24);
3468+ //title_box.pack (icon, false, true);
3469+ icon.show ();
3470+
3471+ text = new Ctk.Text (display_name);
3472+ title_box.pack (text, true, true);
3473+ text.show ();
3474+
3475+ expander = new Ctk.Image (24);
3476+ //title_box.pack (expander, false, true);
3477+ expander.show ();
3478+
3479+ var sep = new Clutter.Rectangle.with_color ({ 255, 255, 255, 255 });
3480+ sep.set_height (1);
3481+ pack (sep, false, false);
3482+ sep.show ();
3483+
3484+ renderer = new Ctk.IconView ();
3485+ renderer.padding = { 12.0f, 0.0f, 0.0f, 0.0f };
3486+ //renderer.spacing = 30;
3487+ pack (renderer, true, true);
3488+ renderer.show ();
3489+
3490+ results.row_added.connect (on_result_added);
3491+ results.row_removed.connect (on_result_removed);
3492+ }
3493+
3494+ private override void get_preferred_height (float for_width,
3495+ out float min_height,
3496+ out float nat_height)
3497+ {
3498+ var children = renderer.get_children ();
3499+ if (children.length () > 0)
3500+ {
3501+ base.get_preferred_height (for_width, out min_height, out nat_height);
3502+ show ();
3503+ }
3504+ else
3505+ {
3506+ min_height = 0;
3507+ nat_height = 0;
3508+ hide ();
3509+ }
3510+ }
3511+
3512+ /*
3513+ * Private Methods
3514+ */
3515+ private void on_result_added (Dee.ModelIter iter)
3516+ {
3517+ if (!interesting (iter))
3518+ return;
3519+
3520+ var button = new Tile ();
3521+ button.set_label (results.get_string (iter, 4));
3522+ unowned Ctk.Text text = button.get_text ();
3523+ text.ellipsize = Pango.EllipsizeMode.END;
3524+ button.get_image ().set_from_stock ("text-x-preview");
3525+ renderer.add_actor (button);
3526+ button.show ();
3527+
3528+ button.set_data<unowned Dee.ModelIter> ("model-iter", iter);
3529+ button.set_data<string> ("uri", "%s".printf (results.get_string (iter, 0)));
3530+ button.clicked.connect ((b) => {
3531+ unowned string uri = b.get_data<unowned string> ("uri");
3532+
3533+ print (@"Launching $uri\n");
3534+ try {
3535+ Gtk.show_uri (Gdk.Screen.get_default (),
3536+ uri,
3537+ 0);
3538+ } catch (GLib.Error e) {
3539+ warning ("Unable to launch: %s", e.message);
3540+ }
3541+ });
3542+
3543+ show ();
3544+ }
3545+
3546+ private void on_result_removed (Dee.ModelIter iter)
3547+ {
3548+ if (!interesting (iter))
3549+ return;
3550+
3551+ var children = renderer.get_children ();
3552+ foreach (Clutter.Actor actor in children)
3553+ {
3554+ unowned Dee.ModelIter i;
3555+
3556+ i = actor.get_data<unowned Dee.ModelIter> ("model-iter");
3557+ if (i == iter)
3558+ {
3559+ actor.destroy ();
3560+ break;
3561+ }
3562+ }
3563+
3564+ if (children.length () <= 1)
3565+ hide ();
3566+ }
3567+
3568+ private bool interesting (Dee.ModelIter iter)
3569+ {
3570+ return (results.get_uint (iter, 2) == group_id);
3571+ }
3572+ }
3573+
3574+ public class Tile : Ctk.Button
3575+ {
3576+ public Tile ()
3577+ {
3578+ Object (orientation:Ctk.Orientation.VERTICAL);
3579+ }
3580+
3581+ private override void get_preferred_width (float for_height,
3582+ out float mwidth,
3583+ out float nwidth)
3584+ {
3585+ mwidth = 160.0f;
3586+ nwidth = 160.0f;
3587+ }
3588+ }
3589+}
3590+
3591
3592=== added file 'unity-private/places/places-default-renderer.vala'
3593--- unity-private/places/places-default-renderer.vala 1970-01-01 00:00:00 +0000
3594+++ unity-private/places/places-default-renderer.vala 2010-06-24 07:45:42 +0000
3595@@ -0,0 +1,86 @@
3596+/*
3597+ * Copyright (C) 2010 Canonical Ltd
3598+ *
3599+ * This program is free software: you can redistribute it and/or modify
3600+ * it under the terms of the GNU General Public License version 3 as
3601+ * published by the Free Software Foundation.
3602+ *
3603+ * This program is distributed in the hope that it will be useful,
3604+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
3605+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3606+ * GNU General Public License for more details.
3607+ *
3608+ * You should have received a copy of the GNU General Public License
3609+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
3610+ *
3611+ * Authored by Neil Jagdish Patel <neil.patel@canonical.com>
3612+ *
3613+ */
3614+
3615+namespace Unity.Places
3616+{
3617+ public class DefaultRenderer : Ctk.ScrollView, Unity.Place.Renderer
3618+ {
3619+ static const float PADDING = 12.0f;
3620+ static const int SPACING = 12;
3621+
3622+ private Ctk.VBox box;
3623+ private Dee.Model groups_model;
3624+ private Dee.Model results_model;
3625+
3626+ public DefaultRenderer ()
3627+ {
3628+ Object ();
3629+ }
3630+
3631+ construct
3632+ {
3633+ padding = { 0.0f, 0.0f, PADDING, 0.0f };
3634+ box = new Ctk.VBox (SPACING);
3635+ box.padding = { PADDING, PADDING, PADDING , PADDING};
3636+ box.homogeneous = false;
3637+ add_actor (box);
3638+ box.show ();
3639+ }
3640+
3641+ /*
3642+ * Private Methods
3643+ */
3644+ public void set_models (Dee.Model groups,
3645+ Dee.Model results,
3646+ Gee.HashMap<string, string> hints)
3647+ {
3648+ groups_model = groups;
3649+ results_model = results;
3650+
3651+ groups_model.row_added.connect (on_group_added);
3652+ groups_model.row_removed.connect (on_group_removed);
3653+ }
3654+
3655+ private void on_group_added (Dee.Model model, Dee.ModelIter iter)
3656+ {
3657+ var group = new DefaultRendererGroup (model.get_position (iter),
3658+ model.get_string (iter, 0),
3659+ model.get_string (iter, 1),
3660+ model.get_string (iter, 2),
3661+ results_model);
3662+ group.set_data<unowned Dee.ModelIter> ("model-iter", iter);
3663+ box.pack (group, false, true);
3664+ }
3665+
3666+ private void on_group_removed (Dee.Model model, Dee.ModelIter iter)
3667+ {
3668+ GLib.List<Clutter.Actor> children = box.get_children ();
3669+ foreach (Clutter.Actor actor in children)
3670+ {
3671+ unowned Dee.ModelIter i = (Dee.ModelIter)actor.get_data<Dee.ModelIter> ("model-iter");
3672+ if (i == iter)
3673+ {
3674+ actor.destroy ();
3675+ break;
3676+ }
3677+ }
3678+ }
3679+ }
3680+}
3681+
3682
3683=== removed file 'unity-private/places/places-model.vala'
3684--- unity-private/places/places-model.vala 2010-01-19 16:10:14 +0000
3685+++ unity-private/places/places-model.vala 1970-01-01 00:00:00 +0000
3686@@ -1,64 +0,0 @@
3687-/*
3688- * Copyright (C) 2009 Canonical Ltd
3689- *
3690- * This program is free software: you can redistribute it and/or modify
3691- * it under the terms of the GNU General Public License version 3 as
3692- * published by the Free Software Foundation.
3693- *
3694- * This program is distributed in the hope that it will be useful,
3695- * but WITHOUT ANY WARRANTY; without even the implied warranty of
3696- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3697- * GNU General Public License for more details.
3698- *
3699- * You should have received a copy of the GNU General Public License
3700- * along with this program. If not, see <http://www.gnu.org/licenses/>.
3701- *
3702- * Authored by Neil Jagdish Patel <neil.patel@canonical.com>
3703- *
3704- */
3705-
3706-using Gee;
3707-
3708-namespace Unity.Places
3709-{
3710- public class Model : Object
3711- {
3712- /**
3713- * Contains a list of places
3714- **/
3715-
3716- /* Properties */
3717- public ArrayList<Place> list;
3718-
3719- /* Signals */
3720- public signal void place_added (Place place);
3721- public signal void place_removed (Place place);
3722- public signal void place_changed (Place place);
3723-
3724- public Model ()
3725- {
3726- Object ();
3727- }
3728-
3729- construct
3730- {
3731- list = new ArrayList<Place> ();
3732- }
3733-
3734- public void add (Place place)
3735- {
3736- this.list.add (place);
3737-
3738- this.place_added (place);
3739- }
3740-
3741- public void remove (Place place)
3742- {
3743- this.list.remove (place);
3744-
3745- this.place_removed (place);
3746- }
3747-
3748- }
3749-}
3750-
3751
3752=== added file 'unity-private/places/places-place-bar.vala'
3753--- unity-private/places/places-place-bar.vala 1970-01-01 00:00:00 +0000
3754+++ unity-private/places/places-place-bar.vala 2010-06-24 07:45:42 +0000
3755@@ -0,0 +1,276 @@
3756+/*
3757+ * Copyright (C) 2010 Canonical Ltd
3758+ *
3759+ * This program is free software: you can redistribute it and/or modify
3760+ * it under the terms of the GNU General Public License version 3 as
3761+ * published by the Free Software Foundation.
3762+ *
3763+ * This program is distributed in the hope that it will be useful,
3764+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
3765+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3766+ * GNU General Public License for more details.
3767+ *
3768+ * You should have received a copy of the GNU General Public License
3769+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
3770+ *
3771+ * Authored by Neil Jagdish Patel <neil.patel@canonical.com>
3772+ *
3773+ */
3774+
3775+namespace Unity.Places
3776+{
3777+ public class PlaceBar : Ctk.Box
3778+ {
3779+ /* Properties */
3780+ public Shell shell { get; construct; }
3781+ public PlaceModel model { get; set construct; }
3782+
3783+ private PlaceBarBackground bg;
3784+ private Ctk.EffectGlow glow;
3785+ private PlaceEntryView active_view = null;
3786+
3787+ public signal void entry_view_activated (PlaceEntryView view, int x);
3788+
3789+ public PlaceBar (Shell shell, PlaceModel model)
3790+ {
3791+ Object (shell:shell,
3792+ model:model,
3793+ orientation:Ctk.Orientation.HORIZONTAL,
3794+ homogeneous:false,
3795+ spacing:0);
3796+ }
3797+
3798+ construct
3799+ {
3800+ bg = new PlaceBarBackground (shell);
3801+ set_background (bg);
3802+ bg.show ();
3803+
3804+ /* Enable once clutk bug is fixed */
3805+ glow = new Ctk.EffectGlow ();
3806+ glow.set_color ({ 255, 255, 255, 255 });
3807+ glow.set_factor (1.0f);
3808+ glow.set_margin (5);
3809+ add_effect (glow);
3810+
3811+ foreach (Place place in model)
3812+ {
3813+ var view = new PlaceView (place);
3814+ pack (view, false, true);
3815+ view.show ();
3816+
3817+ view.entry_activated.connect (on_entry_activated);
3818+ }
3819+ model.place_added.connect ((p) => {
3820+ var view = new PlaceView (p);
3821+ pack (view, false, true);
3822+ view.show ();
3823+
3824+ view.entry_activated.connect (on_entry_activated);
3825+ });
3826+ }
3827+
3828+ private override void allocate (Clutter.ActorBox box,
3829+ Clutter.AllocationFlags flags)
3830+ {
3831+ padding = {
3832+ 0.0f,
3833+ (float)shell.get_indicators_width (),
3834+ 0.0f,
3835+ (float)shell.get_launcher_width_foobar ()};
3836+
3837+ base.allocate (box, flags);
3838+ }
3839+
3840+ private override void get_preferred_height (float for_width,
3841+ out float min_height,
3842+ out float nat_height)
3843+ {
3844+ min_height = 56.0f;
3845+ nat_height = 56.0f;
3846+ }
3847+
3848+ private void on_entry_activated (PlaceView view, PlaceEntryView entry_view)
3849+ {
3850+ if (active_view == entry_view)
3851+ return;
3852+
3853+ if (active_view is PlaceEntryView)
3854+ {
3855+ active_view.entry.active = false;
3856+ }
3857+
3858+ active_view = entry_view;
3859+ active_view.entry.active = true;
3860+ bg.entry_position = (int)(view.x + entry_view.x);
3861+
3862+ glow.set_invalidate_effect_cache (true);
3863+
3864+ entry_view_activated (entry_view,
3865+ bg.entry_position + (PlaceEntryView.WIDTH/2));
3866+ }
3867+ }
3868+
3869+ public class PlaceBarBackground : Clutter.CairoTexture
3870+ {
3871+ public const string BG = "/usr/share/unity/dash_background.png";
3872+
3873+ public Shell shell { get; construct; }
3874+
3875+ private int last_width = 0;
3876+ private int last_height = 0;
3877+
3878+ Gdk.Pixbuf tile = null;
3879+
3880+ private int _entry_position = 0;
3881+ public int entry_position {
3882+ get { return _entry_position; }
3883+ set {
3884+ if (_entry_position != value)
3885+ {
3886+ _entry_position = value;
3887+ update_background ();
3888+ }
3889+ }
3890+ }
3891+
3892+ public PlaceBarBackground (Shell shell)
3893+ {
3894+ Object (shell:shell);
3895+ }
3896+
3897+ construct
3898+ {
3899+ try
3900+ {
3901+ /* I've loaded this in directly and not through theme due to use
3902+ * not having a good loader for pixbufs from the theme right now
3903+ */
3904+ tile = new Gdk.Pixbuf.from_file (BG);
3905+ }
3906+ catch (Error e)
3907+ {
3908+ warning ("Unable to load dash background");
3909+ }
3910+ }
3911+
3912+ private override void allocate (Clutter.ActorBox box,
3913+ Clutter.AllocationFlags flags)
3914+ {
3915+ int width = (int)(box.x2 - box.x1);
3916+ int height = (int)(box.y2 - box.y1);
3917+
3918+ base.allocate (box, flags);
3919+
3920+ if (width != last_width || height != last_height)
3921+ {
3922+ last_width = width;
3923+ last_height = height;
3924+
3925+ Timeout.add (0, update_background);
3926+ }
3927+ }
3928+
3929+ private bool update_background ()
3930+ {
3931+ Cairo.Context cr;
3932+
3933+ set_surface_size (last_width, last_height);
3934+
3935+ cr = create ();
3936+
3937+ cr.set_operator (Cairo.Operator.CLEAR);
3938+ cr.paint ();
3939+
3940+ cr.set_operator (Cairo.Operator.OVER);
3941+ cr.set_line_width (1.5);
3942+ cr.set_source_rgba (1.0, 1.0, 1.0, 0.0);
3943+
3944+ cr.translate (-0.5, -0.5);
3945+
3946+ /* Basic variables */
3947+ var x = -1;
3948+ var y = -1;
3949+ var width = last_width + 2;
3950+ var height = last_height;
3951+ var radius = 13;
3952+ var launcher_width = shell.get_launcher_width_foobar ();
3953+ var panel_height = shell.get_panel_height_foobar ();
3954+ var entry_width = PlaceEntryView.WIDTH;
3955+ var top_padding = 3;
3956+
3957+ /* Draw the top outline */
3958+ cr.move_to (x, y);
3959+ cr.line_to (width, y);
3960+ cr.line_to (width, height);
3961+
3962+ if (entry_position != 0)
3963+ {
3964+ /* This is when we have an active place entry */
3965+ var x1 = entry_position;
3966+ var x2 = entry_position + entry_width;
3967+
3968+ cr.line_to (x2 + radius, height);
3969+ cr.curve_to (x2, height,
3970+ x2, height,
3971+ x2, height - radius);
3972+ cr.line_to (x2, radius + top_padding);
3973+ cr.curve_to (x2, top_padding,
3974+ x2, top_padding,
3975+ x2 - radius, top_padding);
3976+ cr.line_to (x1 + radius, top_padding);
3977+ cr.curve_to (x1, top_padding,
3978+ x1, top_padding,
3979+ x1, top_padding + radius);
3980+
3981+ if (x1 < launcher_width + entry_width) /* first entry */
3982+ {
3983+ cr.line_to (launcher_width, panel_height);
3984+ }
3985+ else
3986+ {
3987+ cr.line_to (x1, height - radius);
3988+ cr.curve_to (x1, height,
3989+ x1, height,
3990+ x1-radius, height);
3991+ cr.line_to (launcher_width + radius, height);
3992+ cr.curve_to (launcher_width, height,
3993+ launcher_width, height,
3994+ launcher_width, height - radius);
3995+ cr.line_to (launcher_width, panel_height);
3996+ }
3997+ }
3998+ else
3999+ {
4000+ cr.line_to (launcher_width + radius, height);
4001+ cr.curve_to (launcher_width, height,
4002+ launcher_width, height,
4003+ launcher_width, height - radius);
4004+ cr.line_to (launcher_width, panel_height);
4005+ }
4006+
4007+ cr.line_to (x, panel_height);
4008+ cr.close_path ();
4009+
4010+ cr.stroke_preserve ();
4011+ cr.clip_preserve ();
4012+
4013+ /* Tile the background */
4014+ if (tile is Gdk.Pixbuf)
4015+ {
4016+ Gdk.cairo_set_source_pixbuf (cr, tile, 0, 0);
4017+ var pat = cr.get_source ();
4018+ pat.set_extend (Cairo.Extend.REPEAT);
4019+ cr.paint_with_alpha (0.25);
4020+ }
4021+
4022+ /* Add the outline */
4023+ cr.reset_clip ();
4024+ cr.set_source_rgba (1.0, 1.0, 1.0, 0.6);
4025+ cr.stroke ();
4026+
4027+ return false;
4028+ }
4029+ }
4030+}
4031+
4032
4033=== added file 'unity-private/places/places-place-entry-view.vala'
4034--- unity-private/places/places-place-entry-view.vala 1970-01-01 00:00:00 +0000
4035+++ unity-private/places/places-place-entry-view.vala 2010-06-24 07:45:42 +0000
4036@@ -0,0 +1,51 @@
4037+/*
4038+ * Copyright (C) 2010 Canonical Ltd
4039+ *
4040+ * This program is free software: you can redistribute it and/or modify
4041+ * it under the terms of the GNU General Public License version 3 as
4042+ * published by the Free Software Foundation.
4043+ *
4044+ * This program is distributed in the hope that it will be useful,
4045+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
4046+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4047+ * GNU General Public License for more details.
4048+ *
4049+ * You should have received a copy of the GNU General Public License
4050+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
4051+ *
4052+ * Authored by Neil Jagdish Patel <neil.patel@canonical.com>
4053+ *
4054+ */
4055+
4056+namespace Unity.Places
4057+{
4058+ public class PlaceEntryView : Ctk.Image
4059+ {
4060+ static const int WIDTH = 80;
4061+
4062+ /* Properties */
4063+ public PlaceEntry entry { get; construct; }
4064+
4065+ public PlaceEntryView (PlaceEntry entry)
4066+ {
4067+ Object (entry:entry,
4068+ size:48,
4069+ reactive:true);
4070+
4071+ set_from_filename (entry.icon);
4072+ }
4073+
4074+ construct
4075+ {
4076+ }
4077+
4078+ private override void get_preferred_width (float for_height,
4079+ out float min_width,
4080+ out float nat_width)
4081+ {
4082+ min_width = (float) WIDTH;
4083+ nat_width = (float) WIDTH;
4084+ }
4085+ }
4086+}
4087+
4088
4089=== added file 'unity-private/places/places-place-entry.vala'
4090--- unity-private/places/places-place-entry.vala 1970-01-01 00:00:00 +0000
4091+++ unity-private/places/places-place-entry.vala 2010-06-24 07:45:42 +0000
4092@@ -0,0 +1,408 @@
4093+/*
4094+ * Copyright (C) 2010 Canonical Ltd
4095+ *
4096+ * This program is free software: you can redistribute it and/or modify
4097+ * it under the terms of the GNU General Public License version 3 as
4098+ * published by the Free Software Foundation.
4099+ *
4100+ * This program is distributed in the hope that it will be useful,
4101+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
4102+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4103+ * GNU General Public License for more details.
4104+ *
4105+ * You should have received a copy of the GNU General Public License
4106+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
4107+ *
4108+ * Authored by Neil Jagdish Patel <neil.patel@canonical.com>
4109+ *
4110+ */
4111+
4112+namespace Unity.Places
4113+{
4114+ /**
4115+ * Represents a PlaceEntry through a .place file ("offline") and then through
4116+ * DBus ("online").
4117+ **/
4118+ public class PlaceEntry : Object
4119+ {
4120+ /* FIXME: Use what's in libunity. We only need this so vala allows us to
4121+ * connect to the signal
4122+ */
4123+ public struct RendererInfo
4124+ {
4125+ string default_renderer;
4126+ string groups_model;
4127+ string results_model;
4128+ HashTable<string, string> renderer_hints;
4129+ }
4130+
4131+ /*
4132+ * Properties
4133+ */
4134+ public string? dbus_name { get; construct; }
4135+ public string? dbus_path { get; construct; }
4136+ public string name { get; construct set; }
4137+ public string icon { get; construct set; }
4138+ public string description { get; construct set; }
4139+
4140+ public uint position { get; set; }
4141+ public string[] mimetypes { get; set; }
4142+ public bool sensitive { get; set; }
4143+
4144+ public Gee.HashMap<string, string> hints { get; set; }
4145+
4146+ /* Whether the Entry is available on the bus, this is only when we want to
4147+ * do optimisations for startup (showing the entries before actually
4148+ * starting the daemon. We can also abuse this for testing :)
4149+ */
4150+ public bool online { get; construct set; }
4151+
4152+ /* This is loaded from the desktop file, isn't useful when the entry
4153+ * is online
4154+ */
4155+ public bool show_global { get; construct set; }
4156+ public bool show_entry { get; construct set; }
4157+
4158+ /* This is relayed to the service, in case it needs to do something special
4159+ * when it's activated
4160+ */
4161+ private bool _active = false;
4162+ public bool active {
4163+ get { return _active; }
4164+ set {
4165+ if (_active != value)
4166+ {
4167+ _active = value;
4168+ service.set_active (_active);
4169+ }
4170+ }
4171+ }
4172+
4173+ /* We store the name of the sections model, and we provide the actual
4174+ * model too. The reason for this is that for testing, we can easily inject
4175+ * a fake model into a fake entry and test the views. It also keeps things
4176+ * cleaner for the views (they aren't creating their own models).
4177+ */
4178+ public string sections_model_name { get; set; }
4179+ private Dee.Model? _sections_model = null;
4180+ public Dee.Model? sections_model {
4181+ get {
4182+ if (_sections_model is Dee.Model == false)
4183+ {
4184+ if (sections_model_name != null)
4185+ {
4186+ _sections_model = new Dee.SharedModel.with_name (sections_model_name);
4187+ (_sections_model as Dee.SharedModel).connect ();
4188+ }
4189+ }
4190+ return _sections_model;
4191+ }
4192+ set {
4193+ _sections_model = value;
4194+ }
4195+ }
4196+
4197+ /* Entry rendering info */
4198+ public string entry_renderer_name;
4199+
4200+ public string entry_groups_model_name;
4201+ private Dee.Model? _entry_groups_model;
4202+ public Dee.Model? entry_groups_model {
4203+ get {
4204+ if (_entry_groups_model is Dee.Model == false)
4205+ {
4206+ if (entry_groups_model_name != null)
4207+ {
4208+ _entry_groups_model = new Dee.SharedModel.with_name (entry_groups_model_name);
4209+ (_entry_groups_model as Dee.SharedModel).connect ();
4210+ }
4211+ }
4212+ return _entry_groups_model;
4213+ }
4214+ set {
4215+ _entry_groups_model = value;
4216+ }
4217+ }
4218+
4219+ public string entry_results_model_name;
4220+ private Dee.Model? _entry_results_model;
4221+ public Dee.Model? entry_results_model {
4222+ get {
4223+ if (_entry_results_model is Dee.Model == false)
4224+ {
4225+ if (entry_results_model_name != null)
4226+ {
4227+ _entry_results_model = new Dee.SharedModel.with_name (entry_results_model_name);
4228+ (_entry_results_model as Dee.SharedModel).connect ();
4229+ }
4230+ }
4231+ return _entry_results_model;
4232+ }
4233+ set {
4234+ _entry_results_model = value;
4235+ }
4236+ }
4237+
4238+ public Gee.HashMap<string, string>? entry_renderer_hints;
4239+
4240+ /* Global rendering info */
4241+ public string global_renderer_name;
4242+
4243+ public string global_groups_model_name;
4244+ private Dee.Model? _global_groups_model;
4245+ public Dee.Model? global_groups_model {
4246+ get {
4247+ if (_global_groups_model is Dee.Model == false)
4248+ {
4249+ if (global_groups_model_name != null)
4250+ {
4251+ _global_groups_model = new Dee.SharedModel.with_name (global_groups_model_name);
4252+ (_global_groups_model as Dee.SharedModel).connect ();
4253+ }
4254+ }
4255+ return _global_groups_model;
4256+ }
4257+ set {
4258+ _global_groups_model = value;
4259+ }
4260+ }
4261+
4262+ public string global_results_model_name;
4263+ private Dee.Model? _global_results_model;
4264+ public Dee.Model? global_results_model {
4265+ get {
4266+ if (_global_results_model is Dee.Model == false)
4267+ {
4268+ if (global_results_model_name != null)
4269+ {
4270+ _global_results_model = new Dee.SharedModel.with_name (global_results_model_name);
4271+ (_global_results_model as Dee.SharedModel).connect ();
4272+ }
4273+ }
4274+ return _global_results_model;
4275+ }
4276+ set {
4277+ _global_results_model = value;
4278+ }
4279+ }
4280+
4281+ public Gee.HashMap<string, string>? global_renderer_hints;
4282+
4283+ /* Our connection to the place-entry over dbus */
4284+ private DBus.Connection? connection;
4285+ private dynamic DBus.Object? service;
4286+
4287+ /*
4288+ * Signals
4289+ */
4290+ public signal void updated ();
4291+ public signal void renderer_info_changed ();
4292+
4293+ /*
4294+ * Constructors
4295+ */
4296+ public PlaceEntry (string dbus_name, string dbus_path)
4297+ {
4298+ Object (dbus_name:dbus_name, dbus_path:dbus_path);
4299+ }
4300+
4301+ public PlaceEntry.with_info (string dbus_name,
4302+ string dbus_path,
4303+ string name,
4304+ string icon,
4305+ string description,
4306+ bool show_global,
4307+ bool show_entry)
4308+ {
4309+ Object (dbus_name:dbus_name,
4310+ dbus_path:dbus_path,
4311+ name:name,
4312+ icon:icon,
4313+ description:description,
4314+ show_global:show_global,
4315+ show_entry:show_entry);
4316+ }
4317+
4318+ construct
4319+ {
4320+ online = false;
4321+ }
4322+
4323+ /*
4324+ * Public Methods
4325+ */
4326+ public void update_info (GLib.ValueArray value_array)
4327+ requires (value_array.n_values == 10)
4328+ {
4329+ /* Un-marshal the array and update our information */
4330+ name = value_array.get_nth (1).get_string ();
4331+ icon = value_array.get_nth (2).get_string ();
4332+ position = value_array.get_nth (3).get_uint ();
4333+
4334+ /* FIXME: Unmarshall string[] mimetypes */
4335+
4336+ sensitive = value_array.get_nth (5).get_boolean ();
4337+ sections_model_name = value_array.get_nth (6).get_string ();
4338+
4339+ HashTable<string, string> hash = (HashTable<string, string>)(value_array.get_nth (7).get_boxed ());
4340+ if (hints != null)
4341+ hints = map_from_hash (hash);
4342+ else
4343+ hints = null;
4344+
4345+ /* Unmarshal the Entry RenderInfo */
4346+ unowned ValueArray ea = (ValueArray)(value_array.get_nth (8).get_boxed ());
4347+ if (ea != null)
4348+ {
4349+ entry_renderer_name = ea.get_nth (0).get_string ();
4350+
4351+ var str = ea.get_nth (1).get_string ();
4352+ if (entry_groups_model_name != str)
4353+ {
4354+ entry_groups_model_name = str;
4355+ entry_groups_model = null;
4356+ }
4357+
4358+ str = ea.get_nth (2).get_string ();
4359+ if (entry_results_model_name != str)
4360+ {
4361+ entry_results_model_name = str;
4362+ entry_results_model = null;
4363+ }
4364+
4365+ hash = (HashTable<string, string>)(ea.get_nth (3).get_boxed ());
4366+ if (hash != null)
4367+ entry_renderer_hints = map_from_hash (hash);
4368+ else
4369+ entry_renderer_hints = null;
4370+ }
4371+
4372+ /* Unmarshal the Global RenderInfo */
4373+ unowned ValueArray ga = (ValueArray)(value_array.get_nth (9).get_boxed ());
4374+ if (ga != null)
4375+ {
4376+ global_renderer_name = ga.get_nth (0).get_string ();
4377+
4378+ var str = ga.get_nth (1).get_string ();
4379+ if (global_groups_model_name != str)
4380+ {
4381+ global_groups_model_name = str;
4382+ global_groups_model = null;
4383+ }
4384+
4385+ str = ga.get_nth (2).get_string ();
4386+ if (global_results_model_name != str)
4387+ {
4388+ global_results_model_name = str;
4389+ global_results_model = null;
4390+ }
4391+
4392+ hash = (HashTable<string, string>)(ga.get_nth (3).get_boxed ());
4393+ if (hash != null)
4394+ global_renderer_hints = map_from_hash (hash);
4395+ else
4396+ global_renderer_hints = null;
4397+ }
4398+
4399+ updated ();
4400+ renderer_info_changed ();
4401+ }
4402+
4403+ public new void connect ()
4404+ {
4405+ if (online == true)
4406+ return;
4407+
4408+ /* Grab the entry off DBus */
4409+ try {
4410+ connection = DBus.Bus.get (DBus.BusType.SESSION);
4411+ service = connection.get_object (dbus_name,
4412+ dbus_path,
4413+ "com.canonical.Unity.PlaceEntry");
4414+ } catch (Error e) {
4415+ warning (@"Unable to connect to $dbus_path on $dbus_name: %s",
4416+ e.message);
4417+ return;
4418+ }
4419+
4420+ service.RendererInfoChanged.connect (on_renderer_info_changed);
4421+
4422+ online = true;
4423+ }
4424+
4425+ public void set_search (string search, HashTable<string, string> hints)
4426+ {
4427+ uint id;
4428+
4429+ id = service.set_search (search, hints);
4430+ }
4431+
4432+ public void set_active_section (uint section_id)
4433+ {
4434+ service.set_active_section (section_id);
4435+ }
4436+
4437+ public void set_global_search (string search,
4438+ HashTable<string, string> hints)
4439+ {
4440+ service.set_global_search (search, hints);
4441+ }
4442+
4443+ /*
4444+ * Private Methods
4445+ */
4446+
4447+ private void on_renderer_info_changed (dynamic DBus.Object dbus_object,
4448+ RendererInfo info)
4449+ {
4450+ RendererInfo *i = &info;
4451+ unowned ValueArray ea = (ValueArray)i;
4452+
4453+ if (ea != null)
4454+ {
4455+ entry_renderer_name = ea.get_nth (0).get_string ();
4456+
4457+ var str = ea.get_nth (1).get_string ();
4458+ if (entry_groups_model_name != str)
4459+ {
4460+ entry_groups_model_name = str;
4461+ entry_groups_model = null;
4462+ }
4463+
4464+ str = ea.get_nth (2).get_string ();
4465+ if (entry_results_model_name != str)
4466+ {
4467+ entry_results_model_name = str;
4468+ entry_results_model = null;
4469+ }
4470+
4471+ HashTable<string, string>hash = (HashTable<string, string>)(ea.get_nth (3).get_boxed ());
4472+ if (hash != null)
4473+ entry_renderer_hints = map_from_hash (hash);
4474+ else
4475+ entry_renderer_hints = null;
4476+
4477+ updated ();
4478+ renderer_info_changed ();
4479+ }
4480+ }
4481+
4482+ private Gee.HashMap<string, string> map_from_hash (HashTable<string, string>hash)
4483+ {
4484+ Gee.HashMap<string, string> map = new Gee.HashMap<string, string> ();
4485+
4486+ HashTableIter<string, string> iter = HashTableIter<string, string> (hash);
4487+ unowned void* key, val;
4488+ while (iter.next (out key, out val))
4489+ {
4490+ unowned string k = (string)key;
4491+ unowned string v = (string)val;
4492+
4493+ map[k] = v;
4494+ }
4495+
4496+ return map;
4497+ }
4498+ }
4499+}
4500+
4501
4502=== added file 'unity-private/places/places-place-model.vala'
4503--- unity-private/places/places-place-model.vala 1970-01-01 00:00:00 +0000
4504+++ unity-private/places/places-place-model.vala 2010-06-24 07:45:42 +0000
4505@@ -0,0 +1,155 @@
4506+/*
4507+ * Copyright (C) 2010 Canonical Ltd
4508+ *
4509+ * This program is free software: you can redistribute it and/or modify
4510+ * it under the terms of the GNU General Public License version 3 as
4511+ * published by the Free Software Foundation.
4512+ *
4513+ * This program is distributed in the hope that it will be useful,
4514+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
4515+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4516+ * GNU General Public License for more details.
4517+ *
4518+ * You should have received a copy of the GNU General Public License
4519+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
4520+ *
4521+ * Authored by Neil Jagdish Patel <neil.patel@canonical.com>
4522+ *
4523+ */
4524+
4525+namespace Unity.Places
4526+{
4527+ /**
4528+ * PlaceModel:
4529+ *
4530+ * Contains the loaded Place objects. Abstract class so views can be
4531+ * tested with fake model
4532+ **/
4533+ public abstract class PlaceModel : Gee.ArrayList<Place>
4534+ {
4535+ public signal void place_added (Place place);
4536+ }
4537+
4538+
4539+ /**
4540+ * PlaceFileModel:
4541+ *
4542+ * Reads in .place files and creates the offline model, ready for representing
4543+ * to the user without actually initing any of the places
4544+ **/
4545+ public class PlaceFileModel : PlaceModel
4546+ {
4547+ /* Properties */
4548+ public string directory { get; construct; }
4549+ public bool async { get; construct; }
4550+
4551+ /* Constructors */
4552+ public PlaceFileModel ()
4553+ {
4554+ Object (directory:PKGDATADIR + "/places", async:true);
4555+ }
4556+
4557+ /* Allows loading places files from a non-install directory */
4558+ public PlaceFileModel.with_directory (string _directory)
4559+ {
4560+ Object (directory: _directory, async:false);
4561+ }
4562+
4563+ construct
4564+ {
4565+ /* Start asyncly reading in place files */
4566+ if (async)
4567+ load_place_files.begin ();
4568+ else
4569+ load_place_files_sync ();
4570+ }
4571+
4572+ /* Private Methods */
4573+
4574+ /*
4575+ * Read in all the .place files from the directory and convert them to
4576+ * Place objects, with the initial set of Entries, if that information
4577+ * was included inside the .place file
4578+ */
4579+ private async void load_place_files ()
4580+ {
4581+ var dir = File.new_for_path (directory);
4582+ try {
4583+ var e = yield dir.enumerate_children_async (FILE_ATTRIBUTE_STANDARD_NAME,
4584+ 0,
4585+ Priority.DEFAULT, null);
4586+ while (true)
4587+ {
4588+ var files = yield e.next_files_async (10, Priority.DEFAULT, null);
4589+ if (files == null)
4590+ break;
4591+
4592+ foreach (var info in files)
4593+ {
4594+ if (info.get_name ().has_suffix (".place") == false)
4595+ continue;
4596+
4597+ /* FIXME: load_place needs to be async */
4598+ var place = load_place (Path.build_filename (directory,
4599+ info.get_name ()));
4600+ if (place is Place)
4601+ {
4602+ place.connect ();
4603+ (place as GLib.Object).ref ();
4604+ add (place);
4605+ place_added (place);
4606+ }
4607+ }
4608+ }
4609+
4610+ } catch (Error error) {
4611+ warning (@"Unable to read place files from directory '$directory': %s",
4612+ error.message);
4613+ }
4614+ }
4615+
4616+ private void load_place_files_sync ()
4617+ {
4618+ var dir = File.new_for_path (directory);
4619+ try {
4620+ var e = dir.enumerate_children (FILE_ATTRIBUTE_STANDARD_NAME, 0, null);
4621+ FileInfo info;
4622+ while ((info = e.next_file (null)) != null)
4623+ {
4624+ string leaf = info.get_name ();
4625+ if (leaf.has_suffix (".place") == false)
4626+ continue;
4627+
4628+ var place = load_place (Path.build_filename (directory, leaf));
4629+ if (place is Place)
4630+ {
4631+ add (place);
4632+ place_added (place);
4633+ }
4634+ }
4635+
4636+ } catch (Error error) {
4637+ warning (@"Unable to read place files from directory '$directory': %s",
4638+ error.message);
4639+ }
4640+ }
4641+
4642+ /*
4643+ * Reads in the place file (which is a key file) and creates and inits
4644+ * a UnityPlacesPlace object to represent it.
4645+ */
4646+ private Place? load_place (string path)
4647+ {
4648+ var file = new KeyFile ();
4649+ try {
4650+ file.load_from_file (path, KeyFileFlags.NONE);
4651+
4652+ return Place.new_from_keyfile (file, path);
4653+
4654+ } catch (Error e) {
4655+ warning (@"Unable to load place file '$path': %s", e.message);
4656+ return null;
4657+ }
4658+ }
4659+ }
4660+}
4661
4662=== removed file 'unity-private/places/places-place-proxy.vala'
4663--- unity-private/places/places-place-proxy.vala 2010-04-28 12:19:01 +0000
4664+++ unity-private/places/places-place-proxy.vala 1970-01-01 00:00:00 +0000
4665@@ -1,119 +0,0 @@
4666-/*
4667- * Copyright (C) 2010 Canonical Ltd
4668- *
4669- * This program is free software: you can redistribute it and/or modify
4670- * it under the terms of the GNU General Public License version 3 as
4671- * published by the Free Software Foundation.
4672- *
4673- * This program is distributed in the hope that it will be useful,
4674- * but WITHOUT ANY WARRANTY; without even the implied warranty of
4675- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4676- * GNU General Public License for more details.
4677- *
4678- * You should have received a copy of the GNU General Public License
4679- * along with this program. If not, see <http://www.gnu.org/licenses/>.
4680- *
4681- * Authored by Neil Jagdish Patel <neil.patel@canonical.com>
4682- *
4683- */
4684-
4685-namespace Unity.Places
4686-{
4687- public class PlaceProxy : Place
4688- {
4689- /**
4690- * Represents a Remote Place (icon, view etc).
4691- **/
4692-
4693- /* Properties */
4694- public string dbus_name { get; construct; }
4695- public string dbus_path { get; construct; }
4696-
4697- private DBus.Connection? conn;
4698- private dynamic DBus.Object? service;
4699-
4700- private Ctk.Box view;
4701-
4702- public PlaceProxy (string name,
4703- string icon_name,
4704- string comment,
4705- string dbus_name,
4706- string dbus_path)
4707- {
4708- Object (name:name,
4709- icon_name:PKGDATADIR + "/applications.png",
4710- comment:comment,
4711- dbus_name:dbus_name,
4712- dbus_path:dbus_path);
4713- }
4714-
4715- construct
4716- {
4717-
4718- }
4719-
4720- private void setup_service ()
4721- {
4722- try
4723- {
4724- // FIXME: Sync dbus calls all over the place!
4725- this.conn = DBus.Bus.get (DBus.BusType.SESSION);
4726- this.service = conn.get_object (this.dbus_name,
4727- this.dbus_path,
4728- "com.canonical.Unity.Place");
4729-
4730- this.service.ViewChanged += this.on_view_changed;
4731-
4732- this.service.set_active (false);
4733- }
4734- catch (Error e)
4735- {
4736- warning ("Unable to start service %s: %s",
4737- this.dbus_name,
4738- e.message);
4739- }
4740- }
4741-
4742- private void on_view_changed (dynamic DBus.Object s,
4743- HashTable<string, string> view_properties)
4744- {
4745- /**
4746- * This is just to get something working, in the future they'll be a
4747- * view_loader class that handles loading internal and extenal views
4748- * (from models), and doing the string => GType conversion. Views just
4749- * need to implement PlaceView interface
4750- **/
4751- var view_name = view_properties.lookup ("view-name");
4752-
4753- debug (@"View changed: $view_name");
4754- if (view_name == "ResultsView")
4755- {
4756- var new_view = new Views.ResultsView ();
4757- new_view.init_with_properties (view_properties);
4758-
4759- this.view.add_actor (new_view);
4760- }
4761- else
4762- {
4763- warning (@"Unknown view: $view_name");
4764- }
4765- }
4766-
4767- public override Clutter.Actor get_view ()
4768- {
4769- /* Dump this in here for the moment */
4770- if (!(this.service is DBus.Object))
4771- {
4772- this.setup_service ();
4773- }
4774-
4775- if (!(this.view is Ctk.Box))
4776- {
4777- this.view = new Ctk.VBox (0);
4778- }
4779-
4780- return this.view;
4781- }
4782- }
4783-}
4784-
4785
4786=== added file 'unity-private/places/places-place-search-bar.vala'
4787--- unity-private/places/places-place-search-bar.vala 1970-01-01 00:00:00 +0000
4788+++ unity-private/places/places-place-search-bar.vala 2010-06-24 07:45:42 +0000
4789@@ -0,0 +1,299 @@
4790+/*
4791+ * Copyright (C) 2010 Canonical Ltd
4792+ *
4793+ * This program is free software: you can redistribute it and/or modify
4794+ * it under the terms of the GNU General Public License version 3 as
4795+ * published by the Free Software Foundation.
4796+ *
4797+ * This program is distributed in the hope that it will be useful,
4798+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
4799+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4800+ * GNU General Public License for more details.
4801+ *
4802+ * You should have received a copy of the GNU General Public License
4803+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
4804+ *
4805+ * Authored by Neil Jagdish Patel <neil.patel@canonical.com>
4806+ *
4807+ */
4808+
4809+namespace Unity.Places
4810+{
4811+ public class PlaceSearchBar : Ctk.Box
4812+ {
4813+ static const int SPACING = 10;
4814+ static const int RANDOM_TEXT_WIDTH = 400;
4815+
4816+ /* Properties */
4817+ private PlaceEntry? active_entry = null;
4818+
4819+ private PlaceSearchBarBackground bg;
4820+
4821+ private PlaceSearchEntry entry;
4822+ private PlaceSearchSectionsBar sections;
4823+
4824+ public PlaceSearchBar ()
4825+ {
4826+ Object (orientation:Ctk.Orientation.HORIZONTAL,
4827+ homogeneous:false,
4828+ spacing:8);
4829+ }
4830+
4831+ construct
4832+ {
4833+ padding = {
4834+ SPACING * 2.0f,
4835+ SPACING * 1.0f,
4836+ SPACING * 1.0f,
4837+ SPACING * 1.0f
4838+ };
4839+
4840+ entry = new PlaceSearchEntry ();
4841+ pack (entry, true, true);
4842+ entry.show ();
4843+ entry.text_changed.connect (on_search_text_changed);
4844+
4845+ sections = new PlaceSearchSectionsBar ();
4846+ pack (sections, false, true);
4847+ entry.show ();
4848+
4849+ bg = new PlaceSearchBarBackground (entry);
4850+ set_background (bg);
4851+ bg.show ();
4852+ }
4853+
4854+ private override void allocate (Clutter.ActorBox box,
4855+ Clutter.AllocationFlags flags)
4856+ {
4857+ float ex = entry.x;
4858+ float ewidth = entry.width;
4859+
4860+ base.allocate (box, flags);
4861+
4862+ if (entry.x != ex || entry.width != ewidth)
4863+ {
4864+ /* After discussion with upstream Clutter guys, it seems like the
4865+ * warning when resizing a CairoTexture is a bug in Clutter, however
4866+ * the fix is not trivial, so it was suggested to use a 0-sec timeout.
4867+ * We don't use an idle as it seems to have a lower priority and the
4868+ * user will see a jump between states, the 0-sec timeout seems to be
4869+ * dealt with immediately in the text iteration.
4870+ */
4871+ Timeout.add (0, bg.update_background);
4872+ }
4873+ }
4874+
4875+ private override void get_preferred_height (float for_width,
4876+ out float min_height,
4877+ out float nat_height)
4878+ {
4879+ float mheight, nheight;
4880+
4881+ entry.get_preferred_height (RANDOM_TEXT_WIDTH, out mheight, out nheight);
4882+ min_height = mheight + SPACING * 3;
4883+ nat_height = nheight + SPACING * 3;
4884+ }
4885+
4886+ private void on_search_text_changed (string text)
4887+ {
4888+ if (active_entry is PlaceEntry)
4889+ {
4890+ var hints = new HashTable<string, string> (str_hash, str_equal);
4891+ active_entry.set_search (text, hints);
4892+ }
4893+ }
4894+
4895+ /*
4896+ * Public Methods
4897+ */
4898+ public void set_active_entry_view (PlaceEntry entry, int x)
4899+ {
4900+ active_entry = entry;
4901+ bg.entry_position = x;
4902+ sections.set_active_entry (entry);
4903+ }
4904+ }
4905+
4906+ public class PlaceSearchBarBackground : Ctk.Bin
4907+ {
4908+ /* This is a full path right now as we get this asset from the assets
4909+ * package that is not installable (easily) normally. Will change to
4910+ * Config.DATADIR as soon as this is fixed in the other package.
4911+ */
4912+ public const string BG = "/usr/share/unity/dash_background.png";
4913+
4914+ private int last_width = 0;
4915+ private int last_height = 0;
4916+
4917+ Gdk.Pixbuf tile = null;
4918+
4919+ private int _entry_position = 0;
4920+ public int entry_position {
4921+ get { return _entry_position; }
4922+ set {
4923+ if (_entry_position != value)
4924+ {
4925+ _entry_position = value;
4926+ update_background ();
4927+ }
4928+ }
4929+ }
4930+
4931+ private Clutter.CairoTexture texture;
4932+ private Ctk.EffectGlow glow;
4933+
4934+ public PlaceSearchEntry search_entry { get; construct; }
4935+
4936+ public PlaceSearchBarBackground (PlaceSearchEntry search_entry)
4937+ {
4938+ Object (search_entry:search_entry);
4939+ }
4940+
4941+ construct
4942+ {
4943+ try
4944+ {
4945+ /* I've loaded this in directly and not through theme due to use
4946+ * not having a good loader for pixbufs from the theme right now
4947+ */
4948+ tile = new Gdk.Pixbuf.from_file (BG);
4949+ }
4950+ catch (Error e)
4951+ {
4952+ warning ("Unable to load dash background");
4953+ }
4954+
4955+ texture = new Clutter.CairoTexture (10, 10);
4956+ add_actor (texture);
4957+ texture.show ();
4958+
4959+ /* Enable once clutk bug is fixed */
4960+ glow = new Ctk.EffectGlow ();
4961+ glow.set_color ({ 255, 255, 255, 255 });
4962+ glow.set_factor (1.0f);
4963+ glow.set_margin (5);
4964+ add_effect (glow);
4965+ }
4966+
4967+ private override void allocate (Clutter.ActorBox box,
4968+ Clutter.AllocationFlags flags)
4969+ {
4970+ int width = (int)(box.x2 - box.x1);
4971+ int height = (int)(box.y2 - box.y1);
4972+
4973+ base.allocate (box, flags);
4974+
4975+ if (width != last_width || height != last_height)
4976+ {
4977+ last_width = width;
4978+ last_height = height;
4979+
4980+ Timeout.add (0, update_background);
4981+ }
4982+ }
4983+
4984+ public bool update_background ()
4985+ {
4986+ Cairo.Context cr;
4987+
4988+ texture.set_surface_size (last_width, last_height);
4989+
4990+ cr = texture.create ();
4991+
4992+ cr.set_operator (Cairo.Operator.CLEAR);
4993+ cr.paint ();
4994+
4995+ cr.set_operator (Cairo.Operator.OVER);
4996+ cr.set_line_width (1.5);
4997+ cr.set_source_rgba (1.0, 1.0, 1.0, 0.0);
4998+
4999+ cr.translate (0.5, 0.5);
5000+
The diff has been truncated for viewing.