From e77cd1f8cb84fa071b386fecde846bff24d15452 Mon Sep 17 00:00:00 2001 From: Andrea Cimitan Date: Thu, 22 Jul 2010 12:19:47 +0200 Subject: Added triangles on the left and new label design on the right. We still need to align not-active services but I don't have any clue on how to do this --- src/indicator-messages.c | 176 ++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 159 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/indicator-messages.c b/src/indicator-messages.c index f47eccd..adfba93 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -44,6 +44,11 @@ with this program. If not, see . #define IS_INDICATOR_MESSAGES_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), INDICATOR_MESSAGES_TYPE)) #define INDICATOR_MESSAGES_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), INDICATOR_MESSAGES_TYPE, IndicatorMessagesClass)) +#define M_PI 3.1415926535897932384626433832795028841971693993751 + +#define RIGHT_LABEL_FONT_SIZE 12 +#define TRIANGLE_PADDING 10 + typedef struct _IndicatorMessages IndicatorMessages; typedef struct _IndicatorMessagesClass IndicatorMessagesClass; @@ -285,27 +290,141 @@ application_prop_change_cb (DbusmenuMenuitem * mi, gchar * prop, GValue * value, return; } +/* Draws a triangle on the left, using fg[STATE_TYPE] color. */ +static gboolean +application_triangle_draw_cb (GtkWidget *widget, GdkEventExpose *event, gpointer data) +{ + GtkStyle *style; + cairo_t *cr; + int x, y, arrow_width, arrow_height; + + /* get style */ + style = gtk_widget_get_style (widget); + + /* set arrow position / dimensions */ + arrow_width = widget->allocation.height/5.0; + arrow_height = widget->allocation.height/3.0; + x = widget->allocation.x; + y = widget->allocation.y + widget->allocation.height/2.0 - (double)arrow_height/2.0; + + /* initialize cairo drawing area */ + cr = (cairo_t*) gdk_cairo_create (widget->window); + + /* set line width */ + cairo_set_line_width (cr, 1.0); + + /* cairo drawing code */ + cairo_move_to (cr, x, y); + cairo_line_to (cr, x, y + arrow_height); + cairo_line_to (cr, x + arrow_width, y + (double)arrow_height/2.0); + cairo_close_path (cr); + cairo_set_source_rgb (cr, style->fg[gtk_widget_get_state(widget)].red/65535.0, + style->fg[gtk_widget_get_state(widget)].green/65535.0, + style->fg[gtk_widget_get_state(widget)].blue/65535.0); + cairo_fill (cr); + + /* remember to destroy cairo context to avoid leaks */ + cairo_destroy (cr); + + return FALSE; +} + +static void +custom_cairo_rounded_rectangle (cairo_t *cr, + double x, double y, double w, double h, + int radius) +{ + radius = MIN (radius, MIN (w/2.0, h/2.0)); + + cairo_move_to (cr, x+radius, y); + cairo_arc (cr, x+w-radius, y+radius, radius, M_PI*1.5, M_PI*2); + cairo_arc (cr, x+w-radius, y+h-radius, radius, 0, M_PI*0.5); + cairo_arc (cr, x+radius, y+h-radius, radius, M_PI*0.5, M_PI); + cairo_arc (cr, x+radius, y+radius, radius, M_PI, M_PI*1.5); +} + +/* Draws a rounded rectangle with text inside. */ +static gboolean +numbers_draw_cb (GtkWidget *widget, GdkEventExpose *event, gpointer data) +{ + GtkStyle *style; + cairo_t *cr; + double x, y, w, h; + PangoLayout * layout; + gint font_size = RIGHT_LABEL_FONT_SIZE; + + /* get style */ + style = gtk_widget_get_style (widget); + + /* set arrow position / dimensions */ + w = widget->allocation.width; + h = widget->allocation.height; + x = widget->allocation.x; + y = widget->allocation.y; + + layout = gtk_label_get_layout (GTK_LABEL(widget)); + + /* This does not work, don't ask me why but font_size is 0. + * I wanted to use a dynamic font size to adjust the padding on left/right edges + * of the rounded rectangle. Andrea Cimitan */ + /* const PangoFontDescription * font_description = pango_layout_get_font_description (layout); + font_size = pango_font_description_get_size (font_description); */ + + /* initialize cairo drawing area */ + cr = (cairo_t*) gdk_cairo_create (widget->window); + + /* set line width */ + cairo_set_line_width (cr, 1.0); + + cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD); + + /* cairo drawing code */ + custom_cairo_rounded_rectangle (cr, x - font_size/2.0, y, w + font_size, h, 30); + + cairo_set_source_rgba (cr, style->fg[gtk_widget_get_state(widget)].red/65535.0, + style->fg[gtk_widget_get_state(widget)].green/65535.0, + style->fg[gtk_widget_get_state(widget)].blue/65535.0, 0.5); + + cairo_move_to (cr, x, y); + pango_cairo_layout_path (cr, layout); + cairo_fill (cr); + + /* remember to destroy cairo context to avoid leaks */ + cairo_destroy (cr); + + return TRUE; +} + /* 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()); - + gchar buf[1024]; gint padding = 4; + gtk_widget_style_get(GTK_WIDGET(gmi), "horizontal-padding", &padding, NULL); + g_snprintf (buf, sizeof (buf), "idomessage-%p", gmi); + gtk_widget_set_name (GTK_WIDGET (gmi), buf); + + g_snprintf (buf, sizeof (buf), + "style \"ido-message\" {\n" + " GtkMenuItem::horizontal-padding = %d\n" + "} widget \"*.idomessage-%p\" style \"ido-message\"\n", + TRIANGLE_PADDING, gmi); + gtk_rc_parse_string (buf); + 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); + 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, APPLICATION_MENUITEM_PROP_NAME)); @@ -313,29 +432,27 @@ new_application_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbu 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); + gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(gmi), icon); /* Make sure it always appears */ gtk_image_menu_item_set_always_show_image(GTK_IMAGE_MENU_ITEM(gmi), TRUE); + /* Insert the hbox */ + gtk_container_add(GTK_CONTAINER(gmi), hbox); + gtk_widget_show(hbox); + /* 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); g_signal_connect(G_OBJECT(newitem), DBUSMENU_MENUITEM_SIGNAL_PROPERTY_CHANGED, G_CALLBACK(application_icon_change_cb), icon); + g_signal_connect_after (G_OBJECT (gmi), "expose_event", G_CALLBACK (application_triangle_draw_cb), NULL); return TRUE; } - typedef struct _indicator_item_t indicator_item_t; struct _indicator_item_t { GtkWidget * icon; @@ -402,11 +519,24 @@ new_indicator_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbusm indicator_item_t * mi_data = g_new0(indicator_item_t, 1); - GtkMenuItem * gmi = GTK_MENU_ITEM(gtk_menu_item_new()); + GtkMenuItem * gmi = GTK_MENU_ITEM(gtk_image_menu_item_new()); + gchar buf[1024]; gint padding = 4; + gint font_size = RIGHT_LABEL_FONT_SIZE; + gtk_widget_style_get(GTK_WIDGET(gmi), "horizontal-padding", &padding, NULL); + g_snprintf (buf, sizeof (buf), "idomessage-%p", gmi); + gtk_widget_set_name (GTK_WIDGET (gmi), buf); + + g_snprintf (buf, sizeof (buf), + "style \"ido-message\" {\n" + " GtkMenuItem::horizontal-padding = %d\n" + "} widget \"*.idomessage-%p\" style \"ido-message\"\n", + TRIANGLE_PADDING, gmi); + gtk_rc_parse_string (buf); + GtkWidget * hbox = gtk_hbox_new(FALSE, 0); /* Icon, probably someone's face or avatar on an IM */ @@ -441,8 +571,6 @@ new_indicator_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbusm g_object_unref(resized_pixbuf); } } - 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, padding); gtk_widget_show(mi_data->icon); /* Label, probably a username, chat room or mailbox name */ @@ -455,10 +583,24 @@ new_indicator_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbusm item. */ 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); + + /* Doesn't work, look numbers_draw_cb. */ + /* PangoLayout * right_layout = gtk_label_get_layout (GTK_LABEL(mi_data->right)); + gint font_size = pango_font_description_get_size (pango_layout_get_font_description (right_layout)); */ + + g_signal_connect (G_OBJECT (mi_data->right), "expose_event", + G_CALLBACK (numbers_draw_cb), NULL); + 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, padding); + gtk_box_pack_start(GTK_BOX(hbox), mi_data->right, FALSE, FALSE, padding + font_size/2.0); gtk_widget_show(mi_data->right); + /* Build up the running icon */ + gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(gmi), mi_data->icon); + + /* Make sure it always appears */ + gtk_image_menu_item_set_always_show_image(GTK_IMAGE_MENU_ITEM(gmi), TRUE); + gtk_container_add(GTK_CONTAINER(gmi), hbox); gtk_widget_show(hbox); -- cgit v1.2.3 From 27df2717d21625ebde66fba258896513567810c5 Mon Sep 17 00:00:00 2001 From: Andrea Cimitan Date: Thu, 22 Jul 2010 19:20:43 +0200 Subject: Fixed position of sub menu indicators (the one with the counter on the right) --- src/indicator-messages.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/indicator-messages.c b/src/indicator-messages.c index adfba93..dd90318 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -570,8 +570,12 @@ new_indicator_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbusm if (resized_pixbuf != pixbuf) { g_object_unref(resized_pixbuf); } + + /* Add the icon only if present. */ + 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, padding); + gtk_widget_show(mi_data->icon); } - 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)); @@ -595,12 +599,6 @@ new_indicator_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbusm gtk_box_pack_start(GTK_BOX(hbox), mi_data->right, FALSE, FALSE, padding + font_size/2.0); gtk_widget_show(mi_data->right); - /* Build up the running icon */ - gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(gmi), mi_data->icon); - - /* Make sure it always appears */ - gtk_image_menu_item_set_always_show_image(GTK_IMAGE_MENU_ITEM(gmi), TRUE); - gtk_container_add(GTK_CONTAINER(gmi), hbox); gtk_widget_show(hbox); -- cgit v1.2.3 From 8712e709c76ca99f71680dd5ade66c03c45c8dd1 Mon Sep 17 00:00:00 2001 From: Andrea Cimitan Date: Thu, 29 Jul 2010 12:55:42 +0200 Subject: Added rounded rectangles on the right --- src/indicator-messages.c | 111 ++++++++++------------------------------------- 1 file changed, 22 insertions(+), 89 deletions(-) (limited to 'src') diff --git a/src/indicator-messages.c b/src/indicator-messages.c index dd90318..a4299dc 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -47,7 +47,7 @@ with this program. If not, see . #define M_PI 3.1415926535897932384626433832795028841971693993751 #define RIGHT_LABEL_FONT_SIZE 12 -#define TRIANGLE_PADDING 10 +#define RIGHT_LABEL_RADIUS 20 typedef struct _IndicatorMessages IndicatorMessages; typedef struct _IndicatorMessagesClass IndicatorMessagesClass; @@ -290,51 +290,12 @@ application_prop_change_cb (DbusmenuMenuitem * mi, gchar * prop, GValue * value, return; } -/* Draws a triangle on the left, using fg[STATE_TYPE] color. */ -static gboolean -application_triangle_draw_cb (GtkWidget *widget, GdkEventExpose *event, gpointer data) -{ - GtkStyle *style; - cairo_t *cr; - int x, y, arrow_width, arrow_height; - - /* get style */ - style = gtk_widget_get_style (widget); - - /* set arrow position / dimensions */ - arrow_width = widget->allocation.height/5.0; - arrow_height = widget->allocation.height/3.0; - x = widget->allocation.x; - y = widget->allocation.y + widget->allocation.height/2.0 - (double)arrow_height/2.0; - - /* initialize cairo drawing area */ - cr = (cairo_t*) gdk_cairo_create (widget->window); - - /* set line width */ - cairo_set_line_width (cr, 1.0); - - /* cairo drawing code */ - cairo_move_to (cr, x, y); - cairo_line_to (cr, x, y + arrow_height); - cairo_line_to (cr, x + arrow_width, y + (double)arrow_height/2.0); - cairo_close_path (cr); - cairo_set_source_rgb (cr, style->fg[gtk_widget_get_state(widget)].red/65535.0, - style->fg[gtk_widget_get_state(widget)].green/65535.0, - style->fg[gtk_widget_get_state(widget)].blue/65535.0); - cairo_fill (cr); - - /* remember to destroy cairo context to avoid leaks */ - cairo_destroy (cr); - - return FALSE; -} - +/* Custom function to draw rounded rectangle with max radius */ static void custom_cairo_rounded_rectangle (cairo_t *cr, - double x, double y, double w, double h, - int radius) + double x, double y, double w, double h) { - radius = MIN (radius, MIN (w/2.0, h/2.0)); + double radius = MIN (w/2.0, h/2.0); cairo_move_to (cr, x+radius, y); cairo_arc (cr, x+w-radius, y+radius, radius, M_PI*1.5, M_PI*2); @@ -379,7 +340,7 @@ numbers_draw_cb (GtkWidget *widget, GdkEventExpose *event, gpointer data) cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD); /* cairo drawing code */ - custom_cairo_rounded_rectangle (cr, x - font_size/2.0, y, w + font_size, h, 30); + custom_cairo_rounded_rectangle (cr, x - font_size/2.0, y, w + font_size, h); cairo_set_source_rgba (cr, style->fg[gtk_widget_get_state(widget)].red/65535.0, style->fg[gtk_widget_get_state(widget)].green/65535.0, @@ -401,30 +362,21 @@ static gboolean new_application_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client) { GtkMenuItem * gmi = GTK_MENU_ITEM(gtk_image_menu_item_new()); - gchar buf[1024]; - gint padding = 4; + gint padding = 4; gtk_widget_style_get(GTK_WIDGET(gmi), "horizontal-padding", &padding, NULL); - g_snprintf (buf, sizeof (buf), "idomessage-%p", gmi); - gtk_widget_set_name (GTK_WIDGET (gmi), buf); - - g_snprintf (buf, sizeof (buf), - "style \"ido-message\" {\n" - " GtkMenuItem::horizontal-padding = %d\n" - "} widget \"*.idomessage-%p\" style \"ido-message\"\n", - TRIANGLE_PADDING, gmi); - gtk_rc_parse_string (buf); - 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); + 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, APPLICATION_MENUITEM_PROP_NAME)); @@ -432,23 +384,24 @@ new_application_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbu 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 */ - gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(gmi), 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); - /* Insert the hbox */ - gtk_container_add(GTK_CONTAINER(gmi), hbox); - gtk_widget_show(hbox); - /* 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); g_signal_connect(G_OBJECT(newitem), DBUSMENU_MENUITEM_SIGNAL_PROPERTY_CHANGED, G_CALLBACK(application_icon_change_cb), icon); - g_signal_connect_after (G_OBJECT (gmi), "expose_event", G_CALLBACK (application_triangle_draw_cb), NULL); return TRUE; } @@ -519,24 +472,12 @@ new_indicator_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbusm indicator_item_t * mi_data = g_new0(indicator_item_t, 1); - GtkMenuItem * gmi = GTK_MENU_ITEM(gtk_image_menu_item_new()); + GtkMenuItem * gmi = GTK_MENU_ITEM(gtk_menu_item_new()); - gchar buf[1024]; gint padding = 4; gint font_size = RIGHT_LABEL_FONT_SIZE; - gtk_widget_style_get(GTK_WIDGET(gmi), "horizontal-padding", &padding, NULL); - g_snprintf (buf, sizeof (buf), "idomessage-%p", gmi); - gtk_widget_set_name (GTK_WIDGET (gmi), buf); - - g_snprintf (buf, sizeof (buf), - "style \"ido-message\" {\n" - " GtkMenuItem::horizontal-padding = %d\n" - "} widget \"*.idomessage-%p\" style \"ido-message\"\n", - TRIANGLE_PADDING, gmi); - gtk_rc_parse_string (buf); - GtkWidget * hbox = gtk_hbox_new(FALSE, 0); /* Icon, probably someone's face or avatar on an IM */ @@ -570,18 +511,10 @@ new_indicator_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbusm if (resized_pixbuf != pixbuf) { g_object_unref(resized_pixbuf); } - - /* Add the icon only if present. */ - 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, 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, padding); - gtk_widget_show(mi_data->label); + 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, padding); + gtk_widget_show(mi_data->icon); /* Usually either the time or the count on the individual item. */ @@ -590,7 +523,7 @@ new_indicator_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbusm /* Doesn't work, look numbers_draw_cb. */ /* PangoLayout * right_layout = gtk_label_get_layout (GTK_LABEL(mi_data->right)); - gint font_size = pango_font_description_get_size (pango_layout_get_font_description (right_layout)); */ + font_size = pango_font_description_get_size (pango_layout_get_font_description (right_layout)); */ g_signal_connect (G_OBJECT (mi_data->right), "expose_event", G_CALLBACK (numbers_draw_cb), NULL); -- cgit v1.2.3 From c4baebd40e86b2277f87a17df0a9d25d79cac251 Mon Sep 17 00:00:00 2001 From: Andrea Cimitan Date: Thu, 29 Jul 2010 13:30:48 +0200 Subject: Ops, readded the label :P --- src/indicator-messages.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src') diff --git a/src/indicator-messages.c b/src/indicator-messages.c index a4299dc..550f1fd 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -516,6 +516,12 @@ new_indicator_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbusm 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, padding); + gtk_widget_show(mi_data->label); + /* Usually either the time or the count on the individual item. */ mi_data->right = gtk_label_new(dbusmenu_menuitem_property_get(newitem, INDICATOR_MENUITEM_PROP_RIGHT)); -- cgit v1.2.3 From 4aa39a73041f2952ffd1918c9b68a7cda1028c6e Mon Sep 17 00:00:00 2001 From: Andrea Cimitan Date: Thu, 29 Jul 2010 13:40:02 +0200 Subject: check if widget is really a widget before getting its style (from dbarth) --- src/indicator-messages.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/indicator-messages.c b/src/indicator-messages.c index 550f1fd..d1133ea 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -314,6 +314,8 @@ numbers_draw_cb (GtkWidget *widget, GdkEventExpose *event, gpointer data) PangoLayout * layout; gint font_size = RIGHT_LABEL_FONT_SIZE; + if (!GTK_IS_WIDGET (widget)) return; + /* get style */ style = gtk_widget_get_style (widget); -- cgit v1.2.3 From 4749650191f707ae86574ca292bb21afe93e10e7 Mon Sep 17 00:00:00 2001 From: Andrea Cimitan Date: Thu, 29 Jul 2010 15:32:08 +0200 Subject: Draw a triangle on the left --- src/indicator-messages.c | 44 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/indicator-messages.c b/src/indicator-messages.c index d1133ea..beea9f2 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -290,6 +290,47 @@ application_prop_change_cb (DbusmenuMenuitem * mi, gchar * prop, GValue * value, return; } +/* Draws a triangle on the left, using fg[STATE_TYPE] color. */ +static gboolean +application_triangle_draw_cb (GtkWidget *widget, GdkEventExpose *event, gpointer data) +{ + GtkStyle *style; + cairo_t *cr; + int x, y, arrow_width, arrow_height; + + if (!GTK_IS_WIDGET (widget)) return; + + /* get style */ + style = gtk_widget_get_style (widget); + + /* set arrow position / dimensions */ + arrow_width = widget->allocation.height/5.0; + arrow_height = widget->allocation.height/3.0; + x = widget->allocation.x; + y = widget->allocation.y + widget->allocation.height/2.0 - (double)arrow_height/2.0; + + /* initialize cairo drawing area */ + cr = (cairo_t*) gdk_cairo_create (widget->window); + + /* set line width */ + cairo_set_line_width (cr, 1.0); + + /* cairo drawing code */ + cairo_move_to (cr, x, y); + cairo_line_to (cr, x, y + arrow_height); + cairo_line_to (cr, x + arrow_width, y + (double)arrow_height/2.0); + cairo_close_path (cr); + cairo_set_source_rgb (cr, style->fg[gtk_widget_get_state(widget)].red/65535.0, + style->fg[gtk_widget_get_state(widget)].green/65535.0, + style->fg[gtk_widget_get_state(widget)].blue/65535.0); + cairo_fill (cr); + + /* remember to destroy cairo context to avoid leaks */ + cairo_destroy (cr); + + return FALSE; +} + /* Custom function to draw rounded rectangle with max radius */ static void custom_cairo_rounded_rectangle (cairo_t *cr, @@ -403,7 +444,8 @@ 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); + g_signal_connect(G_OBJECT(newitem), DBUSMENU_MENUITEM_SIGNAL_PROPERTY_CHANGED, G_CALLBACK(application_icon_change_cb), icon); + g_signal_connect_after(G_OBJECT (gmi), "expose_event", G_CALLBACK (application_triangle_draw_cb), NULL); return TRUE; } -- cgit v1.2.3 From 0fc555a7ff95caca49ec4a48d6405c9255ad3c94 Mon Sep 17 00:00:00 2001 From: Andrea Cimitan Date: Thu, 29 Jul 2010 15:38:22 +0200 Subject: trailing whitespace --- src/indicator-messages.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/indicator-messages.c b/src/indicator-messages.c index beea9f2..06a09c8 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -444,7 +444,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); + g_signal_connect(G_OBJECT(newitem), DBUSMENU_MENUITEM_SIGNAL_PROPERTY_CHANGED, G_CALLBACK(application_icon_change_cb), icon); g_signal_connect_after(G_OBJECT (gmi), "expose_event", G_CALLBACK (application_triangle_draw_cb), NULL); return TRUE; -- cgit v1.2.3 From 07039865d9bb58f7d80c547bff0bc04327a383bc Mon Sep 17 00:00:00 2001 From: Andrea Cimitan Date: Thu, 29 Jul 2010 16:01:44 +0200 Subject: remove the previous icon --- src/indicator-messages.c | 8 -------- 1 file changed, 8 deletions(-) (limited to 'src') diff --git a/src/indicator-messages.c b/src/indicator-messages.c index 06a09c8..a7f79fd 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -431,14 +431,6 @@ new_application_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbu 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); -- cgit v1.2.3 From 32e8f9ff37ace0f23895b762d5c5a4a5696a093e Mon Sep 17 00:00:00 2001 From: David Barth Date: Thu, 29 Jul 2010 16:03:42 +0200 Subject: fix typos to build and clean up comments --- src/indicator-messages.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/indicator-messages.c b/src/indicator-messages.c index 06a09c8..d45dfc8 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -298,7 +298,7 @@ application_triangle_draw_cb (GtkWidget *widget, GdkEventExpose *event, gpointer cairo_t *cr; int x, y, arrow_width, arrow_height; - if (!GTK_IS_WIDGET (widget)) return; + if (!GTK_IS_WIDGET (widget)) return FALSE; /* get style */ style = gtk_widget_get_style (widget); @@ -355,7 +355,7 @@ numbers_draw_cb (GtkWidget *widget, GdkEventExpose *event, gpointer data) PangoLayout * layout; gint font_size = RIGHT_LABEL_FONT_SIZE; - if (!GTK_IS_WIDGET (widget)) return; + if (!GTK_IS_WIDGET (widget)) return FALSE; /* get style */ style = gtk_widget_get_style (widget); @@ -570,11 +570,7 @@ new_indicator_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbusm item. */ 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); - - /* Doesn't work, look numbers_draw_cb. */ - /* PangoLayout * right_layout = gtk_label_get_layout (GTK_LABEL(mi_data->right)); - font_size = pango_font_description_get_size (pango_layout_get_font_description (right_layout)); */ - + /* install extra decoration overlay */ g_signal_connect (G_OBJECT (mi_data->right), "expose_event", G_CALLBACK (numbers_draw_cb), NULL); -- cgit v1.2.3 From 997a69df81d34c92263cad72eed1b772209b6e95 Mon Sep 17 00:00:00 2001 From: David Barth Date: Thu, 29 Jul 2010 16:04:07 +0200 Subject: remove the old running app. icon --- src/indicator-messages.c | 5 ----- 1 file changed, 5 deletions(-) (limited to 'src') diff --git a/src/indicator-messages.c b/src/indicator-messages.c index d45dfc8..aa4cf26 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -431,11 +431,6 @@ new_application_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbu 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); -- cgit v1.2.3 From 59b9d6fe4abecc1d986c73d077c0994fccae37e7 Mon Sep 17 00:00:00 2001 From: David Barth Date: Thu, 29 Jul 2010 16:08:34 +0200 Subject: adjust the triangle size --- src/indicator-messages.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/indicator-messages.c b/src/indicator-messages.c index aa4cf26..8aa64de 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -304,8 +304,8 @@ application_triangle_draw_cb (GtkWidget *widget, GdkEventExpose *event, gpointer style = gtk_widget_get_style (widget); /* set arrow position / dimensions */ - arrow_width = widget->allocation.height/5.0; - arrow_height = widget->allocation.height/3.0; + arrow_width = (int) ((double)widget->allocation.height * 0.25f); + arrow_height = (int) ((double)widget->allocation.height * 0.60f); x = widget->allocation.x; y = widget->allocation.y + widget->allocation.height/2.0 - (double)arrow_height/2.0; -- cgit v1.2.3 From 29d8a891747905a2ec7c5f05f0a9df11fb45e764 Mon Sep 17 00:00:00 2001 From: David Barth Date: Thu, 29 Jul 2010 17:43:43 +0200 Subject: better aspect ratio for the triangle --- src/indicator-messages.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/indicator-messages.c b/src/indicator-messages.c index 8aa64de..dc10516 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -305,7 +305,7 @@ application_triangle_draw_cb (GtkWidget *widget, GdkEventExpose *event, gpointer /* set arrow position / dimensions */ arrow_width = (int) ((double)widget->allocation.height * 0.25f); - arrow_height = (int) ((double)widget->allocation.height * 0.60f); + arrow_height = (int) ((double)widget->allocation.height * 0.50f); x = widget->allocation.x; y = widget->allocation.y + widget->allocation.height/2.0 - (double)arrow_height/2.0; -- cgit v1.2.3 From 2fd2bf207155ebeb4303569e39770c358282eb36 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 12 Aug 2010 09:25:35 -0500 Subject: Removing the parenthesis --- src/im-menu-item.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/im-menu-item.c b/src/im-menu-item.c index 5841d81..b8b3709 100644 --- a/src/im-menu-item.c +++ b/src/im-menu-item.c @@ -348,7 +348,7 @@ count_cb (IndicateListener * listener, IndicateListenerServer * server, Indicate g_free(priv->count); } - priv->count = g_strdup_printf("(%s)", propertydata); + priv->count = g_strdup_printf("%s", propertydata); dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), INDICATOR_MENUITEM_PROP_RIGHT, priv->count); return; -- cgit v1.2.3 From adf2ffddfbf1837ec9db20d2648786e57565719e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 24 Aug 2010 14:59:07 -0500 Subject: Set the image menu icon --- src/indicator-messages.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/indicator-messages.c b/src/indicator-messages.c index df2d972..dcb57dc 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -418,7 +418,7 @@ new_application_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbu 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_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(gmi), icon); gtk_widget_show(icon); /* Application name in a label */ -- cgit v1.2.3 From de84a7600cbe17e38f7fcca07095b105e21e1dea Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 24 Aug 2010 15:00:22 -0500 Subject: Removing the blank menu items --- src/app-menu-item.c | 2 -- src/launcher-menu-item.c | 1 - 2 files changed, 3 deletions(-) (limited to 'src') diff --git a/src/app-menu-item.c b/src/app-menu-item.c index c276a90..676f03e 100644 --- a/src/app-menu-item.c +++ b/src/app-menu-item.c @@ -355,7 +355,6 @@ child_added_cb (DbusmenuMenuitem * root, DbusmenuMenuitem * child, guint positio AppMenuItem * self = APP_MENU_ITEM(data); AppMenuItemPrivate * priv = APP_MENU_ITEM_GET_PRIVATE(self); DbusmenuMenuitemProxy * mip = dbusmenu_menuitem_proxy_new(child); - dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(mip), DBUSMENU_MENUITEM_PROP_ICON_NAME, DBUSMENU_MENUITEM_ICON_NAME_BLANK); priv->shortcuts = g_list_insert(priv->shortcuts, mip, position); @@ -456,7 +455,6 @@ root_changed (DbusmenuClient * client, DbusmenuMenuitem * newroot, gpointer data g_debug("\tProcessing %d children", g_list_length(children)); while (children != NULL) { DbusmenuMenuitemProxy * mip = dbusmenu_menuitem_proxy_new(DBUSMENU_MENUITEM(children->data)); - dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(mip), DBUSMENU_MENUITEM_PROP_ICON_NAME, DBUSMENU_MENUITEM_ICON_NAME_BLANK); priv->shortcuts = g_list_append(priv->shortcuts, mip); g_signal_emit(G_OBJECT(self), signals[SHORTCUT_ADDED], 0, mip, TRUE); children = g_list_next(children); diff --git a/src/launcher-menu-item.c b/src/launcher-menu-item.c index 63e5594..5d9de12 100644 --- a/src/launcher-menu-item.c +++ b/src/launcher-menu-item.c @@ -199,7 +199,6 @@ launcher_menu_item_new (const gchar * desktop_file) DbusmenuMenuitem * mi = dbusmenu_menuitem_new(); g_object_set_data(G_OBJECT(mi), NICK_DATA, (gpointer)nicks[i]); - dbusmenu_menuitem_property_set(mi, DBUSMENU_MENUITEM_PROP_ICON_NAME, DBUSMENU_MENUITEM_ICON_NAME_BLANK); dbusmenu_menuitem_property_set(mi, DBUSMENU_MENUITEM_PROP_LABEL, indicator_desktop_shortcuts_nick_get_name(priv->ids, nicks[i])); g_signal_connect(G_OBJECT(mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(nick_activate_cb), self); -- cgit v1.2.3 From 422423618105395db6ca9316ea78d58d92d136b4 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 24 Aug 2010 15:06:41 -0500 Subject: Only show the avatar if it is sent --- src/indicator-messages.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/indicator-messages.c b/src/indicator-messages.c index dcb57dc..9039af7 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -489,6 +489,10 @@ indicator_prop_change_cb (DbusmenuMenuitem * mi, gchar * prop, GValue * value, i if (resized_pixbuf != pixbuf) { g_object_unref(resized_pixbuf); } + + gtk_widget_show(mi_data->icon); + } else { + gtk_widget_hide(mi_data->icon); } } @@ -550,7 +554,10 @@ 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, padding); - gtk_widget_show(mi_data->icon); + + if (pixbuf != NULL) { + 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)); -- cgit v1.2.3 From a58b07fb80399028e27ee95cc3d1dac848bebe6d Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 24 Aug 2010 15:24:59 -0500 Subject: Removing some extra code that's not needed and ensuring the icon is always shown. --- src/indicator-messages.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'src') diff --git a/src/indicator-messages.c b/src/indicator-messages.c index 9039af7..97220c6 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -405,6 +405,7 @@ static gboolean new_application_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client) { GtkMenuItem * gmi = GTK_MENU_ITEM(gtk_image_menu_item_new()); + gtk_image_menu_item_set_always_show_image(GTK_IMAGE_MENU_ITEM(gmi), TRUE); gint padding = 4; gtk_widget_style_get(GTK_WIDGET(gmi), "horizontal-padding", &padding, NULL); @@ -412,12 +413,7 @@ new_application_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbu 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_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(gmi), icon); gtk_widget_show(icon); -- cgit v1.2.3 From e32c731f5ef66f6be62d6fc839548356f4665e35 Mon Sep 17 00:00:00 2001 From: David Barth Date: Thu, 26 Aug 2010 21:31:18 +0200 Subject: adjusted position of the left icons and triangle overlay --- src/app-menu-item.c | 1 + src/dbus-data.h | 5 +++-- src/indicator-messages.c | 26 +++++++++++++++++++++++--- src/launcher-menu-item.c | 1 + src/messages-service.c | 1 + 5 files changed, 29 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/app-menu-item.c b/src/app-menu-item.c index 676f03e..0b0588e 100644 --- a/src/app-menu-item.c +++ b/src/app-menu-item.c @@ -328,6 +328,7 @@ desktop_cb (IndicateListener * listener, IndicateListenerServer * server, gchar priv->desktop = g_strdup(value); dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(self), DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE); + dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(self), APPLICATION_MENUITEM_PROP_RUNNING, TRUE); update_label(self); diff --git a/src/dbus-data.h b/src/dbus-data.h index c16b2b5..100ac0a 100644 --- a/src/dbus-data.h +++ b/src/dbus-data.h @@ -9,8 +9,9 @@ #define INDICATOR_MESSAGES_DBUS_SERVICE_INTERFACE "org.ayatana.indicator.messages.service" #define APPLICATION_MENUITEM_TYPE "application-item" -#define APPLICATION_MENUITEM_PROP_NAME "app-name" -#define APPLICATION_MENUITEM_PROP_ICON "app-icon" +#define APPLICATION_MENUITEM_PROP_NAME "label" +#define APPLICATION_MENUITEM_PROP_ICON "icon-name" +#define APPLICATION_MENUITEM_PROP_RUNNING "app-running" #define INDICATOR_MENUITEM_TYPE "indicator-item" #define INDICATOR_MENUITEM_PROP_LABEL "indicator-label" diff --git a/src/indicator-messages.c b/src/indicator-messages.c index 97220c6..302b9e5 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -287,6 +287,11 @@ application_prop_change_cb (DbusmenuMenuitem * mi, gchar * prop, GValue * value, } } + if (!g_strcmp0(prop, APPLICATION_MENUITEM_PROP_RUNNING)) { + /* TODO: should hide/show the triangle live if the menu was open. + In practice, this is rarely needed. */ + } + return; } @@ -299,13 +304,18 @@ application_triangle_draw_cb (GtkWidget *widget, GdkEventExpose *event, gpointer int x, y, arrow_width, arrow_height; if (!GTK_IS_WIDGET (widget)) return FALSE; + if (!DBUSMENU_IS_MENUITEM (data)) return FALSE; + + /* render the triangle indicator only if the application is running */ + if (! dbusmenu_menuitem_property_get_bool (DBUSMENU_MENUITEM(data), APPLICATION_MENUITEM_PROP_RUNNING)) + return FALSE;; /* get style */ style = gtk_widget_get_style (widget); /* set arrow position / dimensions */ - arrow_width = (int) ((double)widget->allocation.height * 0.25f); - arrow_height = (int) ((double)widget->allocation.height * 0.50f); + arrow_width = 5; /* the pixel-based reference triangle is 5x9 */ + arrow_height = 9; x = widget->allocation.x; y = widget->allocation.y + widget->allocation.height/2.0 - (double)arrow_height/2.0; @@ -326,7 +336,7 @@ application_triangle_draw_cb (GtkWidget *widget, GdkEventExpose *event, gpointer cairo_fill (cr); /* remember to destroy cairo context to avoid leaks */ - cairo_destroy (cr); + cairo_destroy (cr); return FALSE; } @@ -404,6 +414,8 @@ numbers_draw_cb (GtkWidget *widget, GdkEventExpose *event, gpointer data) static gboolean new_application_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client) { + g_debug ("%s (\"%s\")", __func__, dbusmenu_menuitem_property_get(newitem, APPLICATION_MENUITEM_PROP_NAME)); + GtkMenuItem * gmi = GTK_MENU_ITEM(gtk_image_menu_item_new()); gtk_image_menu_item_set_always_show_image(GTK_IMAGE_MENU_ITEM(gmi), TRUE); @@ -413,7 +425,15 @@ new_application_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbu 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 + + 5 /* ref triangle is 5x9 pixels */ + + 2 /* padding */, + height); + gtk_misc_set_alignment(GTK_MISC(icon), 1.0 /* right aligned */, 0.5); gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(gmi), icon); gtk_widget_show(icon); diff --git a/src/launcher-menu-item.c b/src/launcher-menu-item.c index 5d9de12..a47af03 100644 --- a/src/launcher-menu-item.c +++ b/src/launcher-menu-item.c @@ -197,6 +197,7 @@ launcher_menu_item_new (const gchar * desktop_file) gint i; for (i = 0; nicks[i] != NULL; i++) { DbusmenuMenuitem * mi = dbusmenu_menuitem_new(); + dbusmenu_menuitem_property_set(mi, DBUSMENU_MENUITEM_PROP_TYPE, APPLICATION_MENUITEM_TYPE); g_object_set_data(G_OBJECT(mi), NICK_DATA, (gpointer)nicks[i]); dbusmenu_menuitem_property_set(mi, DBUSMENU_MENUITEM_PROP_LABEL, indicator_desktop_shortcuts_nick_get_name(priv->ids, nicks[i])); diff --git a/src/messages-service.c b/src/messages-service.c index 0783d91..b87c2ff 100644 --- a/src/messages-service.c +++ b/src/messages-service.c @@ -1346,6 +1346,7 @@ build_launcher_core (const gchar * desktop) launcherList = g_list_insert_sorted(launcherList, ll, launcherList_sort); /* Add it to the menu */ + dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(ll->menuitem), DBUSMENU_MENUITEM_PROP_TYPE, APPLICATION_MENUITEM_TYPE); dbusmenu_menuitem_child_append(root_menuitem, DBUSMENU_MENUITEM(ll->menuitem)); GList * shortcuts = launcher_menu_item_get_items(ll->menuitem); while (shortcuts != NULL) { -- cgit v1.2.3 From fe64f4657213dcd733f28571b8b95a06454adc76 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 3 Sep 2010 13:13:16 -0500 Subject: Making sure to put the dbusmenu item in the callback --- src/indicator-messages.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/indicator-messages.c b/src/indicator-messages.c index 302b9e5..b29edce 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -453,7 +453,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); - g_signal_connect_after(G_OBJECT (gmi), "expose_event", G_CALLBACK (application_triangle_draw_cb), NULL); + g_signal_connect_after(G_OBJECT (gmi), "expose_event", G_CALLBACK (application_triangle_draw_cb), newitem); return TRUE; } -- cgit v1.2.3 From 687ea648b9a8fd6e39ec0da306f4440c3f39f694 Mon Sep 17 00:00:00 2001 From: Michael Terry Date: Wed, 6 Oct 2010 14:58:05 -0400 Subject: avoid deprecated API --- src/indicator-messages.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/indicator-messages.c b/src/indicator-messages.c index b29edce..b57244c 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -299,6 +299,7 @@ application_prop_change_cb (DbusmenuMenuitem * mi, gchar * prop, GValue * value, static gboolean application_triangle_draw_cb (GtkWidget *widget, GdkEventExpose *event, gpointer data) { + GtkAllocation allocation; GtkStyle *style; cairo_t *cr; int x, y, arrow_width, arrow_height; @@ -316,11 +317,12 @@ application_triangle_draw_cb (GtkWidget *widget, GdkEventExpose *event, gpointer /* set arrow position / dimensions */ arrow_width = 5; /* the pixel-based reference triangle is 5x9 */ arrow_height = 9; - x = widget->allocation.x; - y = widget->allocation.y + widget->allocation.height/2.0 - (double)arrow_height/2.0; + gtk_widget_get_allocation (widget, &allocation); + x = allocation.x; + y = allocation.y + allocation.height/2.0 - (double)arrow_height/2.0; /* initialize cairo drawing area */ - cr = (cairo_t*) gdk_cairo_create (widget->window); + cr = (cairo_t*) gdk_cairo_create (gtk_widget_get_window (widget)); /* set line width */ cairo_set_line_width (cr, 1.0); @@ -359,6 +361,7 @@ custom_cairo_rounded_rectangle (cairo_t *cr, static gboolean numbers_draw_cb (GtkWidget *widget, GdkEventExpose *event, gpointer data) { + GtkAllocation allocation; GtkStyle *style; cairo_t *cr; double x, y, w, h; @@ -371,10 +374,11 @@ numbers_draw_cb (GtkWidget *widget, GdkEventExpose *event, gpointer data) style = gtk_widget_get_style (widget); /* set arrow position / dimensions */ - w = widget->allocation.width; - h = widget->allocation.height; - x = widget->allocation.x; - y = widget->allocation.y; + gtk_widget_get_allocation (widget, &allocation); + w = allocation.width; + h = allocation.height; + x = allocation.x; + y = allocation.y; layout = gtk_label_get_layout (GTK_LABEL(widget)); @@ -385,7 +389,7 @@ numbers_draw_cb (GtkWidget *widget, GdkEventExpose *event, gpointer data) font_size = pango_font_description_get_size (font_description); */ /* initialize cairo drawing area */ - cr = (cairo_t*) gdk_cairo_create (widget->window); + cr = (cairo_t*) gdk_cairo_create (gtk_widget_get_window (widget)); /* set line width */ cairo_set_line_width (cr, 1.0); -- cgit v1.2.3 From 05083ac8dd47fdf45fc0823b9410ac5a58724578 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 14 Jan 2011 12:33:06 -0600 Subject: Switching over from using dbus-binding-tool to sed --- src/Makefile.am | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index 7c9842a..dd09b8a 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -9,7 +9,8 @@ messaginglibdir = $(INDICATORDIR) messaginglib_LTLIBRARIES = libmessaging.la libmessaging_la_SOURCES = \ indicator-messages.c \ - messages-service-client.h \ + gen-messages-service.xml.h \ + gen-messages-service.xml.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) @@ -23,9 +24,10 @@ indicator_messages_service_SOURCES = \ default-applications.h \ default-applications.c \ messages-service.c \ - messages-service-server.h \ messages-service-dbus.c \ messages-service-dbus.h \ + gen-messages-service.xml.h \ + gen-messages-service.xml.c \ im-menu-item.c \ im-menu-item.h \ app-menu-item.c \ @@ -39,23 +41,19 @@ indicator_messages_service_SOURCES = \ 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 +gen-%.xml.h: %.xml + @echo "Building $@ from $<" + @echo "extern const char * _$(subst -,_,$(subst .,_,$(basename $(notdir $<))));" > $@ -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 +gen-%.xml.c: %.xml + @echo "Building $@ from $<" + echo "const char * _$(subst -,_,$(subst .,_,$(basename $(notdir $<)))) = " > $@ + @sed -e "s:\":\\\\\":g" -e s:^:\": -e s:\$$:\\\\n\": $< >> $@ + @echo ";" >> $@ BUILT_SOURCES = \ - messages-service-client.h \ - messages-service-server.h + gen-messages-service.xml.h \ + gen-messages-service.xml.c CLEANFILES = \ $(BUILT_SOURCES) -- cgit v1.2.3 From 4729b567a36fd08308e06b10dfd1c0285f95522b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 14 Jan 2011 12:44:57 -0600 Subject: Changing to get the interface from the included XML file --- src/indicator-messages.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/indicator-messages.c b/src/indicator-messages.c index b57244c..7608678 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -26,8 +26,6 @@ with this program. If not, see . #include #include #include -#include -#include #include #include @@ -35,7 +33,7 @@ with this program. If not, see . #include #include "dbus-data.h" -#include "messages-service-client.h" +#include "gen-messages-service.xml.h" #define INDICATOR_MESSAGES_TYPE (indicator_messages_get_type ()) #define INDICATOR_MESSAGES(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), INDICATOR_MESSAGES_TYPE, IndicatorMessages)) @@ -69,8 +67,10 @@ INDICATOR_SET_TYPE(INDICATOR_MESSAGES_TYPE) /* Globals */ static GtkWidget * main_image = NULL; -static DBusGProxy * icon_proxy = NULL; +static GDBusProxy * icon_proxy = NULL; static GtkSizeGroup * indicator_right_group = NULL; +static GDBusNodeInfo * bus_node_info = NULL; +static GDBusInterfaceInfo * bus_interface_info = NULL; /* Prototypes */ static void indicator_messages_class_init (IndicatorMessagesClass *klass); @@ -99,6 +99,24 @@ indicator_messages_class_init (IndicatorMessagesClass *klass) io_class->get_image = get_icon; io_class->get_menu = get_menu; + if (bus_node_info == NULL) { + GError * error = NULL; + + bus_node_info = g_dbus_node_info_new_for_xml(_messages_service, &error); + if (error != NULL) { + g_error("Unable to parse Messaging Menu Interface description: %s", error->message); + g_error_free(error); + } + } + + if (bus_interface_info == NULL) { + bus_interface_info = g_dbus_node_info_lookup_interface(bus_node_info, INDICATOR_MESSAGES_DBUS_SERVICE_INTERFACE); + + if (bus_interface_info == NULL) { + g_error("Unable to find interface '" INDICATOR_MESSAGES_DBUS_SERVICE_INTERFACE "'"); + } + } + return; } -- cgit v1.2.3 From 4792855a9b4d615993df48f7e4595f9ca2baf582 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 14 Jan 2011 12:54:55 -0600 Subject: Changing the creation of the proxy --- src/indicator-messages.c | 94 ++++++++++++++++++++++++++++++++---------------- 1 file changed, 63 insertions(+), 31 deletions(-) (limited to 'src') diff --git a/src/indicator-messages.c b/src/indicator-messages.c index 7608678..638b484 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -227,6 +227,43 @@ connection_drop_cb (gpointer user_data) return FALSE; } +/* Proxy is setup now.. whoo! */ +static void +proxy_ready_cb (GObject * obj, GAsyncResult * res, gpointer user_data) +{ + GError * error = NULL; + GDBusProxy * proxy = g_dbus_proxy_new_for_bus_finish(res, &error); + + if (error != NULL) { + g_warning("Unable to get proxy of service: %s", error->message); + g_error_free(error); + return; + } + + icon_proxy = proxy; + + g_signal_connect(G_OBJECT(proxy), "g-signal", G_CALLBACK(proxy_signal), user_data); + + g_dbus_proxy_call(icon_proxy, + "AttentionRequested", + NULL, /* params */ + G_DBUS_CALL_FLAGS_NONE, + -1, /* timeout */ + NULL, /* cancel */ + attention_cb, + sm); + g_dbus_proxy_call(icon_proxy, + "IconShown", + NULL, /* params */ + G_DBUS_CALL_FLAGS_NONE, + -1, /* timeout */ + NULL, /* cancel */ + icon_cb, + sm); + + return; +} + /* Sets up all the icon information in the proxy. */ static void connection_change (IndicatorServiceManager * sm, gboolean connected, gpointer user_data) @@ -243,40 +280,35 @@ connection_change (IndicatorServiceManager * sm, gboolean connected, gpointer us return; } - DBusGConnection * connection = dbus_g_bus_get(DBUS_BUS_SESSION, NULL); - if (connection == NULL) { - g_warning("Unable to get session bus"); - return; - } - if (icon_proxy == NULL) { - 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; - } - - 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), - NULL, - NULL); + g_dbus_proxy_new_for_bus(G_BUS_SESSION, + G_DBUS_PROXY_FLAGS_NONE, + bus_interface_info, + INDICATOR_MESSAGES_DBUS_NAME, + INDICATOR_MESSAGES_DBUS_SERVICE_OBJECT, + INDICATOR_MESSAGES_DBUS_SERVICE_INTERFACE, + NULL, /* cancel */ + proxy_ready_cb, + sm); + } else { + g_dbus_proxy_call(icon_proxy, + "AttentionRequested", + NULL, /* params */ + G_DBUS_CALL_FLAGS_NONE, + -1, /* timeout */ + NULL, /* cancel */ + attention_cb, + sm); + g_dbus_proxy_call(icon_proxy, + "IconShown", + NULL, /* params */ + G_DBUS_CALL_FLAGS_NONE, + -1, /* timeout */ + NULL, /* cancel */ + icon_cb, + sm); } - 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; } -- cgit v1.2.3 From e8ae85455165c6ab3040c53fa66652f78cb86bbb Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 14 Jan 2011 12:59:30 -0600 Subject: Changing the signal callbacks --- src/indicator-messages.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/indicator-messages.c b/src/indicator-messages.c index 638b484..6604100 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -163,27 +163,28 @@ indicator_messages_finalize (GObject *object) /* Functions */ -/* Called everytime the attention changes in the service. */ +/* Signal off of the proxy */ static void -attention_changed_cb (DBusGProxy * proxy, gboolean dot, gpointer userdata) +proxy_signal (GDBusProxy * proxy, const gchar * sender, const gchar * signal, GVariant * params, gpointer user_data) { - if (dot) { - indicator_image_helper_update(GTK_IMAGE(main_image), "indicator-messages-new"); - } else { - indicator_image_helper_update(GTK_IMAGE(main_image), "indicator-messages"); - } - return; -} + gboolean prop = g_variant_get_boolean(g_variant_get_child_value(params, 0)); -/* Change the icon to whether it should be visible or not */ -static void -icon_changed_cb (DBusGProxy * proxy, gboolean hidden, gpointer userdata) -{ - if (hidden) { - gtk_widget_hide(main_image); + if (g_strcmp0("AttentionChanged", signal) == 0) { + if (prop) { + indicator_image_helper_update(GTK_IMAGE(main_image), "indicator-messages-new"); + } else { + indicator_image_helper_update(GTK_IMAGE(main_image), "indicator-messages"); + } + } else if (g_strcmp0("IconChanged", signal) == 0) { + if (prop) { + gtk_widget_hide(main_image); + } else { + gtk_widget_show(main_image); + } } else { - gtk_widget_show(main_image); + g_warning("Unknown signal %s", signal); } + return; } -- cgit v1.2.3 From b141e4fe3dc5c1c86180a7f1a9b18d39ec44bc22 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 14 Jan 2011 13:05:27 -0600 Subject: Switching the function callbacks --- src/indicator-messages.c | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/indicator-messages.c b/src/indicator-messages.c index 6604100..cb435c4 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -190,28 +190,50 @@ proxy_signal (GDBusProxy * proxy, const gchar * sender, const gchar * signal, GV /* Callback from getting the attention status from the service. */ static void -attention_cb (DBusGProxy * proxy, gboolean dot, GError * error, gpointer userdata) +attention_cb (GObject * object, GAsyncResult * ares, gpointer user_data) { + GError * error = NULL; + GVariant * res = g_dbus_proxy_call_finish(G_DBUS_PROXY(object), ares, &error); + if (error != NULL) { g_warning("Unable to get attention status: %s", error->message); g_error_free(error); return; } - return attention_changed_cb(proxy, dot, userdata); + gboolean prop = g_variant_get_boolean(g_variant_get_child_value(res, 0)); + + if (prop) { + indicator_image_helper_update(GTK_IMAGE(main_image), "indicator-messages-new"); + } else { + indicator_image_helper_update(GTK_IMAGE(main_image), "indicator-messages"); + } + + return; } /* Change from getting the icon visibility from the service */ static void -icon_cb (DBusGProxy * proxy, gboolean hidden, GError * error, gpointer userdata) +icon_cb (GObject * object, GAsyncResult * ares, gpointer user_data) { + GError * error = NULL; + GVariant * res = g_dbus_proxy_call_finish(G_DBUS_PROXY(object), ares, &error); + if (error != NULL) { g_warning("Unable to get icon visibility: %s", error->message); g_error_free(error); return; } - return icon_changed_cb(proxy, hidden, userdata); + gboolean prop = g_variant_get_boolean(g_variant_get_child_value(res, 0)); + + if (prop) { + gtk_widget_hide(main_image); + } else { + gtk_widget_show(main_image); + } + + return; } static guint connection_drop_timeout = 0; @@ -252,7 +274,7 @@ proxy_ready_cb (GObject * obj, GAsyncResult * res, gpointer user_data) -1, /* timeout */ NULL, /* cancel */ attention_cb, - sm); + user_data); g_dbus_proxy_call(icon_proxy, "IconShown", NULL, /* params */ @@ -260,7 +282,7 @@ proxy_ready_cb (GObject * obj, GAsyncResult * res, gpointer user_data) -1, /* timeout */ NULL, /* cancel */ icon_cb, - sm); + user_data); return; } -- cgit v1.2.3 From 5f18bbc4b0789b75868e07627da88dcafb478bab Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 14 Jan 2011 13:07:27 -0600 Subject: Type to session --- src/indicator-messages.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/indicator-messages.c b/src/indicator-messages.c index cb435c4..1c2cfeb 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -304,7 +304,7 @@ connection_change (IndicatorServiceManager * sm, gboolean connected, gpointer us } if (icon_proxy == NULL) { - g_dbus_proxy_new_for_bus(G_BUS_SESSION, + g_dbus_proxy_new_for_bus(G_BUS_TYPE_SESSION, G_DBUS_PROXY_FLAGS_NONE, bus_interface_info, INDICATOR_MESSAGES_DBUS_NAME, -- cgit v1.2.3 From c53751d07949b38ad75e794a43a6272634507ee1 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 14 Jan 2011 13:10:10 -0600 Subject: Switch to new dbusmenu signal prototype --- src/indicator-messages.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/indicator-messages.c b/src/indicator-messages.c index 1c2cfeb..6fd6c5c 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -337,12 +337,12 @@ connection_change (IndicatorServiceManager * sm, gboolean connected, gpointer us /* Sets the icon when it changes. */ static void -application_icon_change_cb (DbusmenuMenuitem * mi, gchar * prop, GValue * value, gpointer user_data) +application_icon_change_cb (DbusmenuMenuitem * mi, gchar * prop, GVariant * 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); + gtk_image_set_from_icon_name(GTK_IMAGE(user_data), g_variant_get_string(value, NULL), GTK_ICON_SIZE_MENU); } } @@ -351,12 +351,12 @@ application_icon_change_cb (DbusmenuMenuitem * mi, gchar * prop, GValue * value, /* Sets the label when it changes. */ static void -application_prop_change_cb (DbusmenuMenuitem * mi, gchar * prop, GValue * value, gpointer user_data) +application_prop_change_cb (DbusmenuMenuitem * mi, gchar * prop, GVariant * 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)); + gtk_label_set_text(GTK_LABEL(user_data), g_variant_get_string(value, NULL)); } } @@ -545,14 +545,14 @@ struct _indicator_item_t { /* Whenever we have a property change on a DbusmenuMenuitem we need to be responsive to that. */ static void -indicator_prop_change_cb (DbusmenuMenuitem * mi, gchar * prop, GValue * value, indicator_item_t * mi_data) +indicator_prop_change_cb (DbusmenuMenuitem * mi, gchar * prop, GVariant * value, indicator_item_t * mi_data) { if (!g_strcmp0(prop, INDICATOR_MENUITEM_PROP_LABEL)) { /* Set the main label */ - gtk_label_set_text(GTK_LABEL(mi_data->label), g_value_get_string(value)); + gtk_label_set_text(GTK_LABEL(mi_data->label), g_variant_get_string(value, NULL)); } else if (!g_strcmp0(prop, INDICATOR_MENUITEM_PROP_RIGHT)) { /* Set the right label */ - gtk_label_set_text(GTK_LABEL(mi_data->right), g_value_get_string(value)); + gtk_label_set_text(GTK_LABEL(mi_data->right), g_variant_get_string(value, NULL)); } else if (!g_strcmp0(prop, INDICATOR_MENUITEM_PROP_ICON)) { /* We don't use the value here, which is probably less efficient, but it's easier to use the easy function. And since th value -- cgit v1.2.3 From 26ceab5a8b4e80711f5cd7ed0bda4a28f3113429 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 14 Jan 2011 13:13:43 -0600 Subject: Switching how we get our interface info --- src/messages-service-dbus.c | 24 +++++++++++++++++++++--- src/messages-service.c | 1 - 2 files changed, 21 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/messages-service-dbus.c b/src/messages-service-dbus.c index d9c0e8d..6ed6678 100644 --- a/src/messages-service-dbus.c +++ b/src/messages-service-dbus.c @@ -24,9 +24,10 @@ with this program. If not, see . #include "config.h" #endif -#include +#include #include "messages-service-dbus.h" #include "dbus-data.h" +#include "gen-messages-service.xml.h" enum { ATTENTION_CHANGED, @@ -56,10 +57,12 @@ static void _messages_service_server_watch (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" +static GDBusNodeInfo * bus_node_info = NULL; +static GDBusInterfaceInfo * bus_interface_info = NULL; G_DEFINE_TYPE (MessageServiceDbus, message_service_dbus, G_TYPE_OBJECT); + static void message_service_dbus_class_init (MessageServiceDbusClass *klass) { @@ -86,8 +89,23 @@ message_service_dbus_class_init (MessageServiceDbusClass *klass) g_cclosure_marshal_VOID__BOOLEAN, G_TYPE_NONE, 1, G_TYPE_BOOLEAN); + if (bus_node_info == NULL) { + GError * error = NULL; + + bus_node_info = g_dbus_node_info_new_for_xml(_messages_service, &error); + if (error != NULL) { + g_error("Unable to parse Messaging Menu Interface description: %s", error->message); + g_error_free(error); + } + } - dbus_g_object_type_install_info(MESSAGE_SERVICE_DBUS_TYPE, &dbus_glib__messages_service_server_object_info); + if (bus_interface_info == NULL) { + bus_interface_info = g_dbus_node_info_lookup_interface(bus_node_info, INDICATOR_MESSAGES_DBUS_SERVICE_INTERFACE); + + if (bus_interface_info == NULL) { + g_error("Unable to find interface '" INDICATOR_MESSAGES_DBUS_SERVICE_INTERFACE "'"); + } + } return; } diff --git a/src/messages-service.c b/src/messages-service.c index b87c2ff..e3352e8 100644 --- a/src/messages-service.c +++ b/src/messages-service.c @@ -25,7 +25,6 @@ with this program. If not, see . #include #include #include -#include #include #include #include -- cgit v1.2.3 From 490cde29b6d70c7abad6b6ff90609e64fd2af409 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 14 Jan 2011 13:20:33 -0600 Subject: Get the connection in the cool new style --- src/messages-service-dbus.c | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/messages-service-dbus.c b/src/messages-service-dbus.c index 6ed6678..aeda625 100644 --- a/src/messages-service-dbus.c +++ b/src/messages-service-dbus.c @@ -110,13 +110,41 @@ message_service_dbus_class_init (MessageServiceDbusClass *klass) return; } +static void +connection_cb (GObject * object, GAsyncResult * res, gpointer user_data) +{ + GError * error = NULL; + GDBusConnection * connection = g_bus_get_finish(res, &error); + + if (error != NULL) { + g_error("Unable to connect to the session bus: %s", error->message); + g_error_free(error); + return; + } + + g_dbus_connection_register_object(connection, + INDICATOR_MESSAGES_DBUS_SERVICE_OBJECT, + bus_interface_info, + bus_vtable, + user_data, + NULL, /* destroy */ + &error); + + if (error != NULL) { + g_error("Unable to register on session bus: %s", error->message); + g_error_free(error); + return; + } + + g_debug("Service on session bus"); + + 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)); + g_bus_get(G_BUS_TYPE_SESSION, NULL, connection_cb, self); MessageServiceDbusPrivate * priv = MESSAGE_SERVICE_DBUS_GET_PRIVATE(self); -- cgit v1.2.3 From 39268f3a9830cb76aaf644d540dfe771fde4eebf Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 14 Jan 2011 13:23:07 -0600 Subject: Setting up the vtable and making it connect in --- src/messages-service-dbus.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/messages-service-dbus.c b/src/messages-service-dbus.c index aeda625..e333772 100644 --- a/src/messages-service-dbus.c +++ b/src/messages-service-dbus.c @@ -52,6 +52,14 @@ 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 bus_method_call (GDBusConnection * connection, + const gchar * sender, + const gchar * path, + const gchar * interface, + const gchar * method, + GVariant * params, + GDBusMethodInvocation * invocation, + gpointer user_data); static void _messages_service_server_watch (void); static gboolean _messages_service_server_attention_requested (MessageServiceDbus * self, gboolean * dot, GError ** error); @@ -59,6 +67,11 @@ static gboolean _messages_service_server_icon_shown (MessageServiceDbus * self, static GDBusNodeInfo * bus_node_info = NULL; static GDBusInterfaceInfo * bus_interface_info = NULL; +static const GDBusInterfaceVTable bus_interface_table = { + method_call: bus_method_call, + get_property: NULL, /* No properties */ + set_property: NULL /* No properties */ +}; G_DEFINE_TYPE (MessageServiceDbus, message_service_dbus, G_TYPE_OBJECT); @@ -125,7 +138,7 @@ connection_cb (GObject * object, GAsyncResult * res, gpointer user_data) g_dbus_connection_register_object(connection, INDICATOR_MESSAGES_DBUS_SERVICE_OBJECT, bus_interface_info, - bus_vtable, + &bus_interface_table, user_data, NULL, /* destroy */ &error); -- cgit v1.2.3 From 05e767ce2daf9cca389f482b4c8ad72c375944f5 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 14 Jan 2011 13:26:40 -0600 Subject: Swiching to our method function.. woot! --- src/messages-service-dbus.c | 38 +++++++++++++------------------------- 1 file changed, 13 insertions(+), 25 deletions(-) (limited to 'src') diff --git a/src/messages-service-dbus.c b/src/messages-service-dbus.c index e333772..1a9564b 100644 --- a/src/messages-service-dbus.c +++ b/src/messages-service-dbus.c @@ -61,10 +61,6 @@ static void bus_method_call (GDBusConnection * connection, GDBusMethodInvocation * invocation, gpointer user_data); -static void _messages_service_server_watch (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); - static GDBusNodeInfo * bus_node_info = NULL; static GDBusInterfaceInfo * bus_interface_info = NULL; static const GDBusInterfaceVTable bus_interface_table = { @@ -191,31 +187,23 @@ 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 */ +/* Method request off of DBus */ static void -_messages_service_server_watch (void) +bus_method_call (GDBusConnection * connection, const gchar * sender, const gchar * path, const gchar * interface, const gchar * method, GVariant * params, GDBusMethodInvocation * invocation, gpointer user_data) { + MessageServiceDbusPrivate * priv = MESSAGE_SERVICE_DBUS_GET_PRIVATE(user_data); -} - -/* 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) -{ - MessageServiceDbusPrivate * priv = MESSAGE_SERVICE_DBUS_GET_PRIVATE(self); - *dot = priv->dot; - return TRUE; -} + if (g_strcmp0("AttentionRequested", method) == 0) { + g_dbus_method_invocation_return_value(invocation, g_variant_new("(b)", priv->dot)); + return; + } else if (g_strcmp0("IconShown", method) == 0) { + g_dbus_method_invocation_return_value(invocation, g_variant_new("(b)", priv->hidden)); + return; + } else { + g_warning("Unknown function call '%s'", method); + } -/* 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) -{ - MessageServiceDbusPrivate * priv = MESSAGE_SERVICE_DBUS_GET_PRIVATE(self); - *hidden = priv->hidden; - return TRUE; + return; } void -- cgit v1.2.3 From 4ef2895a07690c2c4ffaa07ac426f85ef702584d Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 14 Jan 2011 13:29:07 -0600 Subject: Saving the connection --- src/messages-service-dbus.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src') diff --git a/src/messages-service-dbus.c b/src/messages-service-dbus.c index 1a9564b..44b35aa 100644 --- a/src/messages-service-dbus.c +++ b/src/messages-service-dbus.c @@ -41,6 +41,7 @@ typedef struct _MessageServiceDbusPrivate MessageServiceDbusPrivate; struct _MessageServiceDbusPrivate { + GDBusConnection * connection; gboolean dot; gboolean hidden; }; @@ -131,6 +132,9 @@ connection_cb (GObject * object, GAsyncResult * res, gpointer user_data) return; } + MessageServiceDbusPrivate * priv = MESSAGE_SERVICE_DBUS_GET_PRIVATE(user_data); + priv->connection = connection; + g_dbus_connection_register_object(connection, INDICATOR_MESSAGES_DBUS_SERVICE_OBJECT, bus_interface_info, @@ -166,7 +170,12 @@ message_service_dbus_init (MessageServiceDbus *self) static void message_service_dbus_dispose (GObject *object) { + MessageServiceDbusPrivate * priv = MESSAGE_SERVICE_DBUS_GET_PRIVATE(object); + if (priv->connection != NULL) { + g_object_unref(priv->connection); + priv->connection = NULL; + } G_OBJECT_CLASS (message_service_dbus_parent_class)->dispose (object); return; -- cgit v1.2.3 From e7dd62a02e53fb7b36758c67b060f42a28c4efc6 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 14 Jan 2011 13:32:24 -0600 Subject: Emitting signals for the connections --- src/messages-service-dbus.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src') diff --git a/src/messages-service-dbus.c b/src/messages-service-dbus.c index 44b35aa..6cc33e0 100644 --- a/src/messages-service-dbus.c +++ b/src/messages-service-dbus.c @@ -223,6 +223,16 @@ message_service_dbus_set_attention (MessageServiceDbus * self, gboolean attentio if (attention != priv->dot) { priv->dot = attention; g_signal_emit(G_OBJECT(self), signals[ATTENTION_CHANGED], 0, priv->dot, TRUE); + + if (priv->connection != NULL) { + g_dbus_connection_emit_signal(priv->connection, + NULL, + INDICATOR_MESSAGES_DBUS_SERVICE_OBJECT, + INDICATOR_MESSAGES_DBUS_SERVICE_INTERFACE, + "AttentionChanged", + g_variant_new("(b)", priv->dot), + NULL); + } } return; } @@ -235,6 +245,16 @@ message_service_dbus_set_icon (MessageServiceDbus * self, gboolean hidden) if (hidden != priv->hidden) { priv->hidden = hidden; g_signal_emit(G_OBJECT(self), signals[ICON_CHANGED], 0, priv->hidden, TRUE); + + if (priv->connection != NULL) { + g_dbus_connection_emit_signal(priv->connection, + NULL, + INDICATOR_MESSAGES_DBUS_SERVICE_OBJECT, + INDICATOR_MESSAGES_DBUS_SERVICE_INTERFACE, + "IconChanged", + g_variant_new("(b)", priv->hidden), + NULL); + } } return; } -- cgit v1.2.3 From e7586d7f8bc699076912a67b194adca8a76b8066 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 14 Jan 2011 13:35:21 -0600 Subject: Prototype changes --- src/app-menu-item.c | 8 ++++---- src/im-menu-item.c | 14 +++++++------- 2 files changed, 11 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/app-menu-item.c b/src/app-menu-item.c index 0b0588e..e846914 100644 --- a/src/app-menu-item.c +++ b/src/app-menu-item.c @@ -70,8 +70,8 @@ static void app_menu_item_finalize (GObject *object); static void activate_cb (AppMenuItem * self, guint timestamp, gpointer data); static void count_changed (IndicateListener * listener, IndicateListenerServer * server, guint count, gpointer data); static void count_cb (IndicateListener * listener, IndicateListenerServer * server, guint value, gpointer data); -static void menu_cb (IndicateListener * listener, IndicateListenerServer * server, gchar * menupath, gpointer data); -static void desktop_cb (IndicateListener * listener, IndicateListenerServer * server, gchar * value, gpointer data); +static void menu_cb (IndicateListener * listener, IndicateListenerServer * server, const gchar * menupath, gpointer data); +static void desktop_cb (IndicateListener * listener, IndicateListenerServer * server, const gchar * value, gpointer data); static void update_label (AppMenuItem * self); /* GObject Boilerplate */ @@ -300,7 +300,7 @@ count_cb (IndicateListener * listener, IndicateListenerServer * server, guint va app structure and start sucking data out of it. Mostly the name. */ static void -desktop_cb (IndicateListener * listener, IndicateListenerServer * server, gchar * value, gpointer data) +desktop_cb (IndicateListener * listener, IndicateListenerServer * server, const gchar * value, gpointer data) { g_return_if_fail(IS_APP_MENU_ITEM(data)); AppMenuItem * self = APP_MENU_ITEM(data); @@ -469,7 +469,7 @@ root_changed (DbusmenuClient * client, DbusmenuMenuitem * newroot, gpointer data /* Gets the path to menuitems if there are some. Now we need to make them special. */ static void -menu_cb (IndicateListener * listener, IndicateListenerServer * server, gchar * menupath, gpointer data) +menu_cb (IndicateListener * listener, IndicateListenerServer * server, const gchar * menupath, gpointer data) { g_debug("Got Menu: %s", menupath); g_return_if_fail(IS_APP_MENU_ITEM(data)); diff --git a/src/im-menu-item.c b/src/im-menu-item.c index b8b3709..25fea52 100644 --- a/src/im-menu-item.c +++ b/src/im-menu-item.c @@ -358,7 +358,7 @@ count_cb (IndicateListener * listener, IndicateListenerServer * server, Indicate 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, const GValue * propertydata, gpointer data) +attention_cb (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * property, GVariant * propertydata, gpointer data) { g_debug("Got Attention Information"); ImMenuItem * self = IM_MENU_ITEM(data); @@ -373,10 +373,10 @@ attention_cb (IndicateListener * listener, IndicateListenerServer * server, Indi ImMenuItemPrivate * priv = IM_MENU_ITEM_GET_PRIVATE(self); gboolean wantit; - if (G_VALUE_HOLDS_BOOLEAN(propertydata)) { - wantit = g_value_get_boolean(propertydata); - } else if (G_VALUE_HOLDS_STRING(propertydata)) { - const gchar * propstring = g_value_get_string(propertydata); + if (g_variant_is_of_type(propertydata, G_VARIANT_TYPE_BOOLEAN)) { + wantit = g_variant_get_boolean(propertydata); + } else if (g_variant_is_of_type(propertydata, G_VARIANT_TYPE_STRING)) { + const gchar * propstring = g_variant_get_string(propertydata, NULL); if (propstring == NULL || propstring[0] == '\0' || !g_strcmp0(propstring, "false")) { wantit = FALSE; @@ -427,7 +427,7 @@ indicator_modified_cb (IndicateListener * listener, IndicateListenerServer * ser } 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_value(listener, server, indicator, INDICATE_INDICATOR_MESSAGES_PROP_ATTENTION, attention_cb, self); + indicate_listener_get_property_variant(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."); @@ -460,7 +460,7 @@ im_menu_item_new (IndicateListener * listener, IndicateListenerServer * server, 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_value(listener, server, indicator, INDICATE_INDICATOR_MESSAGES_PROP_ATTENTION, attention_cb, self); + indicate_listener_get_property_variant(listener, server, indicator, INDICATE_INDICATOR_MESSAGES_PROP_ATTENTION, attention_cb, self); indicate_listener_get_property(listener, server, indicator, "sender", sender_cb, self); g_signal_connect(G_OBJECT(self), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(activate_cb), NULL); -- cgit v1.2.3 From beeedd035387f5c106b3270c9fdd6f9676f557ee Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 14 Jan 2011 14:19:48 -0600 Subject: ayatana.org to canonical.com --- src/dbus-data.h | 8 ++++---- src/messages-service.xml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/dbus-data.h b/src/dbus-data.h index 100ac0a..abff3aa 100644 --- a/src/dbus-data.h +++ b/src/dbus-data.h @@ -2,11 +2,11 @@ #ifndef __DBUS_DATA_H__ #define __DBUS_DATA_H__ 1 -#define INDICATOR_MESSAGES_DBUS_NAME "org.ayatana.indicator.messages" -#define INDICATOR_MESSAGES_DBUS_OBJECT "/org/ayatana/indicator/messages/menu" +#define INDICATOR_MESSAGES_DBUS_NAME "com.canonical.indicator.messages" +#define INDICATOR_MESSAGES_DBUS_OBJECT "/com/canonical/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" +#define INDICATOR_MESSAGES_DBUS_SERVICE_OBJECT "/com/canonical/indicator/messages/service" +#define INDICATOR_MESSAGES_DBUS_SERVICE_INTERFACE "com.canonical.indicator.messages.service" #define APPLICATION_MENUITEM_TYPE "application-item" #define APPLICATION_MENUITEM_PROP_NAME "label" diff --git a/src/messages-service.xml b/src/messages-service.xml index f991179..8a592db 100644 --- a/src/messages-service.xml +++ b/src/messages-service.xml @@ -1,6 +1,6 @@ - + -- cgit v1.2.3 From e659a394b8af69907029c16488be3c010bd7f21d Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 17 Jan 2011 12:04:11 -0600 Subject: Adding in log domains --- src/Makefile.am | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index dd09b8a..8597d77 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -12,7 +12,14 @@ libmessaging_la_SOURCES = \ gen-messages-service.xml.h \ gen-messages-service.xml.c \ dbus-data.h -libmessaging_la_CFLAGS = $(APPLET_CFLAGS) -Wall -Wl,-Bsymbolic-functions -Wl,-z,defs -Wl,--as-needed -Werror +libmessaging_la_CFLAGS = \ + $(APPLET_CFLAGS) \ + -Wall \ + -Wl,-Bsymbolic-functions \ + -Wl,-z,defs \ + -Wl,--as-needed \ + -Werror \ + -DG_LOG_DOMAIN=\"Indicator-Messages\" libmessaging_la_LIBADD = $(APPLET_LIBS) libmessaging_la_LDFLAGS = -module -avoid-version @@ -38,7 +45,14 @@ indicator_messages_service_SOURCES = \ seen-db.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_CFLAGS = \ + $(APPLET_CFLAGS) \ + -Wall \ + -Wl,-Bsymbolic-functions \ + -Wl,-z,defs \ + -Wl,--as-needed \ + -Werror \ + -DG_LOG_DOMAIN=\"Indicator-Messages\" indicator_messages_service_LDADD = $(APPLET_LIBS) gen-%.xml.h: %.xml -- cgit v1.2.3 From d6519fb4f6cd5ed4eaeeae4a8cceb14787a25695 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 27 Jan 2011 16:57:04 -0600 Subject: Upgrading to new type handler prototype --- src/indicator-messages.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/indicator-messages.c b/src/indicator-messages.c index 6fd6c5c..8a94a85 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -489,7 +489,7 @@ numbers_draw_cb (GtkWidget *widget, GdkEventExpose *event, gpointer data) /* Builds a menu item representing a running application in the messaging menu */ static gboolean -new_application_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client) +new_application_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client, gpointer user_data) { g_debug ("%s (\"%s\")", __func__, dbusmenu_menuitem_property_get(newitem, APPLICATION_MENUITEM_PROP_NAME)); @@ -597,7 +597,7 @@ indicator_prop_change_cb (DbusmenuMenuitem * mi, gchar * prop, GVariant * value, 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) +new_indicator_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client, gpointer user_data) { g_return_val_if_fail(DBUSMENU_IS_MENUITEM(newitem), FALSE); g_return_val_if_fail(DBUSMENU_IS_GTKCLIENT(client), FALSE); -- cgit v1.2.3 From cbf07a1b51b423cf125456622f7f48b9c81c89ff Mon Sep 17 00:00:00 2001 From: Luke Yelavich Date: Mon, 14 Feb 2011 17:50:27 +1100 Subject: Add accessible description support --- src/indicator-messages.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'src') diff --git a/src/indicator-messages.c b/src/indicator-messages.c index 8a94a85..ebf670d 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -23,6 +23,7 @@ with this program. If not, see . #include #include #include +#include #include #include #include @@ -52,6 +53,7 @@ typedef struct _IndicatorMessagesClass IndicatorMessagesClass; struct _IndicatorMessagesClass { IndicatorObjectClass parent_class; + void (*update_a11y_desc) (IndicatorServiceManager * service, gpointer * user_data); }; struct _IndicatorMessages { @@ -71,6 +73,8 @@ static GDBusProxy * icon_proxy = NULL; static GtkSizeGroup * indicator_right_group = NULL; static GDBusNodeInfo * bus_node_info = NULL; static GDBusInterfaceInfo * bus_interface_info = NULL; +static const gchar * accessible_desc = NULL; +static IndicatorObject * indicator = NULL; /* Prototypes */ static void indicator_messages_class_init (IndicatorMessagesClass *klass); @@ -79,12 +83,26 @@ static void indicator_messages_dispose (GObject *object); static void indicator_messages_finalize (GObject *object); static GtkImage * get_icon (IndicatorObject * io); static GtkMenu * get_menu (IndicatorObject * io); +static const gchar * get_accessible_desc (IndicatorObject * io); static void connection_change (IndicatorServiceManager * sm, gboolean connected, gpointer user_data); G_DEFINE_TYPE (IndicatorMessages, indicator_messages, INDICATOR_OBJECT_TYPE); +static void +update_a11y_desc (void) +{ + g_return_if_fail(IS_INDICATOR_MESSAGES(indicator)); + + g_signal_emit(G_OBJECT(indicator), + INDICATOR_OBJECT_SIGNAL_ACCESSIBLE_DESC_UPDATE_ID, + 0, + (IndicatorObjectEntry *)indicator_object_get_entries(indicator)->data, + TRUE); + return; +} + /* Initialize the one-timers */ static void indicator_messages_class_init (IndicatorMessagesClass *klass) @@ -98,6 +116,7 @@ indicator_messages_class_init (IndicatorMessagesClass *klass) io_class->get_image = get_icon; io_class->get_menu = get_menu; + io_class->get_accessible_desc = get_accessible_desc; if (bus_node_info == NULL) { GError * error = NULL; @@ -131,6 +150,8 @@ indicator_messages_init (IndicatorMessages *self) self->service = indicator_service_manager_new_version(INDICATOR_MESSAGES_DBUS_NAME, 1); g_signal_connect(self->service, INDICATOR_SERVICE_MANAGER_SIGNAL_CONNECTION_CHANGE, G_CALLBACK(connection_change), self); + indicator = INDICATOR_OBJECT(self); + return; } @@ -172,8 +193,10 @@ proxy_signal (GDBusProxy * proxy, const gchar * sender, const gchar * signal, GV if (g_strcmp0("AttentionChanged", signal) == 0) { if (prop) { indicator_image_helper_update(GTK_IMAGE(main_image), "indicator-messages-new"); + accessible_desc = g_strdup(_("New Messages")); } else { indicator_image_helper_update(GTK_IMAGE(main_image), "indicator-messages"); + accessible_desc = g_strdup(_("Messages")); } } else if (g_strcmp0("IconChanged", signal) == 0) { if (prop) { @@ -185,6 +208,8 @@ proxy_signal (GDBusProxy * proxy, const gchar * sender, const gchar * signal, GV g_warning("Unknown signal %s", signal); } + update_a11y_desc(); + return; } @@ -205,10 +230,14 @@ attention_cb (GObject * object, GAsyncResult * ares, gpointer user_data) if (prop) { indicator_image_helper_update(GTK_IMAGE(main_image), "indicator-messages-new"); + accessible_desc = g_strdup(_("New Messages")); } else { indicator_image_helper_update(GTK_IMAGE(main_image), "indicator-messages"); + accessible_desc = g_strdup(_("Messages")); } + update_a11y_desc(); + return; } @@ -705,3 +734,10 @@ get_menu (IndicatorObject * io) return GTK_MENU(menu); } + +/* Returns the accessible description of the indicator */ +static const gchar * +get_accessible_desc (IndicatorObject * io) +{ + return accessible_desc; +} -- cgit v1.2.3 From a8a74beaa9b5b368a037c9b2fb592a89cb43ecc0 Mon Sep 17 00:00:00 2001 From: Luke Yelavich Date: Thu, 17 Feb 2011 09:56:38 +1100 Subject: No need to use g_strdup, the variable is a const --- src/indicator-messages.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/indicator-messages.c b/src/indicator-messages.c index ebf670d..77a7b70 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -193,10 +193,10 @@ proxy_signal (GDBusProxy * proxy, const gchar * sender, const gchar * signal, GV if (g_strcmp0("AttentionChanged", signal) == 0) { if (prop) { indicator_image_helper_update(GTK_IMAGE(main_image), "indicator-messages-new"); - accessible_desc = g_strdup(_("New Messages")); + accessible_desc = _("New Messages"); } else { indicator_image_helper_update(GTK_IMAGE(main_image), "indicator-messages"); - accessible_desc = g_strdup(_("Messages")); + accessible_desc = _("Messages"); } } else if (g_strcmp0("IconChanged", signal) == 0) { if (prop) { -- cgit v1.2.3 From 633b340034c355a8c2883894f5c61824184a59fa Mon Sep 17 00:00:00 2001 From: Luke Yelavich Date: Thu, 17 Feb 2011 11:14:11 +1100 Subject: Store entry data in a variable so it can be freed after signaling an accessible description change, preventing a memory leak. --- src/indicator-messages.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/indicator-messages.c b/src/indicator-messages.c index 77a7b70..9c57856 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -94,12 +94,15 @@ static void update_a11y_desc (void) { g_return_if_fail(IS_INDICATOR_MESSAGES(indicator)); + GList *entry = indicator_object_get_entries(indicator); g_signal_emit(G_OBJECT(indicator), INDICATOR_OBJECT_SIGNAL_ACCESSIBLE_DESC_UPDATE_ID, - 0, - (IndicatorObjectEntry *)indicator_object_get_entries(indicator)->data, + 0, + entry->data, TRUE); + g_list_free(entry); + return; } -- cgit v1.2.3 From e1c268aa248f8998497221a0245796a943980ef5 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 17 Feb 2011 11:59:42 -0600 Subject: Updating the description when we signal that it's changed --- src/indicator-messages.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/indicator-messages.c b/src/indicator-messages.c index 9c57856..aff4785 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -94,14 +94,19 @@ static void update_a11y_desc (void) { g_return_if_fail(IS_INDICATOR_MESSAGES(indicator)); - GList *entry = indicator_object_get_entries(indicator); + + GList *entries = indicator_object_get_entries(indicator); + IndicatorObjectEntry * entry = (IndicatorObjectEntry *)entries->data; + + entry->accessible_desc = get_accessible_desc(indicator); g_signal_emit(G_OBJECT(indicator), INDICATOR_OBJECT_SIGNAL_ACCESSIBLE_DESC_UPDATE_ID, 0, - entry->data, - TRUE); - g_list_free(entry); + entry, + TRUE); + + g_list_free(entries); return; } -- cgit v1.2.3 From 22fe0467f3be10a6f05c7d3e9f72cce94cf02d35 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 17 Feb 2011 12:04:32 -0600 Subject: Removing an unneeded strdup --- src/indicator-messages.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/indicator-messages.c b/src/indicator-messages.c index aff4785..ed6caa6 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -238,10 +238,10 @@ attention_cb (GObject * object, GAsyncResult * ares, gpointer user_data) if (prop) { indicator_image_helper_update(GTK_IMAGE(main_image), "indicator-messages-new"); - accessible_desc = g_strdup(_("New Messages")); + accessible_desc = _("New Messages"); } else { indicator_image_helper_update(GTK_IMAGE(main_image), "indicator-messages"); - accessible_desc = g_strdup(_("Messages")); + accessible_desc = _("Messages"); } update_a11y_desc(); -- cgit v1.2.3 From 1341d00cb6130b960f6392aa0edf0b4bf66896b8 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 23 Feb 2011 14:46:22 -0600 Subject: Make sure to set the type of the item before all the values. --- src/launcher-menu-item.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/launcher-menu-item.c b/src/launcher-menu-item.c index a47af03..60880ad 100644 --- a/src/launcher-menu-item.c +++ b/src/launcher-menu-item.c @@ -97,6 +97,8 @@ launcher_menu_item_init (LauncherMenuItem *self) priv->ids = NULL; priv->shortcuts = NULL; + dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), DBUSMENU_MENUITEM_PROP_TYPE, APPLICATION_MENUITEM_TYPE); + return; } -- cgit v1.2.3