Merge lp:~alexlauni/unity/state-introspection into lp:unity

Proposed by Alex Launi on 2010-11-22
Status: Merged
Approved by: Neil J. Patel on 2010-11-24
Approved revision: 632
Merged at revision: 626
Proposed branch: lp:~alexlauni/unity/state-introspection
Merge into: lp:unity
Diff against target: 708 lines (+500/-55)
10 files modified
src/Introspectable.cpp (+61/-0)
src/Introspectable.h (+54/-0)
src/IntrospectionDBusInterface.cpp (+223/-0)
src/IntrospectionDBusInterface.h (+54/-0)
src/Launcher.cpp (+9/-0)
src/Launcher.h (+47/-42)
src/PanelView.cpp (+9/-0)
src/PanelView.h (+8/-2)
src/unity.cpp (+16/-1)
src/unity.h (+19/-10)
To merge this branch: bzr merge lp:~alexlauni/unity/state-introspection
Reviewer Review Type Date Requested Status
Neil J. Patel (community) 2010-11-22 Approve on 2010-11-24
Review via email: mp+41479@code.launchpad.net

Description of the Change

Implements a debugging interface to get a snapshot of what Unity's internal data structures contain.

To post a comment you must log in.
Neil J. Patel (njpatel) wrote :

Overall looks great, there are some fixes needed, though:

- Use copyright headers from the other files, should be GPLv3 (no later), (C) Canonical and Authored by: You.

- /com/canonical not /org/canonical, same for org.canoni....

- g_error_free after printing the error

- static void Hello() not
  static void
  Hello ()

- Does initStateIntrospection need to be it's own function? Can't be done in the constructor of StateIntrospectionDBusInterface?

- Style:
  - AddChild not addChild
  - 2sp indenting
  - parenthesis on new line

Re: Style, sorry this isn't more obvious, I'll make sure to clean up the existing code and make a note in the source too. You can use `astyle -s2 -b -S -N -w -Y -M80 -p -H -d -j -k3 -n -z2` to update the style of the code to the correct one (apart from function names, of course).

review: Needs Fixing
Download full text (3.9 KiB)

In have a few comments in addition to what Neil said. But generally
nice work Alex :-)

> === added file 'src/Introspectable.cpp'
> SNIP
> +Introspectable::introspect ()
> +{
> +       GVariant                *result;
> +       GVariant        *childResults;
> +       GVariantBuilder *builder;
> +
> +       builder = g_variant_builder_new (G_VARIANT_TYPE ("a{sv}"));
> +       for (std::list<Introspectable*>::iterator it = _children.begin (); it != _children.end (); it++) {
> +               g_variant_builder_add (builder, "{sv}", (*it)->getName (), (*it)->introspect ());
> +       }
> +       addProperties (builder);
> +
> +       childResults = g_variant_new ("(a{sv})", builder);
> +       g_variant_builder_unref (builder);
> +
> +       if (_children.size () > 0) {
> +               builder = g_variant_builder_new (G_VARIANT_TYPE ("a{sv}"));
> +               g_variant_builder_add (builder, "{sv}", getName (), childResults);
> +               result = g_variant_new ("(a{sv})", builder);
> +               g_variant_builder_unref (builder);
> +
> +               return result;
> +       }
> +
> +       return childResults;
> +}

You can use a stack allocated GVariantBuilder here to simplify the
code somewhat. You rarely need heap allocated ones.

> === added file 'src/StateIntrospectionDBusInterface.cpp'
> +void
> +StateIntrospectionDBusInterface::initStateIntrospection ()
> +{
> +    _owner_id = g_bus_own_name (G_BUS_TYPE_SESSION,
> +                               UNITY_STATE_DEBUG_BUS_NAME,
> +                               G_BUS_NAME_OWNER_FLAGS_NONE,
> +                               &StateIntrospectionDBusInterface::onBusAcquired,
> +                               &StateIntrospectionDBusInterface::onNameAcquired,
> +                               &StateIntrospectionDBusInterface::onNameLost,
> +                               this,
> +                               NULL);
> +
> +}

I don't think we need to own a particular name on the bus for
debugging. We should probably assume that Unity owns the
com.canonical.Unity name and just let the rest be object hierarchies
below that name. Neil?

> +void
> +StateIntrospectionDBusInterface::dBusMethodCall (GDBusConnection *connection,
> +                                                 const gchar *sender,
> +                                                 const gchar *objectPath,
> +                                                 const gchar *ifaceName,
> +                                                 const gchar *methodName,
> +                                                 GVariant *parameters,
> +                                                 GDBusMethodInvocation *invocation,
> +                                                 gpointer data)
> +{
> +    if (g_strcmp0 (methodName, "GetState") == 0) {
> +               GVariant *ret;
> +               const gchar *input;
> +        g_variant_get (parameters, "(&s)", &input);
> +
> +               ret = getState (input);
> +        g_dbus_method_invocation_return_value (invocation, ret);
> +               g_variant_unref (ret);
> +    } else {
> +        g_dbus_method_invocation_return_dbus_error (invocation, "org.canonical.Unity",
> +...

Read more...

And two more things :-)

Is it StateIntrospection or just Introspection? I think just
Introspection makes sense, in which case you should probably rename
StateIntrospectionDBusInterface.

I don't think the new files have been added to Makefile.am?

Neil J. Patel (njpatel) wrote :

RE: DBus, we don't have any one object owning the name right now and I don't plan to add that at least until the week after next, so I think it's okay as it is right now, it would be simple-enough to move to another file once I have that sorted in my head.

Just own/unown com.canonical.Unity from the Compiz plugin load/unload.
There's nothing more to it.

It could possibly just be part of this branch. Alex - can you locate the
Compiz hooks?
On Nov 24, 2010 3:41 PM, "Neil J. Patel" <email address hidden> wrote:
> RE: DBus, we don't have any one object owning the name right now and I
don't plan to add that at least until the week after next, so I think it's
okay as it is right now, it would be simple-enough to move to another file
once I have that sorted in my head.
>
>
> --
>
https://code.launchpad.net/~alexlauni/unity/state-introspection/+merge/41479
> Your team Unity Team is subscribed to branch lp:unity.

622. By Alex Launi on 2010-11-24

Fix copyright in headers

623. By Alex Launi on 2010-11-24

Fix Canonical DBus namespacing

624. By Alex Launi on 2010-11-24

Fix method names

625. By Alex Launi on 2010-11-24

run astyle over my files

626. By Alex Launi on 2010-11-24

free gerror after failing to register bus

627. By Alex Launi on 2010-11-24

Fix compilation

628. By Alex Launi on 2010-11-24

Make DBusMethodCall private

629. By Alex Launi on 2010-11-24

Rename DBus interface from StateIntrospection to Introspection

630. By Alex Launi on 2010-11-24

Add example of property adding to Introspectable.h

631. By Alex Launi on 2010-11-24

A last couple of for s/State//

Neil J. Patel (njpatel) wrote :

Well, no, 'cos there are some bits and pieces that will depend on that and which I'd like to make testable, and hence I can't keep it tied to the plugin, otherwise I'll just have it to move it from there later. So, seeing as this is done, I'll take this as the lesser of two evils today :)

Approved pending the fix of the conflict with trunk as mentioned on #ayatana.

Nice work, and don't forget to add your name to AUTHORS :)

review: Approve
632. By Alex Launi on 2010-11-24

Merge trunk

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'src/Introspectable.cpp'
2--- src/Introspectable.cpp 1970-01-01 00:00:00 +0000
3+++ src/Introspectable.cpp 2010-11-24 17:57:00 +0000
4@@ -0,0 +1,61 @@
5+/*
6+ * Copyright (C) 2010 Canonical Ltd
7+ *
8+ * This program is free software: you can redistribute it and/or modify
9+ * it under the terms of the GNU General Public License version 3 as
10+ * published by the Free Software Foundation.
11+ *
12+ * This program is distributed in the hope that it will be useful,
13+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+ * GNU General Public License for more details.
16+ *
17+ * You should have received a copy of the GNU General Public License
18+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
19+ *
20+ * Authored by: Alex Launi <alex.launi@canonical.com>
21+ */
22+
23+#include "Introspectable.h"
24+
25+GVariant*
26+Introspectable::Introspect ()
27+{
28+ GVariant *result;
29+ GVariant *childResults;
30+ GVariantBuilder *builder;
31+
32+ builder = g_variant_builder_new (G_VARIANT_TYPE ("a{sv}"));
33+ for (std::list<Introspectable *>::iterator it = _children.begin (); it != _children.end (); it++)
34+ {
35+ g_variant_builder_add (builder, "{sv}", (*it)->GetName (), (*it)->Introspect () );
36+ }
37+ AddProperties (builder);
38+
39+ childResults = g_variant_new ("(a{sv})", builder);
40+ g_variant_builder_unref (builder);
41+
42+ if (_children.size () > 0)
43+ {
44+ builder = g_variant_builder_new (G_VARIANT_TYPE ("a{sv}") );
45+ g_variant_builder_add (builder, "{sv}", GetName (), childResults);
46+ result = g_variant_new ("(a{sv})", builder);
47+ g_variant_builder_unref (builder);
48+
49+ return result;
50+ }
51+
52+ return childResults;
53+}
54+
55+void
56+Introspectable::AddChild (Introspectable *child)
57+{
58+ _children.push_back (child);
59+}
60+
61+void
62+Introspectable::RemoveChild (Introspectable *child)
63+{
64+ _children.remove (child);
65+}
66\ No newline at end of file
67
68=== added file 'src/Introspectable.h'
69--- src/Introspectable.h 1970-01-01 00:00:00 +0000
70+++ src/Introspectable.h 2010-11-24 17:57:00 +0000
71@@ -0,0 +1,54 @@
72+/*
73+ * Copyright (C) 2010 Canonical Ltd
74+ *
75+ * This program is free software: you can redistribute it and/or modify
76+ * it under the terms of the GNU General Public License version 3 as
77+ * published by the Free Software Foundation.
78+ *
79+ * This program is distributed in the hope that it will be useful,
80+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
81+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
82+ * GNU General Public License for more details.
83+ *
84+ * You should have received a copy of the GNU General Public License
85+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
86+ *
87+ * Authored by: Alex Launi <alex.launi@canonical.com>
88+ */
89+
90+#ifndef _INTROSPECTABLE_H
91+#define _INTROSPECTABLE_H 1
92+
93+#include <glib.h>
94+#include <list>
95+
96+class Introspectable
97+{
98+public:
99+ GVariant *Introspect ();
100+ void AddChild (Introspectable *child);
101+ void RemoveChild (Introspectable *child);
102+
103+protected:
104+ virtual const gchar *GetName () = 0;
105+ virtual void AddProperties (GVariantBuilder *builder) = 0;
106+ /*
107+ * AddProperties should be implemented as such ...
108+ * void ClassFoo::AddProperties (GVariantBuilder *builder)
109+ * {
110+ * g_variant_builder_add (builder, "{sv}", "label", g_variant_new_string ("_File") );
111+ * g_variant_builder_add (builder, "{sv}", "image", g_variant_new_string ("") );
112+ * g_variant_builder_add (builder, "{sv}", "visible", g_variant_new_boolean (TRUE) );
113+ * g_variant_builder_add (builder, "{sv}", "sensitive", g_variant_new_boolean (TRUE) );
114+ * g_variant_builder_add (builder, "{sv}", "active", g_variant_new_boolean (FALSE) );
115+ * g_variant_builder_add (builder, "{sv}", "label", g_variant_new_int32 (34) );
116+ * g_variant_builder_add (builder, "{sv}", "label", g_variant_new_int32 (24) );
117+ * }
118+ * That's all. Just add a bunch of key-value properties to the builder.
119+ */
120+
121+private:
122+ std::list<Introspectable *> _children;
123+};
124+
125+#endif
126\ No newline at end of file
127
128=== added file 'src/IntrospectionDBusInterface.cpp'
129--- src/IntrospectionDBusInterface.cpp 1970-01-01 00:00:00 +0000
130+++ src/IntrospectionDBusInterface.cpp 2010-11-24 17:57:00 +0000
131@@ -0,0 +1,223 @@
132+/*
133+ * Copyright (C) 2010 Canonical Ltd
134+ *
135+ * This program is free software: you can redistribute it and/or modify
136+ * it under the terms of the GNU General Public License version 3 as
137+ * published by the Free Software Foundation.
138+ *
139+ * This program is distributed in the hope that it will be useful,
140+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
141+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
142+ * GNU General Public License for more details.
143+ *
144+ * You should have received a copy of the GNU General Public License
145+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
146+ *
147+ * Authored by: Alex Launi <alex.launi@canonical.com>
148+ */
149+
150+#include "IntrospectionDBusInterface.h"
151+
152+#define UNITY_STATE_DEBUG_BUS_NAME "com.canonical.Unity.Debug"
153+
154+void DBusMethodCall (GDBusConnection*, const gchar*, const gchar*,
155+ const gchar*, const gchar*, GVariant*,
156+ GDBusMethodInvocation*, gpointer);
157+GVariant* GetState (const gchar*);
158+
159+static const GDBusInterfaceVTable si_vtable =
160+{
161+ &DBusMethodCall,
162+ NULL,
163+ NULL
164+};
165+
166+static const GDBusArgInfo si_getstate_in_args =
167+{
168+ -1,
169+ "piece",
170+ "s",
171+ NULL
172+};
173+static const GDBusArgInfo *const si_getstate_in_arg_pointers[] = { &si_getstate_in_args, NULL };
174+
175+// TODO: this is really a a{sv} or something like that.
176+static const GDBusArgInfo si_getstate_out_args =
177+{
178+ -1,
179+ "state",
180+ "a{sv}",
181+ NULL
182+};
183+static const GDBusArgInfo *const si_getstate_out_arg_pointers[] = { &si_getstate_out_args, NULL };
184+
185+static const GDBusMethodInfo si_method_info_getstate =
186+{
187+ -1,
188+ "GetState",
189+ (GDBusArgInfo **) &si_getstate_in_arg_pointers,
190+ (GDBusArgInfo **) &si_getstate_out_arg_pointers,
191+ NULL
192+};
193+
194+static const GDBusMethodInfo *const si_method_info_pointers[] = { &si_method_info_getstate, NULL };
195+
196+static const GDBusInterfaceInfo si_iface_info =
197+{
198+ -1,
199+ "com.canonical.Unity.Debug.Introspection",
200+ (GDBusMethodInfo **) &si_method_info_pointers,
201+ NULL,
202+ NULL,
203+ NULL,
204+};
205+
206+static Introspectable *_introspectable;
207+
208+IntrospectionDBusInterface::IntrospectionDBusInterface (Introspectable *introspectable)
209+{
210+ _introspectable = introspectable;
211+ _owner_id = g_bus_own_name (G_BUS_TYPE_SESSION,
212+ UNITY_STATE_DEBUG_BUS_NAME,
213+ G_BUS_NAME_OWNER_FLAGS_NONE,
214+ &IntrospectionDBusInterface::OnBusAcquired,
215+ &IntrospectionDBusInterface::OnNameAcquired,
216+ &IntrospectionDBusInterface::OnNameLost,
217+ this,
218+ NULL);
219+}
220+
221+IntrospectionDBusInterface::~IntrospectionDBusInterface ()
222+{
223+ g_bus_unown_name (_owner_id);
224+}
225+
226+void
227+IntrospectionDBusInterface::OnBusAcquired (GDBusConnection *connection, const gchar *name, gpointer data)
228+{
229+ GError *error = NULL;
230+ g_dbus_connection_register_object (connection,
231+ "/com/canonical/Unity/Debug/Introspection",
232+ (GDBusInterfaceInfo *) &si_iface_info,
233+ &si_vtable,
234+ NULL,
235+ NULL,
236+ &error);
237+ if (error != NULL)
238+ {
239+ g_warning ("Could not register Introspection object onto d-bus");
240+ g_error_free (error);
241+ }
242+}
243+
244+void
245+IntrospectionDBusInterface::OnNameAcquired (GDBusConnection *connection, const gchar *name, gpointer data)
246+{
247+}
248+
249+void
250+IntrospectionDBusInterface::OnNameLost (GDBusConnection *connection, const gchar *name, gpointer data)
251+{
252+}
253+
254+void
255+DBusMethodCall (GDBusConnection *connection,
256+ const gchar *sender,
257+ const gchar *objectPath,
258+ const gchar *ifaceName,
259+ const gchar *methodName,
260+ GVariant *parameters,
261+ GDBusMethodInvocation *invocation,
262+ gpointer data)
263+{
264+ if (g_strcmp0 (methodName, "GetState") == 0)
265+ {
266+ GVariant *ret;
267+ const gchar *input;
268+ g_variant_get (parameters, "(&s)", &input);
269+
270+ ret = GetState (input);
271+ g_dbus_method_invocation_return_value (invocation, ret);
272+ g_variant_unref (ret);
273+ }
274+ else
275+ {
276+ g_dbus_method_invocation_return_dbus_error (invocation, "com.canonical.Unity",
277+ "Failed to find method");
278+ }
279+}
280+
281+GVariant*
282+GetState (const gchar *piece)
283+{
284+ return _introspectable->Introspect ();
285+}
286+
287+/* a very contrived example purely for giving QA something purposes */
288+GVariant*
289+IntrospectionDBusInterface::BuildFakeReturn ()
290+{
291+ GVariantBuilder *builder;
292+ GVariant *result, *panel_result, *indicators_result, *appmenu_result, *entries_result, *zero_result, *one_result;
293+
294+ builder = g_variant_builder_new (G_VARIANT_TYPE ("a{sv}") );
295+ g_variant_builder_add (builder, "{sv}", "label", g_variant_new_string ("_File") );
296+ g_variant_builder_add (builder, "{sv}", "image", g_variant_new_string ("") );
297+ g_variant_builder_add (builder, "{sv}", "visible", g_variant_new_boolean (TRUE) );
298+ g_variant_builder_add (builder, "{sv}", "sensitive", g_variant_new_boolean (TRUE) );
299+ g_variant_builder_add (builder, "{sv}", "active", g_variant_new_boolean (FALSE) );
300+ g_variant_builder_add (builder, "{sv}", "label", g_variant_new_int32 (34) );
301+ g_variant_builder_add (builder, "{sv}", "label", g_variant_new_int32 (24) );
302+ zero_result = g_variant_new ("(a{sv})", builder);
303+ g_variant_builder_unref (builder);
304+
305+ builder = g_variant_builder_new (G_VARIANT_TYPE ("a{sv}") );
306+ g_variant_builder_add (builder, "{sv}", "label", g_variant_new_string ("_Edit") );
307+ g_variant_builder_add (builder, "{sv}", "image", g_variant_new_string ("") );
308+ g_variant_builder_add (builder, "{sv}", "visible", g_variant_new_boolean (TRUE) );
309+ g_variant_builder_add (builder, "{sv}", "sensitive", g_variant_new_boolean (TRUE) );
310+ g_variant_builder_add (builder, "{sv}", "active", g_variant_new_boolean (FALSE) );
311+ g_variant_builder_add (builder, "{sv}", "label", g_variant_new_int32 (34) );
312+ g_variant_builder_add (builder, "{sv}", "label", g_variant_new_int32 (24) );
313+ one_result = g_variant_new ("(a{sv})", builder);
314+ g_variant_builder_unref (builder);
315+
316+ builder = g_variant_builder_new (G_VARIANT_TYPE ("a{sv}") );
317+ g_variant_builder_add (builder, "{sv}", "0", zero_result);
318+ g_variant_builder_add (builder, "{sv}", "1", one_result);
319+ entries_result = g_variant_new ("(a{sv})", builder);
320+ g_variant_builder_unref (builder);
321+
322+ builder = g_variant_builder_new (G_VARIANT_TYPE ("a{sv}") );
323+ g_variant_builder_add (builder, "{sv}", "model-name",
324+ g_variant_new_string ("com.canonical.Unity.Panel.Service.Indicators.appmenu.324234243") );
325+ g_variant_builder_add (builder, "{sv}", "entries", entries_result);
326+ appmenu_result = g_variant_new ("(a{sv})", builder);
327+ g_variant_builder_unref (builder);
328+
329+ builder = g_variant_builder_new (G_VARIANT_TYPE ("a{sv}") );
330+ g_variant_builder_add (builder, "{sv}", "appmenu", appmenu_result);
331+ indicators_result = g_variant_new ("(a{sv})", builder);
332+ g_variant_builder_unref (builder);
333+
334+ builder = g_variant_builder_new (G_VARIANT_TYPE ("a{sv}") );
335+ g_variant_builder_add (builder, "{sv}", "backend",
336+ g_variant_new_string ("/com/canonical/Unity/Panel/Service/324234243") );
337+ g_variant_builder_add (builder, "{sv}", "launch-type",
338+ g_variant_new_string ("dbus") );
339+ g_variant_builder_add (builder, "{sv}", "width", g_variant_new_int32 (1024) );
340+ g_variant_builder_add (builder, "{sv}", "width", g_variant_new_int32 (32) );
341+ g_variant_builder_add (builder, "{sv}", "theme", g_variant_new_string ("gtk") );
342+ g_variant_builder_add (builder, "{sv}", "indicators", indicators_result);
343+ panel_result = g_variant_new ("(a{sv})", builder);
344+ g_variant_builder_unref (builder);
345+
346+ builder = g_variant_builder_new (G_VARIANT_TYPE ("a{sv}") );
347+ g_variant_builder_add (builder, "{sv}", "panel", panel_result);
348+ result = g_variant_new ("(a{sv})", builder);
349+ g_variant_builder_unref (builder);
350+
351+ gchar *s = g_variant_print (result, TRUE);
352+ g_free (s);
353+ return result;
354+}
355\ No newline at end of file
356
357=== added file 'src/IntrospectionDBusInterface.h'
358--- src/IntrospectionDBusInterface.h 1970-01-01 00:00:00 +0000
359+++ src/IntrospectionDBusInterface.h 2010-11-24 17:57:00 +0000
360@@ -0,0 +1,54 @@
361+/*
362+ * Copyright (C) 2010 Canonical Ltd
363+ *
364+ * This program is free software: you can redistribute it and/or modify
365+ * it under the terms of the GNU General Public License version 3 as
366+ * published by the Free Software Foundation.
367+ *
368+ * This program is distributed in the hope that it will be useful,
369+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
370+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
371+ * GNU General Public License for more details.
372+ *
373+ * You should have received a copy of the GNU General Public License
374+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
375+ *
376+ * Authored by: Alex Launi <alex.launi@canonical.com>
377+ */
378+
379+#ifndef _STATE_INTROSPECTION_DBUS_INTERFACE_H
380+#define _STATE_INTROSPECTION_DBUS_INTERFACE_H 1
381+
382+#include <glib.h>
383+#include <gio/gio.h>
384+#include "Introspectable.h"
385+
386+class IntrospectionDBusInterface
387+{
388+public:
389+ IntrospectionDBusInterface (Introspectable *introspectable);
390+ ~IntrospectionDBusInterface ();
391+
392+ /*static void DBusMethodCall (GDBusConnection *connection, const gchar *sender,
393+ const gchar *objectPath, const gchar *ifaceName,
394+ const gchar *methodName, GVariant *parameters,
395+ GDBusMethodInvocation *invocation, gpointer data); */
396+
397+private:
398+ /* methods */
399+
400+ static void OnBusAcquired (GDBusConnection *connection, const gchar *name, gpointer data);
401+
402+ static void OnNameAcquired (GDBusConnection *connection, const gchar *name, gpointer data);
403+
404+ static void OnNameLost (GDBusConnection *connection, const gchar *name, gpointer data);
405+
406+ //static GVariant *GetState (const char *piece);
407+
408+ static GVariant *BuildFakeReturn ();
409+
410+ /* members */
411+ guint _owner_id;
412+};
413+
414+#endif
415
416=== modified file 'src/Launcher.cpp'
417--- src/Launcher.cpp 2010-11-24 02:13:08 +0000
418+++ src/Launcher.cpp 2010-11-24 17:57:00 +0000
419@@ -1418,6 +1418,15 @@
420
421 void Launcher::RecvMouseWheel(int x, int y, int wheel_delta, unsigned long button_flags, unsigned long key_flags)
422 {
423+}
424+
425+const gchar* Launcher::GetName ()
426+{
427+ return "Launcher";
428+}
429+
430+void Launcher::AddProperties (GVariantBuilder *builder)
431+{
432 }
433
434 void Launcher::EventLogic ()
435
436=== modified file 'src/Launcher.h'
437--- src/Launcher.h 2010-11-24 01:04:17 +0000
438+++ src/Launcher.h 2010-11-24 17:57:00 +0000
439@@ -23,7 +23,8 @@
440 #include <sys/time.h>
441
442 #include <Nux/View.h>
443-#include <Nux/BaseWindow.h>
444+#include <Nux/BaseWindow.h>
445+#include "Introspectable.h"
446 #include "LauncherIcon.h"
447 #include "NuxGraphics/IOpenGLAsmShader.h"
448 #include "Nux/TimerProc.h"
449@@ -31,49 +32,53 @@
450 class LauncherModel;
451 class QuicklistView;
452
453-class Launcher : public nux::View
454+class Launcher : public Introspectable, public nux::View
455 {
456 public:
457- Launcher(nux::BaseWindow *parent, NUX_FILE_LINE_PROTO);
458- ~Launcher();
459-
460- virtual long ProcessEvent(nux::IEvent &ievent, long TraverseInfo, long ProcessEventInfo);
461- virtual void Draw(nux::GraphicsEngine& GfxContext, bool force_draw);
462- virtual void DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw);
463- virtual void PostDraw(nux::GraphicsEngine& GfxContext, bool force_draw);
464-
465- LauncherIcon* GetActiveTooltipIcon() {return m_ActiveTooltipIcon;}
466- LauncherIcon* GetActiveMenuIcon() {return m_ActiveMenuIcon;}
467-
468- bool TooltipNotify(LauncherIcon* Icon);
469- bool MenuNotify(LauncherIcon* Icon);
470-
471- void SetIconSize(int tile_size, int icon_size);
472- void NotifyMenuTermination(LauncherIcon* Icon);
473-
474- void SetModel (LauncherModel *model);
475-
476- void SetFloating (bool floating);
477-
478- void SetAutohide (bool autohide, nux::View *show_trigger);
479- bool AutohideEnabled ();
480-
481- virtual void RecvMouseUp(int x, int y, unsigned long button_flags, unsigned long key_flags);
482- virtual void RecvMouseDown(int x, int y, unsigned long button_flags, unsigned long key_flags);
483- virtual void RecvMouseDrag(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags);
484- virtual void RecvMouseEnter(int x, int y, unsigned long button_flags, unsigned long key_flags);
485- virtual void RecvMouseLeave(int x, int y, unsigned long button_flags, unsigned long key_flags);
486- virtual void RecvMouseMove(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags);
487- virtual void RecvMouseWheel(int x, int y, int wheel_delta, unsigned long button_flags, unsigned long key_flags);
488-
489-
490- //! Called by LauncherIcon to signal that a Quicklist is becoming active.
491- void SetActiveQuicklist (QuicklistView *quicklist);
492- //! Get the active qicklist
493- QuicklistView *GetActiveQuicklist ();
494- //! Called by LauncherIcon to signal that a Quicklist is becoming unactive.
495- void CancelActiveQuicklist (QuicklistView *quicklist);
496-
497+ Launcher(nux::BaseWindow *parent, NUX_FILE_LINE_PROTO);
498+ ~Launcher();
499+
500+ virtual long ProcessEvent(nux::IEvent &ievent, long TraverseInfo, long ProcessEventInfo);
501+ virtual void Draw(nux::GraphicsEngine& GfxContext, bool force_draw);
502+ virtual void DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw);
503+ virtual void PostDraw(nux::GraphicsEngine& GfxContext, bool force_draw);
504+
505+ LauncherIcon* GetActiveTooltipIcon() {return m_ActiveTooltipIcon;}
506+ LauncherIcon* GetActiveMenuIcon() {return m_ActiveMenuIcon;}
507+
508+ bool TooltipNotify(LauncherIcon* Icon);
509+ bool MenuNotify(LauncherIcon* Icon);
510+
511+ void SetIconSize(int tile_size, int icon_size);
512+ void NotifyMenuTermination(LauncherIcon* Icon);
513+
514+ void SetModel (LauncherModel *model);
515+
516+ void SetFloating (bool floating);
517+
518+ void SetAutohide (bool autohide, nux::View *show_trigger);
519+ bool AutohideEnabled ();
520+
521+ virtual void RecvMouseUp(int x, int y, unsigned long button_flags, unsigned long key_flags);
522+ virtual void RecvMouseDown(int x, int y, unsigned long button_flags, unsigned long key_flags);
523+ virtual void RecvMouseDrag(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags);
524+ virtual void RecvMouseEnter(int x, int y, unsigned long button_flags, unsigned long key_flags);
525+ virtual void RecvMouseLeave(int x, int y, unsigned long button_flags, unsigned long key_flags);
526+ virtual void RecvMouseMove(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags);
527+ virtual void RecvMouseWheel(int x, int y, int wheel_delta, unsigned long button_flags, unsigned long key_flags);
528+
529+ //! Called by LauncherIcon to signal that a Quicklist is becoming active.
530+ void SetActiveQuicklist (QuicklistView *quicklist);
531+ //! Get the active qicklist
532+ QuicklistView *GetActiveQuicklist ();
533+ //! Called by LauncherIcon to signal that a Quicklist is becoming unactive.
534+ void CancelActiveQuicklist (QuicklistView *quicklist);
535+
536+protected:
537+ // Introspectable methods
538+ const gchar* GetName ();
539+ void AddProperties (GVariantBuilder *builder);
540+
541 private:
542 typedef enum
543 {
544
545=== modified file 'src/PanelView.cpp'
546--- src/PanelView.cpp 2010-11-17 11:41:42 +0000
547+++ src/PanelView.cpp 2010-11-24 17:57:00 +0000
548@@ -63,6 +63,15 @@
549 {
550 return _home_button;
551 }
552+
553+const gchar* PanelView::GetName ()
554+{
555+ return "PanelView";
556+}
557+
558+void PanelView::AddProperties (GVariantBuilder *builder)
559+{
560+}
561
562 long
563 PanelView::ProcessEvent (nux::IEvent &ievent, long TraverseInfo, long ProcessEventInfo)
564
565=== modified file 'src/PanelView.h'
566--- src/PanelView.h 2010-11-11 15:07:58 +0000
567+++ src/PanelView.h 2010-11-24 17:57:00 +0000
568@@ -25,8 +25,9 @@
569
570 #include "PanelHomeButton.h"
571 #include "IndicatorObjectFactoryRemote.h"
572+#include "Introspectable.h"
573
574-class PanelView : public nux::View
575+class PanelView : public Introspectable, public nux::View
576 {
577 public:
578 PanelView (NUX_FILE_LINE_PROTO);
579@@ -42,7 +43,12 @@
580 void OnObjectAdded (IndicatorObjectProxy *proxy);
581 void OnMenuPointerMoved (int x, int y);
582
583- PanelHomeButton * HomeButton ();
584+ PanelHomeButton * HomeButton ();
585+
586+protected:
587+ // Introspectable methods
588+ const gchar* GetName ();
589+ void AddProperties (GVariantBuilder *builder);
590
591 private:
592 void UpdateBackground ();
593
594=== modified file 'src/unity.cpp'
595--- src/unity.cpp 2010-11-24 16:35:32 +0000
596+++ src/unity.cpp 2010-11-24 17:57:00 +0000
597@@ -237,6 +237,17 @@
598 return true;
599 }
600
601+void
602+UnityScreen::AddProperties (GVariantBuilder *builder)
603+{
604+}
605+
606+const gchar*
607+UnityScreen::GetName ()
608+{
609+ return "Unity";
610+}
611+
612 /* This gets called whenever the window needs to be repainted. WindowPaintAttrib gives you some
613 * attributes like brightness/saturation etc to play around with. GLMatrix is the window's
614 * transformation matrix. the unsigned int is the mask, have a look at opengl.h on what you can do
615@@ -453,7 +464,9 @@
616
617 wt->Run (NULL);
618 uScreen = this;
619-
620+
621+ debugger = new IntrospectionDBusInterface (this);
622+
623 PluginAdapter::Initialize (screen);
624
625 optionSetLauncherAutohideNotify (boost::bind (&UnityScreen::optionChanged, this, _1, _2));
626@@ -490,6 +503,7 @@
627
628 self->launcherWindow = new nux::BaseWindow(TEXT(""));
629 self->launcher = new Launcher(self->launcherWindow);
630+ self->AddChild (self->launcher);
631
632 nux::HLayout* layout = new nux::HLayout();
633
634@@ -512,6 +526,7 @@
635
636 /* Setup panel */
637 self->panelView = new PanelView ();
638+ self->AddChild (self->panelView);
639
640 layout = new nux::HLayout();
641
642
643=== modified file 'src/unity.h'
644--- src/unity.h 2010-11-24 11:30:46 +0000
645+++ src/unity.h 2010-11-24 17:57:00 +0000
646@@ -41,10 +41,11 @@
647 /* This is the options class header created for us automatically on build with BCOP */
648 #include "unityshell_options.h"
649
650+#include "Introspectable.h"
651 #include "Launcher.h"
652 #include "LauncherController.h"
653 #include "PanelView.h"
654-
655+#include "IntrospectionDBusInterface.h"
656 #include <Nux/WindowThread.h>
657 #include <sigc++/sigc++.h>
658
659@@ -53,7 +54,8 @@
660 * instance per screen.
661 */
662
663-class UnityScreen :
664+class UnityScreen :
665+ public Introspectable,
666 public sigc::trackable,
667 /* You should inherit the ScreenInterface class if you want to dynamically hook
668 * screen-level core functions. */
669@@ -158,6 +160,12 @@
670 initPluginForScreen (CompPlugin *p);
671
672 bool doShellRepaint;
673+
674+ protected:
675+
676+ const gchar* GetName ();
677+
678+ void AddProperties (GVariantBuilder *builder);
679
680 private:
681
682@@ -178,17 +186,18 @@
683
684 static void
685 initUnity(nux::NThread* thread, void* InitData);
686-
687+
688 static gboolean
689 strutHackTimeout (gpointer data);
690
691- Launcher *launcher;
692- LauncherController *controller;
693- PanelView *panelView;
694- nux::WindowThread *wt;
695- nux::BaseWindow *launcherWindow;
696- nux::BaseWindow *panelWindow;
697- nux::Geometry lastTooltipArea;
698+ Launcher *launcher;
699+ LauncherController *controller;
700+ PanelView *panelView;
701+ nux::WindowThread *wt;
702+ nux::BaseWindow *launcherWindow;
703+ nux::BaseWindow *panelWindow;
704+ nux::Geometry lastTooltipArea;
705+ IntrospectionDBusInterface *debugger;
706 };
707
708 class UnityWindow :