This is an automated email from the git hooks/post-receive script. eric pushed a commit to branch master in repository xfce/xfce4-power-manager.
commit 5fc8c54b92843e692f43565abc7109c0c51ab24f Author: Eric Koegel <[email protected]> Date: Mon Jun 16 11:06:24 2014 +0300 LXDE battery plugin support (Bug 10929) Adds support for the battery plugin to be built and used in LXDE as the system tray icon was removed. Thanks to https://github.com/nandhp/multiload-nandhp as it was used as a complete example on how to easily do this. There may be a couple things that need to be added to make this have the same functionality as the Xfce plugin. --- configure.ac.in | 24 +++++- panel-plugins/Makefile.am | 10 ++- panel-plugins/battery/Makefile.am | 77 +++--------------- panel-plugins/battery/battery-button.c | 83 ++++++++++---------- panel-plugins/battery/battery-button.h | 10 +++ panel-plugins/battery/lxde/Makefile.am | 54 +++++++++++++ panel-plugins/battery/{ => lxde}/battery-plugin.c | 45 ++++++----- panel-plugins/battery/{ => xfce}/Makefile.am | 9 ++- panel-plugins/battery/{ => xfce}/battery-plugin.c | 11 ++- .../{ => xfce}/xfce4-battery-plugin.desktop.in.in | 0 po/POTFILES.in | 4 +- 11 files changed, 180 insertions(+), 147 deletions(-) diff --git a/configure.ac.in b/configure.ac.in index beb52f6..c7d4832 100644 --- a/configure.ac.in +++ b/configure.ac.in @@ -9,7 +9,7 @@ m4_define([xfpm_version], [xfpm_version_major().xfpm_version_minor().xfpm_versio AC_INIT([xfce4-power-manager],[xfpm_version],[http://bugzilla.xfce.org/]) AC_PREREQ([2.69]) -AM_INIT_AUTOMAKE([1.8 dist-bzip2 tar-ustar no-dist-gzip]) +AM_INIT_AUTOMAKE([1.8 dist-bzip2 tar-ustar no-dist-gzip subdir-objects]) AC_CONFIG_HEADERS([config.h]) AM_MAINTAINER_MODE() m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) @@ -65,6 +65,7 @@ m4_define([xfconf_minimum_version], [4.10.0]) m4_define([libxfce4ui_minimum_version],[4.10.0]) m4_define([libxfce4util_minimum_version],[4.10.0]) m4_define([libxfce4panel_minimum_version],[4.10.0]) +m4_define([lxdepanel_minimum_version],[0.5.6]) m4_define([libnotify_minimum_version], [0.4.1]) m4_define([upower_minimum_version], [0.9.7]) @@ -154,10 +155,18 @@ if test "x$ac_cv_enable_panel_plugins" = "xno"; then build_panel_plugins="no" else build_panel_plugins="yes" - XDT_CHECK_PACKAGE([LIBXFCE4PANEL], [libxfce4panel-1.0], - [libxfce4panel_minimum_version]) + + XDT_CHECK_OPTIONAL_PACKAGE([LIBXFCE4PANEL], [libxfce4panel-1.0], [libxfce4panel_minimum_version], + [xfce4panel], [To build plugin support for Xfce's panel]) + + XDT_CHECK_OPTIONAL_PACKAGE([LXDEPANEL], [lxpanel], [lxdepanel_minimum_version], + [lxdepanel],[To build plugin support for LXDE's panel]) + AC_CHECK_HEADERS([lxpanel/plugin.h lxpanel/panel.h]) + fi AM_CONDITIONAL([BUILD_PANEL_PLUGINS], [test "x$build_panel_plugins" = "xyes"]) +AM_CONDITIONAL([BUILD_XFCE_PLUGINS], [test "x$LIBXFCE4PANEL_FOUND" = "xyes"]) +AM_CONDITIONAL([BUILD_LXDE_PLUGINS], [test "x$LXDEPANEL_FOUND" = "xyes"]) #=======================================================# # Compile time default choice of backend # @@ -185,7 +194,6 @@ fi if test x$with_backend = xopenbsd; then AC_DEFINE(BACKEND_TYPE_OPENBSD, 1, [OpenBSD suspend/hibernate backend]) fi -AC_MSG_RESULT([$ac_network_manager]) #=======================================================# # Check for debugging support # @@ -213,6 +221,8 @@ src/Makefile settings/Makefile panel-plugins/Makefile panel-plugins/battery/Makefile +panel-plugins/battery/lxde/Makefile +panel-plugins/battery/xfce/Makefile panel-plugins/brightness/Makefile data/Makefile data/icons/Makefile @@ -234,6 +244,12 @@ echo "POLKIT: ${polkit}" echo "DPMS: ${enable_dpms}" echo "Network manager: ${ac_network_manager}" echo "Build panel plugins: ${build_panel_plugins}" +if test "x$LIBXFCE4PANEL_FOUND" = "xyes"; then +echo " Xfce plugins: yes" +fi +if test "x$LXDEPANEL_FOUND" = "xyes"; then +echo " LXDE plugins: yes" +fi echo "Backend: ${with_backend}" echo "Debug: ${enable_debug}" echo "Configuration finished, type make to compile" diff --git a/panel-plugins/Makefile.am b/panel-plugins/Makefile.am index 6376cbf..82edd1a 100644 --- a/panel-plugins/Makefile.am +++ b/panel-plugins/Makefile.am @@ -1,3 +1,7 @@ -SUBDIRS = \ - battery \ - brightness +if BUILD_XFCE_PLUGINS +brightness_dir = brightness +endif + +SUBDIRS = \ + battery \ + $(brightness_dir) diff --git a/panel-plugins/battery/Makefile.am b/panel-plugins/battery/Makefile.am index 47bf91f..f6094da 100644 --- a/panel-plugins/battery/Makefile.am +++ b/panel-plugins/battery/Makefile.am @@ -1,71 +1,12 @@ -AM_CPPFLAGS = \ - -I$(top_srcdir) \ - -DG_LOG_DOMAIN=\"xfce4-battery-plugin\" \ - -DPACKAGE_LOCALE_DIR=\"$(localedir)\" \ - $(PLATFORM_CPPFLAGS) -# -# xfce4 battery plugin -# -plugin_LTLIBRARIES = \ - libxfce4battery.la +if BUILD_XFCE_PLUGINS +xfce_dir = xfce +endif -plugindir = \ - $(libdir)/xfce4/panel/plugins +if BUILD_LXDE_PLUGINS +lxde_dir = lxde +endif -libxfce4battery_la_SOURCES = \ - battery-plugin.c \ - battery-button.c \ - battery-button.h - -libxfce4battery_la_CFLAGS = \ - -I$(top_srcdir) \ - -I$(top_srcdir)/src \ - -DLOCALEDIR=\"$(localedir)\" \ - $(LIBXFCE4PANEL_CFLAGS) \ - $(LIBXFCE4UTIL_CFLAGS) \ - $(LIBXFCE4UI_CFLAGS) \ - $(XFCONF_CFLAGS) \ - $(GTK_CFLAGS) \ - $(GLIB_CFLAGS) \ - $(PLATFORM_CPPFLAGS) \ - $(PLATFORM_CFLAGS) \ - $(DBUS_GLIB_CFLAGS) \ - $(UPOWER_CFLAGS) - -libxfce4battery_la_LDFLAGS = \ - -avoid-version \ - -module \ - -no-undefined \ - -export-symbols-regex '^xfce_panel_module_(preinit|init|construct)' \ - $(PLATFORM_LDFLAGS) - -libxfce4battery_la_LIBADD = \ - $(top_builddir)/common/libxfpmcommon.la \ - $(LIBXFCE4PANEL_LIBS) \ - $(LIBXFCE4UI_LIBS) \ - $(LIBXFCE4UTIL_LIBS) \ - $(XFCONF_LIBS) \ - $(GTK_LIBS) \ - $(GLIB_LIBS) \ - $(DBUS_GLIB_LIBS) \ - $(UPOWER_LIBS) - -# -# Desktop file -# -desktopdir = $(datadir)/xfce4/panel-plugins -desktop_in_in_files = xfce4-battery-plugin.desktop.in.in -desktop_in_files = $(desktop_in_in_files:.desktop.in.in=.desktop.in) -desktop_DATA = $(desktop_in_files:.desktop.in=.desktop) -@INTLTOOL_DESKTOP_RULE@ - -EXTRA_DIST = \ - $(desktop_in_in_files) - -CLEANFILES = \ - $(desktop_in_files) \ - $(desktop_DATA) - -%.desktop.in: %.desktop.in.in - sed -e "s,\@libdir\@,$(libdir),g" < $< > $@ +SUBDIRS = \ + $(xfce_dir) \ + $(lxde_dir) diff --git a/panel-plugins/battery/battery-button.c b/panel-plugins/battery/battery-button.c index 8d267a9..4713900 100644 --- a/panel-plugins/battery/battery-button.c +++ b/panel-plugins/battery/battery-button.c @@ -44,7 +44,12 @@ struct BatteryButtonPrivate { +#ifdef XFCE_PLUGIN XfcePanelPlugin *plugin; +#endif +#ifdef LXDE_PLUGIN + Plugin *plugin; +#endif XfconfChannel *channel; UpClient *upower; @@ -67,12 +72,6 @@ struct BatteryButtonPrivate UpDevice *display_device; }; -enum -{ - PROP_0, - PROP_PLUGIN -}; - typedef struct { GdkPixbuf *pix; /* Icon */ @@ -93,24 +92,6 @@ static void battery_button_show_menu (BatteryButton *button); static void battery_button_menu_add_device (BatteryButton *button, BatteryDevice *battery_device, gboolean append); -static void -battery_button_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - BatteryButton *button = BATTERY_BUTTON (object); - switch (prop_id) - { - case PROP_PLUGIN: - button->priv->plugin = XFCE_PANEL_PLUGIN (g_object_ref (g_value_get_object (value))); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - static BatteryDevice* get_display_device (BatteryButton *button) { @@ -407,19 +388,9 @@ battery_button_class_init (BatteryButtonClass *klass) GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); object_class->finalize = battery_button_finalize; - object_class->set_property = battery_button_set_property; widget_class->button_press_event = battery_button_press_event; - g_object_class_install_property (object_class, - PROP_PLUGIN, - g_param_spec_object ("plugin", - NULL, - NULL, - XFCE_TYPE_PANEL_PLUGIN, - G_PARAM_CONSTRUCT_ONLY | - G_PARAM_WRITABLE)); - g_type_class_add_private (klass, sizeof (BatteryButtonPrivate)); } @@ -440,7 +411,7 @@ battery_button_init (BatteryButton *button) } else { - button->priv->channel = xfconf_channel_get ("xfce4-power-manager"); + button->priv->channel = xfconf_channel_get ("xfce4-power-manager"); } /* Sane defaults for the panel icon */ @@ -462,16 +433,31 @@ battery_button_finalize (GObject *object) g_signal_handlers_disconnect_by_data (button->priv->upower, button); +#ifdef XFCE_PLUGIN g_object_unref (button->priv->plugin); +#endif G_OBJECT_CLASS (battery_button_parent_class)->finalize (object); } GtkWidget * +#ifdef XFCE_PLUGIN battery_button_new (XfcePanelPlugin *plugin) +#endif +#ifdef LXDE_PLUGIN +battery_button_new (Plugin *plugin) +#endif { BatteryButton *button = NULL; - button = g_object_new (BATTERY_TYPE_BUTTON, "plugin", plugin, NULL); + button = g_object_new (BATTERY_TYPE_BUTTON, NULL, NULL); + +#ifdef XFCE_PLUGIN + button->priv->plugin = XFCE_PANEL_PLUGIN (g_object_ref (plugin)); +#endif +#ifdef LXDE_PLUGIN + button->priv->plugin = plugin; +#endif + return GTK_WIDGET (button); } @@ -508,6 +494,7 @@ battery_button_press_event (GtkWidget *widget, GdkEventButton *event) return TRUE; } +#ifdef XFCE_PLUGIN static gboolean battery_button_size_changed_cb (XfcePanelPlugin *plugin, gint size, BatteryButton *button) { @@ -516,6 +503,7 @@ battery_button_size_changed_cb (XfcePanelPlugin *plugin, gint size, BatteryButto g_return_val_if_fail (BATTERY_IS_BUTTON (button), FALSE); g_return_val_if_fail (XFCE_IS_PANEL_PLUGIN (plugin), FALSE); + size /= xfce_panel_plugin_get_nrows (plugin); width = size -2 - 2* MAX(gtk_widget_get_style(GTK_WIDGET(button))->xthickness, gtk_widget_get_style(GTK_WIDGET(button))->ythickness); @@ -531,6 +519,7 @@ battery_button_free_data_cb (XfcePanelPlugin *plugin, BatteryButton *button) { gtk_widget_destroy (GTK_WIDGET (button)); } +#endif static void help_cb (GtkMenuItem *menuitem, gpointer user_data) @@ -545,8 +534,10 @@ battery_button_show (BatteryButton *button) g_return_if_fail (BATTERY_IS_BUTTON (button)); +#ifdef XFCE_PLUGIN xfce_panel_plugin_add_action_widget (button->priv->plugin, GTK_WIDGET (button)); xfce_panel_plugin_set_small (button->priv->plugin, TRUE); +#endif button->priv->panel_icon_image = gtk_image_new (); gtk_container_add (GTK_CONTAINER (button), button->priv->panel_icon_image); @@ -557,13 +548,15 @@ battery_button_show (BatteryButton *button) gtk_widget_show (mi); g_signal_connect (mi, "activate", G_CALLBACK (help_cb), button); +#ifdef XFCE_PLUGIN xfce_panel_plugin_menu_insert_item (button->priv->plugin, GTK_MENU_ITEM (mi)); g_signal_connect (button->priv->plugin, "size-changed", - G_CALLBACK (battery_button_size_changed_cb), button); + G_CALLBACK (battery_button_size_changed_cb), button); g_signal_connect (button->priv->plugin, "free-data", - G_CALLBACK (battery_button_free_data_cb), button); + G_CALLBACK (battery_button_free_data_cb), button); +#endif gtk_widget_show_all (GTK_WIDGET(button)); battery_button_set_tooltip (button); @@ -686,9 +679,13 @@ battery_button_show_menu (BatteryButton *button) gtk_menu_popup (GTK_MENU (menu), NULL, - NULL, - xfce_panel_plugin_position_menu, - button->priv->plugin, - 0, - gtk_get_current_event_time ()); + NULL, +#ifdef XFCE_PLUGIN + xfce_panel_plugin_position_menu, +#else + NULL, +#endif + button->priv->plugin, + 0, + gtk_get_current_event_time ()); } diff --git a/panel-plugins/battery/battery-button.h b/panel-plugins/battery/battery-button.h index d2be8b6..5e35ef4 100644 --- a/panel-plugins/battery/battery-button.h +++ b/panel-plugins/battery/battery-button.h @@ -23,7 +23,12 @@ #include <glib-object.h> #include <gtk/gtk.h> +#ifdef XFCE_PLUGIN #include <libxfce4panel/xfce-panel-plugin.h> +#endif +#ifdef LXDE_PLUGIN +#include <lxpanel/plugin.h> +#endif G_BEGIN_DECLS @@ -48,7 +53,12 @@ typedef struct GType battery_button_get_type (void) G_GNUC_CONST; +#ifdef XFCE_PLUGIN GtkWidget *battery_button_new (XfcePanelPlugin *plugin); +#endif +#ifdef LXDE_PLUGIN +GtkWidget *battery_button_new (Plugin *plugin); +#endif void battery_button_show (BatteryButton *button); diff --git a/panel-plugins/battery/lxde/Makefile.am b/panel-plugins/battery/lxde/Makefile.am new file mode 100644 index 0000000..fbb8050 --- /dev/null +++ b/panel-plugins/battery/lxde/Makefile.am @@ -0,0 +1,54 @@ +AM_CPPFLAGS = \ + -I$(top_srcdir) \ + -DG_LOG_DOMAIN=\"lxde-battery-plugin\" \ + -DPACKAGE_LOCALE_DIR=\"$(localedir)\" \ + $(PLATFORM_CPPFLAGS) + + +# +# lxde battery plugin +# + +plugin_LTLIBRARIES = \ + lxdebattery.la + +plugindir = \ + $(libdir)/lxpanel/plugins + +lxdebattery_la_SOURCES = \ + battery-plugin.c \ + ../battery-button.c \ + ../battery-button.h + +lxdebattery_la_CFLAGS = \ + -I$(top_srcdir) \ + -I$(top_srcdir)/src \ + -DLOCALEDIR=\"$(localedir)\" \ + -DLXDE_PLUGIN \ + $(LXDEPANEL_CFLAGS) \ + $(LIBXFCE4UTIL_CFLAGS) \ + $(LIBXFCE4UI_CFLAGS) \ + $(XFCONF_CFLAGS) \ + $(GTK_CFLAGS) \ + $(GLIB_CFLAGS) \ + $(PLATFORM_CPPFLAGS) \ + $(PLATFORM_CFLAGS) \ + $(DBUS_GLIB_CFLAGS) \ + $(UPOWER_CFLAGS) + +lxdebattery_la_LDFLAGS = \ + -avoid-version \ + -module \ + -no-undefined \ + $(PLATFORM_LDFLAGS) + +lxdebattery_la_LIBADD = \ + $(top_builddir)/common/libxfpmcommon.la \ + $(LXDEPANEL_LIBS) \ + $(LIBXFCE4UI_LIBS) \ + $(LIBXFCE4UTIL_LIBS) \ + $(XFCONF_LIBS) \ + $(GTK_LIBS) \ + $(GLIB_LIBS) \ + $(DBUS_GLIB_LIBS) \ + $(UPOWER_LIBS) diff --git a/panel-plugins/battery/battery-plugin.c b/panel-plugins/battery/lxde/battery-plugin.c similarity index 71% copy from panel-plugins/battery/battery-plugin.c copy to panel-plugins/battery/lxde/battery-plugin.c index 1cec196..d1f9644 100644 --- a/panel-plugins/battery/battery-plugin.c +++ b/panel-plugins/battery/lxde/battery-plugin.c @@ -28,16 +28,14 @@ #include <gtk/gtk.h> #include <glib.h> +#include <glib/gi18n-lib.h> -#include <libxfce4panel/libxfce4panel.h> -#include <libxfce4panel/xfce-panel-plugin.h> - -#include "battery-button.h" +#include "../battery-button.h" /* plugin structure */ typedef struct { - XfcePanelPlugin *plugin; + Plugin *plugin; /* panel widgets */ GtkWidget *ebox; @@ -45,24 +43,33 @@ typedef struct } BatteryPlugin; -/* prototypes */ -static void battery_plugin_construct (XfcePanelPlugin *plugin); - -/* register the plugin */ -XFCE_PANEL_PLUGIN_REGISTER (battery_plugin_construct); +/* prototypes */ +static int battery_plugin_construct (Plugin *p, char **fp); + +PluginClass lxdebattery_plugin_class = { + PLUGINCLASS_VERSIONING, + type : "lxdebattery", + name : N_("Battery indicator plugin"), + version: PACKAGE_VERSION, + description : N_("Display the battery levels of your devices"), + one_per_system : FALSE, + expand_available : FALSE, + constructor : battery_plugin_construct, + destructor : NULL, + config : NULL, + save : NULL, + panel_configuration_changed : NULL +}; static BatteryPlugin * -battery_plugin_new (XfcePanelPlugin *plugin) +battery_plugin_new (Plugin *plugin) { BatteryPlugin *battery_plugin; /* allocate memory for the plugin structure */ - battery_plugin = panel_slice_new0 (BatteryPlugin); - - /* pointer to plugin */ - battery_plugin->plugin = plugin; + battery_plugin = g_new0 (BatteryPlugin, 1); /* pointer to plugin */ battery_plugin->plugin = plugin; @@ -80,8 +87,8 @@ battery_plugin_new (XfcePanelPlugin *plugin) } -static void -battery_plugin_construct (XfcePanelPlugin *plugin) +static int +battery_plugin_construct (Plugin *plugin, char **fp) { BatteryPlugin *battery_plugin; @@ -89,5 +96,7 @@ battery_plugin_construct (XfcePanelPlugin *plugin) battery_plugin = battery_plugin_new (plugin); /* add the ebox to the panel */ - gtk_container_add (GTK_CONTAINER (plugin), battery_plugin->ebox); + plugin->pwid = battery_plugin->ebox; + + return 1; } diff --git a/panel-plugins/battery/Makefile.am b/panel-plugins/battery/xfce/Makefile.am similarity index 92% copy from panel-plugins/battery/Makefile.am copy to panel-plugins/battery/xfce/Makefile.am index 47bf91f..0b19191 100644 --- a/panel-plugins/battery/Makefile.am +++ b/panel-plugins/battery/xfce/Makefile.am @@ -14,14 +14,15 @@ plugindir = \ $(libdir)/xfce4/panel/plugins libxfce4battery_la_SOURCES = \ - battery-plugin.c \ - battery-button.c \ - battery-button.h + battery-plugin.c \ + ../battery-button.c \ + ../battery-button.h -libxfce4battery_la_CFLAGS = \ +libxfce4battery_la_CFLAGS = \ -I$(top_srcdir) \ -I$(top_srcdir)/src \ -DLOCALEDIR=\"$(localedir)\" \ + -DXFCE_PLUGIN \ $(LIBXFCE4PANEL_CFLAGS) \ $(LIBXFCE4UTIL_CFLAGS) \ $(LIBXFCE4UI_CFLAGS) \ diff --git a/panel-plugins/battery/battery-plugin.c b/panel-plugins/battery/xfce/battery-plugin.c similarity index 96% rename from panel-plugins/battery/battery-plugin.c rename to panel-plugins/battery/xfce/battery-plugin.c index 1cec196..84cc5de 100644 --- a/panel-plugins/battery/battery-plugin.c +++ b/panel-plugins/battery/xfce/battery-plugin.c @@ -28,11 +28,14 @@ #include <gtk/gtk.h> #include <glib.h> +#include <glib/gi18n-lib.h> +#ifdef XFCE_PLUGIN #include <libxfce4panel/libxfce4panel.h> #include <libxfce4panel/xfce-panel-plugin.h> +#endif -#include "battery-button.h" +#include "../battery-button.h" /* plugin structure */ typedef struct @@ -45,10 +48,9 @@ typedef struct } BatteryPlugin; + /* prototypes */ static void battery_plugin_construct (XfcePanelPlugin *plugin); - - /* register the plugin */ XFCE_PANEL_PLUGIN_REGISTER (battery_plugin_construct); @@ -64,9 +66,6 @@ battery_plugin_new (XfcePanelPlugin *plugin) /* pointer to plugin */ battery_plugin->plugin = plugin; - /* pointer to plugin */ - battery_plugin->plugin = plugin; - /* create some panel ebox */ battery_plugin->ebox = gtk_event_box_new (); gtk_widget_show (battery_plugin->ebox); diff --git a/panel-plugins/battery/xfce4-battery-plugin.desktop.in.in b/panel-plugins/battery/xfce/xfce4-battery-plugin.desktop.in.in similarity index 100% rename from panel-plugins/battery/xfce4-battery-plugin.desktop.in.in rename to panel-plugins/battery/xfce/xfce4-battery-plugin.desktop.in.in diff --git a/po/POTFILES.in b/po/POTFILES.in index 695062c..58f53ac 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -22,5 +22,7 @@ src/org.xfce.power.policy.in2 panel-plugins/brightness/brightness-button.c panel-plugins/brightness/xfce4-brightness-plugin.desktop.in.in panel-plugins/battery/battery-button.c -panel-plugins/battery/xfce4-battery-plugin.desktop.in.in +panel-plugins/battery/lxde/battery-plugin.c +panel-plugins/battery/xfce/battery-plugin.c +panel-plugins/battery/xfce/xfce4-battery-plugin.desktop.in.in data/appdata/xfce4-power-manager.appdata.xml.in -- To stop receiving notification emails like this one, please contact the administrator of this repository. _______________________________________________ Xfce4-commits mailing list [email protected] https://mail.xfce.org/mailman/listinfo/xfce4-commits
