Merge lp:~ted/indicator-applet/code-unification into lp:indicator-applet/0.4
- code-unification
- Merge into applet
Proposed by
Ted Gould
Status: | Merged |
---|---|
Merged at revision: | not available |
Proposed branch: | lp:~ted/indicator-applet/code-unification |
Merge into: | lp:indicator-applet/0.4 |
Diff against target: |
612 lines (+122/-344) 10 files modified
.bzrignore (+3/-0) Makefile.am (+0/-1) configure.ac (+0/-1) data/GNOME_IndicatorAppletComplete.server.in.in (+28/-0) data/Makefile.am (+2/-0) po/POTFILES.in (+1/-1) src-session/Makefile.am (+0/-17) src-session/applet-main.c (+0/-320) src/Makefile.am (+35/-2) src/applet-main.c (+53/-2) |
To merge this branch: | bzr merge lp:~ted/indicator-applet/code-unification |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Robert Collins (community) | Approve | ||
Review via email: mp+16809@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
Revision history for this message
Ted Gould (ted) wrote : | # |
Revision history for this message
Robert Collins (lifeless) wrote : | # |
review: approve
This is a clear reduction in duplicate code so +1. I'll note though that
it may be a little hard to scale up and work with vs structuring it as
some code with overridable helpers, or a set of callable trivial
functions. But that can be examined in future.
-Rob
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file '.bzrignore' | |||
2 | --- .bzrignore 2009-08-18 15:50:35 +0000 | |||
3 | +++ .bzrignore 2010-01-04 20:49:11 +0000 | |||
4 | @@ -104,3 +104,6 @@ | |||
5 | 104 | data/GNOME_IndicatorAppletSUS.server.in | 104 | data/GNOME_IndicatorAppletSUS.server.in |
6 | 105 | src-session/indicator-applet-no-sus | 105 | src-session/indicator-applet-no-sus |
7 | 106 | src-session/indicator-applet-session | 106 | src-session/indicator-applet-session |
8 | 107 | src/indicator-applet-complete | ||
9 | 108 | src/indicator-applet-session | ||
10 | 109 | data/GNOME_IndicatorAppletComplete.server | ||
11 | 107 | 110 | ||
12 | === modified file 'Makefile.am' | |||
13 | --- Makefile.am 2009-08-24 18:22:32 +0000 | |||
14 | +++ Makefile.am 2010-01-04 20:49:11 +0000 | |||
15 | @@ -1,7 +1,6 @@ | |||
16 | 1 | 1 | ||
17 | 2 | SUBDIRS = \ | 2 | SUBDIRS = \ |
18 | 3 | src \ | 3 | src \ |
19 | 4 | src-session \ | ||
20 | 5 | data \ | 4 | data \ |
21 | 6 | po | 5 | po |
22 | 7 | 6 | ||
23 | 8 | 7 | ||
24 | === modified file 'configure.ac' | |||
25 | --- configure.ac 2009-12-10 17:27:22 +0000 | |||
26 | +++ configure.ac 2010-01-04 20:49:11 +0000 | |||
27 | @@ -124,7 +124,6 @@ | |||
28 | 124 | AC_OUTPUT([ | 124 | AC_OUTPUT([ |
29 | 125 | Makefile | 125 | Makefile |
30 | 126 | src/Makefile | 126 | src/Makefile |
31 | 127 | src-session/Makefile | ||
32 | 128 | data/Makefile | 127 | data/Makefile |
33 | 129 | po/Makefile.in | 128 | po/Makefile.in |
34 | 130 | ]) | 129 | ]) |
35 | 131 | 130 | ||
36 | === added file 'data/GNOME_IndicatorAppletComplete.server.in.in' | |||
37 | --- data/GNOME_IndicatorAppletComplete.server.in.in 1970-01-01 00:00:00 +0000 | |||
38 | +++ data/GNOME_IndicatorAppletComplete.server.in.in 2010-01-04 20:49:11 +0000 | |||
39 | @@ -0,0 +1,28 @@ | |||
40 | 1 | <oaf_info> | ||
41 | 2 | <oaf_server iid="OAFIID:GNOME_IndicatorAppletComplete_Factory" type="exe" | ||
42 | 3 | location="@LIBEXECDIR@/indicator-applet-complete"> | ||
43 | 4 | |||
44 | 5 | <oaf_attribute name="repo_ids" type="stringv"> | ||
45 | 6 | <item value="IDL:Bonobo/GenericFactory:1.0"/> | ||
46 | 7 | <item value="IDL:Bonobo/Unknown:1.0"/> | ||
47 | 8 | </oaf_attribute> | ||
48 | 9 | <oaf_attribute name="name" type="string" value="Indicator Applet Complete Factory"/> | ||
49 | 10 | <oaf_attribute name="description" type="string" value="Indicator Applet Complete Factory"/> | ||
50 | 11 | <oaf_attribute name="bonobo:environment" type="stringv"> | ||
51 | 12 | <item value="DBUS_SESSION_BUS_ADDRESS"/> | ||
52 | 13 | </oaf_attribute> | ||
53 | 14 | </oaf_server> | ||
54 | 15 | |||
55 | 16 | <oaf_server iid="OAFIID:GNOME_IndicatorAppletComplete" type="factory" | ||
56 | 17 | location="OAFIID:GNOME_IndicatorAppletComplete_Factory"> | ||
57 | 18 | |||
58 | 19 | <oaf_attribute name="repo_ids" type="stringv"> | ||
59 | 20 | <item value="IDL:GNOME/Vertigo/PanelAppletShell:1.0"/> | ||
60 | 21 | <item value="IDL:Bonobo/Control:1.0"/> | ||
61 | 22 | <item value="IDL:Bonobo/Unknown:1.0"/> | ||
62 | 23 | </oaf_attribute> | ||
63 | 24 | <oaf_attribute name="name" type="string" _value="Indicator Applet Complete"/> | ||
64 | 25 | <oaf_attribute name="description" type="string" _value="A unified applet containing all of the indicators."/> | ||
65 | 26 | <oaf_attribute name="panel:icon" type="string" value="indicator-applet"/> | ||
66 | 27 | </oaf_server> | ||
67 | 28 | </oaf_info> | ||
68 | 0 | 29 | ||
69 | === modified file 'data/Makefile.am' | |||
70 | --- data/Makefile.am 2009-08-07 17:47:02 +0000 | |||
71 | +++ data/Makefile.am 2010-01-04 20:49:11 +0000 | |||
72 | @@ -8,6 +8,7 @@ | |||
73 | 8 | $(libdir)/bonobo/servers | 8 | $(libdir)/bonobo/servers |
74 | 9 | server_in_files = \ | 9 | server_in_files = \ |
75 | 10 | GNOME_IndicatorApplet.server.in \ | 10 | GNOME_IndicatorApplet.server.in \ |
76 | 11 | GNOME_IndicatorAppletComplete.server.in \ | ||
77 | 11 | GNOME_FastUserSwitchApplet.server.in | 12 | GNOME_FastUserSwitchApplet.server.in |
78 | 12 | server_DATA = \ | 13 | server_DATA = \ |
79 | 13 | $(server_in_files:.server.in=.server) | 14 | $(server_in_files:.server.in=.server) |
80 | @@ -68,6 +69,7 @@ | |||
81 | 68 | EXTRA_DIST = \ | 69 | EXTRA_DIST = \ |
82 | 69 | $(icons_DATA) \ | 70 | $(icons_DATA) \ |
83 | 70 | GNOME_IndicatorApplet.server.in.in \ | 71 | GNOME_IndicatorApplet.server.in.in \ |
84 | 72 | GNOME_IndicatorAppletComplete.server.in.in \ | ||
85 | 71 | GNOME_FastUserSwitchApplet.server.in.in \ | 73 | GNOME_FastUserSwitchApplet.server.in.in \ |
86 | 72 | $(schema_in_files) | 74 | $(schema_in_files) |
87 | 73 | 75 | ||
88 | 74 | 76 | ||
89 | === modified file 'po/POTFILES.in' | |||
90 | --- po/POTFILES.in 2009-08-18 16:03:40 +0000 | |||
91 | +++ po/POTFILES.in 2010-01-04 20:49:11 +0000 | |||
92 | @@ -1,6 +1,6 @@ | |||
93 | 1 | [encoding: UTF-8] | 1 | [encoding: UTF-8] |
94 | 2 | data/GNOME_IndicatorApplet.server.in.in | 2 | data/GNOME_IndicatorApplet.server.in.in |
95 | 3 | data/GNOME_IndicatorAppletComplete.server.in.in | ||
96 | 3 | data/GNOME_FastUserSwitchApplet.server.in.in | 4 | data/GNOME_FastUserSwitchApplet.server.in.in |
97 | 4 | data/indicator-applet.schemas.in | 5 | data/indicator-applet.schemas.in |
98 | 5 | src/applet-main.c | 6 | src/applet-main.c |
99 | 6 | src-session/applet-main.c | ||
100 | 7 | 7 | ||
101 | === removed directory 'src-session' | |||
102 | === removed file 'src-session/Makefile.am' | |||
103 | --- src-session/Makefile.am 2009-08-24 18:22:32 +0000 | |||
104 | +++ src-session/Makefile.am 1970-01-01 00:00:00 +0000 | |||
105 | @@ -1,17 +0,0 @@ | |||
106 | 1 | |||
107 | 2 | libexec_PROGRAMS = \ | ||
108 | 3 | indicator-applet-session | ||
109 | 4 | |||
110 | 5 | indicator_applet_session_CFLAGS = \ | ||
111 | 6 | -DG_LOG_DOMAIN=\""Indicator-Applet"\" \ | ||
112 | 7 | -DDATADIR=\""$(datadir)"\" \ | ||
113 | 8 | -DINDICATOR_DIR=\""$(INDICATORDIR)"\" \ | ||
114 | 9 | -DINDICATOR_ICONS_DIR=\""$(INDICATORICONSDIR)"\" \ | ||
115 | 10 | -I$(srcdir)/.. \ | ||
116 | 11 | $(APPLET_CFLAGS) | ||
117 | 12 | |||
118 | 13 | indicator_applet_session_SOURCES = \ | ||
119 | 14 | applet-main.c | ||
120 | 15 | |||
121 | 16 | indicator_applet_session_LDADD = \ | ||
122 | 17 | $(APPLET_LIBS) | ||
123 | 18 | 0 | ||
124 | === removed file 'src-session/applet-main.c' | |||
125 | --- src-session/applet-main.c 2009-12-24 16:43:37 +0000 | |||
126 | +++ src-session/applet-main.c 1970-01-01 00:00:00 +0000 | |||
127 | @@ -1,320 +0,0 @@ | |||
128 | 1 | /* | ||
129 | 2 | A small wrapper utility to load indicators and put them as menu items | ||
130 | 3 | into the gnome-panel using it's applet interface. | ||
131 | 4 | |||
132 | 5 | Copyright 2009 Canonical Ltd. | ||
133 | 6 | |||
134 | 7 | Authors: | ||
135 | 8 | Ted Gould <ted@canonical.com> | ||
136 | 9 | |||
137 | 10 | This program is free software: you can redistribute it and/or modify it | ||
138 | 11 | under the terms of the GNU General Public License version 3, as published | ||
139 | 12 | by the Free Software Foundation. | ||
140 | 13 | |||
141 | 14 | This program is distributed in the hope that it will be useful, but | ||
142 | 15 | WITHOUT ANY WARRANTY; without even the implied warranties of | ||
143 | 16 | MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
144 | 17 | PURPOSE. See the GNU General Public License for more details. | ||
145 | 18 | |||
146 | 19 | You should have received a copy of the GNU General Public License along | ||
147 | 20 | with this program. If not, see <http://www.gnu.org/licenses/>. | ||
148 | 21 | */ | ||
149 | 22 | |||
150 | 23 | #include <config.h> | ||
151 | 24 | #include <panel-applet.h> | ||
152 | 25 | |||
153 | 26 | #include "libindicator/indicator-object.h" | ||
154 | 27 | |||
155 | 28 | static gboolean applet_fill_cb (PanelApplet * applet, const gchar * iid, gpointer data); | ||
156 | 29 | |||
157 | 30 | |||
158 | 31 | static void cw_panel_background_changed (PanelApplet *applet, | ||
159 | 32 | PanelAppletBackgroundType type, | ||
160 | 33 | GdkColor *colour, | ||
161 | 34 | GdkPixmap *pixmap, | ||
162 | 35 | GtkWidget *menubar); | ||
163 | 36 | |||
164 | 37 | /************* | ||
165 | 38 | * main | ||
166 | 39 | * ***********/ | ||
167 | 40 | |||
168 | 41 | PANEL_APPLET_BONOBO_FACTORY ("OAFIID:GNOME_FastUserSwitchApplet_Factory", | ||
169 | 42 | PANEL_TYPE_APPLET, | ||
170 | 43 | "indicator-applet-session", "0", | ||
171 | 44 | applet_fill_cb, NULL); | ||
172 | 45 | |||
173 | 46 | /************* | ||
174 | 47 | * init function | ||
175 | 48 | * ***********/ | ||
176 | 49 | static gboolean | ||
177 | 50 | load_module (const gchar * name, GtkWidget * menu) | ||
178 | 51 | { | ||
179 | 52 | g_debug("Looking at Module: %s", name); | ||
180 | 53 | g_return_val_if_fail(name != NULL, FALSE); | ||
181 | 54 | |||
182 | 55 | if (!g_str_has_suffix(name, G_MODULE_SUFFIX)) { | ||
183 | 56 | return FALSE; | ||
184 | 57 | } | ||
185 | 58 | |||
186 | 59 | g_debug("Loading Module: %s", name); | ||
187 | 60 | |||
188 | 61 | gchar * fullpath = g_build_filename(INDICATOR_DIR, name, NULL); | ||
189 | 62 | IndicatorObject * io = indicator_object_new_from_file(fullpath); | ||
190 | 63 | g_free(fullpath); | ||
191 | 64 | |||
192 | 65 | GList * entries = indicator_object_get_entries(io); | ||
193 | 66 | GList * entry = NULL; | ||
194 | 67 | |||
195 | 68 | for (entry = entries; entry != NULL; entry = g_list_next(entry)) { | ||
196 | 69 | IndicatorObjectEntry * entrydata = (IndicatorObjectEntry *)entry->data; | ||
197 | 70 | |||
198 | 71 | GtkWidget * menuitem = gtk_menu_item_new(); | ||
199 | 72 | GtkWidget * hbox = gtk_hbox_new(FALSE, 3); | ||
200 | 73 | if (entrydata->image != NULL) { | ||
201 | 74 | gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(entrydata->image), FALSE, FALSE, 0); | ||
202 | 75 | } | ||
203 | 76 | if (entrydata->label != NULL) { | ||
204 | 77 | gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(entrydata->label), FALSE, FALSE, 0); | ||
205 | 78 | } | ||
206 | 79 | gtk_container_add(GTK_CONTAINER(menuitem), hbox); | ||
207 | 80 | gtk_widget_show(hbox); | ||
208 | 81 | |||
209 | 82 | if (entrydata->menu != NULL) { | ||
210 | 83 | gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), GTK_WIDGET(entrydata->menu)); | ||
211 | 84 | } | ||
212 | 85 | |||
213 | 86 | gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | ||
214 | 87 | gtk_widget_show(menuitem); | ||
215 | 88 | } | ||
216 | 89 | |||
217 | 90 | g_list_free(entries); | ||
218 | 91 | |||
219 | 92 | return TRUE; | ||
220 | 93 | } | ||
221 | 94 | |||
222 | 95 | static gboolean | ||
223 | 96 | menubar_press (GtkWidget * widget, | ||
224 | 97 | GdkEventButton *event, | ||
225 | 98 | gpointer data) | ||
226 | 99 | { | ||
227 | 100 | if (event->button != 1) { | ||
228 | 101 | g_signal_stop_emission_by_name(widget, "button-press-event"); | ||
229 | 102 | } | ||
230 | 103 | |||
231 | 104 | return FALSE; | ||
232 | 105 | } | ||
233 | 106 | |||
234 | 107 | static gboolean | ||
235 | 108 | menubar_on_expose (GtkWidget * widget, | ||
236 | 109 | GdkEventExpose *event, | ||
237 | 110 | GtkWidget * menubar) | ||
238 | 111 | { | ||
239 | 112 | if (GTK_WIDGET_HAS_FOCUS(menubar)) | ||
240 | 113 | gtk_paint_focus(widget->style, widget->window, GTK_WIDGET_STATE(menubar), | ||
241 | 114 | NULL, widget, "menubar-applet", 0, 0, -1, -1); | ||
242 | 115 | |||
243 | 116 | return FALSE; | ||
244 | 117 | } | ||
245 | 118 | |||
246 | 119 | static void | ||
247 | 120 | about_cb (BonoboUIComponent *ui_container, | ||
248 | 121 | gpointer data, | ||
249 | 122 | const gchar *cname) | ||
250 | 123 | { | ||
251 | 124 | static const gchar *authors[] = { | ||
252 | 125 | "Ted Gould <ted@canonical.com>", | ||
253 | 126 | NULL | ||
254 | 127 | }; | ||
255 | 128 | |||
256 | 129 | static gchar *license[] = { | ||
257 | 130 | N_("This program is free software: you can redistribute it and/or modify it " | ||
258 | 131 | "under the terms of the GNU General Public License version 3, as published " | ||
259 | 132 | "by the Free Software Foundation."), | ||
260 | 133 | N_("This program is distributed in the hope that it will be useful, but " | ||
261 | 134 | "WITHOUT ANY WARRANTY; without even the implied warranties of " | ||
262 | 135 | "MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR " | ||
263 | 136 | "PURPOSE. See the GNU General Public License for more details."), | ||
264 | 137 | N_("You should have received a copy of the GNU General Public License along " | ||
265 | 138 | "with this program. If not, see <http://www.gnu.org/licenses/>."), | ||
266 | 139 | NULL | ||
267 | 140 | }; | ||
268 | 141 | gchar *license_i18n; | ||
269 | 142 | |||
270 | 143 | license_i18n = g_strconcat (_(license[0]), "\n\n", _(license[1]), "\n\n", _(license[2]), NULL); | ||
271 | 144 | |||
272 | 145 | gtk_show_about_dialog(NULL, | ||
273 | 146 | "version", VERSION, | ||
274 | 147 | "copyright", "Copyright \xc2\xa9 2009 Canonical, Ltd.", | ||
275 | 148 | "comments", _("A place to adjust your status, change users or exit your session."), | ||
276 | 149 | "authors", authors, | ||
277 | 150 | "license", license_i18n, | ||
278 | 151 | "wrap-license", TRUE, | ||
279 | 152 | "translator-credits", _("translator-credits"), | ||
280 | 153 | "logo-icon-name", "indicator-applet", | ||
281 | 154 | "icon-name", "indicator-applet", | ||
282 | 155 | "website", "http://launchpad.net/indicator-applet", | ||
283 | 156 | "website-label", _("Indicator Applet Website"), | ||
284 | 157 | NULL | ||
285 | 158 | ); | ||
286 | 159 | |||
287 | 160 | g_free (license_i18n); | ||
288 | 161 | |||
289 | 162 | return; | ||
290 | 163 | } | ||
291 | 164 | |||
292 | 165 | #ifdef N_ | ||
293 | 166 | #undef N_ | ||
294 | 167 | #endif | ||
295 | 168 | #define N_(x) x | ||
296 | 169 | |||
297 | 170 | static gboolean | ||
298 | 171 | applet_fill_cb (PanelApplet * applet, const gchar * iid, gpointer data) | ||
299 | 172 | { | ||
300 | 173 | static const BonoboUIVerb menu_verbs[] = { | ||
301 | 174 | BONOBO_UI_VERB ("IndicatorAppletAbout", about_cb), | ||
302 | 175 | BONOBO_UI_VERB_END | ||
303 | 176 | }; | ||
304 | 177 | static const gchar * menu_xml = | ||
305 | 178 | "<popup name=\"button3\">" | ||
306 | 179 | "<menuitem name=\"About Item\" verb=\"IndicatorAppletAbout\" _label=\"" N_("_About") "\" pixtype=\"stock\" pixname=\"gtk-about\"/>" | ||
307 | 180 | "</popup>"; | ||
308 | 181 | |||
309 | 182 | GtkWidget *menubar; | ||
310 | 183 | gint i; | ||
311 | 184 | gint indicators_loaded = 0; | ||
312 | 185 | static gboolean first_time = FALSE; | ||
313 | 186 | |||
314 | 187 | /* check if we are running stracciatella session */ | ||
315 | 188 | if (g_strcmp0(g_getenv("GDMSESSION"), "gnome-stracciatella") == 0) { | ||
316 | 189 | g_debug("Running stracciatella GNOME session, disabling myself"); | ||
317 | 190 | return TRUE; | ||
318 | 191 | } | ||
319 | 192 | |||
320 | 193 | if (!first_time) | ||
321 | 194 | { | ||
322 | 195 | first_time = TRUE; | ||
323 | 196 | g_set_application_name(_("Indicator Applet Session")); | ||
324 | 197 | } | ||
325 | 198 | |||
326 | 199 | /* Set panel options */ | ||
327 | 200 | gtk_container_set_border_width(GTK_CONTAINER (applet), 0); | ||
328 | 201 | panel_applet_set_flags(applet, PANEL_APPLET_EXPAND_MINOR); | ||
329 | 202 | panel_applet_setup_menu(applet, menu_xml, menu_verbs, NULL); | ||
330 | 203 | atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (applet)), | ||
331 | 204 | "indicator-applet-session"); | ||
332 | 205 | |||
333 | 206 | /* Init some theme/icon stuff */ | ||
334 | 207 | gtk_icon_theme_append_search_path(gtk_icon_theme_get_default(), | ||
335 | 208 | INDICATOR_ICONS_DIR); | ||
336 | 209 | /* g_debug("Icons directory: %s", INDICATOR_ICONS_DIR); */ | ||
337 | 210 | gtk_rc_parse_string ( | ||
338 | 211 | "style \"indicator-applet-style\"\n" | ||
339 | 212 | "{\n" | ||
340 | 213 | " GtkMenuBar::shadow-type = none\n" | ||
341 | 214 | " GtkMenuBar::internal-padding = 0\n" | ||
342 | 215 | " GtkWidget::focus-line-width = 0\n" | ||
343 | 216 | " GtkWidget::focus-padding = 0\n" | ||
344 | 217 | "}\n" | ||
345 | 218 | "style \"indicator-applet-menubar-style\"\n" | ||
346 | 219 | "{\n" | ||
347 | 220 | " GtkMenuBar::shadow-type = none\n" | ||
348 | 221 | " GtkMenuBar::internal-padding = 0\n" | ||
349 | 222 | " GtkWidget::focus-line-width = 0\n" | ||
350 | 223 | " GtkWidget::focus-padding = 0\n" | ||
351 | 224 | " GtkMenuItem::horizontal-padding = 0\n" | ||
352 | 225 | "}\n" | ||
353 | 226 | "style \"indicator-applet-menuitem-style\"\n" | ||
354 | 227 | "{\n" | ||
355 | 228 | " GtkWidget::focus-line-width = 0\n" | ||
356 | 229 | " GtkWidget::focus-padding = 0\n" | ||
357 | 230 | " GtkMenuItem::horizontal-padding = 0\n" | ||
358 | 231 | "}\n" | ||
359 | 232 | "widget \"*.fast-user-switch-applet\" style \"indicator-applet-style\"" | ||
360 | 233 | "widget \"*.fast-user-switch-menuitem\" style \"indicator-applet-menuitem-style\"" | ||
361 | 234 | "widget \"*.fast-user-switch-menubar\" style \"indicator-applet-menubar-style\""); | ||
362 | 235 | //gtk_widget_set_name(GTK_WIDGET (applet), "indicator-applet-menubar"); | ||
363 | 236 | gtk_widget_set_name(GTK_WIDGET (applet), "fast-user-switch-applet"); | ||
364 | 237 | |||
365 | 238 | /* Build menubar */ | ||
366 | 239 | menubar = gtk_menu_bar_new(); | ||
367 | 240 | GTK_WIDGET_SET_FLAGS (menubar, GTK_WIDGET_FLAGS(menubar) | GTK_CAN_FOCUS); | ||
368 | 241 | gtk_widget_set_name(GTK_WIDGET (menubar), "fast-user-switch-menubar"); | ||
369 | 242 | g_signal_connect(menubar, "button-press-event", G_CALLBACK(menubar_press), NULL); | ||
370 | 243 | g_signal_connect_after(menubar, "expose-event", G_CALLBACK(menubar_on_expose), menubar); | ||
371 | 244 | gtk_container_set_border_width(GTK_CONTAINER(menubar), 0); | ||
372 | 245 | |||
373 | 246 | /* load 'em */ | ||
374 | 247 | if (g_file_test(INDICATOR_DIR, (G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR))) { | ||
375 | 248 | GDir * dir = g_dir_open(INDICATOR_DIR, 0, NULL); | ||
376 | 249 | |||
377 | 250 | const gchar * name; | ||
378 | 251 | while ((name = g_dir_read_name(dir)) != NULL) { | ||
379 | 252 | if (g_strcmp0(name, "libsession.so") && g_strcmp0(name, "libme.so")) { | ||
380 | 253 | continue; | ||
381 | 254 | } | ||
382 | 255 | if (load_module(name, menubar)) { | ||
383 | 256 | indicators_loaded++; | ||
384 | 257 | } | ||
385 | 258 | } | ||
386 | 259 | g_dir_close (dir); | ||
387 | 260 | } | ||
388 | 261 | |||
389 | 262 | if (indicators_loaded == 0) { | ||
390 | 263 | /* A label to allow for click through */ | ||
391 | 264 | GtkWidget * item = gtk_label_new(_("No Indicators")); | ||
392 | 265 | gtk_container_add(GTK_CONTAINER(applet), item); | ||
393 | 266 | gtk_widget_show(item); | ||
394 | 267 | } else { | ||
395 | 268 | gtk_container_add(GTK_CONTAINER(applet), menubar); | ||
396 | 269 | panel_applet_set_background_widget(applet, menubar); | ||
397 | 270 | gtk_widget_show(menubar); | ||
398 | 271 | } | ||
399 | 272 | |||
400 | 273 | /* Background of applet */ | ||
401 | 274 | g_signal_connect(applet, "change-background", | ||
402 | 275 | G_CALLBACK(cw_panel_background_changed), menubar); | ||
403 | 276 | |||
404 | 277 | gtk_widget_show(GTK_WIDGET(applet)); | ||
405 | 278 | |||
406 | 279 | return TRUE; | ||
407 | 280 | } | ||
408 | 281 | |||
409 | 282 | static void | ||
410 | 283 | cw_panel_background_changed (PanelApplet *applet, | ||
411 | 284 | PanelAppletBackgroundType type, | ||
412 | 285 | GdkColor *colour, | ||
413 | 286 | GdkPixmap *pixmap, | ||
414 | 287 | GtkWidget *menubar) | ||
415 | 288 | { | ||
416 | 289 | GtkRcStyle *rc_style; | ||
417 | 290 | GtkStyle *style; | ||
418 | 291 | |||
419 | 292 | /* reset style */ | ||
420 | 293 | gtk_widget_set_style(GTK_WIDGET (applet), NULL); | ||
421 | 294 | gtk_widget_set_style(menubar, NULL); | ||
422 | 295 | rc_style = gtk_rc_style_new (); | ||
423 | 296 | gtk_widget_modify_style(GTK_WIDGET (applet), rc_style); | ||
424 | 297 | gtk_widget_modify_style(menubar, rc_style); | ||
425 | 298 | gtk_rc_style_unref(rc_style); | ||
426 | 299 | |||
427 | 300 | switch (type) | ||
428 | 301 | { | ||
429 | 302 | case PANEL_NO_BACKGROUND: | ||
430 | 303 | break; | ||
431 | 304 | case PANEL_COLOR_BACKGROUND: | ||
432 | 305 | gtk_widget_modify_bg(GTK_WIDGET (applet), GTK_STATE_NORMAL, colour); | ||
433 | 306 | gtk_widget_modify_bg(menubar, GTK_STATE_NORMAL, colour); | ||
434 | 307 | break; | ||
435 | 308 | |||
436 | 309 | case PANEL_PIXMAP_BACKGROUND: | ||
437 | 310 | style = gtk_style_copy(GTK_WIDGET (applet)->style); | ||
438 | 311 | if (style->bg_pixmap[GTK_STATE_NORMAL]) | ||
439 | 312 | g_object_unref(style->bg_pixmap[GTK_STATE_NORMAL]); | ||
440 | 313 | style->bg_pixmap[GTK_STATE_NORMAL] = g_object_ref (pixmap); | ||
441 | 314 | gtk_widget_set_style(GTK_WIDGET (applet), style); | ||
442 | 315 | gtk_widget_set_style(GTK_WIDGET (menubar), style); | ||
443 | 316 | g_object_unref(style); | ||
444 | 317 | break; | ||
445 | 318 | } | ||
446 | 319 | } | ||
447 | 320 | |||
448 | 321 | 0 | ||
449 | === modified file 'src/Makefile.am' | |||
450 | --- src/Makefile.am 2009-08-24 18:22:32 +0000 | |||
451 | +++ src/Makefile.am 2010-01-04 20:49:11 +0000 | |||
452 | @@ -1,17 +1,50 @@ | |||
453 | 1 | 1 | ||
454 | 2 | libexec_PROGRAMS = \ | 2 | libexec_PROGRAMS = \ |
456 | 3 | indicator-applet | 3 | indicator-applet \ |
457 | 4 | indicator-applet-session \ | ||
458 | 5 | indicator-applet-complete | ||
459 | 4 | 6 | ||
460 | 5 | indicator_applet_CFLAGS = \ | 7 | indicator_applet_CFLAGS = \ |
461 | 6 | -DG_LOG_DOMAIN=\""Indicator-Applet"\" \ | 8 | -DG_LOG_DOMAIN=\""Indicator-Applet"\" \ |
462 | 7 | -DDATADIR=\""$(datadir)"\" \ | 9 | -DDATADIR=\""$(datadir)"\" \ |
463 | 8 | -DINDICATOR_DIR=\""$(INDICATORDIR)"\" \ | 10 | -DINDICATOR_DIR=\""$(INDICATORDIR)"\" \ |
464 | 9 | -DINDICATOR_ICONS_DIR=\""$(INDICATORICONSDIR)"\" \ | 11 | -DINDICATOR_ICONS_DIR=\""$(INDICATORICONSDIR)"\" \ |
465 | 12 | -DINDICATOR_APPLET \ | ||
466 | 10 | -I$(srcdir)/.. \ | 13 | -I$(srcdir)/.. \ |
467 | 11 | $(APPLET_CFLAGS) | 14 | $(APPLET_CFLAGS) |
468 | 12 | 15 | ||
470 | 13 | indicator_applet_SOURCES = \ | 16 | indicator_applet_SOURCES = \ |
471 | 14 | applet-main.c | 17 | applet-main.c |
472 | 15 | 18 | ||
473 | 16 | indicator_applet_LDADD = \ | 19 | indicator_applet_LDADD = \ |
474 | 17 | $(APPLET_LIBS) | 20 | $(APPLET_LIBS) |
475 | 21 | |||
476 | 22 | indicator_applet_session_CFLAGS = \ | ||
477 | 23 | -DG_LOG_DOMAIN=\""Indicator-Applet-Session"\" \ | ||
478 | 24 | -DDATADIR=\""$(datadir)"\" \ | ||
479 | 25 | -DINDICATOR_DIR=\""$(INDICATORDIR)"\" \ | ||
480 | 26 | -DINDICATOR_ICONS_DIR=\""$(INDICATORICONSDIR)"\" \ | ||
481 | 27 | -DINDICATOR_APPLET_SESSION \ | ||
482 | 28 | -I$(srcdir)/.. \ | ||
483 | 29 | $(APPLET_CFLAGS) | ||
484 | 30 | |||
485 | 31 | indicator_applet_session_SOURCES = \ | ||
486 | 32 | applet-main.c | ||
487 | 33 | |||
488 | 34 | indicator_applet_session_LDADD = \ | ||
489 | 35 | $(APPLET_LIBS) | ||
490 | 36 | |||
491 | 37 | indicator_applet_complete_CFLAGS = \ | ||
492 | 38 | -DG_LOG_DOMAIN=\""Indicator-Applet-Complete"\" \ | ||
493 | 39 | -DDATADIR=\""$(datadir)"\" \ | ||
494 | 40 | -DINDICATOR_DIR=\""$(INDICATORDIR)"\" \ | ||
495 | 41 | -DINDICATOR_ICONS_DIR=\""$(INDICATORICONSDIR)"\" \ | ||
496 | 42 | -DINDICATOR_APPLET_COMPLETE \ | ||
497 | 43 | -I$(srcdir)/.. \ | ||
498 | 44 | $(APPLET_CFLAGS) | ||
499 | 45 | |||
500 | 46 | indicator_applet_complete_SOURCES = \ | ||
501 | 47 | applet-main.c | ||
502 | 48 | |||
503 | 49 | indicator_applet_complete_LDADD = \ | ||
504 | 50 | $(APPLET_LIBS) | ||
505 | 18 | 51 | ||
506 | === modified file 'src/applet-main.c' | |||
507 | --- src/applet-main.c 2010-01-04 02:23:10 +0000 | |||
508 | +++ src/applet-main.c 2010-01-04 20:49:11 +0000 | |||
509 | @@ -40,10 +40,24 @@ | |||
510 | 40 | * main | 40 | * main |
511 | 41 | * ***********/ | 41 | * ***********/ |
512 | 42 | 42 | ||
513 | 43 | #ifdef INDICATOR_APPLET | ||
514 | 43 | PANEL_APPLET_BONOBO_FACTORY ("OAFIID:GNOME_IndicatorApplet_Factory", | 44 | PANEL_APPLET_BONOBO_FACTORY ("OAFIID:GNOME_IndicatorApplet_Factory", |
515 | 44 | PANEL_TYPE_APPLET, | 45 | PANEL_TYPE_APPLET, |
516 | 45 | "indicator-applet", "0", | 46 | "indicator-applet", "0", |
517 | 46 | applet_fill_cb, NULL); | 47 | applet_fill_cb, NULL); |
518 | 48 | #endif | ||
519 | 49 | #ifdef INDICATOR_APPLET_SESSION | ||
520 | 50 | PANEL_APPLET_BONOBO_FACTORY ("OAFIID:GNOME_FastUserSwitchApplet_Factory", | ||
521 | 51 | PANEL_TYPE_APPLET, | ||
522 | 52 | "indicator-applet-session", "0", | ||
523 | 53 | applet_fill_cb, NULL); | ||
524 | 54 | #endif | ||
525 | 55 | #ifdef INDICATOR_APPLET_COMPLETE | ||
526 | 56 | PANEL_APPLET_BONOBO_FACTORY ("OAFIID:GNOME_IndicatorAppletComplete_Factory", | ||
527 | 57 | PANEL_TYPE_APPLET, | ||
528 | 58 | "indicator-applet-complete", "0", | ||
529 | 59 | applet_fill_cb, NULL); | ||
530 | 60 | #endif | ||
531 | 47 | 61 | ||
532 | 48 | /************* | 62 | /************* |
533 | 49 | * init function | 63 | * init function |
534 | @@ -188,7 +202,11 @@ | |||
535 | 188 | gtk_show_about_dialog(NULL, | 202 | gtk_show_about_dialog(NULL, |
536 | 189 | "version", VERSION, | 203 | "version", VERSION, |
537 | 190 | "copyright", "Copyright \xc2\xa9 2009 Canonical, Ltd.", | 204 | "copyright", "Copyright \xc2\xa9 2009 Canonical, Ltd.", |
538 | 205 | #ifdef INDICATOR_APPLET_SESSION | ||
539 | 206 | "comments", _("A place to adjust your status, change users or exit your session."), | ||
540 | 207 | #else | ||
541 | 191 | "comments", _("An applet to hold all of the system indicators."), | 208 | "comments", _("An applet to hold all of the system indicators."), |
542 | 209 | #endif | ||
543 | 192 | "authors", authors, | 210 | "authors", authors, |
544 | 193 | "license", license_i18n, | 211 | "license", license_i18n, |
545 | 194 | "wrap-license", TRUE, | 212 | "wrap-license", TRUE, |
546 | @@ -227,18 +245,44 @@ | |||
547 | 227 | gint indicators_loaded = 0; | 245 | gint indicators_loaded = 0; |
548 | 228 | static gboolean first_time = FALSE; | 246 | static gboolean first_time = FALSE; |
549 | 229 | 247 | ||
550 | 248 | #ifdef INDICATOR_APPLET_SESSION | ||
551 | 249 | /* check if we are running stracciatella session */ | ||
552 | 250 | if (g_strcmp0(g_getenv("GDMSESSION"), "gnome-stracciatella") == 0) { | ||
553 | 251 | g_debug("Running stracciatella GNOME session, disabling myself"); | ||
554 | 252 | return TRUE; | ||
555 | 253 | } | ||
556 | 254 | #endif | ||
557 | 255 | |||
558 | 230 | if (!first_time) | 256 | if (!first_time) |
559 | 231 | { | 257 | { |
560 | 232 | first_time = TRUE; | 258 | first_time = TRUE; |
561 | 259 | #ifdef INDICATOR_APPLET | ||
562 | 233 | g_set_application_name(_("Indicator Applet")); | 260 | g_set_application_name(_("Indicator Applet")); |
563 | 261 | #endif | ||
564 | 262 | #ifdef INDICATOR_APPLET_SESSION | ||
565 | 263 | g_set_application_name(_("Indicator Applet Session")); | ||
566 | 264 | #endif | ||
567 | 265 | #ifdef INDICATOR_APPLET_COMPLETE | ||
568 | 266 | g_set_application_name(_("Indicator Applet Complete")); | ||
569 | 267 | #endif | ||
570 | 234 | } | 268 | } |
571 | 235 | 269 | ||
572 | 236 | /* Set panel options */ | 270 | /* Set panel options */ |
573 | 237 | gtk_container_set_border_width(GTK_CONTAINER (applet), 0); | 271 | gtk_container_set_border_width(GTK_CONTAINER (applet), 0); |
574 | 238 | panel_applet_set_flags(applet, PANEL_APPLET_EXPAND_MINOR); | 272 | panel_applet_set_flags(applet, PANEL_APPLET_EXPAND_MINOR); |
575 | 239 | panel_applet_setup_menu(applet, menu_xml, menu_verbs, NULL); | 273 | panel_applet_setup_menu(applet, menu_xml, menu_verbs, NULL); |
578 | 240 | atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (applet)), | 274 | #ifdef INDICATOR_APPLET |
579 | 241 | "indicator-applet"); | 275 | atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (applet)), |
580 | 276 | "indicator-applet"); | ||
581 | 277 | #endif | ||
582 | 278 | #ifdef INDICATOR_APPLET_SESSION | ||
583 | 279 | atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (applet)), | ||
584 | 280 | "indicator-applet-session"); | ||
585 | 281 | #endif | ||
586 | 282 | #ifdef INDICATOR_APPLET_COMPLETE | ||
587 | 283 | atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (applet)), | ||
588 | 284 | "indicator-applet-complete"); | ||
589 | 285 | #endif | ||
590 | 242 | 286 | ||
591 | 243 | /* Init some theme/icon stuff */ | 287 | /* Init some theme/icon stuff */ |
592 | 244 | gtk_icon_theme_append_search_path(gtk_icon_theme_get_default(), | 288 | gtk_icon_theme_append_search_path(gtk_icon_theme_get_default(), |
593 | @@ -286,12 +330,19 @@ | |||
594 | 286 | 330 | ||
595 | 287 | const gchar * name; | 331 | const gchar * name; |
596 | 288 | while ((name = g_dir_read_name(dir)) != NULL) { | 332 | while ((name = g_dir_read_name(dir)) != NULL) { |
597 | 333 | #ifdef INDICATOR_APPLET | ||
598 | 289 | if (!g_strcmp0(name, "libsession.so")) { | 334 | if (!g_strcmp0(name, "libsession.so")) { |
599 | 290 | continue; | 335 | continue; |
600 | 291 | } | 336 | } |
601 | 292 | if (!g_strcmp0(name, "libme.so")) { | 337 | if (!g_strcmp0(name, "libme.so")) { |
602 | 293 | continue; | 338 | continue; |
603 | 294 | } | 339 | } |
604 | 340 | #endif | ||
605 | 341 | #ifdef INDICATOR_APPLET_SESSION | ||
606 | 342 | if (g_strcmp0(name, "libsession.so") && g_strcmp0(name, "libme.so")) { | ||
607 | 343 | continue; | ||
608 | 344 | } | ||
609 | 345 | #endif | ||
610 | 295 | if (load_module(name, menubar)) { | 346 | if (load_module(name, menubar)) { |
611 | 296 | indicators_loaded++; | 347 | indicators_loaded++; |
612 | 297 | } | 348 | } |
Makes it so the majority of code is all in one file, then #defined off into the different applets that we need.