aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog15
-rw-r--r--applets/Makefile.am4
-rw-r--r--applets/battery/Makefile.am11
-rw-r--r--applets/battery/battery.c74
-rw-r--r--applets/launcher/launcher.c9
-rw-r--r--configure.ac11
6 files changed, 122 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 5a8f352..4a800ef 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,20 @@
2006-08-21 Jorn Baayen <jorn@openedhand.com>
+ * applets/Makefile.am:
+ * applets/battery/Makefile.am:
+ * applets/battery/battery.c:
+ * configure.ac:
+
+ Add skels for a battery applet. Built only if libapm is available.
+ Needs graphics.
+
+ * applets/launcher/launcher.c: (launcher_data_free),
+ (mb_panel_applet_create):
+
+ Initialize icon_theme and icon_theme_changed_id to NULL and 0.
+
+2006-08-21 Jorn Baayen <jorn@openedhand.com>
+
* applets/systray/Makefile.am:
* applets/systray/systray.c: (tray_icon_added_cb),
(message_sent_cb), (message_cancelled_cb), (screen_changed_cb),
diff --git a/applets/Makefile.am b/applets/Makefile.am
index 6710d56..224fdfb 100644
--- a/applets/Makefile.am
+++ b/applets/Makefile.am
@@ -1,3 +1,7 @@
SUBDIRS = clock launcher systray
+if HAVE_LIBAPM
+ SUBDIRS += battery
+endif
+
MAINTAINERCLEANFILES = Makefile.in
diff --git a/applets/battery/Makefile.am b/applets/battery/Makefile.am
new file mode 100644
index 0000000..a07a1f2
--- /dev/null
+++ b/applets/battery/Makefile.am
@@ -0,0 +1,11 @@
+AM_CPPFLAGS=-DPKGDATADIR=\"$(pkgdatadir)\" -DGETTEXT_PACKAGE=\"matchbox-panel\"
+AM_CFLAGS = -Wall -g $(MATCHBOX_PANEL_CFLAGS) \
+ -I$(top_srcdir) -I$(top_builddir) -Werror
+
+appletdir = $(libdir)/matchbox-panel
+applet_LTLIBRARIES = libbattery.la
+
+libbattery_la_SOURCES = battery.c
+libbattery_la_LIBADD = -lapm
+
+MAINTAINERCLEANFILES = Makefile.in
diff --git a/applets/battery/battery.c b/applets/battery/battery.c
new file mode 100644
index 0000000..fc55743
--- /dev/null
+++ b/applets/battery/battery.c
@@ -0,0 +1,74 @@
+/*
+ * (C) 2006 OpenedHand Ltd.
+ *
+ * Author: Jorn Baayen <jorn@openedhand.com>
+ *
+ * Licensed under the GPL v2 or greater.
+ */
+
+#include <gtk/gtkimage.h>
+#include <apm.h>
+#include <matchbox-panel/mb-panel.h>
+
+/* Applet destroyed */
+static void
+destroy_cb (GtkImage *image)
+{
+ guint timeout_id;
+
+ /* Remove timeout */
+ timeout_id =
+ GPOINTER_TO_UINT
+ (g_object_get_data (G_OBJECT (image), "timeout-id"));
+
+ g_source_remove (timeout_id);
+}
+
+/* Called every minute */
+static gboolean
+timeout (GtkImage *image)
+{
+ apm_info info;
+
+ apm_read (&info);
+
+ /* TODO choose appropriate graphics to display */
+
+ /* Keep going */
+ return TRUE;
+}
+
+G_MODULE_EXPORT GtkWidget *
+mb_panel_applet_create (const char *id,
+ int panel_width,
+ int panel_height)
+{
+ GtkWidget *image;
+ guint timeout_id;
+
+ /* Create label */
+ image = gtk_image_new ();
+
+ gtk_widget_set_name (image, "MatchboxPanelBatteryMonitor");
+
+ timeout (GTK_IMAGE (image));
+
+ g_signal_connect (image,
+ "destroy",
+ G_CALLBACK (destroy_cb),
+ NULL);
+
+ /* Set up a timeout that will be called every minute */
+ timeout_id = g_timeout_add (60 * 1000,
+ (GSourceFunc) timeout,
+ image);
+
+ g_object_set_data (G_OBJECT (image),
+ "timeout-id",
+ GUINT_TO_POINTER (timeout_id));
+
+ /* Show! */
+ gtk_widget_show (image);
+
+ return image;
+};
diff --git a/applets/launcher/launcher.c b/applets/launcher/launcher.c
index 7be0f8b..7fdbfb9 100644
--- a/applets/launcher/launcher.c
+++ b/applets/launcher/launcher.c
@@ -42,8 +42,10 @@ launcher_data_free (LauncherData *data)
{
g_free (data->icon);
- g_signal_handler_disconnect (data->icon_theme,
- data->icon_theme_changed_id);
+ if (data->icon_theme_changed_id) {
+ g_signal_handler_disconnect (data->icon_theme,
+ data->icon_theme_changed_id);
+ }
g_free (data->name);
g_strfreev (data->argv);
@@ -482,6 +484,9 @@ mb_panel_applet_create (const char *id,
data->icon = icon;
data->icon_size = MIN (panel_width, panel_height);
+ data->icon_theme = NULL;
+ data->icon_theme_changed_id = 0;
+
data->button_down = FALSE;
data->use_sn = use_sn;
diff --git a/configure.ac b/configure.ac
index ab0c899..45c9485 100644
--- a/configure.ac
+++ b/configure.ac
@@ -10,11 +10,13 @@ AC_PROG_CC
AC_STDC_HEADERS
AC_PROG_LIBTOOL
+# base deps
PKG_CHECK_MODULES(MATCHBOX_PANEL,
glib-2.0
gtk+-2.0 >= 2.6
gmodule-2.0)
+# startup-notification
AC_ARG_ENABLE(startup_notification,
[ --enable-startup-notification enable startup notification support],
enable_startup_notification=$enableval, enable_startup_notification=yes )
@@ -26,6 +28,7 @@ if test x$enable_startup_notification != xno; then
AC_DEFINE(USE_LIBSN, [1], [Has Startup Notification Support])
fi
+# libnotify
AC_ARG_ENABLE(libnotify,
[ --enable-libnotify enable libnotify support],
enable_libnotify=$enableval, enable_libnotify=yes )
@@ -37,9 +40,15 @@ if test x$enable_libnotify != xno; then
AC_DEFINE(USE_LIBNOTIFY, [1], [Has libnotify Support])
fi
+# apm
+AC_CHECK_HEADERS(apm.h, enable_linux_apm=yes, enable_linux_apm=no)
+AM_CONDITIONAL(HAVE_LIBAPM, test x$enable_linux_apm = xyes)
+
+# glib-genmarshal
GLIB_GENMARSHAL=`$PKG_CONFIG --variable=glib_genmarshal glib-2.0`
AC_SUBST(GLIB_GENMARSHAL)
+# gettext
GETTEXT_PACKAGE=matchbox-panel
AC_SUBST(GETTEXT_PACKAGE)
AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, ["$GETTEXT_PACKAGE"],
@@ -48,6 +57,7 @@ AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, ["$GETTEXT_PACKAGE"],
ALL_LINGUAS=""
AM_GLIB_GNU_GETTEXT
+# output stuff
AC_OUTPUT([
Makefile
matchbox-panel.pc
@@ -56,6 +66,7 @@ applets/Makefile
applets/clock/Makefile
applets/launcher/Makefile
applets/systray/Makefile
+applets/battery/Makefile
po/Makefile.in
po/Makefile
])