Merge lp:~cimi/indicator-messages/left-triangle into lp:indicator-messages/0.5

Proposed by Andrea Cimitan
Status: Merged
Approved by: David Barth
Approved revision: 198
Merged at revision: 191
Proposed branch: lp:~cimi/indicator-messages/left-triangle
Merge into: lp:indicator-messages/0.5
Diff against target: 100 lines (+44/-15)
1 file modified
src/indicator-messages.c (+44/-15)
To merge this branch: bzr merge lp:~cimi/indicator-messages/left-triangle
Reviewer Review Type Date Requested Status
David Barth Approve
Indicator Applet Developers Pending
Review via email: mp+31283@code.launchpad.net

Description of the change

Add a triangle on the left

To post a comment you must log in.
196. By Andrea Cimitan

trailing whitespace

197. By Andrea Cimitan

remove the previous icon

198. By Andrea Cimitan

merged dbarth's branch

Revision history for this message
David Barth (dbarth) wrote :

+1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/indicator-messages.c'
2--- src/indicator-messages.c 2010-07-29 11:40:02 +0000
3+++ src/indicator-messages.c 2010-07-29 16:11:41 +0000
4@@ -290,6 +290,47 @@
5 return;
6 }
7
8+/* Draws a triangle on the left, using fg[STATE_TYPE] color. */
9+static gboolean
10+application_triangle_draw_cb (GtkWidget *widget, GdkEventExpose *event, gpointer data)
11+{
12+ GtkStyle *style;
13+ cairo_t *cr;
14+ int x, y, arrow_width, arrow_height;
15+
16+ if (!GTK_IS_WIDGET (widget)) return FALSE;
17+
18+ /* get style */
19+ style = gtk_widget_get_style (widget);
20+
21+ /* set arrow position / dimensions */
22+ arrow_width = (int) ((double)widget->allocation.height * 0.25f);
23+ arrow_height = (int) ((double)widget->allocation.height * 0.50f);
24+ x = widget->allocation.x;
25+ y = widget->allocation.y + widget->allocation.height/2.0 - (double)arrow_height/2.0;
26+
27+ /* initialize cairo drawing area */
28+ cr = (cairo_t*) gdk_cairo_create (widget->window);
29+
30+ /* set line width */
31+ cairo_set_line_width (cr, 1.0);
32+
33+ /* cairo drawing code */
34+ cairo_move_to (cr, x, y);
35+ cairo_line_to (cr, x, y + arrow_height);
36+ cairo_line_to (cr, x + arrow_width, y + (double)arrow_height/2.0);
37+ cairo_close_path (cr);
38+ cairo_set_source_rgb (cr, style->fg[gtk_widget_get_state(widget)].red/65535.0,
39+ style->fg[gtk_widget_get_state(widget)].green/65535.0,
40+ style->fg[gtk_widget_get_state(widget)].blue/65535.0);
41+ cairo_fill (cr);
42+
43+ /* remember to destroy cairo context to avoid leaks */
44+ cairo_destroy (cr);
45+
46+ return FALSE;
47+}
48+
49 /* Custom function to draw rounded rectangle with max radius */
50 static void
51 custom_cairo_rounded_rectangle (cairo_t *cr,
52@@ -314,7 +355,7 @@
53 PangoLayout * layout;
54 gint font_size = RIGHT_LABEL_FONT_SIZE;
55
56- if (!GTK_IS_WIDGET (widget)) return;
57+ if (!GTK_IS_WIDGET (widget)) return FALSE;
58
59 /* get style */
60 style = gtk_widget_get_style (widget);
61@@ -390,20 +431,13 @@
62 gtk_container_add(GTK_CONTAINER(gmi), hbox);
63 gtk_widget_show(hbox);
64
65- /* Build up the running icon */
66- GtkWidget * running_icon = gtk_image_new_from_icon_name("application-running", GTK_ICON_SIZE_MENU);
67- gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(gmi), running_icon);
68- gtk_widget_show(running_icon);
69-
70- /* Make sure it always appears */
71- gtk_image_menu_item_set_always_show_image(GTK_IMAGE_MENU_ITEM(gmi), TRUE);
72-
73 /* Attach some of the standard GTK stuff */
74 dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, gmi, parent);
75
76 /* Make sure we can handle the label changing */
77 g_signal_connect(G_OBJECT(newitem), DBUSMENU_MENUITEM_SIGNAL_PROPERTY_CHANGED, G_CALLBACK(application_prop_change_cb), label);
78 g_signal_connect(G_OBJECT(newitem), DBUSMENU_MENUITEM_SIGNAL_PROPERTY_CHANGED, G_CALLBACK(application_icon_change_cb), icon);
79+ g_signal_connect_after(G_OBJECT (gmi), "expose_event", G_CALLBACK (application_triangle_draw_cb), NULL);
80
81 return TRUE;
82 }
83@@ -528,11 +562,7 @@
84 item. */
85 mi_data->right = gtk_label_new(dbusmenu_menuitem_property_get(newitem, INDICATOR_MENUITEM_PROP_RIGHT));
86 gtk_size_group_add_widget(indicator_right_group, mi_data->right);
87-
88- /* Doesn't work, look numbers_draw_cb. */
89- /* PangoLayout * right_layout = gtk_label_get_layout (GTK_LABEL(mi_data->right));
90- font_size = pango_font_description_get_size (pango_layout_get_font_description (right_layout)); */
91-
92+ /* install extra decoration overlay */
93 g_signal_connect (G_OBJECT (mi_data->right), "expose_event",
94 G_CALLBACK (numbers_draw_cb), NULL);
95
96@@ -575,4 +605,3 @@
97
98 return GTK_MENU(menu);
99 }
100-

Subscribers

People subscribed via source and target branches