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/indicator-messages.c') 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/indicator-messages.c') 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/indicator-messages.c') 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/indicator-messages.c') 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/indicator-messages.c') 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/indicator-messages.c') 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/indicator-messages.c') 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