aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.ac4
-rw-r--r--src/app-menu-item.c8
-rw-r--r--src/im-menu-item.c20
-rw-r--r--src/indicator-messages.c54
4 files changed, 55 insertions, 31 deletions
diff --git a/configure.ac b/configure.ac
index 7aabc33..e8cd9be 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.1.4)
+AM_INIT_AUTOMAKE(indicator-messages, 0.1.5)
AM_MAINTAINER_MODE
@@ -24,7 +24,7 @@ AC_CONFIG_MACRO_DIR([m4])
GTK_REQUIRED_VERSION=2.12
GIO_UNIX_REQUIRED_VERSION=2.18
PANEL_REQUIRED_VERSION=2.0.0
-INDICATE_REQUIRED_VERSION=0.1
+INDICATE_REQUIRED_VERSION=0.1.5
PKG_CHECK_MODULES(APPLET, gtk+-2.0 >= $GTK_REQUIRED_VERSION
gio-unix-2.0 >= $GIO_UNIX_REQUIRED_VERSION
diff --git a/src/app-menu-item.c b/src/app-menu-item.c
index 4501f43..4af0c7f 100644
--- a/src/app-menu-item.c
+++ b/src/app-menu-item.c
@@ -160,6 +160,9 @@ app_menu_item_new (IndicateListener * listener, IndicateListenerServer * server)
g_signal_connect(G_OBJECT(self), "activate", G_CALLBACK(activate_cb), NULL);
+ indicate_listener_server_show_interest(listener, server, INDICATE_INTEREST_SERVER_DISPLAY);
+ indicate_listener_server_show_interest(listener, server, INDICATE_INTEREST_SERVER_SIGNAL);
+
return self;
}
@@ -179,6 +182,11 @@ type_cb (IndicateListener * listener, IndicateListenerServer * server, gchar * v
/* For IM and Microblogging we want the individual items, not a count */
priv->count_on_label = TRUE;
update_label(self);
+
+ indicate_listener_server_show_interest(listener, server, INDICATE_INTEREST_INDICATOR_COUNT);
+ } else {
+ indicate_listener_server_show_interest(listener, server, INDICATE_INTEREST_INDICATOR_DISPLAY);
+ indicate_listener_server_show_interest(listener, server, INDICATE_INTEREST_INDICATOR_SIGNAL);
}
return;
diff --git a/src/im-menu-item.c b/src/im-menu-item.c
index 7a139fd..6e3a461 100644
--- a/src/im-menu-item.c
+++ b/src/im-menu-item.c
@@ -44,6 +44,7 @@ struct _ImMenuItemPrivate
glong seconds;
gboolean show_time;
+ gulong indicator_changed;
guint time_update_min;
@@ -171,6 +172,11 @@ im_menu_item_dispose (GObject *object)
if (priv->time_update_min != 0) {
g_source_remove(priv->time_update_min);
}
+
+ g_signal_handler_disconnect(priv->listener, priv->indicator_changed);
+ priv->indicator_changed = 0;
+
+ return;
}
static void
@@ -265,7 +271,7 @@ time_cb (IndicateListener * listener, IndicateListenerServer * server, IndicateL
return;
}
- if (property == NULL || strcmp(property, "time")) {
+ if (property == NULL || g_strcmp0(property, "time")) {
g_warning("Time callback called without being sent the time.");
return;
}
@@ -295,7 +301,7 @@ sender_cb (IndicateListener * listener, IndicateListenerServer * server, Indicat
return;
}
- if (property == NULL || strcmp(property, "sender")) {
+ if (property == NULL || g_strcmp0(property, "sender")) {
g_warning("Sender callback called without being sent the sender. We got '%s' with value '%s'.", property, propertydata);
return;
}
@@ -326,13 +332,13 @@ indicator_modified_cb (IndicateListener * listener, IndicateListenerServer * ser
/* Not meant for us */
if (INDICATE_LISTENER_INDICATOR_ID(indicator) != INDICATE_LISTENER_INDICATOR_ID(priv->indicator)) return;
- if (strcmp(INDICATE_LISTENER_SERVER_DBUS_NAME(server), INDICATE_LISTENER_SERVER_DBUS_NAME(priv->server))) return;
+ if (server != priv->server) return;
- if (!strcmp(property, "sender")) {
+ if (!g_strcmp0(property, "sender")) {
indicate_listener_get_property(listener, server, indicator, "sender", sender_cb, self);
- } else if (!strcmp(property, "time")) {
+ } else if (!g_strcmp0(property, "time")) {
indicate_listener_get_property_time(listener, server, indicator, "time", time_cb, self);
- } else if (!strcmp(property, "icon")) {
+ } else if (!g_strcmp0(property, "icon")) {
indicate_listener_get_property_icon(listener, server, indicator, "icon", icon_cb, self);
}
@@ -358,7 +364,7 @@ im_menu_item_new (IndicateListener * listener, IndicateListenerServer * server,
indicate_listener_get_property_icon(listener, server, indicator, "icon", icon_cb, self);
g_signal_connect(G_OBJECT(self), "activate", G_CALLBACK(activate_cb), NULL);
- g_signal_connect(G_OBJECT(listener), INDICATE_LISTENER_SIGNAL_INDICATOR_MODIFIED, G_CALLBACK(indicator_modified_cb), self);
+ priv->indicator_changed = g_signal_connect(G_OBJECT(listener), INDICATE_LISTENER_SIGNAL_INDICATOR_MODIFIED, G_CALLBACK(indicator_modified_cb), self);
return self;
}
diff --git a/src/indicator-messages.c b/src/indicator-messages.c
index e8fed5b..3df1329 100644
--- a/src/indicator-messages.c
+++ b/src/indicator-messages.c
@@ -36,6 +36,7 @@ static void server_count_changed (AppMenuItem * appitem, guint count, gpointer d
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, GtkMenuShell * menushell);
+static void indicator_removed (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * type, gpointer data);
#define DESIGN_TEAM_SIZE design_team_size
static GtkIconSize design_team_size;
@@ -55,8 +56,8 @@ serverList_equal (gconstpointer a, gconstpointer b)
pa = (serverList_t *)a;
pb = (serverList_t *)b;
- gchar * pas = INDICATE_LISTENER_SERVER_DBUS_NAME(pa->server);
- gchar * pbs = INDICATE_LISTENER_SERVER_DBUS_NAME(pb->server);
+ 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);
}
@@ -80,6 +81,7 @@ struct _imList_t {
IndicateListenerServer * server;
IndicateListenerIndicator * indicator;
GtkWidget * menuitem;
+ gulong timechange_cb;
};
static gboolean
@@ -90,15 +92,15 @@ imList_equal (gconstpointer a, gconstpointer b)
pa = (imList_t *)a;
pb = (imList_t *)b;
- gchar * pas = INDICATE_LISTENER_SERVER_DBUS_NAME(pa->server);
- gchar * pbs = INDICATE_LISTENER_SERVER_DBUS_NAME(pb->server);
+ 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 !((!strcmp(pas, pbs)) && (pai == pbi));
+ return !((!g_strcmp0(pas, pbs)) && (pai == pbi));
}
static gint
@@ -139,7 +141,7 @@ server_added (IndicateListener * listener, IndicateListenerServer * server, gcha
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_new(serverList_t, 1);
+ serverList_t * sl_item = g_new0(serverList_t, 1);
sl_item->server = server;
sl_item->menuitem = menuitem;
sl_item->imList = NULL;
@@ -241,6 +243,12 @@ server_removed (IndicateListener * listener, IndicateListenerServer * server, gc
}
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) {
@@ -280,7 +288,7 @@ menushell_foreach_cb (GtkWidget * data_mi, gpointer data_ms) {
}
AppMenuItem * appmenu = APP_MENU_ITEM(data_mi);
- if (!g_strcmp0(INDICATE_LISTENER_SERVER_DBUS_NAME(msl->server), INDICATE_LISTENER_SERVER_DBUS_NAME(app_menu_item_get_server(appmenu)))) {
+ 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;
}
@@ -327,7 +335,7 @@ subtype_cb (IndicateListener * listener, IndicateListenerServer * server, Indica
return;
}
- if (property == NULL || strcmp(property, "subtype")) {
+ 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;
@@ -342,13 +350,13 @@ subtype_cb (IndicateListener * listener, IndicateListenerServer * server, Indica
g_debug("Message subtype: %s", propertydata);
- if (!strcmp(propertydata, "im") || !strcmp(propertydata, "login")) {
- imList_t * listItem = g_new(imList_t, 1);
+ 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, !strcmp(propertydata, "im"));
+ ImMenuItem * menuitem = im_menu_item_new(listener, server, indicator, !g_strcmp0(propertydata, "im"));
g_object_ref(G_OBJECT(menuitem));
listItem->menuitem = GTK_WIDGET(menuitem);
@@ -361,7 +369,7 @@ subtype_cb (IndicateListener * listener, IndicateListenerServer * server, Indica
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_new(serverList_t, 1);
+ serverList_t * sl_item = g_new0(serverList_t, 1);
sl_item->server = server;
sl_item->menuitem = NULL;
sl_item->imList = NULL;
@@ -373,7 +381,7 @@ subtype_cb (IndicateListener * listener, IndicateListenerServer * server, Indica
g_debug("Adding to IM List");
sl_item->imList = g_list_insert_sorted(sl_item->imList, listItem, imList_sort);
- g_signal_connect(G_OBJECT(menuitem), IM_MENU_ITEM_SIGNAL_TIME_CHANGED, G_CALLBACK(im_time_changed), sl_item);
+ 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;
@@ -396,7 +404,7 @@ subtype_cb (IndicateListener * listener, IndicateListenerServer * server, Indica
static void
indicator_added (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * type, gpointer data)
{
- if (type == NULL || strcmp(type, "message")) {
+ 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);
@@ -411,8 +419,8 @@ indicator_added (IndicateListener * listener, IndicateListenerServer * server, I
static void
indicator_removed (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * type, gpointer data)
{
- g_debug("Removing %s %d", (gchar*)server, (guint)indicator);
- if (type == NULL || strcmp(type, "message")) {
+ 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);
@@ -437,23 +445,24 @@ indicator_removed (IndicateListener * listener, IndicateListenerServer * server,
GList * listItem = g_list_find_custom(sl_item->imList, &listData, imList_equal);
GtkWidget * menuitem = NULL;
+ imList_t * ilt = NULL;
if (listItem != NULL) {
- menuitem = ((imList_t *)listItem->data)->menuitem;
+ ilt = (imList_t *)listItem->data;
+ menuitem = ilt->menuitem;
}
if (!removed && menuitem != NULL) {
- g_object_ref(menuitem);
- sl_item->imList = g_list_remove(sl_item->imList, listItem->data);
+ sl_item->imList = g_list_remove(sl_item->imList, ilt);
+ g_signal_handler_disconnect(menuitem, ilt->timechange_cb);
+ g_free(ilt);
gtk_widget_hide(menuitem);
gtk_container_remove(GTK_CONTAINER(data), menuitem);
-
- g_object_unref(menuitem);
removed = TRUE;
}
if (!removed) {
- g_warning("We were asked to remove %s %d but we didn't.", (gchar*)server, (guint)indicator);
+ 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;
@@ -468,6 +477,7 @@ get_menu_item (void)
serverList = NULL;
main_menu = gtk_menu_item_new();
+ gtk_widget_set_name(main_menu, "fast-user-switch-menuitem");
main_image = gtk_image_new_from_icon_name("indicator-messages", DESIGN_TEAM_SIZE);
gtk_widget_show(main_image);