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