diff options
30 files changed, 230 insertions, 51 deletions
@@ -38,3 +38,5 @@ debian/indicator-sus.substvars gtk-logout-helper .deps .libs +src/libsession.la +src/libsession_la-indicator-session.lo @@ -1,6 +1,6 @@ #!/bin/sh -PKG_NAME="indicator-sus" +PKG_NAME="indicator-session" which gnome-autogen.sh || { echo "You need gnome-common from GNOME SVN" diff --git a/configure.ac b/configure.ac index 4a6aac4..0baf030 100644 --- a/configure.ac +++ b/configure.ac @@ -1,10 +1,10 @@ -AC_INIT(src/indicator-sus.c) +AC_INIT(src/indicator-session.c) AC_PREREQ(2.53) AM_CONFIG_HEADER(config.h) -AM_INIT_AUTOMAKE(indicator-sus, 0.1dev) +AM_INIT_AUTOMAKE(indicator-session, 0.1) AM_MAINTAINER_MODE @@ -67,10 +67,13 @@ AC_ARG_ENABLE(localinstall, AS_HELP_STRING([--enable-localinstall], [install all 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) ########################### # DBus Service Info diff --git a/data/icons/16x16/actions/Makefile.am b/data/icons/16x16/actions/Makefile.am index c16c33a..5aa276c 100644 --- a/data/icons/16x16/actions/Makefile.am +++ b/data/icons/16x16/actions/Makefile.am @@ -1,5 +1,5 @@ -iconsdir = $(pkgdatadir)/icons/hicolor/16x16/actions +iconsdir = $(INDICATORICONSDIR)/hicolor/16x16/actions icons_DATA = \ system-shutdown.png \ diff --git a/data/icons/16x16/status/Makefile.am b/data/icons/16x16/status/Makefile.am index ad0c491..7b286f6 100644 --- a/data/icons/16x16/status/Makefile.am +++ b/data/icons/16x16/status/Makefile.am @@ -1,5 +1,5 @@ -iconsdir = $(pkgdatadir)/icons/hicolor/16x16/status +iconsdir = $(INDICATORICONSDIR)/hicolor/16x16/status icons_DATA = \ user-online.png \ diff --git a/data/icons/22x22/actions/Makefile.am b/data/icons/22x22/actions/Makefile.am index 8df746b..73cdd09 100644 --- a/data/icons/22x22/actions/Makefile.am +++ b/data/icons/22x22/actions/Makefile.am @@ -1,5 +1,5 @@ -iconsdir = $(pkgdatadir)/icons/hicolor/22x22/actions +iconsdir = $(INDICATORICONSDIR)/hicolor/22x22/actions icons_DATA = \ system-shutdown.png \ diff --git a/data/icons/22x22/status/Makefile.am b/data/icons/22x22/status/Makefile.am index ab5937b..c0a7f76 100644 --- a/data/icons/22x22/status/Makefile.am +++ b/data/icons/22x22/status/Makefile.am @@ -1,5 +1,5 @@ -iconsdir = $(pkgdatadir)/icons/hicolor/22x22/status +iconsdir = $(INDICATORICONSDIR)/hicolor/22x22/status icons_DATA = \ user-online.png \ diff --git a/data/icons/24x24/actions/Makefile.am b/data/icons/24x24/actions/Makefile.am index e69423c..55c63d1 100644 --- a/data/icons/24x24/actions/Makefile.am +++ b/data/icons/24x24/actions/Makefile.am @@ -1,5 +1,5 @@ -iconsdir = $(pkgdatadir)/icons/hicolor/24x24/actions +iconsdir = $(INDICATORICONSDIR)/hicolor/24x24/actions icons_DATA = \ system-shutdown.png \ diff --git a/data/icons/24x24/status/Makefile.am b/data/icons/24x24/status/Makefile.am index 76676a6..e26596c 100644 --- a/data/icons/24x24/status/Makefile.am +++ b/data/icons/24x24/status/Makefile.am @@ -1,5 +1,5 @@ -iconsdir = $(pkgdatadir)/icons/hicolor/24x24/status +iconsdir = $(INDICATORICONSDIR)/hicolor/24x24/status icons_DATA = \ user-online.png \ diff --git a/data/icons/32x32/actions/Makefile.am b/data/icons/32x32/actions/Makefile.am index 522ab5d..74c2c8d 100644 --- a/data/icons/32x32/actions/Makefile.am +++ b/data/icons/32x32/actions/Makefile.am @@ -1,5 +1,5 @@ -iconsdir = $(pkgdatadir)/icons/hicolor/32x32/actions +iconsdir = $(INDICATORICONSDIR)/hicolor/32x32/actions icons_DATA = \ system-restart.png \ diff --git a/data/icons/32x32/status/Makefile.am b/data/icons/32x32/status/Makefile.am index bcfd6ac..e7967f4 100644 --- a/data/icons/32x32/status/Makefile.am +++ b/data/icons/32x32/status/Makefile.am @@ -1,5 +1,5 @@ -iconsdir = $(pkgdatadir)/icons/hicolor/32x32/status +iconsdir = $(INDICATORICONSDIR)/hicolor/32x32/status icons_DATA = \ user-online.png \ diff --git a/data/icons/48x48/status/Makefile.am b/data/icons/48x48/status/Makefile.am index 102f579..a2ff495 100644 --- a/data/icons/48x48/status/Makefile.am +++ b/data/icons/48x48/status/Makefile.am @@ -1,5 +1,5 @@ -iconsdir = $(pkgdatadir)/icons/hicolor/48x48/status +iconsdir = $(INDICATORICONSDIR)/hicolor/48x48/status icons_DATA = \ user-online.png \ diff --git a/data/icons/Makefile.am b/data/icons/Makefile.am index 17dca13..7c42753 100644 --- a/data/icons/Makefile.am +++ b/data/icons/Makefile.am @@ -1,6 +1,6 @@ SUBDIRS = scalable 16x16 22x22 24x24 32x32 48x48 -gtk_update_icon_cache = gtk-update-icon-cache -f -t $(pkgdatadir)/icons/hicolor +gtk_update_icon_cache = gtk-update-icon-cache -f -t $(INDICATORICONSDIR)/hicolor install-data-hook: update-icon-cache uninstall-hook: update-icon-cache diff --git a/data/icons/scalable/actions/Makefile.am b/data/icons/scalable/actions/Makefile.am index 9c64beb..39b4177 100644 --- a/data/icons/scalable/actions/Makefile.am +++ b/data/icons/scalable/actions/Makefile.am @@ -1,5 +1,5 @@ -iconsdir = $(pkgdatadir)/icons/hicolor/scalable/actions +iconsdir = $(INDICATORICONSDIR)/hicolor/scalable/actions icons_DATA = \ system-restart.svg \ diff --git a/data/icons/scalable/status/Makefile.am b/data/icons/scalable/status/Makefile.am index 0df2f79..2c70d33 100644 --- a/data/icons/scalable/status/Makefile.am +++ b/data/icons/scalable/status/Makefile.am @@ -1,5 +1,5 @@ -iconsdir = $(pkgdatadir)/icons/hicolor/scalable/status +iconsdir = $(INDICATORICONSDIR)/hicolor/scalable/status icons_DATA = \ user-online.svg \ diff --git a/debian/changelog b/debian/changelog index ea25fee..62f5111 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,39 @@ +indicator-session (0.1~bzr17-0ubuntu1~ppa1) karmic; urgency=low + + * Merging in trunk with rename from 'sus' to 'session' + * debian/control: Switching to indicator-session and conflicting + and replacing indicator-sus + * debian/watch: Switching to indicator-session* + + -- Ted Gould <ted@ubuntu.com> Tue, 18 Aug 2009 17:07:35 -0500 + +indicator-sus (0.1-0ubuntu3~ppa1) karmic; urgency=low + + * Merging in the branch that adds in the status icons to + the panel. + + -- Ted Gould <ted@ubuntu.com> Mon, 17 Aug 2009 09:08:53 -0500 + +indicator-sus (0.1-0ubuntu2) UNRELEASE; urgency=low + + * Fixed Vcs-Bzr location, part of the indicator-applet project + * specify Vcs-Bzr-Browser + + -- Alexander Sack <asac@ubuntu.com> Tue, 11 Aug 2009 17:26:15 +0200 + +indicator-sus (0.1-0ubuntu1) karmic; urgency=low + + * Include icons in the tarball + * Added license files + * Corrected the FSF address + * debian/control + - Set Homepage and Vcs-Bzr + * Added debian/watch + * Changed conflicts for gdm to <= 2.27.4-0ubuntu9 + * Depend on indicator-applet >= 0.2 + + -- Ken VanDine <ken.vandine@canonical.com> Tue, 11 Aug 2009 09:53:56 -0400 + indicator-sus (0.1~ppa6) karmic; urgency=low * debian/control: Conflicting with gdm < 2.27.4-0ubuntu9 or diff --git a/debian/control b/debian/control index 1a33a51..4c76aa7 100644 --- a/debian/control +++ b/debian/control @@ -1,4 +1,4 @@ -Source: indicator-sus +Source: indicator-session Section: gnome Priority: optional Maintainer: Ubuntu Core Developers <ubuntu-devel-discuss@lists.ubuntu.com> @@ -13,11 +13,14 @@ Build-Depends: debhelper (>= 5.0), libdbusmenu-gtk-dev, libpolkit-gnome-dev, intltool -Standards-Version: 3.8.0 +Standards-Version: 3.8.2 +Homepage: https://launchpad.net/indicator-applet +Vcs-Bzr: lp:~ubuntu-core-dev/indicator-applet/sus-ubuntu +Vcs-Bzr-Browser: http://bazaar.launchpad.net/~ubuntu-core-dev/indicator-applet/sus-ubuntu -Package: indicator-sus +Package: indicator-session Architecture: any -Depends: ${shlibs:Depends}, ${misc:Depends}, indicator-applet, devicekit-power -Conflicts: gdm (< 2.27.4-0ubuntu9) -Description: Applet for the GNOME panel providing various indicators for - display to users. +Depends: ${shlibs:Depends}, ${misc:Depends}, indicator-applet (>= 0.2), devicekit-power, gdm +Conflicts: gdm (<= 2.27.4-0ubuntu9), indicator-sus +Replaces: indicator-sus +Description: An indicator providing session management, status control and user switching. diff --git a/debian/rules b/debian/rules index 22338be..7f46594 100755 --- a/debian/rules +++ b/debian/rules @@ -6,6 +6,8 @@ include /usr/share/cdbs/1/class/gnome.mk DEB_CONFIGURE_EXTRA_FLAGS += --disable-scrollkeeper LDFLAGS += -Wl,-z,defs -Wl,--as-needed +DEB_DH_MAKESHLIBS_ARGS = -Xusr/lib/indicators + binary-install/indicator-sus:: # remove .a/.la clutter rm -f debian/$(cdbs_curpkg)/usr/lib/indicators/*/*.a diff --git a/debian/watch b/debian/watch new file mode 100644 index 0000000..22a7bca --- /dev/null +++ b/debian/watch @@ -0,0 +1,2 @@ +version=3 +https://launchpad.net/indicator-applet/+download .*/indicator-session-([0-9.]+)\.tar\.gz diff --git a/src/Makefile.am b/src/Makefile.am index ab79f0f..bd35910 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -6,15 +6,15 @@ libexec_PROGRAMS = indicator-status-service indicator-users-service indicator-se # Indicator Stuff ################### -status_users_sessionlibdir = $(INDICATORDIR) -status_users_sessionlib_LTLIBRARIES = libstatus-users-session.la -libstatus_users_session_la_SOURCES = \ - indicator-sus.c \ +sessionlibdir = $(INDICATORDIR) +sessionlib_LTLIBRARIES = libsession.la +libsession_la_SOURCES = \ + indicator-session.c \ dbus-shared-names.h \ status-service-client.h -libstatus_users_session_la_CFLAGS = $(APPLET_CFLAGS) -Wall -Werror -libstatus_users_session_la_LIBADD = $(APPLET_LIBS) -libstatus_users_session_la_LDFLAGS = -module -avoid-version +libsession_la_CFLAGS = $(APPLET_CFLAGS) -Wall -Werror +libsession_la_LIBADD = $(APPLET_LIBS) +libsession_la_LDFLAGS = -module -avoid-version ################ # Status Stuff @@ -29,17 +29,17 @@ indicator_status_service_SOURCES = \ status-provider.c \ status-provider-pidgin.h \ status-provider-pidgin.c -indicator_status_service_CFLAGS = $(STATUSSERVICE_CFLAGS) +indicator_status_service_CFLAGS = $(STATUSSERVICE_CFLAGS) -Wall -Werror indicator_status_service_LDADD = $(STATUSSERVICE_LIBS) -status-service-client.h: status-service.xml +status-service-client.h: $(srcdir)/status-service.xml dbus-binding-tool \ --prefix=_status_service_client \ --mode=glib-client \ --output=status-service-client.h \ $(srcdir)/status-service.xml -status-service-server.h: status-service.xml +status-service-server.h: $(srcdir)/status-service.xml dbus-binding-tool \ --prefix=_status_service_server \ --mode=glib-server \ @@ -51,7 +51,7 @@ status-service-server.h: status-service.xml ############### indicator_users_service_SOURCES = users-service.c -indicator_users_service_CFLAGS = $(USERSSERVICE_CFLAGS) +indicator_users_service_CFLAGS = $(USERSSERVICE_CFLAGS) -Wall -Werror indicator_users_service_LDADD = $(USERSSERVICE_LIBS) ################# @@ -59,7 +59,7 @@ indicator_users_service_LDADD = $(USERSSERVICE_LIBS) ################# indicator_session_service_SOURCES = session-service.c -indicator_session_service_CFLAGS = $(SESSIONSERVICE_CFLAGS) -DLIBEXECDIR=\"$(libexecdir)\" +indicator_session_service_CFLAGS = $(SESSIONSERVICE_CFLAGS) -DLIBEXECDIR=\"$(libexecdir)\" -Wall -Werror indicator_session_service_LDADD = $(SESSIONSERVICE_LIBS) ############### @@ -72,3 +72,6 @@ BUILT_SOURCES = \ EXTRA_DIST = \ status-service.xml + +CLEANFILES = \ + $(BUILT_SOURCES) diff --git a/src/dbus-shared-names.h b/src/dbus-shared-names.h index 3ba21f8..a645830 100644 --- a/src/dbus-shared-names.h +++ b/src/dbus-shared-names.h @@ -25,13 +25,14 @@ with this program. If not, see <http://www.gnu.org/licenses/>. #define __DBUS_SHARED_NAMES_H__ 1 #define INDICATOR_STATUS_DBUS_NAME "org.ayatana.indicator.status" -#define INDICATOR_STATUS_DBUS_OBJECT "/org/ayatana/indicator/status" -#define INDICATOR_STATUS_SERVICE_DBUS_OBJECT "/org/ayatana/indicator/status-service" +#define INDICATOR_STATUS_DBUS_OBJECT "/org/ayatana/indicator/status/menu" +#define INDICATOR_STATUS_SERVICE_DBUS_OBJECT "/org/ayatana/indicator/status/service" +#define INDICATOR_STATUS_SERVICE_DBUS_INTERFACE "org.ayatana.indicator.status.service" #define INDICATOR_USERS_DBUS_NAME "org.ayatana.indicator.users" -#define INDICATOR_USERS_DBUS_OBJECT "/org/ayatana/indicator/users" +#define INDICATOR_USERS_DBUS_OBJECT "/org/ayatana/indicator/users/menu" #define INDICATOR_SESSION_DBUS_NAME "org.ayatana.indicator.session" -#define INDICATOR_SESSION_DBUS_OBJECT "/org/ayatana/indicator/session" +#define INDICATOR_SESSION_DBUS_OBJECT "/org/ayatana/indicator/session/menu" #endif /* __DBUS_SHARED_NAMES_H__ */ diff --git a/src/indicator-sus.c b/src/indicator-session.c index e248e68..07efc86 100644 --- a/src/indicator-sus.c +++ b/src/indicator-session.c @@ -39,6 +39,7 @@ static DbusmenuGtkClient * users_client = NULL; static DbusmenuGtkClient * session_client = NULL; static GtkMenu * main_menu = NULL; +static GtkImage * status_image = NULL; static GtkWidget * status_separator = NULL; static GtkWidget * users_separator = NULL; @@ -47,6 +48,7 @@ static GtkWidget * loading_item = NULL; static DBusGConnection * connection = NULL; static DBusGProxy * proxy = NULL; +static DBusGProxy * status_proxy = NULL; typedef enum { STATUS_SECTION, @@ -71,8 +73,10 @@ get_label (void) GtkImage * get_icon (void) { - GtkImage * image = GTK_IMAGE(gtk_image_new_from_icon_name("user-offline", GTK_ICON_SIZE_MENU)); - return image; + g_debug("Changing status icon: '%s'", "user-offline"); + status_image = GTK_IMAGE(gtk_image_new_from_icon_name("user-offline", GTK_ICON_SIZE_MENU)); + gtk_widget_show(GTK_WIDGET(status_image)); + return status_image; } static void @@ -178,6 +182,55 @@ status_menu_root_changed(DbusmenuGtkClient * client, DbusmenuMenuitem * newroot, return; } +void +status_icon_cb (DBusGProxy * proxy, char * icons, GError *error, gpointer userdata) +{ + g_return_if_fail(status_image != NULL); + g_return_if_fail(icons != NULL); + g_return_if_fail(icons[0] != '\0'); + + g_debug("Changing status icon: '%s'", icons); + gtk_image_set_from_icon_name(status_image, icons, GTK_ICON_SIZE_MENU); + + return; +} + +void +status_icon_changed (DBusGProxy * proxy, gchar * icon, gpointer userdata) +{ + return status_icon_cb(proxy, icon, NULL, NULL); +} + + +static gboolean +connect_to_status (gpointer userdata) +{ + if (status_proxy == NULL) { + GError * error = NULL; + + DBusGConnection * sbus = dbus_g_bus_get(DBUS_BUS_SESSION, NULL); + + status_proxy = dbus_g_proxy_new_for_name_owner(sbus, + INDICATOR_STATUS_DBUS_NAME, + INDICATOR_STATUS_SERVICE_DBUS_OBJECT, + INDICATOR_STATUS_SERVICE_DBUS_INTERFACE, + &error); + + if (error != NULL) { + g_warning("Unable to get status proxy: %s", error->message); + g_error_free(error); + return FALSE; + } + + dbus_g_proxy_add_signal(status_proxy, "StatusIconsChanged", G_TYPE_STRING, G_TYPE_INVALID); + dbus_g_proxy_connect_signal(status_proxy, "StatusIconsChanged", G_CALLBACK(status_icon_changed), NULL, NULL); + } + + org_ayatana_indicator_status_service_status_icons_async(status_proxy, status_icon_cb, NULL); + + return FALSE; +} + static gboolean build_status_menu (gpointer userdata) { @@ -208,6 +261,8 @@ build_status_menu (gpointer userdata) gtk_menu_shell_append(GTK_MENU_SHELL(main_menu), status_separator); gtk_widget_hide(status_separator); /* Should be default, I'm just being explicit. $(%*#$ hide already! */ + g_idle_add(connect_to_status, NULL); + return FALSE; } diff --git a/src/status-provider-pidgin.c b/src/status-provider-pidgin.c index 6a3f7a5..aaa8732 100644 --- a/src/status-provider-pidgin.c +++ b/src/status-provider-pidgin.c @@ -129,6 +129,12 @@ status_provider_pidgin_init (StatusProviderPidgin *self) static void status_provider_pidgin_dispose (GObject *object) { + StatusProviderPidginPrivate * priv = STATUS_PROVIDER_PIDGIN_GET_PRIVATE(object); + + if (priv->proxy != NULL) { + g_object_unref(priv->proxy); + priv->proxy = NULL; + } G_OBJECT_CLASS (status_provider_pidgin_parent_class)->dispose (object); return; @@ -166,6 +172,7 @@ set_status (StatusProvider * sp, StatusProviderStatus status) StatusProviderPidginPrivate * priv = STATUS_PROVIDER_PIDGIN_GET_PRIVATE(sp); pg_status_t pg_status = sp_to_pg_map[status]; priv->pg_status = pg_status; + g_signal_emit(G_OBJECT(sp), STATUS_PROVIDER_SIGNAL_STATUS_CHANGED_ID, 0, pg_to_sp_map[priv->pg_status], TRUE); return; } diff --git a/src/status-provider.c b/src/status-provider.c index 1c9561b..83d44ac 100644 --- a/src/status-provider.c +++ b/src/status-provider.c @@ -43,7 +43,7 @@ G_DEFINE_TYPE (StatusProvider, status_provider, G_TYPE_OBJECT); static void status_provider_class_init (StatusProviderClass *klass) { - GObjectClass *object_class = G_OBJECT_CLASS (klass); + // GObjectClass *object_class = G_OBJECT_CLASS (klass); klass->status_changed = NULL; diff --git a/src/status-provider.h b/src/status-provider.h index f01a90e..9cc9885 100644 --- a/src/status-provider.h +++ b/src/status-provider.h @@ -47,7 +47,8 @@ typedef enum } StatusProviderStatus; -#define STATUS_PROVIDER_SIGNAL_STATUS_CHANGED "status-changed" +#define STATUS_PROVIDER_SIGNAL_STATUS_CHANGED "status-changed" +#define STATUS_PROVIDER_SIGNAL_STATUS_CHANGED_ID (g_signal_lookup(STATUS_PROVIDER_SIGNAL_STATUS_CHANGED, STATUS_PROVIDER_TYPE)) typedef struct _StatusProvider StatusProvider; struct _StatusProvider { diff --git a/src/status-service-dbus.c b/src/status-service-dbus.c index a8e031c..65de499 100644 --- a/src/status-service-dbus.c +++ b/src/status-service-dbus.c @@ -34,7 +34,7 @@ static void status_service_dbus_init (StatusServiceDbus *self); static void status_service_dbus_dispose (GObject *object); static void status_service_dbus_finalize (GObject *object); static gboolean _status_service_server_watch (StatusServiceDbus * service, GError ** error); -static gboolean _status_service_server_status_icons (StatusServiceDbus * service, GArray * array, GError ** error); +static gboolean _status_service_server_status_icons (StatusServiceDbus * service, gchar ** icon, GError ** error); static gboolean _status_service_server_pretty_user_name (StatusServiceDbus * service, gchar ** username, GError ** error); #include "status-service-server.h" @@ -44,6 +44,7 @@ typedef struct _StatusServiceDbusPrivate StatusServiceDbusPrivate; struct _StatusServiceDbusPrivate { gchar * name; + gchar * icon; }; #define STATUS_SERVICE_DBUS_GET_PRIVATE(o) \ @@ -102,8 +103,8 @@ status_service_dbus_class_init (StatusServiceDbusClass *klass) G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET(StatusServiceDbusClass, status_icons_changed), NULL, NULL, - g_cclosure_marshal_VOID__POINTER, - G_TYPE_NONE, 1, G_TYPE_POINTER); + g_cclosure_marshal_VOID__STRING, + G_TYPE_NONE, 1, G_TYPE_STRING); dbus_g_object_type_install_info(STATUS_SERVICE_DBUS_TYPE, &dbus_glib__status_service_server_object_info); @@ -120,7 +121,8 @@ status_service_dbus_init (StatusServiceDbus *self) G_OBJECT(self)); StatusServiceDbusPrivate * priv = STATUS_SERVICE_DBUS_GET_PRIVATE(self); - priv->name = "test"; + priv->name = NULL; + priv->icon = NULL; return; } @@ -149,8 +151,19 @@ _status_service_server_watch (StatusServiceDbus * service, GError ** error) } static gboolean -_status_service_server_status_icons (StatusServiceDbus * service, GArray * array, GError ** error) +_status_service_server_status_icons (StatusServiceDbus * service, gchar ** icon, GError ** error) { + if (!IS_STATUS_SERVICE_DBUS(service)) { + g_warning("NO BAD EVIL!"); + return FALSE; + } + + StatusServiceDbusPrivate * priv = STATUS_SERVICE_DBUS_GET_PRIVATE(service); + if (priv->icon == NULL) { + *icon = g_strdup(""); + } else { + *icon = g_strdup(priv->icon); + } return TRUE; } @@ -172,3 +185,21 @@ _status_service_server_pretty_user_name (StatusServiceDbus * service, gchar ** u return TRUE; } + +void +status_service_dbus_set_status (StatusServiceDbus * self, const gchar * icon) +{ + g_return_if_fail(IS_STATUS_SERVICE_DBUS(self)); + + g_debug("Setting icon to: %s", icon); + + StatusServiceDbusPrivate * priv = STATUS_SERVICE_DBUS_GET_PRIVATE(self); + + if (priv->icon != NULL) { + g_free(priv->icon); + } + priv->icon = g_strdup(icon); + + g_signal_emit(G_OBJECT(self), signals[STATUS_ICONS_CHANGED], 0, priv->icon, TRUE); + return; +} diff --git a/src/status-service-dbus.h b/src/status-service-dbus.h index 66c9206..34a9c3c 100644 --- a/src/status-service-dbus.h +++ b/src/status-service-dbus.h @@ -52,6 +52,7 @@ struct _StatusServiceDbus { }; GType status_service_dbus_get_type (void); +void status_service_dbus_set_status (StatusServiceDbus * self, const gchar * icon); G_END_DECLS diff --git a/src/status-service.c b/src/status-service.c index 4c48c72..5a9d9b5 100644 --- a/src/status-service.c +++ b/src/status-service.c @@ -23,6 +23,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>. #include <sys/types.h> #include <pwd.h> +#include <unistd.h> #include <glib/gi18n.h> @@ -67,6 +68,30 @@ static DbusmenuMenuitem * root_menuitem = NULL; static DbusmenuMenuitem * status_menuitem = NULL; static GMainLoop * mainloop = NULL; static StatusServiceDbus * dbus_interface = NULL; +static StatusProviderStatus global_status = STATUS_PROVIDER_STATUS_OFFLINE; + +static void +status_update (void) { + StatusProviderStatus oldglobal = global_status; + global_status = STATUS_PROVIDER_STATUS_ONLINE; + + int i; + for (i = 0; i < STATUS_PROVIDER_CNT; i++) { + StatusProviderStatus localstatus = status_provider_get_status(status_providers[i]); + if (localstatus > global_status) { + global_status = localstatus; + } + } + + if (global_status != oldglobal) { + g_debug("Global status changed to: %s", _(status_strings[global_status])); + + dbusmenu_menuitem_property_set(status_menuitem, "label", _(status_strings[global_status])); + status_service_dbus_set_status(dbus_interface, status_icons[global_status]); + } + + return; +} /* A fun little function to actually lock the screen. If, that's what you want, let's do it! */ @@ -114,8 +139,14 @@ build_providers (gpointer data) int i; for (i = 0; i < STATUS_PROVIDER_CNT; i++) { status_providers[i] = status_provider_newfuncs[i](); + + if (status_providers[i] != NULL) { + g_signal_connect(G_OBJECT(status_providers[i]), STATUS_PROVIDER_SIGNAL_STATUS_CHANGED, G_CALLBACK(status_update), NULL); + } } + status_update(); + return FALSE; } @@ -154,7 +185,7 @@ build_menu (gpointer data) build_user_item(root); status_menuitem = dbusmenu_menuitem_new(); - dbusmenu_menuitem_property_set(status_menuitem, "label", "Status"); + dbusmenu_menuitem_property_set(status_menuitem, "label", _(status_strings[global_status])); dbusmenu_menuitem_child_append(root, status_menuitem); StatusProviderStatus i; diff --git a/src/status-service.xml b/src/status-service.xml index 3807158..977b338 100644 --- a/src/status-service.xml +++ b/src/status-service.xml @@ -1,13 +1,13 @@ <?xml version="1.0" encoding="UTF-8"?> <node name="/"> - <interface name="org.ayatana.indicator.status"> + <interface name="org.ayatana.indicator.status.service"> <!-- Methods --> <method name="Watch"> <annotation name="org.freedesktop.DBus.GLib.Async" value="true" /> </method> <method name="StatusIcons"> - <arg type="a(s)" name="icons" direction="out" /> + <arg type="s" name="icons" direction="out" /> </method> <method name="PrettyUserName"> <arg type="s" name="name" direction="out" /> @@ -18,7 +18,7 @@ <arg type="s" name="name" direction="out" /> </signal> <signal name="StatusIconsChanged"> - <arg type="a(s)" name="icons" direction="out" /> + <arg type="s" name="icons" direction="out" /> </signal> </interface> diff --git a/src/users-service.c b/src/users-service.c index a8a9c67..9ada91f 100644 --- a/src/users-service.c +++ b/src/users-service.c @@ -20,6 +20,7 @@ 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 <unistd.h> #include <glib/gi18n.h> |