Merge lp:~ted/libdbusmenu/serializable-menuitem into lp:libdbusmenu/0.5
- serializable-menuitem
- Merge into trunk
Status: | Merged |
---|---|
Merged at revision: | 197 |
Proposed branch: | lp:~ted/libdbusmenu/serializable-menuitem |
Merge into: | lp:libdbusmenu/0.5 |
Diff against target: |
687 lines (+489/-18) 11 files modified
.bzrignore (+3/-0) docs/libdbusmenu-gtk/reference/Makefile.am (+1/-1) docs/libdbusmenu-gtk/reference/libdbusmenu-gtk-docs.sgml (+1/-1) libdbusmenu-glib/client.c (+69/-7) libdbusmenu-glib/client.h (+7/-1) libdbusmenu-gtk/Makefile.am (+5/-2) libdbusmenu-gtk/client.c (+4/-4) libdbusmenu-gtk/dbusmenu-gtk.h (+1/-0) libdbusmenu-gtk/menuitem.h (+2/-2) libdbusmenu-gtk/serializablemenuitem.c (+288/-0) libdbusmenu-gtk/serializablemenuitem.h (+108/-0) |
To merge this branch: | bzr merge lp:~ted/libdbusmenu/serializable-menuitem |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Mikkel Kamstrup Erlandsen (community) | Needs Fixing | ||
Review via email: mp+47604@code.launchpad.net |
Commit message
Description of the change
This adds a new object that can be subclassed from to create menuitems with enough data that they can be transported across dbusmenu transparently.
Mikkel Kamstrup Erlandsen (kamstrup) wrote : | # |
Ted Gould (ted) wrote : | # |
On Thu, 2011-01-27 at 09:49 +0000, Mikkel Kamstrup Erlandsen wrote:
> The function prototypes DbusmenuClientT
> DbusmenuClientT
r215
> Can we avoid double namespacing on these two functions?:
>
> dbusmenu_
> dbusmenu_
>
> Becomes:
>
> dbusmenu_
> dbusmenu_
Yes, was looking for a good way to shorten these, thanks!
r214
> Can you add some section docs describing what the purpose of
> DbusmenuGtkSeri
> reviewing this code I am still not entirely sure what it's
> supposed to do :-)
r216
Preview Diff
1 | === modified file '.bzrignore' | |||
2 | --- .bzrignore 2010-12-02 20:13:09 +0000 | |||
3 | +++ .bzrignore 2011-01-26 23:16:59 +0000 | |||
4 | @@ -220,3 +220,6 @@ | |||
5 | 220 | libdbusmenu-gtk/DbusmenuGtk-0.4.vapi | 220 | libdbusmenu-gtk/DbusmenuGtk-0.4.vapi |
6 | 221 | libdbusmenu-gtk/dbusmenu-gtk-0.4.pc | 221 | libdbusmenu-gtk/dbusmenu-gtk-0.4.pc |
7 | 222 | libdbusmenu-gtk/dbusmenu-gtk3-0.4.pc | 222 | libdbusmenu-gtk/dbusmenu-gtk3-0.4.pc |
8 | 223 | libdbusmenu-gtk/libdbusmenu_gtk_la-serializablemenuitem.lo | ||
9 | 224 | docs/libdbusmenu-gtk/reference/html/DbusmenuGtkSerializableMenuItem.html | ||
10 | 225 | docs/libdbusmenu-gtk/reference/tmpl/serializablemenuitem.sgml | ||
11 | 223 | 226 | ||
12 | === modified file 'docs/libdbusmenu-gtk/reference/Makefile.am' | |||
13 | --- docs/libdbusmenu-gtk/reference/Makefile.am 2010-11-23 21:19:52 +0000 | |||
14 | +++ docs/libdbusmenu-gtk/reference/Makefile.am 2011-01-26 23:16:59 +0000 | |||
15 | @@ -54,7 +54,7 @@ | |||
16 | 54 | 54 | ||
17 | 55 | # Header files to ignore when scanning. | 55 | # Header files to ignore when scanning. |
18 | 56 | # e.g. IGNORE_HFILES=gtkdebug.h gtkintl.h | 56 | # e.g. IGNORE_HFILES=gtkdebug.h gtkintl.h |
20 | 57 | IGNORE_HFILES= | 57 | IGNORE_HFILES=genericmenuitem.h |
21 | 58 | 58 | ||
22 | 59 | # Images to copy into HTML directory. | 59 | # Images to copy into HTML directory. |
23 | 60 | # e.g. HTML_IMAGES=$(top_srcdir)/gtk/stock-icons/stock_about_24.png | 60 | # e.g. HTML_IMAGES=$(top_srcdir)/gtk/stock-icons/stock_about_24.png |
24 | 61 | 61 | ||
25 | === modified file 'docs/libdbusmenu-gtk/reference/libdbusmenu-gtk-docs.sgml' | |||
26 | --- docs/libdbusmenu-gtk/reference/libdbusmenu-gtk-docs.sgml 2010-06-09 16:24:31 +0000 | |||
27 | +++ docs/libdbusmenu-gtk/reference/libdbusmenu-gtk-docs.sgml 2011-01-26 23:16:59 +0000 | |||
28 | @@ -13,8 +13,8 @@ | |||
29 | 13 | <title>API</title> | 13 | <title>API</title> |
30 | 14 | <xi:include href="xml/menu.xml"/> | 14 | <xi:include href="xml/menu.xml"/> |
31 | 15 | <xi:include href="xml/client.xml"/> | 15 | <xi:include href="xml/client.xml"/> |
32 | 16 | <xi:include href="xml/genericmenuitem.xml"/> | ||
33 | 17 | <xi:include href="xml/menuitem.xml"/> | 16 | <xi:include href="xml/menuitem.xml"/> |
34 | 17 | <xi:include href="xml/serializablemenuitem.xml"/> | ||
35 | 18 | 18 | ||
36 | 19 | </chapter> | 19 | </chapter> |
37 | 20 | <chapter id="object-tree"> | 20 | <chapter id="object-tree"> |
38 | 21 | 21 | ||
39 | === modified file 'libdbusmenu-glib/client.c' | |||
40 | --- libdbusmenu-glib/client.c 2011-01-26 23:12:22 +0000 | |||
41 | +++ libdbusmenu-glib/client.c 2011-01-26 23:16:59 +0000 | |||
42 | @@ -120,6 +120,15 @@ | |||
43 | 120 | guint timestamp; | 120 | guint timestamp; |
44 | 121 | }; | 121 | }; |
45 | 122 | 122 | ||
46 | 123 | typedef struct _type_handler_t type_handler_t; | ||
47 | 124 | struct _type_handler_t { | ||
48 | 125 | DbusmenuClient * client; | ||
49 | 126 | DbusmenuClientTypeHandler cb; | ||
50 | 127 | DbusmenuClientTypeDestroyHandler destroy_cb; | ||
51 | 128 | gpointer user_data; | ||
52 | 129 | gchar * type; | ||
53 | 130 | }; | ||
54 | 131 | |||
55 | 123 | 132 | ||
56 | 124 | #define DBUSMENU_CLIENT_GET_PRIVATE(o) (DBUSMENU_CLIENT(o)->priv) | 133 | #define DBUSMENU_CLIENT_GET_PRIVATE(o) (DBUSMENU_CLIENT(o)->priv) |
57 | 125 | #define DBUSMENU_INTERFACE "com.canonical.dbusmenu" | 134 | #define DBUSMENU_INTERFACE "com.canonical.dbusmenu" |
58 | @@ -148,6 +157,7 @@ | |||
59 | 148 | static void menuproxy_build_cb (GObject * object, GAsyncResult * res, gpointer user_data); | 157 | static void menuproxy_build_cb (GObject * object, GAsyncResult * res, gpointer user_data); |
60 | 149 | static void menuproxy_name_changed_cb (GObject * object, GParamSpec * pspec, gpointer user_data); | 158 | static void menuproxy_name_changed_cb (GObject * object, GParamSpec * pspec, gpointer user_data); |
61 | 150 | static void menuproxy_signal_cb (GDBusProxy * proxy, gchar * sender, gchar * signal, GVariant * params, gpointer user_data); | 159 | static void menuproxy_signal_cb (GDBusProxy * proxy, gchar * sender, gchar * signal, GVariant * params, gpointer user_data); |
62 | 160 | static void type_handler_destroy (gpointer user_data); | ||
63 | 151 | 161 | ||
64 | 152 | /* Globals */ | 162 | /* Globals */ |
65 | 153 | static GDBusNodeInfo * dbusmenu_node_info = NULL; | 163 | static GDBusNodeInfo * dbusmenu_node_info = NULL; |
66 | @@ -310,7 +320,7 @@ | |||
67 | 310 | priv->dbusproxy = 0; | 320 | priv->dbusproxy = 0; |
68 | 311 | 321 | ||
69 | 312 | priv->type_handlers = g_hash_table_new_full(g_str_hash, g_str_equal, | 322 | priv->type_handlers = g_hash_table_new_full(g_str_hash, g_str_equal, |
71 | 313 | g_free, NULL); | 323 | g_free, type_handler_destroy); |
72 | 314 | 324 | ||
73 | 315 | priv->delayed_idle = 0; | 325 | priv->delayed_idle = 0; |
74 | 316 | priv->delayed_property_list = g_array_new(TRUE, FALSE, sizeof(gchar *)); | 326 | priv->delayed_property_list = g_array_new(TRUE, FALSE, sizeof(gchar *)); |
75 | @@ -1153,17 +1163,17 @@ | |||
76 | 1153 | gboolean handled = FALSE; | 1163 | gboolean handled = FALSE; |
77 | 1154 | 1164 | ||
78 | 1155 | const gchar * type; | 1165 | const gchar * type; |
80 | 1156 | DbusmenuClientTypeHandler newfunc = NULL; | 1166 | type_handler_t * th = NULL; |
81 | 1157 | 1167 | ||
82 | 1158 | type = dbusmenu_menuitem_property_get(propdata->item, DBUSMENU_MENUITEM_PROP_TYPE); | 1168 | type = dbusmenu_menuitem_property_get(propdata->item, DBUSMENU_MENUITEM_PROP_TYPE); |
83 | 1159 | if (type != NULL) { | 1169 | if (type != NULL) { |
85 | 1160 | newfunc = g_hash_table_lookup(priv->type_handlers, type); | 1170 | th = (type_handler_t *)g_hash_table_lookup(priv->type_handlers, type); |
86 | 1161 | } else { | 1171 | } else { |
88 | 1162 | newfunc = g_hash_table_lookup(priv->type_handlers, DBUSMENU_CLIENT_TYPES_DEFAULT); | 1172 | th = (type_handler_t *)g_hash_table_lookup(priv->type_handlers, DBUSMENU_CLIENT_TYPES_DEFAULT); |
89 | 1163 | } | 1173 | } |
90 | 1164 | 1174 | ||
93 | 1165 | if (newfunc != NULL) { | 1175 | if (th != NULL && th->cb != NULL) { |
94 | 1166 | handled = newfunc(propdata->item, propdata->parent, propdata->client); | 1176 | handled = th->cb(propdata->item, propdata->parent, propdata->client, th->user_data); |
95 | 1167 | } | 1177 | } |
96 | 1168 | 1178 | ||
97 | 1169 | #ifdef MASSIVEDEBUGGING | 1179 | #ifdef MASSIVEDEBUGGING |
98 | @@ -1679,6 +1689,19 @@ | |||
99 | 1679 | return priv->root; | 1689 | return priv->root; |
100 | 1680 | } | 1690 | } |
101 | 1681 | 1691 | ||
102 | 1692 | /* Remove the type handler when we're all done with it */ | ||
103 | 1693 | static void | ||
104 | 1694 | type_handler_destroy (gpointer user_data) | ||
105 | 1695 | { | ||
106 | 1696 | type_handler_t * th = (type_handler_t *)user_data; | ||
107 | 1697 | if (th->destroy_cb != NULL) { | ||
108 | 1698 | th->destroy_cb(th->client, th->type, th->user_data); | ||
109 | 1699 | } | ||
110 | 1700 | g_free(th->type); | ||
111 | 1701 | g_free(th); | ||
112 | 1702 | return; | ||
113 | 1703 | } | ||
114 | 1704 | |||
115 | 1682 | /** | 1705 | /** |
116 | 1683 | dbusmenu_client_add_type_handler: | 1706 | dbusmenu_client_add_type_handler: |
117 | 1684 | @client: Client where we're getting types coming in | 1707 | @client: Client where we're getting types coming in |
118 | @@ -1703,6 +1726,37 @@ | |||
119 | 1703 | gboolean | 1726 | gboolean |
120 | 1704 | dbusmenu_client_add_type_handler (DbusmenuClient * client, const gchar * type, DbusmenuClientTypeHandler newfunc) | 1727 | dbusmenu_client_add_type_handler (DbusmenuClient * client, const gchar * type, DbusmenuClientTypeHandler newfunc) |
121 | 1705 | { | 1728 | { |
122 | 1729 | return dbusmenu_client_add_type_handler_full(client, type, newfunc, NULL, NULL); | ||
123 | 1730 | } | ||
124 | 1731 | |||
125 | 1732 | /** | ||
126 | 1733 | dbusmenu_client_add_type_handler_full: | ||
127 | 1734 | @client: Client where we're getting types coming in | ||
128 | 1735 | @type: A text string that will be matched with the 'type' | ||
129 | 1736 | property on incoming menu items | ||
130 | 1737 | @newfunc: The function that will be executed with those new | ||
131 | 1738 | items when they come in. | ||
132 | 1739 | @user_data: Data passed to @newfunc when it is called | ||
133 | 1740 | @destroy_func: A function that is called when the type handler is | ||
134 | 1741 | removed (usually on client destruction) which will free | ||
135 | 1742 | the resources in @user_data. | ||
136 | 1743 | |||
137 | 1744 | This function connects into the type handling of the #DbusmenuClient. | ||
138 | 1745 | Every new menuitem that comes in immediately gets asked for it's | ||
139 | 1746 | properties. When we get those properties we check the 'type' | ||
140 | 1747 | property and look to see if it matches a handler that is known | ||
141 | 1748 | by the client. If so, the @newfunc function is executed on that | ||
142 | 1749 | #DbusmenuMenuitem. If not, then the DbusmenuClient::new-menuitem | ||
143 | 1750 | signal is sent. | ||
144 | 1751 | |||
145 | 1752 | In the future the known types will be sent to the server so that it | ||
146 | 1753 | can make choices about the menu item types availble. | ||
147 | 1754 | |||
148 | 1755 | Return value: If registering the new type was successful. | ||
149 | 1756 | */ | ||
150 | 1757 | gboolean | ||
151 | 1758 | dbusmenu_client_add_type_handler_full (DbusmenuClient * client, const gchar * type, DbusmenuClientTypeHandler newfunc, gpointer user_data, DbusmenuClientTypeDestroyHandler destroy_func) | ||
152 | 1759 | { | ||
153 | 1706 | g_return_val_if_fail(DBUSMENU_IS_CLIENT(client), FALSE); | 1760 | g_return_val_if_fail(DBUSMENU_IS_CLIENT(client), FALSE); |
154 | 1707 | g_return_val_if_fail(type != NULL, FALSE); | 1761 | g_return_val_if_fail(type != NULL, FALSE); |
155 | 1708 | 1762 | ||
156 | @@ -1723,6 +1777,14 @@ | |||
157 | 1723 | return FALSE; | 1777 | return FALSE; |
158 | 1724 | } | 1778 | } |
159 | 1725 | 1779 | ||
161 | 1726 | g_hash_table_insert(priv->type_handlers, g_strdup(type), newfunc); | 1780 | type_handler_t * th = g_new0(type_handler_t, 1); |
162 | 1781 | th->client = client; | ||
163 | 1782 | th->cb = newfunc; | ||
164 | 1783 | th->destroy_cb = destroy_func; | ||
165 | 1784 | th->user_data = user_data; | ||
166 | 1785 | th->type = g_strdup(type); | ||
167 | 1786 | |||
168 | 1787 | g_hash_table_insert(priv->type_handlers, g_strdup(type), th); | ||
169 | 1727 | return TRUE; | 1788 | return TRUE; |
170 | 1728 | } | 1789 | } |
171 | 1790 | |||
172 | 1729 | 1791 | ||
173 | === modified file 'libdbusmenu-glib/client.h' | |||
174 | --- libdbusmenu-glib/client.h 2010-11-18 03:07:51 +0000 | |||
175 | +++ libdbusmenu-glib/client.h 2011-01-26 23:16:59 +0000 | |||
176 | @@ -110,7 +110,8 @@ | |||
177 | 110 | DbusmenuClientPrivate * priv; | 110 | DbusmenuClientPrivate * priv; |
178 | 111 | }; | 111 | }; |
179 | 112 | 112 | ||
181 | 113 | typedef gboolean (*DbusmenuClientTypeHandler) (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client); | 113 | typedef gboolean (*DbusmenuClientTypeHandler) (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client, gpointer user_data); |
182 | 114 | typedef void (*DbusmenuClientTypeDestroyHandler) (DbusmenuClient * client, const gchar * type, gpointer user_data); | ||
183 | 114 | 115 | ||
184 | 115 | GType dbusmenu_client_get_type (void); | 116 | GType dbusmenu_client_get_type (void); |
185 | 116 | DbusmenuClient * dbusmenu_client_new (const gchar * name, | 117 | DbusmenuClient * dbusmenu_client_new (const gchar * name, |
186 | @@ -119,6 +120,11 @@ | |||
187 | 119 | gboolean dbusmenu_client_add_type_handler (DbusmenuClient * client, | 120 | gboolean dbusmenu_client_add_type_handler (DbusmenuClient * client, |
188 | 120 | const gchar * type, | 121 | const gchar * type, |
189 | 121 | DbusmenuClientTypeHandler newfunc); | 122 | DbusmenuClientTypeHandler newfunc); |
190 | 123 | gboolean dbusmenu_client_add_type_handler_full (DbusmenuClient * client, | ||
191 | 124 | const gchar * type, | ||
192 | 125 | DbusmenuClientTypeHandler newfunc, | ||
193 | 126 | gpointer user_data, | ||
194 | 127 | DbusmenuClientTypeDestroyHandler destory_func); | ||
195 | 122 | void dbusmenu_client_send_event (DbusmenuClient * client, | 128 | void dbusmenu_client_send_event (DbusmenuClient * client, |
196 | 123 | gint id, | 129 | gint id, |
197 | 124 | const gchar * name, | 130 | const gchar * name, |
198 | 125 | 131 | ||
199 | === modified file 'libdbusmenu-gtk/Makefile.am' | |||
200 | --- libdbusmenu-gtk/Makefile.am 2011-01-21 16:35:55 +0000 | |||
201 | +++ libdbusmenu-gtk/Makefile.am 2011-01-26 23:16:59 +0000 | |||
202 | @@ -23,7 +23,8 @@ | |||
203 | 23 | dbusmenu-gtk.h \ | 23 | dbusmenu-gtk.h \ |
204 | 24 | client.h \ | 24 | client.h \ |
205 | 25 | menu.h \ | 25 | menu.h \ |
207 | 26 | menuitem.h | 26 | menuitem.h \ |
208 | 27 | serializablemenuitem.h | ||
209 | 27 | 28 | ||
210 | 28 | libdbusmenu_gtk_la_SOURCES = \ | 29 | libdbusmenu_gtk_la_SOURCES = \ |
211 | 29 | client.h \ | 30 | client.h \ |
212 | @@ -33,7 +34,9 @@ | |||
213 | 33 | menu.h \ | 34 | menu.h \ |
214 | 34 | menu.c \ | 35 | menu.c \ |
215 | 35 | menuitem.h \ | 36 | menuitem.h \ |
217 | 36 | menuitem.c | 37 | menuitem.c \ |
218 | 38 | serializablemenuitem.h \ | ||
219 | 39 | serializablemenuitem.c | ||
220 | 37 | 40 | ||
221 | 38 | libdbusmenu_gtk_la_LDFLAGS = \ | 41 | libdbusmenu_gtk_la_LDFLAGS = \ |
222 | 39 | -version-info $(LIBDBUSMENU_CURRENT):$(LIBDBUSMENU_REVISION):$(LIBDBUSMENU_AGE) \ | 42 | -version-info $(LIBDBUSMENU_CURRENT):$(LIBDBUSMENU_REVISION):$(LIBDBUSMENU_AGE) \ |
223 | 40 | 43 | ||
224 | === modified file 'libdbusmenu-gtk/client.c' | |||
225 | --- libdbusmenu-gtk/client.c 2011-01-18 21:59:36 +0000 | |||
226 | +++ libdbusmenu-gtk/client.c 2011-01-26 23:16:59 +0000 | |||
227 | @@ -54,8 +54,8 @@ | |||
228 | 54 | static void move_child (DbusmenuMenuitem * mi, DbusmenuMenuitem * child, guint new, guint old, DbusmenuGtkClient * gtkclient); | 54 | static void move_child (DbusmenuMenuitem * mi, DbusmenuMenuitem * child, guint new, guint old, DbusmenuGtkClient * gtkclient); |
229 | 55 | static void item_activate (DbusmenuClient * client, DbusmenuMenuitem * mi, guint timestamp, gpointer userdata); | 55 | static void item_activate (DbusmenuClient * client, DbusmenuMenuitem * mi, guint timestamp, gpointer userdata); |
230 | 56 | 56 | ||
233 | 57 | static gboolean new_item_normal (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client); | 57 | static gboolean new_item_normal (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client, gpointer user_data); |
234 | 58 | static gboolean new_item_seperator (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client); | 58 | static gboolean new_item_seperator (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client, gpointer user_data); |
235 | 59 | 59 | ||
236 | 60 | static void process_visible (DbusmenuMenuitem * mi, GtkMenuItem * gmi, GVariant * value); | 60 | static void process_visible (DbusmenuMenuitem * mi, GtkMenuItem * gmi, GVariant * value); |
237 | 61 | static void process_sensitive (DbusmenuMenuitem * mi, GtkMenuItem * gmi, GVariant * value); | 61 | static void process_sensitive (DbusmenuMenuitem * mi, GtkMenuItem * gmi, GVariant * value); |
238 | @@ -684,7 +684,7 @@ | |||
239 | 684 | /* The base type handler that builds a plain ol' | 684 | /* The base type handler that builds a plain ol' |
240 | 685 | GtkMenuItem to represent, well, the GtkMenuItem */ | 685 | GtkMenuItem to represent, well, the GtkMenuItem */ |
241 | 686 | static gboolean | 686 | static gboolean |
243 | 687 | new_item_normal (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client) | 687 | new_item_normal (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client, gpointer user_data) |
244 | 688 | { | 688 | { |
245 | 689 | g_return_val_if_fail(DBUSMENU_IS_MENUITEM(newitem), FALSE); | 689 | g_return_val_if_fail(DBUSMENU_IS_MENUITEM(newitem), FALSE); |
246 | 690 | g_return_val_if_fail(DBUSMENU_IS_GTKCLIENT(client), FALSE); | 690 | g_return_val_if_fail(DBUSMENU_IS_GTKCLIENT(client), FALSE); |
247 | @@ -719,7 +719,7 @@ | |||
248 | 719 | /* Type handler for the seperators where it builds | 719 | /* Type handler for the seperators where it builds |
249 | 720 | a GtkSeparator to act as the GtkMenuItem */ | 720 | a GtkSeparator to act as the GtkMenuItem */ |
250 | 721 | static gboolean | 721 | static gboolean |
252 | 722 | new_item_seperator (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client) | 722 | new_item_seperator (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client, gpointer user_data) |
253 | 723 | { | 723 | { |
254 | 724 | g_return_val_if_fail(DBUSMENU_IS_MENUITEM(newitem), FALSE); | 724 | g_return_val_if_fail(DBUSMENU_IS_MENUITEM(newitem), FALSE); |
255 | 725 | g_return_val_if_fail(DBUSMENU_IS_GTKCLIENT(client), FALSE); | 725 | g_return_val_if_fail(DBUSMENU_IS_GTKCLIENT(client), FALSE); |
256 | 726 | 726 | ||
257 | === modified file 'libdbusmenu-gtk/dbusmenu-gtk.h' | |||
258 | --- libdbusmenu-gtk/dbusmenu-gtk.h 2011-01-21 16:35:55 +0000 | |||
259 | +++ libdbusmenu-gtk/dbusmenu-gtk.h 2011-01-26 23:16:59 +0000 | |||
260 | @@ -36,5 +36,6 @@ | |||
261 | 36 | #include <libdbusmenu-gtk/client.h> | 36 | #include <libdbusmenu-gtk/client.h> |
262 | 37 | #include <libdbusmenu-gtk/menu.h> | 37 | #include <libdbusmenu-gtk/menu.h> |
263 | 38 | #include <libdbusmenu-gtk/menuitem.h> | 38 | #include <libdbusmenu-gtk/menuitem.h> |
264 | 39 | #include <libdbusmenu-gtk/serializablemenuitem.h> | ||
265 | 39 | 40 | ||
266 | 40 | #endif /* __DBUSMENU_GLIB_H__ */ | 41 | #endif /* __DBUSMENU_GLIB_H__ */ |
267 | 41 | 42 | ||
268 | === modified file 'libdbusmenu-gtk/menuitem.h' | |||
269 | --- libdbusmenu-gtk/menuitem.h 2010-12-13 13:40:01 +0000 | |||
270 | +++ libdbusmenu-gtk/menuitem.h 2011-01-26 23:16:59 +0000 | |||
271 | @@ -26,8 +26,8 @@ | |||
272 | 26 | <http://www.gnu.org/licenses/> | 26 | <http://www.gnu.org/licenses/> |
273 | 27 | */ | 27 | */ |
274 | 28 | 28 | ||
277 | 29 | #ifndef __DBUSMENU_GTKMENUITEM_H__ | 29 | #ifndef DBUSMENU_GTK_MENUITEM_H__ |
278 | 30 | #define __DBUSMENU_GTKMENUITEM_H__ 1 | 30 | #define DBUSMENU_GTK_MENUITEM_H__ 1 |
279 | 31 | 31 | ||
280 | 32 | #include <glib.h> | 32 | #include <glib.h> |
281 | 33 | #include <gdk-pixbuf/gdk-pixbuf.h> | 33 | #include <gdk-pixbuf/gdk-pixbuf.h> |
282 | 34 | 34 | ||
283 | === added file 'libdbusmenu-gtk/serializablemenuitem.c' | |||
284 | --- libdbusmenu-gtk/serializablemenuitem.c 1970-01-01 00:00:00 +0000 | |||
285 | +++ libdbusmenu-gtk/serializablemenuitem.c 2011-01-26 23:16:59 +0000 | |||
286 | @@ -0,0 +1,288 @@ | |||
287 | 1 | /* | ||
288 | 2 | An object to act as a base class for easy GTK widgets that can be | ||
289 | 3 | transfered over dbusmenu. | ||
290 | 4 | |||
291 | 5 | Copyright 2011 Canonical Ltd. | ||
292 | 6 | |||
293 | 7 | Authors: | ||
294 | 8 | Ted Gould <ted@canonical.com> | ||
295 | 9 | |||
296 | 10 | This program is free software: you can redistribute it and/or modify it | ||
297 | 11 | under the terms of either or both of the following licenses: | ||
298 | 12 | |||
299 | 13 | 1) the GNU Lesser General Public License version 3, as published by the | ||
300 | 14 | Free Software Foundation; and/or | ||
301 | 15 | 2) the GNU Lesser General Public License version 2.1, as published by | ||
302 | 16 | the Free Software Foundation. | ||
303 | 17 | |||
304 | 18 | This program is distributed in the hope that it will be useful, but | ||
305 | 19 | WITHOUT ANY WARRANTY; without even the implied warranties of | ||
306 | 20 | MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR | ||
307 | 21 | PURPOSE. See the applicable version of the GNU Lesser General Public | ||
308 | 22 | License for more details. | ||
309 | 23 | |||
310 | 24 | You should have received a copy of both the GNU Lesser General Public | ||
311 | 25 | License version 3 and version 2.1 along with this program. If not, see | ||
312 | 26 | <http://www.gnu.org/licenses/> | ||
313 | 27 | */ | ||
314 | 28 | |||
315 | 29 | #ifdef HAVE_CONFIG_H | ||
316 | 30 | #include "config.h" | ||
317 | 31 | #endif | ||
318 | 32 | |||
319 | 33 | #include "client.h" | ||
320 | 34 | #include "serializablemenuitem.h" | ||
321 | 35 | |||
322 | 36 | /** | ||
323 | 37 | DbusmenuGtkSerializableMenuItemPrivate: | ||
324 | 38 | @mi: Menuitem to watch the property changes from | ||
325 | 39 | */ | ||
326 | 40 | struct _DbusmenuGtkSerializableMenuItemPrivate { | ||
327 | 41 | DbusmenuMenuitem * mi; | ||
328 | 42 | }; | ||
329 | 43 | |||
330 | 44 | /* Properties */ | ||
331 | 45 | enum { | ||
332 | 46 | PROP_0, | ||
333 | 47 | PROP_MENUITEM | ||
334 | 48 | }; | ||
335 | 49 | |||
336 | 50 | /* Private macro, only used in object init */ | ||
337 | 51 | #define DBUSMENU_GTK_SERIALIZABLE_MENU_ITEM_GET_PRIVATE(o) \ | ||
338 | 52 | (G_TYPE_INSTANCE_GET_PRIVATE ((o), DBUSMENU_TYPE_GTK_SERIALIZABLE_MENU_ITEM, DbusmenuGtkSerializableMenuItemPrivate)) | ||
339 | 53 | |||
340 | 54 | /* Function prototypes */ | ||
341 | 55 | static void dbusmenu_gtk_serializable_menu_item_class_init (DbusmenuGtkSerializableMenuItemClass *klass); | ||
342 | 56 | static void dbusmenu_gtk_serializable_menu_item_init (DbusmenuGtkSerializableMenuItem *self); | ||
343 | 57 | static void dbusmenu_gtk_serializable_menu_item_dispose (GObject *object); | ||
344 | 58 | static void dbusmenu_gtk_serializable_menu_item_finalize (GObject *object); | ||
345 | 59 | static void set_property (GObject * obj, | ||
346 | 60 | guint id, | ||
347 | 61 | const GValue * value, | ||
348 | 62 | GParamSpec * pspec); | ||
349 | 63 | static void get_property (GObject * obj, | ||
350 | 64 | guint id, | ||
351 | 65 | GValue * value, | ||
352 | 66 | GParamSpec * pspec); | ||
353 | 67 | |||
354 | 68 | /* GObject boiler plate */ | ||
355 | 69 | G_DEFINE_TYPE (DbusmenuGtkSerializableMenuItem, dbusmenu_gtk_serializable_menu_item, GTK_TYPE_MENU_ITEM); | ||
356 | 70 | |||
357 | 71 | /* Initialize the stuff in the class structure */ | ||
358 | 72 | static void | ||
359 | 73 | dbusmenu_gtk_serializable_menu_item_class_init (DbusmenuGtkSerializableMenuItemClass *klass) | ||
360 | 74 | { | ||
361 | 75 | GObjectClass *object_class = G_OBJECT_CLASS (klass); | ||
362 | 76 | |||
363 | 77 | g_type_class_add_private (klass, sizeof (DbusmenuGtkSerializableMenuItemPrivate)); | ||
364 | 78 | |||
365 | 79 | object_class->dispose = dbusmenu_gtk_serializable_menu_item_dispose; | ||
366 | 80 | object_class->finalize = dbusmenu_gtk_serializable_menu_item_finalize; | ||
367 | 81 | object_class->set_property = set_property; | ||
368 | 82 | object_class->get_property = get_property; | ||
369 | 83 | |||
370 | 84 | g_object_class_install_property (object_class, PROP_MENUITEM, | ||
371 | 85 | g_param_spec_object(DBUSMENU_GTK_SERIALIZABLE_MENU_ITEM_PROP_MENUITEM, "DBusmenu Menuitem attached to item", | ||
372 | 86 | "A menuitem who's properties are being watched and where changes should be watched for updates. It is the responsibility of subclasses to set up the signal handlers for those property changes.", | ||
373 | 87 | DBUSMENU_TYPE_MENUITEM, | ||
374 | 88 | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); | ||
375 | 89 | |||
376 | 90 | return; | ||
377 | 91 | } | ||
378 | 92 | |||
379 | 93 | /* Initialize the object structures and private structure */ | ||
380 | 94 | static void | ||
381 | 95 | dbusmenu_gtk_serializable_menu_item_init (DbusmenuGtkSerializableMenuItem *self) | ||
382 | 96 | { | ||
383 | 97 | self->priv = DBUSMENU_GTK_SERIALIZABLE_MENU_ITEM_GET_PRIVATE(self); | ||
384 | 98 | |||
385 | 99 | self->priv->mi = NULL; | ||
386 | 100 | |||
387 | 101 | return; | ||
388 | 102 | } | ||
389 | 103 | |||
390 | 104 | /* Free all references to objects */ | ||
391 | 105 | static void | ||
392 | 106 | dbusmenu_gtk_serializable_menu_item_dispose (GObject *object) | ||
393 | 107 | { | ||
394 | 108 | DbusmenuGtkSerializableMenuItem * smi = DBUSMENU_GTK_SERIALIZABLE_MENU_ITEM(object); | ||
395 | 109 | g_return_if_fail(smi != NULL); | ||
396 | 110 | |||
397 | 111 | if (smi->priv->mi != NULL) { | ||
398 | 112 | g_object_unref(G_OBJECT(smi->priv->mi)); | ||
399 | 113 | smi->priv->mi = NULL; | ||
400 | 114 | } | ||
401 | 115 | |||
402 | 116 | |||
403 | 117 | G_OBJECT_CLASS (dbusmenu_gtk_serializable_menu_item_parent_class)->dispose (object); | ||
404 | 118 | return; | ||
405 | 119 | } | ||
406 | 120 | |||
407 | 121 | /* Free memory */ | ||
408 | 122 | static void | ||
409 | 123 | dbusmenu_gtk_serializable_menu_item_finalize (GObject *object) | ||
410 | 124 | { | ||
411 | 125 | |||
412 | 126 | |||
413 | 127 | |||
414 | 128 | G_OBJECT_CLASS (dbusmenu_gtk_serializable_menu_item_parent_class)->finalize (object); | ||
415 | 129 | return; | ||
416 | 130 | } | ||
417 | 131 | |||
418 | 132 | /* Set an object property */ | ||
419 | 133 | static void | ||
420 | 134 | set_property (GObject * obj, guint id, const GValue * value, GParamSpec * pspec) | ||
421 | 135 | { | ||
422 | 136 | DbusmenuGtkSerializableMenuItem * smi = DBUSMENU_GTK_SERIALIZABLE_MENU_ITEM(obj); | ||
423 | 137 | |||
424 | 138 | switch (id) { | ||
425 | 139 | case PROP_MENUITEM: | ||
426 | 140 | smi->priv->mi = g_value_get_object(value); | ||
427 | 141 | break; | ||
428 | 142 | default: | ||
429 | 143 | g_return_if_reached(); | ||
430 | 144 | break; | ||
431 | 145 | } | ||
432 | 146 | |||
433 | 147 | return; | ||
434 | 148 | } | ||
435 | 149 | |||
436 | 150 | /* Get an object property */ | ||
437 | 151 | static void | ||
438 | 152 | get_property (GObject * obj, guint id, GValue * value, GParamSpec * pspec) | ||
439 | 153 | { | ||
440 | 154 | DbusmenuGtkSerializableMenuItem * smi = DBUSMENU_GTK_SERIALIZABLE_MENU_ITEM(obj); | ||
441 | 155 | |||
442 | 156 | switch (id) { | ||
443 | 157 | case PROP_MENUITEM: | ||
444 | 158 | g_value_set_object(value, smi->priv->mi); | ||
445 | 159 | break; | ||
446 | 160 | default: | ||
447 | 161 | g_return_if_reached(); | ||
448 | 162 | break; | ||
449 | 163 | } | ||
450 | 164 | |||
451 | 165 | return; | ||
452 | 166 | } | ||
453 | 167 | |||
454 | 168 | /** | ||
455 | 169 | dbusmenu_gtk_serializable_menu_item_build_dbusmenu_menuitem: | ||
456 | 170 | @smi: #DbusmenuGtkSerializableMenuItem to build a #DbusmenuMenuitem mirroring | ||
457 | 171 | |||
458 | 172 | This function is for menu items that are instanciated from | ||
459 | 173 | GTK and have their properites set using GTK functions. This | ||
460 | 174 | builds a #DbusmenuMenuitem that then has the properties that | ||
461 | 175 | should be sent over the bus to create a new item of this | ||
462 | 176 | type on the other side. | ||
463 | 177 | |||
464 | 178 | Return value: (transfer full) A #DbusmenuMenuitem who's values will be | ||
465 | 179 | set by this object. | ||
466 | 180 | */ | ||
467 | 181 | DbusmenuMenuitem * | ||
468 | 182 | dbusmenu_gtk_serializable_menu_item_build_dbusmenu_menuitem (DbusmenuGtkSerializableMenuItem * smi) | ||
469 | 183 | { | ||
470 | 184 | g_return_val_if_fail(DBUSMENU_IS_GTK_SERIALIZABLE_MENU_ITEM(smi), NULL); | ||
471 | 185 | |||
472 | 186 | DbusmenuGtkSerializableMenuItemClass * klass = DBUSMENU_GTK_SERIALIZABLE_MENU_ITEM_GET_CLASS(smi); | ||
473 | 187 | if (klass->build_dbusmenu_menuitem != NULL) { | ||
474 | 188 | return klass->build_dbusmenu_menuitem(smi); | ||
475 | 189 | } | ||
476 | 190 | |||
477 | 191 | return NULL; | ||
478 | 192 | } | ||
479 | 193 | |||
480 | 194 | /* Callback to the generic type handler */ | ||
481 | 195 | typedef struct _type_handler_t type_handler_t; | ||
482 | 196 | struct _type_handler_t { | ||
483 | 197 | DbusmenuGtkSerializableMenuItemClass * class; | ||
484 | 198 | GType type; | ||
485 | 199 | }; | ||
486 | 200 | |||
487 | 201 | /* Handle the type with this item. */ | ||
488 | 202 | static gboolean | ||
489 | 203 | type_handler (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client, gpointer user_data) | ||
490 | 204 | { | ||
491 | 205 | type_handler_t * th = (type_handler_t *)user_data; | ||
492 | 206 | |||
493 | 207 | DbusmenuGtkSerializableMenuItem * smi = DBUSMENU_GTK_SERIALIZABLE_MENU_ITEM(g_object_new(th->type, NULL)); | ||
494 | 208 | g_return_val_if_fail(smi != NULL, FALSE); | ||
495 | 209 | |||
496 | 210 | dbusmenu_gtk_serializable_menu_item_set_dbusmenu_menuitem(smi, newitem); | ||
497 | 211 | dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, GTK_MENU_ITEM(smi), parent); | ||
498 | 212 | |||
499 | 213 | return TRUE; | ||
500 | 214 | } | ||
501 | 215 | |||
502 | 216 | /* Destruction is inevitable */ | ||
503 | 217 | static void | ||
504 | 218 | type_destroy_handler (DbusmenuClient * client, const gchar * type, gpointer user_data) | ||
505 | 219 | { | ||
506 | 220 | g_return_if_fail(user_data != NULL); | ||
507 | 221 | type_handler_t * th = (type_handler_t *)user_data; | ||
508 | 222 | g_type_class_unref(th->class); | ||
509 | 223 | g_free(user_data); | ||
510 | 224 | return; | ||
511 | 225 | } | ||
512 | 226 | |||
513 | 227 | /** | ||
514 | 228 | dbusmenu_gtk_serializable_menu_item_register_to_client: | ||
515 | 229 | @client: #DbusmenuClient that we should register a type at. | ||
516 | 230 | @item_type: The #GType of a class that is a subclass of #DbusmenuGtkSerializableMenuItem | ||
517 | 231 | |||
518 | 232 | Registers a generic handler for dealing with all subclasses of | ||
519 | 233 | #DbusmenuGtkSerializableMenuItem. This handler responds to the callback, | ||
520 | 234 | creates a new object and attaches it to the appropriate #DbusmenuMenuitem | ||
521 | 235 | object. | ||
522 | 236 | */ | ||
523 | 237 | void | ||
524 | 238 | dbusmenu_gtk_serializable_menu_item_register_to_client (DbusmenuClient * client, GType item_type) | ||
525 | 239 | { | ||
526 | 240 | g_return_if_fail(g_type_is_a(item_type, DBUSMENU_TYPE_GTK_SERIALIZABLE_MENU_ITEM)); | ||
527 | 241 | |||
528 | 242 | gpointer type_class = g_type_class_ref(item_type); | ||
529 | 243 | g_return_if_fail(type_class != NULL); | ||
530 | 244 | |||
531 | 245 | DbusmenuGtkSerializableMenuItemClass * class = DBUSMENU_GTK_SERIALIZABLE_MENU_ITEM_CLASS(type_class); | ||
532 | 246 | |||
533 | 247 | if (class->get_type_string == NULL) { | ||
534 | 248 | g_type_class_unref(type_class); | ||
535 | 249 | g_error("No 'get_type_string' in subclass of DbusmenuGtkSerializableMenuItem"); | ||
536 | 250 | return; | ||
537 | 251 | } | ||
538 | 252 | |||
539 | 253 | /* Register type */ | ||
540 | 254 | type_handler_t * th = g_new0(type_handler_t, 1); | ||
541 | 255 | th->class = class; | ||
542 | 256 | th->type = item_type; | ||
543 | 257 | if (!dbusmenu_client_add_type_handler_full(client, class->get_type_string(), type_handler, th, type_destroy_handler)) { | ||
544 | 258 | type_destroy_handler(client, class->get_type_string(), th); | ||
545 | 259 | } | ||
546 | 260 | |||
547 | 261 | /* Register defaults */ | ||
548 | 262 | /* TODO: Need API on another branch */ | ||
549 | 263 | |||
550 | 264 | return; | ||
551 | 265 | } | ||
552 | 266 | |||
553 | 267 | /** | ||
554 | 268 | dbusmenu_gtk_serializable_menu_item_set_dbusmenu_menuitem: | ||
555 | 269 | @smi: #DbusmenuGtkSerializableMenuItem to set the @DbusmenuGtkSerializableMenuItem::dbusmenu-menuitem of | ||
556 | 270 | @mi: Menuitem to get the properties from | ||
557 | 271 | |||
558 | 272 | This function is used on the server side to signal to the object | ||
559 | 273 | that it should get its' property change events from @mi instead | ||
560 | 274 | of expecting calls to its' API. A call to this function sets the | ||
561 | 275 | property and subclasses should listen to the notify signal to | ||
562 | 276 | pick up this property being set. | ||
563 | 277 | */ | ||
564 | 278 | void | ||
565 | 279 | dbusmenu_gtk_serializable_menu_item_set_dbusmenu_menuitem (DbusmenuGtkSerializableMenuItem * smi, DbusmenuMenuitem * mi) | ||
566 | 280 | { | ||
567 | 281 | g_return_if_fail(DBUSMENU_IS_GTK_SERIALIZABLE_MENU_ITEM(smi)); | ||
568 | 282 | g_return_if_fail(mi != NULL); | ||
569 | 283 | |||
570 | 284 | smi->priv->mi = mi; | ||
571 | 285 | g_object_notify(G_OBJECT(smi), DBUSMENU_GTK_SERIALIZABLE_MENU_ITEM_PROP_MENUITEM); | ||
572 | 286 | |||
573 | 287 | return; | ||
574 | 288 | } | ||
575 | 0 | 289 | ||
576 | === added file 'libdbusmenu-gtk/serializablemenuitem.h' | |||
577 | --- libdbusmenu-gtk/serializablemenuitem.h 1970-01-01 00:00:00 +0000 | |||
578 | +++ libdbusmenu-gtk/serializablemenuitem.h 2011-01-26 23:16:59 +0000 | |||
579 | @@ -0,0 +1,108 @@ | |||
580 | 1 | /* | ||
581 | 2 | An object to act as a base class for easy GTK widgets that can be | ||
582 | 3 | transfered over dbusmenu. | ||
583 | 4 | |||
584 | 5 | Copyright 2011 Canonical Ltd. | ||
585 | 6 | |||
586 | 7 | Authors: | ||
587 | 8 | Ted Gould <ted@canonical.com> | ||
588 | 9 | |||
589 | 10 | This program is free software: you can redistribute it and/or modify it | ||
590 | 11 | under the terms of either or both of the following licenses: | ||
591 | 12 | |||
592 | 13 | 1) the GNU Lesser General Public License version 3, as published by the | ||
593 | 14 | Free Software Foundation; and/or | ||
594 | 15 | 2) the GNU Lesser General Public License version 2.1, as published by | ||
595 | 16 | the Free Software Foundation. | ||
596 | 17 | |||
597 | 18 | This program is distributed in the hope that it will be useful, but | ||
598 | 19 | WITHOUT ANY WARRANTY; without even the implied warranties of | ||
599 | 20 | MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR | ||
600 | 21 | PURPOSE. See the applicable version of the GNU Lesser General Public | ||
601 | 22 | License for more details. | ||
602 | 23 | |||
603 | 24 | You should have received a copy of both the GNU Lesser General Public | ||
604 | 25 | License version 3 and version 2.1 along with this program. If not, see | ||
605 | 26 | <http://www.gnu.org/licenses/> | ||
606 | 27 | */ | ||
607 | 28 | |||
608 | 29 | #ifndef DBUSMENU_GTK_SERIALIZABLE_MENU_ITEM_H__ | ||
609 | 30 | #define DBUSMENU_GTK_SERIALIZABLE_MENU_ITEM_H__ 1 | ||
610 | 31 | |||
611 | 32 | #include <glib.h> | ||
612 | 33 | #include <glib-object.h> | ||
613 | 34 | #include <gtk/gtk.h> | ||
614 | 35 | #include <libdbusmenu-glib/menuitem.h> | ||
615 | 36 | #include <libdbusmenu-glib/client.h> | ||
616 | 37 | |||
617 | 38 | G_BEGIN_DECLS | ||
618 | 39 | |||
619 | 40 | #define DBUSMENU_TYPE_GTK_SERIALIZABLE_MENU_ITEM (dbusmenu_gtk_serializable_menu_item_get_type ()) | ||
620 | 41 | #define DBUSMENU_GTK_SERIALIZABLE_MENU_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DBUSMENU_TYPE_GTK_SERIALIZABLE_MENU_ITEM, DbusmenuGtkSerializableMenuItem)) | ||
621 | 42 | #define DBUSMENU_GTK_SERIALIZABLE_MENU_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DBUSMENU_TYPE_GTK_SERIALIZABLE_MENU_ITEM, DbusmenuGtkSerializableMenuItemClass)) | ||
622 | 43 | #define DBUSMENU_IS_GTK_SERIALIZABLE_MENU_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DBUSMENU_TYPE_GTK_SERIALIZABLE_MENU_ITEM)) | ||
623 | 44 | #define DBUSMENU_IS_GTK_SERIALIZABLE_MENU_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DBUSMENU_TYPE_GTK_SERIALIZABLE_MENU_ITEM)) | ||
624 | 45 | #define DBUSMENU_GTK_SERIALIZABLE_MENU_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DBUSMENU_TYPE_GTK_SERIALIZABLE_MENU_ITEM, DbusmenuGtkSerializableMenuItemClass)) | ||
625 | 46 | |||
626 | 47 | #define DBUSMENU_GTK_SERIALIZABLE_MENU_ITEM_PROP_MENUITEM "dbusmenu-menuitem" | ||
627 | 48 | |||
628 | 49 | typedef struct _DbusmenuGtkSerializableMenuItem DbusmenuGtkSerializableMenuItem; | ||
629 | 50 | typedef struct _DbusmenuGtkSerializableMenuItemClass DbusmenuGtkSerializableMenuItemClass; | ||
630 | 51 | typedef struct _DbusmenuGtkSerializableMenuItemPrivate DbusmenuGtkSerializableMenuItemPrivate; | ||
631 | 52 | |||
632 | 53 | /** | ||
633 | 54 | DbusmenuGtkSerializableMenuItemClass: | ||
634 | 55 | @parent_class: Inherit from GtkMenuItem | ||
635 | 56 | @get_type_string: Static function to get a string describing this type | ||
636 | 57 | @get_default_properties: Return a hashtable of defaults for the menu item type | ||
637 | 58 | @build_dbusmenu_menuitem: Build a menuitem that can be sent over dbus | ||
638 | 59 | @_dbusmenu_gtk_serializable_menu_item_reserved1: Reserved for future use. | ||
639 | 60 | @_dbusmenu_gtk_serializable_menu_item_reserved2: Reserved for future use. | ||
640 | 61 | @_dbusmenu_gtk_serializable_menu_item_reserved3: Reserved for future use. | ||
641 | 62 | @_dbusmenu_gtk_serializable_menu_item_reserved4: Reserved for future use. | ||
642 | 63 | @_dbusmenu_gtk_serializable_menu_item_reserved5: Reserved for future use. | ||
643 | 64 | @_dbusmenu_gtk_serializable_menu_item_reserved6: Reserved for future use. | ||
644 | 65 | */ | ||
645 | 66 | struct _DbusmenuGtkSerializableMenuItemClass { | ||
646 | 67 | GtkMenuItemClass parent_class; | ||
647 | 68 | |||
648 | 69 | /* Subclassable functions */ | ||
649 | 70 | const gchar * (*get_type_string) (void); | ||
650 | 71 | GHashTable * (*get_default_properties) (void); | ||
651 | 72 | |||
652 | 73 | DbusmenuMenuitem * (*build_dbusmenu_menuitem) (DbusmenuGtkSerializableMenuItem * smi); | ||
653 | 74 | |||
654 | 75 | /* Signals */ | ||
655 | 76 | |||
656 | 77 | |||
657 | 78 | |||
658 | 79 | /* Empty Space */ | ||
659 | 80 | /*< Private >*/ | ||
660 | 81 | void (*_dbusmenu_gtk_serializable_menu_item_reserved1) (void); | ||
661 | 82 | void (*_dbusmenu_gtk_serializable_menu_item_reserved2) (void); | ||
662 | 83 | void (*_dbusmenu_gtk_serializable_menu_item_reserved3) (void); | ||
663 | 84 | void (*_dbusmenu_gtk_serializable_menu_item_reserved4) (void); | ||
664 | 85 | void (*_dbusmenu_gtk_serializable_menu_item_reserved5) (void); | ||
665 | 86 | void (*_dbusmenu_gtk_serializable_menu_item_reserved6) (void); | ||
666 | 87 | }; | ||
667 | 88 | |||
668 | 89 | /** | ||
669 | 90 | DbusmenuGtkSerializableMenuItem: | ||
670 | 91 | @parent: Inherit from GtkMenuItem | ||
671 | 92 | @priv: Blind structure of private variables | ||
672 | 93 | */ | ||
673 | 94 | struct _DbusmenuGtkSerializableMenuItem { | ||
674 | 95 | GtkMenuItem parent; | ||
675 | 96 | |||
676 | 97 | DbusmenuGtkSerializableMenuItemPrivate * priv; | ||
677 | 98 | }; | ||
678 | 99 | |||
679 | 100 | GType dbusmenu_gtk_serializable_menu_item_get_type (void); | ||
680 | 101 | |||
681 | 102 | DbusmenuMenuitem * dbusmenu_gtk_serializable_menu_item_build_dbusmenu_menuitem (DbusmenuGtkSerializableMenuItem * smi); | ||
682 | 103 | void dbusmenu_gtk_serializable_menu_item_register_to_client (DbusmenuClient * client, GType item_type); | ||
683 | 104 | void dbusmenu_gtk_serializable_menu_item_set_dbusmenu_menuitem (DbusmenuGtkSerializableMenuItem * smi, DbusmenuMenuitem * mi); | ||
684 | 105 | |||
685 | 106 | G_END_DECLS | ||
686 | 107 | |||
687 | 108 | #endif |
The function prototypes DbusmenuClientT ypeHandler and DbusmenuClientT ypeDestroyHandl er needs documentation.
Can we avoid double namespacing on these two functions?:
dbusmenu_ gtk_serializabl e_menu_ item_build_ dbusmenu_ menuitem( ) gtk_serializabl e_menu_ item_set_ dbusmenu_ menuitem( )
dbusmenu_
Becomes:
dbusmenu_ gtk_serializabl e_menu_ item_build_ menuitem( ) gtk_serializabl e_menu_ item_set_ menuitem( )
dbusmenu_
Can you add some section docs describing what the purpose of DbusmenuGtkSeri alizableMenuIte m is, and how to use it? After reviewing this code I am still not entirely sure what it's supposed to do :-)