From 568d4c63169b2c7f42e77ae5b865cc187a83b062 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Mar 2010 22:58:18 -0500 Subject: Putting padding between the items to make them pretty like. --- src/indicator-messages.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/indicator-messages.c') diff --git a/src/indicator-messages.c b/src/indicator-messages.c index 3f533a5..09c2740 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -278,7 +278,10 @@ new_indicator_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbusm GtkMenuItem * gmi = GTK_MENU_ITEM(gtk_menu_item_new()); - GtkWidget * hbox = gtk_hbox_new(FALSE, 4); + gint padding = 4; + gtk_widget_style_get(GTK_WIDGET(gmi), "horizontal-padding", &padding, NULL); + + GtkWidget * hbox = gtk_hbox_new(FALSE, 0); /* Icon, probably someone's face or avatar on an IM */ mi_data->icon = gtk_image_new(); @@ -309,13 +312,13 @@ new_indicator_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbusm } } gtk_misc_set_alignment(GTK_MISC(mi_data->icon), 0.0, 0.5); - gtk_box_pack_start(GTK_BOX(hbox), mi_data->icon, FALSE, FALSE, 0); + gtk_box_pack_start(GTK_BOX(hbox), mi_data->icon, FALSE, FALSE, padding); gtk_widget_show(mi_data->icon); /* Label, probably a username, chat room or mailbox name */ mi_data->label = gtk_label_new(dbusmenu_menuitem_property_get(newitem, INDICATOR_MENUITEM_PROP_LABEL)); gtk_misc_set_alignment(GTK_MISC(mi_data->label), 0.0, 0.5); - gtk_box_pack_start(GTK_BOX(hbox), mi_data->label, TRUE, TRUE, 0); + gtk_box_pack_start(GTK_BOX(hbox), mi_data->label, TRUE, TRUE, padding); gtk_widget_show(mi_data->label); /* Usually either the time or the count on the individual @@ -323,7 +326,7 @@ new_indicator_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbusm mi_data->right = gtk_label_new(dbusmenu_menuitem_property_get(newitem, INDICATOR_MENUITEM_PROP_RIGHT)); gtk_size_group_add_widget(indicator_right_group, mi_data->right); gtk_misc_set_alignment(GTK_MISC(mi_data->right), 1.0, 0.5); - gtk_box_pack_start(GTK_BOX(hbox), mi_data->right, FALSE, FALSE, 0); + gtk_box_pack_start(GTK_BOX(hbox), mi_data->right, FALSE, FALSE, padding); gtk_widget_show(mi_data->right); gtk_container_add(GTK_CONTAINER(gmi), hbox); -- cgit v1.2.3 From a9b385e38e95268ac13666b32f114e7651caf776 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Mar 2010 23:01:10 -0500 Subject: Setting the minimum allocation for the image to be the menu icon size even if there isn't any pixmap. --- src/indicator-messages.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/indicator-messages.c') diff --git a/src/indicator-messages.c b/src/indicator-messages.c index 09c2740..70304f4 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -285,13 +285,17 @@ new_indicator_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbusm /* Icon, probably someone's face or avatar on an IM */ mi_data->icon = gtk_image_new(); + + /* Set the minimum size, we always want it to take space */ + gint width, height; + gtk_icon_size_lookup(GTK_ICON_SIZE_MENU, &width, &height); + gtk_widget_set_size_request(mi_data->icon, width, height); + GdkPixbuf * pixbuf = dbusmenu_menuitem_property_get_image(newitem, INDICATOR_MENUITEM_PROP_ICON); if (pixbuf != NULL) { /* If we've got a pixbuf we need to make sure it's of a reasonable size to fit in the menu. If not, rescale it. */ GdkPixbuf * resized_pixbuf; - gint width, height; - gtk_icon_size_lookup(GTK_ICON_SIZE_MENU, &width, &height); if (gdk_pixbuf_get_width(pixbuf) > width || gdk_pixbuf_get_height(pixbuf) > height) { g_debug("Resizing icon from %dx%d to %dx%d", gdk_pixbuf_get_width(pixbuf), gdk_pixbuf_get_height(pixbuf), width, height); -- cgit v1.2.3 From d4ed651dbaa582e9859ace5a5e69a63b2cffbcf6 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Mar 2010 23:28:10 -0500 Subject: Switch to using the image helper and drop design team size --- src/indicator-messages.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'src/indicator-messages.c') diff --git a/src/indicator-messages.c b/src/indicator-messages.c index 3f533a5..110875a 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -31,6 +31,7 @@ with this program. If not, see . #include #include +#include #include "dbus-data.h" #include "messages-service-client.h" @@ -61,8 +62,6 @@ INDICATOR_SET_TYPE(INDICATOR_MESSAGES_TYPE) /* Globals */ static GtkWidget * main_image = NULL; -#define DESIGN_TEAM_SIZE design_team_size -static GtkIconSize design_team_size; static DBusGProxy * icon_proxy = NULL; static GtkSizeGroup * indicator_right_group = NULL; @@ -116,9 +115,9 @@ 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); + indicator_image_helper_update(GTK_IMAGE(main_image), "indicator-messages-new"); } else { - gtk_image_set_from_icon_name(GTK_IMAGE(main_image), "indicator-messages", DESIGN_TEAM_SIZE); + indicator_image_helper_update(GTK_IMAGE(main_image), "indicator-messages"); } return; } @@ -340,9 +339,7 @@ new_indicator_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbusm static GtkImage * get_icon (IndicatorObject * io) { - design_team_size = gtk_icon_size_register("design-team-size", 22, 22); - - main_image = gtk_image_new_from_icon_name("indicator-messages", DESIGN_TEAM_SIZE); + main_image = GTK_WIDGET(indicator_image_helper("indicator-messages")); gtk_widget_show(main_image); return GTK_IMAGE(main_image); -- cgit v1.2.3 From 5b178064d69eccc74eb2b7b2dfb505ddc4498957 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 23 Mar 2010 16:06:02 -0500 Subject: Adds in an application menu item. --- src/indicator-messages.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) (limited to 'src/indicator-messages.c') diff --git a/src/indicator-messages.c b/src/indicator-messages.c index f6b2084..2387be4 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -207,6 +207,70 @@ setup_icon_proxy (gpointer userdata) return FALSE; } +/* Sets the label when it changes. */ +static void +application_prop_change_cb (DbusmenuMenuitem * mi, gchar * prop, GValue * value, gpointer user_data) +{ + if (!g_strcmp0(prop, APPLICATION_MENUITEM_PROP_NAME)) { + /* Set the main label */ + if (GTK_IS_LABEL(user_data)) { + gtk_label_set_text(GTK_LABEL(user_data), g_value_get_string(value)); + } + } + + return; +} + +/* Builds a menu item representing a running application in the + messaging menu */ +static gboolean +new_application_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client) +{ + GtkMenuItem * gmi = GTK_MENU_ITEM(gtk_image_menu_item_new()); + + gint padding = 4; + gtk_widget_style_get(GTK_WIDGET(gmi), "horizontal-padding", &padding, NULL); + + GtkWidget * hbox = gtk_hbox_new(FALSE, 0); + + /* Set the minimum size, we always want it to take space */ + gint width, height; + gtk_icon_size_lookup(GTK_ICON_SIZE_MENU, &width, &height); + + GtkWidget * icon = gtk_image_new_from_icon_name(dbusmenu_menuitem_property_get(newitem, APPLICATION_MENUITEM_PROP_ICON), GTK_ICON_SIZE_MENU); + gtk_widget_set_size_request(icon, width, height); + gtk_misc_set_alignment(GTK_MISC(icon), 0.0, 0.5); + gtk_box_pack_start(GTK_BOX(hbox), icon, FALSE, FALSE, padding); + gtk_widget_show(icon); + + /* Application name in a label */ + 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, padding); + gtk_widget_show(label); + + /* Insert the hbox */ + gtk_container_add(GTK_CONTAINER(gmi), hbox); + gtk_widget_show(hbox); + + /* Build up the running icon */ + GtkWidget * running_icon = gtk_image_new_from_icon_name("application-running", GTK_ICON_SIZE_MENU); + gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(gmi), running_icon); + gtk_widget_show(running_icon); + + /* Make sure it always appears */ + gtk_image_menu_item_set_always_show_image(GTK_IMAGE_MENU_ITEM(gmi), TRUE); + + /* Attach some of the standard GTK stuff */ + dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, gmi, parent); + + /* Make sure we can handle the label changing */ + g_signal_connect(G_OBJECT(newitem), DBUSMENU_MENUITEM_SIGNAL_PROPERTY_CHANGED, G_CALLBACK(application_prop_change_cb), label); + + return TRUE; +} + + typedef struct _indicator_item_t indicator_item_t; struct _indicator_item_t { GtkWidget * icon; @@ -380,6 +444,7 @@ get_menu (IndicatorObject * io) DbusmenuGtkClient * client = dbusmenu_gtkmenu_get_client(menu); dbusmenu_client_add_type_handler(DBUSMENU_CLIENT(client), INDICATOR_MENUITEM_TYPE, new_indicator_item); + dbusmenu_client_add_type_handler(DBUSMENU_CLIENT(client), APPLICATION_MENUITEM_TYPE, new_application_item); return GTK_MENU(menu); } -- cgit v1.2.3 From aad1a1cfdf3051929a6788b480c090f7f4e88ef8 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 23 Mar 2010 16:22:26 -0500 Subject: Looking for the right property --- src/indicator-messages.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/indicator-messages.c') diff --git a/src/indicator-messages.c b/src/indicator-messages.c index 2387be4..99e303b 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -244,7 +244,7 @@ new_application_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbu gtk_widget_show(icon); /* Application name in a label */ - GtkWidget * label = gtk_label_new(dbusmenu_menuitem_property_get(newitem, INDICATOR_MENUITEM_PROP_LABEL)); + GtkWidget * label = gtk_label_new(dbusmenu_menuitem_property_get(newitem, APPLICATION_MENUITEM_PROP_NAME)); gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, padding); gtk_widget_show(label); -- cgit v1.2.3 From ce879d3dedab7c15f7d72640f27458f46b7cf2c2 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 24 Mar 2010 17:10:48 -0500 Subject: Allow for applications icons to change incase we haven't gotten the property yet. --- src/indicator-messages.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/indicator-messages.c') diff --git a/src/indicator-messages.c b/src/indicator-messages.c index 99e303b..988d9d6 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -207,6 +207,20 @@ setup_icon_proxy (gpointer userdata) return FALSE; } +/* Sets the icon when it changes. */ +static void +application_icon_change_cb (DbusmenuMenuitem * mi, gchar * prop, GValue * value, gpointer user_data) +{ + if (!g_strcmp0(prop, APPLICATION_MENUITEM_PROP_ICON)) { + /* Set the main icon */ + if (GTK_IS_IMAGE(user_data)) { + gtk_image_set_from_icon_name(GTK_IMAGE(user_data), g_value_get_string(value), GTK_ICON_SIZE_MENU); + } + } + + return; +} + /* Sets the label when it changes. */ static void application_prop_change_cb (DbusmenuMenuitem * mi, gchar * prop, GValue * value, gpointer user_data) @@ -266,6 +280,7 @@ new_application_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbu /* Make sure we can handle the label changing */ g_signal_connect(G_OBJECT(newitem), DBUSMENU_MENUITEM_SIGNAL_PROPERTY_CHANGED, G_CALLBACK(application_prop_change_cb), label); + g_signal_connect(G_OBJECT(newitem), DBUSMENU_MENUITEM_SIGNAL_PROPERTY_CHANGED, G_CALLBACK(application_icon_change_cb), icon); return TRUE; } -- cgit v1.2.3