# Upstream: https://sourceforge.net/tracker/?func=detail&aid=3012036&group_id=180858&atid=894871 # Launchpad: https://bugs.edge.launchpad.net/ubuntu/+source/lxpanel/+bug/500053 Index: lxpanel-0.5.6/configure.ac =================================================================== --- lxpanel-0.5.6.orig/configure.ac 2010-07-20 13:37:18.000000000 +0200 +++ lxpanel-0.5.6/configure.ac 2010-07-22 23:32:46.000000000 +0200 @@ -24,6 +24,33 @@ AC_SUBST(PACKAGE_CFLAGS) AC_SUBST(PACKAGE_LIBS) +########################### +# Indicator Info +########################### +AC_ARG_ENABLE([indicator_support], + AS_HELP_STRING([--enable-indicator-support], + [enable plugin loading (default: disable)]), + indicator_support=$enableval, indicator_support="no") +AM_CONDITIONAL(ENABLE_INDICATOR_SUPPORT, test x"$indicator_support" = x"yes") + +if test "$indicator_support" != "no"; then + INDICATOR_REQUIRED_VERSION=0.3.0 + + PKG_CHECK_MODULES(APPLET, indicator >= $INDICATOR_REQUIRED_VERSION) + AC_SUBST(APPLET_CFLAGS) + + if test "x$with_localinstall" = "xyes"; then + INDICATORDIR="${libdir}/indicators/2/" + INDICATORICONSDIR="${datadir}/indicator-applet/icons/" + else + INDICATORDIR=`$PKG_CONFIG --variable=indicatordir indicator` + INDICATORICONSDIR=`$PKG_CONFIG --variable=iconsdir indicator` +fi + AC_SUBST(INDICATORDIR) + AC_SUBST(INDICATORICONSDIR) +fi + + pkg_modules="x11" PKG_CHECK_MODULES(X11, [$pkg_modules]) AC_SUBST(X11_LIBS) @@ -160,6 +187,7 @@ plugin_kbled= plugin_thermal= plugin_cpufreq= +plugin_indicator= AC_MSG_CHECKING([which plugins should be built dynamically]) AC_ARG_WITH(plugins, @@ -195,6 +223,7 @@ plugin_xkb=xkb plugin_thermal=thermal plugin_cpufreq=cpufreq + plugin_indicator=indicator AC_MSG_RESULT(all) else @@ -233,6 +262,9 @@ cpufreq) plugin_cpufreq=cpufreq ;; + cpufreq) + plugin_indicator=indicator + ;; *) echo "Unknown plugin $plugin." exit 1 @@ -253,6 +285,12 @@ dnl force OSS plugin to plugin_volume= fi + +dnl Exclude indicator support when there is no support. +if test x"$indicator_support" = "xno"; then + plugin_indicator= +fi + PLUGINS_LIST="\ $plugin_netstatus \ $plugin_volume \ @@ -263,7 +301,8 @@ $plugin_kbled \ $plugin_xkb \ $plugin_thermal \ - $plugin_cpufreq" + $plugin_cpufreq \ + $plugin_indicator" AC_SUBST(PLUGINS_LIST) @@ -327,6 +366,7 @@ src/plugins/xkb/Makefile src/plugins/thermal/Makefile src/plugins/cpufreq/Makefile + src/plugins/indicator/Makefile po/Makefile.in data/Makefile data/default/panels/panel @@ -370,6 +410,9 @@ if test x"$plugin_cpufreq" != x; then AC_MSG_RESULT([ cpufreq - CpuFreq frontend]) fi + if test x"$plugin_indicator" != x; then + AC_MSG_RESULT([ indicator - Indicator support]) + fi else echo Dynamic loader for plugins....... : disabled. fi Index: lxpanel-0.5.6/src/plugins/indicator/Makefile.am =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ lxpanel-0.5.6/src/plugins/indicator/Makefile.am 2010-07-22 23:32:46.000000000 +0200 @@ -0,0 +1,23 @@ +INCLUDES = \ + -I. \ + -I$(top_srcdir)/src \ + -DINDICATOR_DIR=\""$(INDICATORDIR)"\" \ + -DINDICATOR_ICONS_DIR=\""$(INDICATORICONSDIR)"\" \ + $(PACKAGE_CFLAGS) \ + $(APPLET_CFLAGS) \ + $(G_CAST_CHECKS) + +module_LTLIBRARIES = indicator.la + +moduledir = $(libdir)/lxpanel/plugins + +indicator_la_SOURCES = \ + indicator.c + +indicator_la_LIBADD = \ + $(PACKAGE_LIBS) \ + $(APPLET_LIBS) + +indicator_la_LDFLAGS = \ + -module \ + @LXPANEL_MODULE@ Index: lxpanel-0.5.6/src/plugins/indicator/indicator.c =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ lxpanel-0.5.6/src/plugins/indicator/indicator.c 2010-07-22 23:32:46.000000000 +0200 @@ -0,0 +1,273 @@ +/* +Copyright 2010 Julien Lavergne + +Based on indicator-applet : +Copyright 2009 Canonical Ltd. + +Authors: + Ted Gould + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +version 3.0 as published by the Free Software Foundation. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License version 3.0 for more details. + +You should have received a copy of the GNU General Public +License along with this library. If not, see +. +*/ + +#include "plugin.h" +#include + +#include +#include + +#define ENTRY_DATA_NAME "indicator-custom-entry-data" + +typedef struct { + + Plugin * plugin; /* Back pointer to plugin */ + + IndicatorObject *io; /* Indicators applets */ + + GList *images; /* List of images of applets */ + GList *menus; /* List of menus of applets */ + + GtkWidget * menubar; /* Displayed menubar */ + + +} IndicatorPlugin; + +static void +entry_added (IndicatorObject * io, IndicatorObjectEntry * entry, gpointer user_data) +{ + g_debug("Signal: Entry Added"); + + GtkWidget * menuitem = gtk_menu_item_new(); + GtkWidget * hbox = gtk_hbox_new(FALSE, 3); + + if (entry->image != NULL) + { + gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(entry->image), FALSE, FALSE, 0); + } + if (entry->label != NULL) + { + gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(entry->label), FALSE, FALSE, 0); + } + gtk_container_add(GTK_CONTAINER(menuitem), hbox); + gtk_widget_show(hbox); + + if (entry->menu != NULL) + { + gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), GTK_WIDGET(entry->menu)); + } + + gtk_menu_shell_append(GTK_MENU_SHELL(user_data), menuitem); + gtk_widget_show(menuitem); + + g_object_set_data(G_OBJECT(menuitem), ENTRY_DATA_NAME, entry); + + return; +} + +static void +entry_removed_cb (GtkWidget * widget, gpointer userdata) +{ + gpointer data = g_object_get_data(G_OBJECT(widget), ENTRY_DATA_NAME); + + if (data != userdata) + { + return; + } + + gtk_widget_destroy(widget); + return; +} + +static void +entry_removed (IndicatorObject * io, IndicatorObjectEntry * entry, gpointer user_data) +{ + g_debug("Signal: Entry Removed"); + + gtk_container_foreach(GTK_CONTAINER(user_data), entry_removed_cb, entry); + + return; +} + +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); + + /* Build the object for the module */ + + gchar *fullpath = g_build_filename(INDICATOR_DIR, name, NULL); + + g_debug("Full path: %s", fullpath); + + IndicatorObject * io = indicator_object_new_from_file(fullpath); + g_free(fullpath); + + /* Connect to it's signals */ + g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED, G_CALLBACK(entry_added), menu); + g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED, G_CALLBACK(entry_removed), menu); + + /* Work on the entries */ + 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; + entry_added(io, entrydata, menu); + } + + g_list_free(entries); + + return TRUE; +} + +/* Plugin constructor. */ +static int indicator_constructor(Plugin * p, char ** fp) +{ + /* Allocate and initialize plugin context and set into Plugin private data pointer. */ + IndicatorPlugin * indicator = g_new0(IndicatorPlugin, 1); + indicator->plugin = p; + p->priv = indicator; + + /* Allocate top level widget and set into Plugin widget pointer. */ + p->pwid = gtk_event_box_new(); + + 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 (p->pwid), "fast-user-switch-applet"); + + /* Allocate icon as a child of top level. */ + indicator->menubar = gtk_menu_bar_new(); + GTK_WIDGET_SET_FLAGS (indicator->menubar, GTK_WIDGET_FLAGS(indicator->menubar) | GTK_CAN_FOCUS); + gtk_widget_set_name(GTK_WIDGET (indicator->menubar), "fast-user-switch-menubar"); + gtk_container_set_border_width(GTK_CONTAINER(indicator->menubar), 0); + + /* load 'em */ + gint indicators_loaded = 0; + + 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) + { + load_module(name, indicator->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(p->pwid), item); + gtk_widget_show(item); + } + else + { + gtk_container_add(GTK_CONTAINER(p->pwid), indicator->menubar); + + /* Set background to default. */ + gtk_widget_set_style(indicator->menubar, p->panel->defstyle); + /*plugin_widget_set_background(indicator->menubar, p->panel);*/ + gtk_widget_show(indicator->menubar); + } + + /* Update the display, show the widget, and return. */ + gtk_widget_show_all(p->pwid); + return 1; +} + +/* Plugin destructor. */ +static void indicator_destructor(Plugin * p) +{ + IndicatorPlugin * indicator = (IndicatorPlugin *) p->priv; + + /* Deallocate all memory. */ + g_free(indicator); +} + +/* Callback when panel configuration changes. */ +static void indicator_panel_configuration_changed(Plugin * p) +{ + /*TODO + Update when configuration changed + */ + + /* Determine if the orientation changed in a way that requires action. */ + /* + GtkWidget * sep = gtk_bin_get_child(GTK_BIN(p->pwid)); + if (GTK_IS_VSEPARATOR(sep)) + { + if (p->panel->orientation == GTK_ORIENTATION_HORIZONTAL) + return; + } + else + { + if (p->panel->orientation == GTK_ORIENTATION_VERTICAL) + return; + } +*/ +} + +/* Plugin descriptor. */ +PluginClass indicator_plugin_class = { + + PLUGINCLASS_VERSIONING, + + type : "indicator", + name : N_("Indicator applets"), + version: "1.0", + description : N_("Add indicator applets to the panel"), + + constructor : indicator_constructor, + destructor : indicator_destructor, + config : NULL, + save : NULL, + panel_configuration_changed : indicator_panel_configuration_changed +};