From ba21dc6356e53dc5c8ab7aa190d3cd3cc0fdd8f3 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 19 Aug 2009 13:36:22 -0500 Subject: AM 1.11 silent rule --- configure.ac | 2 ++ 1 file changed, 2 insertions(+) diff --git a/configure.ac b/configure.ac index 9093512..19a549c 100644 --- a/configure.ac +++ b/configure.ac @@ -17,6 +17,8 @@ AC_PROG_LIBTOOL AC_SUBST(VERSION) AC_CONFIG_MACRO_DIR([m4]) +m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])]) + ########################### # Dependencies ########################### -- cgit v1.2.3 From 1656fcc2e581fe4ba9bf8befbf6c94fe1f0a8f20 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 19 Aug 2009 13:50:16 -0500 Subject: Adding directories. Let's put them in one file so that they'll be changable easy :) --- src/dirs.h | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 src/dirs.h diff --git a/src/dirs.h b/src/dirs.h new file mode 100644 index 0000000..a994ff5 --- /dev/null +++ b/src/dirs.h @@ -0,0 +1,3 @@ +#define SYSTEM_APPS_DIR "/etc/indicators/messages/applications" +#define USER_APPS_DIR "indicators/messages/applications" +#define USER_BLACKLIST_DIR "indicators/messages/applications-blacklist" -- cgit v1.2.3 From aed88cf243dc4862683acc886513ad970aafad60 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 19 Aug 2009 15:22:58 -0500 Subject: Adding the basis for launchers --- src/indicator-service.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/indicator-service.c b/src/indicator-service.c index cb7e23a..93c926b 100644 --- a/src/indicator-service.c +++ b/src/indicator-service.c @@ -28,6 +28,7 @@ with this program. If not, see . #include "im-menu-item.h" #include "app-menu-item.h" +#include "launcher-menu-item.h" #include "dbus-data.h" static IndicateListener * listener; @@ -116,6 +117,25 @@ imList_sort (gconstpointer a, gconstpointer b) return (gint)(im_menu_item_get_seconds(IM_MENU_ITEM(pb->menuitem)) - im_menu_item_get_seconds(IM_MENU_ITEM(pa->menuitem))); } +typedef struct _launcherList_t launcherList_t; +struct _launcherList_t { + LauncherMenuItem * menuitem; +}; + +static gint +launcherList_sort (gconstpointer a, gconstpointer b) +{ + launcherList_t * pa, * pb; + + pa = (launcherList_t *)a; + pb = (launcherList_t *)b; + + const gchar * pan = launcher_menu_item_get_name(pa->menuitem); + const gchar * pbn = launcher_menu_item_get_name(pb->menuitem); + + return g_strcmp0(pan, pbn); +} + static void server_added (IndicateListener * listener, IndicateListenerServer * server, gchar * type, gpointer data) { @@ -466,6 +486,15 @@ indicator_removed (IndicateListener * listener, IndicateListenerServer * server, return; } +gboolean +build_launchers (gpointer data) +{ + + + + return FALSE; +} + int main (int argc, char ** argv) { @@ -498,6 +527,8 @@ main (int argc, char ** argv) g_signal_connect(listener, INDICATE_LISTENER_SIGNAL_SERVER_ADDED, G_CALLBACK(server_added), root_menuitem); g_signal_connect(listener, INDICATE_LISTENER_SIGNAL_SERVER_REMOVED, G_CALLBACK(server_removed), root_menuitem); + g_idle_add(build_launchers, NULL); + mainloop = g_main_loop_new(NULL, FALSE); g_main_loop_run(mainloop); -- cgit v1.2.3 From f0269893fd65671ee5022a7be43570572e118917 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 19 Aug 2009 15:37:31 -0500 Subject: No reason that all these should be linked into the loadable module. Err, fail. --- src/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Makefile.am b/src/Makefile.am index 74db2df..4944c45 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -3,7 +3,7 @@ bin_PROGRAMS = indicator-messages-service messaginglibdir = $(INDICATORDIR) messaginglib_LTLIBRARIES = libmessaging.la -libmessaging_la_SOURCES = indicator-messages.c im-menu-item.c im-menu-item.h app-menu-item.c app-menu-item.h +libmessaging_la_SOURCES = indicator-messages.c libmessaging_la_CFLAGS = $(APPLET_CFLAGS) -Wall -Wl,-Bsymbolic-functions -Wl,-z,defs -Wl,--as-needed -Werror libmessaging_la_LIBADD = $(APPLET_LIBS) libmessaging_la_LDFLAGS = -module -avoid-version -- cgit v1.2.3 From 83836f587d5f4c11a9227c215a719a4ec4f2a71f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 19 Aug 2009 15:38:15 -0500 Subject: Adding in a new menu-item type. One for launchers! Woo Hoo! --- src/Makefile.am | 2 +- src/launcher-menu-item.c | 133 +++++++++++++++++++++++++++++++++++++++++++++++ src/launcher-menu-item.h | 62 ++++++++++++++++++++++ 3 files changed, 196 insertions(+), 1 deletion(-) create mode 100644 src/launcher-menu-item.c create mode 100644 src/launcher-menu-item.h diff --git a/src/Makefile.am b/src/Makefile.am index 4944c45..fea03eb 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -8,6 +8,6 @@ libmessaging_la_CFLAGS = $(APPLET_CFLAGS) -Wall -Wl,-Bsymbolic-functions -Wl,-z, libmessaging_la_LIBADD = $(APPLET_LIBS) libmessaging_la_LDFLAGS = -module -avoid-version -indicator_messages_service_SOURCES = indicator-service.c im-menu-item.c im-menu-item.h app-menu-item.c app-menu-item.h +indicator_messages_service_SOURCES = indicator-service.c im-menu-item.c im-menu-item.h app-menu-item.c app-menu-item.h launcher-menu-item.c launcher-menu-item.h indicator_messages_service_CFLAGS = $(APPLET_CFLAGS) -Wall -Wl,-Bsymbolic-functions -Wl,-z,defs -Wl,--as-needed -Werror indicator_messages_service_LDADD = $(APPLET_LIBS) diff --git a/src/launcher-menu-item.c b/src/launcher-menu-item.c new file mode 100644 index 0000000..ce8fd5f --- /dev/null +++ b/src/launcher-menu-item.c @@ -0,0 +1,133 @@ +/* +An indicator to show information that is in messaging applications +that the user is using. + +Copyright 2009 Canonical Ltd. + +Authors: + Ted Gould + +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 . +*/ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include "launcher-menu-item.h" + +enum { + NAME_CHANGED, + LAST_SIGNAL +}; + +static guint signals[LAST_SIGNAL] = { 0 }; + +typedef struct _LauncherMenuItemPrivate LauncherMenuItemPrivate; +struct _LauncherMenuItemPrivate +{ + GAppInfo * appinfo; +}; + +#define LAUNCHER_MENU_ITEM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), LAUNCHER_MENU_ITEM_TYPE, LauncherMenuItemPrivate)) + +/* Prototypes */ +static void launcher_menu_item_class_init (LauncherMenuItemClass *klass); +static void launcher_menu_item_init (LauncherMenuItem *self); +static void launcher_menu_item_dispose (GObject *object); +static void launcher_menu_item_finalize (GObject *object); + + +G_DEFINE_TYPE (LauncherMenuItem, launcher_menu_item, DBUSMENU_TYPE_MENUITEM); + +static void +launcher_menu_item_class_init (LauncherMenuItemClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + g_type_class_add_private (klass, sizeof (LauncherMenuItemPrivate)); + + object_class->dispose = launcher_menu_item_dispose; + object_class->finalize = launcher_menu_item_finalize; + + signals[NAME_CHANGED] = g_signal_new(LAUNCHER_MENU_ITEM_SIGNAL_NAME_CHANGED, + G_TYPE_FROM_CLASS(klass), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (LauncherMenuItemClass, name_changed), + NULL, NULL, + g_cclosure_marshal_VOID__STRING, + G_TYPE_NONE, 1, G_TYPE_STRING); + + return; +} + +static void +launcher_menu_item_init (LauncherMenuItem *self) +{ + g_debug("Building new Launcher Menu Item"); + LauncherMenuItemPrivate * priv = LAUNCHER_MENU_ITEM_GET_PRIVATE(self); + + priv->appinfo = NULL; + + return; +} + +static void +launcher_menu_item_dispose (GObject *object) +{ + // LauncherMenuItem * self = LAUNCHER_MENU_ITEM(object); + // LauncherMenuItemPrivate * priv = LAUNCHER_MENU_ITEM_GET_PRIVATE(self); + + G_OBJECT_CLASS (launcher_menu_item_parent_class)->dispose (object); +} + +static void +launcher_menu_item_finalize (GObject *object) +{ + LauncherMenuItem * self = LAUNCHER_MENU_ITEM(object); + LauncherMenuItemPrivate * priv = LAUNCHER_MENU_ITEM_GET_PRIVATE(self); + + if (priv->appinfo != NULL) { + g_object_unref(priv->appinfo); + } + + G_OBJECT_CLASS (launcher_menu_item_parent_class)->finalize (object); + + return; +} + +LauncherMenuItem * +launcher_menu_item_new (const gchar * desktop_file) +{ + LauncherMenuItem * self = g_object_new(LAUNCHER_MENU_ITEM_TYPE, NULL); + + LauncherMenuItemPrivate * priv = LAUNCHER_MENU_ITEM_GET_PRIVATE(self); + + priv->appinfo = G_APP_INFO(g_desktop_app_info_new_from_filename(desktop_file)); + + return self; +} + +const gchar * +launcher_menu_item_get_name (LauncherMenuItem * appitem) +{ + LauncherMenuItemPrivate * priv = LAUNCHER_MENU_ITEM_GET_PRIVATE(appitem); + + if (priv->appinfo == NULL) { + return NULL; + } else { + return g_app_info_get_name(priv->appinfo); + } +} diff --git a/src/launcher-menu-item.h b/src/launcher-menu-item.h new file mode 100644 index 0000000..c351dd9 --- /dev/null +++ b/src/launcher-menu-item.h @@ -0,0 +1,62 @@ +/* +An indicator to show information that is in messaging applications +that the user is using. + +Copyright 2009 Canonical Ltd. + +Authors: + Ted Gould + +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 . +*/ + +#ifndef __LAUNCHER_MENU_ITEM_H__ +#define __LAUNCHER_MENU_ITEM_H__ + +#include +#include + +#include + +G_BEGIN_DECLS + +#define LAUNCHER_MENU_ITEM_TYPE (launcher_menu_item_get_type ()) +#define LAUNCHER_MENU_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), LAUNCHER_MENU_ITEM_TYPE, LauncherMenuItem)) +#define LAUNCHER_MENU_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), LAUNCHER_MENU_ITEM_TYPE, LauncherMenuItemClass)) +#define IS_LAUNCHER_MENU_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), LAUNCHER_MENU_ITEM_TYPE)) +#define IS_LAUNCHER_MENU_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), LAUNCHER_MENU_ITEM_TYPE)) +#define LAUNCHER_MENU_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), LAUNCHER_MENU_ITEM_TYPE, LauncherMenuItemClass)) + +#define LAUNCHER_MENU_ITEM_SIGNAL_NAME_CHANGED "name-changed" + +typedef struct _LauncherMenuItem LauncherMenuItem; +typedef struct _LauncherMenuItemClass LauncherMenuItemClass; + +struct _LauncherMenuItemClass { + DbusmenuMenuitemClass parent_class; + + void (* name_changed) (gchar * name); +}; + +struct _LauncherMenuItem { + DbusmenuMenuitem parent; +}; + +GType launcher_menu_item_get_type (void); +LauncherMenuItem * launcher_menu_item_new (const gchar * desktop_file); +const gchar * launcher_menu_item_get_name (LauncherMenuItem * appitem); + +G_END_DECLS + +#endif /* __LAUNCHER_MENU_ITEM_H__ */ + -- cgit v1.2.3 From d44ae676f2d89a286a8298927bdda89725d91603 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 19 Aug 2009 15:39:40 -0500 Subject: Not sure why, but the naming of this file is really bugging me. Fixed now. --- src/Makefile.am | 2 +- src/indicator-service.c | 536 ------------------------------------------------ src/messages-service.c | 536 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 537 insertions(+), 537 deletions(-) delete mode 100644 src/indicator-service.c create mode 100644 src/messages-service.c diff --git a/src/Makefile.am b/src/Makefile.am index fea03eb..0428cbb 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -8,6 +8,6 @@ libmessaging_la_CFLAGS = $(APPLET_CFLAGS) -Wall -Wl,-Bsymbolic-functions -Wl,-z, libmessaging_la_LIBADD = $(APPLET_LIBS) libmessaging_la_LDFLAGS = -module -avoid-version -indicator_messages_service_SOURCES = indicator-service.c im-menu-item.c im-menu-item.h app-menu-item.c app-menu-item.h launcher-menu-item.c launcher-menu-item.h +indicator_messages_service_SOURCES = messages-service.c im-menu-item.c im-menu-item.h app-menu-item.c app-menu-item.h launcher-menu-item.c launcher-menu-item.h indicator_messages_service_CFLAGS = $(APPLET_CFLAGS) -Wall -Wl,-Bsymbolic-functions -Wl,-z,defs -Wl,--as-needed -Werror indicator_messages_service_LDADD = $(APPLET_LIBS) diff --git a/src/indicator-service.c b/src/indicator-service.c deleted file mode 100644 index 93c926b..0000000 --- a/src/indicator-service.c +++ /dev/null @@ -1,536 +0,0 @@ -/* -An indicator to show information that is in messaging applications -that the user is using. - -Copyright 2009 Canonical Ltd. - -Authors: - Ted Gould - -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 . -*/ - -#include -#include -#include - -#include - -#include "im-menu-item.h" -#include "app-menu-item.h" -#include "launcher-menu-item.h" -#include "dbus-data.h" - -static IndicateListener * listener; -static GList * serverList; - -static DbusmenuMenuitem * root_menuitem = NULL; -static GMainLoop * mainloop = NULL; - - -static void server_count_changed (AppMenuItem * appitem, guint count, gpointer data); -static void server_name_changed (AppMenuItem * appitem, gchar * name, gpointer data); -static void im_time_changed (ImMenuItem * imitem, glong seconds, gpointer data); -static void reconsile_list_and_menu (GList * serverlist, DbusmenuMenuitem * menushell); -static void indicator_removed (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * type, gpointer data); - -typedef struct _serverList_t serverList_t; -struct _serverList_t { - IndicateListenerServer * server; - AppMenuItem * menuitem; - GList * imList; -}; - -static gint -serverList_equal (gconstpointer a, gconstpointer b) -{ - serverList_t * pa, * pb; - - pa = (serverList_t *)a; - pb = (serverList_t *)b; - - const gchar * pas = INDICATE_LISTENER_SERVER_DBUS_NAME(pa->server); - const gchar * pbs = INDICATE_LISTENER_SERVER_DBUS_NAME(pb->server); - - return g_strcmp0(pas, pbs); -} - -static gint -serverList_sort (gconstpointer a, gconstpointer b) -{ - serverList_t * pa, * pb; - - pa = (serverList_t *)a; - pb = (serverList_t *)b; - - const gchar * pan = app_menu_item_get_name(pa->menuitem); - const gchar * pbn = app_menu_item_get_name(pb->menuitem); - - return g_strcmp0(pan, pbn); -} - -typedef struct _imList_t imList_t; -struct _imList_t { - IndicateListenerServer * server; - IndicateListenerIndicator * indicator; - DbusmenuMenuitem * menuitem; - gulong timechange_cb; -}; - -static gboolean -imList_equal (gconstpointer a, gconstpointer b) -{ - imList_t * pa, * pb; - - pa = (imList_t *)a; - pb = (imList_t *)b; - - const gchar * pas = INDICATE_LISTENER_SERVER_DBUS_NAME(pa->server); - const gchar * pbs = INDICATE_LISTENER_SERVER_DBUS_NAME(pb->server); - - guint pai = INDICATE_LISTENER_INDICATOR_ID(pa->indicator); - guint pbi = INDICATE_LISTENER_INDICATOR_ID(pb->indicator); - - g_debug("\tComparing (%s %d) to (%s %d)", pas, pai, pbs, pbi); - - return !((!g_strcmp0(pas, pbs)) && (pai == pbi)); -} - -static gint -imList_sort (gconstpointer a, gconstpointer b) -{ - imList_t * pa, * pb; - - pa = (imList_t *)a; - pb = (imList_t *)b; - - return (gint)(im_menu_item_get_seconds(IM_MENU_ITEM(pb->menuitem)) - im_menu_item_get_seconds(IM_MENU_ITEM(pa->menuitem))); -} - -typedef struct _launcherList_t launcherList_t; -struct _launcherList_t { - LauncherMenuItem * menuitem; -}; - -static gint -launcherList_sort (gconstpointer a, gconstpointer b) -{ - launcherList_t * pa, * pb; - - pa = (launcherList_t *)a; - pb = (launcherList_t *)b; - - const gchar * pan = launcher_menu_item_get_name(pa->menuitem); - const gchar * pbn = launcher_menu_item_get_name(pb->menuitem); - - return g_strcmp0(pan, pbn); -} - -static void -server_added (IndicateListener * listener, IndicateListenerServer * server, gchar * type, gpointer data) -{ - g_debug("Server Added '%s' of type '%s'.", INDICATE_LISTENER_SERVER_DBUS_NAME(server), type); - if (type == NULL) { - return; - } - - if (type[0] == '\0') { - return; - } - - if (strncmp(type, "message", strlen("message"))) { - g_debug("\tServer type '%s' is not a message based type.", type); - return; - } - - DbusmenuMenuitem * menushell = DBUSMENU_MENUITEM(data); - if (menushell == NULL) { - g_error("\tData in callback is not a menushell"); - return; - } - - AppMenuItem * menuitem = app_menu_item_new(listener, server); - g_signal_connect(G_OBJECT(menuitem), APP_MENU_ITEM_SIGNAL_COUNT_CHANGED, G_CALLBACK(server_count_changed), NULL); - g_signal_connect(G_OBJECT(menuitem), APP_MENU_ITEM_SIGNAL_NAME_CHANGED, G_CALLBACK(server_name_changed), menushell); - - serverList_t * sl_item = g_new0(serverList_t, 1); - sl_item->server = server; - sl_item->menuitem = menuitem; - sl_item->imList = NULL; - - /* Incase we got an indicator first */ - GList * alreadythere = g_list_find_custom(serverList, sl_item, serverList_equal); - if (alreadythere != NULL) { - g_free(sl_item); - sl_item = (serverList_t *)alreadythere->data; - sl_item->menuitem = menuitem; - serverList = g_list_sort(serverList, serverList_sort); - } else { - serverList = g_list_insert_sorted(serverList, sl_item, serverList_sort); - } - - dbusmenu_menuitem_child_append(menushell, DBUSMENU_MENUITEM(menuitem)); - /* Should be prepend ^ */ - - reconsile_list_and_menu(serverList, menushell); - - return; -} - -static void -server_name_changed (AppMenuItem * appitem, gchar * name, gpointer data) -{ - serverList = g_list_sort(serverList, serverList_sort); - reconsile_list_and_menu(serverList, DBUSMENU_MENUITEM(data)); - return; -} - -static void -server_count_changed (AppMenuItem * appitem, guint count, gpointer data) -{ - static gboolean showing_new_icon = FALSE; - - /* Quick check for a common case */ - if (count != 0 && showing_new_icon) { - return; - } - - /* Odd that we'd get a signal in this case, but let's - take it out of the mix too */ - if (count == 0 && !showing_new_icon) { - return; - } - - if (count != 0) { - g_debug("Setting image to 'new'"); - showing_new_icon = TRUE; - /* gtk_image_set_from_icon_name(GTK_IMAGE(main_image), "indicator-messages-new", DESIGN_TEAM_SIZE); */ - return; - } - - /* Okay, now at this point the count is zero and it - might result in a switching of the icon back to being - the plain one. Let's check. */ - - gboolean we_have_indicators = FALSE; - GList * appitems = serverList; - for (; appitems != NULL; appitems = appitems->next) { - AppMenuItem * appitem = ((serverList_t *)appitems->data)->menuitem; - if (app_menu_item_get_count(appitem) != 0) { - we_have_indicators = TRUE; - break; - } - } - - if (!we_have_indicators) { - g_debug("Setting image to boring"); - showing_new_icon = FALSE; - /* gtk_image_set_from_icon_name(GTK_IMAGE(main_image), "indicator-messages", DESIGN_TEAM_SIZE); */ - } - - return; -} - -static void -im_time_changed (ImMenuItem * imitem, glong seconds, gpointer data) -{ - serverList_t * sl = (serverList_t *)data; - sl->imList = g_list_sort(sl->imList, imList_sort); - reconsile_list_and_menu(serverList, root_menuitem); - return; -} - -static void -server_removed (IndicateListener * listener, IndicateListenerServer * server, gchar * type, gpointer data) -{ - g_debug("Removing server: %s", INDICATE_LISTENER_SERVER_DBUS_NAME(server)); - serverList_t slt; - slt.server = server; - GList * lookup = g_list_find_custom(serverList, &slt, serverList_equal); - - if (lookup == NULL) { - g_debug("\tUnable to find server: %s", INDICATE_LISTENER_SERVER_DBUS_NAME(server)); - return; - } - - serverList_t * sltp = (serverList_t *)lookup->data; - - while (sltp->imList) { - imList_t * imitem = (imList_t *)sltp->imList->data; - indicator_removed(listener, server, imitem->indicator, "message", data); - } - - serverList = g_list_remove(serverList, sltp); - - if (sltp->menuitem != NULL) { - dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(sltp->menuitem), "visibile", "false"); - dbusmenu_menuitem_child_delete(DBUSMENU_MENUITEM(data), DBUSMENU_MENUITEM(sltp->menuitem)); - g_object_unref(G_OBJECT(sltp->menuitem)); - } - - g_free(sltp); - - /* Simulate a server saying zero to recalculate icon */ - server_count_changed(NULL, 0, NULL); - - return; -} - -typedef struct _menushell_location menushell_location_t; -struct _menushell_location { - const IndicateListenerServer * server; - gint position; - gboolean found; -}; - -static void -menushell_foreach_cb (DbusmenuMenuitem * data_mi, gpointer data_ms) { - menushell_location_t * msl = (menushell_location_t *)data_ms; - - if (msl->found) return; - - msl->position++; - - if (!IS_APP_MENU_ITEM(data_mi)) { - return; - } - - AppMenuItem * appmenu = APP_MENU_ITEM(data_mi); - if (!g_strcmp0(INDICATE_LISTENER_SERVER_DBUS_NAME((IndicateListenerServer*)msl->server), INDICATE_LISTENER_SERVER_DBUS_NAME(app_menu_item_get_server(appmenu)))) { - msl->found = TRUE; - } - - return; -} - -static void -reconsile_list_and_menu (GList * serverlist, DbusmenuMenuitem * menushell) -{ - guint position = 0; - GList * serverentry; - - g_debug("Reordering Menu:"); - - for (serverentry = serverList; serverentry != NULL; serverentry = serverentry->next) { - serverList_t * si = (serverList_t *)serverentry->data; - if (si->menuitem != NULL) { - g_debug("\tMoving app %s to position %d", INDICATE_LISTENER_SERVER_DBUS_NAME(si->server), position); - dbusmenu_menuitem_child_reorder(DBUSMENU_MENUITEM(menushell), DBUSMENU_MENUITEM(si->menuitem), position); - position++; - } - - GList * imentry; - for (imentry = si->imList; imentry != NULL; imentry = imentry->next) { - imList_t * imi = (imList_t *)imentry->data; - - if (imi->menuitem != NULL) { - g_debug("\tMoving indicator on %s id %d to position %d", INDICATE_LISTENER_SERVER_DBUS_NAME(imi->server), INDICATE_LISTENER_INDICATOR_ID(imi->indicator), position); - dbusmenu_menuitem_child_reorder(DBUSMENU_MENUITEM(menushell), DBUSMENU_MENUITEM(imi->menuitem), position); - position++; - } - } - } - - return; -} - -static void -subtype_cb (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * property, gchar * propertydata, gpointer data) -{ - DbusmenuMenuitem * menushell = DBUSMENU_MENUITEM(data); - if (menushell == NULL) { - g_error("Data in callback is not a menushell"); - return; - } - - if (property == NULL || g_strcmp0(property, "subtype")) { - /* We should only ever get subtypes, but just in case */ - g_warning("Subtype callback got a property '%s'", property); - return; - } - - if (propertydata == NULL || propertydata[0] == '\0') { - /* It's possible that this message didn't have a subtype. That's - * okay, but we don't want to display those */ - g_debug("No subtype"); - return; - } - - g_debug("Message subtype: %s", propertydata); - - if (!g_strcmp0(propertydata, "im") || !g_strcmp0(propertydata, "login")) { - imList_t * listItem = g_new0(imList_t, 1); - listItem->server = server; - listItem->indicator = indicator; - - g_debug("Building IM Item"); - ImMenuItem * menuitem = im_menu_item_new(listener, server, indicator, !g_strcmp0(propertydata, "im")); - g_object_ref(G_OBJECT(menuitem)); - listItem->menuitem = DBUSMENU_MENUITEM(menuitem); - - g_debug("Finding the server entry"); - serverList_t sl_item_local; - serverList_t * sl_item = NULL; - sl_item_local.server = server; - GList * serverentry = g_list_find_custom(serverList, &sl_item_local, serverList_equal); - - if (serverentry == NULL) { - /* This sucks, we got an indicator before the server. I guess - that's the joy of being asynchronous */ - serverList_t * sl_item = g_new0(serverList_t, 1); - sl_item->server = server; - sl_item->menuitem = NULL; - sl_item->imList = NULL; - - serverList = g_list_insert_sorted(serverList, sl_item, serverList_sort); - } else { - sl_item = (serverList_t *)serverentry->data; - } - - g_debug("Adding to IM List"); - sl_item->imList = g_list_insert_sorted(sl_item->imList, listItem, imList_sort); - listItem->timechange_cb = g_signal_connect(G_OBJECT(menuitem), IM_MENU_ITEM_SIGNAL_TIME_CHANGED, G_CALLBACK(im_time_changed), sl_item); - - g_debug("Placing in Shell"); - menushell_location_t msl; - msl.found = FALSE; - msl.position = 0; - msl.server = server; - - dbusmenu_menuitem_foreach(DBUSMENU_MENUITEM(menushell), menushell_foreach_cb, &msl); - if (msl.found) { - dbusmenu_menuitem_child_add_position(menushell, DBUSMENU_MENUITEM(menuitem), msl.position); - } else { - g_warning("Unable to find server menu item"); - dbusmenu_menuitem_child_append(menushell, DBUSMENU_MENUITEM(menuitem)); - } - } - - return; -} - -static void -indicator_added (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * type, gpointer data) -{ - if (type == NULL || g_strcmp0(type, "message")) { - /* We only care about message type indicators - all of the others can go to the bit bucket */ - g_debug("Ignoreing indicator of type '%s'", type); - return; - } - g_debug("Got a message"); - - indicate_listener_get_property(listener, server, indicator, "subtype", subtype_cb, data); - return; -} - -static void -indicator_removed (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * type, gpointer data) -{ - g_debug("Removing %s %d", INDICATE_LISTENER_SERVER_DBUS_NAME(server), INDICATE_LISTENER_INDICATOR_ID(indicator)); - if (type == NULL || g_strcmp0(type, "message")) { - /* We only care about message type indicators - all of the others can go to the bit bucket */ - g_debug("Ignoreing indicator of type '%s'", type); - return; - } - - gboolean removed = FALSE; - - serverList_t sl_item_local; - serverList_t * sl_item = NULL; - sl_item_local.server = server; - GList * serverentry = g_list_find_custom(serverList, &sl_item_local, serverList_equal); - if (serverentry == NULL) { - return; - } - sl_item = (serverList_t *)serverentry->data; - - /* Look in the IM Hash Table */ - imList_t listData; - listData.server = server; - listData.indicator = indicator; - - GList * listItem = g_list_find_custom(sl_item->imList, &listData, imList_equal); - DbusmenuMenuitem * menuitem = NULL; - imList_t * ilt = NULL; - if (listItem != NULL) { - ilt = (imList_t *)listItem->data; - menuitem = ilt->menuitem; - } - - if (!removed && menuitem != NULL) { - sl_item->imList = g_list_remove(sl_item->imList, ilt); - g_signal_handler_disconnect(menuitem, ilt->timechange_cb); - g_free(ilt); - - dbusmenu_menuitem_property_set(menuitem, "visibile", "false"); - dbusmenu_menuitem_child_delete(DBUSMENU_MENUITEM(data), menuitem); - removed = TRUE; - } - - if (!removed) { - g_warning("We were asked to remove %s %d but we didn't.", INDICATE_LISTENER_SERVER_DBUS_NAME(server), INDICATE_LISTENER_INDICATOR_ID(indicator)); - } - - return; -} - -gboolean -build_launchers (gpointer data) -{ - - - - return FALSE; -} - -int -main (int argc, char ** argv) -{ - g_type_init(); - - DBusGConnection * connection = dbus_g_bus_get(DBUS_BUS_SESSION, NULL); - DBusGProxy * bus_proxy = dbus_g_proxy_new_for_name(connection, DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS); - GError * error = NULL; - guint nameret = 0; - - if (!org_freedesktop_DBus_request_name(bus_proxy, INDICATOR_MESSAGES_DBUS_NAME, 0, &nameret, &error)) { - g_error("Unable to call to request name"); - return 1; - } - - if (nameret != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) { - g_error("Unable to get name"); - return 1; - } - - listener = indicate_listener_ref_default(); - serverList = NULL; - - root_menuitem = dbusmenu_menuitem_new(); - DbusmenuServer * server = dbusmenu_server_new(INDICATOR_MESSAGES_DBUS_OBJECT); - dbusmenu_server_set_root(server, root_menuitem); - - g_signal_connect(listener, INDICATE_LISTENER_SIGNAL_INDICATOR_ADDED, G_CALLBACK(indicator_added), root_menuitem); - g_signal_connect(listener, INDICATE_LISTENER_SIGNAL_INDICATOR_REMOVED, G_CALLBACK(indicator_removed), root_menuitem); - g_signal_connect(listener, INDICATE_LISTENER_SIGNAL_SERVER_ADDED, G_CALLBACK(server_added), root_menuitem); - g_signal_connect(listener, INDICATE_LISTENER_SIGNAL_SERVER_REMOVED, G_CALLBACK(server_removed), root_menuitem); - - g_idle_add(build_launchers, NULL); - - mainloop = g_main_loop_new(NULL, FALSE); - g_main_loop_run(mainloop); - - return 0; -} diff --git a/src/messages-service.c b/src/messages-service.c new file mode 100644 index 0000000..93c926b --- /dev/null +++ b/src/messages-service.c @@ -0,0 +1,536 @@ +/* +An indicator to show information that is in messaging applications +that the user is using. + +Copyright 2009 Canonical Ltd. + +Authors: + Ted Gould + +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 . +*/ + +#include +#include +#include + +#include + +#include "im-menu-item.h" +#include "app-menu-item.h" +#include "launcher-menu-item.h" +#include "dbus-data.h" + +static IndicateListener * listener; +static GList * serverList; + +static DbusmenuMenuitem * root_menuitem = NULL; +static GMainLoop * mainloop = NULL; + + +static void server_count_changed (AppMenuItem * appitem, guint count, gpointer data); +static void server_name_changed (AppMenuItem * appitem, gchar * name, gpointer data); +static void im_time_changed (ImMenuItem * imitem, glong seconds, gpointer data); +static void reconsile_list_and_menu (GList * serverlist, DbusmenuMenuitem * menushell); +static void indicator_removed (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * type, gpointer data); + +typedef struct _serverList_t serverList_t; +struct _serverList_t { + IndicateListenerServer * server; + AppMenuItem * menuitem; + GList * imList; +}; + +static gint +serverList_equal (gconstpointer a, gconstpointer b) +{ + serverList_t * pa, * pb; + + pa = (serverList_t *)a; + pb = (serverList_t *)b; + + const gchar * pas = INDICATE_LISTENER_SERVER_DBUS_NAME(pa->server); + const gchar * pbs = INDICATE_LISTENER_SERVER_DBUS_NAME(pb->server); + + return g_strcmp0(pas, pbs); +} + +static gint +serverList_sort (gconstpointer a, gconstpointer b) +{ + serverList_t * pa, * pb; + + pa = (serverList_t *)a; + pb = (serverList_t *)b; + + const gchar * pan = app_menu_item_get_name(pa->menuitem); + const gchar * pbn = app_menu_item_get_name(pb->menuitem); + + return g_strcmp0(pan, pbn); +} + +typedef struct _imList_t imList_t; +struct _imList_t { + IndicateListenerServer * server; + IndicateListenerIndicator * indicator; + DbusmenuMenuitem * menuitem; + gulong timechange_cb; +}; + +static gboolean +imList_equal (gconstpointer a, gconstpointer b) +{ + imList_t * pa, * pb; + + pa = (imList_t *)a; + pb = (imList_t *)b; + + const gchar * pas = INDICATE_LISTENER_SERVER_DBUS_NAME(pa->server); + const gchar * pbs = INDICATE_LISTENER_SERVER_DBUS_NAME(pb->server); + + guint pai = INDICATE_LISTENER_INDICATOR_ID(pa->indicator); + guint pbi = INDICATE_LISTENER_INDICATOR_ID(pb->indicator); + + g_debug("\tComparing (%s %d) to (%s %d)", pas, pai, pbs, pbi); + + return !((!g_strcmp0(pas, pbs)) && (pai == pbi)); +} + +static gint +imList_sort (gconstpointer a, gconstpointer b) +{ + imList_t * pa, * pb; + + pa = (imList_t *)a; + pb = (imList_t *)b; + + return (gint)(im_menu_item_get_seconds(IM_MENU_ITEM(pb->menuitem)) - im_menu_item_get_seconds(IM_MENU_ITEM(pa->menuitem))); +} + +typedef struct _launcherList_t launcherList_t; +struct _launcherList_t { + LauncherMenuItem * menuitem; +}; + +static gint +launcherList_sort (gconstpointer a, gconstpointer b) +{ + launcherList_t * pa, * pb; + + pa = (launcherList_t *)a; + pb = (launcherList_t *)b; + + const gchar * pan = launcher_menu_item_get_name(pa->menuitem); + const gchar * pbn = launcher_menu_item_get_name(pb->menuitem); + + return g_strcmp0(pan, pbn); +} + +static void +server_added (IndicateListener * listener, IndicateListenerServer * server, gchar * type, gpointer data) +{ + g_debug("Server Added '%s' of type '%s'.", INDICATE_LISTENER_SERVER_DBUS_NAME(server), type); + if (type == NULL) { + return; + } + + if (type[0] == '\0') { + return; + } + + if (strncmp(type, "message", strlen("message"))) { + g_debug("\tServer type '%s' is not a message based type.", type); + return; + } + + DbusmenuMenuitem * menushell = DBUSMENU_MENUITEM(data); + if (menushell == NULL) { + g_error("\tData in callback is not a menushell"); + return; + } + + AppMenuItem * menuitem = app_menu_item_new(listener, server); + g_signal_connect(G_OBJECT(menuitem), APP_MENU_ITEM_SIGNAL_COUNT_CHANGED, G_CALLBACK(server_count_changed), NULL); + g_signal_connect(G_OBJECT(menuitem), APP_MENU_ITEM_SIGNAL_NAME_CHANGED, G_CALLBACK(server_name_changed), menushell); + + serverList_t * sl_item = g_new0(serverList_t, 1); + sl_item->server = server; + sl_item->menuitem = menuitem; + sl_item->imList = NULL; + + /* Incase we got an indicator first */ + GList * alreadythere = g_list_find_custom(serverList, sl_item, serverList_equal); + if (alreadythere != NULL) { + g_free(sl_item); + sl_item = (serverList_t *)alreadythere->data; + sl_item->menuitem = menuitem; + serverList = g_list_sort(serverList, serverList_sort); + } else { + serverList = g_list_insert_sorted(serverList, sl_item, serverList_sort); + } + + dbusmenu_menuitem_child_append(menushell, DBUSMENU_MENUITEM(menuitem)); + /* Should be prepend ^ */ + + reconsile_list_and_menu(serverList, menushell); + + return; +} + +static void +server_name_changed (AppMenuItem * appitem, gchar * name, gpointer data) +{ + serverList = g_list_sort(serverList, serverList_sort); + reconsile_list_and_menu(serverList, DBUSMENU_MENUITEM(data)); + return; +} + +static void +server_count_changed (AppMenuItem * appitem, guint count, gpointer data) +{ + static gboolean showing_new_icon = FALSE; + + /* Quick check for a common case */ + if (count != 0 && showing_new_icon) { + return; + } + + /* Odd that we'd get a signal in this case, but let's + take it out of the mix too */ + if (count == 0 && !showing_new_icon) { + return; + } + + if (count != 0) { + g_debug("Setting image to 'new'"); + showing_new_icon = TRUE; + /* gtk_image_set_from_icon_name(GTK_IMAGE(main_image), "indicator-messages-new", DESIGN_TEAM_SIZE); */ + return; + } + + /* Okay, now at this point the count is zero and it + might result in a switching of the icon back to being + the plain one. Let's check. */ + + gboolean we_have_indicators = FALSE; + GList * appitems = serverList; + for (; appitems != NULL; appitems = appitems->next) { + AppMenuItem * appitem = ((serverList_t *)appitems->data)->menuitem; + if (app_menu_item_get_count(appitem) != 0) { + we_have_indicators = TRUE; + break; + } + } + + if (!we_have_indicators) { + g_debug("Setting image to boring"); + showing_new_icon = FALSE; + /* gtk_image_set_from_icon_name(GTK_IMAGE(main_image), "indicator-messages", DESIGN_TEAM_SIZE); */ + } + + return; +} + +static void +im_time_changed (ImMenuItem * imitem, glong seconds, gpointer data) +{ + serverList_t * sl = (serverList_t *)data; + sl->imList = g_list_sort(sl->imList, imList_sort); + reconsile_list_and_menu(serverList, root_menuitem); + return; +} + +static void +server_removed (IndicateListener * listener, IndicateListenerServer * server, gchar * type, gpointer data) +{ + g_debug("Removing server: %s", INDICATE_LISTENER_SERVER_DBUS_NAME(server)); + serverList_t slt; + slt.server = server; + GList * lookup = g_list_find_custom(serverList, &slt, serverList_equal); + + if (lookup == NULL) { + g_debug("\tUnable to find server: %s", INDICATE_LISTENER_SERVER_DBUS_NAME(server)); + return; + } + + serverList_t * sltp = (serverList_t *)lookup->data; + + while (sltp->imList) { + imList_t * imitem = (imList_t *)sltp->imList->data; + indicator_removed(listener, server, imitem->indicator, "message", data); + } + + serverList = g_list_remove(serverList, sltp); + + if (sltp->menuitem != NULL) { + dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(sltp->menuitem), "visibile", "false"); + dbusmenu_menuitem_child_delete(DBUSMENU_MENUITEM(data), DBUSMENU_MENUITEM(sltp->menuitem)); + g_object_unref(G_OBJECT(sltp->menuitem)); + } + + g_free(sltp); + + /* Simulate a server saying zero to recalculate icon */ + server_count_changed(NULL, 0, NULL); + + return; +} + +typedef struct _menushell_location menushell_location_t; +struct _menushell_location { + const IndicateListenerServer * server; + gint position; + gboolean found; +}; + +static void +menushell_foreach_cb (DbusmenuMenuitem * data_mi, gpointer data_ms) { + menushell_location_t * msl = (menushell_location_t *)data_ms; + + if (msl->found) return; + + msl->position++; + + if (!IS_APP_MENU_ITEM(data_mi)) { + return; + } + + AppMenuItem * appmenu = APP_MENU_ITEM(data_mi); + if (!g_strcmp0(INDICATE_LISTENER_SERVER_DBUS_NAME((IndicateListenerServer*)msl->server), INDICATE_LISTENER_SERVER_DBUS_NAME(app_menu_item_get_server(appmenu)))) { + msl->found = TRUE; + } + + return; +} + +static void +reconsile_list_and_menu (GList * serverlist, DbusmenuMenuitem * menushell) +{ + guint position = 0; + GList * serverentry; + + g_debug("Reordering Menu:"); + + for (serverentry = serverList; serverentry != NULL; serverentry = serverentry->next) { + serverList_t * si = (serverList_t *)serverentry->data; + if (si->menuitem != NULL) { + g_debug("\tMoving app %s to position %d", INDICATE_LISTENER_SERVER_DBUS_NAME(si->server), position); + dbusmenu_menuitem_child_reorder(DBUSMENU_MENUITEM(menushell), DBUSMENU_MENUITEM(si->menuitem), position); + position++; + } + + GList * imentry; + for (imentry = si->imList; imentry != NULL; imentry = imentry->next) { + imList_t * imi = (imList_t *)imentry->data; + + if (imi->menuitem != NULL) { + g_debug("\tMoving indicator on %s id %d to position %d", INDICATE_LISTENER_SERVER_DBUS_NAME(imi->server), INDICATE_LISTENER_INDICATOR_ID(imi->indicator), position); + dbusmenu_menuitem_child_reorder(DBUSMENU_MENUITEM(menushell), DBUSMENU_MENUITEM(imi->menuitem), position); + position++; + } + } + } + + return; +} + +static void +subtype_cb (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * property, gchar * propertydata, gpointer data) +{ + DbusmenuMenuitem * menushell = DBUSMENU_MENUITEM(data); + if (menushell == NULL) { + g_error("Data in callback is not a menushell"); + return; + } + + if (property == NULL || g_strcmp0(property, "subtype")) { + /* We should only ever get subtypes, but just in case */ + g_warning("Subtype callback got a property '%s'", property); + return; + } + + if (propertydata == NULL || propertydata[0] == '\0') { + /* It's possible that this message didn't have a subtype. That's + * okay, but we don't want to display those */ + g_debug("No subtype"); + return; + } + + g_debug("Message subtype: %s", propertydata); + + if (!g_strcmp0(propertydata, "im") || !g_strcmp0(propertydata, "login")) { + imList_t * listItem = g_new0(imList_t, 1); + listItem->server = server; + listItem->indicator = indicator; + + g_debug("Building IM Item"); + ImMenuItem * menuitem = im_menu_item_new(listener, server, indicator, !g_strcmp0(propertydata, "im")); + g_object_ref(G_OBJECT(menuitem)); + listItem->menuitem = DBUSMENU_MENUITEM(menuitem); + + g_debug("Finding the server entry"); + serverList_t sl_item_local; + serverList_t * sl_item = NULL; + sl_item_local.server = server; + GList * serverentry = g_list_find_custom(serverList, &sl_item_local, serverList_equal); + + if (serverentry == NULL) { + /* This sucks, we got an indicator before the server. I guess + that's the joy of being asynchronous */ + serverList_t * sl_item = g_new0(serverList_t, 1); + sl_item->server = server; + sl_item->menuitem = NULL; + sl_item->imList = NULL; + + serverList = g_list_insert_sorted(serverList, sl_item, serverList_sort); + } else { + sl_item = (serverList_t *)serverentry->data; + } + + g_debug("Adding to IM List"); + sl_item->imList = g_list_insert_sorted(sl_item->imList, listItem, imList_sort); + listItem->timechange_cb = g_signal_connect(G_OBJECT(menuitem), IM_MENU_ITEM_SIGNAL_TIME_CHANGED, G_CALLBACK(im_time_changed), sl_item); + + g_debug("Placing in Shell"); + menushell_location_t msl; + msl.found = FALSE; + msl.position = 0; + msl.server = server; + + dbusmenu_menuitem_foreach(DBUSMENU_MENUITEM(menushell), menushell_foreach_cb, &msl); + if (msl.found) { + dbusmenu_menuitem_child_add_position(menushell, DBUSMENU_MENUITEM(menuitem), msl.position); + } else { + g_warning("Unable to find server menu item"); + dbusmenu_menuitem_child_append(menushell, DBUSMENU_MENUITEM(menuitem)); + } + } + + return; +} + +static void +indicator_added (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * type, gpointer data) +{ + if (type == NULL || g_strcmp0(type, "message")) { + /* We only care about message type indicators + all of the others can go to the bit bucket */ + g_debug("Ignoreing indicator of type '%s'", type); + return; + } + g_debug("Got a message"); + + indicate_listener_get_property(listener, server, indicator, "subtype", subtype_cb, data); + return; +} + +static void +indicator_removed (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * type, gpointer data) +{ + g_debug("Removing %s %d", INDICATE_LISTENER_SERVER_DBUS_NAME(server), INDICATE_LISTENER_INDICATOR_ID(indicator)); + if (type == NULL || g_strcmp0(type, "message")) { + /* We only care about message type indicators + all of the others can go to the bit bucket */ + g_debug("Ignoreing indicator of type '%s'", type); + return; + } + + gboolean removed = FALSE; + + serverList_t sl_item_local; + serverList_t * sl_item = NULL; + sl_item_local.server = server; + GList * serverentry = g_list_find_custom(serverList, &sl_item_local, serverList_equal); + if (serverentry == NULL) { + return; + } + sl_item = (serverList_t *)serverentry->data; + + /* Look in the IM Hash Table */ + imList_t listData; + listData.server = server; + listData.indicator = indicator; + + GList * listItem = g_list_find_custom(sl_item->imList, &listData, imList_equal); + DbusmenuMenuitem * menuitem = NULL; + imList_t * ilt = NULL; + if (listItem != NULL) { + ilt = (imList_t *)listItem->data; + menuitem = ilt->menuitem; + } + + if (!removed && menuitem != NULL) { + sl_item->imList = g_list_remove(sl_item->imList, ilt); + g_signal_handler_disconnect(menuitem, ilt->timechange_cb); + g_free(ilt); + + dbusmenu_menuitem_property_set(menuitem, "visibile", "false"); + dbusmenu_menuitem_child_delete(DBUSMENU_MENUITEM(data), menuitem); + removed = TRUE; + } + + if (!removed) { + g_warning("We were asked to remove %s %d but we didn't.", INDICATE_LISTENER_SERVER_DBUS_NAME(server), INDICATE_LISTENER_INDICATOR_ID(indicator)); + } + + return; +} + +gboolean +build_launchers (gpointer data) +{ + + + + return FALSE; +} + +int +main (int argc, char ** argv) +{ + g_type_init(); + + DBusGConnection * connection = dbus_g_bus_get(DBUS_BUS_SESSION, NULL); + DBusGProxy * bus_proxy = dbus_g_proxy_new_for_name(connection, DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS); + GError * error = NULL; + guint nameret = 0; + + if (!org_freedesktop_DBus_request_name(bus_proxy, INDICATOR_MESSAGES_DBUS_NAME, 0, &nameret, &error)) { + g_error("Unable to call to request name"); + return 1; + } + + if (nameret != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) { + g_error("Unable to get name"); + return 1; + } + + listener = indicate_listener_ref_default(); + serverList = NULL; + + root_menuitem = dbusmenu_menuitem_new(); + DbusmenuServer * server = dbusmenu_server_new(INDICATOR_MESSAGES_DBUS_OBJECT); + dbusmenu_server_set_root(server, root_menuitem); + + g_signal_connect(listener, INDICATE_LISTENER_SIGNAL_INDICATOR_ADDED, G_CALLBACK(indicator_added), root_menuitem); + g_signal_connect(listener, INDICATE_LISTENER_SIGNAL_INDICATOR_REMOVED, G_CALLBACK(indicator_removed), root_menuitem); + g_signal_connect(listener, INDICATE_LISTENER_SIGNAL_SERVER_ADDED, G_CALLBACK(server_added), root_menuitem); + g_signal_connect(listener, INDICATE_LISTENER_SIGNAL_SERVER_REMOVED, G_CALLBACK(server_removed), root_menuitem); + + g_idle_add(build_launchers, NULL); + + mainloop = g_main_loop_new(NULL, FALSE); + g_main_loop_run(mainloop); + + return 0; +} -- cgit v1.2.3 From 24cd5919a5de12b2309ba6f9fa48f402e3d2ae11 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 19 Aug 2009 16:47:04 -0500 Subject: Go through the launchers and start building items --- src/messages-service.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/messages-service.c b/src/messages-service.c index 93c926b..ce3fcdb 100644 --- a/src/messages-service.c +++ b/src/messages-service.c @@ -30,9 +30,11 @@ with this program. If not, see . #include "app-menu-item.h" #include "launcher-menu-item.h" #include "dbus-data.h" +#include "dirs.h" static IndicateListener * listener; -static GList * serverList; +static GList * serverList = NULL; +static GList * launcherList = NULL; static DbusmenuMenuitem * root_menuitem = NULL; static GMainLoop * mainloop = NULL; @@ -489,9 +491,29 @@ indicator_removed (IndicateListener * listener, IndicateListenerServer * server, gboolean build_launchers (gpointer data) { + if (!g_file_test(SYSTEM_APPS_DIR, G_FILE_TEST_IS_DIR)) { + return FALSE; + } + GError * error = NULL; + GDir * dir = g_dir_open(SYSTEM_APPS_DIR, 0, &error); + if (dir == NULL) { + g_warning("Unable to open system apps directory: %s", error->message); + g_error_free(error); + return FALSE; + } + const gchar * filename = NULL; + while ((filename = g_dir_read_name(dir)) != NULL) { + gchar * path = g_build_filename(SYSTEM_APPS_DIR, filename, NULL); + launcherList_t * ll = g_new0(launcherList_t, 1); + ll->menuitem = launcher_menu_item_new(path); + g_free(path); + launcherList = g_list_append(launcherList, ll); + } + g_dir_close(dir); + launcherList = g_list_sort(launcherList, launcherList_sort); return FALSE; } -- cgit v1.2.3 From 23e2cdf7f788996e5dc429444b1fd81425bf3b05 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 19 Aug 2009 16:55:57 -0500 Subject: Spliting out the building of the items as it'll read the desktop file off disk and parse it. --- src/messages-service.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/messages-service.c b/src/messages-service.c index ce3fcdb..481df1d 100644 --- a/src/messages-service.c +++ b/src/messages-service.c @@ -488,6 +488,20 @@ indicator_removed (IndicateListener * listener, IndicateListenerServer * server, return; } +gboolean +build_launcher (gpointer data) +{ + gchar * path = (gchar *)data; + + launcherList_t * ll = g_new0(launcherList_t, 1); + ll->menuitem = launcher_menu_item_new(path); + + g_free(path); + + launcherList = g_list_insert_sorted(launcherList, ll, launcherList_sort); + return FALSE; +} + gboolean build_launchers (gpointer data) { @@ -506,10 +520,7 @@ build_launchers (gpointer data) const gchar * filename = NULL; while ((filename = g_dir_read_name(dir)) != NULL) { gchar * path = g_build_filename(SYSTEM_APPS_DIR, filename, NULL); - launcherList_t * ll = g_new0(launcherList_t, 1); - ll->menuitem = launcher_menu_item_new(path); - g_free(path); - launcherList = g_list_append(launcherList, ll); + g_idle_add(build_launcher, path); } g_dir_close(dir); -- cgit v1.2.3 From a32eba9041f5fb90083f5212bc58bb6d6a094912 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 19 Aug 2009 17:02:27 -0500 Subject: Oops, forgot one level of redirection here --- src/messages-service.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/messages-service.c b/src/messages-service.c index 481df1d..6f62b1f 100644 --- a/src/messages-service.c +++ b/src/messages-service.c @@ -492,11 +492,18 @@ gboolean build_launcher (gpointer data) { gchar * path = (gchar *)data; + gchar * desktop = NULL; + + g_file_get_contents(path, &desktop, NULL, NULL); + g_free(path); + + if (desktop == NULL) { + return FALSE; + } launcherList_t * ll = g_new0(launcherList_t, 1); ll->menuitem = launcher_menu_item_new(path); - g_free(path); launcherList = g_list_insert_sorted(launcherList, ll, launcherList_sort); return FALSE; -- cgit v1.2.3 From 29ce275bdc22d99ab995e260dfcee9fe49e951e1 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 19 Aug 2009 20:34:26 -0500 Subject: Lots of debug, but also cleaning up the desktop file name path so it gets properly into the constructor. --- src/launcher-menu-item.c | 3 +++ src/messages-service.c | 13 +++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/launcher-menu-item.c b/src/launcher-menu-item.c index ce8fd5f..915c81c 100644 --- a/src/launcher-menu-item.c +++ b/src/launcher-menu-item.c @@ -112,11 +112,14 @@ LauncherMenuItem * launcher_menu_item_new (const gchar * desktop_file) { LauncherMenuItem * self = g_object_new(LAUNCHER_MENU_ITEM_TYPE, NULL); + g_debug("\tDesktop file: %s", desktop_file); LauncherMenuItemPrivate * priv = LAUNCHER_MENU_ITEM_GET_PRIVATE(self); priv->appinfo = G_APP_INFO(g_desktop_app_info_new_from_filename(desktop_file)); + g_debug("\tName: %s", launcher_menu_item_get_name(self)); + return self; } diff --git a/src/messages-service.c b/src/messages-service.c index 6f62b1f..61e0ca9 100644 --- a/src/messages-service.c +++ b/src/messages-service.c @@ -21,6 +21,7 @@ with this program. If not, see . */ #include +#include #include #include @@ -492,6 +493,7 @@ gboolean build_launcher (gpointer data) { gchar * path = (gchar *)data; + g_debug("\tpath: %s", path); gchar * desktop = NULL; g_file_get_contents(path, &desktop, NULL, NULL); @@ -501,11 +503,17 @@ build_launcher (gpointer data) return FALSE; } - launcherList_t * ll = g_new0(launcherList_t, 1); - ll->menuitem = launcher_menu_item_new(path); + gchar * trimdesktop = pango_trim_string(desktop); + g_debug("\tcontents: %s", trimdesktop); + launcherList_t * ll = g_new0(launcherList_t, 1); + ll->menuitem = launcher_menu_item_new(trimdesktop); launcherList = g_list_insert_sorted(launcherList, ll, launcherList_sort); + + g_free(trimdesktop); + g_free(desktop); + return FALSE; } @@ -526,6 +534,7 @@ build_launchers (gpointer data) const gchar * filename = NULL; while ((filename = g_dir_read_name(dir)) != NULL) { + g_debug("Found file: %s", filename); gchar * path = g_build_filename(SYSTEM_APPS_DIR, filename, NULL); g_idle_add(build_launcher, path); } -- cgit v1.2.3 From 69a569919e85cec838fce571be5fe319d17258e0 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 19 Aug 2009 20:38:33 -0500 Subject: Setting the label of the menu item. --- src/launcher-menu-item.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/launcher-menu-item.c b/src/launcher-menu-item.c index 915c81c..e8fc269 100644 --- a/src/launcher-menu-item.c +++ b/src/launcher-menu-item.c @@ -119,6 +119,7 @@ launcher_menu_item_new (const gchar * desktop_file) priv->appinfo = G_APP_INFO(g_desktop_app_info_new_from_filename(desktop_file)); g_debug("\tName: %s", launcher_menu_item_get_name(self)); + dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), "label", launcher_menu_item_get_name(self)); return self; } -- cgit v1.2.3 From 5fdfdc0015f5ffc7ef090688526f3bca2352155c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 19 Aug 2009 20:45:23 -0500 Subject: Getting launchers to add to the menu, and changing the function to do that so it's not all server based. We want everyone involved now. --- src/messages-service.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/messages-service.c b/src/messages-service.c index 61e0ca9..1d8c61c 100644 --- a/src/messages-service.c +++ b/src/messages-service.c @@ -44,7 +44,7 @@ static GMainLoop * mainloop = NULL; static void server_count_changed (AppMenuItem * appitem, guint count, gpointer data); static void server_name_changed (AppMenuItem * appitem, gchar * name, gpointer data); static void im_time_changed (ImMenuItem * imitem, glong seconds, gpointer data); -static void reconsile_list_and_menu (GList * serverlist, DbusmenuMenuitem * menushell); +static void resort_menu (DbusmenuMenuitem * menushell); static void indicator_removed (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * type, gpointer data); typedef struct _serverList_t serverList_t; @@ -185,7 +185,7 @@ server_added (IndicateListener * listener, IndicateListenerServer * server, gcha dbusmenu_menuitem_child_append(menushell, DBUSMENU_MENUITEM(menuitem)); /* Should be prepend ^ */ - reconsile_list_and_menu(serverList, menushell); + resort_menu(menushell); return; } @@ -194,7 +194,7 @@ static void server_name_changed (AppMenuItem * appitem, gchar * name, gpointer data) { serverList = g_list_sort(serverList, serverList_sort); - reconsile_list_and_menu(serverList, DBUSMENU_MENUITEM(data)); + resort_menu(DBUSMENU_MENUITEM(data)); return; } @@ -249,7 +249,7 @@ im_time_changed (ImMenuItem * imitem, glong seconds, gpointer data) { serverList_t * sl = (serverList_t *)data; sl->imList = g_list_sort(sl->imList, imList_sort); - reconsile_list_and_menu(serverList, root_menuitem); + resort_menu(root_menuitem); return; } @@ -317,7 +317,7 @@ menushell_foreach_cb (DbusmenuMenuitem * data_mi, gpointer data_ms) { } static void -reconsile_list_and_menu (GList * serverlist, DbusmenuMenuitem * menushell) +resort_menu (DbusmenuMenuitem * menushell) { guint position = 0; GList * serverentry; @@ -492,6 +492,7 @@ indicator_removed (IndicateListener * listener, IndicateListenerServer * server, gboolean build_launcher (gpointer data) { + /* Read the file get the data */ gchar * path = (gchar *)data; g_debug("\tpath: %s", path); gchar * desktop = NULL; @@ -504,15 +505,20 @@ build_launcher (gpointer data) } gchar * trimdesktop = pango_trim_string(desktop); + g_free(desktop); g_debug("\tcontents: %s", trimdesktop); + /* Build the item */ launcherList_t * ll = g_new0(launcherList_t, 1); ll->menuitem = launcher_menu_item_new(trimdesktop); + g_free(trimdesktop); + /* Add it to the list */ launcherList = g_list_insert_sorted(launcherList, ll, launcherList_sort); - g_free(trimdesktop); - g_free(desktop); + /* Add it to the menu */ + dbusmenu_menuitem_child_append(root_menuitem, DBUSMENU_MENUITEM(ll->menuitem)); + resort_menu(root_menuitem); return FALSE; } -- cgit v1.2.3 From dbba757b9c5e2ff2b67221915264c8963982cb24 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 19 Aug 2009 20:54:41 -0500 Subject: Missing a couple headers for distcheckness --- src/Makefile.am | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index 0428cbb..b4a6bdd 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -3,11 +3,11 @@ bin_PROGRAMS = indicator-messages-service messaginglibdir = $(INDICATORDIR) messaginglib_LTLIBRARIES = libmessaging.la -libmessaging_la_SOURCES = indicator-messages.c +libmessaging_la_SOURCES = indicator-messages.c dbus-data.h libmessaging_la_CFLAGS = $(APPLET_CFLAGS) -Wall -Wl,-Bsymbolic-functions -Wl,-z,defs -Wl,--as-needed -Werror libmessaging_la_LIBADD = $(APPLET_LIBS) libmessaging_la_LDFLAGS = -module -avoid-version -indicator_messages_service_SOURCES = messages-service.c im-menu-item.c im-menu-item.h app-menu-item.c app-menu-item.h launcher-menu-item.c launcher-menu-item.h +indicator_messages_service_SOURCES = messages-service.c im-menu-item.c im-menu-item.h app-menu-item.c app-menu-item.h launcher-menu-item.c launcher-menu-item.h dirs.h dbus-data.h indicator_messages_service_CFLAGS = $(APPLET_CFLAGS) -Wall -Wl,-Bsymbolic-functions -Wl,-z,defs -Wl,--as-needed -Werror indicator_messages_service_LDADD = $(APPLET_LIBS) -- cgit v1.2.3 From 72be94fdd1299c2bcec99e169f4800ff6e89c516 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 19 Aug 2009 20:57:37 -0500 Subject: Making this file a little more readable. Eh, I guess you never plan on them getting this big when you start do you? I remember when he was just a little automake file. --- src/Makefile.am | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index b4a6bdd..0678537 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,13 +1,32 @@ bin_PROGRAMS = indicator-messages-service +###################################### +# Building the messages indicator +###################################### + messaginglibdir = $(INDICATORDIR) messaginglib_LTLIBRARIES = libmessaging.la -libmessaging_la_SOURCES = indicator-messages.c dbus-data.h +libmessaging_la_SOURCES = \ + indicator-messages.c\ + dbus-data.h libmessaging_la_CFLAGS = $(APPLET_CFLAGS) -Wall -Wl,-Bsymbolic-functions -Wl,-z,defs -Wl,--as-needed -Werror libmessaging_la_LIBADD = $(APPLET_LIBS) libmessaging_la_LDFLAGS = -module -avoid-version -indicator_messages_service_SOURCES = messages-service.c im-menu-item.c im-menu-item.h app-menu-item.c app-menu-item.h launcher-menu-item.c launcher-menu-item.h dirs.h dbus-data.h +###################################### +# Building the messages service +###################################### + +indicator_messages_service_SOURCES = \ + messages-service.c \ + im-menu-item.c \ + im-menu-item.h \ + app-menu-item.c \ + app-menu-item.h \ + launcher-menu-item.c \ + launcher-menu-item.h \ + dirs.h \ + dbus-data.h indicator_messages_service_CFLAGS = $(APPLET_CFLAGS) -Wall -Wl,-Bsymbolic-functions -Wl,-z,defs -Wl,--as-needed -Werror indicator_messages_service_LDADD = $(APPLET_LIBS) -- cgit v1.2.3 From 74df2c7eb2914922bf68940994751b8369991300 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 19 Aug 2009 21:15:37 -0500 Subject: Adding the launcher list to the resorting function. This looks more complex than it is, it's just merging the two lists on the fly in alphabetical order. --- src/messages-service.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/messages-service.c b/src/messages-service.c index 1d8c61c..3f2974e 100644 --- a/src/messages-service.c +++ b/src/messages-service.c @@ -321,11 +321,27 @@ resort_menu (DbusmenuMenuitem * menushell) { guint position = 0; GList * serverentry; + GList * launcherentry = launcherList; g_debug("Reordering Menu:"); for (serverentry = serverList; serverentry != NULL; serverentry = serverentry->next) { serverList_t * si = (serverList_t *)serverentry->data; + + if (launcherentry != NULL) { + launcherList_t * li = (launcherList_t *)launcherentry->data; + while (launcherentry != NULL && g_strcmp0(launcher_menu_item_get_name(li->menuitem), app_menu_item_get_name(si->menuitem)) < 0) { + g_debug("\tMoving launcher '%s' to position %d", launcher_menu_item_get_name(li->menuitem), position); + dbusmenu_menuitem_child_reorder(DBUSMENU_MENUITEM(menushell), DBUSMENU_MENUITEM(li->menuitem), position); + + position++; + launcherentry = launcherentry->next; + if (launcherentry != NULL) { + li = (launcherList_t *)launcherentry->data; + } + } + } + if (si->menuitem != NULL) { g_debug("\tMoving app %s to position %d", INDICATE_LISTENER_SERVER_DBUS_NAME(si->server), position); dbusmenu_menuitem_child_reorder(DBUSMENU_MENUITEM(menushell), DBUSMENU_MENUITEM(si->menuitem), position); @@ -344,6 +360,15 @@ resort_menu (DbusmenuMenuitem * menushell) } } + while (launcherentry != NULL) { + launcherList_t * li = (launcherList_t *)launcherentry->data; + g_debug("\tMoving launcher '%s' to position %d", launcher_menu_item_get_name(li->menuitem), position); + dbusmenu_menuitem_child_reorder(DBUSMENU_MENUITEM(menushell), DBUSMENU_MENUITEM(li->menuitem), position); + + position++; + launcherentry = launcherentry->next; + } + return; } -- cgit v1.2.3 From cfb0854e7c6bfa7cc9ac5ffdcd6672ad812ecfa0 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 19 Aug 2009 21:30:02 -0500 Subject: Adding in the activate logic so that the menu items actually launch the application. --- src/launcher-menu-item.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/launcher-menu-item.c b/src/launcher-menu-item.c index e8fc269..7970288 100644 --- a/src/launcher-menu-item.c +++ b/src/launcher-menu-item.c @@ -48,6 +48,7 @@ static void launcher_menu_item_class_init (LauncherMenuItemClass *klass); static void launcher_menu_item_init (LauncherMenuItem *self); static void launcher_menu_item_dispose (GObject *object); static void launcher_menu_item_finalize (GObject *object); +void activate_cb (LauncherMenuItem * self, gpointer data); G_DEFINE_TYPE (LauncherMenuItem, launcher_menu_item, DBUSMENU_TYPE_MENUITEM); @@ -121,6 +122,8 @@ launcher_menu_item_new (const gchar * desktop_file) g_debug("\tName: %s", launcher_menu_item_get_name(self)); dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), "label", launcher_menu_item_get_name(self)); + g_signal_connect(G_OBJECT(self), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(activate_cb), NULL); + return self; } @@ -135,3 +138,18 @@ launcher_menu_item_get_name (LauncherMenuItem * appitem) return g_app_info_get_name(priv->appinfo); } } + +void +activate_cb (LauncherMenuItem * self, gpointer data) +{ + LauncherMenuItemPrivate * priv = LAUNCHER_MENU_ITEM_GET_PRIVATE(self); + g_return_if_fail(priv->appinfo != NULL); + + GError * error = NULL; + if (!g_app_info_launch(priv->appinfo, NULL, NULL, &error)) { + g_warning("Application failed to launch '%s' because: %s", launcher_menu_item_get_name(self), error->message); + g_error_free(error); + } + + return; +} -- cgit v1.2.3 From b8adb87bc06248378bc0d72a53c21d566a31e2b4 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 19 Aug 2009 21:49:55 -0500 Subject: Adding in a couple function to deal with disappearing launchers. --- src/messages-service.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/messages-service.c b/src/messages-service.c index 3f2974e..c3b3db9 100644 --- a/src/messages-service.c +++ b/src/messages-service.c @@ -46,6 +46,8 @@ static void server_name_changed (AppMenuItem * appitem, gchar * name, gpointer d static void im_time_changed (ImMenuItem * imitem, glong seconds, gpointer data); static void resort_menu (DbusmenuMenuitem * menushell); static void indicator_removed (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * type, gpointer data); +static void check_eclipses (AppMenuItem * ai); +static void remove_eclipses (AppMenuItem * ai); typedef struct _serverList_t serverList_t; struct _serverList_t { @@ -194,6 +196,7 @@ static void server_name_changed (AppMenuItem * appitem, gchar * name, gpointer data) { serverList = g_list_sort(serverList, serverList_sort); + check_eclipses(appitem); resort_menu(DBUSMENU_MENUITEM(data)); return; } @@ -268,6 +271,8 @@ server_removed (IndicateListener * listener, IndicateListenerServer * server, gc serverList_t * sltp = (serverList_t *)lookup->data; + remove_eclipses(sltp->menuitem); + while (sltp->imList) { imList_t * imitem = (imList_t *)sltp->imList->data; indicator_removed(listener, server, imitem->indicator, "message", data); @@ -514,6 +519,27 @@ indicator_removed (IndicateListener * listener, IndicateListenerServer * server, return; } +/* Check to see if a new desktop file causes + any of the launchers to be eclipsed by a running + process */ +static void +check_eclipses (AppMenuItem * ai) +{ + + + return; +} + +/* Remove any eclipses that might have been caused + by this app item that is now retiring */ +static void +remove_eclipses (AppMenuItem * ai) +{ + + + return; +} + gboolean build_launcher (gpointer data) { -- cgit v1.2.3 From de5f8b0273d835a96eccdcb2ecb744e41ec082db Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 19 Aug 2009 21:53:09 -0500 Subject: Clean up, clean up, everybody everywhere --- src/messages-service.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/messages-service.c b/src/messages-service.c index c3b3db9..c6bc5b8 100644 --- a/src/messages-service.c +++ b/src/messages-service.c @@ -48,6 +48,8 @@ static void resort_menu (DbusmenuMenuitem * menushell); static void indicator_removed (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * type, gpointer data); static void check_eclipses (AppMenuItem * ai); static void remove_eclipses (AppMenuItem * ai); +static gboolean build_launcher (gpointer data); +static gboolean build_launchers (gpointer data); typedef struct _serverList_t serverList_t; struct _serverList_t { @@ -540,7 +542,9 @@ remove_eclipses (AppMenuItem * ai) return; } -gboolean +/* This function turns a specific file into a menu + item and registers it appropriately with everyone */ +static gboolean build_launcher (gpointer data) { /* Read the file get the data */ @@ -574,7 +578,11 @@ build_launcher (gpointer data) return FALSE; } -gboolean +/* This function goes through all the launchers that we're + supposed to be grabbing and decides to show turn them + into menu items or not. It doens't do the work, but it + makes the decision. */ +static gboolean build_launchers (gpointer data) { if (!g_file_test(SYSTEM_APPS_DIR, G_FILE_TEST_IS_DIR)) { -- cgit v1.2.3 From 99744b30f0ebf4c7054b8274c30af063ec52b248 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 19 Aug 2009 21:59:43 -0500 Subject: Adding an eclipsed function for the LMI --- src/launcher-menu-item.c | 16 ++++++++++++++-- src/launcher-menu-item.h | 1 + 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/launcher-menu-item.c b/src/launcher-menu-item.c index 7970288..b869a40 100644 --- a/src/launcher-menu-item.c +++ b/src/launcher-menu-item.c @@ -48,7 +48,7 @@ static void launcher_menu_item_class_init (LauncherMenuItemClass *klass); static void launcher_menu_item_init (LauncherMenuItem *self); static void launcher_menu_item_dispose (GObject *object); static void launcher_menu_item_finalize (GObject *object); -void activate_cb (LauncherMenuItem * self, gpointer data); +static void activate_cb (LauncherMenuItem * self, gpointer data); G_DEFINE_TYPE (LauncherMenuItem, launcher_menu_item, DBUSMENU_TYPE_MENUITEM); @@ -139,7 +139,9 @@ launcher_menu_item_get_name (LauncherMenuItem * appitem) } } -void +/* When the menu item is clicked on it tries to launch + the application that is represented by the desktop file */ +static void activate_cb (LauncherMenuItem * self, gpointer data) { LauncherMenuItemPrivate * priv = LAUNCHER_MENU_ITEM_GET_PRIVATE(self); @@ -153,3 +155,13 @@ activate_cb (LauncherMenuItem * self, gpointer data) return; } + +/* Hides the menu item based on whether it is eclipsed + or not. */ +void +launcher_menu_item_set_eclipsed (LauncherMenuItem * li, gboolean eclipsed) +{ + g_debug("Laucher '%s' is %s", launcher_menu_item_get_name(li), eclipsed ? "now eclipsed" : "shown again"); + dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(li), "show", eclipsed ? "false" : "true"); + return; +} diff --git a/src/launcher-menu-item.h b/src/launcher-menu-item.h index c351dd9..f17fbad 100644 --- a/src/launcher-menu-item.h +++ b/src/launcher-menu-item.h @@ -55,6 +55,7 @@ struct _LauncherMenuItem { GType launcher_menu_item_get_type (void); LauncherMenuItem * launcher_menu_item_new (const gchar * desktop_file); const gchar * launcher_menu_item_get_name (LauncherMenuItem * appitem); +void launcher_menu_item_set_eclipsed (LauncherMenuItem * li, gboolean eclipsed); G_END_DECLS -- cgit v1.2.3 From 17745461f669047872c12a6c7db7b05a9ccb0417 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 19 Aug 2009 22:29:40 -0500 Subject: Big commit. Trying to check for eclipses, but first both objects needed to track their desktop file paths. So I had to add that little nugget in as well. --- src/app-menu-item.c | 27 ++++++++++++++++++++++++++- src/app-menu-item.h | 1 + src/launcher-menu-item.c | 17 +++++++++++++++++ src/launcher-menu-item.h | 1 + src/messages-service.c | 24 ++++++++++++++++++++++++ 5 files changed, 69 insertions(+), 1 deletion(-) diff --git a/src/app-menu-item.c b/src/app-menu-item.c index 2212be5..3a2c795 100644 --- a/src/app-menu-item.c +++ b/src/app-menu-item.c @@ -45,6 +45,7 @@ struct _AppMenuItemPrivate gchar * type; GAppInfo * appinfo; + gchar * desktop; guint unreadcount; gboolean count_on_label; }; @@ -105,6 +106,7 @@ app_menu_item_init (AppMenuItem *self) priv->server = NULL; priv->type = NULL; priv->appinfo = NULL; + priv->desktop = NULL; priv->unreadcount = 0; priv->count_on_label = FALSE; @@ -136,6 +138,10 @@ app_menu_item_finalize (GObject *object) g_free(priv->type); } + if (priv->desktop != NULL) { + g_free(priv->desktop); + } + if (priv->appinfo != NULL) { g_object_unref(priv->appinfo); } @@ -229,15 +235,23 @@ desktop_cb (IndicateListener * listener, IndicateListenerServer * server, gchar if (priv->appinfo != NULL) { g_object_unref(G_OBJECT(priv->appinfo)); + priv->appinfo = NULL; + } + + if (priv->desktop != NULL) { + g_free(priv->desktop); + priv->desktop = NULL; } if (value == NULL || value[0] == '\0') { return; } - + priv->appinfo = G_APP_INFO(g_desktop_app_info_new_from_filename(value)); g_return_if_fail(priv->appinfo != NULL); + priv->desktop = g_strdup(value); + update_label(self); g_signal_emit(G_OBJECT(self), signals[NAME_CHANGED], 0, app_menu_item_get_name(self), TRUE); @@ -297,6 +311,7 @@ indicator_removed_cb (IndicateListener * listener, IndicateListenerServer * serv guint app_menu_item_get_count (AppMenuItem * appitem) { + g_return_val_if_fail(IS_APP_MENU_ITEM(appitem), 0); AppMenuItemPrivate * priv = APP_MENU_ITEM_GET_PRIVATE(appitem); return priv->unreadcount; @@ -304,6 +319,7 @@ app_menu_item_get_count (AppMenuItem * appitem) IndicateListenerServer * app_menu_item_get_server (AppMenuItem * appitem) { + g_return_val_if_fail(IS_APP_MENU_ITEM(appitem), NULL); AppMenuItemPrivate * priv = APP_MENU_ITEM_GET_PRIVATE(appitem); return priv->server; @@ -312,6 +328,7 @@ app_menu_item_get_server (AppMenuItem * appitem) { const gchar * app_menu_item_get_name (AppMenuItem * appitem) { + g_return_val_if_fail(IS_APP_MENU_ITEM(appitem), NULL); AppMenuItemPrivate * priv = APP_MENU_ITEM_GET_PRIVATE(appitem); if (priv->appinfo == NULL) { @@ -320,3 +337,11 @@ app_menu_item_get_name (AppMenuItem * appitem) return g_app_info_get_name(priv->appinfo); } } + +const gchar * +app_menu_item_get_desktop (AppMenuItem * appitem) +{ + g_return_val_if_fail(IS_APP_MENU_ITEM(appitem), NULL); + AppMenuItemPrivate * priv = APP_MENU_ITEM_GET_PRIVATE(appitem); + return priv->desktop; +} diff --git a/src/app-menu-item.h b/src/app-menu-item.h index dda4765..583d50d 100644 --- a/src/app-menu-item.h +++ b/src/app-menu-item.h @@ -59,6 +59,7 @@ AppMenuItem * app_menu_item_new (IndicateListener * listener, IndicateListenerSe guint app_menu_item_get_count (AppMenuItem * appitem); IndicateListenerServer * app_menu_item_get_server (AppMenuItem * appitem); const gchar * app_menu_item_get_name (AppMenuItem * appitem); +const gchar * app_menu_item_get_desktop (AppMenuItem * appitem); G_END_DECLS diff --git a/src/launcher-menu-item.c b/src/launcher-menu-item.c index b869a40..4f05ae6 100644 --- a/src/launcher-menu-item.c +++ b/src/launcher-menu-item.c @@ -39,6 +39,7 @@ typedef struct _LauncherMenuItemPrivate LauncherMenuItemPrivate; struct _LauncherMenuItemPrivate { GAppInfo * appinfo; + gchar * desktop; }; #define LAUNCHER_MENU_ITEM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), LAUNCHER_MENU_ITEM_TYPE, LauncherMenuItemPrivate)) @@ -81,6 +82,7 @@ launcher_menu_item_init (LauncherMenuItem *self) LauncherMenuItemPrivate * priv = LAUNCHER_MENU_ITEM_GET_PRIVATE(self); priv->appinfo = NULL; + priv->desktop = NULL; return; } @@ -102,6 +104,12 @@ launcher_menu_item_finalize (GObject *object) if (priv->appinfo != NULL) { g_object_unref(priv->appinfo); + priv->appinfo = NULL; + } + + if (priv->desktop != NULL) { + g_free(priv->desktop); + priv->desktop = NULL; } G_OBJECT_CLASS (launcher_menu_item_parent_class)->finalize (object); @@ -118,6 +126,7 @@ launcher_menu_item_new (const gchar * desktop_file) LauncherMenuItemPrivate * priv = LAUNCHER_MENU_ITEM_GET_PRIVATE(self); priv->appinfo = G_APP_INFO(g_desktop_app_info_new_from_filename(desktop_file)); + priv->desktop = g_strdup(desktop_file); g_debug("\tName: %s", launcher_menu_item_get_name(self)); dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), "label", launcher_menu_item_get_name(self)); @@ -156,6 +165,14 @@ activate_cb (LauncherMenuItem * self, gpointer data) return; } +const gchar * +launcher_menu_item_get_desktop (LauncherMenuItem * launchitem) +{ + g_return_val_if_fail(IS_LAUNCHER_MENU_ITEM(launchitem), NULL); + LauncherMenuItemPrivate * priv = LAUNCHER_MENU_ITEM_GET_PRIVATE(launchitem); + return priv->desktop; +} + /* Hides the menu item based on whether it is eclipsed or not. */ void diff --git a/src/launcher-menu-item.h b/src/launcher-menu-item.h index f17fbad..2b39073 100644 --- a/src/launcher-menu-item.h +++ b/src/launcher-menu-item.h @@ -55,6 +55,7 @@ struct _LauncherMenuItem { GType launcher_menu_item_get_type (void); LauncherMenuItem * launcher_menu_item_new (const gchar * desktop_file); const gchar * launcher_menu_item_get_name (LauncherMenuItem * appitem); +const gchar * launcher_menu_item_get_desktop (LauncherMenuItem * launchitem); void launcher_menu_item_set_eclipsed (LauncherMenuItem * li, gboolean eclipsed); G_END_DECLS diff --git a/src/messages-service.c b/src/messages-service.c index c6bc5b8..f8f1aaf 100644 --- a/src/messages-service.c +++ b/src/messages-service.c @@ -527,7 +527,18 @@ indicator_removed (IndicateListener * listener, IndicateListenerServer * server, static void check_eclipses (AppMenuItem * ai) { + const gchar * aidesktop = app_menu_item_get_desktop(ai); + if (aidesktop == NULL) return; + GList * llitem; + for (llitem = launcherList; llitem != NULL; llitem = llitem->next) { + const gchar * lidesktop = launcher_menu_item_get_desktop(LAUNCHER_MENU_ITEM(llitem->data)); + + if (!g_strcmp0(aidesktop, lidesktop)) { + launcher_menu_item_set_eclipsed(LAUNCHER_MENU_ITEM(llitem->data), TRUE); + break; + } + } return; } @@ -537,7 +548,18 @@ check_eclipses (AppMenuItem * ai) static void remove_eclipses (AppMenuItem * ai) { + const gchar * aidesktop = app_menu_item_get_desktop(ai); + if (aidesktop == NULL) return; + GList * llitem; + for (llitem = launcherList; llitem != NULL; llitem = llitem->next) { + const gchar * lidesktop = launcher_menu_item_get_desktop(LAUNCHER_MENU_ITEM(llitem->data)); + + if (!g_strcmp0(aidesktop, lidesktop)) { + launcher_menu_item_set_eclipsed(LAUNCHER_MENU_ITEM(llitem->data), FALSE); + break; + } + } return; } @@ -609,6 +631,8 @@ build_launchers (gpointer data) return FALSE; } +/* Oh, if you don't know what main() is for + we really shouldn't be talking. */ int main (int argc, char ** argv) { -- cgit v1.2.3 From db8ada09e2f254026f318b38cd45ae1cd765f584 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 19 Aug 2009 22:42:15 -0500 Subject: Ah, where casting kills. You can cast anything to the right value even though it's not. Nice opaque errors you get for that. --- src/messages-service.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/messages-service.c b/src/messages-service.c index f8f1aaf..395bf32 100644 --- a/src/messages-service.c +++ b/src/messages-service.c @@ -532,10 +532,11 @@ check_eclipses (AppMenuItem * ai) GList * llitem; for (llitem = launcherList; llitem != NULL; llitem = llitem->next) { - const gchar * lidesktop = launcher_menu_item_get_desktop(LAUNCHER_MENU_ITEM(llitem->data)); + launcherList_t * ll = (launcherList_t *)llitem->data; + const gchar * lidesktop = launcher_menu_item_get_desktop(ll->menuitem); if (!g_strcmp0(aidesktop, lidesktop)) { - launcher_menu_item_set_eclipsed(LAUNCHER_MENU_ITEM(llitem->data), TRUE); + launcher_menu_item_set_eclipsed(ll->menuitem, TRUE); break; } } @@ -553,10 +554,11 @@ remove_eclipses (AppMenuItem * ai) GList * llitem; for (llitem = launcherList; llitem != NULL; llitem = llitem->next) { - const gchar * lidesktop = launcher_menu_item_get_desktop(LAUNCHER_MENU_ITEM(llitem->data)); + launcherList_t * ll = (launcherList_t *)llitem->data; + const gchar * lidesktop = launcher_menu_item_get_desktop(ll->menuitem); if (!g_strcmp0(aidesktop, lidesktop)) { - launcher_menu_item_set_eclipsed(LAUNCHER_MENU_ITEM(llitem->data), FALSE); + launcher_menu_item_set_eclipsed(ll->menuitem, FALSE); break; } } -- cgit v1.2.3 From c49644e5e7a901c2113d6d0a88e54b4224f90de5 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 19 Aug 2009 22:54:33 -0500 Subject: Oh, some debug messages to see what's going on. --- src/messages-service.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/messages-service.c b/src/messages-service.c index 395bf32..2020dd3 100644 --- a/src/messages-service.c +++ b/src/messages-service.c @@ -527,13 +527,16 @@ indicator_removed (IndicateListener * listener, IndicateListenerServer * server, static void check_eclipses (AppMenuItem * ai) { + g_debug("Checking eclipsing"); const gchar * aidesktop = app_menu_item_get_desktop(ai); if (aidesktop == NULL) return; + g_debug("\tApp desktop: %s", aidesktop); GList * llitem; for (llitem = launcherList; llitem != NULL; llitem = llitem->next) { launcherList_t * ll = (launcherList_t *)llitem->data; const gchar * lidesktop = launcher_menu_item_get_desktop(ll->menuitem); + g_debug("\tLauncher desktop: %s", lidesktop); if (!g_strcmp0(aidesktop, lidesktop)) { launcher_menu_item_set_eclipsed(ll->menuitem, TRUE); -- cgit v1.2.3 From 8483b2d92f9b86e6d00afc163b835a47e1bebdbe Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 20 Aug 2009 10:25:07 -0500 Subject: Use a GDK app context. Not sure about the timestamp units though. --- src/launcher-menu-item.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/launcher-menu-item.c b/src/launcher-menu-item.c index 4f05ae6..653592c 100644 --- a/src/launcher-menu-item.c +++ b/src/launcher-menu-item.c @@ -24,6 +24,7 @@ with this program. If not, see . #include "config.h" #endif +#include #include #include #include "launcher-menu-item.h" @@ -156,12 +157,23 @@ activate_cb (LauncherMenuItem * self, gpointer data) LauncherMenuItemPrivate * priv = LAUNCHER_MENU_ITEM_GET_PRIVATE(self); g_return_if_fail(priv->appinfo != NULL); + /* This should manage the X stuff for us */ + GdkAppLaunchContext * context = gdk_app_launch_context_new(); + + /* Using the current time as we don't have the event + time as that's not sent across the bus */ + GTimeVal time; + g_get_current_time(&time); + gdk_app_launch_context_set_timestamp(context, time.tv_usec); + GError * error = NULL; - if (!g_app_info_launch(priv->appinfo, NULL, NULL, &error)) { + if (!g_app_info_launch(priv->appinfo, NULL, G_APP_LAUNCH_CONTEXT(context), &error)) { g_warning("Application failed to launch '%s' because: %s", launcher_menu_item_get_name(self), error->message); g_error_free(error); } + g_object_unref(G_OBJECT(context)); + return; } -- cgit v1.2.3 From da36b66e974c34b2024677396236a62e5973e9c9 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 20 Aug 2009 11:29:09 -0500 Subject: Should be in milliseconds not micro --- src/launcher-menu-item.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/launcher-menu-item.c b/src/launcher-menu-item.c index 653592c..6c79adb 100644 --- a/src/launcher-menu-item.c +++ b/src/launcher-menu-item.c @@ -164,7 +164,7 @@ activate_cb (LauncherMenuItem * self, gpointer data) time as that's not sent across the bus */ GTimeVal time; g_get_current_time(&time); - gdk_app_launch_context_set_timestamp(context, time.tv_usec); + gdk_app_launch_context_set_timestamp(context, time.tv_usec / 1000); GError * error = NULL; if (!g_app_info_launch(priv->appinfo, NULL, G_APP_LAUNCH_CONTEXT(context), &error)) { -- cgit v1.2.3 From b0f699b4d657330edfa56cd27c856db9941d3a0c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 20 Aug 2009 14:04:58 -0500 Subject: Adding in a couple of blacklist check point. --- src/messages-service.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/messages-service.c b/src/messages-service.c index 2020dd3..8743b62 100644 --- a/src/messages-service.c +++ b/src/messages-service.c @@ -143,6 +143,13 @@ launcherList_sort (gconstpointer a, gconstpointer b) return g_strcmp0(pan, pbn); } +static gboolean +blacklist_check (const gchar * desktop_file) +{ + + return FALSE; +} + static void server_added (IndicateListener * listener, IndicateListenerServer * server, gchar * type, gpointer data) { @@ -555,6 +562,8 @@ remove_eclipses (AppMenuItem * ai) const gchar * aidesktop = app_menu_item_get_desktop(ai); if (aidesktop == NULL) return; + if (blacklist_check(aidesktop)) return; + GList * llitem; for (llitem = launcherList; llitem != NULL; llitem = llitem->next) { launcherList_t * ll = (launcherList_t *)llitem->data; @@ -602,6 +611,10 @@ build_launcher (gpointer data) dbusmenu_menuitem_child_append(root_menuitem, DBUSMENU_MENUITEM(ll->menuitem)); resort_menu(root_menuitem); + if (blacklist_check(trimdesktop)) { + launcher_menu_item_set_eclipsed(ll->menuitem, TRUE); + } + return FALSE; } -- cgit v1.2.3 From 754694356af4079753531d5a090c0d7ed9eee828 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 20 Aug 2009 14:06:52 -0500 Subject: Adding in some seperators to make things more clear. --- src/messages-service.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/messages-service.c b/src/messages-service.c index 8743b62..9879e3a 100644 --- a/src/messages-service.c +++ b/src/messages-service.c @@ -51,6 +51,11 @@ static void remove_eclipses (AppMenuItem * ai); static gboolean build_launcher (gpointer data); static gboolean build_launchers (gpointer data); + +/* + * Server List + */ + typedef struct _serverList_t serverList_t; struct _serverList_t { IndicateListenerServer * server; @@ -86,6 +91,10 @@ serverList_sort (gconstpointer a, gconstpointer b) return g_strcmp0(pan, pbn); } +/* + * Item List + */ + typedef struct _imList_t imList_t; struct _imList_t { IndicateListenerServer * server; @@ -124,6 +133,10 @@ imList_sort (gconstpointer a, gconstpointer b) return (gint)(im_menu_item_get_seconds(IM_MENU_ITEM(pb->menuitem)) - im_menu_item_get_seconds(IM_MENU_ITEM(pa->menuitem))); } +/* + * Launcher List + */ + typedef struct _launcherList_t launcherList_t; struct _launcherList_t { LauncherMenuItem * menuitem; @@ -143,6 +156,10 @@ launcherList_sort (gconstpointer a, gconstpointer b) return g_strcmp0(pan, pbn); } +/* + * Black List + */ + static gboolean blacklist_check (const gchar * desktop_file) { @@ -150,6 +167,10 @@ blacklist_check (const gchar * desktop_file) return FALSE; } +/* + * More code + */ + static void server_added (IndicateListener * listener, IndicateListenerServer * server, gchar * type, gpointer data) { -- cgit v1.2.3 From ee713f22dd253cf6e757f3ffb4ec839dad91bf31 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 20 Aug 2009 14:26:56 -0500 Subject: More of a basis for the black list stuff. Some functions and an interface. --- src/messages-service.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/messages-service.c b/src/messages-service.c index 9879e3a..1ff97ca 100644 --- a/src/messages-service.c +++ b/src/messages-service.c @@ -160,9 +160,41 @@ launcherList_sort (gconstpointer a, gconstpointer b) * Black List */ +static GHashTable * blacklist = NULL; + +/* Initialize the black list and start to setup + handlers for it. */ +static void +blacklist_init (gpointer data) +{ + + return; +} + +/* Add a definition file into the black list and eclipse + and launchers that have the same file. */ +static void +blacklist_add (const gchar * definition_file) +{ + + return; +} + +/* Remove a black list item based on the definition file + and uneclipse those launchers blocked by it. */ +static void +blacklist_remove (const gchar * definition_file) +{ + + return; +} + +/* Check to see if a particular desktop file is + in the blacklist. */ static gboolean blacklist_check (const gchar * desktop_file) { + if (blacklist == NULL) return FALSE; return FALSE; } -- cgit v1.2.3 From 528c37375ce30f80c2ca0376d62fd41a3629b66e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 20 Aug 2009 14:59:45 -0500 Subject: Fleshing out the add function. Just a little. --- src/messages-service.c | 42 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/src/messages-service.c b/src/messages-service.c index 1ff97ca..e4290f4 100644 --- a/src/messages-service.c +++ b/src/messages-service.c @@ -167,6 +167,8 @@ static GHashTable * blacklist = NULL; static void blacklist_init (gpointer data) { + blacklist = g_hash_table_new_full(g_str_hash, g_str_equal, + g_free, g_free); return; } @@ -174,8 +176,46 @@ blacklist_init (gpointer data) /* Add a definition file into the black list and eclipse and launchers that have the same file. */ static void -blacklist_add (const gchar * definition_file) +blacklist_add (gchar * definition_file) { + /* Dump the file */ + gchar * desktop; + g_file_get_contents(definition_file, &desktop, NULL, NULL); + if (desktop == NULL) { + g_warning("Couldn't get data out of: %s", definition_file); + return; + } + + /* Clean up the data */ + gchar * trimdesktop = pango_trim_string(desktop); + g_free(desktop); + + /* Check for conflicts */ + gpointer data = g_hash_table_lookup(blacklist, trimdesktop); + if (data != NULL) { + gchar * oldfile = (gchar *)data; + if (!g_strcmp0(oldfile, definition_file)) { + g_warning("Already added file '%s'", oldfile); + } else { + g_warning("Already have desktop file '%s' in blacklist file '%s' not adding from '%s'", trimdesktop, oldfile, definition_file); + } + + g_free(trimdesktop); + return; + } + + /* Actually blacklist this thing */ + g_hash_table_insert(blacklist, trimdesktop, definition_file); + g_debug("Adding Blacklist item '%s' for desktop '%s'", definition_file, trimdesktop); + + /* Go through and eclipse folks */ + GList * launcher; + for (launcher = launcherList; launcher != NULL; launcher = launcher->next) { + launcherList_t * item = (launcherList_t *)launcher->data; + if (!g_strcmp0(trimdesktop, launcher_menu_item_get_desktop(item->menuitem))) { + launcher_menu_item_set_eclipsed(item->menuitem, TRUE); + } + } return; } -- cgit v1.2.3 From cc75cbe10d562c29657f61deda56115362df6179 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 20 Aug 2009 15:00:25 -0500 Subject: We're taking ownership of that variable as well --- src/messages-service.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/messages-service.c b/src/messages-service.c index e4290f4..61a4b1a 100644 --- a/src/messages-service.c +++ b/src/messages-service.c @@ -201,6 +201,7 @@ blacklist_add (gchar * definition_file) } g_free(trimdesktop); + g_free(definition_file); return; } -- cgit v1.2.3 From 333467a2e1736c372108c954a191e6206cb18849 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 20 Aug 2009 15:05:38 -0500 Subject: Writing the fairly extensive and complex check function. But, if that's the way it needs to be, I guess it needs to be that way. --- src/messages-service.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/messages-service.c b/src/messages-service.c index 61a4b1a..e238b78 100644 --- a/src/messages-service.c +++ b/src/messages-service.c @@ -237,6 +237,10 @@ blacklist_check (const gchar * desktop_file) { if (blacklist == NULL) return FALSE; + if (g_hash_table_lookup(blacklist, desktop_file)) { + return TRUE; + } + return FALSE; } -- cgit v1.2.3 From e5d4b846037b0397022f12b5355d6889e5b9adec Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 20 Aug 2009 15:51:01 -0500 Subject: Now parsing the directory on start up. Getting this whole thing started up. --- src/messages-service.c | 46 +++++++++++++++++++++++++++++++++++++++------- 1 file changed, 39 insertions(+), 7 deletions(-) diff --git a/src/messages-service.c b/src/messages-service.c index e238b78..f2768cb 100644 --- a/src/messages-service.c +++ b/src/messages-service.c @@ -50,6 +50,9 @@ static void check_eclipses (AppMenuItem * ai); static void remove_eclipses (AppMenuItem * ai); static gboolean build_launcher (gpointer data); static gboolean build_launchers (gpointer data); +static gboolean blacklist_init (gpointer data); +static gboolean blacklist_add (gpointer data); +static void blacklist_remove (const gchar * definition_file); /* @@ -164,26 +167,53 @@ static GHashTable * blacklist = NULL; /* Initialize the black list and start to setup handlers for it. */ -static void +static gboolean blacklist_init (gpointer data) { blacklist = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); - return; + gchar * blacklistdir = g_build_filename(g_get_user_config_dir(), USER_BLACKLIST_DIR, NULL); + g_debug("Looking at blacklist: %s", blacklistdir); + if (!g_file_test(blacklistdir, G_FILE_TEST_IS_DIR)) { + g_free(blacklistdir); + return FALSE; + } + + GError * error = NULL; + GDir * dir = g_dir_open(blacklistdir, 0, &error); + if (dir == NULL) { + g_warning("Unable to open blacklist directory (%s): %s", blacklistdir, error->message); + g_error_free(error); + g_free(blacklistdir); + return FALSE; + } + + const gchar * filename = NULL; + while ((filename = g_dir_read_name(dir)) != NULL) { + g_debug("Found file: %s", filename); + gchar * path = g_build_filename(blacklistdir, filename, NULL); + g_idle_add(blacklist_add, path); + } + + g_dir_close(dir); + g_free(blacklistdir); + + return FALSE; } /* Add a definition file into the black list and eclipse and launchers that have the same file. */ -static void -blacklist_add (gchar * definition_file) +static gboolean +blacklist_add (gpointer udata) { + gchar * definition_file = (gchar *)udata; /* Dump the file */ gchar * desktop; g_file_get_contents(definition_file, &desktop, NULL, NULL); if (desktop == NULL) { g_warning("Couldn't get data out of: %s", definition_file); - return; + return FALSE; } /* Clean up the data */ @@ -202,7 +232,7 @@ blacklist_add (gchar * definition_file) g_free(trimdesktop); g_free(definition_file); - return; + return FALSE; } /* Actually blacklist this thing */ @@ -218,7 +248,8 @@ blacklist_add (gchar * definition_file) } } - return; + blacklist_remove(NULL); + return FALSE; } /* Remove a black list item based on the definition file @@ -781,6 +812,7 @@ main (int argc, char ** argv) g_signal_connect(listener, INDICATE_LISTENER_SIGNAL_SERVER_ADDED, G_CALLBACK(server_added), root_menuitem); g_signal_connect(listener, INDICATE_LISTENER_SIGNAL_SERVER_REMOVED, G_CALLBACK(server_removed), root_menuitem); + g_idle_add(blacklist_init, NULL); g_idle_add(build_launchers, NULL); mainloop = g_main_loop_new(NULL, FALSE); -- cgit v1.2.3 From f41d2527cb53f8a5ca091e860b6fd5f25f6ce87a Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 20 Aug 2009 16:00:12 -0500 Subject: Some debug and fixing checking the desktop file. All good. --- src/messages-service.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/messages-service.c b/src/messages-service.c index f2768cb..a4e8870 100644 --- a/src/messages-service.c +++ b/src/messages-service.c @@ -266,9 +266,11 @@ blacklist_remove (const gchar * definition_file) static gboolean blacklist_check (const gchar * desktop_file) { + g_debug("Checking blacklist for: %s", desktop_file); if (blacklist == NULL) return FALSE; if (g_hash_table_lookup(blacklist, desktop_file)) { + g_debug("\tFound!"); return TRUE; } @@ -740,7 +742,7 @@ build_launcher (gpointer data) dbusmenu_menuitem_child_append(root_menuitem, DBUSMENU_MENUITEM(ll->menuitem)); resort_menu(root_menuitem); - if (blacklist_check(trimdesktop)) { + if (blacklist_check(launcher_menu_item_get_desktop(ll->menuitem))) { launcher_menu_item_set_eclipsed(ll->menuitem, TRUE); } -- cgit v1.2.3 From 33f40e13838d18687507145c98c1cae48c0bc033 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 20 Aug 2009 20:48:52 -0500 Subject: Switching the build to take the directory as a parameter --- src/messages-service.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/messages-service.c b/src/messages-service.c index a4e8870..0e4c296 100644 --- a/src/messages-service.c +++ b/src/messages-service.c @@ -756,12 +756,14 @@ build_launcher (gpointer data) static gboolean build_launchers (gpointer data) { - if (!g_file_test(SYSTEM_APPS_DIR, G_FILE_TEST_IS_DIR)) { + gchar * directory = (gchar *)data; + + if (!g_file_test(directory, G_FILE_TEST_IS_DIR)) { return FALSE; } GError * error = NULL; - GDir * dir = g_dir_open(SYSTEM_APPS_DIR, 0, &error); + GDir * dir = g_dir_open(directory, 0, &error); if (dir == NULL) { g_warning("Unable to open system apps directory: %s", error->message); g_error_free(error); @@ -771,7 +773,7 @@ build_launchers (gpointer data) const gchar * filename = NULL; while ((filename = g_dir_read_name(dir)) != NULL) { g_debug("Found file: %s", filename); - gchar * path = g_build_filename(SYSTEM_APPS_DIR, filename, NULL); + gchar * path = g_build_filename(directory, filename, NULL); g_idle_add(build_launcher, path); } @@ -815,7 +817,7 @@ main (int argc, char ** argv) g_signal_connect(listener, INDICATE_LISTENER_SIGNAL_SERVER_REMOVED, G_CALLBACK(server_removed), root_menuitem); g_idle_add(blacklist_init, NULL); - g_idle_add(build_launchers, NULL); + g_idle_add(build_launchers, SYSTEM_APPS_DIR); mainloop = g_main_loop_new(NULL, FALSE); g_main_loop_run(mainloop); -- cgit v1.2.3 From ce045e0d41054c2ccf8c9e524a4997ea2ee38601 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 20 Aug 2009 20:52:12 -0500 Subject: Adding the user APPS directory to the places where we can find applications --- src/messages-service.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/messages-service.c b/src/messages-service.c index 0e4c296..8b9b5cb 100644 --- a/src/messages-service.c +++ b/src/messages-service.c @@ -818,9 +818,13 @@ main (int argc, char ** argv) g_idle_add(blacklist_init, NULL); g_idle_add(build_launchers, SYSTEM_APPS_DIR); + gchar * userdir = g_build_filename(g_get_user_config_dir(), USER_APPS_DIR, NULL); + g_idle_add(build_launchers, userdir); mainloop = g_main_loop_new(NULL, FALSE); g_main_loop_run(mainloop); + g_free(userdir); + return 0; } -- cgit v1.2.3 From 79f4b7e53cc1a26d37de1daf98fdcb9a6f803aa8 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 20 Aug 2009 21:24:31 -0500 Subject: Basic code to monitor the directories --- src/messages-service.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/messages-service.c b/src/messages-service.c index 8b9b5cb..b153eda 100644 --- a/src/messages-service.c +++ b/src/messages-service.c @@ -24,6 +24,7 @@ with this program. If not, see . #include #include #include +#include #include @@ -53,6 +54,8 @@ static gboolean build_launchers (gpointer data); static gboolean blacklist_init (gpointer data); static gboolean blacklist_add (gpointer data); static void blacklist_remove (const gchar * definition_file); +static void blacklist_dir_changed (GFileMonitor * monitor, GFile * file, GFile * other_file, GFileMonitorEvent event_type, gpointer user_data); +static void app_dir_changed (GFileMonitor * monitor, GFile * file, GFile * other_file, GFileMonitorEvent event_type, gpointer user_data); /* @@ -164,6 +167,7 @@ launcherList_sort (gconstpointer a, gconstpointer b) */ static GHashTable * blacklist = NULL; +static GFileMonitor * blacklistdirmon = NULL; /* Initialize the black list and start to setup handlers for it. */ @@ -180,6 +184,12 @@ blacklist_init (gpointer data) return FALSE; } + GFile * filedir = g_file_new_for_path(blacklistdir); + blacklistdirmon = g_file_monitor_directory(filedir, G_FILE_MONITOR_NONE, NULL, NULL); + if (blacklistdirmon != NULL) { + g_signal_connect(G_OBJECT(blacklistdirmon), "changed", G_CALLBACK(blacklist_dir_changed), NULL); + } + GError * error = NULL; GDir * dir = g_dir_open(blacklistdir, 0, &error); if (dir == NULL) { @@ -277,6 +287,16 @@ blacklist_check (const gchar * desktop_file) return FALSE; } +/* A callback everytime the blacklist directory changes + in some way. It needs to handle that. */ +static void +blacklist_dir_changed (GFileMonitor * monitor, GFile * file, GFile * other_file, GFileMonitorEvent event_type, gpointer user_data) +{ + g_debug("Blacklist directory changed!"); + + return; +} + /* * More code */ @@ -659,6 +679,14 @@ indicator_removed (IndicateListener * listener, IndicateListenerServer * server, return; } +static void +app_dir_changed (GFileMonitor * monitor, GFile * file, GFile * other_file, GFileMonitorEvent event_type, gpointer user_data) +{ + gchar * directory = (gchar *)user_data; + g_debug("Application directory changed: %s", directory); + return; +} + /* Check to see if a new desktop file causes any of the launchers to be eclipsed by a running process */ @@ -762,6 +790,12 @@ build_launchers (gpointer data) return FALSE; } + GFile * filedir = g_file_new_for_path(directory); + GFileMonitor * dirmon = g_file_monitor_directory(filedir, G_FILE_MONITOR_NONE, NULL, NULL); + if (dirmon != NULL) { + g_signal_connect(G_OBJECT(dirmon), "changed", G_CALLBACK(app_dir_changed), directory); + } + GError * error = NULL; GDir * dir = g_dir_open(directory, 0, &error); if (dir == NULL) { -- cgit v1.2.3 From 33e07dab3aafaf7219b3284a95ad4f16755d677d Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 21 Aug 2009 14:01:38 -0500 Subject: Turning blacklist dir changes into events --- src/messages-service.c | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/src/messages-service.c b/src/messages-service.c index b153eda..4e03c26 100644 --- a/src/messages-service.c +++ b/src/messages-service.c @@ -53,7 +53,7 @@ static gboolean build_launcher (gpointer data); static gboolean build_launchers (gpointer data); static gboolean blacklist_init (gpointer data); static gboolean blacklist_add (gpointer data); -static void blacklist_remove (const gchar * definition_file); +static gboolean blacklist_remove (gpointer data); static void blacklist_dir_changed (GFileMonitor * monitor, GFile * file, GFile * other_file, GFileMonitorEvent event_type, gpointer user_data); static void app_dir_changed (GFileMonitor * monitor, GFile * file, GFile * other_file, GFileMonitorEvent event_type, gpointer user_data); @@ -258,17 +258,18 @@ blacklist_add (gpointer udata) } } - blacklist_remove(NULL); return FALSE; } /* Remove a black list item based on the definition file and uneclipse those launchers blocked by it. */ -static void -blacklist_remove (const gchar * definition_file) +static gboolean +blacklist_remove (gpointer data) { + gchar * definition_file = (gchar *)data; + g_debug("Removing: %s", definition_file); - return; + return FALSE; } /* Check to see if a particular desktop file is @@ -294,6 +295,23 @@ blacklist_dir_changed (GFileMonitor * monitor, GFile * file, GFile * other_file, { g_debug("Blacklist directory changed!"); + switch (event_type) { + case G_FILE_MONITOR_EVENT_DELETED: { + gchar * path = g_file_get_path(file); + g_debug("\tDelete: %s", path); + g_idle_add(blacklist_remove, path); + break; + } + case G_FILE_MONITOR_EVENT_CREATED: { + gchar * path = g_file_get_path(file); + g_debug("\tCreate: %s", path); + g_idle_add(blacklist_add, path); + break; + } + default: + break; + } + return; } -- cgit v1.2.3 From 10a149cf899e14f6ef5dd4be97d21f450fd8bd0f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 21 Aug 2009 14:53:06 -0500 Subject: Fleshing out remove to try to get rid of all these blacklist items. --- src/messages-service.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/messages-service.c b/src/messages-service.c index 4e03c26..9c015e2 100644 --- a/src/messages-service.c +++ b/src/messages-service.c @@ -261,6 +261,14 @@ blacklist_add (gpointer udata) return FALSE; } +/* Looks through the list of definition files and + tries to match the one passed in. */ +static gboolean +blacklist_find_def (gpointer key, gpointer value, gpointer data) +{ + return !g_strcmp0((gchar *)value, (gchar *)data); +} + /* Remove a black list item based on the definition file and uneclipse those launchers blocked by it. */ static gboolean @@ -269,6 +277,31 @@ blacklist_remove (gpointer data) gchar * definition_file = (gchar *)data; g_debug("Removing: %s", definition_file); + gpointer key = g_hash_table_find(blacklist, blacklist_find_def, data); + if (key == NULL) { + g_debug("\tNot found!"); + return FALSE; + } + + GList * launcheritem; + for (launcheritem = launcherList; launcheritem != NULL; launcheritem = launcheritem->next) { + launcherList_t * li = (launcherList_t *)launcheritem->data; + if (!g_strcmp0(launcher_menu_item_get_desktop(li->menuitem), (gchar *)key)) { + GList * serveritem; + for (serveritem = serverList; serveritem != NULL; serveritem = serveritem->next) { + serverList_t * si = (serverList_t *)serveritem->data; + if (!g_strcmp0(app_menu_item_get_desktop(si->menuitem), (gchar *)key)) { + break; + } + } + if (serveritem == NULL) { + launcher_menu_item_set_eclipsed(li->menuitem, FALSE); + } + } + } + + g_hash_table_remove(blacklist, key); + return FALSE; } -- cgit v1.2.3 From 51992ee519580718b3904adaabc76004dba6f323 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 21 Aug 2009 15:12:51 -0500 Subject: I'd have to say that hash_table_find didn't do what I expected, and is pretty useless. --- src/messages-service.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/src/messages-service.c b/src/messages-service.c index 9c015e2..7d48769 100644 --- a/src/messages-service.c +++ b/src/messages-service.c @@ -261,14 +261,6 @@ blacklist_add (gpointer udata) return FALSE; } -/* Looks through the list of definition files and - tries to match the one passed in. */ -static gboolean -blacklist_find_def (gpointer key, gpointer value, gpointer data) -{ - return !g_strcmp0((gchar *)value, (gchar *)data); -} - /* Remove a black list item based on the definition file and uneclipse those launchers blocked by it. */ static gboolean @@ -277,8 +269,19 @@ blacklist_remove (gpointer data) gchar * definition_file = (gchar *)data; g_debug("Removing: %s", definition_file); - gpointer key = g_hash_table_find(blacklist, blacklist_find_def, data); - if (key == NULL) { + GHashTableIter iter; + gpointer key, value; + gboolean found = FALSE; + + g_hash_table_iter_init(&iter, blacklist); + while (g_hash_table_iter_next(&iter, &key, &value)) { + if (!g_strcmp0((gchar *)value, definition_file)) { + found = TRUE; + break; + } + } + + if (!found) { g_debug("\tNot found!"); return FALSE; } @@ -300,7 +303,9 @@ blacklist_remove (gpointer data) } } - g_hash_table_remove(blacklist, key); + if (!g_hash_table_remove(blacklist, key)) { + g_warning("Unable to remove '%s' with value '%s'", definition_file, (gchar *)key); + } return FALSE; } -- cgit v1.2.3 From 50a2c4e02d275a88e5c917e4946410383c44b3ed Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 21 Aug 2009 15:31:13 -0500 Subject: Start responding to changes in the applications directories --- src/messages-service.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/messages-service.c b/src/messages-service.c index 7d48769..3a145d6 100644 --- a/src/messages-service.c +++ b/src/messages-service.c @@ -56,6 +56,7 @@ static gboolean blacklist_add (gpointer data); static gboolean blacklist_remove (gpointer data); static void blacklist_dir_changed (GFileMonitor * monitor, GFile * file, GFile * other_file, GFileMonitorEvent event_type, gpointer user_data); static void app_dir_changed (GFileMonitor * monitor, GFile * file, GFile * other_file, GFileMonitorEvent event_type, gpointer user_data); +static gboolean destroy_launcher (gpointer data); /* @@ -740,6 +741,24 @@ app_dir_changed (GFileMonitor * monitor, GFile * file, GFile * other_file, GFile { gchar * directory = (gchar *)user_data; g_debug("Application directory changed: %s", directory); + + switch (event_type) { + case G_FILE_MONITOR_EVENT_DELETED: { + gchar * path = g_file_get_path(file); + g_debug("\tDelete: %s", path); + g_idle_add(destroy_launcher, path); + break; + } + case G_FILE_MONITOR_EVENT_CREATED: { + gchar * path = g_file_get_path(file); + g_debug("\tCreate: %s", path); + g_idle_add(build_launcher, path); + break; + } + default: + break; + } + return; } @@ -793,6 +812,15 @@ remove_eclipses (AppMenuItem * ai) return; } +/* Remove a launcher from the system. We need to figure + out what it's up to! */ +static gboolean +destroy_launcher (gpointer data) +{ + + return FALSE; +} + /* This function turns a specific file into a menu item and registers it appropriately with everyone */ static gboolean -- cgit v1.2.3 From 1827c88f591eeefa129b700c0eb4b1710f712272 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 21 Aug 2009 15:56:16 -0500 Subject: The launcher creation didn't test to see if it already exists. Now we keep one launcher per desktop file. Makes sense, eh? That's what we're going for. --- src/messages-service.c | 41 +++++++++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/src/messages-service.c b/src/messages-service.c index 3a145d6..41afb6b 100644 --- a/src/messages-service.c +++ b/src/messages-service.c @@ -147,6 +147,7 @@ imList_sort (gconstpointer a, gconstpointer b) typedef struct _launcherList_t launcherList_t; struct _launcherList_t { LauncherMenuItem * menuitem; + GList * appdiritems; }; static gint @@ -832,7 +833,6 @@ build_launcher (gpointer data) gchar * desktop = NULL; g_file_get_contents(path, &desktop, NULL, NULL); - g_free(path); if (desktop == NULL) { return FALSE; @@ -842,20 +842,37 @@ build_launcher (gpointer data) g_free(desktop); g_debug("\tcontents: %s", trimdesktop); - /* Build the item */ - launcherList_t * ll = g_new0(launcherList_t, 1); - ll->menuitem = launcher_menu_item_new(trimdesktop); - g_free(trimdesktop); + /* Check to see if we already have a launcher */ + GList * listitem; + for (listitem = launcherList; listitem != NULL; listitem = listitem->next) { + launcherList_t * li = (launcherList_t *)listitem->data; + if (!g_strcmp0(launcher_menu_item_get_desktop(li->menuitem), trimdesktop)) { + break; + } + } - /* Add it to the list */ - launcherList = g_list_insert_sorted(launcherList, ll, launcherList_sort); + if (listitem == NULL) { + /* If not */ + /* Build the item */ + launcherList_t * ll = g_new0(launcherList_t, 1); + ll->menuitem = launcher_menu_item_new(trimdesktop); + g_free(trimdesktop); + ll->appdiritems = g_list_append(NULL, path); - /* Add it to the menu */ - dbusmenu_menuitem_child_append(root_menuitem, DBUSMENU_MENUITEM(ll->menuitem)); - resort_menu(root_menuitem); + /* Add it to the list */ + launcherList = g_list_insert_sorted(launcherList, ll, launcherList_sort); - if (blacklist_check(launcher_menu_item_get_desktop(ll->menuitem))) { - launcher_menu_item_set_eclipsed(ll->menuitem, TRUE); + /* Add it to the menu */ + dbusmenu_menuitem_child_append(root_menuitem, DBUSMENU_MENUITEM(ll->menuitem)); + resort_menu(root_menuitem); + + if (blacklist_check(launcher_menu_item_get_desktop(ll->menuitem))) { + launcher_menu_item_set_eclipsed(ll->menuitem, TRUE); + } + } else { + /* If so add ourselves */ + launcherList_t * ll = (launcherList_t *)listitem->data; + ll->appdiritems = g_list_append(ll->appdiritems, path); } return FALSE; -- cgit v1.2.3 From 286c51ca41139a2961cfe68a80a458ebf882bae9 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 21 Aug 2009 16:15:16 -0500 Subject: Fleshing out the first part of destroy, in that we're just removing an item from a list. --- src/messages-service.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/messages-service.c b/src/messages-service.c index 41afb6b..8617c5d 100644 --- a/src/messages-service.c +++ b/src/messages-service.c @@ -818,6 +818,41 @@ remove_eclipses (AppMenuItem * ai) static gboolean destroy_launcher (gpointer data) { + gchar * appdirentry = (gchar *)data; + + GList * listitem; + GList * direntry; + launcherList_t * li; + gchar * appdir; + + for (listitem = launcherList; listitem != NULL; listitem = listitem->next) { + li = (launcherList_t *)listitem->data; + for (direntry = li->appdiritems; direntry != NULL; direntry = direntry->next) { + appdir = (gchar *)direntry->data; + if (!g_strcmp0(appdir, appdirentry)) { + break; + } + } + + if (direntry != NULL) { + break; + } + } + + if (listitem == NULL) { + g_warning("Removed '%s' by the way of it not seeming to exist anywhere.", appdirentry); + return FALSE; + } + + if (g_list_length(li->appdiritems) > 1) { + /* Just remove this item, and we can move on */ + g_debug("Just removing file entry: %s", appdir); + li->appdiritems = g_list_remove(li->appdiritems, appdir); + g_free(appdir); + return FALSE; + } + + /* Full Destroy */ return FALSE; } -- cgit v1.2.3 From acf054710bea98ee0a63c72cf5e5bcbff8b9bc74 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 21 Aug 2009 16:27:59 -0500 Subject: Now we're really killing these puppies! Don't cry, they weren't cuddly puppies. --- src/messages-service.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/messages-service.c b/src/messages-service.c index 8617c5d..384198a 100644 --- a/src/messages-service.c +++ b/src/messages-service.c @@ -853,6 +853,18 @@ destroy_launcher (gpointer data) } /* Full Destroy */ + g_free(appdir); + g_list_free(li->appdiritems); + + if (li->menuitem != NULL) { + dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(li->menuitem), "visible", "false"); + dbusmenu_menuitem_child_delete(root_menuitem, DBUSMENU_MENUITEM(li->menuitem)); + g_object_unref(G_OBJECT(li->menuitem)); + li->menuitem = NULL; + } + + launcherList = g_list_remove(launcherList, li); + g_free(li); return FALSE; } -- cgit v1.2.3 From 19f312f6319d5c3fcb4b21d1e655b08bc4a609de Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 25 Aug 2009 16:01:45 -0500 Subject: Checking to see if error is null before looking inside it. --- src/messages-service.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/messages-service.c b/src/messages-service.c index 384198a..e4982a2 100644 --- a/src/messages-service.c +++ b/src/messages-service.c @@ -195,7 +195,7 @@ blacklist_init (gpointer data) GError * error = NULL; GDir * dir = g_dir_open(blacklistdir, 0, &error); if (dir == NULL) { - g_warning("Unable to open blacklist directory (%s): %s", blacklistdir, error->message); + g_warning("Unable to open blacklist directory (%s): %s", blacklistdir, error == NULL ? "No Message" : error->message); g_error_free(error); g_free(blacklistdir); return FALSE; -- cgit v1.2.3 From 7258fe52ed30b06de812773f123fedabb90efe89 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 25 Aug 2009 21:39:54 -0500 Subject: Switching to ayatana.org and adding a new name for the service as a whole. --- src/dbus-data.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/dbus-data.h b/src/dbus-data.h index 4aeedf0..e7d4d26 100644 --- a/src/dbus-data.h +++ b/src/dbus-data.h @@ -2,7 +2,10 @@ #ifndef __DBUS_DATA_H__ #define __DBUS_DATA_H__ 1 -#define INDICATOR_MESSAGES_DBUS_NAME "com.ubuntu.indicator.messages" -#define INDICATOR_MESSAGES_DBUS_OBJECT "/com/ubuntu/indicator/messages" +#define INDICATOR_MESSAGES_DBUS_NAME "org.ayatana.indicator.messages" +#define INDICATOR_MESSAGES_DBUS_OBJECT "/org/ayatana/indicator/messages/menu" + +#define INDICATOR_MESSAGES_DBUS_SERVICE_OBJECT "/org/ayatana/indicator/messages/service" +#define INDICATOR_MESSAGES_DBUS_SERVICE_INTERFACE "org.ayatana.indicator.messages.service" #endif /* __DBUS_DATA_H__ */ -- cgit v1.2.3 From 8601a2b19bdb2352b1830888f982978a447dbeec Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 25 Aug 2009 21:40:35 -0500 Subject: Adding in a new dbus interface. --- .bzrignore | 2 ++ src/Makefile.am | 29 ++++++++++++++++++++++++++++- src/messages-service.xml | 25 +++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 src/messages-service.xml diff --git a/.bzrignore b/.bzrignore index 42bdaa3..1d6767c 100644 --- a/.bzrignore +++ b/.bzrignore @@ -19,3 +19,5 @@ src/libmessaging_la-app-menu-item.lo data/indicator-messages.service indicator-messages-service indicator-messages-service-activate +src/messages-service-client.h +src/messages-service-server.h diff --git a/src/Makefile.am b/src/Makefile.am index 0678537..243247e 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -8,7 +8,8 @@ bin_PROGRAMS = indicator-messages-service messaginglibdir = $(INDICATORDIR) messaginglib_LTLIBRARIES = libmessaging.la libmessaging_la_SOURCES = \ - indicator-messages.c\ + indicator-messages.c \ + messages-service-client.h \ dbus-data.h libmessaging_la_CFLAGS = $(APPLET_CFLAGS) -Wall -Wl,-Bsymbolic-functions -Wl,-z,defs -Wl,--as-needed -Werror libmessaging_la_LIBADD = $(APPLET_LIBS) @@ -20,6 +21,7 @@ libmessaging_la_LDFLAGS = -module -avoid-version indicator_messages_service_SOURCES = \ messages-service.c \ + messages-service-server.h \ im-menu-item.c \ im-menu-item.h \ app-menu-item.c \ @@ -30,3 +32,28 @@ indicator_messages_service_SOURCES = \ dbus-data.h indicator_messages_service_CFLAGS = $(APPLET_CFLAGS) -Wall -Wl,-Bsymbolic-functions -Wl,-z,defs -Wl,--as-needed -Werror indicator_messages_service_LDADD = $(APPLET_LIBS) + +messages-service-client.h: $(srcdir)/messages-service.xml + dbus-binding-tool \ + --prefix=_messages_service_client \ + --mode=glib-client \ + --output=messages-service-client.h \ + $(srcdir)/messages-service.xml + +messages-service-server.h: $(srcdir)/messages-service.xml + dbus-binding-tool \ + --prefix=_messages_service_server \ + --mode=glib-server \ + --output=messages-service-server.h \ + $(srcdir)/messages-service.xml + +BUILT_SOURCES = \ + messages-service-client.h \ + messages-service-server.h + +CLEANFILES = \ + $(BUILT_SOURCES) + +EXTRA_DIST = \ + messages-service.xml + diff --git a/src/messages-service.xml b/src/messages-service.xml new file mode 100644 index 0000000..f991179 --- /dev/null +++ b/src/messages-service.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.3 From e7695d9f9da90e12aaefe490e46e18d3b32f33dd Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 25 Aug 2009 22:08:41 -0500 Subject: Building an object to represent the service over DBus. --- src/Makefile.am | 2 ++ src/messages-service-dbus.c | 84 +++++++++++++++++++++++++++++++++++++++++++++ src/messages-service-dbus.h | 37 ++++++++++++++++++++ 3 files changed, 123 insertions(+) create mode 100644 src/messages-service-dbus.c create mode 100644 src/messages-service-dbus.h diff --git a/src/Makefile.am b/src/Makefile.am index 243247e..38787a1 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -22,6 +22,8 @@ libmessaging_la_LDFLAGS = -module -avoid-version indicator_messages_service_SOURCES = \ messages-service.c \ messages-service-server.h \ + messages-service-dbus.c \ + messages-service-dbus.h \ im-menu-item.c \ im-menu-item.h \ app-menu-item.c \ diff --git a/src/messages-service-dbus.c b/src/messages-service-dbus.c new file mode 100644 index 0000000..6fa2125 --- /dev/null +++ b/src/messages-service-dbus.c @@ -0,0 +1,84 @@ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "messages-service-dbus.h" + +typedef struct _MessageServiceDbusPrivate MessageServiceDbusPrivate; + +struct _MessageServiceDbusPrivate +{ + guint temp; +}; + +#define MESSAGE_SERVICE_DBUS_GET_PRIVATE(o) \ +(G_TYPE_INSTANCE_GET_PRIVATE ((o), MESSAGE_SERVICE_DBUS_TYPE, MessageServiceDbusPrivate)) + +static void message_service_dbus_class_init (MessageServiceDbusClass *klass); +static void message_service_dbus_init (MessageServiceDbus *self); +static void message_service_dbus_dispose (GObject *object); +static void message_service_dbus_finalize (GObject *object); + +static void _messages_service_server_watch (void); +static void _messages_service_server_attention_requested (void); +static void _messages_service_server_icon_shown (void); + +#include "messages-service-server.h" + +G_DEFINE_TYPE (MessageServiceDbus, message_service_dbus, G_TYPE_OBJECT); + +static void +message_service_dbus_class_init (MessageServiceDbusClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + g_type_class_add_private (klass, sizeof (MessageServiceDbusPrivate)); + + object_class->dispose = message_service_dbus_dispose; + object_class->finalize = message_service_dbus_finalize; + + return; +} + +static void +message_service_dbus_init (MessageServiceDbus *self) +{ + return; +} + +static void +message_service_dbus_dispose (GObject *object) +{ + + + G_OBJECT_CLASS (message_service_dbus_parent_class)->dispose (object); + return; +} + +static void +message_service_dbus_finalize (GObject *object) +{ + + + G_OBJECT_CLASS (message_service_dbus_parent_class)->finalize (object); + return; +} + +static void +_messages_service_server_watch (void) +{ + +} + +static void +_messages_service_server_attention_requested (void) +{ + +} + +static void +_messages_service_server_icon_shown (void) +{ + +} + diff --git a/src/messages-service-dbus.h b/src/messages-service-dbus.h new file mode 100644 index 0000000..cde14b1 --- /dev/null +++ b/src/messages-service-dbus.h @@ -0,0 +1,37 @@ +#ifndef __MESSAGE_SERVICE_DBUS_H__ +#define __MESSAGE_SERVICE_DBUS_H__ + +#include +#include + +G_BEGIN_DECLS + +#define MESSAGE_SERVICE_DBUS_TYPE (message_service_dbus_get_type ()) +#define MESSAGE_SERVICE_DBUS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MESSAGE_SERVICE_DBUS_TYPE, MessageServiceDbus)) +#define MESSAGE_SERVICE_DBUS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MESSAGE_SERVICE_DBUS_TYPE, MessageServiceDbusClass)) +#define IS_MESSAGE_SERVICE_DBUS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MESSAGE_SERVICE_DBUS_TYPE)) +#define IS_MESSAGE_SERVICE_DBUS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MESSAGE_SERVICE_DBUS_TYPE)) +#define MESSAGE_SERVICE_DBUS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MESSAGE_SERVICE_DBUS_TYPE, MessageServiceDbusClass)) + +#define MESSAGE_SERVICE_DBUS_SIGNAL_ATTENTION_CHANGED "attention-changed" +#define MESSAGE_SERVICE_DBUS_SIGNAL_ICON_CHANGED "icon-changed" + +typedef struct _MessageServiceDbus MessageServiceDbus; +typedef struct _MessageServiceDbusClass MessageServiceDbusClass; + +struct _MessageServiceDbusClass { + GObjectClass parent_class; + + void (*attention_changed) (gboolean dot); + void (*icon_changed) (gboolean hidden); +}; + +struct _MessageServiceDbus { + GObject parent; +}; + +GType message_service_dbus_get_type (void); + +G_END_DECLS + +#endif -- cgit v1.2.3 From 2b7746e2e74ffbafb7f1eb663a6a525dec9d28cb Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 25 Aug 2009 22:23:15 -0500 Subject: Creating a real object and initing it. --- src/messages-service-dbus.c | 6 ++++++ src/messages-service-dbus.h | 3 +++ src/messages-service.c | 5 +++++ 3 files changed, 14 insertions(+) diff --git a/src/messages-service-dbus.c b/src/messages-service-dbus.c index 6fa2125..ecc74e2 100644 --- a/src/messages-service-dbus.c +++ b/src/messages-service-dbus.c @@ -64,6 +64,12 @@ message_service_dbus_finalize (GObject *object) return; } +MessageServiceDbus * +message_service_dbus_new (void) +{ + return MESSAGE_SERVICE_DBUS(g_object_new(MESSAGE_SERVICE_DBUS_TYPE, NULL)); +} + static void _messages_service_server_watch (void) { diff --git a/src/messages-service-dbus.h b/src/messages-service-dbus.h index cde14b1..26035b7 100644 --- a/src/messages-service-dbus.h +++ b/src/messages-service-dbus.h @@ -31,6 +31,9 @@ struct _MessageServiceDbus { }; GType message_service_dbus_get_type (void); +MessageServiceDbus * message_service_dbus_new (void); +void message_service_dbus_set_attention (gboolean attention); +void message_service_dbus_set_icon (gboolean hidden); G_END_DECLS diff --git a/src/messages-service.c b/src/messages-service.c index e4982a2..d23e9ee 100644 --- a/src/messages-service.c +++ b/src/messages-service.c @@ -33,6 +33,7 @@ with this program. If not, see . #include "launcher-menu-item.h" #include "dbus-data.h" #include "dirs.h" +#include "messages-service-dbus.h" static IndicateListener * listener; static GList * serverList = NULL; @@ -41,6 +42,8 @@ static GList * launcherList = NULL; static DbusmenuMenuitem * root_menuitem = NULL; static GMainLoop * mainloop = NULL; +static MessageServiceDbus * dbus_interface = NULL; + static void server_count_changed (AppMenuItem * appitem, guint count, gpointer data); static void server_name_changed (AppMenuItem * appitem, gchar * name, gpointer data); @@ -986,6 +989,8 @@ main (int argc, char ** argv) return 1; } + dbus_interface = message_service_dbus_new(); + listener = indicate_listener_ref_default(); serverList = NULL; -- cgit v1.2.3 From 96b2dc1cc2be79cdda2fb109eebe2f4bab6551d9 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 25 Aug 2009 22:48:52 -0500 Subject: Bringing up the object and having some variables to access. --- src/messages-service-dbus.c | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/src/messages-service-dbus.c b/src/messages-service-dbus.c index ecc74e2..5ce7695 100644 --- a/src/messages-service-dbus.c +++ b/src/messages-service-dbus.c @@ -2,13 +2,16 @@ #include "config.h" #endif +#include #include "messages-service-dbus.h" +#include "dbus-data.h" typedef struct _MessageServiceDbusPrivate MessageServiceDbusPrivate; struct _MessageServiceDbusPrivate { - guint temp; + gboolean dot; + gboolean hidden; }; #define MESSAGE_SERVICE_DBUS_GET_PRIVATE(o) \ @@ -20,8 +23,8 @@ static void message_service_dbus_dispose (GObject *object); static void message_service_dbus_finalize (GObject *object); static void _messages_service_server_watch (void); -static void _messages_service_server_attention_requested (void); -static void _messages_service_server_icon_shown (void); +static gboolean _messages_service_server_attention_requested (MessageServiceDbus * self, gboolean * dot, GError ** error); +static gboolean _messages_service_server_icon_shown (MessageServiceDbus * self, gboolean * hidden, GError ** error); #include "messages-service-server.h" @@ -37,12 +40,24 @@ message_service_dbus_class_init (MessageServiceDbusClass *klass) object_class->dispose = message_service_dbus_dispose; object_class->finalize = message_service_dbus_finalize; + dbus_g_object_type_install_info(MESSAGE_SERVICE_DBUS_TYPE, &dbus_glib__messages_service_server_object_info); + return; } static void message_service_dbus_init (MessageServiceDbus *self) { + DBusGConnection * connection = dbus_g_bus_get(DBUS_BUS_SESSION, NULL); + dbus_g_connection_register_g_object(connection, + INDICATOR_MESSAGES_DBUS_SERVICE_OBJECT, + G_OBJECT(self)); + + MessageServiceDbusPrivate * priv = MESSAGE_SERVICE_DBUS_GET_PRIVATE(self); + + priv->dot = FALSE; + priv->hidden = FALSE; + return; } @@ -76,15 +91,19 @@ _messages_service_server_watch (void) } -static void -_messages_service_server_attention_requested (void) +static gboolean +_messages_service_server_attention_requested (MessageServiceDbus * self, gboolean * dot, GError ** error) { - + MessageServiceDbusPrivate * priv = MESSAGE_SERVICE_DBUS_GET_PRIVATE(self); + *dot = priv->dot; + return TRUE; } -static void -_messages_service_server_icon_shown (void) +static gboolean +_messages_service_server_icon_shown (MessageServiceDbus * self, gboolean * hidden, GError ** error) { - + MessageServiceDbusPrivate * priv = MESSAGE_SERVICE_DBUS_GET_PRIVATE(self); + *hidden = priv->hidden; + return TRUE; } -- cgit v1.2.3 From 9efbade0a88f7ebce9ceb8d06293b1d636d02672 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 26 Aug 2009 09:17:50 -0500 Subject: Some comments. --- src/messages-service-dbus.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/messages-service-dbus.c b/src/messages-service-dbus.c index 5ce7695..da91af5 100644 --- a/src/messages-service-dbus.c +++ b/src/messages-service-dbus.c @@ -85,12 +85,15 @@ message_service_dbus_new (void) return MESSAGE_SERVICE_DBUS(g_object_new(MESSAGE_SERVICE_DBUS_TYPE, NULL)); } +/* DBus function to say that someone is watching */ static void _messages_service_server_watch (void) { } +/* DBus interface to request the private variable to know + whether there is a green dot. */ static gboolean _messages_service_server_attention_requested (MessageServiceDbus * self, gboolean * dot, GError ** error) { @@ -99,6 +102,8 @@ _messages_service_server_attention_requested (MessageServiceDbus * self, gboolea return TRUE; } +/* DBus interface to request the private variable to know + whether the icon is hidden. */ static gboolean _messages_service_server_icon_shown (MessageServiceDbus * self, gboolean * hidden, GError ** error) { -- cgit v1.2.3 From 4b1b97c765557715451b16aa9c409e1539050b9f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 26 Aug 2009 09:20:34 -0500 Subject: Adding the basic set functions into the C files. --- src/messages-service-dbus.c | 17 +++++++++++++++++ src/messages-service-dbus.h | 4 ++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/messages-service-dbus.c b/src/messages-service-dbus.c index da91af5..8d0d5e7 100644 --- a/src/messages-service-dbus.c +++ b/src/messages-service-dbus.c @@ -112,3 +112,20 @@ _messages_service_server_icon_shown (MessageServiceDbus * self, gboolean * hidde return TRUE; } +void +message_server_dbus_set_attention (MessageServiceDbus * self, gboolean attention) +{ + MessageServiceDbusPrivate * priv = MESSAGE_SERVICE_DBUS_GET_PRIVATE(self); + /* Do signal */ + priv->dot = attention; + return; +} + +void +message_server_dbus_set_icon (MessageServiceDbus * self, gboolean hidden) +{ + MessageServiceDbusPrivate * priv = MESSAGE_SERVICE_DBUS_GET_PRIVATE(self); + /* Do signal */ + priv->hidden = hidden; + return; +} diff --git a/src/messages-service-dbus.h b/src/messages-service-dbus.h index 26035b7..1075eb4 100644 --- a/src/messages-service-dbus.h +++ b/src/messages-service-dbus.h @@ -32,8 +32,8 @@ struct _MessageServiceDbus { GType message_service_dbus_get_type (void); MessageServiceDbus * message_service_dbus_new (void); -void message_service_dbus_set_attention (gboolean attention); -void message_service_dbus_set_icon (gboolean hidden); +void message_server_dbus_set_attention (MessageServiceDbus * self, gboolean attention); +void message_server_dbus_set_icon (MessageServiceDbus * self, gboolean hidden); G_END_DECLS -- cgit v1.2.3 From 964062bdeb9d3e9ca8db4bb0466440523c323f39 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 26 Aug 2009 09:30:16 -0500 Subject: Making some signal lovin' --- src/messages-service-dbus.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/messages-service-dbus.c b/src/messages-service-dbus.c index 8d0d5e7..38f2894 100644 --- a/src/messages-service-dbus.c +++ b/src/messages-service-dbus.c @@ -6,6 +6,14 @@ #include "messages-service-dbus.h" #include "dbus-data.h" +enum { + ATTENTION_CHANGED, + ICON_CHANGED, + LAST_SIGNAL +}; + +static guint signals[LAST_SIGNAL] = { 0 }; + typedef struct _MessageServiceDbusPrivate MessageServiceDbusPrivate; struct _MessageServiceDbusPrivate @@ -40,6 +48,23 @@ message_service_dbus_class_init (MessageServiceDbusClass *klass) object_class->dispose = message_service_dbus_dispose; object_class->finalize = message_service_dbus_finalize; + signals[ATTENTION_CHANGED] = g_signal_new(MESSAGE_SERVICE_DBUS_SIGNAL_ATTENTION_CHANGED, + G_TYPE_FROM_CLASS(klass), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (MessageServiceDbusClass, attention_changed), + NULL, NULL, + g_cclosure_marshal_VOID__BOOLEAN, + G_TYPE_NONE, 1, G_TYPE_BOOLEAN); + + signals[ICON_CHANGED] = g_signal_new(MESSAGE_SERVICE_DBUS_SIGNAL_ICON_CHANGED, + G_TYPE_FROM_CLASS(klass), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (MessageServiceDbusClass, icon_changed), + NULL, NULL, + g_cclosure_marshal_VOID__BOOLEAN, + G_TYPE_NONE, 1, G_TYPE_BOOLEAN); + + dbus_g_object_type_install_info(MESSAGE_SERVICE_DBUS_TYPE, &dbus_glib__messages_service_server_object_info); return; -- cgit v1.2.3 From 3e09c01a33e88d9789678adbdb57f1bfcbe44edd Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 26 Aug 2009 09:37:53 -0500 Subject: Okay, now we're signaling change. --- src/messages-service-dbus.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/messages-service-dbus.c b/src/messages-service-dbus.c index 38f2894..108360b 100644 --- a/src/messages-service-dbus.c +++ b/src/messages-service-dbus.c @@ -142,7 +142,10 @@ message_server_dbus_set_attention (MessageServiceDbus * self, gboolean attention { MessageServiceDbusPrivate * priv = MESSAGE_SERVICE_DBUS_GET_PRIVATE(self); /* Do signal */ - priv->dot = attention; + if (attention != priv->dot) { + priv->dot = attention; + g_signal_emit(G_OBJECT(self), signals[ATTENTION_CHANGED], 0, priv->dot, TRUE); + } return; } @@ -151,6 +154,9 @@ message_server_dbus_set_icon (MessageServiceDbus * self, gboolean hidden) { MessageServiceDbusPrivate * priv = MESSAGE_SERVICE_DBUS_GET_PRIVATE(self); /* Do signal */ - priv->hidden = hidden; + if (hidden != priv->hidden) { + priv->hidden = hidden; + g_signal_emit(G_OBJECT(self), signals[ICON_CHANGED], 0, priv->hidden, TRUE); + } return; } -- cgit v1.2.3 From 03ca8ad97b53334826abc317472932289b17f69f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 26 Aug 2009 09:48:45 -0500 Subject: Building a proxy... --- src/indicator-messages.c | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/src/indicator-messages.c b/src/indicator-messages.c index efb52b2..a7628b0 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -32,11 +32,34 @@ INDICATOR_SET_NAME("messages") #include "dbus-data.h" -static GtkWidget * main_image; +static GtkWidget * main_image = NULL; #define DESIGN_TEAM_SIZE design_team_size static GtkIconSize design_team_size; +static DBusGProxy * icon_proxy = NULL; + +gboolean +setup_icon_proxy (gpointer userdata) +{ + DBusGConnection * connection = dbus_g_bus_get(DBUS_BUS_SESSION, NULL); + if (connection == NULL) { + g_warning("Unable to get session bus"); + return FALSE; /* TRUE? */ + } + + icon_proxy = dbus_g_proxy_new_for_name(connection, + INDICATOR_MESSAGES_DBUS_NAME, + INDICATOR_MESSAGES_DBUS_SERVICE_OBJECT, + INDICATOR_MESSAGES_DBUS_SERVICE_INTERFACE); + if (icon_proxy == NULL) { + g_warning("Unable to get messages service interface."); + return FALSE; + } + + return FALSE; +} + GtkLabel * get_label (void) { @@ -51,8 +74,6 @@ get_icon (void) main_image = gtk_image_new_from_icon_name("indicator-messages", DESIGN_TEAM_SIZE); gtk_widget_show(main_image); - /* Need a proxy here to figure out when the icon changes */ - return GTK_IMAGE(main_image); } @@ -76,6 +97,8 @@ get_menu (void) return NULL; } + g_idle_add(setup_icon_proxy, NULL); + return GTK_MENU(dbusmenu_gtkmenu_new(INDICATOR_MESSAGES_DBUS_NAME, INDICATOR_MESSAGES_DBUS_OBJECT)); } -- cgit v1.2.3 From 91fa6c67e8720123c2d81ac8aac0ef5aa4ac97e8 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 26 Aug 2009 10:03:34 -0500 Subject: Setting up signals and callbacks, oh my! Watch for lions. --- src/indicator-messages.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) diff --git a/src/indicator-messages.c b/src/indicator-messages.c index a7628b0..87fd77e 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -31,6 +31,7 @@ INDICATOR_SET_VERSION INDICATOR_SET_NAME("messages") #include "dbus-data.h" +#include "messages-service-client.h" static GtkWidget * main_image = NULL; @@ -39,7 +40,43 @@ static GtkIconSize design_team_size; static DBusGProxy * icon_proxy = NULL; -gboolean +static void +attention_changed_cb (DBusGProxy * proxy, gboolean dot, gpointer userdata) +{ + +} + +static void +icon_changed_cb (DBusGProxy * proxy, gboolean hidden, gpointer userdata) +{ + +} + +static void +watch_cb (DBusGProxy * proxy, GError * error, gpointer userdata) +{ + if (error != NULL) { + g_warning("Watch failed! %s", error->message); + g_error_free(error); + } + return; +} + +static void +attention_cb (DBusGProxy * proxy, gboolean dot, GError * error, gpointer userdata) +{ + + return; +} + +static void +icon_cb (DBusGProxy * proxy, gboolean hidden, GError * error, gpointer userdata) +{ + + return; +} + +static gboolean setup_icon_proxy (gpointer userdata) { DBusGConnection * connection = dbus_g_bus_get(DBUS_BUS_SESSION, NULL); @@ -56,6 +93,23 @@ setup_icon_proxy (gpointer userdata) g_warning("Unable to get messages service interface."); return FALSE; } + + org_ayatana_indicator_messages_service_watch_async(icon_proxy, watch_cb, NULL); + + dbus_g_proxy_connect_signal(icon_proxy, + "AttentionChanged", + G_CALLBACK(attention_changed_cb), + NULL, + NULL); + + dbus_g_proxy_connect_signal(icon_proxy, + "IconChanged", + G_CALLBACK(icon_changed_cb), + NULL, + NULL); + + org_ayatana_indicator_messages_service_attention_requested_async(icon_proxy, attention_cb, NULL); + org_ayatana_indicator_messages_service_icon_shown_async(icon_proxy, icon_cb, NULL); return FALSE; } -- cgit v1.2.3 From 7c407863390dbe97bccad51a52baf3ffc65d213b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 26 Aug 2009 10:13:08 -0500 Subject: Oh, wow, now there's some flesh on these. Let's hide and show icons. --- src/indicator-messages.c | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/src/indicator-messages.c b/src/indicator-messages.c index 87fd77e..ef77c28 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -43,13 +43,23 @@ static DBusGProxy * icon_proxy = NULL; static void attention_changed_cb (DBusGProxy * proxy, gboolean dot, gpointer userdata) { - + if (dot) { + gtk_image_set_from_icon_name(GTK_IMAGE(main_image), "indicator-messages-new", DESIGN_TEAM_SIZE); + } else { + gtk_image_set_from_icon_name(GTK_IMAGE(main_image), "indicator-messages", DESIGN_TEAM_SIZE); + } + return; } static void icon_changed_cb (DBusGProxy * proxy, gboolean hidden, gpointer userdata) { - + if (hidden) { + gtk_widget_hide(main_image); + } else { + gtk_widget_show(main_image); + } + return; } static void @@ -65,15 +75,25 @@ watch_cb (DBusGProxy * proxy, GError * error, gpointer userdata) static void attention_cb (DBusGProxy * proxy, gboolean dot, GError * error, gpointer userdata) { + if (error != NULL) { + g_warning("Unable to get attention status: %s", error->message); + g_error_free(error); + return; + } - return; + return attention_changed_cb(proxy, dot, userdata); } static void icon_cb (DBusGProxy * proxy, gboolean hidden, GError * error, gpointer userdata) { + if (error != NULL) { + g_warning("Unable to get icon visibility: %s", error->message); + g_error_free(error); + return; + } - return; + return icon_changed_cb(proxy, hidden, userdata); } static gboolean -- cgit v1.2.3 From cffb400b0c368f4314f734596c144278dbb2ce53 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 26 Aug 2009 10:15:57 -0500 Subject: Legal crap. --- src/messages-service-dbus.c | 22 ++++++++++++++++++++++ src/messages-service-dbus.h | 22 ++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/src/messages-service-dbus.c b/src/messages-service-dbus.c index 108360b..7b0a0ff 100644 --- a/src/messages-service-dbus.c +++ b/src/messages-service-dbus.c @@ -1,3 +1,25 @@ +/* +An indicator to show information that is in messaging applications +that the user is using. + +Copyright 2009 Canonical Ltd. + +Authors: + Ted Gould + +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 . +*/ + #ifdef HAVE_CONFIG_H #include "config.h" #endif diff --git a/src/messages-service-dbus.h b/src/messages-service-dbus.h index 1075eb4..caf50db 100644 --- a/src/messages-service-dbus.h +++ b/src/messages-service-dbus.h @@ -1,3 +1,25 @@ +/* +An indicator to show information that is in messaging applications +that the user is using. + +Copyright 2009 Canonical Ltd. + +Authors: + Ted Gould + +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 . +*/ + #ifndef __MESSAGE_SERVICE_DBUS_H__ #define __MESSAGE_SERVICE_DBUS_H__ -- cgit v1.2.3 From bd24e02220d5158b1b502771bbba3012848fcef5 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 26 Aug 2009 10:32:07 -0500 Subject: Setting the attention parameter in the dbus interface. --- src/messages-service.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/messages-service.c b/src/messages-service.c index d23e9ee..6b11e8c 100644 --- a/src/messages-service.c +++ b/src/messages-service.c @@ -441,7 +441,7 @@ server_count_changed (AppMenuItem * appitem, guint count, gpointer data) if (count != 0) { g_debug("Setting image to 'new'"); showing_new_icon = TRUE; - /* gtk_image_set_from_icon_name(GTK_IMAGE(main_image), "indicator-messages-new", DESIGN_TEAM_SIZE); */ + message_service_dbus_set_attention(dbus_interface, TRUE); return; } @@ -462,7 +462,7 @@ server_count_changed (AppMenuItem * appitem, guint count, gpointer data) if (!we_have_indicators) { g_debug("Setting image to boring"); showing_new_icon = FALSE; - /* gtk_image_set_from_icon_name(GTK_IMAGE(main_image), "indicator-messages", DESIGN_TEAM_SIZE); */ + message_service_dbus_set_attention(dbus_interface, FALSE); } return; -- cgit v1.2.3 From fe8917650da7a04c0a7ed4a6549597f2f6437101 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 26 Aug 2009 10:35:56 -0500 Subject: Bad name, fixed. --- src/messages-service-dbus.c | 4 ++-- src/messages-service-dbus.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/messages-service-dbus.c b/src/messages-service-dbus.c index 7b0a0ff..d9c0e8d 100644 --- a/src/messages-service-dbus.c +++ b/src/messages-service-dbus.c @@ -160,7 +160,7 @@ _messages_service_server_icon_shown (MessageServiceDbus * self, gboolean * hidde } void -message_server_dbus_set_attention (MessageServiceDbus * self, gboolean attention) +message_service_dbus_set_attention (MessageServiceDbus * self, gboolean attention) { MessageServiceDbusPrivate * priv = MESSAGE_SERVICE_DBUS_GET_PRIVATE(self); /* Do signal */ @@ -172,7 +172,7 @@ message_server_dbus_set_attention (MessageServiceDbus * self, gboolean attention } void -message_server_dbus_set_icon (MessageServiceDbus * self, gboolean hidden) +message_service_dbus_set_icon (MessageServiceDbus * self, gboolean hidden) { MessageServiceDbusPrivate * priv = MESSAGE_SERVICE_DBUS_GET_PRIVATE(self); /* Do signal */ diff --git a/src/messages-service-dbus.h b/src/messages-service-dbus.h index caf50db..7a8574e 100644 --- a/src/messages-service-dbus.h +++ b/src/messages-service-dbus.h @@ -54,8 +54,8 @@ struct _MessageServiceDbus { GType message_service_dbus_get_type (void); MessageServiceDbus * message_service_dbus_new (void); -void message_server_dbus_set_attention (MessageServiceDbus * self, gboolean attention); -void message_server_dbus_set_icon (MessageServiceDbus * self, gboolean hidden); +void message_service_dbus_set_attention (MessageServiceDbus * self, gboolean attention); +void message_service_dbus_set_icon (MessageServiceDbus * self, gboolean hidden); G_END_DECLS -- cgit v1.2.3 From f551d2604b0afbcb682b5836e98e40db074c447c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 26 Aug 2009 10:40:35 -0500 Subject: Forgot to change to Ayatana --- data/indicator-messages.service.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/indicator-messages.service.in b/data/indicator-messages.service.in index 908079a..9ae3960 100644 --- a/data/indicator-messages.service.in +++ b/data/indicator-messages.service.in @@ -1,3 +1,3 @@ [D-BUS Service] -Name=com.ubuntu.indicator.messages +Name=org.ayatana.indicator.messages Exec=@prefix@/bin/indicator-messages-service -- cgit v1.2.3 From 0f990e5a823361e8e428aea77d2db1b7a1cbe8b4 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 26 Aug 2009 10:50:02 -0500 Subject: The documentation clearly states that you don't need these if the client supports introspection. I thought I was being old school by still putting them in. But, THE DOCUMENTATION LIES, you need to add the signals no matter what. --- src/indicator-messages.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/indicator-messages.c b/src/indicator-messages.c index ef77c28..0d2854b 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -116,12 +116,14 @@ setup_icon_proxy (gpointer userdata) org_ayatana_indicator_messages_service_watch_async(icon_proxy, watch_cb, NULL); + dbus_g_proxy_add_signal(icon_proxy, "AttentionChanged", G_TYPE_BOOLEAN, G_TYPE_INVALID); dbus_g_proxy_connect_signal(icon_proxy, "AttentionChanged", G_CALLBACK(attention_changed_cb), NULL, NULL); + dbus_g_proxy_add_signal(icon_proxy, "IconChanged", G_TYPE_BOOLEAN, G_TYPE_INVALID); dbus_g_proxy_connect_signal(icon_proxy, "IconChanged", G_CALLBACK(icon_changed_cb), -- cgit v1.2.3 From 81ad298ac031b8a1d3727f00f19b7d82bef981f8 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 26 Aug 2009 11:14:39 -0500 Subject: Adding in teh ability to count the number of launchers that are visable --- src/launcher-menu-item.c | 13 +++++++++++++ src/launcher-menu-item.h | 1 + src/messages-service.c | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 49 insertions(+) diff --git a/src/launcher-menu-item.c b/src/launcher-menu-item.c index 6c79adb..d9c35a8 100644 --- a/src/launcher-menu-item.c +++ b/src/launcher-menu-item.c @@ -194,3 +194,16 @@ launcher_menu_item_set_eclipsed (LauncherMenuItem * li, gboolean eclipsed) dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(li), "show", eclipsed ? "false" : "true"); return; } + +gboolean +launcher_menu_item_get_eclipsed (LauncherMenuItem * li) +{ + const gchar * show = dbusmenu_menuitem_property_get(DBUSMENU_MENUITEM(li), "show"); + if (show == NULL) { + return FALSE; + } + if (!g_strcmp0(show, "true")) { + return TRUE; + } + return FALSE; +} diff --git a/src/launcher-menu-item.h b/src/launcher-menu-item.h index 2b39073..920194e 100644 --- a/src/launcher-menu-item.h +++ b/src/launcher-menu-item.h @@ -57,6 +57,7 @@ LauncherMenuItem * launcher_menu_item_new (const gchar * desktop_file); const gchar * launcher_menu_item_get_name (LauncherMenuItem * appitem); const gchar * launcher_menu_item_get_desktop (LauncherMenuItem * launchitem); void launcher_menu_item_set_eclipsed (LauncherMenuItem * li, gboolean eclipsed); +gboolean launcher_menu_item_get_eclipsed (LauncherMenuItem * li); G_END_DECLS diff --git a/src/messages-service.c b/src/messages-service.c index 6b11e8c..5632c22 100644 --- a/src/messages-service.c +++ b/src/messages-service.c @@ -60,6 +60,7 @@ static gboolean blacklist_remove (gpointer data); static void blacklist_dir_changed (GFileMonitor * monitor, GFile * file, GFile * other_file, GFileMonitorEvent event_type, gpointer user_data); static void app_dir_changed (GFileMonitor * monitor, GFile * file, GFile * other_file, GFileMonitorEvent event_type, gpointer user_data); static gboolean destroy_launcher (gpointer data); +static void check_hidden (void); /* @@ -167,6 +168,29 @@ launcherList_sort (gconstpointer a, gconstpointer b) return g_strcmp0(pan, pbn); } +static void +launcherList_count_helper (gpointer data, gpointer user_data) +{ + guint * count = (guint *)user_data; + launcherList_t * li = (launcherList_t *)data; + + if (!launcher_menu_item_get_eclipsed(li->menuitem)) { + *count = *count + 1; + } + + return; +} + +static guint +launcherList_count (void) +{ + guint count = 0; + + g_list_foreach(launcherList, launcherList_count_helper, &count); + + return count; +} + /* * Black List */ @@ -263,6 +287,8 @@ blacklist_add (gpointer udata) } } + check_hidden(); + return FALSE; } @@ -312,6 +338,8 @@ blacklist_remove (gpointer data) g_warning("Unable to remove '%s' with value '%s'", definition_file, (gchar *)key); } + check_hidden(); + return FALSE; } @@ -542,6 +570,13 @@ menushell_foreach_cb (DbusmenuMenuitem * data_mi, gpointer data_ms) { return; } +static void +check_hidden (void) +{ + launcherList_count(); + return; +} + static void resort_menu (DbusmenuMenuitem * menushell) { -- cgit v1.2.3 From d9debb0b236b8e1e3e404224d128443c9fb50819 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 26 Aug 2009 11:18:12 -0500 Subject: Putting in the hiding logic --- src/messages-service.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/messages-service.c b/src/messages-service.c index 5632c22..d2f0785 100644 --- a/src/messages-service.c +++ b/src/messages-service.c @@ -573,7 +573,15 @@ menushell_foreach_cb (DbusmenuMenuitem * data_mi, gpointer data_ms) { static void check_hidden (void) { - launcherList_count(); + gboolean hide = FALSE; + if (launcherList_count() == 0) { + /* If we don't have visible launchers we need to look more */ + if (serverList != NULL) { /* Basically if there are zero entries it'll be NULL */ + hide = TRUE; + } + } + + message_service_dbus_set_icon(dbus_interface, hide); return; } -- cgit v1.2.3 From a13c1cb4fad904f91df3b32bad5d49918cab01da Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 26 Aug 2009 11:19:34 -0500 Subject: Checking hidden when servers are added and removed as well. --- src/messages-service.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/messages-service.c b/src/messages-service.c index d2f0785..23721be 100644 --- a/src/messages-service.c +++ b/src/messages-service.c @@ -437,6 +437,7 @@ server_added (IndicateListener * listener, IndicateListenerServer * server, gcha /* Should be prepend ^ */ resort_menu(menushell); + check_hidden(); return; } @@ -539,6 +540,7 @@ server_removed (IndicateListener * listener, IndicateListenerServer * server, gc /* Simulate a server saying zero to recalculate icon */ server_count_changed(NULL, 0, NULL); + check_hidden(); return; } -- cgit v1.2.3 From 7f0a072a9c1f1efc914c132b1e208b05176f7de9 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 26 Aug 2009 12:44:48 -0500 Subject: Some debug messages and checking the list length, but most importantly, got the show/eclipsed logic backwards. --- src/launcher-menu-item.c | 3 ++- src/messages-service.c | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/launcher-menu-item.c b/src/launcher-menu-item.c index d9c35a8..802575f 100644 --- a/src/launcher-menu-item.c +++ b/src/launcher-menu-item.c @@ -202,7 +202,8 @@ launcher_menu_item_get_eclipsed (LauncherMenuItem * li) if (show == NULL) { return FALSE; } - if (!g_strcmp0(show, "true")) { + g_debug("Launcher check eclipse: %s", show); + if (!g_strcmp0(show, "false")) { return TRUE; } return FALSE; diff --git a/src/messages-service.c b/src/messages-service.c index 23721be..a5af895 100644 --- a/src/messages-service.c +++ b/src/messages-service.c @@ -575,10 +575,13 @@ menushell_foreach_cb (DbusmenuMenuitem * data_mi, gpointer data_ms) { static void check_hidden (void) { + g_debug("Checking Hidden..."); gboolean hide = FALSE; if (launcherList_count() == 0) { + g_debug("\tZero Launchers"); /* If we don't have visible launchers we need to look more */ - if (serverList != NULL) { /* Basically if there are zero entries it'll be NULL */ + if (g_list_length(serverList) == 0) { + g_debug("\tZero Applications"); hide = TRUE; } } -- cgit v1.2.3 -- cgit v1.2.3 From 21caab3ed3cbb70ec0f2929dd69d9f348162e975 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 26 Aug 2009 13:32:34 -0500 Subject: Adding a get_description function --- src/launcher-menu-item.c | 10 ++++++++++ src/launcher-menu-item.h | 1 + 2 files changed, 11 insertions(+) diff --git a/src/launcher-menu-item.c b/src/launcher-menu-item.c index 6c79adb..6f005e9 100644 --- a/src/launcher-menu-item.c +++ b/src/launcher-menu-item.c @@ -185,6 +185,16 @@ launcher_menu_item_get_desktop (LauncherMenuItem * launchitem) return priv->desktop; } +/* Gets the decription for the item that should + go in the messaging menu */ +const gchar * +launcher_menu_item_get_description (LauncherMenuItem * li) +{ + g_return_val_if_fail(IS_LAUNCHER_MENU_ITEM(li), NULL); + LauncherMenuItemPrivate * priv = LAUNCHER_MENU_ITEM_GET_PRIVATE(li); + return g_app_info_get_description(priv->appinfo); +} + /* Hides the menu item based on whether it is eclipsed or not. */ void diff --git a/src/launcher-menu-item.h b/src/launcher-menu-item.h index 2b39073..9a46824 100644 --- a/src/launcher-menu-item.h +++ b/src/launcher-menu-item.h @@ -56,6 +56,7 @@ GType launcher_menu_item_get_type (void); LauncherMenuItem * launcher_menu_item_new (const gchar * desktop_file); const gchar * launcher_menu_item_get_name (LauncherMenuItem * appitem); const gchar * launcher_menu_item_get_desktop (LauncherMenuItem * launchitem); +const gchar * launcher_menu_item_get_description (LauncherMenuItem * li); void launcher_menu_item_set_eclipsed (LauncherMenuItem * li, gboolean eclipsed); G_END_DECLS -- cgit v1.2.3 From 8078204a3c807df06e10be50376536ac102b3dd9 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 26 Aug 2009 16:06:20 -0500 Subject: show -> visible --- src/launcher-menu-item.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/launcher-menu-item.c b/src/launcher-menu-item.c index 802575f..100dd67 100644 --- a/src/launcher-menu-item.c +++ b/src/launcher-menu-item.c @@ -191,14 +191,14 @@ void launcher_menu_item_set_eclipsed (LauncherMenuItem * li, gboolean eclipsed) { g_debug("Laucher '%s' is %s", launcher_menu_item_get_name(li), eclipsed ? "now eclipsed" : "shown again"); - dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(li), "show", eclipsed ? "false" : "true"); + dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(li), "visible", eclipsed ? "false" : "true"); return; } gboolean launcher_menu_item_get_eclipsed (LauncherMenuItem * li) { - const gchar * show = dbusmenu_menuitem_property_get(DBUSMENU_MENUITEM(li), "show"); + const gchar * show = dbusmenu_menuitem_property_get(DBUSMENU_MENUITEM(li), "visible"); if (show == NULL) { return FALSE; } -- cgit v1.2.3 From 482016974e086dbd2da6d5b093b4b80322cab4c8 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 26 Aug 2009 16:43:14 -0500 Subject: Locking to version 0.0.2 to use some of the new nicities --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 19a549c..d9962a0 100644 --- a/configure.ac +++ b/configure.ac @@ -28,7 +28,7 @@ GIO_UNIX_REQUIRED_VERSION=2.18 PANEL_REQUIRED_VERSION=2.0.0 INDICATE_REQUIRED_VERSION=0.2.0 INDICATOR_REQUIRED_VERSION=0.2.0 -DBUSMENUGTK_REQUIRED_VERSION=0.0.0 +DBUSMENUGTK_REQUIRED_VERSION=0.0.2 PKG_CHECK_MODULES(APPLET, gtk+-2.0 >= $GTK_REQUIRED_VERSION gio-unix-2.0 >= $GIO_UNIX_REQUIRED_VERSION -- cgit v1.2.3 From 9449d49b38b2dfe2f9a0d90378877a801b6def03 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 26 Aug 2009 16:47:55 -0500 Subject: Replacing the prop strings with defines --- src/app-menu-item.c | 4 ++-- src/im-menu-item.c | 2 +- src/launcher-menu-item.c | 6 +++--- src/messages-service.c | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/app-menu-item.c b/src/app-menu-item.c index 3a2c795..feb780d 100644 --- a/src/app-menu-item.c +++ b/src/app-menu-item.c @@ -218,10 +218,10 @@ update_label (AppMenuItem * self) /* TRANSLATORS: This is the name of the program and the number of indicators. So it would read something like "Mail Client (5)" */ gchar * label = g_strdup_printf(_("%s (%d)"), app_menu_item_get_name(self), priv->unreadcount); - dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), "label", label); + dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), DBUSMENU_MENUITEM_PROP_LABEL, label); g_free(label); } else { - dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), "label", app_menu_item_get_name(self)); + dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), DBUSMENU_MENUITEM_PROP_LABEL, app_menu_item_get_name(self)); } return; diff --git a/src/im-menu-item.c b/src/im-menu-item.c index d35684e..008e33f 100644 --- a/src/im-menu-item.c +++ b/src/im-menu-item.c @@ -253,7 +253,7 @@ sender_cb (IndicateListener * listener, IndicateListenerServer * server, Indicat return; } - dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), "label", propertydata); + dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), DBUSMENU_MENUITEM_PROP_LABEL, propertydata); return; } diff --git a/src/launcher-menu-item.c b/src/launcher-menu-item.c index 100dd67..eb32e59 100644 --- a/src/launcher-menu-item.c +++ b/src/launcher-menu-item.c @@ -130,7 +130,7 @@ launcher_menu_item_new (const gchar * desktop_file) priv->desktop = g_strdup(desktop_file); g_debug("\tName: %s", launcher_menu_item_get_name(self)); - dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), "label", launcher_menu_item_get_name(self)); + dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), DBUSMENU_MENUITEM_PROP_LABEL, launcher_menu_item_get_name(self)); g_signal_connect(G_OBJECT(self), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(activate_cb), NULL); @@ -191,14 +191,14 @@ void launcher_menu_item_set_eclipsed (LauncherMenuItem * li, gboolean eclipsed) { g_debug("Laucher '%s' is %s", launcher_menu_item_get_name(li), eclipsed ? "now eclipsed" : "shown again"); - dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(li), "visible", eclipsed ? "false" : "true"); + dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(li), DBUSMENU_MENUITEM_PROP_VISIBLE, eclipsed ? "false" : "true"); return; } gboolean launcher_menu_item_get_eclipsed (LauncherMenuItem * li) { - const gchar * show = dbusmenu_menuitem_property_get(DBUSMENU_MENUITEM(li), "visible"); + const gchar * show = dbusmenu_menuitem_property_get(DBUSMENU_MENUITEM(li), DBUSMENU_MENUITEM_PROP_VISIBLE); if (show == NULL) { return FALSE; } diff --git a/src/messages-service.c b/src/messages-service.c index a5af895..093ebfd 100644 --- a/src/messages-service.c +++ b/src/messages-service.c @@ -908,7 +908,7 @@ destroy_launcher (gpointer data) g_list_free(li->appdiritems); if (li->menuitem != NULL) { - dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(li->menuitem), "visible", "false"); + dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(li->menuitem), DBUSMENU_MENUITEM_PROP_VISIBLE, "false"); dbusmenu_menuitem_child_delete(root_menuitem, DBUSMENU_MENUITEM(li->menuitem)); g_object_unref(G_OBJECT(li->menuitem)); li->menuitem = NULL; -- cgit v1.2.3 From 983f83536606972bd90e9f95377a8d1ced282720 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 26 Aug 2009 17:27:39 -0500 Subject: Making ourselves a variable in the middle of everything. --- src/indicator-messages.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/indicator-messages.c b/src/indicator-messages.c index 0d2854b..80ab535 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -175,6 +175,8 @@ get_menu (void) g_idle_add(setup_icon_proxy, NULL); - return GTK_MENU(dbusmenu_gtkmenu_new(INDICATOR_MESSAGES_DBUS_NAME, INDICATOR_MESSAGES_DBUS_OBJECT)); + DbusmenuGtkMenu * menu = dbusmenu_gtkmenu_new(INDICATOR_MESSAGES_DBUS_NAME, INDICATOR_MESSAGES_DBUS_OBJECT); + + return GTK_MENU(menu); } -- cgit v1.2.3 From bb8dfce7d1a137eeff3792862b3f9a27416f3836 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 26 Aug 2009 17:29:53 -0500 Subject: Injecting in a type for the launchers. --- src/indicator-messages.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/indicator-messages.c b/src/indicator-messages.c index 80ab535..2aec8e9 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -136,6 +136,13 @@ setup_icon_proxy (gpointer userdata) return FALSE; } +static gboolean +new_launcher_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client) +{ + + return TRUE; +} + GtkLabel * get_label (void) { @@ -176,6 +183,9 @@ get_menu (void) g_idle_add(setup_icon_proxy, NULL); DbusmenuGtkMenu * menu = dbusmenu_gtkmenu_new(INDICATOR_MESSAGES_DBUS_NAME, INDICATOR_MESSAGES_DBUS_OBJECT); + DbusmenuGtkClient * client = dbusmenu_gtkmenu_get_client(menu); + + dbusmenu_client_add_type_handler(DBUSMENU_CLIENT(client), "launcher-item", new_launcher_item); return GTK_MENU(menu); } -- cgit v1.2.3 From 96d5cadae1492a0d4db6e38f606be309e76ab0aa Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 26 Aug 2009 20:06:09 -0500 Subject: Pulling the type and the properties into the shared DBus header. --- src/dbus-data.h | 4 ++++ src/indicator-messages.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/dbus-data.h b/src/dbus-data.h index e7d4d26..db59003 100644 --- a/src/dbus-data.h +++ b/src/dbus-data.h @@ -8,4 +8,8 @@ #define INDICATOR_MESSAGES_DBUS_SERVICE_OBJECT "/org/ayatana/indicator/messages/service" #define INDICATOR_MESSAGES_DBUS_SERVICE_INTERFACE "org.ayatana.indicator.messages.service" +#define LAUNCHER_MENUITEM_TYPE "launcher-item" +#define LAUNCHER_MENUITEM_PROP_APP_NAME "application-name" +#define LAUNCHER_MENUITEM_PROP_APP_DESC "application-description" + #endif /* __DBUS_DATA_H__ */ diff --git a/src/indicator-messages.c b/src/indicator-messages.c index 2aec8e9..8762593 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -185,7 +185,7 @@ get_menu (void) DbusmenuGtkMenu * menu = dbusmenu_gtkmenu_new(INDICATOR_MESSAGES_DBUS_NAME, INDICATOR_MESSAGES_DBUS_OBJECT); DbusmenuGtkClient * client = dbusmenu_gtkmenu_get_client(menu); - dbusmenu_client_add_type_handler(DBUSMENU_CLIENT(client), "launcher-item", new_launcher_item); + dbusmenu_client_add_type_handler(DBUSMENU_CLIENT(client), LAUNCHER_MENUITEM_TYPE, new_launcher_item); return GTK_MENU(menu); } -- cgit v1.2.3 From bab6bd250e02bb8a139ea4ad36fdee2b7b250544 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 26 Aug 2009 20:20:02 -0500 Subject: Filling in the new launcher menu item --- src/indicator-messages.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/indicator-messages.c b/src/indicator-messages.c index 8762593..8838313 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -139,6 +139,22 @@ setup_icon_proxy (gpointer userdata) static gboolean new_launcher_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client) { + GtkMenuItem * gmi = GTK_MENU_ITEM(gtk_menu_item_new()); + + GtkWidget * vbox = gtk_vbox_new(TRUE, 2); + + GtkWidget * app_label = gtk_label_new(dbusmenu_menuitem_property_get(newitem, LAUNCHER_MENUITEM_PROP_APP_NAME)); + GtkWidget * dsc_label = gtk_label_new(dbusmenu_menuitem_property_get(newitem, LAUNCHER_MENUITEM_PROP_APP_DESC)); + + gtk_box_pack_start(GTK_BOX(vbox), app_label, FALSE, FALSE, 0); + gtk_widget_show(app_label); + gtk_box_pack_start(GTK_BOX(vbox), dsc_label, FALSE, FALSE, 0); + gtk_widget_show(dsc_label); + + gtk_container_add(GTK_CONTAINER(gmi), GTK_WIDGET(vbox)); + gtk_widget_show(GTK_WIDGET(vbox)); + + dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, gmi, parent); return TRUE; } -- cgit v1.2.3 From 2273a4d1f95cf44edb1aad21849eda6fca358deb Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 26 Aug 2009 20:24:07 -0500 Subject: Setting the type of the item and app name --- src/launcher-menu-item.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/launcher-menu-item.c b/src/launcher-menu-item.c index eb32e59..9c2dbeb 100644 --- a/src/launcher-menu-item.c +++ b/src/launcher-menu-item.c @@ -28,6 +28,7 @@ with this program. If not, see . #include #include #include "launcher-menu-item.h" +#include "dbus-data.h" enum { NAME_CHANGED, @@ -130,7 +131,9 @@ launcher_menu_item_new (const gchar * desktop_file) priv->desktop = g_strdup(desktop_file); g_debug("\tName: %s", launcher_menu_item_get_name(self)); - dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), DBUSMENU_MENUITEM_PROP_LABEL, launcher_menu_item_get_name(self)); + dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), "type", LAUNCHER_MENUITEM_TYPE); + dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), LAUNCHER_MENUITEM_PROP_APP_NAME, launcher_menu_item_get_name(self)); + // dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), LAUNCHER_MENUITEM_PROP_APP_DESC, launcher_menu_item_get_name(self)); g_signal_connect(G_OBJECT(self), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(activate_cb), NULL); -- cgit v1.2.3 From d08632f2c21df15c8edf292910d63f144bb4a7a3 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 26 Aug 2009 20:26:13 -0500 Subject: Use that handy get_description function that we just merged in. Heh, wonder why we did that... --- src/launcher-menu-item.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/launcher-menu-item.c b/src/launcher-menu-item.c index 07598d7..6678cc5 100644 --- a/src/launcher-menu-item.c +++ b/src/launcher-menu-item.c @@ -133,7 +133,7 @@ launcher_menu_item_new (const gchar * desktop_file) g_debug("\tName: %s", launcher_menu_item_get_name(self)); dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), "type", LAUNCHER_MENUITEM_TYPE); dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), LAUNCHER_MENUITEM_PROP_APP_NAME, launcher_menu_item_get_name(self)); - // dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), LAUNCHER_MENUITEM_PROP_APP_DESC, launcher_menu_item_get_name(self)); + dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), LAUNCHER_MENUITEM_PROP_APP_DESC, launcher_menu_item_get_description(self)); g_signal_connect(G_OBJECT(self), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(activate_cb), NULL); -- cgit v1.2.3 From 1077ceea42e73c4c9ef0f368913f18a9a3b092f8 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 26 Aug 2009 20:46:43 -0500 Subject: Adding a little style to our labels. Hopefully making them look a little nicer. --- src/indicator-messages.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/indicator-messages.c b/src/indicator-messages.c index 8838313..0a1002d 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -21,6 +21,7 @@ with this program. If not, see . */ #include +#include #include #include #include @@ -144,7 +145,13 @@ new_launcher_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbusme GtkWidget * vbox = gtk_vbox_new(TRUE, 2); GtkWidget * app_label = gtk_label_new(dbusmenu_menuitem_property_get(newitem, LAUNCHER_MENUITEM_PROP_APP_NAME)); - GtkWidget * dsc_label = gtk_label_new(dbusmenu_menuitem_property_get(newitem, LAUNCHER_MENUITEM_PROP_APP_DESC)); + gtk_misc_set_alignment(GTK_MISC(app_label), 0.0, 0.5); + GtkWidget * dsc_label = gtk_label_new(""); + gtk_misc_set_alignment(GTK_MISC(dsc_label), 0.05, 0.5); + gtk_label_set_ellipsize(GTK_LABEL(dsc_label), PANGO_ELLIPSIZE_END); + gchar * markup = g_markup_printf_escaped("%s", dbusmenu_menuitem_property_get(newitem, LAUNCHER_MENUITEM_PROP_APP_DESC)); + gtk_label_set_markup(GTK_LABEL(dsc_label), markup); + g_free(markup); gtk_box_pack_start(GTK_BOX(vbox), app_label, FALSE, FALSE, 0); gtk_widget_show(app_label); -- cgit v1.2.3 From 6af9df41572d52b6115980ac2a1a98a74a71f9f1 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 26 Aug 2009 20:53:29 -0500 Subject: This stuff is crashing big time now. Not sure why it worked before, but not going to look into it now. --- src/launcher-menu-item.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/src/launcher-menu-item.c b/src/launcher-menu-item.c index 6678cc5..822196b 100644 --- a/src/launcher-menu-item.c +++ b/src/launcher-menu-item.c @@ -160,23 +160,12 @@ activate_cb (LauncherMenuItem * self, gpointer data) LauncherMenuItemPrivate * priv = LAUNCHER_MENU_ITEM_GET_PRIVATE(self); g_return_if_fail(priv->appinfo != NULL); - /* This should manage the X stuff for us */ - GdkAppLaunchContext * context = gdk_app_launch_context_new(); - - /* Using the current time as we don't have the event - time as that's not sent across the bus */ - GTimeVal time; - g_get_current_time(&time); - gdk_app_launch_context_set_timestamp(context, time.tv_usec / 1000); - GError * error = NULL; - if (!g_app_info_launch(priv->appinfo, NULL, G_APP_LAUNCH_CONTEXT(context), &error)) { + if (!g_app_info_launch(priv->appinfo, NULL, NULL, &error)) { g_warning("Application failed to launch '%s' because: %s", launcher_menu_item_get_name(self), error->message); g_error_free(error); } - g_object_unref(G_OBJECT(context)); - return; } -- cgit v1.2.3 -- cgit v1.2.3 From 86cab293762c8b864a58f3e297c057cc05794daf Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 27 Aug 2009 09:31:43 -0500 Subject: Checking args from libdbusmenu, stealing code from there. Comments by Neil. --- src/indicator-messages.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/indicator-messages.c b/src/indicator-messages.c index 0a1002d..c410ef7 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -140,6 +140,10 @@ setup_icon_proxy (gpointer userdata) static gboolean new_launcher_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client) { + g_return_val_if_fail(DBUSMENU_IS_MENUITEM(newitem), FALSE); + g_return_val_if_fail(DBUSMENU_IS_GTKCLIENT(client), FALSE); + /* Note: not checking parent, it's reasonable for it to be NULL */ + GtkMenuItem * gmi = GTK_MENU_ITEM(gtk_menu_item_new()); GtkWidget * vbox = gtk_vbox_new(TRUE, 2); -- cgit v1.2.3 From 9490242a8ee3f624599668ff3cc77b4c7026ead3 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 27 Aug 2009 10:11:36 -0500 Subject: Changing to version 0.2.0. We need a release sometime. --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index d9962a0..ef2239b 100644 --- a/configure.ac +++ b/configure.ac @@ -4,7 +4,7 @@ AC_INIT(src/indicator-messages.c) AC_PREREQ(2.53) AM_CONFIG_HEADER(config.h) -AM_INIT_AUTOMAKE(indicator-messages, 0.2.0dev) +AM_INIT_AUTOMAKE(indicator-messages, 0.2.0) AM_MAINTAINER_MODE -- cgit v1.2.3 From 48c1827cd615f895720a71bff70e0401f4b52f17 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 27 Aug 2009 13:58:13 -0500 Subject: Updating to dbusmenu 0.1.0 as a versioning snafu got involved. --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index ef2239b..8b9caca 100644 --- a/configure.ac +++ b/configure.ac @@ -28,7 +28,7 @@ GIO_UNIX_REQUIRED_VERSION=2.18 PANEL_REQUIRED_VERSION=2.0.0 INDICATE_REQUIRED_VERSION=0.2.0 INDICATOR_REQUIRED_VERSION=0.2.0 -DBUSMENUGTK_REQUIRED_VERSION=0.0.2 +DBUSMENUGTK_REQUIRED_VERSION=0.1.0 PKG_CHECK_MODULES(APPLET, gtk+-2.0 >= $GTK_REQUIRED_VERSION gio-unix-2.0 >= $GIO_UNIX_REQUIRED_VERSION -- cgit v1.2.3 From 8f44a2f0e4c64839956a4238a4088baa54547ca3 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 3 Sep 2009 14:06:22 -0500 Subject: Upping dbusmenu version --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 8b9caca..a3d937b 100644 --- a/configure.ac +++ b/configure.ac @@ -28,7 +28,7 @@ GIO_UNIX_REQUIRED_VERSION=2.18 PANEL_REQUIRED_VERSION=2.0.0 INDICATE_REQUIRED_VERSION=0.2.0 INDICATOR_REQUIRED_VERSION=0.2.0 -DBUSMENUGTK_REQUIRED_VERSION=0.1.0 +DBUSMENUGTK_REQUIRED_VERSION=0.1.1 PKG_CHECK_MODULES(APPLET, gtk+-2.0 >= $GTK_REQUIRED_VERSION gio-unix-2.0 >= $GIO_UNIX_REQUIRED_VERSION -- cgit v1.2.3 From 77ad7a72d9c7f1996d82cb32ce8f3887c87df6f2 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 3 Sep 2009 14:13:45 -0500 Subject: Using defines for visibility. --- src/messages-service.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/messages-service.c b/src/messages-service.c index 093ebfd..754021b 100644 --- a/src/messages-service.c +++ b/src/messages-service.c @@ -531,7 +531,7 @@ server_removed (IndicateListener * listener, IndicateListenerServer * server, gc serverList = g_list_remove(serverList, sltp); if (sltp->menuitem != NULL) { - dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(sltp->menuitem), "visibile", "false"); + dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(sltp->menuitem), DBUSMENU_MENUITEM_PROP_VISIBLE, "false"); dbusmenu_menuitem_child_delete(DBUSMENU_MENUITEM(data), DBUSMENU_MENUITEM(sltp->menuitem)); g_object_unref(G_OBJECT(sltp->menuitem)); } @@ -776,7 +776,7 @@ indicator_removed (IndicateListener * listener, IndicateListenerServer * server, g_signal_handler_disconnect(menuitem, ilt->timechange_cb); g_free(ilt); - dbusmenu_menuitem_property_set(menuitem, "visibile", "false"); + dbusmenu_menuitem_property_set(menuitem, DBUSMENU_MENUITEM_PROP_VISIBLE, "false"); dbusmenu_menuitem_child_delete(DBUSMENU_MENUITEM(data), menuitem); removed = TRUE; } -- cgit v1.2.3 From 004770625d33b0b106551c90f7e07e109180279f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 3 Sep 2009 14:14:24 -0500 Subject: Using the defines fo dealing with the icons and using the generic image type. We're just passing along the PNGs right now. --- src/im-menu-item.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/im-menu-item.c b/src/im-menu-item.c index 008e33f..242c1c4 100644 --- a/src/im-menu-item.c +++ b/src/im-menu-item.c @@ -147,10 +147,9 @@ im_menu_item_finalize (GObject *object) } static void -icon_cb (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * property, GdkPixbuf * propertydata, gpointer data) +icon_cb (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * property, gchar * propertydata, gpointer data) { - /* dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), "icon", propertydata); */ - + dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), DBUSMENU_MENUITEM_PROP_ICON_DATA, propertydata); return; } @@ -280,7 +279,7 @@ indicator_modified_cb (IndicateListener * listener, IndicateListenerServer * ser } else if (!g_strcmp0(property, "time")) { indicate_listener_get_property_time(listener, server, indicator, "time", time_cb, self); } else if (!g_strcmp0(property, "icon")) { - indicate_listener_get_property_icon(listener, server, indicator, "icon", icon_cb, self); + indicate_listener_get_property(listener, server, indicator, "icon", icon_cb, self); } return; @@ -299,9 +298,11 @@ im_menu_item_new (IndicateListener * listener, IndicateListenerServer * server, priv->show_time = show_time; priv->time_update_min = 0; + dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_CLIENT_TYPES_IMAGE); + indicate_listener_get_property(listener, server, indicator, "sender", sender_cb, self); indicate_listener_get_property_time(listener, server, indicator, "time", time_cb, self); - indicate_listener_get_property_icon(listener, server, indicator, "icon", icon_cb, self); + indicate_listener_get_property(listener, server, indicator, "icon", icon_cb, self); g_signal_connect(G_OBJECT(self), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(activate_cb), NULL); priv->indicator_changed = g_signal_connect(G_OBJECT(listener), INDICATE_LISTENER_SIGNAL_INDICATOR_MODIFIED, G_CALLBACK(indicator_modified_cb), self); -- cgit v1.2.3 From 51e1ef970beb33b529fe339abcfafa1ff99c8a83 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 4 Sep 2009 08:58:43 -0500 Subject: Fixing a header and some defines. --- src/im-menu-item.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/im-menu-item.c b/src/im-menu-item.c index 242c1c4..0b8ef8f 100644 --- a/src/im-menu-item.c +++ b/src/im-menu-item.c @@ -24,6 +24,7 @@ with this program. If not, see . #endif #include +#include #include #include #include "im-menu-item.h" @@ -298,7 +299,7 @@ im_menu_item_new (IndicateListener * listener, IndicateListenerServer * server, priv->show_time = show_time; priv->time_update_min = 0; - dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_CLIENT_TYPES_IMAGE); + dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), "type", DBUSMENU_CLIENT_TYPES_IMAGE); indicate_listener_get_property(listener, server, indicator, "sender", sender_cb, self); indicate_listener_get_property_time(listener, server, indicator, "time", time_cb, self); -- cgit v1.2.3 From a04a5e11668a7068f1307b28911df1097ab983cf Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 4 Sep 2009 09:02:34 -0500 Subject: A variable and a prototype. Such is life. --- src/im-menu-item.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/im-menu-item.c b/src/im-menu-item.c index 0b8ef8f..6f58ebd 100644 --- a/src/im-menu-item.c +++ b/src/im-menu-item.c @@ -74,7 +74,7 @@ static void icon_cb (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * property, - GdkPixbuf * propertydata, + gchar * propertydata, gpointer data); static void activate_cb (ImMenuItem * self, gpointer data); @@ -150,7 +150,7 @@ im_menu_item_finalize (GObject *object) static void icon_cb (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * property, gchar * propertydata, gpointer data) { - dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), DBUSMENU_MENUITEM_PROP_ICON_DATA, propertydata); + dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(data), DBUSMENU_MENUITEM_PROP_ICON_DATA, propertydata); return; } -- cgit v1.2.3