Merge lp:~jconti/indicator-applet/gnome3 into lp:indicator-applet/0.4
- gnome3
- Merge into applet
Status: | Superseded | ||||
---|---|---|---|---|---|
Proposed branch: | lp:~jconti/indicator-applet/gnome3 | ||||
Merge into: | lp:indicator-applet/0.4 | ||||
Diff against target: |
1835 lines (+732/-741) 8 files modified
.bzrignore (+3/-0) configure.ac (+13/-8) data/Makefile.am (+1/-1) src/Makefile.am (+8/-0) src/applet-main.c (+694/-718) src/eggaccelerators.c (+9/-9) src/eggaccelerators.h (+1/-1) src/tomboykeybinder.c (+3/-4) |
||||
To merge this branch: | bzr merge lp:~jconti/indicator-applet/gnome3 | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Sebastian Geiger (community) | code review and test | Approve | |
Ted Gould (community) | Approve | ||
Marco Trevisan (Treviño) | Approve | ||
Dmitry Shachnev | Approve | ||
Review via email: mp+80877@code.launchpad.net |
This proposal has been superseded by a proposal from 2012-02-07.
Commit message
Description of the change
It looks like this branch is the only code base that works with GNOME3. Someone should take the responsibility to merge it and to make a new official release of it.
Without this release, the package is going to be dropped from Debian testing (unless we decide to package this branch directly, but it would be weird to have to do that...).
I put Ted as reviewer since he's the only upstream person that has worked on a port.
Sebastien Bacher (seb128) wrote : | # |
Thanks for the work there, the people working on this code are at the ubuntu summit this week so it might take a few extra fays before getting a review but it's on the list of things to review
Jason Conti (jconti) wrote : | # |
I unfortunately converted the tabs to spaces in src/applet-main.c, which makes the diff kind of ugly, so I did the same with Ted's branch and posted a slightly better diff here: http://
It is worth noting that I took a look at Ted's branch after seeing the merge proposal, and it appears to work correctly with just the updated configure.ac, data/Makefile.am and src/tomboykeybi
Dmitry Shachnev (mitya57) wrote : | # |
@Jason: I've updated indicator-session package in my ppa (it's now based on 0.7.3.1), can you please copy it to yours?
Marco Trevisan (Treviño) (3v1n0) wrote : | # |
Missing support for secondary-activate event (i.e. middle-click) and I'd suggest to use something like the indicator-priority that we used in unity-panel-service to show some app-indicators (like bluetooth, keyboard and network ones) in the proper place.
For the rest, it seems good.
- 405. By Jason Conti
-
Add indicator secondary-activate signal
- 406. By Jason Conti
-
* Prepare indicator_order array for name-hints.
* Clean up menuitem data:
- Remove old "indicator" data
- Add new definitions for box and secondary-activate signal data - 407. By Jason Conti
-
* Refactor place_in_menu into a separate function using place_in_menu_cb.
* If an entry has name-hint, it is used to position the entry. - 408. By Jason Conti
-
Bump version to 0.4.14
Jason Conti (jconti) wrote : | # |
Added secondary-activate signal and name-hint for positioning support. I'll update the ppa tomorrow for testing.
Marco Trevisan (Treviño) (3v1n0) wrote : | # |
Code looks good. Thanks.
I've also planned to make the indicator order configurable via gsettings, so stay tuned on this side.
Ted Gould (ted) wrote : | # |
Great, thanks for the work on this. A few comments:
* Please don't change the version number in configure.ac, it really confuses things if there are multiple version numbers in "the wild" so it's better just to have one place define it. I'll fix this on merge, no worries there.
* Love that you changed the strings to #defines. I think that's a wonderful thing :-)
Thanks again for your work.
Sebastian Geiger (lanoxx) wrote : | # |
This was approved by Marco and Ted back in November, but the merge status is still set to 'Needs Review' could some body please update the status and tell if this is going to be merge upstream?
I also reviewed the code and can approve it. And also the ppa works on my oneric installation right now.
Unmerged revisions
- 408. By Jason Conti
-
Bump version to 0.4.14
- 407. By Jason Conti
-
* Refactor place_in_menu into a separate function using place_in_menu_cb.
* If an entry has name-hint, it is used to position the entry. - 406. By Jason Conti
-
* Prepare indicator_order array for name-hints.
* Clean up menuitem data:
- Remove old "indicator" data
- Add new definitions for box and secondary-activate signal data - 405. By Jason Conti
-
Add indicator secondary-activate signal
- 404. By Jason Conti
-
Bump version to 0.4.13
- 403. By Jason Conti
-
Missed a dollar sign in configure.ac.
- 402. By Jason Conti
-
Drop the default css code, it seems to be causing theming issues in the about
dialog when using the Ambiance theme. - 401. By Jason Conti
-
Forgot to update the location of the applets.
- 400. By Jason Conti
-
Updated indicator_order to match the order in unity-panel-
service. - 399. By Jason Conti
-
Dropped menubar_on_expose and cw_panel_
background_ changed, I'm not sure they
are necessary anymore (the indicator applet seems to respond correctly to
changes in the panel background).
Preview Diff
1 | === modified file '.bzrignore' | |||
2 | --- .bzrignore 2010-04-27 22:02:51 +0000 | |||
3 | +++ .bzrignore 2011-11-26 02:05:26 +0000 | |||
4 | @@ -4,8 +4,11 @@ | |||
5 | 4 | data/GNOME_IndicatorApplet.server | 4 | data/GNOME_IndicatorApplet.server |
6 | 5 | data/GNOME_IndicatorApplet.server.in | 5 | data/GNOME_IndicatorApplet.server.in |
7 | 6 | data/indicator-applet.schemas | 6 | data/indicator-applet.schemas |
8 | 7 | data/*.panel-applet | ||
9 | 8 | data/*.service | ||
10 | 7 | po/@GETTEXT_PACKAGE@.pot | 9 | po/@GETTEXT_PACKAGE@.pot |
11 | 8 | po/indicator-applet.pot | 10 | po/indicator-applet.pot |
12 | 11 | po/*.gmo | ||
13 | 9 | src/indicator-applet | 12 | src/indicator-applet |
14 | 10 | dbus-indicate-client.h | 13 | dbus-indicate-client.h |
15 | 11 | dbus-indicate-server.h | 14 | dbus-indicate-server.h |
16 | 12 | 15 | ||
17 | === modified file 'configure.ac' | |||
18 | --- configure.ac 2011-04-15 02:32:33 +0000 | |||
19 | +++ configure.ac 2011-11-26 02:05:26 +0000 | |||
20 | @@ -4,7 +4,7 @@ | |||
21 | 4 | AC_PREREQ(2.53) | 4 | AC_PREREQ(2.53) |
22 | 5 | 5 | ||
23 | 6 | AM_CONFIG_HEADER(config.h) | 6 | AM_CONFIG_HEADER(config.h) |
25 | 7 | AM_INIT_AUTOMAKE(indicator-applet, 0.4.12) | 7 | AM_INIT_AUTOMAKE(indicator-applet, 0.4.14) |
26 | 8 | 8 | ||
27 | 9 | AM_MAINTAINER_MODE | 9 | AM_MAINTAINER_MODE |
28 | 10 | m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES]) | 10 | m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES]) |
29 | @@ -25,13 +25,15 @@ | |||
30 | 25 | # Dependencies | 25 | # Dependencies |
31 | 26 | ########################### | 26 | ########################### |
32 | 27 | 27 | ||
35 | 28 | GTK_REQUIRED_VERSION=2.12 | 28 | GTK_REQUIRED_VERSION=3.1 |
36 | 29 | INDICATOR_REQUIRED_VERSION=0.3.22 | 29 | INDICATOR_REQUIRED_VERSION=0.3.92 |
37 | 30 | INDICATOR_PKG=indicator3-0.4 | ||
38 | 31 | APPLET_PKG=libpanelapplet-4.0 | ||
39 | 30 | 32 | ||
41 | 31 | PKG_CHECK_MODULES(APPLET, gtk+-2.0 >= $GTK_REQUIRED_VERSION | 33 | PKG_CHECK_MODULES(APPLET, gtk+-3.0 >= $GTK_REQUIRED_VERSION |
42 | 32 | x11 | 34 | x11 |
45 | 33 | libpanelapplet-3.0 | 35 | $APPLET_PKG |
46 | 34 | indicator >= $INDICATOR_REQUIRED_VERSION) | 36 | $INDICATOR_PKG >= $INDICATOR_REQUIRED_VERSION) |
47 | 35 | AC_SUBST(APPLET_CFLAGS) | 37 | AC_SUBST(APPLET_CFLAGS) |
48 | 36 | AC_SUBST(APPLET_LIBS) | 38 | AC_SUBST(APPLET_LIBS) |
49 | 37 | 39 | ||
50 | @@ -47,13 +49,16 @@ | |||
51 | 47 | ########################### | 49 | ########################### |
52 | 48 | 50 | ||
53 | 49 | if test "x$with_localinstall" = "xyes"; then | 51 | if test "x$with_localinstall" = "xyes"; then |
54 | 52 | APPLETDIR="${datadir}/gnome-panel/applets/" | ||
55 | 50 | INDICATORDIR="${libdir}/indicators/2/" | 53 | INDICATORDIR="${libdir}/indicators/2/" |
56 | 51 | INDICATORICONSDIR="${datadir}/indicator-applet/icons/" | 54 | INDICATORICONSDIR="${datadir}/indicator-applet/icons/" |
57 | 52 | else | 55 | else |
60 | 53 | INDICATORDIR=`$PKG_CONFIG --variable=indicatordir indicator` | 56 | APPLETDIR=`$PKG_CONFIG --variable=libpanel_applet_dir $APPLET_PKG` |
61 | 54 | INDICATORICONSDIR=`$PKG_CONFIG --variable=iconsdir indicator` | 57 | INDICATORDIR=`$PKG_CONFIG --variable=indicatordir $INDICATOR_PKG` |
62 | 58 | INDICATORICONSDIR=`$PKG_CONFIG --variable=iconsdir $INDICATOR_PKG` | ||
63 | 55 | fi | 59 | fi |
64 | 56 | 60 | ||
65 | 61 | AC_SUBST(APPLETDIR) | ||
66 | 57 | AC_SUBST(INDICATORDIR) | 62 | AC_SUBST(INDICATORDIR) |
67 | 58 | AC_SUBST(INDICATORICONSDIR) | 63 | AC_SUBST(INDICATORICONSDIR) |
68 | 59 | 64 | ||
69 | 60 | 65 | ||
70 | === modified file 'data/Makefile.am' | |||
71 | --- data/Makefile.am 2010-11-10 18:28:18 +0000 | |||
72 | +++ data/Makefile.am 2011-11-26 02:05:26 +0000 | |||
73 | @@ -4,7 +4,7 @@ | |||
74 | 4 | # Applets | 4 | # Applets |
75 | 5 | ############################## | 5 | ############################## |
76 | 6 | 6 | ||
78 | 7 | appletdir = $(datadir)/gnome-panel/applets | 7 | appletdir = $(APPLETDIR) |
79 | 8 | applet_in_files = \ | 8 | applet_in_files = \ |
80 | 9 | org.ayatana.panel.IndicatorApplet.panel-applet.in \ | 9 | org.ayatana.panel.IndicatorApplet.panel-applet.in \ |
81 | 10 | org.ayatana.panel.IndicatorAppletComplete.panel-applet.in \ | 10 | org.ayatana.panel.IndicatorAppletComplete.panel-applet.in \ |
82 | 11 | 11 | ||
83 | === modified file 'src/Makefile.am' | |||
84 | --- src/Makefile.am 2010-04-26 15:21:06 +0000 | |||
85 | +++ src/Makefile.am 2011-11-26 02:05:26 +0000 | |||
86 | @@ -11,6 +11,8 @@ | |||
87 | 11 | -DINDICATOR_DIR=\""$(INDICATORDIR)"\" \ | 11 | -DINDICATOR_DIR=\""$(INDICATORDIR)"\" \ |
88 | 12 | -DINDICATOR_ICONS_DIR=\""$(INDICATORICONSDIR)"\" \ | 12 | -DINDICATOR_ICONS_DIR=\""$(INDICATORICONSDIR)"\" \ |
89 | 13 | -DINDICATOR_APPLET \ | 13 | -DINDICATOR_APPLET \ |
90 | 14 | -DGDK_DISABLE_DEPRECATED \ | ||
91 | 15 | -DGTK_DISABLE_DEPRECATED \ | ||
92 | 14 | -I$(srcdir)/.. \ | 16 | -I$(srcdir)/.. \ |
93 | 15 | $(APPLET_CFLAGS) | 17 | $(APPLET_CFLAGS) |
94 | 16 | 18 | ||
95 | @@ -30,6 +32,8 @@ | |||
96 | 30 | -DINDICATOR_DIR=\""$(INDICATORDIR)"\" \ | 32 | -DINDICATOR_DIR=\""$(INDICATORDIR)"\" \ |
97 | 31 | -DINDICATOR_ICONS_DIR=\""$(INDICATORICONSDIR)"\" \ | 33 | -DINDICATOR_ICONS_DIR=\""$(INDICATORICONSDIR)"\" \ |
98 | 32 | -DINDICATOR_APPLET_APPMENU \ | 34 | -DINDICATOR_APPLET_APPMENU \ |
99 | 35 | -DGDK_DISABLE_DEPRECATED \ | ||
100 | 36 | -DGTK_DISABLE_DEPRECATED \ | ||
101 | 33 | -I$(srcdir)/.. \ | 37 | -I$(srcdir)/.. \ |
102 | 34 | $(APPLET_CFLAGS) | 38 | $(APPLET_CFLAGS) |
103 | 35 | 39 | ||
104 | @@ -49,6 +53,8 @@ | |||
105 | 49 | -DINDICATOR_DIR=\""$(INDICATORDIR)"\" \ | 53 | -DINDICATOR_DIR=\""$(INDICATORDIR)"\" \ |
106 | 50 | -DINDICATOR_ICONS_DIR=\""$(INDICATORICONSDIR)"\" \ | 54 | -DINDICATOR_ICONS_DIR=\""$(INDICATORICONSDIR)"\" \ |
107 | 51 | -DINDICATOR_APPLET_SESSION \ | 55 | -DINDICATOR_APPLET_SESSION \ |
108 | 56 | -DGDK_DISABLE_DEPRECATED \ | ||
109 | 57 | -DGTK_DISABLE_DEPRECATED \ | ||
110 | 52 | -I$(srcdir)/.. \ | 58 | -I$(srcdir)/.. \ |
111 | 53 | $(APPLET_CFLAGS) | 59 | $(APPLET_CFLAGS) |
112 | 54 | 60 | ||
113 | @@ -68,6 +74,8 @@ | |||
114 | 68 | -DINDICATOR_DIR=\""$(INDICATORDIR)"\" \ | 74 | -DINDICATOR_DIR=\""$(INDICATORDIR)"\" \ |
115 | 69 | -DINDICATOR_ICONS_DIR=\""$(INDICATORICONSDIR)"\" \ | 75 | -DINDICATOR_ICONS_DIR=\""$(INDICATORICONSDIR)"\" \ |
116 | 70 | -DINDICATOR_APPLET_COMPLETE \ | 76 | -DINDICATOR_APPLET_COMPLETE \ |
117 | 77 | -DGDK_DISABLE_DEPRECATED \ | ||
118 | 78 | -DGTK_DISABLE_DEPRECATED \ | ||
119 | 71 | -I$(srcdir)/.. \ | 79 | -I$(srcdir)/.. \ |
120 | 72 | $(APPLET_CFLAGS) | 80 | $(APPLET_CFLAGS) |
121 | 73 | 81 | ||
122 | 74 | 82 | ||
123 | === modified file 'src/applet-main.c' | |||
124 | --- src/applet-main.c 2011-04-13 16:22:14 +0000 | |||
125 | +++ src/applet-main.c 2011-11-26 02:05:26 +0000 | |||
126 | @@ -30,31 +30,36 @@ | |||
127 | 30 | #include "libindicator/indicator-object.h" | 30 | #include "libindicator/indicator-object.h" |
128 | 31 | #include "tomboykeybinder.h" | 31 | #include "tomboykeybinder.h" |
129 | 32 | 32 | ||
138 | 33 | static gchar * indicator_order[] = { | 33 | static gchar * indicator_order[][2] = { |
139 | 34 | "libapplication.so", | 34 | {"libappmenu.so", NULL}, |
140 | 35 | "libsoundmenu.so", | 35 | {"libapplication.so", NULL}, |
141 | 36 | "libmessaging.so", | 36 | {"libapplication.so", "gst-keyboard-xkb"}, |
142 | 37 | "libdatetime.so", | 37 | {"libmessaging.so", NULL}, |
143 | 38 | "libme.so", | 38 | {"libpower.so", NULL}, |
144 | 39 | "libsession.so", | 39 | {"libapplication.so", "bluetooth-manager"}, |
145 | 40 | NULL | 40 | {"libnetwork.so", NULL}, |
146 | 41 | {"libnetworkmenu.so", NULL}, | ||
147 | 42 | {"libapplication.so", "nm-applet"}, | ||
148 | 43 | {"libsoundmenu.so", NULL}, | ||
149 | 44 | {"libdatetime.so", NULL}, | ||
150 | 45 | {"libsession.so", NULL}, | ||
151 | 46 | {NULL, NULL} | ||
152 | 41 | }; | 47 | }; |
153 | 42 | 48 | ||
154 | 43 | static GtkPackDirection packdirection; | 49 | static GtkPackDirection packdirection; |
155 | 44 | static PanelAppletOrient orient; | 50 | static PanelAppletOrient orient; |
156 | 45 | 51 | ||
157 | 52 | #define MENU_DATA_BOX "box" | ||
158 | 46 | #define MENU_DATA_INDICATOR_OBJECT "indicator-object" | 53 | #define MENU_DATA_INDICATOR_OBJECT "indicator-object" |
159 | 47 | #define MENU_DATA_INDICATOR_ENTRY "indicator-entry" | 54 | #define MENU_DATA_INDICATOR_ENTRY "indicator-entry" |
160 | 55 | #define MENU_DATA_IN_MENUITEM "in-menuitem" | ||
161 | 56 | #define MENU_DATA_MENUITEM_PRESSED "menuitem-pressed" | ||
162 | 48 | 57 | ||
163 | 58 | #define IO_DATA_NAME "indicator-name" | ||
164 | 49 | #define IO_DATA_ORDER_NUMBER "indicator-order-number" | 59 | #define IO_DATA_ORDER_NUMBER "indicator-order-number" |
165 | 50 | 60 | ||
167 | 51 | static gboolean applet_fill_cb (PanelApplet * applet, const gchar * iid, gpointer data); | 61 | static gboolean applet_fill_cb (PanelApplet * applet, const gchar * iid, gpointer data); |
168 | 52 | 62 | ||
169 | 53 | static void cw_panel_background_changed (PanelApplet *applet, | ||
170 | 54 | PanelAppletBackgroundType type, | ||
171 | 55 | GdkColor *colour, | ||
172 | 56 | GdkPixmap *pixmap, | ||
173 | 57 | GtkWidget *menubar); | ||
174 | 58 | static void update_accessible_desc (IndicatorObjectEntry * entry, GtkWidget * menuitem); | 63 | static void update_accessible_desc (IndicatorObjectEntry * entry, GtkWidget * menuitem); |
175 | 59 | 64 | ||
176 | 60 | /************* | 65 | /************* |
177 | @@ -64,25 +69,21 @@ | |||
178 | 64 | #ifdef INDICATOR_APPLET | 69 | #ifdef INDICATOR_APPLET |
179 | 65 | PANEL_APPLET_OUT_PROCESS_FACTORY ("IndicatorAppletFactory", | 70 | PANEL_APPLET_OUT_PROCESS_FACTORY ("IndicatorAppletFactory", |
180 | 66 | PANEL_TYPE_APPLET, | 71 | PANEL_TYPE_APPLET, |
181 | 67 | "indicator-applet", | ||
182 | 68 | applet_fill_cb, NULL); | 72 | applet_fill_cb, NULL); |
183 | 69 | #endif | 73 | #endif |
184 | 70 | #ifdef INDICATOR_APPLET_SESSION | 74 | #ifdef INDICATOR_APPLET_SESSION |
185 | 71 | PANEL_APPLET_OUT_PROCESS_FACTORY ("FastUserSwitchAppletFactory", | 75 | PANEL_APPLET_OUT_PROCESS_FACTORY ("FastUserSwitchAppletFactory", |
186 | 72 | PANEL_TYPE_APPLET, | 76 | PANEL_TYPE_APPLET, |
187 | 73 | "indicator-applet-session", | ||
188 | 74 | applet_fill_cb, NULL); | 77 | applet_fill_cb, NULL); |
189 | 75 | #endif | 78 | #endif |
190 | 76 | #ifdef INDICATOR_APPLET_COMPLETE | 79 | #ifdef INDICATOR_APPLET_COMPLETE |
191 | 77 | PANEL_APPLET_OUT_PROCESS_FACTORY ("IndicatorAppletCompleteFactory", | 80 | PANEL_APPLET_OUT_PROCESS_FACTORY ("IndicatorAppletCompleteFactory", |
192 | 78 | PANEL_TYPE_APPLET, | 81 | PANEL_TYPE_APPLET, |
193 | 79 | "indicator-applet-complete", | ||
194 | 80 | applet_fill_cb, NULL); | 82 | applet_fill_cb, NULL); |
195 | 81 | #endif | 83 | #endif |
196 | 82 | #ifdef INDICATOR_APPLET_APPMENU | 84 | #ifdef INDICATOR_APPLET_APPMENU |
197 | 83 | PANEL_APPLET_OUT_PROCESS_FACTORY ("IndicatorAppletAppmenuFactory", | 85 | PANEL_APPLET_OUT_PROCESS_FACTORY ("IndicatorAppletAppmenuFactory", |
198 | 84 | PANEL_TYPE_APPLET, | 86 | PANEL_TYPE_APPLET, |
199 | 85 | "indicator-applet-appmenu", | ||
200 | 86 | applet_fill_cb, NULL); | 87 | applet_fill_cb, NULL); |
201 | 87 | #endif | 88 | #endif |
202 | 88 | 89 | ||
203 | @@ -101,7 +102,7 @@ | |||
204 | 101 | #ifdef INDICATOR_APPLET_APPMENU | 102 | #ifdef INDICATOR_APPLET_APPMENU |
205 | 102 | #define LOG_FILE_NAME "indicator-applet-appmenu.log" | 103 | #define LOG_FILE_NAME "indicator-applet-appmenu.log" |
206 | 103 | #endif | 104 | #endif |
208 | 104 | GOutputStream * log_file = NULL; | 105 | static FILE *log_file = NULL; |
209 | 105 | 106 | ||
210 | 106 | /***************** | 107 | /***************** |
211 | 107 | * Hotkey support | 108 | * Hotkey support |
212 | @@ -136,34 +137,31 @@ | |||
213 | 136 | #endif | 137 | #endif |
214 | 137 | 138 | ||
215 | 138 | static const gchar * indicator_env[] = { | 139 | static const gchar * indicator_env[] = { |
219 | 139 | "indicator-applet", | 140 | "indicator-applet", |
220 | 140 | INDICATOR_SPECIFIC_ENV, | 141 | INDICATOR_SPECIFIC_ENV, |
221 | 141 | NULL | 142 | NULL |
222 | 142 | }; | 143 | }; |
223 | 143 | 144 | ||
224 | 144 | /************* | ||
225 | 145 | * init function | ||
226 | 146 | * ***********/ | ||
227 | 147 | |||
228 | 148 | static gint | 145 | static gint |
239 | 149 | name2order (const gchar * name) { | 146 | name2order (const gchar * name, const gchar * hint) { |
240 | 150 | int i; | 147 | int i; |
241 | 151 | 148 | ||
242 | 152 | for (i = 0; indicator_order[i] != NULL; i++) { | 149 | for (i = 0; indicator_order[i][0] != NULL; i++) { |
243 | 153 | if (g_strcmp0(name, indicator_order[i]) == 0) { | 150 | if (g_strcmp0(name, indicator_order[i][0]) == 0 && |
244 | 154 | return i; | 151 | g_strcmp0(hint, indicator_order[i][1]) == 0) { |
245 | 155 | } | 152 | return i; |
246 | 156 | } | 153 | } |
247 | 157 | 154 | } | |
248 | 158 | return -1; | 155 | |
249 | 156 | return -1; | ||
250 | 159 | } | 157 | } |
251 | 160 | 158 | ||
252 | 161 | typedef struct _incoming_position_t incoming_position_t; | 159 | typedef struct _incoming_position_t incoming_position_t; |
253 | 162 | struct _incoming_position_t { | 160 | struct _incoming_position_t { |
258 | 163 | gint objposition; | 161 | gint objposition; |
259 | 164 | gint entryposition; | 162 | gint entryposition; |
260 | 165 | gint menupos; | 163 | gint menupos; |
261 | 166 | gboolean found; | 164 | gboolean found; |
262 | 167 | }; | 165 | }; |
263 | 168 | 166 | ||
264 | 169 | /* This function helps by determining where in the menu list | 167 | /* This function helps by determining where in the menu list |
265 | @@ -171,263 +169,337 @@ | |||
266 | 171 | that they're on, and then the individual entries. Each | 169 | that they're on, and then the individual entries. Each |
267 | 172 | is progressively more expensive. */ | 170 | is progressively more expensive. */ |
268 | 173 | static void | 171 | static void |
312 | 174 | place_in_menu (GtkWidget * widget, gpointer user_data) | 172 | place_in_menu_cb (GtkWidget * widget, gpointer user_data) |
313 | 175 | { | 173 | { |
314 | 176 | incoming_position_t * position = (incoming_position_t *)user_data; | 174 | incoming_position_t * position = (incoming_position_t *)user_data; |
315 | 177 | if (position->found) { | 175 | if (position->found) { |
316 | 178 | /* We've already been placed, just finish the foreach */ | 176 | /* We've already been placed, just finish the foreach */ |
317 | 179 | return; | 177 | return; |
318 | 180 | } | 178 | } |
319 | 181 | 179 | ||
320 | 182 | IndicatorObject * io = INDICATOR_OBJECT(g_object_get_data(G_OBJECT(widget), MENU_DATA_INDICATOR_OBJECT)); | 180 | IndicatorObject * io = INDICATOR_OBJECT(g_object_get_data(G_OBJECT(widget), MENU_DATA_INDICATOR_OBJECT)); |
321 | 183 | g_assert(io != NULL); | 181 | g_return_if_fail(INDICATOR_IS_OBJECT(io)); |
322 | 184 | 182 | ||
323 | 185 | gint objposition = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(io), IO_DATA_ORDER_NUMBER)); | 183 | gint objposition = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(io), IO_DATA_ORDER_NUMBER)); |
324 | 186 | /* We've already passed it, well, then this is where | 184 | /* We've already passed it, well, then this is where |
325 | 187 | we should be be. Stop! */ | 185 | we should be be. Stop! */ |
326 | 188 | if (objposition > position->objposition) { | 186 | if (objposition > position->objposition) { |
327 | 189 | position->found = TRUE; | 187 | position->found = TRUE; |
328 | 190 | return; | 188 | return; |
329 | 191 | } | 189 | } |
330 | 192 | 190 | ||
331 | 193 | /* The objects don't match yet, keep looking */ | 191 | /* The objects don't match yet, keep looking */ |
332 | 194 | if (objposition < position->objposition) { | 192 | if (objposition < position->objposition) { |
333 | 195 | position->menupos++; | 193 | position->menupos++; |
334 | 196 | return; | 194 | return; |
335 | 197 | } | 195 | } |
336 | 198 | 196 | ||
337 | 199 | /* The objects are the same, let's start looking at entries. */ | 197 | /* The objects are the same, let's start looking at entries. */ |
338 | 200 | IndicatorObjectEntry * entry = (IndicatorObjectEntry *)g_object_get_data(G_OBJECT(widget), MENU_DATA_INDICATOR_ENTRY); | 198 | IndicatorObjectEntry * entry = (IndicatorObjectEntry *)g_object_get_data(G_OBJECT(widget), MENU_DATA_INDICATOR_ENTRY); |
339 | 201 | gint entryposition = indicator_object_get_location(io, entry); | 199 | gint entryposition = indicator_object_get_location(io, entry); |
340 | 202 | 200 | ||
341 | 203 | if (entryposition > position->entryposition) { | 201 | if (entryposition > position->entryposition) { |
342 | 204 | position->found = TRUE; | 202 | position->found = TRUE; |
343 | 205 | return; | 203 | return; |
344 | 206 | } | 204 | } |
345 | 207 | 205 | ||
346 | 208 | if (entryposition < position->entryposition) { | 206 | if (entryposition < position->entryposition) { |
347 | 209 | position->menupos++; | 207 | position->menupos++; |
348 | 210 | return; | 208 | return; |
349 | 211 | } | 209 | } |
350 | 212 | 210 | ||
351 | 213 | /* We've got the same object and the same entry. Well, | 211 | /* We've got the same object and the same entry. Well, |
352 | 214 | let's just put it right here then. */ | 212 | let's just put it right here then. */ |
353 | 215 | position->found = TRUE; | 213 | position->found = TRUE; |
354 | 216 | return; | 214 | return; |
355 | 215 | } | ||
356 | 216 | |||
357 | 217 | /* Position the entry */ | ||
358 | 218 | static void | ||
359 | 219 | place_in_menu (GtkWidget *menubar, | ||
360 | 220 | GtkWidget *menuitem, | ||
361 | 221 | IndicatorObject *io, | ||
362 | 222 | IndicatorObjectEntry *entry) | ||
363 | 223 | { | ||
364 | 224 | incoming_position_t position; | ||
365 | 225 | |||
366 | 226 | /* Start with the default position for this indicator object */ | ||
367 | 227 | gint io_position = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(io), IO_DATA_ORDER_NUMBER)); | ||
368 | 228 | |||
369 | 229 | /* If name-hint is set, try to find the entry's position */ | ||
370 | 230 | if (entry->name_hint != NULL) { | ||
371 | 231 | const gchar *name = (const gchar *)g_object_get_data(G_OBJECT(io), IO_DATA_NAME); | ||
372 | 232 | gint entry_position = name2order(name, entry->name_hint); | ||
373 | 233 | |||
374 | 234 | /* If we don't find the entry, fall back to the indicator object's position */ | ||
375 | 235 | if (entry_position > -1) | ||
376 | 236 | io_position = entry_position; | ||
377 | 237 | } | ||
378 | 238 | |||
379 | 239 | position.objposition = io_position; | ||
380 | 240 | position.entryposition = indicator_object_get_location(io, entry); | ||
381 | 241 | position.menupos = 0; | ||
382 | 242 | position.found = FALSE; | ||
383 | 243 | |||
384 | 244 | gtk_container_foreach(GTK_CONTAINER(menubar), place_in_menu_cb, &position); | ||
385 | 245 | |||
386 | 246 | gtk_menu_shell_insert(GTK_MENU_SHELL(menubar), menuitem, position.menupos); | ||
387 | 217 | } | 247 | } |
388 | 218 | 248 | ||
389 | 219 | static void | 249 | static void |
390 | 220 | something_shown (GtkWidget * widget, gpointer user_data) | 250 | something_shown (GtkWidget * widget, gpointer user_data) |
391 | 221 | { | 251 | { |
394 | 222 | GtkWidget * menuitem = GTK_WIDGET(user_data); | 252 | GtkWidget * menuitem = GTK_WIDGET(user_data); |
395 | 223 | gtk_widget_show(menuitem); | 253 | gtk_widget_show(menuitem); |
396 | 224 | } | 254 | } |
397 | 225 | 255 | ||
398 | 226 | static void | 256 | static void |
399 | 227 | something_hidden (GtkWidget * widget, gpointer user_data) | 257 | something_hidden (GtkWidget * widget, gpointer user_data) |
400 | 228 | { | 258 | { |
403 | 229 | GtkWidget * menuitem = GTK_WIDGET(user_data); | 259 | GtkWidget * menuitem = GTK_WIDGET(user_data); |
404 | 230 | gtk_widget_hide(menuitem); | 260 | gtk_widget_hide(menuitem); |
405 | 231 | } | 261 | } |
406 | 232 | 262 | ||
407 | 233 | static void | 263 | static void |
408 | 234 | sensitive_cb (GObject * obj, GParamSpec * pspec, gpointer user_data) | 264 | sensitive_cb (GObject * obj, GParamSpec * pspec, gpointer user_data) |
409 | 235 | { | 265 | { |
412 | 236 | g_return_if_fail(GTK_IS_WIDGET(obj)); | 266 | g_return_if_fail(GTK_IS_WIDGET(obj)); |
413 | 237 | g_return_if_fail(GTK_IS_WIDGET(user_data)); | 267 | g_return_if_fail(GTK_IS_WIDGET(user_data)); |
414 | 238 | 268 | ||
417 | 239 | gtk_widget_set_sensitive(GTK_WIDGET(user_data), gtk_widget_get_sensitive(GTK_WIDGET(obj))); | 269 | gtk_widget_set_sensitive(GTK_WIDGET(user_data), gtk_widget_get_sensitive(GTK_WIDGET(obj))); |
418 | 240 | return; | 270 | return; |
419 | 241 | } | 271 | } |
420 | 242 | 272 | ||
421 | 243 | static void | 273 | static void |
422 | 244 | entry_activated (GtkWidget * widget, gpointer user_data) | 274 | entry_activated (GtkWidget * widget, gpointer user_data) |
423 | 245 | { | 275 | { |
430 | 246 | g_return_if_fail(GTK_IS_WIDGET(widget)); | 276 | g_return_if_fail(GTK_IS_WIDGET(widget)); |
431 | 247 | gpointer pio = g_object_get_data(G_OBJECT(widget), "indicator"); | 277 | |
432 | 248 | g_return_if_fail(INDICATOR_IS_OBJECT(pio)); | 278 | IndicatorObject *io = g_object_get_data (G_OBJECT (widget), MENU_DATA_INDICATOR_OBJECT); |
433 | 249 | IndicatorObject * io = INDICATOR_OBJECT(pio); | 279 | IndicatorObjectEntry *entry = g_object_get_data (G_OBJECT (widget), MENU_DATA_INDICATOR_ENTRY); |
434 | 250 | 280 | ||
435 | 251 | return indicator_object_entry_activate(io, (IndicatorObjectEntry *)user_data, gtk_get_current_event_time()); | 281 | g_return_if_fail(INDICATOR_IS_OBJECT(io)); |
436 | 282 | |||
437 | 283 | return indicator_object_entry_activate(io, entry, gtk_get_current_event_time()); | ||
438 | 284 | } | ||
439 | 285 | |||
440 | 286 | static gboolean | ||
441 | 287 | entry_secondary_activated (GtkWidget * widget, GdkEvent * event, gpointer user_data) | ||
442 | 288 | { | ||
443 | 289 | g_return_val_if_fail(GTK_IS_WIDGET(widget), FALSE); | ||
444 | 290 | |||
445 | 291 | switch (event->type) { | ||
446 | 292 | case GDK_ENTER_NOTIFY: | ||
447 | 293 | g_object_set_data(G_OBJECT(widget), MENU_DATA_IN_MENUITEM, GINT_TO_POINTER(TRUE)); | ||
448 | 294 | break; | ||
449 | 295 | |||
450 | 296 | case GDK_LEAVE_NOTIFY: | ||
451 | 297 | g_object_set_data(G_OBJECT(widget), MENU_DATA_IN_MENUITEM, GINT_TO_POINTER(FALSE)); | ||
452 | 298 | g_object_set_data(G_OBJECT(widget), MENU_DATA_MENUITEM_PRESSED, GINT_TO_POINTER(FALSE)); | ||
453 | 299 | break; | ||
454 | 300 | |||
455 | 301 | case GDK_BUTTON_PRESS: | ||
456 | 302 | if (event->button.button == 2) { | ||
457 | 303 | g_object_set_data(G_OBJECT(widget), MENU_DATA_MENUITEM_PRESSED, GINT_TO_POINTER(TRUE)); | ||
458 | 304 | } | ||
459 | 305 | break; | ||
460 | 306 | |||
461 | 307 | case GDK_BUTTON_RELEASE: | ||
462 | 308 | if (event->button.button == 2) { | ||
463 | 309 | gboolean in_menuitem = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(widget), MENU_DATA_IN_MENUITEM)); | ||
464 | 310 | gboolean menuitem_pressed = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(widget), MENU_DATA_MENUITEM_PRESSED)); | ||
465 | 311 | |||
466 | 312 | if (in_menuitem && menuitem_pressed) { | ||
467 | 313 | g_object_set_data(G_OBJECT(widget), MENU_DATA_MENUITEM_PRESSED, GINT_TO_POINTER(FALSE)); | ||
468 | 314 | |||
469 | 315 | IndicatorObject *io = g_object_get_data(G_OBJECT(widget), MENU_DATA_INDICATOR_OBJECT); | ||
470 | 316 | IndicatorObjectEntry *entry = g_object_get_data(G_OBJECT(widget), MENU_DATA_INDICATOR_ENTRY); | ||
471 | 317 | |||
472 | 318 | g_return_val_if_fail(INDICATOR_IS_OBJECT(io), FALSE); | ||
473 | 319 | |||
474 | 320 | g_signal_emit_by_name(io, INDICATOR_OBJECT_SIGNAL_SECONDARY_ACTIVATE, | ||
475 | 321 | entry, event->button.time); | ||
476 | 322 | } | ||
477 | 323 | } | ||
478 | 324 | break; | ||
479 | 325 | } | ||
480 | 326 | |||
481 | 327 | return FALSE; | ||
482 | 252 | } | 328 | } |
483 | 253 | 329 | ||
484 | 254 | static gboolean | 330 | static gboolean |
485 | 255 | entry_scrolled (GtkWidget *menuitem, GdkEventScroll *event, gpointer data) | 331 | entry_scrolled (GtkWidget *menuitem, GdkEventScroll *event, gpointer data) |
486 | 256 | { | 332 | { |
496 | 257 | IndicatorObject *io = g_object_get_data (G_OBJECT (menuitem), MENU_DATA_INDICATOR_OBJECT); | 333 | g_return_val_if_fail(GTK_IS_WIDGET(menuitem), FALSE); |
497 | 258 | IndicatorObjectEntry *entry = g_object_get_data (G_OBJECT (menuitem), MENU_DATA_INDICATOR_ENTRY); | 334 | |
498 | 259 | 335 | IndicatorObject *io = g_object_get_data (G_OBJECT (menuitem), MENU_DATA_INDICATOR_OBJECT); | |
499 | 260 | g_return_val_if_fail(INDICATOR_IS_OBJECT(io), FALSE); | 336 | IndicatorObjectEntry *entry = g_object_get_data (G_OBJECT (menuitem), MENU_DATA_INDICATOR_ENTRY); |
500 | 261 | 337 | ||
501 | 262 | g_signal_emit_by_name (io, "scroll", 1, event->direction); | 338 | g_return_val_if_fail(INDICATOR_IS_OBJECT(io), FALSE); |
502 | 263 | g_signal_emit_by_name (io, "scroll-entry", entry, 1, event->direction); | 339 | |
503 | 264 | 340 | g_signal_emit_by_name (io, INDICATOR_OBJECT_SIGNAL_ENTRY_SCROLLED, entry, 1, event->direction); | |
504 | 265 | return FALSE; | 341 | |
505 | 342 | return FALSE; | ||
506 | 266 | } | 343 | } |
507 | 267 | 344 | ||
508 | 268 | static void | 345 | static void |
509 | 269 | accessible_desc_update_cb (GtkWidget * widget, gpointer userdata) | 346 | accessible_desc_update_cb (GtkWidget * widget, gpointer userdata) |
510 | 270 | { | 347 | { |
519 | 271 | gpointer data = g_object_get_data(G_OBJECT(widget), MENU_DATA_INDICATOR_ENTRY); | 348 | gpointer data = g_object_get_data(G_OBJECT(widget), MENU_DATA_INDICATOR_ENTRY); |
520 | 272 | 349 | ||
521 | 273 | if (data != userdata) { | 350 | if (data != userdata) { |
522 | 274 | return; | 351 | return; |
523 | 275 | } | 352 | } |
524 | 276 | 353 | ||
525 | 277 | IndicatorObjectEntry * entry = (IndicatorObjectEntry *)data; | 354 | IndicatorObjectEntry * entry = (IndicatorObjectEntry *)data; |
526 | 278 | update_accessible_desc(entry, widget); | 355 | update_accessible_desc(entry, widget); |
527 | 279 | } | 356 | } |
528 | 280 | 357 | ||
529 | 281 | static void | 358 | static void |
530 | 282 | accessible_desc_update (IndicatorObject * io, IndicatorObjectEntry * entry, GtkWidget * menubar) | 359 | accessible_desc_update (IndicatorObject * io, IndicatorObjectEntry * entry, GtkWidget * menubar) |
531 | 283 | { | 360 | { |
534 | 284 | gtk_container_foreach(GTK_CONTAINER(menubar), accessible_desc_update_cb, entry); | 361 | gtk_container_foreach(GTK_CONTAINER(menubar), accessible_desc_update_cb, entry); |
535 | 285 | return; | 362 | return; |
536 | 286 | } | 363 | } |
537 | 287 | 364 | ||
538 | 288 | static void | 365 | static void |
539 | 289 | entry_added (IndicatorObject * io, IndicatorObjectEntry * entry, GtkWidget * menubar) | 366 | entry_added (IndicatorObject * io, IndicatorObjectEntry * entry, GtkWidget * menubar) |
540 | 290 | { | 367 | { |
627 | 291 | g_debug("Signal: Entry Added"); | 368 | const char *indicator_name = (const gchar *)g_object_get_data(G_OBJECT(io), IO_DATA_NAME); |
628 | 292 | gboolean something_visible = FALSE; | 369 | g_debug("Signal: Entry Added from %s", indicator_name); |
629 | 293 | gboolean something_sensitive = FALSE; | 370 | gboolean something_visible = FALSE; |
630 | 294 | 371 | gboolean something_sensitive = FALSE; | |
631 | 295 | GtkWidget * menuitem = gtk_menu_item_new(); | 372 | |
632 | 296 | GtkWidget * box = (packdirection == GTK_PACK_DIRECTION_LTR) ? | 373 | GtkWidget * menuitem = gtk_menu_item_new(); |
633 | 297 | gtk_hbox_new(FALSE, 3) : gtk_vbox_new(FALSE, 3); | 374 | GtkWidget * box = (packdirection == GTK_PACK_DIRECTION_LTR) ? |
634 | 298 | 375 | gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 3) : gtk_box_new(GTK_ORIENTATION_VERTICAL, 3); | |
635 | 299 | g_object_set_data (G_OBJECT (menuitem), "indicator", io); | 376 | |
636 | 300 | g_object_set_data (G_OBJECT (menuitem), "box", box); | 377 | g_object_set_data (G_OBJECT (menuitem), MENU_DATA_BOX, box); |
637 | 301 | 378 | g_object_set_data(G_OBJECT(menuitem), MENU_DATA_INDICATOR_ENTRY, entry); | |
638 | 302 | g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(entry_activated), entry); | 379 | g_object_set_data(G_OBJECT(menuitem), MENU_DATA_INDICATOR_OBJECT, io); |
639 | 303 | g_signal_connect(G_OBJECT(menuitem), "scroll-event", G_CALLBACK(entry_scrolled), entry); | 380 | |
640 | 304 | 381 | g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(entry_activated), NULL); | |
641 | 305 | if (entry->image != NULL) { | 382 | g_signal_connect(G_OBJECT(menuitem), "button-press-event", G_CALLBACK(entry_secondary_activated), NULL); |
642 | 306 | gtk_box_pack_start(GTK_BOX(box), GTK_WIDGET(entry->image), FALSE, FALSE, 1); | 383 | g_signal_connect(G_OBJECT(menuitem), "button-release-event", G_CALLBACK(entry_secondary_activated), NULL); |
643 | 307 | if (gtk_widget_get_visible(GTK_WIDGET(entry->image))) { | 384 | g_signal_connect(G_OBJECT(menuitem), "enter-notify-event", G_CALLBACK(entry_secondary_activated), NULL); |
644 | 308 | something_visible = TRUE; | 385 | g_signal_connect(G_OBJECT(menuitem), "leave-notify-event", G_CALLBACK(entry_secondary_activated), NULL); |
645 | 309 | } | 386 | g_signal_connect(G_OBJECT(menuitem), "scroll-event", G_CALLBACK(entry_scrolled), NULL); |
646 | 310 | 387 | ||
647 | 311 | if (gtk_widget_get_sensitive(GTK_WIDGET(entry->image))) { | 388 | if (entry->image != NULL) { |
648 | 312 | something_sensitive = TRUE; | 389 | gtk_box_pack_start(GTK_BOX(box), GTK_WIDGET(entry->image), FALSE, FALSE, 1); |
649 | 313 | } | 390 | if (gtk_widget_get_visible(GTK_WIDGET(entry->image))) { |
650 | 314 | 391 | something_visible = TRUE; | |
651 | 315 | g_signal_connect(G_OBJECT(entry->image), "show", G_CALLBACK(something_shown), menuitem); | 392 | } |
652 | 316 | g_signal_connect(G_OBJECT(entry->image), "hide", G_CALLBACK(something_hidden), menuitem); | 393 | |
653 | 317 | 394 | if (gtk_widget_get_sensitive(GTK_WIDGET(entry->image))) { | |
654 | 318 | g_signal_connect(G_OBJECT(entry->image), "notify::sensitive", G_CALLBACK(sensitive_cb), menuitem); | 395 | something_sensitive = TRUE; |
655 | 319 | } | 396 | } |
656 | 320 | if (entry->label != NULL) { | 397 | |
657 | 321 | switch(packdirection) { | 398 | g_signal_connect(G_OBJECT(entry->image), "show", G_CALLBACK(something_shown), menuitem); |
658 | 322 | case GTK_PACK_DIRECTION_LTR: | 399 | g_signal_connect(G_OBJECT(entry->image), "hide", G_CALLBACK(something_hidden), menuitem); |
659 | 323 | gtk_label_set_angle(GTK_LABEL(entry->label), 0.0); | 400 | |
660 | 324 | break; | 401 | g_signal_connect(G_OBJECT(entry->image), "notify::sensitive", G_CALLBACK(sensitive_cb), menuitem); |
661 | 325 | case GTK_PACK_DIRECTION_TTB: | 402 | } |
662 | 326 | gtk_label_set_angle(GTK_LABEL(entry->label), | 403 | if (entry->label != NULL) { |
663 | 327 | (orient == PANEL_APPLET_ORIENT_LEFT) ? | 404 | switch(packdirection) { |
664 | 328 | 270.0 : 90.0); | 405 | case GTK_PACK_DIRECTION_LTR: |
665 | 329 | break; | 406 | gtk_label_set_angle(GTK_LABEL(entry->label), 0.0); |
666 | 330 | default: | 407 | break; |
667 | 331 | break; | 408 | case GTK_PACK_DIRECTION_TTB: |
668 | 332 | } | 409 | gtk_label_set_angle(GTK_LABEL(entry->label), |
669 | 333 | gtk_box_pack_start(GTK_BOX(box), GTK_WIDGET(entry->label), FALSE, FALSE, 1); | 410 | (orient == PANEL_APPLET_ORIENT_LEFT) ? |
670 | 334 | 411 | 270.0 : 90.0); | |
671 | 335 | if (gtk_widget_get_visible(GTK_WIDGET(entry->label))) { | 412 | break; |
672 | 336 | something_visible = TRUE; | 413 | default: |
673 | 337 | } | 414 | break; |
674 | 338 | 415 | } | |
675 | 339 | if (gtk_widget_get_sensitive(GTK_WIDGET(entry->label))) { | 416 | gtk_box_pack_start(GTK_BOX(box), GTK_WIDGET(entry->label), FALSE, FALSE, 1); |
676 | 340 | something_sensitive = TRUE; | 417 | |
677 | 341 | } | 418 | if (gtk_widget_get_visible(GTK_WIDGET(entry->label))) { |
678 | 342 | 419 | something_visible = TRUE; | |
679 | 343 | g_signal_connect(G_OBJECT(entry->label), "show", G_CALLBACK(something_shown), menuitem); | 420 | } |
680 | 344 | g_signal_connect(G_OBJECT(entry->label), "hide", G_CALLBACK(something_hidden), menuitem); | 421 | |
681 | 345 | 422 | if (gtk_widget_get_sensitive(GTK_WIDGET(entry->label))) { | |
682 | 346 | g_signal_connect(G_OBJECT(entry->label), "notify::sensitive", G_CALLBACK(sensitive_cb), menuitem); | 423 | something_sensitive = TRUE; |
683 | 347 | } | 424 | } |
684 | 348 | gtk_container_add(GTK_CONTAINER(menuitem), box); | 425 | |
685 | 349 | gtk_widget_show(box); | 426 | g_signal_connect(G_OBJECT(entry->label), "show", G_CALLBACK(something_shown), menuitem); |
686 | 350 | 427 | g_signal_connect(G_OBJECT(entry->label), "hide", G_CALLBACK(something_hidden), menuitem); | |
687 | 351 | if (entry->menu != NULL) { | 428 | |
688 | 352 | gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), GTK_WIDGET(entry->menu)); | 429 | g_signal_connect(G_OBJECT(entry->label), "notify::sensitive", G_CALLBACK(sensitive_cb), menuitem); |
689 | 353 | } | 430 | } |
690 | 354 | 431 | gtk_container_add(GTK_CONTAINER(menuitem), box); | |
691 | 355 | incoming_position_t position; | 432 | gtk_widget_show(box); |
692 | 356 | position.objposition = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(io), IO_DATA_ORDER_NUMBER)); | 433 | |
693 | 357 | position.entryposition = indicator_object_get_location(io, entry); | 434 | if (entry->menu != NULL) { |
694 | 358 | position.menupos = 0; | 435 | gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), GTK_WIDGET(entry->menu)); |
695 | 359 | position.found = FALSE; | 436 | } |
696 | 360 | 437 | ||
697 | 361 | gtk_container_foreach(GTK_CONTAINER(menubar), place_in_menu, &position); | 438 | place_in_menu(menubar, menuitem, io, entry); |
698 | 362 | 439 | ||
699 | 363 | gtk_menu_shell_insert(GTK_MENU_SHELL(menubar), menuitem, position.menupos); | 440 | if (something_visible) { |
700 | 364 | 441 | if (entry->accessible_desc != NULL) { | |
701 | 365 | if (something_visible) { | 442 | update_accessible_desc(entry, menuitem); |
702 | 366 | if (entry->accessible_desc != NULL) { | 443 | } |
703 | 367 | update_accessible_desc(entry, menuitem); | 444 | gtk_widget_show(menuitem); |
704 | 368 | } | 445 | } |
705 | 369 | gtk_widget_show(menuitem); | 446 | gtk_widget_set_sensitive(menuitem, something_sensitive); |
706 | 370 | } | 447 | |
707 | 371 | gtk_widget_set_sensitive(menuitem, something_sensitive); | 448 | return; |
622 | 372 | |||
623 | 373 | g_object_set_data(G_OBJECT(menuitem), MENU_DATA_INDICATOR_ENTRY, entry); | ||
624 | 374 | g_object_set_data(G_OBJECT(menuitem), MENU_DATA_INDICATOR_OBJECT, io); | ||
625 | 375 | |||
626 | 376 | return; | ||
708 | 377 | } | 449 | } |
709 | 378 | 450 | ||
710 | 379 | static void | 451 | static void |
711 | 380 | entry_removed_cb (GtkWidget * widget, gpointer userdata) | 452 | entry_removed_cb (GtkWidget * widget, gpointer userdata) |
712 | 381 | { | 453 | { |
733 | 382 | gpointer data = g_object_get_data(G_OBJECT(widget), MENU_DATA_INDICATOR_ENTRY); | 454 | gpointer data = g_object_get_data(G_OBJECT(widget), MENU_DATA_INDICATOR_ENTRY); |
734 | 383 | 455 | ||
735 | 384 | if (data != userdata) { | 456 | if (data != userdata) { |
736 | 385 | return; | 457 | return; |
737 | 386 | } | 458 | } |
738 | 387 | 459 | ||
739 | 388 | IndicatorObjectEntry * entry = (IndicatorObjectEntry *)data; | 460 | IndicatorObjectEntry * entry = (IndicatorObjectEntry *)data; |
740 | 389 | if (entry->label != NULL) { | 461 | if (entry->label != NULL) { |
741 | 390 | g_signal_handlers_disconnect_by_func(G_OBJECT(entry->label), G_CALLBACK(something_shown), widget); | 462 | g_signal_handlers_disconnect_by_func(G_OBJECT(entry->label), G_CALLBACK(something_shown), widget); |
742 | 391 | g_signal_handlers_disconnect_by_func(G_OBJECT(entry->label), G_CALLBACK(something_hidden), widget); | 463 | g_signal_handlers_disconnect_by_func(G_OBJECT(entry->label), G_CALLBACK(something_hidden), widget); |
743 | 392 | g_signal_handlers_disconnect_by_func(G_OBJECT(entry->label), G_CALLBACK(sensitive_cb), widget); | 464 | g_signal_handlers_disconnect_by_func(G_OBJECT(entry->label), G_CALLBACK(sensitive_cb), widget); |
744 | 393 | } | 465 | } |
745 | 394 | if (entry->image != NULL) { | 466 | if (entry->image != NULL) { |
746 | 395 | g_signal_handlers_disconnect_by_func(G_OBJECT(entry->image), G_CALLBACK(something_shown), widget); | 467 | g_signal_handlers_disconnect_by_func(G_OBJECT(entry->image), G_CALLBACK(something_shown), widget); |
747 | 396 | g_signal_handlers_disconnect_by_func(G_OBJECT(entry->image), G_CALLBACK(something_hidden), widget); | 468 | g_signal_handlers_disconnect_by_func(G_OBJECT(entry->image), G_CALLBACK(something_hidden), widget); |
748 | 397 | g_signal_handlers_disconnect_by_func(G_OBJECT(entry->image), G_CALLBACK(sensitive_cb), widget); | 469 | g_signal_handlers_disconnect_by_func(G_OBJECT(entry->image), G_CALLBACK(sensitive_cb), widget); |
749 | 398 | } | 470 | } |
750 | 399 | 471 | ||
751 | 400 | gtk_widget_destroy(widget); | 472 | gtk_widget_destroy(widget); |
752 | 401 | return; | 473 | return; |
753 | 402 | } | 474 | } |
754 | 403 | 475 | ||
755 | 404 | static void | 476 | static void |
756 | 405 | entry_removed (IndicatorObject * io G_GNUC_UNUSED, IndicatorObjectEntry * entry, | 477 | entry_removed (IndicatorObject * io G_GNUC_UNUSED, IndicatorObjectEntry * entry, |
757 | 406 | gpointer user_data) | 478 | gpointer user_data) |
758 | 407 | { | 479 | { |
764 | 408 | g_debug("Signal: Entry Removed"); | 480 | g_debug("Signal: Entry Removed"); |
765 | 409 | 481 | ||
766 | 410 | gtk_container_foreach(GTK_CONTAINER(user_data), entry_removed_cb, entry); | 482 | gtk_container_foreach(GTK_CONTAINER(user_data), entry_removed_cb, entry); |
767 | 411 | 483 | ||
768 | 412 | return; | 484 | return; |
769 | 413 | } | 485 | } |
770 | 414 | 486 | ||
771 | 415 | static void | 487 | static void |
772 | 416 | entry_moved_find_cb (GtkWidget * widget, gpointer userdata) | 488 | entry_moved_find_cb (GtkWidget * widget, gpointer userdata) |
773 | 417 | { | 489 | { |
787 | 418 | gpointer * array = (gpointer *)userdata; | 490 | gpointer * array = (gpointer *)userdata; |
788 | 419 | if (array[1] != NULL) { | 491 | if (array[1] != NULL) { |
789 | 420 | return; | 492 | return; |
790 | 421 | } | 493 | } |
791 | 422 | 494 | ||
792 | 423 | gpointer data = g_object_get_data(G_OBJECT(widget), MENU_DATA_INDICATOR_ENTRY); | 495 | gpointer data = g_object_get_data(G_OBJECT(widget), MENU_DATA_INDICATOR_ENTRY); |
793 | 424 | 496 | ||
794 | 425 | if (data != array[0]) { | 497 | if (data != array[0]) { |
795 | 426 | return; | 498 | return; |
796 | 427 | } | 499 | } |
797 | 428 | 500 | ||
798 | 429 | array[1] = widget; | 501 | array[1] = widget; |
799 | 430 | return; | 502 | return; |
800 | 431 | } | 503 | } |
801 | 432 | 504 | ||
802 | 433 | /* Gets called when an entry for an object was moved. */ | 505 | /* Gets called when an entry for an object was moved. */ |
803 | @@ -435,147 +507,135 @@ | |||
804 | 435 | entry_moved (IndicatorObject * io, IndicatorObjectEntry * entry, | 507 | entry_moved (IndicatorObject * io, IndicatorObjectEntry * entry, |
805 | 436 | gint old G_GNUC_UNUSED, gint new G_GNUC_UNUSED, gpointer user_data) | 508 | gint old G_GNUC_UNUSED, gint new G_GNUC_UNUSED, gpointer user_data) |
806 | 437 | { | 509 | { |
835 | 438 | GtkWidget * menubar = GTK_WIDGET(user_data); | 510 | GtkWidget * menubar = GTK_WIDGET(user_data); |
836 | 439 | 511 | ||
837 | 440 | gpointer array[2]; | 512 | gpointer array[2]; |
838 | 441 | array[0] = entry; | 513 | array[0] = entry; |
839 | 442 | array[1] = NULL; | 514 | array[1] = NULL; |
840 | 443 | 515 | ||
841 | 444 | gtk_container_foreach(GTK_CONTAINER(menubar), entry_moved_find_cb, array); | 516 | gtk_container_foreach(GTK_CONTAINER(menubar), entry_moved_find_cb, array); |
842 | 445 | if (array[1] == NULL) { | 517 | if (array[1] == NULL) { |
843 | 446 | g_warning("Moving an entry that isn't in our menus."); | 518 | g_warning("Moving an entry that isn't in our menus."); |
844 | 447 | return; | 519 | return; |
845 | 448 | } | 520 | } |
846 | 449 | 521 | ||
847 | 450 | GtkWidget * mi = GTK_WIDGET(array[1]); | 522 | GtkWidget * mi = GTK_WIDGET(array[1]); |
848 | 451 | g_object_ref(G_OBJECT(mi)); | 523 | g_object_ref(G_OBJECT(mi)); |
849 | 452 | gtk_container_remove(GTK_CONTAINER(menubar), mi); | 524 | gtk_container_remove(GTK_CONTAINER(menubar), mi); |
850 | 453 | 525 | place_in_menu(menubar, mi, io, entry); | |
851 | 454 | incoming_position_t position; | 526 | g_object_unref(G_OBJECT(mi)); |
852 | 455 | position.objposition = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(io), IO_DATA_ORDER_NUMBER)); | 527 | |
853 | 456 | position.entryposition = indicator_object_get_location(io, entry); | 528 | return; |
826 | 457 | position.menupos = 0; | ||
827 | 458 | position.found = FALSE; | ||
828 | 459 | |||
829 | 460 | gtk_container_foreach(GTK_CONTAINER(menubar), place_in_menu, &position); | ||
830 | 461 | |||
831 | 462 | gtk_menu_shell_insert(GTK_MENU_SHELL(menubar), mi, position.menupos); | ||
832 | 463 | g_object_unref(G_OBJECT(mi)); | ||
833 | 464 | |||
834 | 465 | return; | ||
854 | 466 | } | 529 | } |
855 | 467 | 530 | ||
856 | 468 | static void | 531 | static void |
857 | 469 | menu_show (IndicatorObject * io, IndicatorObjectEntry * entry, | 532 | menu_show (IndicatorObject * io, IndicatorObjectEntry * entry, |
858 | 470 | guint32 timestamp, gpointer user_data) | 533 | guint32 timestamp, gpointer user_data) |
859 | 471 | { | 534 | { |
878 | 472 | GtkWidget * menubar = GTK_WIDGET(user_data); | 535 | GtkWidget * menubar = GTK_WIDGET(user_data); |
879 | 473 | 536 | ||
880 | 474 | if (entry == NULL) { | 537 | if (entry == NULL) { |
881 | 475 | /* Close any open menus instead of opening one */ | 538 | /* Close any open menus instead of opening one */ |
882 | 476 | GList * entries = indicator_object_get_entries(io); | 539 | GList * entries = indicator_object_get_entries(io); |
883 | 477 | GList * entry = NULL; | 540 | GList * entry = NULL; |
884 | 478 | for (entry = entries; entry != NULL; entry = g_list_next(entry)) { | 541 | for (entry = entries; entry != NULL; entry = g_list_next(entry)) { |
885 | 479 | IndicatorObjectEntry * entrydata = (IndicatorObjectEntry *)entry->data; | 542 | IndicatorObjectEntry * entrydata = (IndicatorObjectEntry *)entry->data; |
886 | 480 | gtk_menu_popdown(entrydata->menu); | 543 | gtk_menu_popdown(entrydata->menu); |
887 | 481 | } | 544 | } |
888 | 482 | g_list_free(entries); | 545 | g_list_free(entries); |
889 | 483 | 546 | ||
890 | 484 | /* And tell the menubar to exit activation mode too */ | 547 | /* And tell the menubar to exit activation mode too */ |
891 | 485 | gtk_menu_shell_cancel(GTK_MENU_SHELL(menubar)); | 548 | gtk_menu_shell_cancel(GTK_MENU_SHELL(menubar)); |
892 | 486 | return; | 549 | return; |
893 | 487 | } | 550 | } |
894 | 488 | 551 | ||
895 | 489 | // TODO: do something sensible here | 552 | // TODO: do something sensible here |
896 | 490 | } | 553 | } |
897 | 491 | 554 | ||
898 | 492 | static void | 555 | static void |
899 | 493 | update_accessible_desc(IndicatorObjectEntry * entry, GtkWidget * menuitem) | 556 | update_accessible_desc(IndicatorObjectEntry * entry, GtkWidget * menuitem) |
900 | 494 | { | 557 | { |
910 | 495 | /* FIXME: We need to deal with the use case where the contents of the | 558 | /* FIXME: We need to deal with the use case where the contents of the |
911 | 496 | label overrides what is found in the atk object's name, or at least | 559 | label overrides what is found in the atk object's name, or at least |
912 | 497 | orca speaks the label instead of the atk object name. | 560 | orca speaks the label instead of the atk object name. |
913 | 498 | */ | 561 | */ |
914 | 499 | AtkObject * menuitem_obj = gtk_widget_get_accessible(menuitem); | 562 | AtkObject * menuitem_obj = gtk_widget_get_accessible(menuitem); |
915 | 500 | if (menuitem_obj == NULL) { | 563 | if (menuitem_obj == NULL) { |
916 | 501 | /* Should there be an error printed here? */ | 564 | /* Should there be an error printed here? */ |
917 | 502 | return; | 565 | return; |
918 | 503 | } | 566 | } |
919 | 504 | 567 | ||
926 | 505 | if (entry->accessible_desc != NULL) { | 568 | if (entry->accessible_desc != NULL) { |
927 | 506 | atk_object_set_name(menuitem_obj, entry->accessible_desc); | 569 | atk_object_set_name(menuitem_obj, entry->accessible_desc); |
928 | 507 | } else { | 570 | } else { |
929 | 508 | atk_object_set_name(menuitem_obj, ""); | 571 | atk_object_set_name(menuitem_obj, ""); |
930 | 509 | } | 572 | } |
931 | 510 | return; | 573 | return; |
932 | 511 | } | 574 | } |
933 | 512 | 575 | ||
934 | 513 | 576 | ||
935 | 514 | static gboolean | 577 | static gboolean |
936 | 515 | load_module (const gchar * name, GtkWidget * menubar) | 578 | load_module (const gchar * name, GtkWidget * menubar) |
937 | 516 | { | 579 | { |
977 | 517 | g_debug("Looking at Module: %s", name); | 580 | g_debug("Looking at Module: %s", name); |
978 | 518 | g_return_val_if_fail(name != NULL, FALSE); | 581 | g_return_val_if_fail(name != NULL, FALSE); |
979 | 519 | 582 | ||
980 | 520 | if (!g_str_has_suffix(name, G_MODULE_SUFFIX)) { | 583 | if (!g_str_has_suffix(name, G_MODULE_SUFFIX)) { |
981 | 521 | return FALSE; | 584 | return FALSE; |
982 | 522 | } | 585 | } |
983 | 523 | 586 | ||
984 | 524 | g_debug("Loading Module: %s", name); | 587 | g_debug("Loading Module: %s", name); |
985 | 525 | 588 | ||
986 | 526 | /* Build the object for the module */ | 589 | /* Build the object for the module */ |
987 | 527 | gchar * fullpath = g_build_filename(INDICATOR_DIR, name, NULL); | 590 | gchar * fullpath = g_build_filename(INDICATOR_DIR, name, NULL); |
988 | 528 | IndicatorObject * io = indicator_object_new_from_file(fullpath); | 591 | IndicatorObject * io = indicator_object_new_from_file(fullpath); |
989 | 529 | g_free(fullpath); | 592 | g_free(fullpath); |
990 | 530 | 593 | ||
991 | 531 | /* Set the environment it's in */ | 594 | /* Set the environment it's in */ |
992 | 532 | indicator_object_set_environment(io, (const GStrv)indicator_env); | 595 | indicator_object_set_environment(io, (const GStrv)indicator_env); |
993 | 533 | 596 | ||
994 | 534 | /* Attach the 'name' to the object */ | 597 | /* Attach the 'name' to the object */ |
995 | 535 | g_object_set_data(G_OBJECT(io), IO_DATA_ORDER_NUMBER, GINT_TO_POINTER(name2order(name))); | 598 | g_object_set_data_full(G_OBJECT(io), IO_DATA_NAME, g_strdup(name), g_free); |
996 | 536 | 599 | g_object_set_data(G_OBJECT(io), IO_DATA_ORDER_NUMBER, GINT_TO_POINTER(name2order(name, NULL))); | |
997 | 537 | /* Connect to its signals */ | 600 | |
998 | 538 | g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED, G_CALLBACK(entry_added), menubar); | 601 | /* Connect to its signals */ |
999 | 539 | g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED, G_CALLBACK(entry_removed), menubar); | 602 | g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED, G_CALLBACK(entry_added), menubar); |
1000 | 540 | g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_MOVED, G_CALLBACK(entry_moved), menubar); | 603 | g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED, G_CALLBACK(entry_removed), menubar); |
1001 | 541 | g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_MENU_SHOW, G_CALLBACK(menu_show), menubar); | 604 | g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_MOVED, G_CALLBACK(entry_moved), menubar); |
1002 | 542 | g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ACCESSIBLE_DESC_UPDATE, G_CALLBACK(accessible_desc_update), menubar); | 605 | g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_MENU_SHOW, G_CALLBACK(menu_show), menubar); |
1003 | 543 | 606 | g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ACCESSIBLE_DESC_UPDATE, G_CALLBACK(accessible_desc_update), menubar); | |
1004 | 544 | /* Work on the entries */ | 607 | |
1005 | 545 | GList * entries = indicator_object_get_entries(io); | 608 | /* Work on the entries */ |
1006 | 546 | GList * entry = NULL; | 609 | GList * entries = indicator_object_get_entries(io); |
1007 | 547 | 610 | GList * entry = NULL; | |
1008 | 548 | for (entry = entries; entry != NULL; entry = g_list_next(entry)) { | 611 | |
1009 | 549 | IndicatorObjectEntry * entrydata = (IndicatorObjectEntry *)entry->data; | 612 | for (entry = entries; entry != NULL; entry = g_list_next(entry)) { |
1010 | 550 | entry_added(io, entrydata, menubar); | 613 | IndicatorObjectEntry * entrydata = (IndicatorObjectEntry *)entry->data; |
1011 | 551 | } | 614 | entry_added(io, entrydata, menubar); |
1012 | 552 | 615 | } | |
1013 | 553 | g_list_free(entries); | 616 | |
1014 | 554 | 617 | g_list_free(entries); | |
1015 | 555 | return TRUE; | 618 | |
1016 | 619 | return TRUE; | ||
1017 | 556 | } | 620 | } |
1018 | 557 | 621 | ||
1019 | 558 | static void | 622 | static void |
1021 | 559 | hotkey_filter (char * keystring G_GNUC_UNUSED, gpointer data) | 623 | hotkey_filter (char * keystring, gpointer data) |
1022 | 560 | { | 624 | { |
1041 | 561 | g_return_if_fail(GTK_IS_MENU_SHELL(data)); | 625 | g_return_if_fail(GTK_IS_MENU_SHELL(data)); |
1042 | 562 | 626 | ||
1043 | 563 | /* Oh, wow, it's us! */ | 627 | g_debug ("Hotkey: %s", keystring); |
1044 | 564 | GList * children = gtk_container_get_children(GTK_CONTAINER(data)); | 628 | |
1045 | 565 | if (children == NULL) { | 629 | /* Oh, wow, it's us! */ |
1046 | 566 | g_debug("Menubar has no children"); | 630 | GList * children = gtk_container_get_children(GTK_CONTAINER(data)); |
1047 | 567 | return; | 631 | if (children == NULL) { |
1048 | 568 | } | 632 | g_debug("Menubar has no children"); |
1049 | 569 | 633 | return; | |
1050 | 570 | if (!GTK_MENU_SHELL(data)->active) { | 634 | } |
1051 | 571 | gtk_grab_add (GTK_WIDGET(data)); | 635 | |
1052 | 572 | GTK_MENU_SHELL(data)->have_grab = TRUE; | 636 | gtk_menu_shell_select_item(GTK_MENU_SHELL(data), GTK_WIDGET(g_list_last(children)->data)); |
1053 | 573 | GTK_MENU_SHELL(data)->active = TRUE; | 637 | g_list_free(children); |
1054 | 574 | } | 638 | return; |
1037 | 575 | |||
1038 | 576 | gtk_menu_shell_select_item(GTK_MENU_SHELL(data), GTK_WIDGET(g_list_last(children)->data)); | ||
1039 | 577 | g_list_free(children); | ||
1040 | 578 | return; | ||
1055 | 579 | } | 639 | } |
1056 | 580 | 640 | ||
1057 | 581 | static gboolean | 641 | static gboolean |
1058 | @@ -583,35 +643,23 @@ | |||
1059 | 583 | GdkEventButton *event, | 643 | GdkEventButton *event, |
1060 | 584 | gpointer data G_GNUC_UNUSED) | 644 | gpointer data G_GNUC_UNUSED) |
1061 | 585 | { | 645 | { |
1079 | 586 | if (event->button != 1) { | 646 | if (event->button != 1) { |
1080 | 587 | g_signal_stop_emission_by_name(widget, "button-press-event"); | 647 | g_signal_stop_emission_by_name(widget, "button-press-event"); |
1081 | 588 | } | 648 | } |
1082 | 589 | 649 | ||
1083 | 590 | return FALSE; | 650 | return FALSE; |
1067 | 591 | } | ||
1068 | 592 | |||
1069 | 593 | static gboolean | ||
1070 | 594 | menubar_on_expose (GtkWidget * widget, | ||
1071 | 595 | GdkEventExpose *event G_GNUC_UNUSED, | ||
1072 | 596 | GtkWidget * menubar) | ||
1073 | 597 | { | ||
1074 | 598 | if (GTK_WIDGET_HAS_FOCUS(menubar)) | ||
1075 | 599 | gtk_paint_focus(widget->style, widget->window, GTK_WIDGET_STATE(menubar), | ||
1076 | 600 | NULL, widget, "menubar-applet", 0, 0, -1, -1); | ||
1077 | 601 | |||
1078 | 602 | return FALSE; | ||
1084 | 603 | } | 651 | } |
1085 | 604 | 652 | ||
1086 | 605 | static void | 653 | static void |
1087 | 606 | about_cb (GtkAction *action G_GNUC_UNUSED, | 654 | about_cb (GtkAction *action G_GNUC_UNUSED, |
1088 | 607 | gpointer data G_GNUC_UNUSED) | 655 | gpointer data G_GNUC_UNUSED) |
1089 | 608 | { | 656 | { |
1094 | 609 | static const gchar *authors[] = { | 657 | static const gchar *authors[] = { |
1095 | 610 | "Ted Gould <ted@canonical.com>", | 658 | "Ted Gould <ted@canonical.com>", |
1096 | 611 | NULL | 659 | NULL |
1097 | 612 | }; | 660 | }; |
1098 | 613 | 661 | ||
1100 | 614 | static gchar *license[] = { | 662 | static gchar *license[] = { |
1101 | 615 | N_("This program is free software: you can redistribute it and/or modify it " | 663 | N_("This program is free software: you can redistribute it and/or modify it " |
1102 | 616 | "under the terms of the GNU General Public License version 3, as published " | 664 | "under the terms of the GNU General Public License version 3, as published " |
1103 | 617 | "by the Free Software Foundation."), | 665 | "by the Free Software Foundation."), |
1104 | @@ -621,103 +669,103 @@ | |||
1105 | 621 | "PURPOSE. See the GNU General Public License for more details."), | 669 | "PURPOSE. See the GNU General Public License for more details."), |
1106 | 622 | N_("You should have received a copy of the GNU General Public License along " | 670 | N_("You should have received a copy of the GNU General Public License along " |
1107 | 623 | "with this program. If not, see <http://www.gnu.org/licenses/>."), | 671 | "with this program. If not, see <http://www.gnu.org/licenses/>."), |
1117 | 624 | NULL | 672 | NULL |
1118 | 625 | }; | 673 | }; |
1119 | 626 | gchar *license_i18n; | 674 | gchar *license_i18n; |
1120 | 627 | 675 | ||
1121 | 628 | license_i18n = g_strconcat (_(license[0]), "\n\n", _(license[1]), "\n\n", _(license[2]), NULL); | 676 | license_i18n = g_strconcat (_(license[0]), "\n\n", _(license[1]), "\n\n", _(license[2]), NULL); |
1122 | 629 | 677 | ||
1123 | 630 | gtk_show_about_dialog(NULL, | 678 | gtk_show_about_dialog(NULL, |
1124 | 631 | "version", VERSION, | 679 | "version", VERSION, |
1125 | 632 | "copyright", "Copyright \xc2\xa9 2009-2010 Canonical, Ltd.", | 680 | "copyright", "Copyright \xc2\xa9 2009-2010 Canonical, Ltd.", |
1126 | 633 | #ifdef INDICATOR_APPLET_SESSION | 681 | #ifdef INDICATOR_APPLET_SESSION |
1128 | 634 | "comments", _("A place to adjust your status, change users or exit your session."), | 682 | "comments", _("A place to adjust your status, change users or exit your session."), |
1129 | 635 | #else | 683 | #else |
1130 | 636 | #ifdef INDICATOR_APPLET_APPMENU | 684 | #ifdef INDICATOR_APPLET_APPMENU |
1149 | 637 | "comments", _("An applet to hold your application menus."), | 685 | "comments", _("An applet to hold your application menus."), |
1150 | 638 | #endif | 686 | #endif |
1151 | 639 | "comments", _("An applet to hold all of the system indicators."), | 687 | "comments", _("An applet to hold all of the system indicators."), |
1152 | 640 | #endif | 688 | #endif |
1153 | 641 | "authors", authors, | 689 | "authors", authors, |
1154 | 642 | "license", license_i18n, | 690 | "license", license_i18n, |
1155 | 643 | "wrap-license", TRUE, | 691 | "wrap-license", TRUE, |
1156 | 644 | "translator-credits", _("translator-credits"), | 692 | "translator-credits", _("translator-credits"), |
1157 | 645 | "logo-icon-name", "indicator-applet", | 693 | "logo-icon-name", "indicator-applet", |
1158 | 646 | "icon-name", "indicator-applet", | 694 | "icon-name", "indicator-applet", |
1159 | 647 | "website", "http://launchpad.net/indicator-applet", | 695 | "website", "http://launchpad.net/indicator-applet", |
1160 | 648 | "website-label", _("Indicator Applet Website"), | 696 | "website-label", _("Indicator Applet Website"), |
1161 | 649 | NULL | 697 | NULL |
1162 | 650 | ); | 698 | ); |
1163 | 651 | 699 | ||
1164 | 652 | g_free (license_i18n); | 700 | g_free (license_i18n); |
1165 | 653 | 701 | ||
1166 | 654 | return; | 702 | return; |
1167 | 655 | } | 703 | } |
1168 | 656 | 704 | ||
1169 | 657 | static gboolean | 705 | static gboolean |
1170 | 658 | swap_orient_cb (GtkWidget *item, gpointer data) | 706 | swap_orient_cb (GtkWidget *item, gpointer data) |
1171 | 659 | { | 707 | { |
1192 | 660 | GtkWidget *from = (GtkWidget *) data; | 708 | GtkWidget *from = (GtkWidget *) data; |
1193 | 661 | GtkWidget *to = (GtkWidget *) g_object_get_data(G_OBJECT(from), "to"); | 709 | GtkWidget *to = (GtkWidget *) g_object_get_data(G_OBJECT(from), "to"); |
1194 | 662 | g_object_ref(G_OBJECT(item)); | 710 | g_object_ref(G_OBJECT(item)); |
1195 | 663 | gtk_container_remove(GTK_CONTAINER(from), item); | 711 | gtk_container_remove(GTK_CONTAINER(from), item); |
1196 | 664 | if (GTK_IS_LABEL(item)) { | 712 | if (GTK_IS_LABEL(item)) { |
1197 | 665 | switch(packdirection) { | 713 | switch(packdirection) { |
1198 | 666 | case GTK_PACK_DIRECTION_LTR: | 714 | case GTK_PACK_DIRECTION_LTR: |
1199 | 667 | gtk_label_set_angle(GTK_LABEL(item), 0.0); | 715 | gtk_label_set_angle(GTK_LABEL(item), 0.0); |
1200 | 668 | break; | 716 | break; |
1201 | 669 | case GTK_PACK_DIRECTION_TTB: | 717 | case GTK_PACK_DIRECTION_TTB: |
1202 | 670 | gtk_label_set_angle(GTK_LABEL(item), | 718 | gtk_label_set_angle(GTK_LABEL(item), |
1203 | 671 | (orient == PANEL_APPLET_ORIENT_LEFT) ? | 719 | (orient == PANEL_APPLET_ORIENT_LEFT) ? |
1204 | 672 | 270.0 : 90.0); | 720 | 270.0 : 90.0); |
1205 | 673 | break; | 721 | break; |
1206 | 674 | default: | 722 | default: |
1207 | 675 | break; | 723 | break; |
1208 | 676 | } | 724 | } |
1209 | 677 | } | 725 | } |
1210 | 678 | gtk_box_pack_start(GTK_BOX(to), item, FALSE, FALSE, 0); | 726 | gtk_box_pack_start(GTK_BOX(to), item, FALSE, FALSE, 0); |
1211 | 679 | return TRUE; | 727 | return TRUE; |
1212 | 680 | } | 728 | } |
1213 | 681 | 729 | ||
1214 | 682 | static gboolean | 730 | static gboolean |
1215 | 683 | reorient_box_cb (GtkWidget *menuitem, gpointer data) | 731 | reorient_box_cb (GtkWidget *menuitem, gpointer data) |
1216 | 684 | { | 732 | { |
1228 | 685 | GtkWidget *from = g_object_get_data(G_OBJECT(menuitem), "box"); | 733 | GtkWidget *from = g_object_get_data(G_OBJECT(menuitem), MENU_DATA_BOX); |
1229 | 686 | GtkWidget *to = (packdirection == GTK_PACK_DIRECTION_LTR) ? | 734 | GtkWidget *to = (packdirection == GTK_PACK_DIRECTION_LTR) ? |
1230 | 687 | gtk_hbox_new(FALSE, 0) : gtk_vbox_new(FALSE, 0); | 735 | gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0) : gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); |
1231 | 688 | g_object_set_data(G_OBJECT(from), "to", to); | 736 | g_object_set_data(G_OBJECT(from), "to", to); |
1232 | 689 | gtk_container_foreach(GTK_CONTAINER(from), (GtkCallback)swap_orient_cb, | 737 | gtk_container_foreach(GTK_CONTAINER(from), (GtkCallback)swap_orient_cb, |
1233 | 690 | from); | 738 | from); |
1234 | 691 | gtk_container_remove(GTK_CONTAINER(menuitem), from); | 739 | gtk_container_remove(GTK_CONTAINER(menuitem), from); |
1235 | 692 | gtk_container_add(GTK_CONTAINER(menuitem), to); | 740 | gtk_container_add(GTK_CONTAINER(menuitem), to); |
1236 | 693 | g_object_set_data(G_OBJECT(menuitem), "box", to); | 741 | g_object_set_data(G_OBJECT(menuitem), MENU_DATA_BOX, to); |
1237 | 694 | gtk_widget_show_all(menuitem); | 742 | gtk_widget_show_all(menuitem); |
1238 | 695 | return TRUE; | 743 | return TRUE; |
1239 | 696 | } | 744 | } |
1240 | 697 | 745 | ||
1241 | 698 | static gboolean | 746 | static gboolean |
1242 | 699 | panelapplet_reorient_cb (GtkWidget *applet, PanelAppletOrient neworient, | 747 | panelapplet_reorient_cb (GtkWidget *applet, PanelAppletOrient neworient, |
1244 | 700 | gpointer data) | 748 | gpointer data) |
1245 | 701 | { | 749 | { |
1265 | 702 | GtkWidget *menubar = (GtkWidget *)data; | 750 | GtkWidget *menubar = (GtkWidget *)data; |
1266 | 703 | if ((((neworient == PANEL_APPLET_ORIENT_UP) || | 751 | if ((((neworient == PANEL_APPLET_ORIENT_UP) || |
1267 | 704 | (neworient == PANEL_APPLET_ORIENT_DOWN)) && | 752 | (neworient == PANEL_APPLET_ORIENT_DOWN)) && |
1268 | 705 | ((orient == PANEL_APPLET_ORIENT_LEFT) || | 753 | ((orient == PANEL_APPLET_ORIENT_LEFT) || |
1269 | 706 | (orient == PANEL_APPLET_ORIENT_RIGHT))) || | 754 | (orient == PANEL_APPLET_ORIENT_RIGHT))) || |
1270 | 707 | (((neworient == PANEL_APPLET_ORIENT_LEFT) || | 755 | (((neworient == PANEL_APPLET_ORIENT_LEFT) || |
1271 | 708 | (neworient == PANEL_APPLET_ORIENT_RIGHT)) && | 756 | (neworient == PANEL_APPLET_ORIENT_RIGHT)) && |
1272 | 709 | ((orient == PANEL_APPLET_ORIENT_UP) || | 757 | ((orient == PANEL_APPLET_ORIENT_UP) || |
1273 | 710 | (orient == PANEL_APPLET_ORIENT_DOWN)))) { | 758 | (orient == PANEL_APPLET_ORIENT_DOWN)))) { |
1274 | 711 | packdirection = (packdirection == GTK_PACK_DIRECTION_LTR) ? | 759 | packdirection = (packdirection == GTK_PACK_DIRECTION_LTR) ? |
1275 | 712 | GTK_PACK_DIRECTION_TTB : GTK_PACK_DIRECTION_LTR; | 760 | GTK_PACK_DIRECTION_TTB : GTK_PACK_DIRECTION_LTR; |
1276 | 713 | gtk_menu_bar_set_pack_direction(GTK_MENU_BAR(menubar), | 761 | gtk_menu_bar_set_pack_direction(GTK_MENU_BAR(menubar), |
1277 | 714 | packdirection); | 762 | packdirection); |
1278 | 715 | orient = neworient; | 763 | orient = neworient; |
1279 | 716 | gtk_container_foreach(GTK_CONTAINER(menubar), | 764 | gtk_container_foreach(GTK_CONTAINER(menubar), |
1280 | 717 | (GtkCallback)reorient_box_cb, NULL); | 765 | (GtkCallback)reorient_box_cb, NULL); |
1281 | 718 | } | 766 | } |
1282 | 719 | orient = neworient; | 767 | orient = neworient; |
1283 | 720 | return FALSE; | 768 | return FALSE; |
1284 | 721 | } | 769 | } |
1285 | 722 | 770 | ||
1286 | 723 | #ifdef N_ | 771 | #ifdef N_ |
1287 | @@ -726,277 +774,205 @@ | |||
1288 | 726 | #define N_(x) x | 774 | #define N_(x) x |
1289 | 727 | 775 | ||
1290 | 728 | static void | 776 | static void |
1301 | 729 | log_to_file_cb (GObject * source_obj G_GNUC_UNUSED, | 777 | log_to_file (const gchar * domain, |
1302 | 730 | GAsyncResult * result G_GNUC_UNUSED, gpointer user_data) | 778 | GLogLevelFlags level, |
1293 | 731 | { | ||
1294 | 732 | g_free(user_data); | ||
1295 | 733 | return; | ||
1296 | 734 | } | ||
1297 | 735 | |||
1298 | 736 | static void | ||
1299 | 737 | log_to_file (const gchar * domain G_GNUC_UNUSED, | ||
1300 | 738 | GLogLevelFlags level G_GNUC_UNUSED, | ||
1303 | 739 | const gchar * message, | 779 | const gchar * message, |
1305 | 740 | gpointer data G_GNUC_UNUSED) | 780 | gpointer data) |
1306 | 741 | { | 781 | { |
1347 | 742 | if (log_file == NULL) { | 782 | if (log_file == NULL) { |
1348 | 743 | GError * error = NULL; | 783 | gchar *path; |
1349 | 744 | gchar * filename = g_build_filename(g_get_user_cache_dir(), LOG_FILE_NAME, NULL); | 784 | |
1350 | 745 | GFile * file = g_file_new_for_path(filename); | 785 | g_mkdir_with_parents(g_get_user_cache_dir(), 0755); |
1351 | 746 | g_free(filename); | 786 | path = g_build_filename(g_get_user_cache_dir(), LOG_FILE_NAME, NULL); |
1352 | 747 | 787 | ||
1353 | 748 | if (!g_file_test(g_get_user_cache_dir(), G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) { | 788 | log_file = fopen(path, "w"); |
1354 | 749 | GFile * cachedir = g_file_new_for_path(g_get_user_cache_dir()); | 789 | |
1355 | 750 | g_file_make_directory_with_parents(cachedir, NULL, &error); | 790 | g_free(path); |
1356 | 751 | 791 | } | |
1357 | 752 | if (error != NULL) { | 792 | |
1358 | 753 | g_error("Unable to make directory '%s' for log file: %s", g_get_user_cache_dir(), error->message); | 793 | if(log_file) { |
1359 | 754 | return; | 794 | const gchar *prefix; |
1360 | 755 | } | 795 | |
1361 | 756 | } | 796 | switch(level & G_LOG_LEVEL_MASK) { |
1362 | 757 | 797 | case G_LOG_LEVEL_ERROR: | |
1363 | 758 | g_file_delete(file, NULL, NULL); | 798 | prefix = "ERROR:"; |
1364 | 759 | 799 | break; | |
1365 | 760 | GFileIOStream * io = g_file_create_readwrite(file, | 800 | case G_LOG_LEVEL_CRITICAL: |
1366 | 761 | G_FILE_CREATE_REPLACE_DESTINATION, /* flags */ | 801 | prefix = "CRITICAL:"; |
1367 | 762 | NULL, /* cancelable */ | 802 | break; |
1368 | 763 | &error); /* error */ | 803 | case G_LOG_LEVEL_WARNING: |
1369 | 764 | if (error != NULL) { | 804 | prefix = "WARNING:"; |
1370 | 765 | g_error("Unable to replace file: %s", error->message); | 805 | break; |
1371 | 766 | return; | 806 | case G_LOG_LEVEL_MESSAGE: |
1372 | 767 | } | 807 | prefix = "MESSAGE:"; |
1373 | 768 | 808 | break; | |
1374 | 769 | log_file = g_io_stream_get_output_stream(G_IO_STREAM(io)); | 809 | case G_LOG_LEVEL_INFO: |
1375 | 770 | } | 810 | prefix = "INFO:"; |
1376 | 771 | 811 | break; | |
1377 | 772 | gchar * outputstring = g_strdup_printf("%s\n", message); | 812 | case G_LOG_LEVEL_DEBUG: |
1378 | 773 | g_output_stream_write_async(log_file, | 813 | prefix = "DEBUG:"; |
1379 | 774 | outputstring, /* data */ | 814 | break; |
1380 | 775 | strlen(outputstring), /* length */ | 815 | default: |
1381 | 776 | G_PRIORITY_LOW, /* priority */ | 816 | prefix = "LOG:"; |
1382 | 777 | NULL, /* cancelable */ | 817 | break; |
1383 | 778 | log_to_file_cb, /* callback */ | 818 | } |
1384 | 779 | outputstring); /* data */ | 819 | |
1385 | 780 | 820 | fprintf(log_file, "%s %s - %s\n", prefix, domain, message); | |
1386 | 781 | return; | 821 | fflush(log_file); |
1387 | 822 | } | ||
1388 | 823 | |||
1389 | 824 | g_log_default_handler(domain, level, message, data); | ||
1390 | 825 | |||
1391 | 826 | return; | ||
1392 | 782 | } | 827 | } |
1393 | 783 | 828 | ||
1394 | 784 | static gboolean | 829 | static gboolean |
1395 | 785 | applet_fill_cb (PanelApplet * applet, const gchar * iid G_GNUC_UNUSED, | 830 | applet_fill_cb (PanelApplet * applet, const gchar * iid G_GNUC_UNUSED, |
1396 | 786 | gpointer data G_GNUC_UNUSED) | 831 | gpointer data G_GNUC_UNUSED) |
1397 | 787 | { | 832 | { |
1525 | 788 | static const GtkActionEntry menu_actions[] = { | 833 | static const GtkActionEntry menu_actions[] = { |
1526 | 789 | {"About", GTK_STOCK_ABOUT, N_("_About"), NULL, NULL, G_CALLBACK(about_cb)} | 834 | {"About", GTK_STOCK_ABOUT, N_("_About"), NULL, NULL, G_CALLBACK(about_cb)} |
1527 | 790 | }; | 835 | }; |
1528 | 791 | static const gchar *menu_xml = "<menuitem name=\"About\" action=\"About\"/>"; | 836 | static const gchar *menu_xml = "<menuitem name=\"About\" action=\"About\"/>"; |
1529 | 792 | 837 | ||
1530 | 793 | static gboolean first_time = FALSE; | 838 | static gboolean first_time = FALSE; |
1531 | 794 | GtkWidget *menubar; | 839 | GtkWidget *menubar; |
1532 | 795 | gint indicators_loaded = 0; | 840 | gint indicators_loaded = 0; |
1533 | 796 | GtkActionGroup *action_group; | 841 | GtkActionGroup *action_group; |
1534 | 797 | 842 | GError *error = NULL; | |
1535 | 798 | #ifdef INDICATOR_APPLET_SESSION | 843 | |
1536 | 799 | /* check if we are running stracciatella session */ | 844 | #ifdef INDICATOR_APPLET_SESSION |
1537 | 800 | if (g_strcmp0(g_getenv("GDMSESSION"), "gnome-stracciatella") == 0) { | 845 | /* check if we are running stracciatella session */ |
1538 | 801 | g_debug("Running stracciatella GNOME session, disabling myself"); | 846 | if (g_strcmp0(g_getenv("GDMSESSION"), "gnome-stracciatella") == 0) { |
1539 | 802 | return TRUE; | 847 | g_debug("Running stracciatella GNOME session, disabling myself"); |
1540 | 803 | } | 848 | return TRUE; |
1541 | 804 | #endif | 849 | } |
1542 | 805 | 850 | #endif | |
1543 | 806 | if (!first_time) | 851 | |
1544 | 807 | { | 852 | if (!first_time) |
1545 | 808 | first_time = TRUE; | 853 | { |
1546 | 809 | #ifdef INDICATOR_APPLET | 854 | first_time = TRUE; |
1547 | 810 | g_set_application_name(_("Indicator Applet")); | 855 | #ifdef INDICATOR_APPLET |
1548 | 811 | #endif | 856 | g_set_application_name(_("Indicator Applet")); |
1549 | 812 | #ifdef INDICATOR_APPLET_SESSION | 857 | #endif |
1550 | 813 | g_set_application_name(_("Indicator Applet Session")); | 858 | #ifdef INDICATOR_APPLET_SESSION |
1551 | 814 | #endif | 859 | g_set_application_name(_("Indicator Applet Session")); |
1552 | 815 | #ifdef INDICATOR_APPLET_COMPLETE | 860 | #endif |
1553 | 816 | g_set_application_name(_("Indicator Applet Complete")); | 861 | #ifdef INDICATOR_APPLET_COMPLETE |
1554 | 817 | #endif | 862 | g_set_application_name(_("Indicator Applet Complete")); |
1555 | 818 | #ifdef INDICATOR_APPLET_APPMENU | 863 | #endif |
1556 | 819 | g_set_application_name(_("Indicator Applet Application Menu")); | 864 | #ifdef INDICATOR_APPLET_APPMENU |
1557 | 820 | #endif | 865 | g_set_application_name(_("Indicator Applet Application Menu")); |
1558 | 821 | 866 | #endif | |
1559 | 822 | g_log_set_default_handler(log_to_file, NULL); | 867 | |
1560 | 823 | 868 | g_log_set_default_handler(log_to_file, NULL); | |
1561 | 824 | tomboy_keybinder_init(); | 869 | |
1562 | 825 | } | 870 | tomboy_keybinder_init(); |
1563 | 826 | 871 | } | |
1564 | 827 | /* Set panel options */ | 872 | |
1565 | 828 | gtk_container_set_border_width(GTK_CONTAINER (applet), 0); | 873 | /* Set panel options */ |
1566 | 829 | panel_applet_set_flags(applet, PANEL_APPLET_EXPAND_MINOR); | 874 | gtk_container_set_border_width(GTK_CONTAINER (applet), 0); |
1567 | 830 | menubar = gtk_menu_bar_new(); | 875 | panel_applet_set_flags(applet, PANEL_APPLET_EXPAND_MINOR); |
1568 | 831 | action_group = gtk_action_group_new ("Indicator Applet Actions"); | 876 | menubar = gtk_menu_bar_new(); |
1569 | 832 | gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE); | 877 | action_group = gtk_action_group_new ("Indicator Applet Actions"); |
1570 | 833 | gtk_action_group_add_actions (action_group, menu_actions, | 878 | gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE); |
1571 | 834 | G_N_ELEMENTS (menu_actions), | 879 | gtk_action_group_add_actions (action_group, menu_actions, |
1572 | 835 | menubar); | 880 | G_N_ELEMENTS (menu_actions), |
1573 | 836 | panel_applet_setup_menu(applet, menu_xml, action_group); | 881 | menubar); |
1574 | 837 | g_object_unref(action_group); | 882 | panel_applet_setup_menu(applet, menu_xml, action_group); |
1575 | 838 | #ifdef INDICATOR_APPLET | 883 | g_object_unref(action_group); |
1576 | 839 | atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (applet)), | 884 | #ifdef INDICATOR_APPLET |
1577 | 840 | "indicator-applet"); | 885 | atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (applet)), |
1578 | 841 | #endif | 886 | "indicator-applet"); |
1579 | 842 | #ifdef INDICATOR_APPLET_SESSION | 887 | #endif |
1580 | 843 | atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (applet)), | 888 | #ifdef INDICATOR_APPLET_SESSION |
1581 | 844 | "indicator-applet-session"); | 889 | atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (applet)), |
1582 | 845 | #endif | 890 | "indicator-applet-session"); |
1583 | 846 | #ifdef INDICATOR_APPLET_COMPLETE | 891 | #endif |
1584 | 847 | atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (applet)), | 892 | #ifdef INDICATOR_APPLET_COMPLETE |
1585 | 848 | "indicator-applet-complete"); | 893 | atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (applet)), |
1586 | 849 | #endif | 894 | "indicator-applet-complete"); |
1587 | 850 | #ifdef INDICATOR_APPLET_APPMENU | 895 | #endif |
1588 | 851 | atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (applet)), | 896 | #ifdef INDICATOR_APPLET_APPMENU |
1589 | 852 | "indicator-applet-appmenu"); | 897 | atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (applet)), |
1590 | 853 | #endif | 898 | "indicator-applet-appmenu"); |
1591 | 854 | 899 | #endif | |
1592 | 855 | /* Init some theme/icon stuff */ | 900 | |
1593 | 856 | gtk_icon_theme_append_search_path(gtk_icon_theme_get_default(), | 901 | /* Init some theme/icon stuff */ |
1594 | 857 | INDICATOR_ICONS_DIR); | 902 | gtk_icon_theme_append_search_path(gtk_icon_theme_get_default(), |
1595 | 858 | /* g_debug("Icons directory: %s", INDICATOR_ICONS_DIR); */ | 903 | INDICATOR_ICONS_DIR); |
1596 | 859 | gtk_rc_parse_string ( | 904 | g_debug("Icons directory: %s", INDICATOR_ICONS_DIR); |
1597 | 860 | "style \"indicator-applet-style\"\n" | 905 | |
1598 | 861 | "{\n" | 906 | gtk_widget_set_name(GTK_WIDGET (applet), "fast-user-switch-applet"); |
1599 | 862 | " GtkMenuBar::shadow-type = none\n" | 907 | |
1600 | 863 | " GtkMenuBar::internal-padding = 0\n" | 908 | /* Build menubar */ |
1601 | 864 | " GtkWidget::focus-line-width = 0\n" | 909 | orient = (panel_applet_get_orient(applet)); |
1602 | 865 | " GtkWidget::focus-padding = 0\n" | 910 | packdirection = ((orient == PANEL_APPLET_ORIENT_UP) || |
1603 | 866 | "}\n" | 911 | (orient == PANEL_APPLET_ORIENT_DOWN)) ? |
1604 | 867 | "style \"indicator-applet-menubar-style\"\n" | 912 | GTK_PACK_DIRECTION_LTR : GTK_PACK_DIRECTION_TTB; |
1605 | 868 | "{\n" | 913 | gtk_menu_bar_set_pack_direction(GTK_MENU_BAR(menubar), |
1606 | 869 | " GtkMenuBar::shadow-type = none\n" | 914 | packdirection); |
1607 | 870 | " GtkMenuBar::internal-padding = 0\n" | 915 | gtk_widget_set_can_focus (GTK_WIDGET (menubar), TRUE); |
1608 | 871 | " GtkWidget::focus-line-width = 0\n" | 916 | gtk_widget_set_name(GTK_WIDGET (menubar), "fast-user-switch-menubar"); |
1609 | 872 | " GtkWidget::focus-padding = 0\n" | 917 | g_signal_connect(menubar, "button-press-event", G_CALLBACK(menubar_press), NULL); |
1610 | 873 | " GtkMenuItem::horizontal-padding = 0\n" | 918 | g_signal_connect(applet, "change-orient", |
1611 | 874 | "}\n" | 919 | G_CALLBACK(panelapplet_reorient_cb), menubar); |
1612 | 875 | "style \"indicator-applet-menuitem-style\"\n" | 920 | gtk_container_set_border_width(GTK_CONTAINER(menubar), 0); |
1613 | 876 | "{\n" | 921 | |
1614 | 877 | " GtkWidget::focus-line-width = 0\n" | 922 | /* Add in filter func */ |
1615 | 878 | " GtkWidget::focus-padding = 0\n" | 923 | tomboy_keybinder_bind(hotkey_keycode, hotkey_filter, menubar); |
1616 | 879 | " GtkMenuItem::horizontal-padding = 0\n" | 924 | |
1617 | 880 | "}\n" | 925 | /* load 'em */ |
1618 | 881 | "widget \"*.fast-user-switch-applet\" style \"indicator-applet-style\"" | 926 | if (g_file_test(INDICATOR_DIR, (G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR))) { |
1619 | 882 | "widget \"*.fast-user-switch-menuitem\" style \"indicator-applet-menuitem-style\"" | 927 | GDir * dir = g_dir_open(INDICATOR_DIR, 0, NULL); |
1620 | 883 | "widget \"*.fast-user-switch-menubar\" style \"indicator-applet-menubar-style\""); | 928 | |
1621 | 884 | //gtk_widget_set_name(GTK_WIDGET (applet), "indicator-applet-menubar"); | 929 | const gchar * name; |
1622 | 885 | gtk_widget_set_name(GTK_WIDGET (applet), "fast-user-switch-applet"); | 930 | while ((name = g_dir_read_name(dir)) != NULL) { |
1623 | 886 | 931 | #ifdef INDICATOR_APPLET_APPMENU | |
1624 | 887 | /* Build menubar */ | 932 | if (g_strcmp0(name, "libappmenu.so")) { |
1625 | 888 | orient = (panel_applet_get_orient(applet)); | 933 | continue; |
1626 | 889 | packdirection = ((orient == PANEL_APPLET_ORIENT_UP) || | 934 | } |
1500 | 890 | (orient == PANEL_APPLET_ORIENT_DOWN)) ? | ||
1501 | 891 | GTK_PACK_DIRECTION_LTR : GTK_PACK_DIRECTION_TTB; | ||
1502 | 892 | gtk_menu_bar_set_pack_direction(GTK_MENU_BAR(menubar), | ||
1503 | 893 | packdirection); | ||
1504 | 894 | GTK_WIDGET_SET_FLAGS (menubar, GTK_WIDGET_FLAGS(menubar) | GTK_CAN_FOCUS); | ||
1505 | 895 | gtk_widget_set_name(GTK_WIDGET (menubar), "fast-user-switch-menubar"); | ||
1506 | 896 | g_signal_connect(menubar, "button-press-event", G_CALLBACK(menubar_press), NULL); | ||
1507 | 897 | g_signal_connect_after(menubar, "expose-event", G_CALLBACK(menubar_on_expose), menubar); | ||
1508 | 898 | g_signal_connect(applet, "change-orient", | ||
1509 | 899 | G_CALLBACK(panelapplet_reorient_cb), menubar); | ||
1510 | 900 | gtk_container_set_border_width(GTK_CONTAINER(menubar), 0); | ||
1511 | 901 | |||
1512 | 902 | /* Add in filter func */ | ||
1513 | 903 | tomboy_keybinder_bind(hotkey_keycode, hotkey_filter, menubar); | ||
1514 | 904 | |||
1515 | 905 | /* load 'em */ | ||
1516 | 906 | if (g_file_test(INDICATOR_DIR, (G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR))) { | ||
1517 | 907 | GDir * dir = g_dir_open(INDICATOR_DIR, 0, NULL); | ||
1518 | 908 | |||
1519 | 909 | const gchar * name; | ||
1520 | 910 | while ((name = g_dir_read_name(dir)) != NULL) { | ||
1521 | 911 | #ifdef INDICATOR_APPLET_APPMENU | ||
1522 | 912 | if (g_strcmp0(name, "libappmenu.so")) { | ||
1523 | 913 | continue; | ||
1524 | 914 | } | ||
1627 | 915 | #else | 935 | #else |
1631 | 916 | if (!g_strcmp0(name, "libappmenu.so")) { | 936 | if (!g_strcmp0(name, "libappmenu.so")) { |
1632 | 917 | continue; | 937 | continue; |
1633 | 918 | } | 938 | } |
1634 | 919 | #endif | 939 | #endif |
1635 | 920 | #ifdef INDICATOR_APPLET | 940 | #ifdef INDICATOR_APPLET |
1645 | 921 | if (!g_strcmp0(name, "libsession.so")) { | 941 | if (!g_strcmp0(name, "libsession.so")) { |
1646 | 922 | continue; | 942 | continue; |
1647 | 923 | } | 943 | } |
1648 | 924 | if (!g_strcmp0(name, "libme.so")) { | 944 | if (!g_strcmp0(name, "libme.so")) { |
1649 | 925 | continue; | 945 | continue; |
1650 | 926 | } | 946 | } |
1651 | 927 | if (!g_strcmp0(name, "libdatetime.so")) { | 947 | if (!g_strcmp0(name, "libdatetime.so")) { |
1652 | 928 | continue; | 948 | continue; |
1653 | 929 | } | 949 | } |
1654 | 930 | #endif | 950 | #endif |
1655 | 931 | #ifdef INDICATOR_APPLET_SESSION | 951 | #ifdef INDICATOR_APPLET_SESSION |
1659 | 932 | if (g_strcmp0(name, "libsession.so") && g_strcmp0(name, "libme.so")) { | 952 | if (g_strcmp0(name, "libsession.so") && g_strcmp0(name, "libme.so")) { |
1660 | 933 | continue; | 953 | continue; |
1661 | 934 | } | 954 | } |
1662 | 935 | #endif | 955 | #endif |
1728 | 936 | if (load_module(name, menubar)) { | 956 | if (load_module(name, menubar)) { |
1729 | 937 | indicators_loaded++; | 957 | indicators_loaded++; |
1730 | 938 | } | 958 | } |
1731 | 939 | } | 959 | } |
1732 | 940 | g_dir_close (dir); | 960 | g_dir_close (dir); |
1733 | 941 | } | 961 | } |
1734 | 942 | 962 | ||
1735 | 943 | if (indicators_loaded == 0) { | 963 | if (indicators_loaded == 0) { |
1736 | 944 | /* A label to allow for click through */ | 964 | /* A label to allow for click through */ |
1737 | 945 | GtkWidget * item = gtk_label_new(_("No Indicators")); | 965 | GtkWidget * item = gtk_label_new(_("No Indicators")); |
1738 | 946 | gtk_container_add(GTK_CONTAINER(applet), item); | 966 | gtk_container_add(GTK_CONTAINER(applet), item); |
1739 | 947 | gtk_widget_show(item); | 967 | gtk_widget_show(item); |
1740 | 948 | } else { | 968 | } else { |
1741 | 949 | gtk_container_add(GTK_CONTAINER(applet), menubar); | 969 | gtk_container_add(GTK_CONTAINER(applet), menubar); |
1742 | 950 | panel_applet_set_background_widget(applet, menubar); | 970 | panel_applet_set_background_widget(applet, menubar); |
1743 | 951 | gtk_widget_show(menubar); | 971 | gtk_widget_show(menubar); |
1744 | 952 | } | 972 | } |
1745 | 953 | 973 | ||
1746 | 954 | /* Background of applet */ | 974 | gtk_widget_show(GTK_WIDGET(applet)); |
1747 | 955 | g_signal_connect(applet, "change-background", | 975 | |
1748 | 956 | G_CALLBACK(cw_panel_background_changed), menubar); | 976 | return TRUE; |
1684 | 957 | |||
1685 | 958 | gtk_widget_show(GTK_WIDGET(applet)); | ||
1686 | 959 | |||
1687 | 960 | return TRUE; | ||
1688 | 961 | |||
1689 | 962 | } | ||
1690 | 963 | |||
1691 | 964 | static void | ||
1692 | 965 | cw_panel_background_changed (PanelApplet *applet, | ||
1693 | 966 | PanelAppletBackgroundType type, | ||
1694 | 967 | GdkColor *colour, | ||
1695 | 968 | GdkPixmap *pixmap, | ||
1696 | 969 | GtkWidget *menubar) | ||
1697 | 970 | { | ||
1698 | 971 | GtkRcStyle *rc_style; | ||
1699 | 972 | GtkStyle *style; | ||
1700 | 973 | |||
1701 | 974 | /* reset style */ | ||
1702 | 975 | gtk_widget_set_style(GTK_WIDGET (applet), NULL); | ||
1703 | 976 | gtk_widget_set_style(menubar, NULL); | ||
1704 | 977 | rc_style = gtk_rc_style_new (); | ||
1705 | 978 | gtk_widget_modify_style(GTK_WIDGET (applet), rc_style); | ||
1706 | 979 | gtk_widget_modify_style(menubar, rc_style); | ||
1707 | 980 | gtk_rc_style_unref(rc_style); | ||
1708 | 981 | |||
1709 | 982 | switch (type) | ||
1710 | 983 | { | ||
1711 | 984 | case PANEL_NO_BACKGROUND: | ||
1712 | 985 | break; | ||
1713 | 986 | case PANEL_COLOR_BACKGROUND: | ||
1714 | 987 | gtk_widget_modify_bg(GTK_WIDGET (applet), GTK_STATE_NORMAL, colour); | ||
1715 | 988 | gtk_widget_modify_bg(menubar, GTK_STATE_NORMAL, colour); | ||
1716 | 989 | break; | ||
1717 | 990 | |||
1718 | 991 | case PANEL_PIXMAP_BACKGROUND: | ||
1719 | 992 | style = gtk_style_copy(GTK_WIDGET (applet)->style); | ||
1720 | 993 | if (style->bg_pixmap[GTK_STATE_NORMAL]) | ||
1721 | 994 | g_object_unref(style->bg_pixmap[GTK_STATE_NORMAL]); | ||
1722 | 995 | style->bg_pixmap[GTK_STATE_NORMAL] = g_object_ref (pixmap); | ||
1723 | 996 | gtk_widget_set_style(GTK_WIDGET (applet), style); | ||
1724 | 997 | gtk_widget_set_style(GTK_WIDGET (menubar), style); | ||
1725 | 998 | g_object_unref(style); | ||
1726 | 999 | break; | ||
1727 | 1000 | } | ||
1749 | 1001 | } | 977 | } |
1750 | 1002 | 978 | ||
1751 | 1003 | 979 | ||
1752 | === modified file 'src/eggaccelerators.c' | |||
1753 | --- src/eggaccelerators.c 2010-03-02 22:24:00 +0000 | |||
1754 | +++ src/eggaccelerators.c 2011-11-26 02:05:26 +0000 | |||
1755 | @@ -578,20 +578,20 @@ | |||
1756 | 578 | j = 0; | 578 | j = 0; |
1757 | 579 | while (j < n_entries) | 579 | while (j < n_entries) |
1758 | 580 | { | 580 | { |
1760 | 581 | if (keyvals[j] == GDK_Num_Lock) | 581 | if (keyvals[j] == GDK_KEY_Num_Lock) |
1761 | 582 | mask |= EGG_VIRTUAL_NUM_LOCK_MASK; | 582 | mask |= EGG_VIRTUAL_NUM_LOCK_MASK; |
1763 | 583 | else if (keyvals[j] == GDK_Scroll_Lock) | 583 | else if (keyvals[j] == GDK_KEY_Scroll_Lock) |
1764 | 584 | mask |= EGG_VIRTUAL_SCROLL_LOCK_MASK; | 584 | mask |= EGG_VIRTUAL_SCROLL_LOCK_MASK; |
1767 | 585 | else if (keyvals[j] == GDK_Meta_L || | 585 | else if (keyvals[j] == GDK_KEY_Meta_L || |
1768 | 586 | keyvals[j] == GDK_Meta_R) | 586 | keyvals[j] == GDK_KEY_Meta_R) |
1769 | 587 | mask |= EGG_VIRTUAL_META_MASK; | 587 | mask |= EGG_VIRTUAL_META_MASK; |
1772 | 588 | else if (keyvals[j] == GDK_Hyper_L || | 588 | else if (keyvals[j] == GDK_KEY_Hyper_L || |
1773 | 589 | keyvals[j] == GDK_Hyper_R) | 589 | keyvals[j] == GDK_KEY_Hyper_R) |
1774 | 590 | mask |= EGG_VIRTUAL_HYPER_MASK; | 590 | mask |= EGG_VIRTUAL_HYPER_MASK; |
1777 | 591 | else if (keyvals[j] == GDK_Super_L || | 591 | else if (keyvals[j] == GDK_KEY_Super_L || |
1778 | 592 | keyvals[j] == GDK_Super_R) | 592 | keyvals[j] == GDK_KEY_Super_R) |
1779 | 593 | mask |= EGG_VIRTUAL_SUPER_MASK; | 593 | mask |= EGG_VIRTUAL_SUPER_MASK; |
1781 | 594 | else if (keyvals[j] == GDK_Mode_switch) | 594 | else if (keyvals[j] == GDK_KEY_Mode_switch) |
1782 | 595 | mask |= EGG_VIRTUAL_MODE_SWITCH_MASK; | 595 | mask |= EGG_VIRTUAL_MODE_SWITCH_MASK; |
1783 | 596 | 596 | ||
1784 | 597 | ++j; | 597 | ++j; |
1785 | 598 | 598 | ||
1786 | === modified file 'src/eggaccelerators.h' | |||
1787 | --- src/eggaccelerators.h 2010-03-02 22:24:00 +0000 | |||
1788 | +++ src/eggaccelerators.h 2011-11-26 02:05:26 +0000 | |||
1789 | @@ -20,7 +20,7 @@ | |||
1790 | 20 | #ifndef __EGG_ACCELERATORS_H__ | 20 | #ifndef __EGG_ACCELERATORS_H__ |
1791 | 21 | #define __EGG_ACCELERATORS_H__ | 21 | #define __EGG_ACCELERATORS_H__ |
1792 | 22 | 22 | ||
1794 | 23 | #include <gtk/gtkaccelgroup.h> | 23 | #include <gtk/gtk.h> |
1795 | 24 | #include <gdk/gdk.h> | 24 | #include <gdk/gdk.h> |
1796 | 25 | 25 | ||
1797 | 26 | G_BEGIN_DECLS | 26 | G_BEGIN_DECLS |
1798 | 27 | 27 | ||
1799 | === modified file 'src/tomboykeybinder.c' | |||
1800 | --- src/tomboykeybinder.c 2010-05-04 16:54:22 +0000 | |||
1801 | +++ src/tomboykeybinder.c 2011-11-26 02:05:26 +0000 | |||
1802 | @@ -18,7 +18,6 @@ | |||
1803 | 18 | #include <string.h> | 18 | #include <string.h> |
1804 | 19 | 19 | ||
1805 | 20 | #include <gdk/gdk.h> | 20 | #include <gdk/gdk.h> |
1806 | 21 | #include <gdk/gdkwindow.h> | ||
1807 | 22 | #include <gdk/gdkx.h> | 21 | #include <gdk/gdkx.h> |
1808 | 23 | #include <X11/Xlib.h> | 22 | #include <X11/Xlib.h> |
1809 | 24 | 23 | ||
1810 | @@ -86,7 +85,7 @@ | |||
1811 | 86 | XGrabKey (GDK_WINDOW_XDISPLAY (rootwin), | 85 | XGrabKey (GDK_WINDOW_XDISPLAY (rootwin), |
1812 | 87 | binding->keycode, | 86 | binding->keycode, |
1813 | 88 | binding->modifiers | mod_masks [i], | 87 | binding->modifiers | mod_masks [i], |
1815 | 89 | GDK_WINDOW_XWINDOW (rootwin), | 88 | GDK_WINDOW_XID (rootwin), |
1816 | 90 | False, | 89 | False, |
1817 | 91 | GrabModeAsync, | 90 | GrabModeAsync, |
1818 | 92 | GrabModeAsync); | 91 | GrabModeAsync); |
1819 | @@ -94,7 +93,7 @@ | |||
1820 | 94 | XUngrabKey (GDK_WINDOW_XDISPLAY (rootwin), | 93 | XUngrabKey (GDK_WINDOW_XDISPLAY (rootwin), |
1821 | 95 | binding->keycode, | 94 | binding->keycode, |
1822 | 96 | binding->modifiers | mod_masks [i], | 95 | binding->modifiers | mod_masks [i], |
1824 | 97 | GDK_WINDOW_XWINDOW (rootwin)); | 96 | GDK_WINDOW_XID (rootwin)); |
1825 | 98 | } | 97 | } |
1826 | 99 | } | 98 | } |
1827 | 100 | } | 99 | } |
1828 | @@ -312,7 +311,7 @@ | |||
1829 | 312 | XModifierKeymap *mod_keymap; | 311 | XModifierKeymap *mod_keymap; |
1830 | 313 | gboolean retval = FALSE; | 312 | gboolean retval = FALSE; |
1831 | 314 | 313 | ||
1833 | 315 | mod_keymap = XGetModifierMapping (gdk_display); | 314 | mod_keymap = XGetModifierMapping (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ())); |
1834 | 316 | 315 | ||
1835 | 317 | map_size = 8 * mod_keymap->max_keypermod; | 316 | map_size = 8 * mod_keymap->max_keypermod; |
1836 | 318 | 317 |
Builds and works for me™, though not for all (see https:/ /bugs.launchpad .net/indicator- applet/ +bug/724369/ comments/ 27).
Note that my branch lp:~mitya57/indicator-session/fix-lp-881832 should be merged as well to get this working properly.