aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/dbus-data.h9
-rw-r--r--src/im-menu-item.c212
-rw-r--r--src/im-menu-item.h6
-rw-r--r--src/indicator-messages.c54
-rw-r--r--src/messages-service.c130
5 files changed, 306 insertions, 105 deletions
diff --git a/src/dbus-data.h b/src/dbus-data.h
index db59003..5ea4046 100644
--- a/src/dbus-data.h
+++ b/src/dbus-data.h
@@ -12,4 +12,13 @@
#define LAUNCHER_MENUITEM_PROP_APP_NAME "application-name"
#define LAUNCHER_MENUITEM_PROP_APP_DESC "application-description"
+#define APPLICATION_MENUITEM_TYPE "application-item"
+#define APPLICATION_MENUITEM_PROP_NAME "app-name"
+#define APPLICATION_MENUITEM_PROP_COUNT "app-count"
+
+#define INDICATOR_MENUITEM_TYPE "indicator-item"
+#define INDICATOR_MENUITEM_PROP_LABEL "indicator-label"
+#define INDICATOR_MENUITEM_PROP_ICON "indicator-icon"
+#define INDICATOR_MENUITEM_PROP_RIGHT "right-side-text"
+
#endif /* __DBUS_DATA_H__ */
diff --git a/src/im-menu-item.c b/src/im-menu-item.c
index 6f58ebd..52cf80c 100644
--- a/src/im-menu-item.c
+++ b/src/im-menu-item.c
@@ -25,12 +25,15 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#include <glib/gi18n.h>
#include <libdbusmenu-glib/client.h>
-#include <libindicate-gtk/indicator.h>
-#include <libindicate-gtk/listener.h>
+#include <libindicate/indicator.h>
+#include <libindicate/indicator-messages.h>
+#include <libindicate/listener.h>
#include "im-menu-item.h"
+#include "dbus-data.h"
enum {
TIME_CHANGED,
+ ATTENTION_CHANGED,
LAST_SIGNAL
};
@@ -45,8 +48,10 @@ struct _ImMenuItemPrivate
IndicateListenerIndicator * indicator;
glong seconds;
- gboolean show_time;
+ gchar * count;
gulong indicator_changed;
+ gboolean attention;
+ gboolean show;
guint time_update_min;
};
@@ -81,7 +86,6 @@ static void activate_cb (ImMenuItem * self,
static void indicator_modified_cb (IndicateListener * listener,
IndicateListenerServer * server,
IndicateListenerIndicator * indicator,
- gchar * type,
gchar * property,
ImMenuItem * self);
@@ -104,6 +108,13 @@ im_menu_item_class_init (ImMenuItemClass *klass)
NULL, NULL,
g_cclosure_marshal_VOID__LONG,
G_TYPE_NONE, 1, G_TYPE_LONG);
+ signals[ATTENTION_CHANGED] = g_signal_new(IM_MENU_ITEM_SIGNAL_ATTENTION_CHANGED,
+ G_TYPE_FROM_CLASS(klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (ImMenuItemClass, attention_changed),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__BOOLEAN,
+ G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
return;
}
@@ -147,20 +158,25 @@ im_menu_item_finalize (GObject *object)
G_OBJECT_CLASS (im_menu_item_parent_class)->finalize (object);
}
+/* Call back for getting icon data. It just passes it along
+ to the indicator so that it can visualize it. Not our problem. */
static void
icon_cb (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * property, gchar * propertydata, gpointer data)
{
- dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(data), DBUSMENU_MENUITEM_PROP_ICON_DATA, propertydata);
+ dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(data), INDICATOR_MENUITEM_PROP_ICON, propertydata);
return;
}
+/* This function takes the time and turns it into the appropriate
+ string to put on the right side of the menu item. Of course it
+ doesn't do that if there is a count set. If there's a count then
+ it gets that space. */
static void
update_time (ImMenuItem * self)
{
ImMenuItemPrivate * priv = IM_MENU_ITEM_GET_PRIVATE(self);
- if (!priv->show_time) {
- dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), "right-column", "");
+ if (priv->count != NULL) {
return;
}
@@ -191,13 +207,15 @@ update_time (ImMenuItem * self)
}
if (timestring != NULL) {
- dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), "right-column", "");
+ dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), INDICATOR_MENUITEM_PROP_RIGHT, timestring);
g_free(timestring);
}
return;
}
+/* This is a wrapper around update_time that matches the prototype
+ needed to make this a timer callback. Silly. */
static gboolean
time_update_cb (gpointer data)
{
@@ -208,6 +226,10 @@ time_update_cb (gpointer data)
return TRUE;
}
+/* Yet another time function. This one takes the time as formated as
+ we get it from libindicate and turns it into the seconds that we're
+ looking for. It should only be called once at the init with a new
+ indicator and again when the value changes. */
static void
time_cb (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * property, GTimeVal * propertydata, gpointer data)
{
@@ -238,26 +260,106 @@ time_cb (IndicateListener * listener, IndicateListenerServer * server, IndicateL
return;
}
+/* Callback from libindicate that is for getting the sender information
+ on a particular indicator. */
static void
sender_cb (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * property, gchar * propertydata, gpointer data)
{
g_debug("Got Sender Information");
ImMenuItem * self = IM_MENU_ITEM(data);
- if (self == NULL) {
- g_error("Menu Item callback called without a menu item");
+
+ /* Our data should be right */
+ g_return_if_fail(self != NULL);
+ /* We should have a property name */
+ g_return_if_fail(property != NULL);
+ /* The Property should be sender or name */
+ g_return_if_fail(!g_strcmp0(property, "sender") || !g_strcmp0(property, INDICATE_INDICATOR_MESSAGES_PROP_NAME));
+
+ /* We might get the sender variable returning a
+ null string as it doesn't exist on newer clients
+ but we don't want to listen to that. */
+ if (!g_strcmp0(property, "sender") && property[0] == '\0') {
return;
}
- 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);
+ dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), INDICATOR_MENUITEM_PROP_LABEL, propertydata);
+
+ return;
+}
+
+/* Callback saying that the count is updated, we need to either put
+ that on the menu item or just remove it if the count is gone. If
+ that's the case we can update time. */
+static void
+count_cb (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * property, gchar * propertydata, gpointer data)
+{
+ g_debug("Got Count Information");
+ ImMenuItem * self = IM_MENU_ITEM(data);
+
+ /* Our data should be right */
+ g_return_if_fail(self != NULL);
+ /* We should have a property name */
+ g_return_if_fail(property != NULL);
+ /* The Property should be count */
+ g_return_if_fail(!g_strcmp0(property, INDICATE_INDICATOR_MESSAGES_PROP_COUNT));
+
+ ImMenuItemPrivate * priv = IM_MENU_ITEM_GET_PRIVATE(self);
+
+ if (propertydata == NULL || propertydata[0] == '\0') {
+ /* The count is either being unset or it was never
+ set in the first place. */
+ if (priv->count != NULL) {
+ g_free(priv->count);
+ priv->count = NULL;
+ update_time(self);
+ }
return;
}
- dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), DBUSMENU_MENUITEM_PROP_LABEL, propertydata);
+ if (priv->count != NULL) {
+ g_free(priv->count);
+ }
+
+ priv->count = g_strdup_printf("(%s)", propertydata);
+ dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), INDICATOR_MENUITEM_PROP_RIGHT, priv->count);
return;
}
+/* This is getting the attention variable that's looking at whether
+ this indicator should be calling for attention or not. If we are,
+ we need to signal that. */
+static void
+attention_cb (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * property, gchar * propertydata, gpointer data)
+{
+ g_debug("Got Attention Information");
+ ImMenuItem * self = IM_MENU_ITEM(data);
+
+ /* Our data should be right */
+ g_return_if_fail(self != NULL);
+ /* We should have a property name */
+ g_return_if_fail(property != NULL);
+ /* The Property should be count */
+ g_return_if_fail(!g_strcmp0(property, INDICATE_INDICATOR_MESSAGES_PROP_ATTENTION));
+
+ ImMenuItemPrivate * priv = IM_MENU_ITEM_GET_PRIVATE(self);
+
+ gboolean wantit;
+ if (propertydata == NULL || propertydata[0] == '\0' || !g_strcmp0(propertydata, "false")) {
+ wantit = FALSE;
+ } else {
+ wantit = TRUE;
+ }
+
+ if (priv->attention != wantit) {
+ priv->attention = wantit;
+ g_signal_emit(G_OBJECT(self), signals[ATTENTION_CHANGED], 0, wantit, TRUE);
+ }
+
+ return;
+}
+
+/* Callback when the item gets clicked on from the Messaging Menu */
static void
activate_cb (ImMenuItem * self, gpointer data)
{
@@ -266,8 +368,10 @@ activate_cb (ImMenuItem * self, gpointer data)
indicate_listener_display(priv->listener, priv->server, priv->indicator);
}
+/* Callback when a property gets modified. It figures out which one
+ got modified and notifies the appropriate person. */
void
-indicator_modified_cb (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * type, gchar * property, ImMenuItem * self)
+indicator_modified_cb (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * property, ImMenuItem * self)
{
ImMenuItemPrivate * priv = IM_MENU_ITEM_GET_PRIVATE(self);
@@ -275,19 +379,29 @@ indicator_modified_cb (IndicateListener * listener, IndicateListenerServer * ser
if (INDICATE_LISTENER_INDICATOR_ID(indicator) != INDICATE_LISTENER_INDICATOR_ID(priv->indicator)) return;
if (server != priv->server) return;
- if (!g_strcmp0(property, "sender")) {
+ /* Determine which property has been changed and request the
+ value go to the appropriate callback. */
+ if (!g_strcmp0(property, INDICATE_INDICATOR_MESSAGES_PROP_NAME)) {
+ indicate_listener_get_property(listener, server, indicator, INDICATE_INDICATOR_MESSAGES_PROP_NAME, sender_cb, self);
+ } else if (!g_strcmp0(property, INDICATE_INDICATOR_MESSAGES_PROP_TIME)) {
+ indicate_listener_get_property_time(listener, server, indicator, INDICATE_INDICATOR_MESSAGES_PROP_TIME, time_cb, self);
+ } else if (!g_strcmp0(property, INDICATE_INDICATOR_MESSAGES_PROP_ICON)) {
+ indicate_listener_get_property(listener, server, indicator, INDICATE_INDICATOR_MESSAGES_PROP_ICON, icon_cb, self);
+ } else if (!g_strcmp0(property, INDICATE_INDICATOR_MESSAGES_PROP_COUNT)) {
+ indicate_listener_get_property(listener, server, indicator, INDICATE_INDICATOR_MESSAGES_PROP_COUNT, count_cb, self);
+ } else if (!g_strcmp0(property, INDICATE_INDICATOR_MESSAGES_PROP_ATTENTION)) {
+ indicate_listener_get_property(listener, server, indicator, INDICATE_INDICATOR_MESSAGES_PROP_ATTENTION, attention_cb, self);
+ } else if (!g_strcmp0(property, "sender")) {
+ /* This is a compatibility string with v1 and should be removed */
+ g_debug("Indicator is using 'sender' property which is a v1 string.");
indicate_listener_get_property(listener, server, indicator, "sender", sender_cb, self);
- } 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(listener, server, indicator, "icon", icon_cb, self);
}
return;
}
ImMenuItem *
-im_menu_item_new (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gboolean show_time)
+im_menu_item_new (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator)
{
ImMenuItem * self = g_object_new(IM_MENU_ITEM_TYPE, NULL);
@@ -296,14 +410,21 @@ im_menu_item_new (IndicateListener * listener, IndicateListenerServer * server,
priv->listener = listener;
priv->server = server;
priv->indicator = indicator;
- priv->show_time = show_time;
+ priv->count = NULL;
priv->time_update_min = 0;
+ priv->attention = FALSE;
+ priv->show = TRUE;
- dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), "type", DBUSMENU_CLIENT_TYPES_IMAGE);
+ dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), "type", INDICATOR_MENUITEM_TYPE);
+ indicate_listener_displayed(listener, server, indicator, TRUE);
+
+ indicate_listener_get_property(listener, server, indicator, INDICATE_INDICATOR_MESSAGES_PROP_NAME, sender_cb, self);
+ indicate_listener_get_property_time(listener, server, indicator, INDICATE_INDICATOR_MESSAGES_PROP_TIME, time_cb, self);
+ indicate_listener_get_property(listener, server, indicator, INDICATE_INDICATOR_MESSAGES_PROP_ICON, icon_cb, self);
+ indicate_listener_get_property(listener, server, indicator, INDICATE_INDICATOR_MESSAGES_PROP_COUNT, count_cb, self);
+ indicate_listener_get_property(listener, server, indicator, INDICATE_INDICATOR_MESSAGES_PROP_ATTENTION, attention_cb, self);
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(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);
@@ -311,9 +432,52 @@ im_menu_item_new (IndicateListener * listener, IndicateListenerServer * server,
return self;
}
+/* Gets the number of seconds for the creator
+ of this item. */
glong
im_menu_item_get_seconds (ImMenuItem * menuitem)
{
+ g_return_val_if_fail(IS_IM_MENU_ITEM(menuitem), 0);
+
ImMenuItemPrivate * priv = IM_MENU_ITEM_GET_PRIVATE(menuitem);
return priv->seconds;
}
+
+/* Gets whether or not this indicator item is
+ asking for attention or not. */
+gboolean
+im_menu_item_get_attention (ImMenuItem * menuitem)
+{
+ g_return_val_if_fail(IS_IM_MENU_ITEM(menuitem), FALSE);
+
+ ImMenuItemPrivate * priv = IM_MENU_ITEM_GET_PRIVATE(menuitem);
+ return priv->attention;
+}
+
+/* This takes care of items that need to be hidden, this is
+ usually because they go over the count of allowed indicators.
+ Which is more than a little bit silly. We shouldn't do that.
+ But we need to enforce it to save users against bad apps. */
+void
+im_menu_item_show (ImMenuItem * menuitem, gboolean show)
+{
+ g_return_if_fail(IS_IM_MENU_ITEM(menuitem));
+
+ ImMenuItemPrivate * priv = IM_MENU_ITEM_GET_PRIVATE(menuitem);
+
+ if (priv->show == show) {
+ return;
+ }
+
+ priv->show = show;
+ /* Tell the app what we're doing to it. If it's being
+ punished it needs to know about it. */
+ indicate_listener_displayed(priv->listener, priv->server, priv->indicator, priv->show);
+ if (priv->attention) {
+ /* If we were asking for attention we can ask for it
+ again if we're being shown, otherwise no. */
+ g_signal_emit(G_OBJECT(menuitem), signals[ATTENTION_CHANGED], 0, priv->show, TRUE);
+ }
+
+ return;
+}
diff --git a/src/im-menu-item.h b/src/im-menu-item.h
index 51414de..244c32a 100644
--- a/src/im-menu-item.h
+++ b/src/im-menu-item.h
@@ -38,6 +38,7 @@ G_BEGIN_DECLS
#define IM_MENU_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), IM_MENU_ITEM_TYPE, ImMenuItemClass))
#define IM_MENU_ITEM_SIGNAL_TIME_CHANGED "time-changed"
+#define IM_MENU_ITEM_SIGNAL_ATTENTION_CHANGED "attention-changed"
typedef struct _ImMenuItem ImMenuItem;
typedef struct _ImMenuItemClass ImMenuItemClass;
@@ -46,6 +47,7 @@ struct _ImMenuItemClass {
DbusmenuMenuitemClass parent_class;
void (*time_changed) (glong seconds);
+ void (*attention_changed) (gboolean requestit);
};
struct _ImMenuItem {
@@ -53,8 +55,10 @@ struct _ImMenuItem {
};
GType im_menu_item_get_type (void);
-ImMenuItem * im_menu_item_new (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gboolean show_time);
+ImMenuItem * im_menu_item_new (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator);
glong im_menu_item_get_seconds (ImMenuItem * menuitem);
+gboolean im_menu_item_get_attention (ImMenuItem * menuitem);
+void im_menu_item_show (ImMenuItem * menuitem, gboolean show);
G_END_DECLS
diff --git a/src/indicator-messages.c b/src/indicator-messages.c
index c410ef7..42f2707 100644
--- a/src/indicator-messages.c
+++ b/src/indicator-messages.c
@@ -24,6 +24,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#include <glib.h>
#include <gtk/gtk.h>
#include <libdbusmenu-gtk/menu.h>
+#include <libdbusmenu-gtk/menuitem.h>
#include <dbus/dbus-glib.h>
#include <dbus/dbus-glib-bindings.h>
@@ -41,6 +42,8 @@ static GtkIconSize design_team_size;
static DBusGProxy * icon_proxy = NULL;
+static GtkSizeGroup * indicator_right_group = NULL;
+
static void
attention_changed_cb (DBusGProxy * proxy, gboolean dot, gpointer userdata)
{
@@ -137,6 +140,54 @@ setup_icon_proxy (gpointer userdata)
return FALSE;
}
+/* We have a small little menuitem type that handles all
+ of the fun stuff for indicators. Mostly this is the
+ shifting over and putting the icon in with some right
+ side text that'll be determined by the service. */
+static gboolean
+new_indicator_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 * hbox = gtk_hbox_new(FALSE, 4);
+
+ /* Icon, probably someone's face or avatar on an IM */
+ GtkWidget * icon = gtk_image_new();
+ GdkPixbuf * pixbuf = dbusmenu_menuitem_property_get_image(newitem, INDICATOR_MENUITEM_PROP_ICON);
+ if (pixbuf != NULL) {
+ gtk_image_set_from_pixbuf(GTK_IMAGE(icon), pixbuf);
+ }
+ gtk_misc_set_alignment(GTK_MISC(icon), 0.0, 0.5);
+ gtk_box_pack_start(GTK_BOX(hbox), icon, FALSE, FALSE, 0);
+ gtk_widget_show(icon);
+
+ /* Label, probably a username, chat room or mailbox name */
+ GtkWidget * label = gtk_label_new(dbusmenu_menuitem_property_get(newitem, INDICATOR_MENUITEM_PROP_LABEL));
+ gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
+ gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 0);
+ gtk_widget_show(label);
+
+ /* Usually either the time or the count on the individual
+ item. */
+ GtkWidget * right = gtk_label_new(dbusmenu_menuitem_property_get(newitem, INDICATOR_MENUITEM_PROP_RIGHT));
+ gtk_size_group_add_widget(indicator_right_group, right);
+ gtk_misc_set_alignment(GTK_MISC(right), 1.0, 0.5);
+ gtk_box_pack_start(GTK_BOX(hbox), right, FALSE, FALSE, 0);
+ gtk_widget_show(right);
+
+ gtk_container_add(GTK_CONTAINER(gmi), hbox);
+ gtk_widget_show(hbox);
+
+ dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, gmi, parent);
+ /* TODO: Handle changes */
+
+ return TRUE;
+}
+
static gboolean
new_launcher_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client)
{
@@ -207,12 +258,15 @@ get_menu (void)
return NULL;
}
+ indicator_right_group = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
+
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_MENUITEM_TYPE, new_launcher_item);
+ dbusmenu_client_add_type_handler(DBUSMENU_CLIENT(client), INDICATOR_MENUITEM_TYPE, new_indicator_item);
return GTK_MENU(menu);
}
diff --git a/src/messages-service.c b/src/messages-service.c
index 754021b..c59edc2 100644
--- a/src/messages-service.c
+++ b/src/messages-service.c
@@ -49,7 +49,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 resort_menu (DbusmenuMenuitem * menushell);
-static void indicator_removed (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * type, gpointer data);
+static void indicator_removed (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gpointer data);
static void check_eclipses (AppMenuItem * ai);
static void remove_eclipses (AppMenuItem * ai);
static gboolean build_launcher (gpointer data);
@@ -525,7 +525,7 @@ server_removed (IndicateListener * listener, IndicateListenerServer * server, gc
while (sltp->imList) {
imList_t * imitem = (imList_t *)sltp->imList->data;
- indicator_removed(listener, server, imitem->indicator, "message", data);
+ indicator_removed(listener, server, imitem->indicator, data);
}
serverList = g_list_remove(serverList, sltp);
@@ -646,8 +646,11 @@ resort_menu (DbusmenuMenuitem * menushell)
return;
}
+/* Responding to a new indicator showing up on the bus. We
+ need to create a menuitem for it and start populating the
+ internal structures to track it. */
static void
-subtype_cb (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * property, gchar * propertydata, gpointer data)
+indicator_added (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gpointer data)
{
DbusmenuMenuitem * menushell = DBUSMENU_MENUITEM(data);
if (menushell == NULL) {
@@ -655,97 +658,64 @@ subtype_cb (IndicateListener * listener, IndicateListenerServer * server, Indica
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;
- }
+ imList_t * listItem = g_new0(imList_t, 1);
+ listItem->server = server;
+ listItem->indicator = indicator;
- 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;
- }
+ /* Building the IM Menu Item which is a subclass
+ of DBus Menuitem */
+ ImMenuItem * menuitem = im_menu_item_new(listener, server, indicator);
+ g_object_ref(G_OBJECT(menuitem));
+ listItem->menuitem = DBUSMENU_MENUITEM(menuitem);
- 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);
+ /* Looking for a server entry to attach this indicator
+ to. If we can't find one then we have to build one
+ and attach the indicator to it. */
+ 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);
- g_debug("Placing in Shell");
- menushell_location_t msl;
- msl.found = FALSE;
- msl.position = 0;
- msl.server = server;
+ 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;
- 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));
- }
+ serverList = g_list_insert_sorted(serverList, sl_item, serverList_sort);
+ } else {
+ sl_item = (serverList_t *)serverentry->data;
}
- 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;
+ /* Added a this entry into the 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);
+
+ /* Placing the item into the shell. Look to see if
+ we can find our server and slip in there. Otherwise
+ we'll just append. */
+ 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));
}
- 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)
+indicator_removed (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, 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;