aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Gould <ted@canonical.com>2009-09-04 15:28:55 -0500
committerTed Gould <ted@canonical.com>2009-09-04 15:28:55 -0500
commit31a318bf3f316ef4873dc8b109e62248a226be43 (patch)
treed99f8b58b6cff426b994a3d7f064f44e953bca16
parent7f0f735b408ad87ee70764485001d07806280673 (diff)
downloadayatana-indicator-messages-31a318bf3f316ef4873dc8b109e62248a226be43.tar.gz
ayatana-indicator-messages-31a318bf3f316ef4873dc8b109e62248a226be43.tar.bz2
ayatana-indicator-messages-31a318bf3f316ef4873dc8b109e62248a226be43.zip
Fleshing out the indicator item. It's purdy.
-rw-r--r--src/indicator-messages.c54
1 files changed, 54 insertions, 0 deletions
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);
}