Merge lp:~ted/libdbusmenu/parse-serializable-menuitem into lp:libdbusmenu/0.5
- parse-serializable-menuitem
- Merge into trunk
Proposed by
Ted Gould
Status: | Merged |
---|---|
Merged at revision: | 198 |
Proposed branch: | lp:~ted/libdbusmenu/parse-serializable-menuitem |
Merge into: | lp:libdbusmenu/0.5 |
Prerequisite: | lp:~ted/libdbusmenu/serializable-menuitem |
Diff against target: |
857 lines (+743/-7) (has conflicts) 6 files modified
.bzrignore (+4/-0) libdbusmenu-glib/client.h (+21/-0) libdbusmenu-gtk/Makefile.am (+3/-0) libdbusmenu-gtk/parser.c (+701/-0) libdbusmenu-gtk/serializablemenuitem.c (+5/-5) libdbusmenu-gtk/serializablemenuitem.h (+9/-2) Text conflict in .bzrignore Text conflict in libdbusmenu-gtk/Makefile.am Text conflict in libdbusmenu-gtk/parser.c |
To merge this branch: | bzr merge lp:~ted/libdbusmenu/parse-serializable-menuitem |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Mikkel Kamstrup Erlandsen | Pending | ||
Review via email: mp+47710@code.launchpad.net |
This proposal supersedes 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 :)
Resubmitting so it's dependent on serializable-
To post a comment you must log in.
Revision history for this message
Mikkel Kamstrup Erlandsen (kamstrup) wrote : Posted in a previous version of this proposal | # |
review:
Needs Information
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-27 19:48:12 +0000 | |||
3 | +++ .bzrignore 2011-01-27 19:48:12 +0000 | |||
4 | @@ -229,4 +229,8 @@ | |||
5 | 229 | libdbusmenu-gtk/libdbusmenu_gtk_la-serializablemenuitem.lo | 229 | libdbusmenu-gtk/libdbusmenu_gtk_la-serializablemenuitem.lo |
6 | 230 | docs/libdbusmenu-gtk/reference/html/DbusmenuGtkSerializableMenuItem.html | 230 | docs/libdbusmenu-gtk/reference/html/DbusmenuGtkSerializableMenuItem.html |
7 | 231 | docs/libdbusmenu-gtk/reference/tmpl/serializablemenuitem.sgml | 231 | docs/libdbusmenu-gtk/reference/tmpl/serializablemenuitem.sgml |
8 | 232 | libdbusmenu-gtk/libdbusmenu_gtk_la-parser.lo | ||
9 | 233 | test-gtk-parser | ||
10 | 234 | test-gtk-parser-test | ||
11 | 235 | test-gtk-parser.xml | ||
12 | 232 | >>>>>>> MERGE-SOURCE | 236 | >>>>>>> MERGE-SOURCE |
13 | 233 | 237 | ||
14 | === modified file 'libdbusmenu-glib/client.h' | |||
15 | --- libdbusmenu-glib/client.h 2011-01-27 19:48:12 +0000 | |||
16 | +++ libdbusmenu-glib/client.h 2011-01-27 19:48:12 +0000 | |||
17 | @@ -110,7 +110,28 @@ | |||
18 | 110 | DbusmenuClientPrivate * priv; | 110 | DbusmenuClientPrivate * priv; |
19 | 111 | }; | 111 | }; |
20 | 112 | 112 | ||
21 | 113 | /** | ||
22 | 114 | DbusmenuClientTypeHandler: | ||
23 | 115 | @newitem: The #DbusmenuMenuitem that was created | ||
24 | 116 | @parent: The parent of @newitem or #NULL if none | ||
25 | 117 | @client: A pointer to the #DbusmenuClient | ||
26 | 118 | @user_data: The data you gave us | ||
27 | 119 | |||
28 | 120 | The type handler is called when a dbusmenu item is created | ||
29 | 121 | with a matching type as setup in #dbusmenu_client_add_type_handler | ||
30 | 122 | */ | ||
31 | 113 | typedef gboolean (*DbusmenuClientTypeHandler) (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client, gpointer user_data); | 123 | typedef gboolean (*DbusmenuClientTypeHandler) (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client, gpointer user_data); |
32 | 124 | |||
33 | 125 | /** | ||
34 | 126 | DbusmenuClientTypeDestroyHandler: | ||
35 | 127 | @client: A pointer to the #DbusmenuClient | ||
36 | 128 | @type: The type that this handler was registered with | ||
37 | 129 | @user_data: The data you gave us | ||
38 | 130 | |||
39 | 131 | This handler is called when the type becomes unregistered by the | ||
40 | 132 | client. This is usally caused by the #DbusmenuClient being destroyed | ||
41 | 133 | and should free memory or unref objects in @user_data. | ||
42 | 134 | */ | ||
43 | 114 | typedef void (*DbusmenuClientTypeDestroyHandler) (DbusmenuClient * client, const gchar * type, gpointer user_data); | 135 | typedef void (*DbusmenuClientTypeDestroyHandler) (DbusmenuClient * client, const gchar * type, gpointer user_data); |
44 | 115 | 136 | ||
45 | 116 | GType dbusmenu_client_get_type (void); | 137 | GType dbusmenu_client_get_type (void); |
46 | 117 | 138 | ||
47 | === modified file 'libdbusmenu-gtk/Makefile.am' | |||
48 | --- libdbusmenu-gtk/Makefile.am 2011-01-27 19:48:12 +0000 | |||
49 | +++ libdbusmenu-gtk/Makefile.am 2011-01-27 19:48:12 +0000 | |||
50 | @@ -28,6 +28,7 @@ | |||
51 | 28 | parser.h | 28 | parser.h |
52 | 29 | ======= | 29 | ======= |
53 | 30 | menuitem.h \ | 30 | menuitem.h \ |
54 | 31 | parser.h \ | ||
55 | 31 | serializablemenuitem.h | 32 | serializablemenuitem.h |
56 | 32 | >>>>>>> MERGE-SOURCE | 33 | >>>>>>> MERGE-SOURCE |
57 | 33 | 34 | ||
58 | @@ -45,6 +46,8 @@ | |||
59 | 45 | parser.c | 46 | parser.c |
60 | 46 | ======= | 47 | ======= |
61 | 47 | menuitem.c \ | 48 | menuitem.c \ |
62 | 49 | parser.h \ | ||
63 | 50 | parser.c \ | ||
64 | 48 | serializablemenuitem.h \ | 51 | serializablemenuitem.h \ |
65 | 49 | serializablemenuitem.c | 52 | serializablemenuitem.c |
66 | 50 | >>>>>>> MERGE-SOURCE | 53 | >>>>>>> MERGE-SOURCE |
67 | 51 | 54 | ||
68 | === modified file 'libdbusmenu-gtk/parser.c' | |||
69 | --- libdbusmenu-gtk/parser.c 2011-01-27 14:50:24 +0000 | |||
70 | +++ libdbusmenu-gtk/parser.c 2011-01-27 19:48:12 +0000 | |||
71 | @@ -1,3 +1,4 @@ | |||
72 | 1 | <<<<<<< TREE | ||
73 | 1 | /* | 2 | /* |
74 | 2 | Parse to take a set of GTK Menus and turn them into something that can | 3 | Parse to take a set of GTK Menus and turn them into something that can |
75 | 3 | be sent over the wire. | 4 | be sent over the wire. |
76 | @@ -665,3 +666,703 @@ | |||
77 | 665 | return FALSE; | 666 | return FALSE; |
78 | 666 | } | 667 | } |
79 | 667 | 668 | ||
80 | 669 | ======= | ||
81 | 670 | /* | ||
82 | 671 | Parse to take a set of GTK Menus and turn them into something that can | ||
83 | 672 | be sent over the wire. | ||
84 | 673 | |||
85 | 674 | Copyright 2011 Canonical Ltd. | ||
86 | 675 | |||
87 | 676 | Authors: | ||
88 | 677 | Numerous (check Bazaar) | ||
89 | 678 | |||
90 | 679 | This program is free software: you can redistribute it and/or modify it | ||
91 | 680 | under the terms of either or both of the following licenses: | ||
92 | 681 | |||
93 | 682 | 1) the GNU Lesser General Public License version 3, as published by the | ||
94 | 683 | Free Software Foundation; and/or | ||
95 | 684 | 2) the GNU Lesser General Public License version 2.1, as published by | ||
96 | 685 | the Free Software Foundation. | ||
97 | 686 | |||
98 | 687 | This program is distributed in the hope that it will be useful, but | ||
99 | 688 | WITHOUT ANY WARRANTY; without even the implied warranties of | ||
100 | 689 | MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR | ||
101 | 690 | PURPOSE. See the applicable version of the GNU Lesser General Public | ||
102 | 691 | License for more details. | ||
103 | 692 | |||
104 | 693 | You should have received a copy of both the GNU Lesser General Public | ||
105 | 694 | License version 3 and version 2.1 along with this program. If not, see | ||
106 | 695 | <http://www.gnu.org/licenses/> | ||
107 | 696 | */ | ||
108 | 697 | |||
109 | 698 | #include "parser.h" | ||
110 | 699 | #include "menuitem.h" | ||
111 | 700 | #include "serializablemenuitem.h" | ||
112 | 701 | |||
113 | 702 | #define CACHED_MENUITEM "dbusmenu-gtk-parser-cached-item" | ||
114 | 703 | |||
115 | 704 | typedef struct _RecurseContext | ||
116 | 705 | { | ||
117 | 706 | GtkWidget * toplevel; | ||
118 | 707 | gint count; | ||
119 | 708 | DbusmenuMenuitem *stack[30]; | ||
120 | 709 | } RecurseContext; | ||
121 | 710 | |||
122 | 711 | static void parse_menu_structure_helper (GtkWidget * widget, RecurseContext * recurse); | ||
123 | 712 | static DbusmenuMenuitem * construct_dbusmenu_for_widget (GtkWidget * widget); | ||
124 | 713 | static void accel_changed (GtkWidget * widget, | ||
125 | 714 | gpointer data); | ||
126 | 715 | static gboolean update_stock_item (DbusmenuMenuitem * menuitem, | ||
127 | 716 | GtkWidget * widget); | ||
128 | 717 | static void checkbox_toggled (GtkWidget * widget, | ||
129 | 718 | DbusmenuMenuitem * mi); | ||
130 | 719 | static void update_icon_name (DbusmenuMenuitem * menuitem, | ||
131 | 720 | GtkWidget * widget); | ||
132 | 721 | static GtkWidget * find_menu_label (GtkWidget * widget); | ||
133 | 722 | static void label_notify_cb (GtkWidget * widget, | ||
134 | 723 | GParamSpec * pspec, | ||
135 | 724 | gpointer data); | ||
136 | 725 | static void action_notify_cb (GtkAction * action, | ||
137 | 726 | GParamSpec * pspec, | ||
138 | 727 | gpointer data); | ||
139 | 728 | static void item_activated (DbusmenuMenuitem * item, | ||
140 | 729 | guint timestamp, | ||
141 | 730 | gpointer user_data); | ||
142 | 731 | static gboolean item_about_to_show (DbusmenuMenuitem * item, | ||
143 | 732 | gpointer user_data); | ||
144 | 733 | static void widget_notify_cb (GtkWidget * widget, | ||
145 | 734 | GParamSpec * pspec, | ||
146 | 735 | gpointer data); | ||
147 | 736 | static gboolean should_show_image (GtkImage * image); | ||
148 | 737 | static void menuitem_notify_cb (GtkWidget * widget, | ||
149 | 738 | GParamSpec * pspec, | ||
150 | 739 | gpointer data); | ||
151 | 740 | |||
152 | 741 | DbusmenuMenuitem * | ||
153 | 742 | dbusmenu_gtk_parse_menu_structure (GtkWidget * widget) | ||
154 | 743 | { | ||
155 | 744 | RecurseContext recurse = {0}; | ||
156 | 745 | |||
157 | 746 | recurse.count = -1; | ||
158 | 747 | recurse.toplevel = gtk_widget_get_toplevel(widget); | ||
159 | 748 | |||
160 | 749 | parse_menu_structure_helper(widget, &recurse); | ||
161 | 750 | |||
162 | 751 | if (recurse.stack[0] != NULL && DBUSMENU_IS_MENUITEM(recurse.stack[0])) { | ||
163 | 752 | return recurse.stack[0]; | ||
164 | 753 | } | ||
165 | 754 | |||
166 | 755 | return NULL; | ||
167 | 756 | } | ||
168 | 757 | |||
169 | 758 | static void | ||
170 | 759 | dbusmenu_cache_freed (gpointer data, GObject * obj) | ||
171 | 760 | { | ||
172 | 761 | /* If the dbusmenu item is killed we don't need to remove | ||
173 | 762 | the weak ref as well. */ | ||
174 | 763 | g_object_steal_data(G_OBJECT(data), CACHED_MENUITEM); | ||
175 | 764 | return; | ||
176 | 765 | } | ||
177 | 766 | |||
178 | 767 | static void | ||
179 | 768 | object_cache_freed (gpointer data) | ||
180 | 769 | { | ||
181 | 770 | g_object_weak_unref(G_OBJECT(data), dbusmenu_cache_freed, data); | ||
182 | 771 | return; | ||
183 | 772 | } | ||
184 | 773 | |||
185 | 774 | static void | ||
186 | 775 | parse_menu_structure_helper (GtkWidget * widget, RecurseContext * recurse) | ||
187 | 776 | { | ||
188 | 777 | if (GTK_IS_CONTAINER (widget)) | ||
189 | 778 | { | ||
190 | 779 | gboolean increment = GTK_IS_MENU_SHELL (widget) || GTK_IS_MENU_ITEM (widget); | ||
191 | 780 | |||
192 | 781 | if (increment) | ||
193 | 782 | recurse->count++; | ||
194 | 783 | |||
195 | 784 | /* Okay, this is a little janky and all.. but some applications update some | ||
196 | 785 | * menuitem properties such as sensitivity on the activate callback. This | ||
197 | 786 | * seems a little weird, but it's not our place to judge when all this code | ||
198 | 787 | * is so crazy. So we're going to get ever crazier and activate all the | ||
199 | 788 | * menus that are directly below the menubar and force the applications to | ||
200 | 789 | * update their sensitivity. The menus won't actually popup in the app | ||
201 | 790 | * window due to our gtk+ patches. | ||
202 | 791 | * | ||
203 | 792 | * Note that this will not force menuitems in submenus to be updated as well. | ||
204 | 793 | */ | ||
205 | 794 | if (recurse->count == 0 && GTK_IS_MENU_BAR (widget)) | ||
206 | 795 | { | ||
207 | 796 | GList *children = gtk_container_get_children (GTK_CONTAINER (widget)); | ||
208 | 797 | |||
209 | 798 | for (; children != NULL; children = children->next) | ||
210 | 799 | { | ||
211 | 800 | gtk_menu_shell_activate_item (GTK_MENU_SHELL (widget), | ||
212 | 801 | children->data, | ||
213 | 802 | TRUE); | ||
214 | 803 | } | ||
215 | 804 | |||
216 | 805 | g_list_free (children); | ||
217 | 806 | } | ||
218 | 807 | |||
219 | 808 | if (recurse->count > -1 && increment) | ||
220 | 809 | { | ||
221 | 810 | gpointer pmi = g_object_get_data(G_OBJECT(widget), CACHED_MENUITEM); | ||
222 | 811 | DbusmenuMenuitem *dmi = NULL; | ||
223 | 812 | if (pmi != NULL) dmi = DBUSMENU_MENUITEM(pmi); | ||
224 | 813 | |||
225 | 814 | if (dmi != NULL) | ||
226 | 815 | { | ||
227 | 816 | if (increment) | ||
228 | 817 | recurse->count--; | ||
229 | 818 | |||
230 | 819 | return; | ||
231 | 820 | } | ||
232 | 821 | else | ||
233 | 822 | { | ||
234 | 823 | recurse->stack[recurse->count] = construct_dbusmenu_for_widget (widget); | ||
235 | 824 | g_object_set_data_full(G_OBJECT(widget), CACHED_MENUITEM, recurse->stack[recurse->count], object_cache_freed); | ||
236 | 825 | g_object_weak_ref(G_OBJECT(recurse->stack[recurse->count]), dbusmenu_cache_freed, widget); | ||
237 | 826 | } | ||
238 | 827 | |||
239 | 828 | if (!gtk_widget_get_visible (widget)) | ||
240 | 829 | { | ||
241 | 830 | g_signal_connect (G_OBJECT (widget), | ||
242 | 831 | "notify::visible", | ||
243 | 832 | G_CALLBACK (menuitem_notify_cb), | ||
244 | 833 | recurse->toplevel); | ||
245 | 834 | } | ||
246 | 835 | |||
247 | 836 | if (GTK_IS_TEAROFF_MENU_ITEM (widget)) | ||
248 | 837 | { | ||
249 | 838 | dbusmenu_menuitem_property_set_bool (recurse->stack[recurse->count], | ||
250 | 839 | DBUSMENU_MENUITEM_PROP_VISIBLE, | ||
251 | 840 | FALSE); | ||
252 | 841 | } | ||
253 | 842 | |||
254 | 843 | if (recurse->count > 0) | ||
255 | 844 | { | ||
256 | 845 | GList *children = NULL; | ||
257 | 846 | GList *peek = NULL; | ||
258 | 847 | |||
259 | 848 | if (recurse->stack[recurse->count - 1]) | ||
260 | 849 | { | ||
261 | 850 | children = dbusmenu_menuitem_get_children (recurse->stack[recurse->count - 1]); | ||
262 | 851 | |||
263 | 852 | if (children) | ||
264 | 853 | { | ||
265 | 854 | peek = g_list_find (children, recurse->stack[recurse->count]); | ||
266 | 855 | } | ||
267 | 856 | |||
268 | 857 | if (!peek) | ||
269 | 858 | { | ||
270 | 859 | /* Should we set a weak ref on the parent? */ | ||
271 | 860 | g_object_set_data (G_OBJECT (recurse->stack[recurse->count]), | ||
272 | 861 | "dbusmenu-parent", | ||
273 | 862 | recurse->stack[recurse->count - 1]); | ||
274 | 863 | dbusmenu_menuitem_child_append (recurse->stack[recurse->count - 1], | ||
275 | 864 | recurse->stack[recurse->count]); | ||
276 | 865 | } | ||
277 | 866 | } | ||
278 | 867 | else | ||
279 | 868 | { | ||
280 | 869 | DbusmenuMenuitem *item = NULL; /* g_hash_table_lookup (recurse->context->lookup, | ||
281 | 870 | gtk_widget_get_parent (widget)); */ | ||
282 | 871 | |||
283 | 872 | if (item) | ||
284 | 873 | { | ||
285 | 874 | children = dbusmenu_menuitem_get_children (item); | ||
286 | 875 | |||
287 | 876 | if (children) | ||
288 | 877 | { | ||
289 | 878 | peek = g_list_find (children, recurse->stack[recurse->count]); | ||
290 | 879 | } | ||
291 | 880 | |||
292 | 881 | if (!peek) | ||
293 | 882 | { | ||
294 | 883 | g_object_set_data (G_OBJECT (recurse->stack[recurse->count]), | ||
295 | 884 | "dbusmenu-parent", | ||
296 | 885 | recurse->stack[recurse->count - 1]); | ||
297 | 886 | |||
298 | 887 | dbusmenu_menuitem_child_append (item, recurse->stack[recurse->count]); | ||
299 | 888 | } | ||
300 | 889 | } | ||
301 | 890 | } | ||
302 | 891 | } | ||
303 | 892 | } | ||
304 | 893 | |||
305 | 894 | gtk_container_foreach (GTK_CONTAINER (widget), | ||
306 | 895 | (GtkCallback)parse_menu_structure_helper, | ||
307 | 896 | recurse); | ||
308 | 897 | |||
309 | 898 | if (GTK_IS_MENU_ITEM (widget)) | ||
310 | 899 | { | ||
311 | 900 | GtkWidget *menu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (widget)); | ||
312 | 901 | |||
313 | 902 | if (menu != NULL) | ||
314 | 903 | { | ||
315 | 904 | parse_menu_structure_helper (menu, recurse); | ||
316 | 905 | } | ||
317 | 906 | } | ||
318 | 907 | |||
319 | 908 | if (increment) | ||
320 | 909 | recurse->count--; | ||
321 | 910 | } | ||
322 | 911 | } | ||
323 | 912 | |||
324 | 913 | /* Turn a widget into a dbusmenu item depending on the type of GTK | ||
325 | 914 | object that it is. */ | ||
326 | 915 | static DbusmenuMenuitem * | ||
327 | 916 | construct_dbusmenu_for_widget (GtkWidget * widget) | ||
328 | 917 | { | ||
329 | 918 | /* If it's a subclass of our serializable menu item then we can | ||
330 | 919 | use its own build function */ | ||
331 | 920 | if (DBUSMENU_IS_GTK_SERIALIZABLE_MENU_ITEM(widget)) { | ||
332 | 921 | DbusmenuGtkSerializableMenuItem * smi = DBUSMENU_GTK_SERIALIZABLE_MENU_ITEM(widget); | ||
333 | 922 | return dbusmenu_gtk_serializable_menu_item_build_menuitem(smi); | ||
334 | 923 | } | ||
335 | 924 | |||
336 | 925 | /* If it's a standard GTK Menu Item we need to do some of our own work */ | ||
337 | 926 | if (GTK_IS_MENU_ITEM (widget)) | ||
338 | 927 | { | ||
339 | 928 | DbusmenuMenuitem *mi = dbusmenu_menuitem_new (); | ||
340 | 929 | |||
341 | 930 | gboolean visible = FALSE; | ||
342 | 931 | gboolean sensitive = FALSE; | ||
343 | 932 | if (GTK_IS_SEPARATOR_MENU_ITEM (widget)) | ||
344 | 933 | { | ||
345 | 934 | dbusmenu_menuitem_property_set (mi, | ||
346 | 935 | "type", | ||
347 | 936 | "separator"); | ||
348 | 937 | |||
349 | 938 | visible = gtk_widget_get_visible (widget); | ||
350 | 939 | sensitive = gtk_widget_get_sensitive (widget); | ||
351 | 940 | } | ||
352 | 941 | else | ||
353 | 942 | { | ||
354 | 943 | gboolean label_set = FALSE; | ||
355 | 944 | |||
356 | 945 | g_signal_connect (widget, | ||
357 | 946 | "accel-closures-changed", | ||
358 | 947 | G_CALLBACK (accel_changed), | ||
359 | 948 | mi); | ||
360 | 949 | |||
361 | 950 | if (GTK_IS_CHECK_MENU_ITEM (widget)) | ||
362 | 951 | { | ||
363 | 952 | dbusmenu_menuitem_property_set (mi, | ||
364 | 953 | DBUSMENU_MENUITEM_PROP_TOGGLE_TYPE, | ||
365 | 954 | gtk_check_menu_item_get_draw_as_radio (GTK_CHECK_MENU_ITEM (widget)) ? DBUSMENU_MENUITEM_TOGGLE_RADIO : DBUSMENU_MENUITEM_TOGGLE_CHECK); | ||
366 | 955 | |||
367 | 956 | dbusmenu_menuitem_property_set_int (mi, | ||
368 | 957 | DBUSMENU_MENUITEM_PROP_TOGGLE_STATE, | ||
369 | 958 | gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (widget)) ? DBUSMENU_MENUITEM_TOGGLE_STATE_CHECKED : DBUSMENU_MENUITEM_TOGGLE_STATE_UNCHECKED); | ||
370 | 959 | |||
371 | 960 | g_signal_connect (widget, | ||
372 | 961 | "activate", | ||
373 | 962 | G_CALLBACK (checkbox_toggled), | ||
374 | 963 | mi); | ||
375 | 964 | } | ||
376 | 965 | |||
377 | 966 | if (GTK_IS_IMAGE_MENU_ITEM (widget)) | ||
378 | 967 | { | ||
379 | 968 | GtkWidget *image; | ||
380 | 969 | GtkImageType image_type; | ||
381 | 970 | |||
382 | 971 | image = gtk_image_menu_item_get_image (GTK_IMAGE_MENU_ITEM (widget)); | ||
383 | 972 | |||
384 | 973 | if (GTK_IS_IMAGE (image)) | ||
385 | 974 | { | ||
386 | 975 | image_type = gtk_image_get_storage_type (GTK_IMAGE (image)); | ||
387 | 976 | |||
388 | 977 | if (image_type == GTK_IMAGE_STOCK) | ||
389 | 978 | { | ||
390 | 979 | label_set = update_stock_item (mi, image); | ||
391 | 980 | } | ||
392 | 981 | else if (image_type == GTK_IMAGE_ICON_NAME) | ||
393 | 982 | { | ||
394 | 983 | update_icon_name (mi, image); | ||
395 | 984 | } | ||
396 | 985 | else if (image_type == GTK_IMAGE_PIXBUF) | ||
397 | 986 | { | ||
398 | 987 | dbusmenu_menuitem_property_set_image (mi, | ||
399 | 988 | DBUSMENU_MENUITEM_PROP_ICON_DATA, | ||
400 | 989 | gtk_image_get_pixbuf (GTK_IMAGE (image))); | ||
401 | 990 | } | ||
402 | 991 | } | ||
403 | 992 | } | ||
404 | 993 | |||
405 | 994 | GtkWidget *label = find_menu_label (widget); | ||
406 | 995 | |||
407 | 996 | dbusmenu_menuitem_property_set (mi, | ||
408 | 997 | "label", | ||
409 | 998 | label ? gtk_label_get_text (GTK_LABEL (label)) : NULL); | ||
410 | 999 | |||
411 | 1000 | if (label) | ||
412 | 1001 | { | ||
413 | 1002 | // Sometimes, an app will directly find and modify the label | ||
414 | 1003 | // (like empathy), so watch the label especially for that. | ||
415 | 1004 | g_signal_connect (G_OBJECT (label), | ||
416 | 1005 | "notify", | ||
417 | 1006 | G_CALLBACK (label_notify_cb), | ||
418 | 1007 | mi); | ||
419 | 1008 | } | ||
420 | 1009 | |||
421 | 1010 | if (GTK_IS_ACTIVATABLE (widget)) | ||
422 | 1011 | { | ||
423 | 1012 | GtkActivatable *activatable = GTK_ACTIVATABLE (widget); | ||
424 | 1013 | |||
425 | 1014 | if (gtk_activatable_get_use_action_appearance (activatable)) | ||
426 | 1015 | { | ||
427 | 1016 | GtkAction *action = gtk_activatable_get_related_action (activatable); | ||
428 | 1017 | |||
429 | 1018 | if (action) | ||
430 | 1019 | { | ||
431 | 1020 | visible = gtk_action_is_visible (action); | ||
432 | 1021 | sensitive = gtk_action_is_sensitive (action); | ||
433 | 1022 | |||
434 | 1023 | g_signal_connect_object (action, "notify", | ||
435 | 1024 | G_CALLBACK (action_notify_cb), | ||
436 | 1025 | mi, | ||
437 | 1026 | G_CONNECT_AFTER); | ||
438 | 1027 | } | ||
439 | 1028 | } | ||
440 | 1029 | } | ||
441 | 1030 | |||
442 | 1031 | if (!g_object_get_data (G_OBJECT (widget), "gtk-empty-menu-item") && !GTK_IS_TEAROFF_MENU_ITEM (widget)) | ||
443 | 1032 | { | ||
444 | 1033 | visible = gtk_widget_get_visible (widget); | ||
445 | 1034 | sensitive = gtk_widget_get_sensitive (widget); | ||
446 | 1035 | } | ||
447 | 1036 | |||
448 | 1037 | dbusmenu_menuitem_property_set_shortcut_menuitem (mi, GTK_MENU_ITEM (widget)); | ||
449 | 1038 | |||
450 | 1039 | g_signal_connect (G_OBJECT (mi), | ||
451 | 1040 | DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, | ||
452 | 1041 | G_CALLBACK (item_activated), | ||
453 | 1042 | widget); | ||
454 | 1043 | |||
455 | 1044 | g_signal_connect (G_OBJECT (mi), | ||
456 | 1045 | DBUSMENU_MENUITEM_SIGNAL_ABOUT_TO_SHOW, | ||
457 | 1046 | G_CALLBACK (item_about_to_show), | ||
458 | 1047 | widget); | ||
459 | 1048 | } | ||
460 | 1049 | |||
461 | 1050 | dbusmenu_menuitem_property_set_bool (mi, | ||
462 | 1051 | DBUSMENU_MENUITEM_PROP_VISIBLE, | ||
463 | 1052 | visible); | ||
464 | 1053 | |||
465 | 1054 | dbusmenu_menuitem_property_set_bool (mi, | ||
466 | 1055 | DBUSMENU_MENUITEM_PROP_ENABLED, | ||
467 | 1056 | sensitive); | ||
468 | 1057 | |||
469 | 1058 | g_signal_connect (widget, | ||
470 | 1059 | "notify", | ||
471 | 1060 | G_CALLBACK (widget_notify_cb), | ||
472 | 1061 | mi); | ||
473 | 1062 | return mi; | ||
474 | 1063 | } | ||
475 | 1064 | |||
476 | 1065 | /* If it's none of those we're going to just create a | ||
477 | 1066 | generic menuitem as a place holder for it. */ | ||
478 | 1067 | return dbusmenu_menuitem_new(); | ||
479 | 1068 | } | ||
480 | 1069 | |||
481 | 1070 | static void | ||
482 | 1071 | menuitem_notify_cb (GtkWidget *widget, | ||
483 | 1072 | GParamSpec *pspec, | ||
484 | 1073 | gpointer data) | ||
485 | 1074 | { | ||
486 | 1075 | if (pspec->name == g_intern_static_string ("visible")) | ||
487 | 1076 | { | ||
488 | 1077 | GtkWidget * new_toplevel = gtk_widget_get_toplevel (widget); | ||
489 | 1078 | GtkWidget * old_toplevel = GTK_WIDGET(data); | ||
490 | 1079 | |||
491 | 1080 | if (new_toplevel == old_toplevel) { | ||
492 | 1081 | /* TODO: Figure this out -> rebuild (context->bridge, window); */ | ||
493 | 1082 | } | ||
494 | 1083 | |||
495 | 1084 | /* We only care about this once, so let's disconnect now. */ | ||
496 | 1085 | g_signal_handlers_disconnect_by_func (widget, | ||
497 | 1086 | G_CALLBACK (menuitem_notify_cb), | ||
498 | 1087 | data); | ||
499 | 1088 | } | ||
500 | 1089 | } | ||
501 | 1090 | |||
502 | 1091 | static void | ||
503 | 1092 | accel_changed (GtkWidget *widget, | ||
504 | 1093 | gpointer data) | ||
505 | 1094 | { | ||
506 | 1095 | DbusmenuMenuitem *mi = (DbusmenuMenuitem *)data; | ||
507 | 1096 | dbusmenu_menuitem_property_set_shortcut_menuitem (mi, GTK_MENU_ITEM (widget)); | ||
508 | 1097 | } | ||
509 | 1098 | |||
510 | 1099 | static gboolean | ||
511 | 1100 | update_stock_item (DbusmenuMenuitem *menuitem, | ||
512 | 1101 | GtkWidget *widget) | ||
513 | 1102 | { | ||
514 | 1103 | GtkStockItem stock; | ||
515 | 1104 | GtkImage *image; | ||
516 | 1105 | |||
517 | 1106 | g_return_val_if_fail (GTK_IS_IMAGE (widget), FALSE); | ||
518 | 1107 | |||
519 | 1108 | image = GTK_IMAGE (widget); | ||
520 | 1109 | |||
521 | 1110 | if (gtk_image_get_storage_type (image) != GTK_IMAGE_STOCK) | ||
522 | 1111 | return FALSE; | ||
523 | 1112 | |||
524 | 1113 | gchar * stock_id = NULL; | ||
525 | 1114 | gtk_image_get_stock(image, &stock_id, NULL); | ||
526 | 1115 | |||
527 | 1116 | gtk_stock_lookup (stock_id, &stock); | ||
528 | 1117 | |||
529 | 1118 | if (should_show_image (image)) | ||
530 | 1119 | dbusmenu_menuitem_property_set (menuitem, | ||
531 | 1120 | DBUSMENU_MENUITEM_PROP_ICON_NAME, | ||
532 | 1121 | stock_id); | ||
533 | 1122 | else | ||
534 | 1123 | dbusmenu_menuitem_property_remove (menuitem, | ||
535 | 1124 | DBUSMENU_MENUITEM_PROP_ICON_NAME); | ||
536 | 1125 | |||
537 | 1126 | const gchar *label = dbusmenu_menuitem_property_get (menuitem, | ||
538 | 1127 | DBUSMENU_MENUITEM_PROP_LABEL); | ||
539 | 1128 | |||
540 | 1129 | if (stock.label != NULL && label != NULL) | ||
541 | 1130 | { | ||
542 | 1131 | dbusmenu_menuitem_property_set (menuitem, | ||
543 | 1132 | DBUSMENU_MENUITEM_PROP_LABEL, | ||
544 | 1133 | stock.label); | ||
545 | 1134 | |||
546 | 1135 | return TRUE; | ||
547 | 1136 | } | ||
548 | 1137 | |||
549 | 1138 | return FALSE; | ||
550 | 1139 | } | ||
551 | 1140 | |||
552 | 1141 | static void | ||
553 | 1142 | checkbox_toggled (GtkWidget *widget, DbusmenuMenuitem *mi) | ||
554 | 1143 | { | ||
555 | 1144 | dbusmenu_menuitem_property_set_int (mi, | ||
556 | 1145 | DBUSMENU_MENUITEM_PROP_TOGGLE_STATE, | ||
557 | 1146 | gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (widget)) ? DBUSMENU_MENUITEM_TOGGLE_STATE_CHECKED : DBUSMENU_MENUITEM_TOGGLE_STATE_UNCHECKED); | ||
558 | 1147 | } | ||
559 | 1148 | |||
560 | 1149 | static void | ||
561 | 1150 | update_icon_name (DbusmenuMenuitem *menuitem, | ||
562 | 1151 | GtkWidget *widget) | ||
563 | 1152 | { | ||
564 | 1153 | GtkImage *image; | ||
565 | 1154 | |||
566 | 1155 | g_return_if_fail (GTK_IS_IMAGE (widget)); | ||
567 | 1156 | |||
568 | 1157 | image = GTK_IMAGE (widget); | ||
569 | 1158 | |||
570 | 1159 | if (gtk_image_get_storage_type (image) != GTK_IMAGE_ICON_NAME) | ||
571 | 1160 | return; | ||
572 | 1161 | |||
573 | 1162 | if (should_show_image (image)) { | ||
574 | 1163 | const gchar * icon_name = NULL; | ||
575 | 1164 | gtk_image_get_icon_name(image, &icon_name, NULL); | ||
576 | 1165 | dbusmenu_menuitem_property_set (menuitem, | ||
577 | 1166 | DBUSMENU_MENUITEM_PROP_ICON_NAME, | ||
578 | 1167 | icon_name); | ||
579 | 1168 | } else { | ||
580 | 1169 | dbusmenu_menuitem_property_remove (menuitem, | ||
581 | 1170 | DBUSMENU_MENUITEM_PROP_ICON_NAME); | ||
582 | 1171 | } | ||
583 | 1172 | } | ||
584 | 1173 | |||
585 | 1174 | static GtkWidget * | ||
586 | 1175 | find_menu_label (GtkWidget *widget) | ||
587 | 1176 | { | ||
588 | 1177 | GtkWidget *label = NULL; | ||
589 | 1178 | |||
590 | 1179 | if (GTK_IS_LABEL (widget)) | ||
591 | 1180 | return widget; | ||
592 | 1181 | |||
593 | 1182 | if (GTK_IS_CONTAINER (widget)) | ||
594 | 1183 | { | ||
595 | 1184 | GList *children; | ||
596 | 1185 | GList *l; | ||
597 | 1186 | |||
598 | 1187 | children = gtk_container_get_children (GTK_CONTAINER (widget)); | ||
599 | 1188 | |||
600 | 1189 | for (l = children; l; l = l->next) | ||
601 | 1190 | { | ||
602 | 1191 | label = find_menu_label (l->data); | ||
603 | 1192 | |||
604 | 1193 | if (label) | ||
605 | 1194 | break; | ||
606 | 1195 | } | ||
607 | 1196 | |||
608 | 1197 | g_list_free (children); | ||
609 | 1198 | } | ||
610 | 1199 | |||
611 | 1200 | return label; | ||
612 | 1201 | } | ||
613 | 1202 | |||
614 | 1203 | static void | ||
615 | 1204 | label_notify_cb (GtkWidget *widget, | ||
616 | 1205 | GParamSpec *pspec, | ||
617 | 1206 | gpointer data) | ||
618 | 1207 | { | ||
619 | 1208 | DbusmenuMenuitem *child = (DbusmenuMenuitem *)data; | ||
620 | 1209 | |||
621 | 1210 | if (pspec->name == g_intern_static_string ("label")) | ||
622 | 1211 | { | ||
623 | 1212 | dbusmenu_menuitem_property_set (child, | ||
624 | 1213 | DBUSMENU_MENUITEM_PROP_LABEL, | ||
625 | 1214 | gtk_label_get_text (GTK_LABEL (widget))); | ||
626 | 1215 | } | ||
627 | 1216 | } | ||
628 | 1217 | |||
629 | 1218 | static void | ||
630 | 1219 | action_notify_cb (GtkAction *action, | ||
631 | 1220 | GParamSpec *pspec, | ||
632 | 1221 | gpointer data) | ||
633 | 1222 | { | ||
634 | 1223 | DbusmenuMenuitem *mi = (DbusmenuMenuitem *)data; | ||
635 | 1224 | |||
636 | 1225 | if (pspec->name == g_intern_static_string ("sensitive")) | ||
637 | 1226 | { | ||
638 | 1227 | dbusmenu_menuitem_property_set_bool (mi, | ||
639 | 1228 | DBUSMENU_MENUITEM_PROP_ENABLED, | ||
640 | 1229 | gtk_action_is_sensitive (action)); | ||
641 | 1230 | } | ||
642 | 1231 | else if (pspec->name == g_intern_static_string ("visible")) | ||
643 | 1232 | { | ||
644 | 1233 | dbusmenu_menuitem_property_set_bool (mi, | ||
645 | 1234 | DBUSMENU_MENUITEM_PROP_VISIBLE, | ||
646 | 1235 | gtk_action_is_visible (action)); | ||
647 | 1236 | } | ||
648 | 1237 | else if (pspec->name == g_intern_static_string ("active")) | ||
649 | 1238 | { | ||
650 | 1239 | dbusmenu_menuitem_property_set_bool (mi, | ||
651 | 1240 | DBUSMENU_MENUITEM_PROP_TOGGLE_STATE, | ||
652 | 1241 | gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action))); | ||
653 | 1242 | } | ||
654 | 1243 | else if (pspec->name == g_intern_static_string ("label")) | ||
655 | 1244 | { | ||
656 | 1245 | dbusmenu_menuitem_property_set (mi, | ||
657 | 1246 | DBUSMENU_MENUITEM_PROP_LABEL, | ||
658 | 1247 | gtk_action_get_label (action)); | ||
659 | 1248 | } | ||
660 | 1249 | } | ||
661 | 1250 | |||
662 | 1251 | static void | ||
663 | 1252 | item_activated (DbusmenuMenuitem *item, guint timestamp, gpointer user_data) | ||
664 | 1253 | { | ||
665 | 1254 | GtkWidget *child; | ||
666 | 1255 | |||
667 | 1256 | if (user_data != NULL) | ||
668 | 1257 | { | ||
669 | 1258 | child = (GtkWidget *)user_data; | ||
670 | 1259 | |||
671 | 1260 | if (GTK_IS_MENU_ITEM (child)) | ||
672 | 1261 | { | ||
673 | 1262 | gtk_menu_item_activate (GTK_MENU_ITEM (child)); | ||
674 | 1263 | } | ||
675 | 1264 | } | ||
676 | 1265 | } | ||
677 | 1266 | |||
678 | 1267 | static gboolean | ||
679 | 1268 | item_about_to_show (DbusmenuMenuitem *item, gpointer user_data) | ||
680 | 1269 | { | ||
681 | 1270 | GtkWidget *child; | ||
682 | 1271 | |||
683 | 1272 | if (user_data != NULL) | ||
684 | 1273 | { | ||
685 | 1274 | child = (GtkWidget *)user_data; | ||
686 | 1275 | |||
687 | 1276 | if (GTK_IS_MENU_ITEM (child)) | ||
688 | 1277 | { | ||
689 | 1278 | // Only called for items with submens. So we activate it here in | ||
690 | 1279 | // case the program dynamically creates menus (like empathy does) | ||
691 | 1280 | gtk_menu_item_activate (GTK_MENU_ITEM (child)); | ||
692 | 1281 | } | ||
693 | 1282 | } | ||
694 | 1283 | |||
695 | 1284 | return TRUE; | ||
696 | 1285 | } | ||
697 | 1286 | |||
698 | 1287 | static void | ||
699 | 1288 | widget_notify_cb (GtkWidget *widget, | ||
700 | 1289 | GParamSpec *pspec, | ||
701 | 1290 | gpointer data) | ||
702 | 1291 | { | ||
703 | 1292 | DbusmenuMenuitem *child = (DbusmenuMenuitem *)data; | ||
704 | 1293 | |||
705 | 1294 | if (pspec->name == g_intern_static_string ("sensitive")) | ||
706 | 1295 | { | ||
707 | 1296 | dbusmenu_menuitem_property_set_bool (child, | ||
708 | 1297 | DBUSMENU_MENUITEM_PROP_ENABLED, | ||
709 | 1298 | gtk_widget_get_sensitive (widget)); | ||
710 | 1299 | } | ||
711 | 1300 | else if (pspec->name == g_intern_static_string ("label")) | ||
712 | 1301 | { | ||
713 | 1302 | dbusmenu_menuitem_property_set (child, | ||
714 | 1303 | DBUSMENU_MENUITEM_PROP_LABEL, | ||
715 | 1304 | gtk_menu_item_get_label (GTK_MENU_ITEM (widget))); | ||
716 | 1305 | } | ||
717 | 1306 | else if (pspec->name == g_intern_static_string ("visible")) | ||
718 | 1307 | { | ||
719 | 1308 | dbusmenu_menuitem_property_set_bool (child, | ||
720 | 1309 | DBUSMENU_MENUITEM_PROP_VISIBLE, | ||
721 | 1310 | gtk_widget_get_visible (widget)); | ||
722 | 1311 | } | ||
723 | 1312 | else if (pspec->name == g_intern_static_string ("stock")) | ||
724 | 1313 | { | ||
725 | 1314 | update_stock_item (child, widget); | ||
726 | 1315 | } | ||
727 | 1316 | else if (pspec->name == g_intern_static_string ("icon-name")) | ||
728 | 1317 | { | ||
729 | 1318 | update_icon_name (child, widget); | ||
730 | 1319 | } | ||
731 | 1320 | else if (pspec->name == g_intern_static_string ("parent")) | ||
732 | 1321 | { | ||
733 | 1322 | /* | ||
734 | 1323 | * We probably should have added a 'remove' method to the | ||
735 | 1324 | * UbuntuMenuProxy early on, but it's late in the cycle now. | ||
736 | 1325 | */ | ||
737 | 1326 | if (gtk_widget_get_parent (widget) == NULL) | ||
738 | 1327 | { | ||
739 | 1328 | g_signal_handlers_disconnect_by_func (widget, | ||
740 | 1329 | G_CALLBACK (widget_notify_cb), | ||
741 | 1330 | child); | ||
742 | 1331 | |||
743 | 1332 | DbusmenuMenuitem *parent = g_object_get_data (G_OBJECT (child), "dbusmenu-parent"); | ||
744 | 1333 | |||
745 | 1334 | if (DBUSMENU_IS_MENUITEM (parent) && DBUSMENU_IS_MENUITEM (child)) | ||
746 | 1335 | { | ||
747 | 1336 | dbusmenu_menuitem_child_delete (parent, child); | ||
748 | 1337 | } | ||
749 | 1338 | } | ||
750 | 1339 | } | ||
751 | 1340 | } | ||
752 | 1341 | |||
753 | 1342 | static gboolean | ||
754 | 1343 | should_show_image (GtkImage *image) | ||
755 | 1344 | { | ||
756 | 1345 | GtkWidget *item; | ||
757 | 1346 | |||
758 | 1347 | item = gtk_widget_get_ancestor (GTK_WIDGET (image), | ||
759 | 1348 | GTK_TYPE_IMAGE_MENU_ITEM); | ||
760 | 1349 | |||
761 | 1350 | if (item) | ||
762 | 1351 | { | ||
763 | 1352 | GtkSettings *settings; | ||
764 | 1353 | gboolean gtk_menu_images; | ||
765 | 1354 | |||
766 | 1355 | settings = gtk_widget_get_settings (item); | ||
767 | 1356 | |||
768 | 1357 | g_object_get (settings, "gtk-menu-images", >k_menu_images, NULL); | ||
769 | 1358 | |||
770 | 1359 | if (gtk_menu_images) | ||
771 | 1360 | return TRUE; | ||
772 | 1361 | |||
773 | 1362 | return gtk_image_menu_item_get_always_show_image (GTK_IMAGE_MENU_ITEM (item)); | ||
774 | 1363 | } | ||
775 | 1364 | |||
776 | 1365 | return FALSE; | ||
777 | 1366 | } | ||
778 | 1367 | |||
779 | 1368 | >>>>>>> MERGE-SOURCE | ||
780 | 668 | 1369 | ||
781 | === modified file 'libdbusmenu-gtk/serializablemenuitem.c' | |||
782 | --- libdbusmenu-gtk/serializablemenuitem.c 2011-01-27 19:48:12 +0000 | |||
783 | +++ libdbusmenu-gtk/serializablemenuitem.c 2011-01-27 19:48:12 +0000 | |||
784 | @@ -166,7 +166,7 @@ | |||
785 | 166 | } | 166 | } |
786 | 167 | 167 | ||
787 | 168 | /** | 168 | /** |
789 | 169 | dbusmenu_gtk_serializable_menu_item_build_dbusmenu_menuitem: | 169 | dbusmenu_gtk_serializable_menu_item_build_menuitem: |
790 | 170 | @smi: #DbusmenuGtkSerializableMenuItem to build a #DbusmenuMenuitem mirroring | 170 | @smi: #DbusmenuGtkSerializableMenuItem to build a #DbusmenuMenuitem mirroring |
791 | 171 | 171 | ||
792 | 172 | This function is for menu items that are instanciated from | 172 | This function is for menu items that are instanciated from |
793 | @@ -179,7 +179,7 @@ | |||
794 | 179 | set by this object. | 179 | set by this object. |
795 | 180 | */ | 180 | */ |
796 | 181 | DbusmenuMenuitem * | 181 | DbusmenuMenuitem * |
798 | 182 | dbusmenu_gtk_serializable_menu_item_build_dbusmenu_menuitem (DbusmenuGtkSerializableMenuItem * smi) | 182 | dbusmenu_gtk_serializable_menu_item_build_menuitem (DbusmenuGtkSerializableMenuItem * smi) |
799 | 183 | { | 183 | { |
800 | 184 | g_return_val_if_fail(DBUSMENU_IS_GTK_SERIALIZABLE_MENU_ITEM(smi), NULL); | 184 | g_return_val_if_fail(DBUSMENU_IS_GTK_SERIALIZABLE_MENU_ITEM(smi), NULL); |
801 | 185 | 185 | ||
802 | @@ -207,7 +207,7 @@ | |||
803 | 207 | DbusmenuGtkSerializableMenuItem * smi = DBUSMENU_GTK_SERIALIZABLE_MENU_ITEM(g_object_new(th->type, NULL)); | 207 | DbusmenuGtkSerializableMenuItem * smi = DBUSMENU_GTK_SERIALIZABLE_MENU_ITEM(g_object_new(th->type, NULL)); |
804 | 208 | g_return_val_if_fail(smi != NULL, FALSE); | 208 | g_return_val_if_fail(smi != NULL, FALSE); |
805 | 209 | 209 | ||
807 | 210 | dbusmenu_gtk_serializable_menu_item_set_dbusmenu_menuitem(smi, newitem); | 210 | dbusmenu_gtk_serializable_menu_item_set_menuitem(smi, newitem); |
808 | 211 | dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, GTK_MENU_ITEM(smi), parent); | 211 | dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, GTK_MENU_ITEM(smi), parent); |
809 | 212 | 212 | ||
810 | 213 | return TRUE; | 213 | return TRUE; |
811 | @@ -265,7 +265,7 @@ | |||
812 | 265 | } | 265 | } |
813 | 266 | 266 | ||
814 | 267 | /** | 267 | /** |
816 | 268 | dbusmenu_gtk_serializable_menu_item_set_dbusmenu_menuitem: | 268 | dbusmenu_gtk_serializable_menu_item_set_menuitem: |
817 | 269 | @smi: #DbusmenuGtkSerializableMenuItem to set the @DbusmenuGtkSerializableMenuItem::dbusmenu-menuitem of | 269 | @smi: #DbusmenuGtkSerializableMenuItem to set the @DbusmenuGtkSerializableMenuItem::dbusmenu-menuitem of |
818 | 270 | @mi: Menuitem to get the properties from | 270 | @mi: Menuitem to get the properties from |
819 | 271 | 271 | ||
820 | @@ -276,7 +276,7 @@ | |||
821 | 276 | pick up this property being set. | 276 | pick up this property being set. |
822 | 277 | */ | 277 | */ |
823 | 278 | void | 278 | void |
825 | 279 | dbusmenu_gtk_serializable_menu_item_set_dbusmenu_menuitem (DbusmenuGtkSerializableMenuItem * smi, DbusmenuMenuitem * mi) | 279 | dbusmenu_gtk_serializable_menu_item_set_menuitem (DbusmenuGtkSerializableMenuItem * smi, DbusmenuMenuitem * mi) |
826 | 280 | { | 280 | { |
827 | 281 | g_return_if_fail(DBUSMENU_IS_GTK_SERIALIZABLE_MENU_ITEM(smi)); | 281 | g_return_if_fail(DBUSMENU_IS_GTK_SERIALIZABLE_MENU_ITEM(smi)); |
828 | 282 | g_return_if_fail(mi != NULL); | 282 | g_return_if_fail(mi != NULL); |
829 | 283 | 283 | ||
830 | === modified file 'libdbusmenu-gtk/serializablemenuitem.h' | |||
831 | --- libdbusmenu-gtk/serializablemenuitem.h 2011-01-27 19:48:12 +0000 | |||
832 | +++ libdbusmenu-gtk/serializablemenuitem.h 2011-01-27 19:48:12 +0000 | |||
833 | @@ -90,6 +90,13 @@ | |||
834 | 90 | DbusmenuGtkSerializableMenuItem: | 90 | DbusmenuGtkSerializableMenuItem: |
835 | 91 | @parent: Inherit from GtkMenuItem | 91 | @parent: Inherit from GtkMenuItem |
836 | 92 | @priv: Blind structure of private variables | 92 | @priv: Blind structure of private variables |
837 | 93 | |||
838 | 94 | The Serializable Menuitem provides a way for menu items to be created | ||
839 | 95 | that can easily be picked up by the Dbusmenu GTK Parser. This way | ||
840 | 96 | you can create custom items, and transport them across dbusmenu to | ||
841 | 97 | your menus or the appmenu on the other side of the bus. By providing | ||
842 | 98 | these function the parser has enough information to both serialize, and | ||
843 | 99 | deserialize on the other side, the menuitem you've so carefully created. | ||
844 | 93 | */ | 100 | */ |
845 | 94 | struct _DbusmenuGtkSerializableMenuItem { | 101 | struct _DbusmenuGtkSerializableMenuItem { |
846 | 95 | GtkMenuItem parent; | 102 | GtkMenuItem parent; |
847 | @@ -99,9 +106,9 @@ | |||
848 | 99 | 106 | ||
849 | 100 | GType dbusmenu_gtk_serializable_menu_item_get_type (void); | 107 | GType dbusmenu_gtk_serializable_menu_item_get_type (void); |
850 | 101 | 108 | ||
852 | 102 | DbusmenuMenuitem * dbusmenu_gtk_serializable_menu_item_build_dbusmenu_menuitem (DbusmenuGtkSerializableMenuItem * smi); | 109 | DbusmenuMenuitem * dbusmenu_gtk_serializable_menu_item_build_menuitem (DbusmenuGtkSerializableMenuItem * smi); |
853 | 103 | void dbusmenu_gtk_serializable_menu_item_register_to_client (DbusmenuClient * client, GType item_type); | 110 | void dbusmenu_gtk_serializable_menu_item_register_to_client (DbusmenuClient * client, GType item_type); |
855 | 104 | void dbusmenu_gtk_serializable_menu_item_set_dbusmenu_menuitem (DbusmenuGtkSerializableMenuItem * smi, DbusmenuMenuitem * mi); | 111 | void dbusmenu_gtk_serializable_menu_item_set_menuitem (DbusmenuGtkSerializableMenuItem * smi, DbusmenuMenuitem * mi); |
856 | 105 | 112 | ||
857 | 106 | G_END_DECLS | 113 | G_END_DECLS |
858 | 107 | 114 |
How does this branch relate to https:/ /code.launchpad .net/~ted/ dbusmenu/ serializable- menuitem/ +merge/ 47604 ? They look identical?