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