Merge lp:~jconti/indicator-applet/gnome3 into lp:indicator-applet/0.4

Proposed by Raphaël Hertzog
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
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.

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.

To post a comment you must log in.
Revision history for this message
Dmitry Shachnev (mitya57) wrote :

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.

review: Approve
Revision history for this message
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

Revision history for this message
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://paste.ubuntu.com/725607/

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/tomboykeybinder.c (to silence a warning) from my branch, so that may be another way to go since I made quite a few possibly unwelcomed changes in my branch (such as using the logging functions from lightdm, since I found that the ones in indicator-applet tend to lose debug messages occasionally).

Revision history for this message
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?

Revision history for this message
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.

review: Needs Fixing
lp:~jconti/indicator-applet/gnome3 updated
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

Revision history for this message
Jason Conti (jconti) wrote :

Added secondary-activate signal and name-hint for positioning support. I'll update the ppa tomorrow for testing.

Revision history for this message
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.

review: Approve
Revision history for this message
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.

review: Approve
Revision history for this message
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.

review: Approve (code review and test)

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

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file '.bzrignore'
--- .bzrignore 2010-04-27 22:02:51 +0000
+++ .bzrignore 2011-11-26 02:05:26 +0000
@@ -4,8 +4,11 @@
4data/GNOME_IndicatorApplet.server4data/GNOME_IndicatorApplet.server
5data/GNOME_IndicatorApplet.server.in5data/GNOME_IndicatorApplet.server.in
6data/indicator-applet.schemas6data/indicator-applet.schemas
7data/*.panel-applet
8data/*.service
7po/@GETTEXT_PACKAGE@.pot9po/@GETTEXT_PACKAGE@.pot
8po/indicator-applet.pot10po/indicator-applet.pot
11po/*.gmo
9src/indicator-applet12src/indicator-applet
10dbus-indicate-client.h13dbus-indicate-client.h
11dbus-indicate-server.h14dbus-indicate-server.h
1215
=== modified file 'configure.ac'
--- configure.ac 2011-04-15 02:32:33 +0000
+++ configure.ac 2011-11-26 02:05:26 +0000
@@ -4,7 +4,7 @@
4AC_PREREQ(2.53)4AC_PREREQ(2.53)
55
6AM_CONFIG_HEADER(config.h)6AM_CONFIG_HEADER(config.h)
7AM_INIT_AUTOMAKE(indicator-applet, 0.4.12)7AM_INIT_AUTOMAKE(indicator-applet, 0.4.14)
88
9AM_MAINTAINER_MODE9AM_MAINTAINER_MODE
10m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES])10m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES])
@@ -25,13 +25,15 @@
25# Dependencies 25# Dependencies
26###########################26###########################
2727
28GTK_REQUIRED_VERSION=2.1228GTK_REQUIRED_VERSION=3.1
29INDICATOR_REQUIRED_VERSION=0.3.2229INDICATOR_REQUIRED_VERSION=0.3.92
30INDICATOR_PKG=indicator3-0.4
31APPLET_PKG=libpanelapplet-4.0
3032
31PKG_CHECK_MODULES(APPLET, gtk+-2.0 >= $GTK_REQUIRED_VERSION33PKG_CHECK_MODULES(APPLET, gtk+-3.0 >= $GTK_REQUIRED_VERSION
32 x1134 x11
33 libpanelapplet-3.035 $APPLET_PKG
34 indicator >= $INDICATOR_REQUIRED_VERSION)36 $INDICATOR_PKG >= $INDICATOR_REQUIRED_VERSION)
35AC_SUBST(APPLET_CFLAGS)37AC_SUBST(APPLET_CFLAGS)
36AC_SUBST(APPLET_LIBS)38AC_SUBST(APPLET_LIBS)
3739
@@ -47,13 +49,16 @@
47###########################49###########################
4850
49if test "x$with_localinstall" = "xyes"; then51if test "x$with_localinstall" = "xyes"; then
52 APPLETDIR="${datadir}/gnome-panel/applets/"
50 INDICATORDIR="${libdir}/indicators/2/"53 INDICATORDIR="${libdir}/indicators/2/"
51 INDICATORICONSDIR="${datadir}/indicator-applet/icons/"54 INDICATORICONSDIR="${datadir}/indicator-applet/icons/"
52else55else
53 INDICATORDIR=`$PKG_CONFIG --variable=indicatordir indicator`56 APPLETDIR=`$PKG_CONFIG --variable=libpanel_applet_dir $APPLET_PKG`
54 INDICATORICONSDIR=`$PKG_CONFIG --variable=iconsdir indicator`57 INDICATORDIR=`$PKG_CONFIG --variable=indicatordir $INDICATOR_PKG`
58 INDICATORICONSDIR=`$PKG_CONFIG --variable=iconsdir $INDICATOR_PKG`
55fi59fi
5660
61AC_SUBST(APPLETDIR)
57AC_SUBST(INDICATORDIR)62AC_SUBST(INDICATORDIR)
58AC_SUBST(INDICATORICONSDIR)63AC_SUBST(INDICATORICONSDIR)
5964
6065
=== modified file 'data/Makefile.am'
--- data/Makefile.am 2010-11-10 18:28:18 +0000
+++ data/Makefile.am 2011-11-26 02:05:26 +0000
@@ -4,7 +4,7 @@
4# Applets4# Applets
5##############################5##############################
66
7appletdir = $(datadir)/gnome-panel/applets7appletdir = $(APPLETDIR)
8applet_in_files = \8applet_in_files = \
9 org.ayatana.panel.IndicatorApplet.panel-applet.in \9 org.ayatana.panel.IndicatorApplet.panel-applet.in \
10 org.ayatana.panel.IndicatorAppletComplete.panel-applet.in \10 org.ayatana.panel.IndicatorAppletComplete.panel-applet.in \
1111
=== modified file 'src/Makefile.am'
--- src/Makefile.am 2010-04-26 15:21:06 +0000
+++ src/Makefile.am 2011-11-26 02:05:26 +0000
@@ -11,6 +11,8 @@
11 -DINDICATOR_DIR=\""$(INDICATORDIR)"\" \11 -DINDICATOR_DIR=\""$(INDICATORDIR)"\" \
12 -DINDICATOR_ICONS_DIR=\""$(INDICATORICONSDIR)"\" \12 -DINDICATOR_ICONS_DIR=\""$(INDICATORICONSDIR)"\" \
13 -DINDICATOR_APPLET \13 -DINDICATOR_APPLET \
14 -DGDK_DISABLE_DEPRECATED \
15 -DGTK_DISABLE_DEPRECATED \
14 -I$(srcdir)/.. \16 -I$(srcdir)/.. \
15 $(APPLET_CFLAGS)17 $(APPLET_CFLAGS)
1618
@@ -30,6 +32,8 @@
30 -DINDICATOR_DIR=\""$(INDICATORDIR)"\" \32 -DINDICATOR_DIR=\""$(INDICATORDIR)"\" \
31 -DINDICATOR_ICONS_DIR=\""$(INDICATORICONSDIR)"\" \33 -DINDICATOR_ICONS_DIR=\""$(INDICATORICONSDIR)"\" \
32 -DINDICATOR_APPLET_APPMENU \34 -DINDICATOR_APPLET_APPMENU \
35 -DGDK_DISABLE_DEPRECATED \
36 -DGTK_DISABLE_DEPRECATED \
33 -I$(srcdir)/.. \37 -I$(srcdir)/.. \
34 $(APPLET_CFLAGS)38 $(APPLET_CFLAGS)
3539
@@ -49,6 +53,8 @@
49 -DINDICATOR_DIR=\""$(INDICATORDIR)"\" \53 -DINDICATOR_DIR=\""$(INDICATORDIR)"\" \
50 -DINDICATOR_ICONS_DIR=\""$(INDICATORICONSDIR)"\" \54 -DINDICATOR_ICONS_DIR=\""$(INDICATORICONSDIR)"\" \
51 -DINDICATOR_APPLET_SESSION \55 -DINDICATOR_APPLET_SESSION \
56 -DGDK_DISABLE_DEPRECATED \
57 -DGTK_DISABLE_DEPRECATED \
52 -I$(srcdir)/.. \58 -I$(srcdir)/.. \
53 $(APPLET_CFLAGS)59 $(APPLET_CFLAGS)
5460
@@ -68,6 +74,8 @@
68 -DINDICATOR_DIR=\""$(INDICATORDIR)"\" \74 -DINDICATOR_DIR=\""$(INDICATORDIR)"\" \
69 -DINDICATOR_ICONS_DIR=\""$(INDICATORICONSDIR)"\" \75 -DINDICATOR_ICONS_DIR=\""$(INDICATORICONSDIR)"\" \
70 -DINDICATOR_APPLET_COMPLETE \76 -DINDICATOR_APPLET_COMPLETE \
77 -DGDK_DISABLE_DEPRECATED \
78 -DGTK_DISABLE_DEPRECATED \
71 -I$(srcdir)/.. \79 -I$(srcdir)/.. \
72 $(APPLET_CFLAGS)80 $(APPLET_CFLAGS)
7381
7482
=== modified file 'src/applet-main.c'
--- src/applet-main.c 2011-04-13 16:22:14 +0000
+++ src/applet-main.c 2011-11-26 02:05:26 +0000
@@ -30,31 +30,36 @@
30#include "libindicator/indicator-object.h"30#include "libindicator/indicator-object.h"
31#include "tomboykeybinder.h"31#include "tomboykeybinder.h"
3232
33static gchar * indicator_order[] = {33static gchar * indicator_order[][2] = {
34 "libapplication.so",34 {"libappmenu.so", NULL},
35 "libsoundmenu.so",35 {"libapplication.so", NULL},
36 "libmessaging.so",36 {"libapplication.so", "gst-keyboard-xkb"},
37 "libdatetime.so",37 {"libmessaging.so", NULL},
38 "libme.so",38 {"libpower.so", NULL},
39 "libsession.so",39 {"libapplication.so", "bluetooth-manager"},
40 NULL40 {"libnetwork.so", NULL},
41 {"libnetworkmenu.so", NULL},
42 {"libapplication.so", "nm-applet"},
43 {"libsoundmenu.so", NULL},
44 {"libdatetime.so", NULL},
45 {"libsession.so", NULL},
46 {NULL, NULL}
41};47};
4248
43static GtkPackDirection packdirection;49static GtkPackDirection packdirection;
44static PanelAppletOrient orient;50static PanelAppletOrient orient;
4551
52#define MENU_DATA_BOX "box"
46#define MENU_DATA_INDICATOR_OBJECT "indicator-object"53#define MENU_DATA_INDICATOR_OBJECT "indicator-object"
47#define MENU_DATA_INDICATOR_ENTRY "indicator-entry"54#define MENU_DATA_INDICATOR_ENTRY "indicator-entry"
55#define MENU_DATA_IN_MENUITEM "in-menuitem"
56#define MENU_DATA_MENUITEM_PRESSED "menuitem-pressed"
4857
58#define IO_DATA_NAME "indicator-name"
49#define IO_DATA_ORDER_NUMBER "indicator-order-number"59#define IO_DATA_ORDER_NUMBER "indicator-order-number"
5060
51static gboolean applet_fill_cb (PanelApplet * applet, const gchar * iid, gpointer data);61static gboolean applet_fill_cb (PanelApplet * applet, const gchar * iid, gpointer data);
5262
53static void cw_panel_background_changed (PanelApplet *applet,
54 PanelAppletBackgroundType type,
55 GdkColor *colour,
56 GdkPixmap *pixmap,
57 GtkWidget *menubar);
58static void update_accessible_desc (IndicatorObjectEntry * entry, GtkWidget * menuitem);63static void update_accessible_desc (IndicatorObjectEntry * entry, GtkWidget * menuitem);
5964
60/*************65/*************
@@ -64,25 +69,21 @@
64#ifdef INDICATOR_APPLET69#ifdef INDICATOR_APPLET
65PANEL_APPLET_OUT_PROCESS_FACTORY ("IndicatorAppletFactory",70PANEL_APPLET_OUT_PROCESS_FACTORY ("IndicatorAppletFactory",
66 PANEL_TYPE_APPLET,71 PANEL_TYPE_APPLET,
67 "indicator-applet",
68 applet_fill_cb, NULL);72 applet_fill_cb, NULL);
69#endif73#endif
70#ifdef INDICATOR_APPLET_SESSION74#ifdef INDICATOR_APPLET_SESSION
71PANEL_APPLET_OUT_PROCESS_FACTORY ("FastUserSwitchAppletFactory",75PANEL_APPLET_OUT_PROCESS_FACTORY ("FastUserSwitchAppletFactory",
72 PANEL_TYPE_APPLET,76 PANEL_TYPE_APPLET,
73 "indicator-applet-session",
74 applet_fill_cb, NULL);77 applet_fill_cb, NULL);
75#endif78#endif
76#ifdef INDICATOR_APPLET_COMPLETE79#ifdef INDICATOR_APPLET_COMPLETE
77PANEL_APPLET_OUT_PROCESS_FACTORY ("IndicatorAppletCompleteFactory",80PANEL_APPLET_OUT_PROCESS_FACTORY ("IndicatorAppletCompleteFactory",
78 PANEL_TYPE_APPLET,81 PANEL_TYPE_APPLET,
79 "indicator-applet-complete",
80 applet_fill_cb, NULL);82 applet_fill_cb, NULL);
81#endif83#endif
82#ifdef INDICATOR_APPLET_APPMENU84#ifdef INDICATOR_APPLET_APPMENU
83PANEL_APPLET_OUT_PROCESS_FACTORY ("IndicatorAppletAppmenuFactory",85PANEL_APPLET_OUT_PROCESS_FACTORY ("IndicatorAppletAppmenuFactory",
84 PANEL_TYPE_APPLET,86 PANEL_TYPE_APPLET,
85 "indicator-applet-appmenu",
86 applet_fill_cb, NULL);87 applet_fill_cb, NULL);
87#endif88#endif
8889
@@ -101,7 +102,7 @@
101#ifdef INDICATOR_APPLET_APPMENU102#ifdef INDICATOR_APPLET_APPMENU
102#define LOG_FILE_NAME "indicator-applet-appmenu.log"103#define LOG_FILE_NAME "indicator-applet-appmenu.log"
103#endif104#endif
104GOutputStream * log_file = NULL;105static FILE *log_file = NULL;
105106
106/*****************107/*****************
107 * Hotkey support 108 * Hotkey support
@@ -136,34 +137,31 @@
136#endif137#endif
137138
138static const gchar * indicator_env[] = {139static const gchar * indicator_env[] = {
139 "indicator-applet",140 "indicator-applet",
140 INDICATOR_SPECIFIC_ENV,141 INDICATOR_SPECIFIC_ENV,
141 NULL142 NULL
142};143};
143144
144/*************
145 * init function
146 * ***********/
147
148static gint145static gint
149name2order (const gchar * name) {146name2order (const gchar * name, const gchar * hint) {
150 int i;147 int i;
151148
152 for (i = 0; indicator_order[i] != NULL; i++) {149 for (i = 0; indicator_order[i][0] != NULL; i++) {
153 if (g_strcmp0(name, indicator_order[i]) == 0) {150 if (g_strcmp0(name, indicator_order[i][0]) == 0 &&
154 return i;151 g_strcmp0(hint, indicator_order[i][1]) == 0) {
155 }152 return i;
156 }153 }
157154 }
158 return -1;155
156 return -1;
159}157}
160158
161typedef struct _incoming_position_t incoming_position_t;159typedef struct _incoming_position_t incoming_position_t;
162struct _incoming_position_t {160struct _incoming_position_t {
163 gint objposition;161 gint objposition;
164 gint entryposition;162 gint entryposition;
165 gint menupos;163 gint menupos;
166 gboolean found;164 gboolean found;
167};165};
168166
169/* This function helps by determining where in the menu list167/* This function helps by determining where in the menu list
@@ -171,263 +169,337 @@
171 that they're on, and then the individual entries. Each169 that they're on, and then the individual entries. Each
172 is progressively more expensive. */170 is progressively more expensive. */
173static void171static void
174place_in_menu (GtkWidget * widget, gpointer user_data)172place_in_menu_cb (GtkWidget * widget, gpointer user_data)
175{173{
176 incoming_position_t * position = (incoming_position_t *)user_data;174 incoming_position_t * position = (incoming_position_t *)user_data;
177 if (position->found) {175 if (position->found) {
178 /* We've already been placed, just finish the foreach */176 /* We've already been placed, just finish the foreach */
179 return;177 return;
180 }178 }
181179
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));
183 g_assert(io != NULL);181 g_return_if_fail(INDICATOR_IS_OBJECT(io));
184182
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));
186 /* We've already passed it, well, then this is where184 /* We've already passed it, well, then this is where
187 we should be be. Stop! */185 we should be be. Stop! */
188 if (objposition > position->objposition) {186 if (objposition > position->objposition) {
189 position->found = TRUE;187 position->found = TRUE;
190 return;188 return;
191 }189 }
192190
193 /* The objects don't match yet, keep looking */191 /* The objects don't match yet, keep looking */
194 if (objposition < position->objposition) {192 if (objposition < position->objposition) {
195 position->menupos++;193 position->menupos++;
196 return;194 return;
197 }195 }
198196
199 /* The objects are the same, let's start looking at entries. */197 /* The objects are the same, let's start looking at entries. */
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);
201 gint entryposition = indicator_object_get_location(io, entry);199 gint entryposition = indicator_object_get_location(io, entry);
202200
203 if (entryposition > position->entryposition) {201 if (entryposition > position->entryposition) {
204 position->found = TRUE;202 position->found = TRUE;
205 return;203 return;
206 }204 }
207205
208 if (entryposition < position->entryposition) {206 if (entryposition < position->entryposition) {
209 position->menupos++;207 position->menupos++;
210 return;208 return;
211 }209 }
212210
213 /* We've got the same object and the same entry. Well,211 /* We've got the same object and the same entry. Well,
214 let's just put it right here then. */212 let's just put it right here then. */
215 position->found = TRUE;213 position->found = TRUE;
216 return;214 return;
215}
216
217/* Position the entry */
218static void
219place_in_menu (GtkWidget *menubar,
220 GtkWidget *menuitem,
221 IndicatorObject *io,
222 IndicatorObjectEntry *entry)
223{
224 incoming_position_t position;
225
226 /* Start with the default position for this indicator object */
227 gint io_position = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(io), IO_DATA_ORDER_NUMBER));
228
229 /* If name-hint is set, try to find the entry's position */
230 if (entry->name_hint != NULL) {
231 const gchar *name = (const gchar *)g_object_get_data(G_OBJECT(io), IO_DATA_NAME);
232 gint entry_position = name2order(name, entry->name_hint);
233
234 /* If we don't find the entry, fall back to the indicator object's position */
235 if (entry_position > -1)
236 io_position = entry_position;
237 }
238
239 position.objposition = io_position;
240 position.entryposition = indicator_object_get_location(io, entry);
241 position.menupos = 0;
242 position.found = FALSE;
243
244 gtk_container_foreach(GTK_CONTAINER(menubar), place_in_menu_cb, &position);
245
246 gtk_menu_shell_insert(GTK_MENU_SHELL(menubar), menuitem, position.menupos);
217}247}
218248
219static void249static void
220something_shown (GtkWidget * widget, gpointer user_data)250something_shown (GtkWidget * widget, gpointer user_data)
221{251{
222 GtkWidget * menuitem = GTK_WIDGET(user_data);252 GtkWidget * menuitem = GTK_WIDGET(user_data);
223 gtk_widget_show(menuitem);253 gtk_widget_show(menuitem);
224}254}
225255
226static void256static void
227something_hidden (GtkWidget * widget, gpointer user_data)257something_hidden (GtkWidget * widget, gpointer user_data)
228{258{
229 GtkWidget * menuitem = GTK_WIDGET(user_data);259 GtkWidget * menuitem = GTK_WIDGET(user_data);
230 gtk_widget_hide(menuitem);260 gtk_widget_hide(menuitem);
231}261}
232262
233static void263static void
234sensitive_cb (GObject * obj, GParamSpec * pspec, gpointer user_data)264sensitive_cb (GObject * obj, GParamSpec * pspec, gpointer user_data)
235{265{
236 g_return_if_fail(GTK_IS_WIDGET(obj));266 g_return_if_fail(GTK_IS_WIDGET(obj));
237 g_return_if_fail(GTK_IS_WIDGET(user_data));267 g_return_if_fail(GTK_IS_WIDGET(user_data));
238268
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)));
240 return;270 return;
241}271}
242272
243static void273static void
244entry_activated (GtkWidget * widget, gpointer user_data)274entry_activated (GtkWidget * widget, gpointer user_data)
245{275{
246 g_return_if_fail(GTK_IS_WIDGET(widget));276 g_return_if_fail(GTK_IS_WIDGET(widget));
247 gpointer pio = g_object_get_data(G_OBJECT(widget), "indicator");277
248 g_return_if_fail(INDICATOR_IS_OBJECT(pio));278 IndicatorObject *io = g_object_get_data (G_OBJECT (widget), MENU_DATA_INDICATOR_OBJECT);
249 IndicatorObject * io = INDICATOR_OBJECT(pio);279 IndicatorObjectEntry *entry = g_object_get_data (G_OBJECT (widget), MENU_DATA_INDICATOR_ENTRY);
250280
251 return indicator_object_entry_activate(io, (IndicatorObjectEntry *)user_data, gtk_get_current_event_time());281 g_return_if_fail(INDICATOR_IS_OBJECT(io));
282
283 return indicator_object_entry_activate(io, entry, gtk_get_current_event_time());
284}
285
286static gboolean
287entry_secondary_activated (GtkWidget * widget, GdkEvent * event, gpointer user_data)
288{
289 g_return_val_if_fail(GTK_IS_WIDGET(widget), FALSE);
290
291 switch (event->type) {
292 case GDK_ENTER_NOTIFY:
293 g_object_set_data(G_OBJECT(widget), MENU_DATA_IN_MENUITEM, GINT_TO_POINTER(TRUE));
294 break;
295
296 case GDK_LEAVE_NOTIFY:
297 g_object_set_data(G_OBJECT(widget), MENU_DATA_IN_MENUITEM, GINT_TO_POINTER(FALSE));
298 g_object_set_data(G_OBJECT(widget), MENU_DATA_MENUITEM_PRESSED, GINT_TO_POINTER(FALSE));
299 break;
300
301 case GDK_BUTTON_PRESS:
302 if (event->button.button == 2) {
303 g_object_set_data(G_OBJECT(widget), MENU_DATA_MENUITEM_PRESSED, GINT_TO_POINTER(TRUE));
304 }
305 break;
306
307 case GDK_BUTTON_RELEASE:
308 if (event->button.button == 2) {
309 gboolean in_menuitem = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(widget), MENU_DATA_IN_MENUITEM));
310 gboolean menuitem_pressed = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(widget), MENU_DATA_MENUITEM_PRESSED));
311
312 if (in_menuitem && menuitem_pressed) {
313 g_object_set_data(G_OBJECT(widget), MENU_DATA_MENUITEM_PRESSED, GINT_TO_POINTER(FALSE));
314
315 IndicatorObject *io = g_object_get_data(G_OBJECT(widget), MENU_DATA_INDICATOR_OBJECT);
316 IndicatorObjectEntry *entry = g_object_get_data(G_OBJECT(widget), MENU_DATA_INDICATOR_ENTRY);
317
318 g_return_val_if_fail(INDICATOR_IS_OBJECT(io), FALSE);
319
320 g_signal_emit_by_name(io, INDICATOR_OBJECT_SIGNAL_SECONDARY_ACTIVATE,
321 entry, event->button.time);
322 }
323 }
324 break;
325 }
326
327 return FALSE;
252}328}
253329
254static gboolean330static gboolean
255entry_scrolled (GtkWidget *menuitem, GdkEventScroll *event, gpointer data)331entry_scrolled (GtkWidget *menuitem, GdkEventScroll *event, gpointer data)
256{332{
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);
258 IndicatorObjectEntry *entry = g_object_get_data (G_OBJECT (menuitem), MENU_DATA_INDICATOR_ENTRY);334
259335 IndicatorObject *io = g_object_get_data (G_OBJECT (menuitem), MENU_DATA_INDICATOR_OBJECT);
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);
261337
262 g_signal_emit_by_name (io, "scroll", 1, event->direction);338 g_return_val_if_fail(INDICATOR_IS_OBJECT(io), FALSE);
263 g_signal_emit_by_name (io, "scroll-entry", entry, 1, event->direction);339
264340 g_signal_emit_by_name (io, INDICATOR_OBJECT_SIGNAL_ENTRY_SCROLLED, entry, 1, event->direction);
265 return FALSE;341
342 return FALSE;
266}343}
267344
268static void345static void
269accessible_desc_update_cb (GtkWidget * widget, gpointer userdata)346accessible_desc_update_cb (GtkWidget * widget, gpointer userdata)
270{347{
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);
272349
273 if (data != userdata) {350 if (data != userdata) {
274 return;351 return;
275 }352 }
276353
277 IndicatorObjectEntry * entry = (IndicatorObjectEntry *)data;354 IndicatorObjectEntry * entry = (IndicatorObjectEntry *)data;
278 update_accessible_desc(entry, widget);355 update_accessible_desc(entry, widget);
279}356}
280357
281static void358static void
282accessible_desc_update (IndicatorObject * io, IndicatorObjectEntry * entry, GtkWidget * menubar)359accessible_desc_update (IndicatorObject * io, IndicatorObjectEntry * entry, GtkWidget * menubar)
283{360{
284 gtk_container_foreach(GTK_CONTAINER(menubar), accessible_desc_update_cb, entry);361 gtk_container_foreach(GTK_CONTAINER(menubar), accessible_desc_update_cb, entry);
285 return;362 return;
286}363}
287364
288static void365static void
289entry_added (IndicatorObject * io, IndicatorObjectEntry * entry, GtkWidget * menubar)366entry_added (IndicatorObject * io, IndicatorObjectEntry * entry, GtkWidget * menubar)
290{367{
291 g_debug("Signal: Entry Added");368 const char *indicator_name = (const gchar *)g_object_get_data(G_OBJECT(io), IO_DATA_NAME);
292 gboolean something_visible = FALSE;369 g_debug("Signal: Entry Added from %s", indicator_name);
293 gboolean something_sensitive = FALSE;370 gboolean something_visible = FALSE;
294371 gboolean something_sensitive = FALSE;
295 GtkWidget * menuitem = gtk_menu_item_new();372
296 GtkWidget * box = (packdirection == GTK_PACK_DIRECTION_LTR) ?373 GtkWidget * menuitem = gtk_menu_item_new();
297 gtk_hbox_new(FALSE, 3) : gtk_vbox_new(FALSE, 3);374 GtkWidget * box = (packdirection == GTK_PACK_DIRECTION_LTR) ?
298375 gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 3) : gtk_box_new(GTK_ORIENTATION_VERTICAL, 3);
299 g_object_set_data (G_OBJECT (menuitem), "indicator", io);376
300 g_object_set_data (G_OBJECT (menuitem), "box", box);377 g_object_set_data (G_OBJECT (menuitem), MENU_DATA_BOX, box);
301378 g_object_set_data(G_OBJECT(menuitem), MENU_DATA_INDICATOR_ENTRY, entry);
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);
303 g_signal_connect(G_OBJECT(menuitem), "scroll-event", G_CALLBACK(entry_scrolled), entry);380
304381 g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(entry_activated), NULL);
305 if (entry->image != NULL) {382 g_signal_connect(G_OBJECT(menuitem), "button-press-event", G_CALLBACK(entry_secondary_activated), NULL);
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);
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);
308 something_visible = TRUE;385 g_signal_connect(G_OBJECT(menuitem), "leave-notify-event", G_CALLBACK(entry_secondary_activated), NULL);
309 }386 g_signal_connect(G_OBJECT(menuitem), "scroll-event", G_CALLBACK(entry_scrolled), NULL);
310387
311 if (gtk_widget_get_sensitive(GTK_WIDGET(entry->image))) {388 if (entry->image != NULL) {
312 something_sensitive = TRUE;389 gtk_box_pack_start(GTK_BOX(box), GTK_WIDGET(entry->image), FALSE, FALSE, 1);
313 }390 if (gtk_widget_get_visible(GTK_WIDGET(entry->image))) {
314391 something_visible = TRUE;
315 g_signal_connect(G_OBJECT(entry->image), "show", G_CALLBACK(something_shown), menuitem);392 }
316 g_signal_connect(G_OBJECT(entry->image), "hide", G_CALLBACK(something_hidden), menuitem);393
317394 if (gtk_widget_get_sensitive(GTK_WIDGET(entry->image))) {
318 g_signal_connect(G_OBJECT(entry->image), "notify::sensitive", G_CALLBACK(sensitive_cb), menuitem);395 something_sensitive = TRUE;
319 }396 }
320 if (entry->label != NULL) {397
321 switch(packdirection) {398 g_signal_connect(G_OBJECT(entry->image), "show", G_CALLBACK(something_shown), menuitem);
322 case GTK_PACK_DIRECTION_LTR:399 g_signal_connect(G_OBJECT(entry->image), "hide", G_CALLBACK(something_hidden), menuitem);
323 gtk_label_set_angle(GTK_LABEL(entry->label), 0.0);400
324 break;401 g_signal_connect(G_OBJECT(entry->image), "notify::sensitive", G_CALLBACK(sensitive_cb), menuitem);
325 case GTK_PACK_DIRECTION_TTB:402 }
326 gtk_label_set_angle(GTK_LABEL(entry->label),403 if (entry->label != NULL) {
327 (orient == PANEL_APPLET_ORIENT_LEFT) ? 404 switch(packdirection) {
328 270.0 : 90.0);405 case GTK_PACK_DIRECTION_LTR:
329 break;406 gtk_label_set_angle(GTK_LABEL(entry->label), 0.0);
330 default:407 break;
331 break;408 case GTK_PACK_DIRECTION_TTB:
332 } 409 gtk_label_set_angle(GTK_LABEL(entry->label),
333 gtk_box_pack_start(GTK_BOX(box), GTK_WIDGET(entry->label), FALSE, FALSE, 1);410 (orient == PANEL_APPLET_ORIENT_LEFT) ?
334411 270.0 : 90.0);
335 if (gtk_widget_get_visible(GTK_WIDGET(entry->label))) {412 break;
336 something_visible = TRUE;413 default:
337 }414 break;
338415 }
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);
340 something_sensitive = TRUE;417
341 }418 if (gtk_widget_get_visible(GTK_WIDGET(entry->label))) {
342419 something_visible = TRUE;
343 g_signal_connect(G_OBJECT(entry->label), "show", G_CALLBACK(something_shown), menuitem);420 }
344 g_signal_connect(G_OBJECT(entry->label), "hide", G_CALLBACK(something_hidden), menuitem);421
345422 if (gtk_widget_get_sensitive(GTK_WIDGET(entry->label))) {
346 g_signal_connect(G_OBJECT(entry->label), "notify::sensitive", G_CALLBACK(sensitive_cb), menuitem);423 something_sensitive = TRUE;
347 }424 }
348 gtk_container_add(GTK_CONTAINER(menuitem), box);425
349 gtk_widget_show(box);426 g_signal_connect(G_OBJECT(entry->label), "show", G_CALLBACK(something_shown), menuitem);
350427 g_signal_connect(G_OBJECT(entry->label), "hide", G_CALLBACK(something_hidden), menuitem);
351 if (entry->menu != NULL) {428
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);
353 }430 }
354431 gtk_container_add(GTK_CONTAINER(menuitem), box);
355 incoming_position_t position;432 gtk_widget_show(box);
356 position.objposition = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(io), IO_DATA_ORDER_NUMBER));433
357 position.entryposition = indicator_object_get_location(io, entry);434 if (entry->menu != NULL) {
358 position.menupos = 0;435 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), GTK_WIDGET(entry->menu));
359 position.found = FALSE;436 }
360437
361 gtk_container_foreach(GTK_CONTAINER(menubar), place_in_menu, &position);438 place_in_menu(menubar, menuitem, io, entry);
362439
363 gtk_menu_shell_insert(GTK_MENU_SHELL(menubar), menuitem, position.menupos);440 if (something_visible) {
364441 if (entry->accessible_desc != NULL) {
365 if (something_visible) {442 update_accessible_desc(entry, menuitem);
366 if (entry->accessible_desc != NULL) {443 }
367 update_accessible_desc(entry, menuitem);444 gtk_widget_show(menuitem);
368 }445 }
369 gtk_widget_show(menuitem);446 gtk_widget_set_sensitive(menuitem, something_sensitive);
370 }447
371 gtk_widget_set_sensitive(menuitem, something_sensitive);448 return;
372
373 g_object_set_data(G_OBJECT(menuitem), MENU_DATA_INDICATOR_ENTRY, entry);
374 g_object_set_data(G_OBJECT(menuitem), MENU_DATA_INDICATOR_OBJECT, io);
375
376 return;
377}449}
378450
379static void451static void
380entry_removed_cb (GtkWidget * widget, gpointer userdata)452entry_removed_cb (GtkWidget * widget, gpointer userdata)
381{453{
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);
383455
384 if (data != userdata) {456 if (data != userdata) {
385 return;457 return;
386 }458 }
387459
388 IndicatorObjectEntry * entry = (IndicatorObjectEntry *)data;460 IndicatorObjectEntry * entry = (IndicatorObjectEntry *)data;
389 if (entry->label != NULL) {461 if (entry->label != NULL) {
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);
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);
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);
393 }465 }
394 if (entry->image != NULL) {466 if (entry->image != NULL) {
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);
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);
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);
398 }470 }
399471
400 gtk_widget_destroy(widget);472 gtk_widget_destroy(widget);
401 return;473 return;
402}474}
403475
404static void476static void
405entry_removed (IndicatorObject * io G_GNUC_UNUSED, IndicatorObjectEntry * entry,477entry_removed (IndicatorObject * io G_GNUC_UNUSED, IndicatorObjectEntry * entry,
406 gpointer user_data)478 gpointer user_data)
407{479{
408 g_debug("Signal: Entry Removed");480 g_debug("Signal: Entry Removed");
409481
410 gtk_container_foreach(GTK_CONTAINER(user_data), entry_removed_cb, entry);482 gtk_container_foreach(GTK_CONTAINER(user_data), entry_removed_cb, entry);
411483
412 return;484 return;
413}485}
414486
415static void487static void
416entry_moved_find_cb (GtkWidget * widget, gpointer userdata)488entry_moved_find_cb (GtkWidget * widget, gpointer userdata)
417{489{
418 gpointer * array = (gpointer *)userdata;490 gpointer * array = (gpointer *)userdata;
419 if (array[1] != NULL) {491 if (array[1] != NULL) {
420 return;492 return;
421 }493 }
422494
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);
424496
425 if (data != array[0]) {497 if (data != array[0]) {
426 return;498 return;
427 }499 }
428500
429 array[1] = widget;501 array[1] = widget;
430 return;502 return;
431}503}
432504
433/* Gets called when an entry for an object was moved. */505/* Gets called when an entry for an object was moved. */
@@ -435,147 +507,135 @@
435entry_moved (IndicatorObject * io, IndicatorObjectEntry * entry,507entry_moved (IndicatorObject * io, IndicatorObjectEntry * entry,
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)
437{509{
438 GtkWidget * menubar = GTK_WIDGET(user_data);510 GtkWidget * menubar = GTK_WIDGET(user_data);
439511
440 gpointer array[2];512 gpointer array[2];
441 array[0] = entry;513 array[0] = entry;
442 array[1] = NULL;514 array[1] = NULL;
443515
444 gtk_container_foreach(GTK_CONTAINER(menubar), entry_moved_find_cb, array);516 gtk_container_foreach(GTK_CONTAINER(menubar), entry_moved_find_cb, array);
445 if (array[1] == NULL) {517 if (array[1] == NULL) {
446 g_warning("Moving an entry that isn't in our menus.");518 g_warning("Moving an entry that isn't in our menus.");
447 return;519 return;
448 }520 }
449521
450 GtkWidget * mi = GTK_WIDGET(array[1]);522 GtkWidget * mi = GTK_WIDGET(array[1]);
451 g_object_ref(G_OBJECT(mi));523 g_object_ref(G_OBJECT(mi));
452 gtk_container_remove(GTK_CONTAINER(menubar), mi);524 gtk_container_remove(GTK_CONTAINER(menubar), mi);
453525 place_in_menu(menubar, mi, io, entry);
454 incoming_position_t position;526 g_object_unref(G_OBJECT(mi));
455 position.objposition = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(io), IO_DATA_ORDER_NUMBER));527
456 position.entryposition = indicator_object_get_location(io, entry);528 return;
457 position.menupos = 0;
458 position.found = FALSE;
459
460 gtk_container_foreach(GTK_CONTAINER(menubar), place_in_menu, &position);
461
462 gtk_menu_shell_insert(GTK_MENU_SHELL(menubar), mi, position.menupos);
463 g_object_unref(G_OBJECT(mi));
464
465 return;
466}529}
467530
468static void531static void
469menu_show (IndicatorObject * io, IndicatorObjectEntry * entry,532menu_show (IndicatorObject * io, IndicatorObjectEntry * entry,
470 guint32 timestamp, gpointer user_data)533 guint32 timestamp, gpointer user_data)
471{534{
472 GtkWidget * menubar = GTK_WIDGET(user_data);535 GtkWidget * menubar = GTK_WIDGET(user_data);
473536
474 if (entry == NULL) {537 if (entry == NULL) {
475 /* Close any open menus instead of opening one */538 /* Close any open menus instead of opening one */
476 GList * entries = indicator_object_get_entries(io);539 GList * entries = indicator_object_get_entries(io);
477 GList * entry = NULL;540 GList * entry = NULL;
478 for (entry = entries; entry != NULL; entry = g_list_next(entry)) {541 for (entry = entries; entry != NULL; entry = g_list_next(entry)) {
479 IndicatorObjectEntry * entrydata = (IndicatorObjectEntry *)entry->data;542 IndicatorObjectEntry * entrydata = (IndicatorObjectEntry *)entry->data;
480 gtk_menu_popdown(entrydata->menu);543 gtk_menu_popdown(entrydata->menu);
481 }544 }
482 g_list_free(entries);545 g_list_free(entries);
483546
484 /* And tell the menubar to exit activation mode too */547 /* And tell the menubar to exit activation mode too */
485 gtk_menu_shell_cancel(GTK_MENU_SHELL(menubar));548 gtk_menu_shell_cancel(GTK_MENU_SHELL(menubar));
486 return;549 return;
487 }550 }
488551
489 // TODO: do something sensible here552 // TODO: do something sensible here
490}553}
491554
492static void555static void
493update_accessible_desc(IndicatorObjectEntry * entry, GtkWidget * menuitem)556update_accessible_desc(IndicatorObjectEntry * entry, GtkWidget * menuitem)
494{557{
495 /* FIXME: We need to deal with the use case where the contents of the558 /* FIXME: We need to deal with the use case where the contents of the
496 label overrides what is found in the atk object's name, or at least559 label overrides what is found in the atk object's name, or at least
497 orca speaks the label instead of the atk object name.560 orca speaks the label instead of the atk object name.
498 */561 */
499 AtkObject * menuitem_obj = gtk_widget_get_accessible(menuitem);562 AtkObject * menuitem_obj = gtk_widget_get_accessible(menuitem);
500 if (menuitem_obj == NULL) {563 if (menuitem_obj == NULL) {
501 /* Should there be an error printed here? */564 /* Should there be an error printed here? */
502 return;565 return;
503 }566 }
504567
505 if (entry->accessible_desc != NULL) {568 if (entry->accessible_desc != NULL) {
506 atk_object_set_name(menuitem_obj, entry->accessible_desc);569 atk_object_set_name(menuitem_obj, entry->accessible_desc);
507 } else {570 } else {
508 atk_object_set_name(menuitem_obj, "");571 atk_object_set_name(menuitem_obj, "");
509 }572 }
510 return;573 return;
511}574}
512575
513576
514static gboolean577static gboolean
515load_module (const gchar * name, GtkWidget * menubar)578load_module (const gchar * name, GtkWidget * menubar)
516{579{
517 g_debug("Looking at Module: %s", name);580 g_debug("Looking at Module: %s", name);
518 g_return_val_if_fail(name != NULL, FALSE);581 g_return_val_if_fail(name != NULL, FALSE);
519582
520 if (!g_str_has_suffix(name, G_MODULE_SUFFIX)) {583 if (!g_str_has_suffix(name, G_MODULE_SUFFIX)) {
521 return FALSE;584 return FALSE;
522 }585 }
523586
524 g_debug("Loading Module: %s", name);587 g_debug("Loading Module: %s", name);
525588
526 /* Build the object for the module */589 /* Build the object for the module */
527 gchar * fullpath = g_build_filename(INDICATOR_DIR, name, NULL);590 gchar * fullpath = g_build_filename(INDICATOR_DIR, name, NULL);
528 IndicatorObject * io = indicator_object_new_from_file(fullpath);591 IndicatorObject * io = indicator_object_new_from_file(fullpath);
529 g_free(fullpath);592 g_free(fullpath);
530593
531 /* Set the environment it's in */594 /* Set the environment it's in */
532 indicator_object_set_environment(io, (const GStrv)indicator_env);595 indicator_object_set_environment(io, (const GStrv)indicator_env);
533596
534 /* Attach the 'name' to the object */597 /* Attach the 'name' to the object */
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);
536599 g_object_set_data(G_OBJECT(io), IO_DATA_ORDER_NUMBER, GINT_TO_POINTER(name2order(name, NULL)));
537 /* Connect to its signals */600
538 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED, G_CALLBACK(entry_added), menubar);601 /* Connect to its signals */
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);
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);
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);
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);
543606 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ACCESSIBLE_DESC_UPDATE, G_CALLBACK(accessible_desc_update), menubar);
544 /* Work on the entries */607
545 GList * entries = indicator_object_get_entries(io);608 /* Work on the entries */
546 GList * entry = NULL;609 GList * entries = indicator_object_get_entries(io);
547610 GList * entry = NULL;
548 for (entry = entries; entry != NULL; entry = g_list_next(entry)) {611
549 IndicatorObjectEntry * entrydata = (IndicatorObjectEntry *)entry->data;612 for (entry = entries; entry != NULL; entry = g_list_next(entry)) {
550 entry_added(io, entrydata, menubar);613 IndicatorObjectEntry * entrydata = (IndicatorObjectEntry *)entry->data;
551 }614 entry_added(io, entrydata, menubar);
552615 }
553 g_list_free(entries);616
554617 g_list_free(entries);
555 return TRUE;618
619 return TRUE;
556}620}
557621
558static void622static void
559hotkey_filter (char * keystring G_GNUC_UNUSED, gpointer data)623hotkey_filter (char * keystring, gpointer data)
560{624{
561 g_return_if_fail(GTK_IS_MENU_SHELL(data));625 g_return_if_fail(GTK_IS_MENU_SHELL(data));
562626
563 /* Oh, wow, it's us! */627 g_debug ("Hotkey: %s", keystring);
564 GList * children = gtk_container_get_children(GTK_CONTAINER(data));628
565 if (children == NULL) {629 /* Oh, wow, it's us! */
566 g_debug("Menubar has no children");630 GList * children = gtk_container_get_children(GTK_CONTAINER(data));
567 return;631 if (children == NULL) {
568 }632 g_debug("Menubar has no children");
569633 return;
570 if (!GTK_MENU_SHELL(data)->active) {634 }
571 gtk_grab_add (GTK_WIDGET(data));635
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));
573 GTK_MENU_SHELL(data)->active = TRUE;637 g_list_free(children);
574 }638 return;
575
576 gtk_menu_shell_select_item(GTK_MENU_SHELL(data), GTK_WIDGET(g_list_last(children)->data));
577 g_list_free(children);
578 return;
579}639}
580640
581static gboolean641static gboolean
@@ -583,35 +643,23 @@
583 GdkEventButton *event,643 GdkEventButton *event,
584 gpointer data G_GNUC_UNUSED)644 gpointer data G_GNUC_UNUSED)
585{645{
586 if (event->button != 1) {646 if (event->button != 1) {
587 g_signal_stop_emission_by_name(widget, "button-press-event");647 g_signal_stop_emission_by_name(widget, "button-press-event");
588 }648 }
589649
590 return FALSE;650 return FALSE;
591}
592
593static gboolean
594menubar_on_expose (GtkWidget * widget,
595 GdkEventExpose *event G_GNUC_UNUSED,
596 GtkWidget * menubar)
597{
598 if (GTK_WIDGET_HAS_FOCUS(menubar))
599 gtk_paint_focus(widget->style, widget->window, GTK_WIDGET_STATE(menubar),
600 NULL, widget, "menubar-applet", 0, 0, -1, -1);
601
602 return FALSE;
603}651}
604652
605static void653static void
606about_cb (GtkAction *action G_GNUC_UNUSED,654about_cb (GtkAction *action G_GNUC_UNUSED,
607 gpointer data G_GNUC_UNUSED)655 gpointer data G_GNUC_UNUSED)
608{656{
609 static const gchar *authors[] = {657 static const gchar *authors[] = {
610 "Ted Gould <ted@canonical.com>",658 "Ted Gould <ted@canonical.com>",
611 NULL659 NULL
612 };660 };
613661
614 static gchar *license[] = {662 static gchar *license[] = {
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 "
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 "
617 "by the Free Software Foundation."),665 "by the Free Software Foundation."),
@@ -621,103 +669,103 @@
621 "PURPOSE. See the GNU General Public License for more details."),669 "PURPOSE. See the GNU General Public License for more details."),
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 "
623 "with this program. If not, see <http://www.gnu.org/licenses/>."),671 "with this program. If not, see <http://www.gnu.org/licenses/>."),
624 NULL672 NULL
625 };673 };
626 gchar *license_i18n;674 gchar *license_i18n;
627675
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);
629677
630 gtk_show_about_dialog(NULL,678 gtk_show_about_dialog(NULL,
631 "version", VERSION,679 "version", VERSION,
632 "copyright", "Copyright \xc2\xa9 2009-2010 Canonical, Ltd.",680 "copyright", "Copyright \xc2\xa9 2009-2010 Canonical, Ltd.",
633#ifdef INDICATOR_APPLET_SESSION681#ifdef INDICATOR_APPLET_SESSION
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."),
635#else683#else
636#ifdef INDICATOR_APPLET_APPMENU684#ifdef INDICATOR_APPLET_APPMENU
637 "comments", _("An applet to hold your application menus."),685 "comments", _("An applet to hold your application menus."),
638#endif686#endif
639 "comments", _("An applet to hold all of the system indicators."),687 "comments", _("An applet to hold all of the system indicators."),
640#endif688#endif
641 "authors", authors,689 "authors", authors,
642 "license", license_i18n,690 "license", license_i18n,
643 "wrap-license", TRUE,691 "wrap-license", TRUE,
644 "translator-credits", _("translator-credits"),692 "translator-credits", _("translator-credits"),
645 "logo-icon-name", "indicator-applet",693 "logo-icon-name", "indicator-applet",
646 "icon-name", "indicator-applet",694 "icon-name", "indicator-applet",
647 "website", "http://launchpad.net/indicator-applet",695 "website", "http://launchpad.net/indicator-applet",
648 "website-label", _("Indicator Applet Website"),696 "website-label", _("Indicator Applet Website"),
649 NULL697 NULL
650 );698 );
651699
652 g_free (license_i18n);700 g_free (license_i18n);
653701
654 return;702 return;
655}703}
656704
657static gboolean705static gboolean
658swap_orient_cb (GtkWidget *item, gpointer data)706swap_orient_cb (GtkWidget *item, gpointer data)
659{707{
660 GtkWidget *from = (GtkWidget *) data;708 GtkWidget *from = (GtkWidget *) data;
661 GtkWidget *to = (GtkWidget *) g_object_get_data(G_OBJECT(from), "to");709 GtkWidget *to = (GtkWidget *) g_object_get_data(G_OBJECT(from), "to");
662 g_object_ref(G_OBJECT(item));710 g_object_ref(G_OBJECT(item));
663 gtk_container_remove(GTK_CONTAINER(from), item);711 gtk_container_remove(GTK_CONTAINER(from), item);
664 if (GTK_IS_LABEL(item)) {712 if (GTK_IS_LABEL(item)) {
665 switch(packdirection) {713 switch(packdirection) {
666 case GTK_PACK_DIRECTION_LTR:714 case GTK_PACK_DIRECTION_LTR:
667 gtk_label_set_angle(GTK_LABEL(item), 0.0);715 gtk_label_set_angle(GTK_LABEL(item), 0.0);
668 break;716 break;
669 case GTK_PACK_DIRECTION_TTB:717 case GTK_PACK_DIRECTION_TTB:
670 gtk_label_set_angle(GTK_LABEL(item),718 gtk_label_set_angle(GTK_LABEL(item),
671 (orient == PANEL_APPLET_ORIENT_LEFT) ? 719 (orient == PANEL_APPLET_ORIENT_LEFT) ?
672 270.0 : 90.0);720 270.0 : 90.0);
673 break;721 break;
674 default:722 default:
675 break;723 break;
676 } 724 }
677 }725 }
678 gtk_box_pack_start(GTK_BOX(to), item, FALSE, FALSE, 0);726 gtk_box_pack_start(GTK_BOX(to), item, FALSE, FALSE, 0);
679 return TRUE;727 return TRUE;
680}728}
681729
682static gboolean730static gboolean
683reorient_box_cb (GtkWidget *menuitem, gpointer data)731reorient_box_cb (GtkWidget *menuitem, gpointer data)
684{732{
685 GtkWidget *from = g_object_get_data(G_OBJECT(menuitem), "box");733 GtkWidget *from = g_object_get_data(G_OBJECT(menuitem), MENU_DATA_BOX);
686 GtkWidget *to = (packdirection == GTK_PACK_DIRECTION_LTR) ?734 GtkWidget *to = (packdirection == GTK_PACK_DIRECTION_LTR) ?
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);
688 g_object_set_data(G_OBJECT(from), "to", to);736 g_object_set_data(G_OBJECT(from), "to", to);
689 gtk_container_foreach(GTK_CONTAINER(from), (GtkCallback)swap_orient_cb,737 gtk_container_foreach(GTK_CONTAINER(from), (GtkCallback)swap_orient_cb,
690 from);738 from);
691 gtk_container_remove(GTK_CONTAINER(menuitem), from);739 gtk_container_remove(GTK_CONTAINER(menuitem), from);
692 gtk_container_add(GTK_CONTAINER(menuitem), to);740 gtk_container_add(GTK_CONTAINER(menuitem), to);
693 g_object_set_data(G_OBJECT(menuitem), "box", to);741 g_object_set_data(G_OBJECT(menuitem), MENU_DATA_BOX, to);
694 gtk_widget_show_all(menuitem);742 gtk_widget_show_all(menuitem);
695 return TRUE;743 return TRUE;
696}744}
697745
698static gboolean746static gboolean
699panelapplet_reorient_cb (GtkWidget *applet, PanelAppletOrient neworient,747panelapplet_reorient_cb (GtkWidget *applet, PanelAppletOrient neworient,
700 gpointer data)748 gpointer data)
701{749{
702 GtkWidget *menubar = (GtkWidget *)data;750 GtkWidget *menubar = (GtkWidget *)data;
703 if ((((neworient == PANEL_APPLET_ORIENT_UP) || 751 if ((((neworient == PANEL_APPLET_ORIENT_UP) ||
704 (neworient == PANEL_APPLET_ORIENT_DOWN)) && 752 (neworient == PANEL_APPLET_ORIENT_DOWN)) &&
705 ((orient == PANEL_APPLET_ORIENT_LEFT) || 753 ((orient == PANEL_APPLET_ORIENT_LEFT) ||
706 (orient == PANEL_APPLET_ORIENT_RIGHT))) || 754 (orient == PANEL_APPLET_ORIENT_RIGHT))) ||
707 (((neworient == PANEL_APPLET_ORIENT_LEFT) || 755 (((neworient == PANEL_APPLET_ORIENT_LEFT) ||
708 (neworient == PANEL_APPLET_ORIENT_RIGHT)) && 756 (neworient == PANEL_APPLET_ORIENT_RIGHT)) &&
709 ((orient == PANEL_APPLET_ORIENT_UP) ||757 ((orient == PANEL_APPLET_ORIENT_UP) ||
710 (orient == PANEL_APPLET_ORIENT_DOWN)))) {758 (orient == PANEL_APPLET_ORIENT_DOWN)))) {
711 packdirection = (packdirection == GTK_PACK_DIRECTION_LTR) ?759 packdirection = (packdirection == GTK_PACK_DIRECTION_LTR) ?
712 GTK_PACK_DIRECTION_TTB : GTK_PACK_DIRECTION_LTR;760 GTK_PACK_DIRECTION_TTB : GTK_PACK_DIRECTION_LTR;
713 gtk_menu_bar_set_pack_direction(GTK_MENU_BAR(menubar),761 gtk_menu_bar_set_pack_direction(GTK_MENU_BAR(menubar),
714 packdirection);762 packdirection);
715 orient = neworient;763 orient = neworient;
716 gtk_container_foreach(GTK_CONTAINER(menubar),764 gtk_container_foreach(GTK_CONTAINER(menubar),
717 (GtkCallback)reorient_box_cb, NULL);765 (GtkCallback)reorient_box_cb, NULL);
718 }766 }
719 orient = neworient;767 orient = neworient;
720 return FALSE;768 return FALSE;
721}769}
722770
723#ifdef N_771#ifdef N_
@@ -726,277 +774,205 @@
726#define N_(x) x774#define N_(x) x
727775
728static void776static void
729log_to_file_cb (GObject * source_obj G_GNUC_UNUSED,777log_to_file (const gchar * domain,
730 GAsyncResult * result G_GNUC_UNUSED, gpointer user_data)778 GLogLevelFlags level,
731{
732 g_free(user_data);
733 return;
734}
735
736static void
737log_to_file (const gchar * domain G_GNUC_UNUSED,
738 GLogLevelFlags level G_GNUC_UNUSED,
739 const gchar * message,779 const gchar * message,
740 gpointer data G_GNUC_UNUSED)780 gpointer data)
741{781{
742 if (log_file == NULL) {782 if (log_file == NULL) {
743 GError * error = NULL;783 gchar *path;
744 gchar * filename = g_build_filename(g_get_user_cache_dir(), LOG_FILE_NAME, NULL);784
745 GFile * file = g_file_new_for_path(filename);785 g_mkdir_with_parents(g_get_user_cache_dir(), 0755);
746 g_free(filename);786 path = g_build_filename(g_get_user_cache_dir(), LOG_FILE_NAME, NULL);
747787
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");
749 GFile * cachedir = g_file_new_for_path(g_get_user_cache_dir());789
750 g_file_make_directory_with_parents(cachedir, NULL, &error);790 g_free(path);
751791 }
752 if (error != NULL) {792
753 g_error("Unable to make directory '%s' for log file: %s", g_get_user_cache_dir(), error->message);793 if(log_file) {
754 return;794 const gchar *prefix;
755 }795
756 }796 switch(level & G_LOG_LEVEL_MASK) {
757797 case G_LOG_LEVEL_ERROR:
758 g_file_delete(file, NULL, NULL);798 prefix = "ERROR:";
759799 break;
760 GFileIOStream * io = g_file_create_readwrite(file,800 case G_LOG_LEVEL_CRITICAL:
761 G_FILE_CREATE_REPLACE_DESTINATION, /* flags */801 prefix = "CRITICAL:";
762 NULL, /* cancelable */802 break;
763 &error); /* error */803 case G_LOG_LEVEL_WARNING:
764 if (error != NULL) {804 prefix = "WARNING:";
765 g_error("Unable to replace file: %s", error->message);805 break;
766 return;806 case G_LOG_LEVEL_MESSAGE:
767 }807 prefix = "MESSAGE:";
768808 break;
769 log_file = g_io_stream_get_output_stream(G_IO_STREAM(io));809 case G_LOG_LEVEL_INFO:
770 }810 prefix = "INFO:";
771811 break;
772 gchar * outputstring = g_strdup_printf("%s\n", message);812 case G_LOG_LEVEL_DEBUG:
773 g_output_stream_write_async(log_file,813 prefix = "DEBUG:";
774 outputstring, /* data */814 break;
775 strlen(outputstring), /* length */815 default:
776 G_PRIORITY_LOW, /* priority */816 prefix = "LOG:";
777 NULL, /* cancelable */817 break;
778 log_to_file_cb, /* callback */818 }
779 outputstring); /* data */819
780820 fprintf(log_file, "%s %s - %s\n", prefix, domain, message);
781 return;821 fflush(log_file);
822 }
823
824 g_log_default_handler(domain, level, message, data);
825
826 return;
782}827}
783828
784static gboolean829static gboolean
785applet_fill_cb (PanelApplet * applet, const gchar * iid G_GNUC_UNUSED,830applet_fill_cb (PanelApplet * applet, const gchar * iid G_GNUC_UNUSED,
786 gpointer data G_GNUC_UNUSED)831 gpointer data G_GNUC_UNUSED)
787{832{
788 static const GtkActionEntry menu_actions[] = {833 static const GtkActionEntry menu_actions[] = {
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)}
790 };835 };
791 static const gchar *menu_xml = "<menuitem name=\"About\" action=\"About\"/>";836 static const gchar *menu_xml = "<menuitem name=\"About\" action=\"About\"/>";
792837
793 static gboolean first_time = FALSE;838 static gboolean first_time = FALSE;
794 GtkWidget *menubar;839 GtkWidget *menubar;
795 gint indicators_loaded = 0;840 gint indicators_loaded = 0;
796 GtkActionGroup *action_group;841 GtkActionGroup *action_group;
797842 GError *error = NULL;
798#ifdef INDICATOR_APPLET_SESSION843
799 /* check if we are running stracciatella session */844#ifdef INDICATOR_APPLET_SESSION
800 if (g_strcmp0(g_getenv("GDMSESSION"), "gnome-stracciatella") == 0) {845 /* check if we are running stracciatella session */
801 g_debug("Running stracciatella GNOME session, disabling myself");846 if (g_strcmp0(g_getenv("GDMSESSION"), "gnome-stracciatella") == 0) {
802 return TRUE;847 g_debug("Running stracciatella GNOME session, disabling myself");
803 }848 return TRUE;
804#endif849 }
805850#endif
806 if (!first_time)851
807 {852 if (!first_time)
808 first_time = TRUE;853 {
809#ifdef INDICATOR_APPLET854 first_time = TRUE;
810 g_set_application_name(_("Indicator Applet"));855#ifdef INDICATOR_APPLET
811#endif856 g_set_application_name(_("Indicator Applet"));
812#ifdef INDICATOR_APPLET_SESSION857#endif
813 g_set_application_name(_("Indicator Applet Session"));858#ifdef INDICATOR_APPLET_SESSION
814#endif859 g_set_application_name(_("Indicator Applet Session"));
815#ifdef INDICATOR_APPLET_COMPLETE860#endif
816 g_set_application_name(_("Indicator Applet Complete"));861#ifdef INDICATOR_APPLET_COMPLETE
817#endif862 g_set_application_name(_("Indicator Applet Complete"));
818#ifdef INDICATOR_APPLET_APPMENU863#endif
819 g_set_application_name(_("Indicator Applet Application Menu"));864#ifdef INDICATOR_APPLET_APPMENU
820#endif865 g_set_application_name(_("Indicator Applet Application Menu"));
821 866#endif
822 g_log_set_default_handler(log_to_file, NULL);867
823868 g_log_set_default_handler(log_to_file, NULL);
824 tomboy_keybinder_init();869
825 }870 tomboy_keybinder_init();
826871 }
827 /* Set panel options */872
828 gtk_container_set_border_width(GTK_CONTAINER (applet), 0);873 /* Set panel options */
829 panel_applet_set_flags(applet, PANEL_APPLET_EXPAND_MINOR);874 gtk_container_set_border_width(GTK_CONTAINER (applet), 0);
830 menubar = gtk_menu_bar_new();875 panel_applet_set_flags(applet, PANEL_APPLET_EXPAND_MINOR);
831 action_group = gtk_action_group_new ("Indicator Applet Actions");876 menubar = gtk_menu_bar_new();
832 gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE);877 action_group = gtk_action_group_new ("Indicator Applet Actions");
833 gtk_action_group_add_actions (action_group, menu_actions,878 gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE);
834 G_N_ELEMENTS (menu_actions),879 gtk_action_group_add_actions (action_group, menu_actions,
835 menubar);880 G_N_ELEMENTS (menu_actions),
836 panel_applet_setup_menu(applet, menu_xml, action_group);881 menubar);
837 g_object_unref(action_group);882 panel_applet_setup_menu(applet, menu_xml, action_group);
838#ifdef INDICATOR_APPLET883 g_object_unref(action_group);
839 atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (applet)),884#ifdef INDICATOR_APPLET
840 "indicator-applet");885 atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (applet)),
841#endif886 "indicator-applet");
842#ifdef INDICATOR_APPLET_SESSION887#endif
843 atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (applet)),888#ifdef INDICATOR_APPLET_SESSION
844 "indicator-applet-session");889 atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (applet)),
845#endif890 "indicator-applet-session");
846#ifdef INDICATOR_APPLET_COMPLETE891#endif
847 atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (applet)),892#ifdef INDICATOR_APPLET_COMPLETE
848 "indicator-applet-complete");893 atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (applet)),
849#endif894 "indicator-applet-complete");
850#ifdef INDICATOR_APPLET_APPMENU895#endif
851 atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (applet)),896#ifdef INDICATOR_APPLET_APPMENU
852 "indicator-applet-appmenu");897 atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (applet)),
853#endif898 "indicator-applet-appmenu");
854899#endif
855 /* Init some theme/icon stuff */900
856 gtk_icon_theme_append_search_path(gtk_icon_theme_get_default(),901 /* Init some theme/icon stuff */
857 INDICATOR_ICONS_DIR);902 gtk_icon_theme_append_search_path(gtk_icon_theme_get_default(),
858 /* g_debug("Icons directory: %s", INDICATOR_ICONS_DIR); */903 INDICATOR_ICONS_DIR);
859 gtk_rc_parse_string (904 g_debug("Icons directory: %s", INDICATOR_ICONS_DIR);
860 "style \"indicator-applet-style\"\n"905
861 "{\n"906 gtk_widget_set_name(GTK_WIDGET (applet), "fast-user-switch-applet");
862 " GtkMenuBar::shadow-type = none\n"907
863 " GtkMenuBar::internal-padding = 0\n"908 /* Build menubar */
864 " GtkWidget::focus-line-width = 0\n"909 orient = (panel_applet_get_orient(applet));
865 " GtkWidget::focus-padding = 0\n"910 packdirection = ((orient == PANEL_APPLET_ORIENT_UP) ||
866 "}\n"911 (orient == PANEL_APPLET_ORIENT_DOWN)) ?
867 "style \"indicator-applet-menubar-style\"\n"912 GTK_PACK_DIRECTION_LTR : GTK_PACK_DIRECTION_TTB;
868 "{\n"913 gtk_menu_bar_set_pack_direction(GTK_MENU_BAR(menubar),
869 " GtkMenuBar::shadow-type = none\n"914 packdirection);
870 " GtkMenuBar::internal-padding = 0\n"915 gtk_widget_set_can_focus (GTK_WIDGET (menubar), TRUE);
871 " GtkWidget::focus-line-width = 0\n"916 gtk_widget_set_name(GTK_WIDGET (menubar), "fast-user-switch-menubar");
872 " GtkWidget::focus-padding = 0\n"917 g_signal_connect(menubar, "button-press-event", G_CALLBACK(menubar_press), NULL);
873 " GtkMenuItem::horizontal-padding = 0\n"918 g_signal_connect(applet, "change-orient",
874 "}\n"919 G_CALLBACK(panelapplet_reorient_cb), menubar);
875 "style \"indicator-applet-menuitem-style\"\n"920 gtk_container_set_border_width(GTK_CONTAINER(menubar), 0);
876 "{\n"921
877 " GtkWidget::focus-line-width = 0\n"922 /* Add in filter func */
878 " GtkWidget::focus-padding = 0\n"923 tomboy_keybinder_bind(hotkey_keycode, hotkey_filter, menubar);
879 " GtkMenuItem::horizontal-padding = 0\n"924
880 "}\n"925 /* load 'em */
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))) {
882 "widget \"*.fast-user-switch-menuitem\" style \"indicator-applet-menuitem-style\""927 GDir * dir = g_dir_open(INDICATOR_DIR, 0, NULL);
883 "widget \"*.fast-user-switch-menubar\" style \"indicator-applet-menubar-style\"");928
884 //gtk_widget_set_name(GTK_WIDGET (applet), "indicator-applet-menubar");929 const gchar * name;
885 gtk_widget_set_name(GTK_WIDGET (applet), "fast-user-switch-applet");930 while ((name = g_dir_read_name(dir)) != NULL) {
886931#ifdef INDICATOR_APPLET_APPMENU
887 /* Build menubar */932 if (g_strcmp0(name, "libappmenu.so")) {
888 orient = (panel_applet_get_orient(applet));933 continue;
889 packdirection = ((orient == PANEL_APPLET_ORIENT_UP) ||934 }
890 (orient == PANEL_APPLET_ORIENT_DOWN)) ?
891 GTK_PACK_DIRECTION_LTR : GTK_PACK_DIRECTION_TTB;
892 gtk_menu_bar_set_pack_direction(GTK_MENU_BAR(menubar),
893 packdirection);
894 GTK_WIDGET_SET_FLAGS (menubar, GTK_WIDGET_FLAGS(menubar) | GTK_CAN_FOCUS);
895 gtk_widget_set_name(GTK_WIDGET (menubar), "fast-user-switch-menubar");
896 g_signal_connect(menubar, "button-press-event", G_CALLBACK(menubar_press), NULL);
897 g_signal_connect_after(menubar, "expose-event", G_CALLBACK(menubar_on_expose), menubar);
898 g_signal_connect(applet, "change-orient",
899 G_CALLBACK(panelapplet_reorient_cb), menubar);
900 gtk_container_set_border_width(GTK_CONTAINER(menubar), 0);
901
902 /* Add in filter func */
903 tomboy_keybinder_bind(hotkey_keycode, hotkey_filter, menubar);
904
905 /* load 'em */
906 if (g_file_test(INDICATOR_DIR, (G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR))) {
907 GDir * dir = g_dir_open(INDICATOR_DIR, 0, NULL);
908
909 const gchar * name;
910 while ((name = g_dir_read_name(dir)) != NULL) {
911#ifdef INDICATOR_APPLET_APPMENU
912 if (g_strcmp0(name, "libappmenu.so")) {
913 continue;
914 }
915#else935#else
916 if (!g_strcmp0(name, "libappmenu.so")) {936 if (!g_strcmp0(name, "libappmenu.so")) {
917 continue;937 continue;
918 }938 }
919#endif939#endif
920#ifdef INDICATOR_APPLET940#ifdef INDICATOR_APPLET
921 if (!g_strcmp0(name, "libsession.so")) {941 if (!g_strcmp0(name, "libsession.so")) {
922 continue;942 continue;
923 }943 }
924 if (!g_strcmp0(name, "libme.so")) {944 if (!g_strcmp0(name, "libme.so")) {
925 continue;945 continue;
926 }946 }
927 if (!g_strcmp0(name, "libdatetime.so")) {947 if (!g_strcmp0(name, "libdatetime.so")) {
928 continue;948 continue;
929 }949 }
930#endif950#endif
931#ifdef INDICATOR_APPLET_SESSION951#ifdef INDICATOR_APPLET_SESSION
932 if (g_strcmp0(name, "libsession.so") && g_strcmp0(name, "libme.so")) {952 if (g_strcmp0(name, "libsession.so") && g_strcmp0(name, "libme.so")) {
933 continue;953 continue;
934 }954 }
935#endif955#endif
936 if (load_module(name, menubar)) {956 if (load_module(name, menubar)) {
937 indicators_loaded++;957 indicators_loaded++;
938 }958 }
939 }959 }
940 g_dir_close (dir);960 g_dir_close (dir);
941 }961 }
942962
943 if (indicators_loaded == 0) {963 if (indicators_loaded == 0) {
944 /* A label to allow for click through */964 /* A label to allow for click through */
945 GtkWidget * item = gtk_label_new(_("No Indicators"));965 GtkWidget * item = gtk_label_new(_("No Indicators"));
946 gtk_container_add(GTK_CONTAINER(applet), item);966 gtk_container_add(GTK_CONTAINER(applet), item);
947 gtk_widget_show(item);967 gtk_widget_show(item);
948 } else {968 } else {
949 gtk_container_add(GTK_CONTAINER(applet), menubar);969 gtk_container_add(GTK_CONTAINER(applet), menubar);
950 panel_applet_set_background_widget(applet, menubar);970 panel_applet_set_background_widget(applet, menubar);
951 gtk_widget_show(menubar);971 gtk_widget_show(menubar);
952 }972 }
953973
954 /* Background of applet */974 gtk_widget_show(GTK_WIDGET(applet));
955 g_signal_connect(applet, "change-background",975
956 G_CALLBACK(cw_panel_background_changed), menubar);976 return TRUE;
957
958 gtk_widget_show(GTK_WIDGET(applet));
959
960 return TRUE;
961
962}
963
964static void
965cw_panel_background_changed (PanelApplet *applet,
966 PanelAppletBackgroundType type,
967 GdkColor *colour,
968 GdkPixmap *pixmap,
969 GtkWidget *menubar)
970{
971 GtkRcStyle *rc_style;
972 GtkStyle *style;
973
974 /* reset style */
975 gtk_widget_set_style(GTK_WIDGET (applet), NULL);
976 gtk_widget_set_style(menubar, NULL);
977 rc_style = gtk_rc_style_new ();
978 gtk_widget_modify_style(GTK_WIDGET (applet), rc_style);
979 gtk_widget_modify_style(menubar, rc_style);
980 gtk_rc_style_unref(rc_style);
981
982 switch (type)
983 {
984 case PANEL_NO_BACKGROUND:
985 break;
986 case PANEL_COLOR_BACKGROUND:
987 gtk_widget_modify_bg(GTK_WIDGET (applet), GTK_STATE_NORMAL, colour);
988 gtk_widget_modify_bg(menubar, GTK_STATE_NORMAL, colour);
989 break;
990
991 case PANEL_PIXMAP_BACKGROUND:
992 style = gtk_style_copy(GTK_WIDGET (applet)->style);
993 if (style->bg_pixmap[GTK_STATE_NORMAL])
994 g_object_unref(style->bg_pixmap[GTK_STATE_NORMAL]);
995 style->bg_pixmap[GTK_STATE_NORMAL] = g_object_ref (pixmap);
996 gtk_widget_set_style(GTK_WIDGET (applet), style);
997 gtk_widget_set_style(GTK_WIDGET (menubar), style);
998 g_object_unref(style);
999 break;
1000 }
1001}977}
1002978
1003979
=== modified file 'src/eggaccelerators.c'
--- src/eggaccelerators.c 2010-03-02 22:24:00 +0000
+++ src/eggaccelerators.c 2011-11-26 02:05:26 +0000
@@ -578,20 +578,20 @@
578 j = 0;578 j = 0;
579 while (j < n_entries)579 while (j < n_entries)
580 { 580 {
581 if (keyvals[j] == GDK_Num_Lock)581 if (keyvals[j] == GDK_KEY_Num_Lock)
582 mask |= EGG_VIRTUAL_NUM_LOCK_MASK;582 mask |= EGG_VIRTUAL_NUM_LOCK_MASK;
583 else if (keyvals[j] == GDK_Scroll_Lock)583 else if (keyvals[j] == GDK_KEY_Scroll_Lock)
584 mask |= EGG_VIRTUAL_SCROLL_LOCK_MASK;584 mask |= EGG_VIRTUAL_SCROLL_LOCK_MASK;
585 else if (keyvals[j] == GDK_Meta_L ||585 else if (keyvals[j] == GDK_KEY_Meta_L ||
586 keyvals[j] == GDK_Meta_R)586 keyvals[j] == GDK_KEY_Meta_R)
587 mask |= EGG_VIRTUAL_META_MASK;587 mask |= EGG_VIRTUAL_META_MASK;
588 else if (keyvals[j] == GDK_Hyper_L ||588 else if (keyvals[j] == GDK_KEY_Hyper_L ||
589 keyvals[j] == GDK_Hyper_R)589 keyvals[j] == GDK_KEY_Hyper_R)
590 mask |= EGG_VIRTUAL_HYPER_MASK;590 mask |= EGG_VIRTUAL_HYPER_MASK;
591 else if (keyvals[j] == GDK_Super_L ||591 else if (keyvals[j] == GDK_KEY_Super_L ||
592 keyvals[j] == GDK_Super_R)592 keyvals[j] == GDK_KEY_Super_R)
593 mask |= EGG_VIRTUAL_SUPER_MASK;593 mask |= EGG_VIRTUAL_SUPER_MASK;
594 else if (keyvals[j] == GDK_Mode_switch)594 else if (keyvals[j] == GDK_KEY_Mode_switch)
595 mask |= EGG_VIRTUAL_MODE_SWITCH_MASK;595 mask |= EGG_VIRTUAL_MODE_SWITCH_MASK;
596 596
597 ++j;597 ++j;
598598
=== modified file 'src/eggaccelerators.h'
--- src/eggaccelerators.h 2010-03-02 22:24:00 +0000
+++ src/eggaccelerators.h 2011-11-26 02:05:26 +0000
@@ -20,7 +20,7 @@
20#ifndef __EGG_ACCELERATORS_H__20#ifndef __EGG_ACCELERATORS_H__
21#define __EGG_ACCELERATORS_H__21#define __EGG_ACCELERATORS_H__
2222
23#include <gtk/gtkaccelgroup.h>23#include <gtk/gtk.h>
24#include <gdk/gdk.h>24#include <gdk/gdk.h>
2525
26G_BEGIN_DECLS26G_BEGIN_DECLS
2727
=== modified file 'src/tomboykeybinder.c'
--- src/tomboykeybinder.c 2010-05-04 16:54:22 +0000
+++ src/tomboykeybinder.c 2011-11-26 02:05:26 +0000
@@ -18,7 +18,6 @@
18#include <string.h>18#include <string.h>
1919
20#include <gdk/gdk.h>20#include <gdk/gdk.h>
21#include <gdk/gdkwindow.h>
22#include <gdk/gdkx.h>21#include <gdk/gdkx.h>
23#include <X11/Xlib.h>22#include <X11/Xlib.h>
2423
@@ -86,7 +85,7 @@
86 XGrabKey (GDK_WINDOW_XDISPLAY (rootwin), 85 XGrabKey (GDK_WINDOW_XDISPLAY (rootwin),
87 binding->keycode, 86 binding->keycode,
88 binding->modifiers | mod_masks [i], 87 binding->modifiers | mod_masks [i],
89 GDK_WINDOW_XWINDOW (rootwin), 88 GDK_WINDOW_XID (rootwin),
90 False, 89 False,
91 GrabModeAsync,90 GrabModeAsync,
92 GrabModeAsync);91 GrabModeAsync);
@@ -94,7 +93,7 @@
94 XUngrabKey (GDK_WINDOW_XDISPLAY (rootwin),93 XUngrabKey (GDK_WINDOW_XDISPLAY (rootwin),
95 binding->keycode,94 binding->keycode,
96 binding->modifiers | mod_masks [i], 95 binding->modifiers | mod_masks [i],
97 GDK_WINDOW_XWINDOW (rootwin));96 GDK_WINDOW_XID (rootwin));
98 }97 }
99 }98 }
100}99}
@@ -312,7 +311,7 @@
312 XModifierKeymap *mod_keymap;311 XModifierKeymap *mod_keymap;
313 gboolean retval = FALSE;312 gboolean retval = FALSE;
314313
315 mod_keymap = XGetModifierMapping (gdk_display);314 mod_keymap = XGetModifierMapping (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()));
316315
317 map_size = 8 * mod_keymap->max_keypermod;316 map_size = 8 * mod_keymap->max_keypermod;
318317

Subscribers

People subscribed via source and target branches

to status/vote changes: