Mercurial > audlegacy
annotate src/audacious/sync-menu.c @ 4779:aa79a84627b9
g_basename is deprecated, replace with g_path_get_basename.
author | Tony Vroon <chainsaw@gentoo.org> |
---|---|
date | Fri, 26 Sep 2008 21:02:49 +0100 |
parents | db83b4a786ed |
children |
rev | line source |
---|---|
3417
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1 /* GTK+ Integration for the Mac OS X Menubar. |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2 * |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3 * Copyright (C) 2007 Pioneer Research Center USA, Inc. |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
4 * |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
5 * This library is free software; you can redistribute it and/or |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
6 * modify it under the terms of the GNU Lesser General Public |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
7 * License as published by the Free Software Foundation; either |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
8 * version 2 of the License, or (at your option) any later version. |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
9 * |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
10 * This library is distributed in the hope that it will be useful, |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
13 * Lesser General Public License for more details. |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
14 * |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU Lesser General Public |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
16 * License along with this library; if not, write to the |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
18 * Boston, MA 02111-1307, USA. |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
19 */ |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
20 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
21 #include <gtk/gtk.h> |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
22 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
23 #ifdef GDK_WINDOWING_QUARTZ |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
24 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
25 #include <gdk/gdkkeysyms.h> |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
26 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
27 #include <Carbon/Carbon.h> |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
28 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
29 #include "sync-menu.h" |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
30 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
31 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
32 /* TODO |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
33 * |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
34 * - Setup shortcuts, possibly transforming ctrl->cmd |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
35 * - Sync menus |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
36 * - Create on demand? (can this be done with gtk+? ie fill in menu items when the menu is opened) |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
37 * - Figure out what to do per app/window... |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
38 * - Toggle/radio items |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
39 * |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
40 */ |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
41 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
42 #define GTK_QUARTZ_MENU_CREATOR 'GTKC' |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
43 #define GTK_QUARTZ_ITEM_WIDGET 'GWID' |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
44 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
45 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
46 static void sync_menu_shell (GtkMenuShell *menu_shell, |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
47 MenuRef carbon_menu, |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
48 gboolean toplevel); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
49 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
50 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
51 /* |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
52 * utility functions |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
53 */ |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
54 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
55 static GtkWidget * |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
56 find_menu_label (GtkWidget *widget) |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
57 { |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
58 GtkWidget *label = NULL; |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
59 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
60 if (GTK_IS_LABEL (widget)) |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
61 return widget; |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
62 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
63 if (GTK_IS_CONTAINER (widget)) |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
64 { |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
65 GList *children; |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
66 GList *l; |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
67 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
68 children = gtk_container_get_children (GTK_CONTAINER (widget)); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
69 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
70 for (l = children; l; l = l->next) |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
71 { |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
72 label = find_menu_label (l->data); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
73 if (label) |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
74 break; |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
75 } |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
76 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
77 g_list_free (children); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
78 } |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
79 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
80 return label; |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
81 } |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
82 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
83 static const gchar * |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
84 get_menu_label_text (GtkWidget *menu_item, |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
85 GtkWidget **label) |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
86 { |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
87 *label = find_menu_label (menu_item); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
88 if (!*label) |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
89 return NULL; |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
90 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
91 return gtk_label_get_text (GTK_LABEL (*label)); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
92 } |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
93 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
94 static gboolean |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
95 accel_find_func (GtkAccelKey *key, |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
96 GClosure *closure, |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
97 gpointer data) |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
98 { |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
99 return (GClosure *) data == closure; |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
100 } |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
101 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
102 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
103 /* |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
104 * CarbonMenu functions |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
105 */ |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
106 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
107 typedef struct |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
108 { |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
109 MenuRef menu; |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
110 } CarbonMenu; |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
111 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
112 static GQuark carbon_menu_quark = 0; |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
113 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
114 static CarbonMenu * |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
115 carbon_menu_new (void) |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
116 { |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
117 return g_slice_new0 (CarbonMenu); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
118 } |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
119 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
120 static void |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
121 carbon_menu_free (CarbonMenu *menu) |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
122 { |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
123 g_slice_free (CarbonMenu, menu); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
124 } |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
125 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
126 static CarbonMenu * |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
127 carbon_menu_get (GtkWidget *widget) |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
128 { |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
129 return g_object_get_qdata (G_OBJECT (widget), carbon_menu_quark); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
130 } |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
131 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
132 static void |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
133 carbon_menu_connect (GtkWidget *menu, |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
134 MenuRef menuRef) |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
135 { |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
136 CarbonMenu *carbon_menu = carbon_menu_get (menu); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
137 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
138 if (!carbon_menu) |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
139 { |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
140 carbon_menu = carbon_menu_new (); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
141 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
142 g_object_set_qdata_full (G_OBJECT (menu), carbon_menu_quark, |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
143 carbon_menu, |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
144 (GDestroyNotify) carbon_menu_free); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
145 } |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
146 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
147 carbon_menu->menu = menuRef; |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
148 } |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
149 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
150 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
151 /* |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
152 * CarbonMenuItem functions |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
153 */ |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
154 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
155 typedef struct |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
156 { |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
157 MenuRef menu; |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
158 MenuItemIndex index; |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
159 MenuRef submenu; |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
160 GClosure *accel_closure; |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
161 } CarbonMenuItem; |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
162 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
163 static GQuark carbon_menu_item_quark = 0; |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
164 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
165 static CarbonMenuItem * |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
166 carbon_menu_item_new (void) |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
167 { |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
168 return g_slice_new0 (CarbonMenuItem); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
169 } |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
170 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
171 static void |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
172 carbon_menu_item_free (CarbonMenuItem *menu_item) |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
173 { |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
174 if (menu_item->accel_closure) |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
175 g_closure_unref (menu_item->accel_closure); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
176 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
177 g_slice_free (CarbonMenuItem, menu_item); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
178 } |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
179 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
180 static CarbonMenuItem * |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
181 carbon_menu_item_get (GtkWidget *widget) |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
182 { |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
183 return g_object_get_qdata (G_OBJECT (widget), carbon_menu_item_quark); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
184 } |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
185 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
186 static void |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
187 carbon_menu_item_update_state (CarbonMenuItem *carbon_item, |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
188 GtkWidget *widget) |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
189 { |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
190 gboolean sensitive; |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
191 gboolean visible; |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
192 UInt32 set_attrs = 0; |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
193 UInt32 clear_attrs = 0; |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
194 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
195 g_object_get (widget, |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
196 "sensitive", &sensitive, |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
197 "visible", &visible, |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
198 NULL); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
199 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
200 if (!sensitive) |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
201 set_attrs |= kMenuItemAttrDisabled; |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
202 else |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
203 clear_attrs |= kMenuItemAttrDisabled; |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
204 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
205 if (!visible) |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
206 set_attrs |= kMenuItemAttrHidden; |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
207 else |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
208 clear_attrs |= kMenuItemAttrHidden; |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
209 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
210 ChangeMenuItemAttributes (carbon_item->menu, carbon_item->index, |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
211 set_attrs, clear_attrs); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
212 } |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
213 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
214 static void |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
215 carbon_menu_item_update_active (CarbonMenuItem *carbon_item, |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
216 GtkWidget *widget) |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
217 { |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
218 gboolean active; |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
219 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
220 g_object_get (widget, |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
221 "active", &active, |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
222 NULL); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
223 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
224 CheckMenuItem (carbon_item->menu, carbon_item->index, |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
225 active); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
226 } |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
227 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
228 static void |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
229 carbon_menu_item_update_submenu (CarbonMenuItem *carbon_item, |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
230 GtkWidget *widget) |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
231 { |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
232 GtkWidget *submenu; |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
233 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
234 submenu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (widget)); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
235 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
236 if (submenu) |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
237 { |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
238 GtkWidget *label = NULL; |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
239 const gchar *label_text; |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
240 CFStringRef cfstr = NULL; |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
241 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
242 label_text = get_menu_label_text (widget, &label); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
243 if (label_text) |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
244 cfstr = CFStringCreateWithCString (NULL, label_text, |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
245 kCFStringEncodingUTF8); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
246 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
247 CreateNewMenu (0, 0, &carbon_item->submenu); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
248 SetMenuTitleWithCFString (carbon_item->submenu, cfstr); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
249 SetMenuItemHierarchicalMenu (carbon_item->menu, carbon_item->index, |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
250 carbon_item->submenu); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
251 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
252 sync_menu_shell (GTK_MENU_SHELL (submenu), carbon_item->submenu, FALSE); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
253 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
254 if (cfstr) |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
255 CFRelease (cfstr); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
256 } |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
257 else |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
258 { |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
259 SetMenuItemHierarchicalMenu (carbon_item->menu, carbon_item->index, |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
260 NULL); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
261 carbon_item->submenu = NULL; |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
262 } |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
263 } |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
264 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
265 static void |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
266 carbon_menu_item_update_label (CarbonMenuItem *carbon_item, |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
267 GtkWidget *widget) |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
268 { |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
269 GtkWidget *label; |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
270 const gchar *label_text; |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
271 CFStringRef cfstr = NULL; |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
272 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
273 label_text = get_menu_label_text (widget, &label); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
274 if (label_text) |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
275 cfstr = CFStringCreateWithCString (NULL, label_text, |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
276 kCFStringEncodingUTF8); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
277 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
278 SetMenuItemTextWithCFString (carbon_item->menu, carbon_item->index, |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
279 cfstr); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
280 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
281 if (cfstr) |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
282 CFRelease (cfstr); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
283 } |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
284 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
285 static void |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
286 carbon_menu_item_update_accelerator (CarbonMenuItem *carbon_item, |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
287 GtkWidget *widget) |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
288 { |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
289 GtkWidget *label; |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
290 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
291 get_menu_label_text (widget, &label); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
292 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
293 if (GTK_IS_ACCEL_LABEL (label) && |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
294 GTK_ACCEL_LABEL (label)->accel_closure) |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
295 { |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
296 GtkAccelKey *key; |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
297 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
298 key = gtk_accel_group_find (GTK_ACCEL_LABEL (label)->accel_group, |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
299 accel_find_func, |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
300 GTK_ACCEL_LABEL (label)->accel_closure); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
301 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
302 if (key && |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
303 key->accel_key && |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
304 key->accel_flags & GTK_ACCEL_VISIBLE) |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
305 { |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
306 GdkDisplay *display = gtk_widget_get_display (widget); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
307 GdkKeymap *keymap = gdk_keymap_get_for_display (display); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
308 GdkKeymapKey *keys; |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
309 gint n_keys; |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
310 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
311 if (gdk_keymap_get_entries_for_keyval (keymap, key->accel_key, |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
312 &keys, &n_keys)) |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
313 { |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
314 UInt8 modifiers = 0; |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
315 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
316 SetMenuItemCommandKey (carbon_item->menu, carbon_item->index, |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
317 true, keys[0].keycode); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
318 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
319 g_free (keys); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
320 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
321 if (key->accel_mods) |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
322 { |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
323 if (key->accel_mods & GDK_SHIFT_MASK) |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
324 modifiers |= kMenuShiftModifier; |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
325 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
326 if (key->accel_mods & GDK_MOD1_MASK) |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
327 modifiers |= kMenuOptionModifier; |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
328 } |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
329 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
330 if (!(key->accel_mods & GDK_CONTROL_MASK)) |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
331 { |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
332 modifiers |= kMenuNoCommandModifier; |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
333 } |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
334 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
335 SetMenuItemModifiers (carbon_item->menu, carbon_item->index, |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
336 modifiers); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
337 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
338 return; |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
339 } |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
340 } |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
341 } |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
342 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
343 /* otherwise, clear the menu shortcut */ |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
344 SetMenuItemModifiers (carbon_item->menu, carbon_item->index, |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
345 kMenuNoModifiers | kMenuNoCommandModifier); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
346 ChangeMenuItemAttributes (carbon_item->menu, carbon_item->index, |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
347 0, kMenuItemAttrUseVirtualKey); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
348 SetMenuItemCommandKey (carbon_item->menu, carbon_item->index, |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
349 false, 0); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
350 } |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
351 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
352 static void |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
353 carbon_menu_item_accel_changed (GtkAccelGroup *accel_group, |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
354 guint keyval, |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
355 GdkModifierType modifier, |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
356 GClosure *accel_closure, |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
357 GtkWidget *widget) |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
358 { |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
359 CarbonMenuItem *carbon_item = carbon_menu_item_get (widget); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
360 GtkWidget *label; |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
361 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
362 get_menu_label_text (widget, &label); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
363 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
364 if (GTK_IS_ACCEL_LABEL (label) && |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
365 GTK_ACCEL_LABEL (label)->accel_closure == accel_closure) |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
366 carbon_menu_item_update_accelerator (carbon_item, widget); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
367 } |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
368 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
369 static void |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
370 carbon_menu_item_update_accel_closure (CarbonMenuItem *carbon_item, |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
371 GtkWidget *widget) |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
372 { |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
373 GtkAccelGroup *group; |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
374 GtkWidget *label; |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
375 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
376 get_menu_label_text (widget, &label); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
377 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
378 if (carbon_item->accel_closure) |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
379 { |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
380 group = gtk_accel_group_from_accel_closure (carbon_item->accel_closure); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
381 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
382 g_signal_handlers_disconnect_by_func (group, |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
383 carbon_menu_item_accel_changed, |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
384 widget); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
385 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
386 g_closure_unref (carbon_item->accel_closure); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
387 carbon_item->accel_closure = NULL; |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
388 } |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
389 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
390 if (GTK_IS_ACCEL_LABEL (label)) |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
391 carbon_item->accel_closure = GTK_ACCEL_LABEL (label)->accel_closure; |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
392 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
393 if (carbon_item->accel_closure) |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
394 { |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
395 g_closure_ref (carbon_item->accel_closure); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
396 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
397 group = gtk_accel_group_from_accel_closure (carbon_item->accel_closure); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
398 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
399 g_signal_connect_object (group, "accel-changed", |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
400 G_CALLBACK (carbon_menu_item_accel_changed), |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
401 widget, 0); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
402 } |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
403 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
404 carbon_menu_item_update_accelerator (carbon_item, widget); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
405 } |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
406 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
407 static void |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
408 carbon_menu_item_notify (GObject *object, |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
409 GParamSpec *pspec, |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
410 CarbonMenuItem *carbon_item) |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
411 { |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
412 if (!strcmp (pspec->name, "sensitive") || |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
413 !strcmp (pspec->name, "visible")) |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
414 { |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
415 carbon_menu_item_update_state (carbon_item, GTK_WIDGET (object)); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
416 } |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
417 else if (!strcmp (pspec->name, "active")) |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
418 { |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
419 carbon_menu_item_update_active (carbon_item, GTK_WIDGET (object)); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
420 } |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
421 else if (!strcmp (pspec->name, "submenu")) |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
422 { |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
423 carbon_menu_item_update_submenu (carbon_item, GTK_WIDGET (object)); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
424 } |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
425 } |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
426 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
427 static void |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
428 carbon_menu_item_notify_label (GObject *object, |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
429 GParamSpec *pspec, |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
430 gpointer data) |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
431 { |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
432 CarbonMenuItem *carbon_item = carbon_menu_item_get (GTK_WIDGET (object)); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
433 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
434 if (!strcmp (pspec->name, "label")) |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
435 { |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
436 carbon_menu_item_update_label (carbon_item, |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
437 GTK_WIDGET (object)); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
438 } |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
439 else if (!strcmp (pspec->name, "accel-closure")) |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
440 { |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
441 carbon_menu_item_update_accel_closure (carbon_item, |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
442 GTK_WIDGET (object)); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
443 } |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
444 } |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
445 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
446 static CarbonMenuItem * |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
447 carbon_menu_item_connect (GtkWidget *menu_item, |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
448 GtkWidget *label, |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
449 MenuRef menu, |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
450 MenuItemIndex index) |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
451 { |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
452 CarbonMenuItem *carbon_item = carbon_menu_item_get (menu_item); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
453 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
454 if (!carbon_item) |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
455 { |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
456 carbon_item = carbon_menu_item_new (); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
457 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
458 g_object_set_qdata_full (G_OBJECT (menu_item), carbon_menu_item_quark, |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
459 carbon_item, |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
460 (GDestroyNotify) carbon_menu_item_free); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
461 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
462 g_signal_connect (menu_item, "notify", |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
463 G_CALLBACK (carbon_menu_item_notify), |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
464 carbon_item); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
465 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
466 if (label) |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
467 g_signal_connect_swapped (label, "notify::label", |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
468 G_CALLBACK (carbon_menu_item_notify_label), |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
469 menu_item); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
470 } |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
471 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
472 carbon_item->menu = menu; |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
473 carbon_item->index = index; |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
474 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
475 return carbon_item; |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
476 } |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
477 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
478 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
479 /* |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
480 * carbon event handler |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
481 */ |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
482 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
483 static OSStatus |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
484 menu_event_handler_func (EventHandlerCallRef event_handler_call_ref, |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
485 EventRef event_ref, |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
486 void *data) |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
487 { |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
488 UInt32 event_class = GetEventClass (event_ref); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
489 UInt32 event_kind = GetEventKind (event_ref); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
490 MenuRef menu_ref; |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
491 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
492 switch (event_class) |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
493 { |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
494 case kEventClassCommand: |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
495 /* This is called when activating (is that the right GTK+ term?) |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
496 * a menu item. |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
497 */ |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
498 if (event_kind == kEventCommandProcess) |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
499 { |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
500 HICommand command; |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
501 OSStatus err; |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
502 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
503 //g_print ("Menu: kEventClassCommand/kEventCommandProcess\n"); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
504 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
505 err = GetEventParameter (event_ref, kEventParamDirectObject, |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
506 typeHICommand, 0, |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
507 sizeof (command), 0, &command); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
508 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
509 if (err == noErr) |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
510 { |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
511 GtkWidget *widget = NULL; |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
512 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
513 if (command.commandID == kHICommandQuit) |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
514 { |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
515 gtk_main_quit (); /* Just testing... */ |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
516 return noErr; |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
517 } |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
518 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
519 /* Get any GtkWidget associated with the item. */ |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
520 err = GetMenuItemProperty (command.menu.menuRef, |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
521 command.menu.menuItemIndex, |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
522 GTK_QUARTZ_MENU_CREATOR, |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
523 GTK_QUARTZ_ITEM_WIDGET, |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
524 sizeof (widget), 0, &widget); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
525 if (err == noErr && widget) |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
526 { |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
527 gtk_menu_item_activate (GTK_MENU_ITEM (widget)); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
528 return noErr; |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
529 } |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
530 } |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
531 } |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
532 break; |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
533 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
534 case kEventClassMenu: |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
535 GetEventParameter (event_ref, |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
536 kEventParamDirectObject, |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
537 typeMenuRef, |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
538 NULL, |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
539 sizeof (menu_ref), |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
540 NULL, |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
541 &menu_ref); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
542 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
543 switch (event_kind) |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
544 { |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
545 case kEventMenuTargetItem: |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
546 /* This is called when an item is selected (what is the |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
547 * GTK+ term? prelight?) |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
548 */ |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
549 //g_print ("kEventClassMenu/kEventMenuTargetItem\n"); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
550 break; |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
551 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
552 case kEventMenuOpening: |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
553 /* Is it possible to dynamically build the menu here? We |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
554 * can at least set visibility/sensitivity. |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
555 */ |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
556 //g_print ("kEventClassMenu/kEventMenuOpening\n"); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
557 break; |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
558 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
559 case kEventMenuClosed: |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
560 //g_print ("kEventClassMenu/kEventMenuClosed\n"); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
561 break; |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
562 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
563 default: |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
564 break; |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
565 } |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
566 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
567 break; |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
568 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
569 default: |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
570 break; |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
571 } |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
572 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
573 return CallNextEventHandler (event_handler_call_ref, event_ref); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
574 } |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
575 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
576 static void |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
577 setup_menu_event_handler (void) |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
578 { |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
579 EventHandlerUPP menu_event_handler_upp; |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
580 EventHandlerRef menu_event_handler_ref; |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
581 const EventTypeSpec menu_events[] = { |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
582 { kEventClassCommand, kEventCommandProcess }, |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
583 { kEventClassMenu, kEventMenuTargetItem }, |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
584 { kEventClassMenu, kEventMenuOpening }, |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
585 { kEventClassMenu, kEventMenuClosed } |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
586 }; |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
587 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
588 /* FIXME: We might have to install one per window? */ |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
589 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
590 menu_event_handler_upp = NewEventHandlerUPP (menu_event_handler_func); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
591 InstallEventHandler (GetApplicationEventTarget (), menu_event_handler_upp, |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
592 GetEventTypeCount (menu_events), menu_events, 0, |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
593 &menu_event_handler_ref); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
594 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
595 #if 0 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
596 /* FIXME: Remove the handler with: */ |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
597 RemoveEventHandler(menu_event_handler_ref); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
598 DisposeEventHandlerUPP(menu_event_handler_upp); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
599 #endif |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
600 } |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
601 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
602 static void |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
603 sync_menu_shell (GtkMenuShell *menu_shell, |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
604 MenuRef carbon_menu, |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
605 gboolean toplevel) |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
606 { |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
607 GList *children; |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
608 GList *l; |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
609 MenuItemIndex carbon_index = 1; |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
610 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
611 carbon_menu_connect (GTK_WIDGET (menu_shell), carbon_menu); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
612 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
613 children = gtk_container_get_children (GTK_CONTAINER (menu_shell)); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
614 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
615 for (l = children; l; l = l->next) |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
616 { |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
617 GtkWidget *menu_item = l->data; |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
618 CarbonMenuItem *carbon_item; |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
619 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
620 if (GTK_IS_TEAROFF_MENU_ITEM (menu_item)) |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
621 continue; |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
622 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
623 if (toplevel && g_object_get_data (G_OBJECT (menu_item), "gtk-empty-menu-item")) |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
624 continue; |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
625 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
626 carbon_item = carbon_menu_item_get (menu_item); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
627 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
628 if (carbon_item && carbon_item->index != carbon_index) |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
629 { |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
630 DeleteMenuItem (carbon_item->menu, |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
631 carbon_item->index); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
632 carbon_item = NULL; |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
633 } |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
634 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
635 if (!carbon_item) |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
636 { |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
637 GtkWidget *label = NULL; |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
638 const gchar *label_text; |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
639 CFStringRef cfstr = NULL; |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
640 MenuItemAttributes attributes = 0; |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
641 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
642 label_text = get_menu_label_text (menu_item, &label); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
643 if (label_text) |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
644 cfstr = CFStringCreateWithCString (NULL, label_text, |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
645 kCFStringEncodingUTF8); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
646 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
647 if (GTK_IS_SEPARATOR_MENU_ITEM (menu_item)) |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
648 attributes |= kMenuItemAttrSeparator; |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
649 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
650 if (!GTK_WIDGET_IS_SENSITIVE (menu_item)) |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
651 attributes |= kMenuItemAttrDisabled; |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
652 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
653 if (!GTK_WIDGET_VISIBLE (menu_item)) |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
654 attributes |= kMenuItemAttrHidden; |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
655 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
656 InsertMenuItemTextWithCFString (carbon_menu, cfstr, |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
657 carbon_index, |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
658 attributes, 0); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
659 SetMenuItemProperty (carbon_menu, carbon_index, |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
660 GTK_QUARTZ_MENU_CREATOR, |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
661 GTK_QUARTZ_ITEM_WIDGET, |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
662 sizeof (menu_item), &menu_item); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
663 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
664 if (cfstr) |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
665 CFRelease (cfstr); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
666 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
667 carbon_item = carbon_menu_item_connect (menu_item, label, |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
668 carbon_menu, |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
669 carbon_index); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
670 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
671 if (GTK_IS_CHECK_MENU_ITEM (menu_item)) |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
672 carbon_menu_item_update_active (carbon_item, menu_item); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
673 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
674 carbon_menu_item_update_accel_closure (carbon_item, menu_item); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
675 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
676 if (gtk_menu_item_get_submenu (GTK_MENU_ITEM (menu_item))) |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
677 carbon_menu_item_update_submenu (carbon_item, menu_item); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
678 } |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
679 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
680 carbon_index++; |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
681 } |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
682 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
683 g_list_free (children); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
684 } |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
685 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
686 void |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
687 sync_menu_takeover_menu (GtkMenuShell *menu_shell) |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
688 { |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
689 MenuRef carbon_menubar; |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
690 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
691 g_return_if_fail (GTK_IS_MENU_SHELL (menu_shell)); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
692 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
693 if (carbon_menu_quark == 0) |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
694 carbon_menu_quark = g_quark_from_static_string ("CarbonMenu"); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
695 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
696 if (carbon_menu_item_quark == 0) |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
697 carbon_menu_item_quark = g_quark_from_static_string ("CarbonMenuItem"); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
698 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
699 CreateNewMenu (0 /*id*/, 0 /*options*/, &carbon_menubar); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
700 SetRootMenu (carbon_menubar); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
701 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
702 setup_menu_event_handler (); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
703 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
704 sync_menu_shell (menu_shell, carbon_menubar, TRUE); |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
705 } |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
706 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
707 #else |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
708 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
709 void |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
710 sync_menu_takeover_menu (GtkMenuShell *menu_shell) |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
711 { |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
712 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
713 } |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
714 |
db83b4a786ed
MacOS platform: Add support code for the MacOS menubar.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
715 #endif |