Merge lp:~unity-team/unity/unity.complete-places-api into lp:unity

Proposed by Mikkel Kamstrup Erlandsen
Status: Merged
Merge reported by: Mikkel Kamstrup Erlandsen
Merged at revision: not available
Proposed branch: lp:~unity-team/unity/unity.complete-places-api
Merge into: lp:unity
Diff against target: 264 lines (+108/-87)
1 file modified
unity/unity-place.vala (+108/-87)
To merge this branch: bzr merge lp:~unity-team/unity/unity.complete-places-api
Reviewer Review Type Date Requested Status
Neil J. Patel (community) Approve
Review via email: mp+26943@code.launchpad.net

Description of the change

Please see last commit message for details

To post a comment you must log in.
Revision history for this message
Neil J. Patel (njpatel) wrote :

Looks good. Approved.

review: Approve
Revision history for this message
Neil J. Patel (njpatel) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'unity/unity-place.vala'
--- unity/unity-place.vala 2010-06-04 11:59:49 +0000
+++ unity/unity-place.vala 2010-06-07 12:56:23 +0000
@@ -24,7 +24,7 @@
24 * some good reasons.24 * some good reasons.
25 *25 *
26 * Firstly we want to hide away Vala's internal DBus marshalling which would26 * Firstly we want to hide away Vala's internal DBus marshalling which would
27 * expose raw structs in the. These structs are hidden away in _RendererInfo,27 * expose raw structs in the API. These structs are hidden away in _RendererInfo,
28 * and _EntryInfo. We wrap these in handy GObjects with properties and what not.28 * and _EntryInfo. We wrap these in handy GObjects with properties and what not.
29 * In fact we want to hide all DBusisms, which is also why the DBus interfaces29 * In fact we want to hide all DBusisms, which is also why the DBus interfaces
30 * are declared private.30 * are declared private.
@@ -134,7 +134,64 @@
134 {134 {
135 info.hints.remove_all ();135 info.hints.remove_all ();
136 }136 }
137 }137
138 public uint num_hints ()
139 {
140 return info.hints.size ();
141 }
142 }
143
144 /**
145 *
146 */
147 public class Search : InitiallyUnowned {
148
149 private string search;
150 private HashTable<string,string> hints;
151
152 /*
153 * Public API
154 */
155
156 public Search (string search, HashTable<string,string> hints)
157 {
158 GLib.Object();
159 this.search = search;
160 this.hints = hints;
161 }
162
163 public string get_search_string ()
164 {
165 return search;
166 }
167
168 public void set_hint (string hint, string val)
169 {
170 hints.insert (hint, val);
171 }
172
173 public string? get_hint (string hint)
174 {
175 return hints.lookup (hint);
176 }
177
178 public void clear_hint (string hint)
179 {
180 hints.remove (hint);
181 }
182
183 public void clear_hints ()
184 {
185 hints.remove_all ();
186 }
187
188 public uint num_hints ()
189 {
190 return hints.size ();
191 }
192 }
193
194 public delegate uint SearchHandler (Search search);
138 195
139 /**196 /**
140 * UnityPlace_EntryInfo:197 * UnityPlace_EntryInfo:
@@ -162,6 +219,10 @@
162 private RendererInfo _entry_renderer_info;219 private RendererInfo _entry_renderer_info;
163 private RendererInfo _global_renderer_info;220 private RendererInfo _global_renderer_info;
164 private Dee.Model _sections_model;221 private Dee.Model _sections_model;
222 private SearchHandler _search_handler = null;
223 private SearchHandler _global_search_handler = null;
224 private bool _active = false;
225 private uint _active_section = 0;
165 226
166 /*227 /*
167 * Properties228 * Properties
@@ -218,6 +279,26 @@
218 }279 }
219 }280 }
220 281
282 public bool active {
283 get { return _active; }
284 set { _active = value; }
285 }
286
287 public uint active_section {
288 get { return _active_section; }
289 set { _active_section = value; }
290 }
291
292 public SearchHandler search_handler {
293 get { return _search_handler; }
294 set { _search_handler = value; }
295 }
296
297 public SearchHandler global_search_handler {
298 get { return _global_search_handler; }
299 set { _global_search_handler = value; }
300 }
301
221 /*302 /*
222 * Constructors303 * Constructors
223 */304 */
@@ -288,6 +369,11 @@
288 info.hints.remove_all ();369 info.hints.remove_all ();
289 }370 }
290 371
372 public uint num_hints ()
373 {
374 return info.hints.size ();
375 }
376
291 /*377 /*
292 * Internal API378 * Internal API
293 */379 */
@@ -531,23 +617,37 @@
531 public uint set_global_search (string search,617 public uint set_global_search (string search,
532 HashTable<string,string> hints)618 HashTable<string,string> hints)
533 {619 {
534 return 0;620 if (_entry_info.global_search_handler != null)
621 return _entry_info.global_search_handler (new Search (search, hints));
622 else
623 {
624 warning ("No global search handler installed for %s",
625 _entry_info.dbus_path);
626 return 0;
627 }
535 }628 }
536629
537 public uint set_search (string search,630 public uint set_search (string search,
538 HashTable<string,string> hints)631 HashTable<string,string> hints)
539 {632 {
540 return 0;633 if (_entry_info.search_handler != null)
634 return _entry_info.search_handler (new Search (search, hints));
635 else
636 {
637 warning ("No search handler installed for %s",
638 _entry_info.dbus_path);
639 return 0;
640 }
541 }641 }
542 642
543 public void set_active (bool is_active)643 public void set_active (bool is_active)
544 {644 {
545 // pass645 this._entry_info.active = is_active;
546 }646 }
547647
548 public void set_active_section (uint section_id)648 public void set_active_section (uint section_id)
549 {649 {
550 // pass650 this._entry_info.active_section = section_id;
551 }651 }
552 652
553 /*653 /*
@@ -597,7 +697,7 @@
597 697
598 public bool exported {698 public bool exported {
599 get { return _exported; }699 get { return _exported; }
600 }700 }
601 701
602 /*702 /*
603 * Constructors703 * Constructors
@@ -671,83 +771,4 @@
671 }771 }
672 }772 }
673 773
674 /*public class TestPlaceDaemon : GLib.Object, PlaceService
675 {
676 private static string[] supported_mimetypes = {"text/plain", "text/html"};
677
678 public TestPlaceDaemon()
679 {
680 try {
681 var conn = DBus.Bus.get (DBus.BusType. SESSION);
682
683 dynamic DBus.Object bus = conn.get_object ("org.freedesktop.DBus",
684 "/org/freedesktop/DBus",
685 "org.freedesktop.DBus");
686
687 // try to register service in session bus
688 uint request_name_result = bus.request_name ("org.ayatana.TestPlace", (uint) 0);
689
690 if (request_name_result == DBus.RequestNameReply.PRIMARY_OWNER) {
691 conn.register_object ("/org/ayatana/places/test", this);
692 } else {
693 stderr.printf ("Unable to grab DBus name. Another test server is probably running\n");
694 }
695 } catch (DBus.Error e) {
696 stderr.printf ("Oops: %s\n", e.message);
697 }
698 }
699
700 public _EntryInfo[] get_entries () throws DBus.Error
701 {
702 var entry = _EntryInfo();
703 entry.dbus_path = "/org/foo/bar";
704 entry.name = "My Entry Name";
705 entry.icon = "__icon__";
706 entry.position = 0;
707 entry.mimetypes = supported_mimetypes;
708 entry.sensitive = true;
709 entry.sections_model = "org.ayatana.MySectionsModel";
710 entry.hints = new HashTable<string, string> (str_hash, str_equal);
711 entry.entry_renderer_info.default_renderer = "DefaultRenderer";
712 entry.entry_renderer_info.groups_model = "org.ayatana.MyGroupsModel";
713 entry.entry_renderer_info.results_model = "org.ayatana.MyResultsModel";
714 entry.entry_renderer_info.hints = new HashTable<string, string> (str_hash, str_equal);
715 entry.global_renderer_info.default_renderer = "DefaultRenderer";
716 entry.global_renderer_info.groups_model = "org.ayatana.MyGlobalGroupsModel";
717 entry.global_renderer_info.results_model = "org.ayatana.MyGlobalResultsModel";
718 entry.global_renderer_info.hints = new HashTable<string, string> (str_hash, str_equal);
719
720 _EntryInfo[] entries = new _EntryInfo[1];
721 entries[0] = entry;
722 return entries;
723 }
724
725 public static int main (string[] args)
726 {
727 var loop = new MainLoop (null, false);
728 var daemon = new TestPlaceDaemon();
729 loop.run ();
730
731 return 0;
732 }
733 }*/
734 /*
735 public static int main (string[] args)
736 {
737 var loop = new MainLoop (null, false);
738 var ctl = new Controller ("/foo/bar");
739 ctl.export();
740
741 var entry = new EntryInfo();
742 entry.dbus_path = "/foo/bar/entries/0";
743 entry.display_name = "Display Name";
744 entry.set_hint ("hintkey1", "hintvalue1");
745 ctl.add_entry (entry);
746
747 loop.run ();
748
749 return 0;
750 }
751 */
752
753} /* namespace */774} /* namespace */