ayatana-commits team mailing list archive
-
ayatana-commits team
-
Mailing list archive
-
Message #00721
[Merge] lp:~ted/indicator-applet/code-unification into lp:indicator-applet
Ted Gould has proposed merging lp:~ted/indicator-applet/code-unification into lp:indicator-applet.
Requested reviews:
Indicator Applet Developers (indicator-applet-developers)
Makes it so the majority of code is all in one file, then #defined off into the different applets that we need.
--
https://code.launchpad.net/~ted/indicator-applet/code-unification/+merge/16809
Your team ayatana-commits is subscribed to branch lp:indicator-applet.
=== modified file '.bzrignore'
--- .bzrignore 2009-08-18 15:50:35 +0000
+++ .bzrignore 2010-01-04 20:49:11 +0000
@@ -104,3 +104,6 @@
data/GNOME_IndicatorAppletSUS.server.in
src-session/indicator-applet-no-sus
src-session/indicator-applet-session
+src/indicator-applet-complete
+src/indicator-applet-session
+data/GNOME_IndicatorAppletComplete.server
=== modified file 'Makefile.am'
--- Makefile.am 2009-08-24 18:22:32 +0000
+++ Makefile.am 2010-01-04 20:49:11 +0000
@@ -1,7 +1,6 @@
SUBDIRS = \
src \
- src-session \
data \
po
=== modified file 'configure.ac'
--- configure.ac 2009-12-10 17:27:22 +0000
+++ configure.ac 2010-01-04 20:49:11 +0000
@@ -124,7 +124,6 @@
AC_OUTPUT([
Makefile
src/Makefile
-src-session/Makefile
data/Makefile
po/Makefile.in
])
=== added file 'data/GNOME_IndicatorAppletComplete.server.in.in'
--- data/GNOME_IndicatorAppletComplete.server.in.in 1970-01-01 00:00:00 +0000
+++ data/GNOME_IndicatorAppletComplete.server.in.in 2010-01-04 20:49:11 +0000
@@ -0,0 +1,28 @@
+<oaf_info>
+ <oaf_server iid="OAFIID:GNOME_IndicatorAppletComplete_Factory" type="exe"
+ location="@LIBEXECDIR@/indicator-applet-complete">
+
+ <oaf_attribute name="repo_ids" type="stringv">
+ <item value="IDL:Bonobo/GenericFactory:1.0"/>
+ <item value="IDL:Bonobo/Unknown:1.0"/>
+ </oaf_attribute>
+ <oaf_attribute name="name" type="string" value="Indicator Applet Complete Factory"/>
+ <oaf_attribute name="description" type="string" value="Indicator Applet Complete Factory"/>
+ <oaf_attribute name="bonobo:environment" type="stringv">
+ <item value="DBUS_SESSION_BUS_ADDRESS"/>
+ </oaf_attribute>
+ </oaf_server>
+
+ <oaf_server iid="OAFIID:GNOME_IndicatorAppletComplete" type="factory"
+ location="OAFIID:GNOME_IndicatorAppletComplete_Factory">
+
+ <oaf_attribute name="repo_ids" type="stringv">
+ <item value="IDL:GNOME/Vertigo/PanelAppletShell:1.0"/>
+ <item value="IDL:Bonobo/Control:1.0"/>
+ <item value="IDL:Bonobo/Unknown:1.0"/>
+ </oaf_attribute>
+ <oaf_attribute name="name" type="string" _value="Indicator Applet Complete"/>
+ <oaf_attribute name="description" type="string" _value="A unified applet containing all of the indicators."/>
+ <oaf_attribute name="panel:icon" type="string" value="indicator-applet"/>
+ </oaf_server>
+</oaf_info>
=== modified file 'data/Makefile.am'
--- data/Makefile.am 2009-08-07 17:47:02 +0000
+++ data/Makefile.am 2010-01-04 20:49:11 +0000
@@ -8,6 +8,7 @@
$(libdir)/bonobo/servers
server_in_files = \
GNOME_IndicatorApplet.server.in \
+ GNOME_IndicatorAppletComplete.server.in \
GNOME_FastUserSwitchApplet.server.in
server_DATA = \
$(server_in_files:.server.in=.server)
@@ -68,6 +69,7 @@
EXTRA_DIST = \
$(icons_DATA) \
GNOME_IndicatorApplet.server.in.in \
+ GNOME_IndicatorAppletComplete.server.in.in \
GNOME_FastUserSwitchApplet.server.in.in \
$(schema_in_files)
=== modified file 'po/POTFILES.in'
--- po/POTFILES.in 2009-08-18 16:03:40 +0000
+++ po/POTFILES.in 2010-01-04 20:49:11 +0000
@@ -1,6 +1,6 @@
[encoding: UTF-8]
data/GNOME_IndicatorApplet.server.in.in
+data/GNOME_IndicatorAppletComplete.server.in.in
data/GNOME_FastUserSwitchApplet.server.in.in
data/indicator-applet.schemas.in
src/applet-main.c
-src-session/applet-main.c
=== removed directory 'src-session'
=== removed file 'src-session/Makefile.am'
--- src-session/Makefile.am 2009-08-24 18:22:32 +0000
+++ src-session/Makefile.am 1970-01-01 00:00:00 +0000
@@ -1,17 +0,0 @@
-
-libexec_PROGRAMS = \
- indicator-applet-session
-
-indicator_applet_session_CFLAGS = \
- -DG_LOG_DOMAIN=\""Indicator-Applet"\" \
- -DDATADIR=\""$(datadir)"\" \
- -DINDICATOR_DIR=\""$(INDICATORDIR)"\" \
- -DINDICATOR_ICONS_DIR=\""$(INDICATORICONSDIR)"\" \
- -I$(srcdir)/.. \
- $(APPLET_CFLAGS)
-
-indicator_applet_session_SOURCES = \
- applet-main.c
-
-indicator_applet_session_LDADD = \
- $(APPLET_LIBS)
=== removed file 'src-session/applet-main.c'
--- src-session/applet-main.c 2009-12-24 16:43:37 +0000
+++ src-session/applet-main.c 1970-01-01 00:00:00 +0000
@@ -1,320 +0,0 @@
-/*
-A small wrapper utility to load indicators and put them as menu items
-into the gnome-panel using it's applet interface.
-
-Copyright 2009 Canonical Ltd.
-
-Authors:
- Ted Gould <ted@xxxxxxxxxxxxx>
-
-This program is free software: you can redistribute it and/or modify it
-under the terms of the GNU General Public License version 3, as published
-by the Free Software Foundation.
-
-This program is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranties of
-MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
-PURPOSE. See the GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License along
-with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include <config.h>
-#include <panel-applet.h>
-
-#include "libindicator/indicator-object.h"
-
-static gboolean applet_fill_cb (PanelApplet * applet, const gchar * iid, gpointer data);
-
-
-static void cw_panel_background_changed (PanelApplet *applet,
- PanelAppletBackgroundType type,
- GdkColor *colour,
- GdkPixmap *pixmap,
- GtkWidget *menubar);
-
-/*************
- * main
- * ***********/
-
-PANEL_APPLET_BONOBO_FACTORY ("OAFIID:GNOME_FastUserSwitchApplet_Factory",
- PANEL_TYPE_APPLET,
- "indicator-applet-session", "0",
- applet_fill_cb, NULL);
-
-/*************
- * init function
- * ***********/
-static gboolean
-load_module (const gchar * name, GtkWidget * menu)
-{
- g_debug("Looking at Module: %s", name);
- g_return_val_if_fail(name != NULL, FALSE);
-
- if (!g_str_has_suffix(name, G_MODULE_SUFFIX)) {
- return FALSE;
- }
-
- g_debug("Loading Module: %s", name);
-
- gchar * fullpath = g_build_filename(INDICATOR_DIR, name, NULL);
- IndicatorObject * io = indicator_object_new_from_file(fullpath);
- g_free(fullpath);
-
- GList * entries = indicator_object_get_entries(io);
- GList * entry = NULL;
-
- for (entry = entries; entry != NULL; entry = g_list_next(entry)) {
- IndicatorObjectEntry * entrydata = (IndicatorObjectEntry *)entry->data;
-
- GtkWidget * menuitem = gtk_menu_item_new();
- GtkWidget * hbox = gtk_hbox_new(FALSE, 3);
- if (entrydata->image != NULL) {
- gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(entrydata->image), FALSE, FALSE, 0);
- }
- if (entrydata->label != NULL) {
- gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(entrydata->label), FALSE, FALSE, 0);
- }
- gtk_container_add(GTK_CONTAINER(menuitem), hbox);
- gtk_widget_show(hbox);
-
- if (entrydata->menu != NULL) {
- gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), GTK_WIDGET(entrydata->menu));
- }
-
- gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
- gtk_widget_show(menuitem);
- }
-
- g_list_free(entries);
-
- return TRUE;
-}
-
-static gboolean
-menubar_press (GtkWidget * widget,
- GdkEventButton *event,
- gpointer data)
-{
- if (event->button != 1) {
- g_signal_stop_emission_by_name(widget, "button-press-event");
- }
-
- return FALSE;
-}
-
-static gboolean
-menubar_on_expose (GtkWidget * widget,
- GdkEventExpose *event,
- GtkWidget * menubar)
-{
- if (GTK_WIDGET_HAS_FOCUS(menubar))
- gtk_paint_focus(widget->style, widget->window, GTK_WIDGET_STATE(menubar),
- NULL, widget, "menubar-applet", 0, 0, -1, -1);
-
- return FALSE;
-}
-
-static void
-about_cb (BonoboUIComponent *ui_container,
- gpointer data,
- const gchar *cname)
-{
- static const gchar *authors[] = {
- "Ted Gould <ted@xxxxxxxxxxxxx>",
- NULL
- };
-
- static gchar *license[] = {
- N_("This program is free software: you can redistribute it and/or modify it "
- "under the terms of the GNU General Public License version 3, as published "
- "by the Free Software Foundation."),
- N_("This program is distributed in the hope that it will be useful, but "
- "WITHOUT ANY WARRANTY; without even the implied warranties of "
- "MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR "
- "PURPOSE. See the GNU General Public License for more details."),
- N_("You should have received a copy of the GNU General Public License along "
- "with this program. If not, see <http://www.gnu.org/licenses/>."),
- NULL
- };
- gchar *license_i18n;
-
- license_i18n = g_strconcat (_(license[0]), "\n\n", _(license[1]), "\n\n", _(license[2]), NULL);
-
- gtk_show_about_dialog(NULL,
- "version", VERSION,
- "copyright", "Copyright \xc2\xa9 2009 Canonical, Ltd.",
- "comments", _("A place to adjust your status, change users or exit your session."),
- "authors", authors,
- "license", license_i18n,
- "wrap-license", TRUE,
- "translator-credits", _("translator-credits"),
- "logo-icon-name", "indicator-applet",
- "icon-name", "indicator-applet",
- "website", "http://launchpad.net/indicator-applet",
- "website-label", _("Indicator Applet Website"),
- NULL
- );
-
- g_free (license_i18n);
-
- return;
-}
-
-#ifdef N_
-#undef N_
-#endif
-#define N_(x) x
-
-static gboolean
-applet_fill_cb (PanelApplet * applet, const gchar * iid, gpointer data)
-{
- static const BonoboUIVerb menu_verbs[] = {
- BONOBO_UI_VERB ("IndicatorAppletAbout", about_cb),
- BONOBO_UI_VERB_END
- };
- static const gchar * menu_xml =
- "<popup name=\"button3\">"
- "<menuitem name=\"About Item\" verb=\"IndicatorAppletAbout\" _label=\"" N_("_About") "\" pixtype=\"stock\" pixname=\"gtk-about\"/>"
- "</popup>";
-
- GtkWidget *menubar;
- gint i;
- gint indicators_loaded = 0;
- static gboolean first_time = FALSE;
-
- /* check if we are running stracciatella session */
- if (g_strcmp0(g_getenv("GDMSESSION"), "gnome-stracciatella") == 0) {
- g_debug("Running stracciatella GNOME session, disabling myself");
- return TRUE;
- }
-
- if (!first_time)
- {
- first_time = TRUE;
- g_set_application_name(_("Indicator Applet Session"));
- }
-
- /* Set panel options */
- gtk_container_set_border_width(GTK_CONTAINER (applet), 0);
- panel_applet_set_flags(applet, PANEL_APPLET_EXPAND_MINOR);
- panel_applet_setup_menu(applet, menu_xml, menu_verbs, NULL);
- atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (applet)),
- "indicator-applet-session");
-
- /* Init some theme/icon stuff */
- gtk_icon_theme_append_search_path(gtk_icon_theme_get_default(),
- INDICATOR_ICONS_DIR);
- /* g_debug("Icons directory: %s", INDICATOR_ICONS_DIR); */
- gtk_rc_parse_string (
- "style \"indicator-applet-style\"\n"
- "{\n"
- " GtkMenuBar::shadow-type = none\n"
- " GtkMenuBar::internal-padding = 0\n"
- " GtkWidget::focus-line-width = 0\n"
- " GtkWidget::focus-padding = 0\n"
- "}\n"
- "style \"indicator-applet-menubar-style\"\n"
- "{\n"
- " GtkMenuBar::shadow-type = none\n"
- " GtkMenuBar::internal-padding = 0\n"
- " GtkWidget::focus-line-width = 0\n"
- " GtkWidget::focus-padding = 0\n"
- " GtkMenuItem::horizontal-padding = 0\n"
- "}\n"
- "style \"indicator-applet-menuitem-style\"\n"
- "{\n"
- " GtkWidget::focus-line-width = 0\n"
- " GtkWidget::focus-padding = 0\n"
- " GtkMenuItem::horizontal-padding = 0\n"
- "}\n"
- "widget \"*.fast-user-switch-applet\" style \"indicator-applet-style\""
- "widget \"*.fast-user-switch-menuitem\" style \"indicator-applet-menuitem-style\""
- "widget \"*.fast-user-switch-menubar\" style \"indicator-applet-menubar-style\"");
- //gtk_widget_set_name(GTK_WIDGET (applet), "indicator-applet-menubar");
- gtk_widget_set_name(GTK_WIDGET (applet), "fast-user-switch-applet");
-
- /* Build menubar */
- menubar = gtk_menu_bar_new();
- GTK_WIDGET_SET_FLAGS (menubar, GTK_WIDGET_FLAGS(menubar) | GTK_CAN_FOCUS);
- gtk_widget_set_name(GTK_WIDGET (menubar), "fast-user-switch-menubar");
- g_signal_connect(menubar, "button-press-event", G_CALLBACK(menubar_press), NULL);
- g_signal_connect_after(menubar, "expose-event", G_CALLBACK(menubar_on_expose), menubar);
- gtk_container_set_border_width(GTK_CONTAINER(menubar), 0);
-
- /* load 'em */
- if (g_file_test(INDICATOR_DIR, (G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR))) {
- GDir * dir = g_dir_open(INDICATOR_DIR, 0, NULL);
-
- const gchar * name;
- while ((name = g_dir_read_name(dir)) != NULL) {
- if (g_strcmp0(name, "libsession.so") && g_strcmp0(name, "libme.so")) {
- continue;
- }
- if (load_module(name, menubar)) {
- indicators_loaded++;
- }
- }
- g_dir_close (dir);
- }
-
- if (indicators_loaded == 0) {
- /* A label to allow for click through */
- GtkWidget * item = gtk_label_new(_("No Indicators"));
- gtk_container_add(GTK_CONTAINER(applet), item);
- gtk_widget_show(item);
- } else {
- gtk_container_add(GTK_CONTAINER(applet), menubar);
- panel_applet_set_background_widget(applet, menubar);
- gtk_widget_show(menubar);
- }
-
- /* Background of applet */
- g_signal_connect(applet, "change-background",
- G_CALLBACK(cw_panel_background_changed), menubar);
-
- gtk_widget_show(GTK_WIDGET(applet));
-
- return TRUE;
-}
-
-static void
-cw_panel_background_changed (PanelApplet *applet,
- PanelAppletBackgroundType type,
- GdkColor *colour,
- GdkPixmap *pixmap,
- GtkWidget *menubar)
-{
- GtkRcStyle *rc_style;
- GtkStyle *style;
-
- /* reset style */
- gtk_widget_set_style(GTK_WIDGET (applet), NULL);
- gtk_widget_set_style(menubar, NULL);
- rc_style = gtk_rc_style_new ();
- gtk_widget_modify_style(GTK_WIDGET (applet), rc_style);
- gtk_widget_modify_style(menubar, rc_style);
- gtk_rc_style_unref(rc_style);
-
- switch (type)
- {
- case PANEL_NO_BACKGROUND:
- break;
- case PANEL_COLOR_BACKGROUND:
- gtk_widget_modify_bg(GTK_WIDGET (applet), GTK_STATE_NORMAL, colour);
- gtk_widget_modify_bg(menubar, GTK_STATE_NORMAL, colour);
- break;
-
- case PANEL_PIXMAP_BACKGROUND:
- style = gtk_style_copy(GTK_WIDGET (applet)->style);
- if (style->bg_pixmap[GTK_STATE_NORMAL])
- g_object_unref(style->bg_pixmap[GTK_STATE_NORMAL]);
- style->bg_pixmap[GTK_STATE_NORMAL] = g_object_ref (pixmap);
- gtk_widget_set_style(GTK_WIDGET (applet), style);
- gtk_widget_set_style(GTK_WIDGET (menubar), style);
- g_object_unref(style);
- break;
- }
-}
-
=== modified file 'src/Makefile.am'
--- src/Makefile.am 2009-08-24 18:22:32 +0000
+++ src/Makefile.am 2010-01-04 20:49:11 +0000
@@ -1,17 +1,50 @@
libexec_PROGRAMS = \
- indicator-applet
+ indicator-applet \
+ indicator-applet-session \
+ indicator-applet-complete
indicator_applet_CFLAGS = \
-DG_LOG_DOMAIN=\""Indicator-Applet"\" \
-DDATADIR=\""$(datadir)"\" \
-DINDICATOR_DIR=\""$(INDICATORDIR)"\" \
-DINDICATOR_ICONS_DIR=\""$(INDICATORICONSDIR)"\" \
+ -DINDICATOR_APPLET \
-I$(srcdir)/.. \
$(APPLET_CFLAGS)
-indicator_applet_SOURCES = \
+indicator_applet_SOURCES = \
applet-main.c
indicator_applet_LDADD = \
$(APPLET_LIBS)
+
+indicator_applet_session_CFLAGS = \
+ -DG_LOG_DOMAIN=\""Indicator-Applet-Session"\" \
+ -DDATADIR=\""$(datadir)"\" \
+ -DINDICATOR_DIR=\""$(INDICATORDIR)"\" \
+ -DINDICATOR_ICONS_DIR=\""$(INDICATORICONSDIR)"\" \
+ -DINDICATOR_APPLET_SESSION \
+ -I$(srcdir)/.. \
+ $(APPLET_CFLAGS)
+
+indicator_applet_session_SOURCES = \
+ applet-main.c
+
+indicator_applet_session_LDADD = \
+ $(APPLET_LIBS)
+
+indicator_applet_complete_CFLAGS = \
+ -DG_LOG_DOMAIN=\""Indicator-Applet-Complete"\" \
+ -DDATADIR=\""$(datadir)"\" \
+ -DINDICATOR_DIR=\""$(INDICATORDIR)"\" \
+ -DINDICATOR_ICONS_DIR=\""$(INDICATORICONSDIR)"\" \
+ -DINDICATOR_APPLET_COMPLETE \
+ -I$(srcdir)/.. \
+ $(APPLET_CFLAGS)
+
+indicator_applet_complete_SOURCES = \
+ applet-main.c
+
+indicator_applet_complete_LDADD = \
+ $(APPLET_LIBS)
=== modified file 'src/applet-main.c'
--- src/applet-main.c 2010-01-04 02:23:10 +0000
+++ src/applet-main.c 2010-01-04 20:49:11 +0000
@@ -40,10 +40,24 @@
* main
* ***********/
+#ifdef INDICATOR_APPLET
PANEL_APPLET_BONOBO_FACTORY ("OAFIID:GNOME_IndicatorApplet_Factory",
PANEL_TYPE_APPLET,
"indicator-applet", "0",
applet_fill_cb, NULL);
+#endif
+#ifdef INDICATOR_APPLET_SESSION
+PANEL_APPLET_BONOBO_FACTORY ("OAFIID:GNOME_FastUserSwitchApplet_Factory",
+ PANEL_TYPE_APPLET,
+ "indicator-applet-session", "0",
+ applet_fill_cb, NULL);
+#endif
+#ifdef INDICATOR_APPLET_COMPLETE
+PANEL_APPLET_BONOBO_FACTORY ("OAFIID:GNOME_IndicatorAppletComplete_Factory",
+ PANEL_TYPE_APPLET,
+ "indicator-applet-complete", "0",
+ applet_fill_cb, NULL);
+#endif
/*************
* init function
@@ -188,7 +202,11 @@
gtk_show_about_dialog(NULL,
"version", VERSION,
"copyright", "Copyright \xc2\xa9 2009 Canonical, Ltd.",
+#ifdef INDICATOR_APPLET_SESSION
+ "comments", _("A place to adjust your status, change users or exit your session."),
+#else
"comments", _("An applet to hold all of the system indicators."),
+#endif
"authors", authors,
"license", license_i18n,
"wrap-license", TRUE,
@@ -227,18 +245,44 @@
gint indicators_loaded = 0;
static gboolean first_time = FALSE;
+#ifdef INDICATOR_APPLET_SESSION
+ /* check if we are running stracciatella session */
+ if (g_strcmp0(g_getenv("GDMSESSION"), "gnome-stracciatella") == 0) {
+ g_debug("Running stracciatella GNOME session, disabling myself");
+ return TRUE;
+ }
+#endif
+
if (!first_time)
{
first_time = TRUE;
+#ifdef INDICATOR_APPLET
g_set_application_name(_("Indicator Applet"));
+#endif
+#ifdef INDICATOR_APPLET_SESSION
+ g_set_application_name(_("Indicator Applet Session"));
+#endif
+#ifdef INDICATOR_APPLET_COMPLETE
+ g_set_application_name(_("Indicator Applet Complete"));
+#endif
}
/* Set panel options */
gtk_container_set_border_width(GTK_CONTAINER (applet), 0);
panel_applet_set_flags(applet, PANEL_APPLET_EXPAND_MINOR);
panel_applet_setup_menu(applet, menu_xml, menu_verbs, NULL);
- atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (applet)),
- "indicator-applet");
+#ifdef INDICATOR_APPLET
+ atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (applet)),
+ "indicator-applet");
+#endif
+#ifdef INDICATOR_APPLET_SESSION
+ atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (applet)),
+ "indicator-applet-session");
+#endif
+#ifdef INDICATOR_APPLET_COMPLETE
+ atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (applet)),
+ "indicator-applet-complete");
+#endif
/* Init some theme/icon stuff */
gtk_icon_theme_append_search_path(gtk_icon_theme_get_default(),
@@ -286,12 +330,19 @@
const gchar * name;
while ((name = g_dir_read_name(dir)) != NULL) {
+#ifdef INDICATOR_APPLET
if (!g_strcmp0(name, "libsession.so")) {
continue;
}
if (!g_strcmp0(name, "libme.so")) {
continue;
}
+#endif
+#ifdef INDICATOR_APPLET_SESSION
+ if (g_strcmp0(name, "libsession.so") && g_strcmp0(name, "libme.so")) {
+ continue;
+ }
+#endif
if (load_module(name, menubar)) {
indicators_loaded++;
}
Follow ups