Merge lp:~cjcurran/indicator-sound/excessive-redraws-fix into lp:indicator-sound/fifth

Proposed by Conor Curran
Status: Merged
Approved by: Charles Kerr
Approved revision: 308
Merged at revision: 309
Proposed branch: lp:~cjcurran/indicator-sound/excessive-redraws-fix
Merge into: lp:indicator-sound/fifth
Diff against target: 151 lines (+30/-19)
1 file modified
src/metadata-widget.c (+30/-19)
To merge this branch: bzr merge lp:~cjcurran/indicator-sound/excessive-redraws-fix
Reviewer Review Type Date Requested Status
Charles Kerr (community) Approve
Review via email: mp+97703@code.launchpad.net

Description of the change

fixes attached bug

To post a comment you must log in.
Charles Kerr (charlesk) wrote :

Looks good.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/metadata-widget.c'
2--- src/metadata-widget.c 2012-03-03 19:12:05 +0000
3+++ src/metadata-widget.c 2012-03-15 17:12:24 +0000
4@@ -138,8 +138,7 @@
5 hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
6 #else
7 hbox = gtk_hbox_new(FALSE, 0);
8- #endif
9-
10+ #endif
11
12 priv->meta_data_h_box = hbox;
13 priv->current_height = 1;
14@@ -270,6 +269,18 @@
15 G_OBJECT_CLASS (metadata_widget_parent_class)->finalize (object);
16 }
17
18+/**
19+* Make sure to only clear the album art only when it is not empty
20+* Otherwise it will continuously call queue_draw after each empty call.
21+*/
22+static void
23+clear_album_art (GtkImage* album_art)
24+{
25+ if (gtk_image_get_storage_type(album_art) != GTK_IMAGE_EMPTY){
26+ gtk_image_clear (album_art);
27+ }
28+}
29+
30
31 #if GTK_CHECK_VERSION(3, 0, 0)
32 static void
33@@ -279,6 +290,7 @@
34 {
35 *minimum_width = *natural_width = 200;
36 }
37+
38 /**
39 * We override the expose method to enable primitive drawing of the
40 * empty album art image.
41@@ -298,15 +310,16 @@
42 return FALSE;
43 }
44
45- if(priv->image_path->len > 0){
46- if(g_string_equal(priv->image_path, priv->old_image_path) == FALSE ||
47+ if((guint)priv->image_path->len != 0){
48+
49+ if(g_string_equal (priv->image_path, priv->old_image_path) == FALSE ||
50 priv->theme_change_occured == TRUE){
51 priv->theme_change_occured = FALSE;
52 GdkPixbuf* pixbuf;
53 pixbuf = gdk_pixbuf_new_from_file_at_size(priv->image_path->str, 60, 60, NULL);
54-
55+
56 if(GDK_IS_PIXBUF(pixbuf) == FALSE){
57- gtk_image_clear ( GTK_IMAGE(priv->album_art));
58+ clear_album_art (GTK_IMAGE(priv->album_art));
59 gtk_widget_set_size_request(GTK_WIDGET(priv->album_art), 60, 60);
60 draw_album_border (metadata, FALSE);
61 draw_album_art_placeholder(metadata);
62@@ -325,9 +338,10 @@
63 }
64 return FALSE;
65 }
66- gtk_image_clear (GTK_IMAGE(priv->album_art));
67+ clear_album_art (GTK_IMAGE(priv->album_art));
68+ g_string_erase (priv->old_image_path, 0, -1);
69 gtk_widget_set_size_request(GTK_WIDGET(priv->album_art), 60, 60);
70- draw_album_border (metadata, FALSE);
71+ draw_album_border (metadata, FALSE);
72 draw_album_art_placeholder(metadata);
73 return FALSE;
74 }
75@@ -337,8 +351,7 @@
76 metadata_widget_icon_triangle_draw_cb_gtk_3 (GtkWidget *widget,
77 cairo_t* cr,
78 gpointer user_data)
79-{
80-
81+{
82 g_return_val_if_fail(IS_METADATA_WIDGET(user_data), FALSE);
83 MetadataWidget* meta = METADATA_WIDGET(user_data);
84 MetadataWidgetPrivate * priv = METADATA_WIDGET_GET_PRIVATE(meta);
85@@ -371,11 +384,8 @@
86 if (dbusmenu_menuitem_property_get_bool (priv->twin_item,
87 DBUSMENU_METADATA_MENUITEM_PLAYER_RUNNING)){
88 y += gdk_pixbuf_get_height (priv->icon_buf) / 3 + 3;
89- //allocation.height/2.0 - (double)arrow_height/2.0;
90 cairo_set_line_width (cr, 1.0);
91
92- //g_debug ("triangle drawing");
93-
94 cairo_move_to (cr, x, y);
95 cairo_line_to (cr, x, y + arrow_height);
96 cairo_line_to (cr, x + arrow_width, y + (double)arrow_height/2.0);
97@@ -417,7 +427,7 @@
98 pixbuf = gdk_pixbuf_new_from_file_at_size(priv->image_path->str, 60, 60, NULL);
99
100 if(GDK_IS_PIXBUF(pixbuf) == FALSE){
101- gtk_image_clear ( GTK_IMAGE(priv->album_art));
102+ clear_album_art (GTK_IMAGE(priv->album_art));
103 gtk_widget_set_size_request(GTK_WIDGET(priv->album_art), 60, 60);
104 draw_album_art_placeholder(metadata);
105 return FALSE;
106@@ -434,7 +444,8 @@
107 }
108 return FALSE;
109 }
110- gtk_image_clear (GTK_IMAGE(priv->album_art));
111+ clear_album_art (GTK_IMAGE(priv->album_art));
112+ g_string_erase (priv->old_image_path, 0, -1);
113 gtk_widget_set_size_request(GTK_WIDGET(priv->album_art), 60, 60);
114 draw_album_art_placeholder(metadata);
115 return FALSE;
116@@ -597,7 +608,7 @@
117
118 static void
119 draw_album_art_placeholder(GtkWidget *metadata)
120-{
121+{
122 cairo_t *cr;
123 cr = gdk_cairo_create (gtk_widget_get_window (metadata));
124 GtkStyle *style;
125@@ -726,7 +737,7 @@
126 }
127 else if(g_ascii_strcasecmp(DBUSMENU_METADATA_MENUITEM_ARTURL, property) == 0){
128 g_string_erase(priv->image_path, 0, -1);
129- g_string_overwrite(priv->image_path, 0, g_variant_get_string (value, NULL));
130+ g_string_overwrite (priv->image_path, 0, g_variant_get_string (value, NULL));
131 gtk_widget_queue_draw(GTK_WIDGET(mitem));
132 }
133 else if (g_ascii_strcasecmp (DBUSMENU_METADATA_MENUITEM_PLAYER_NAME, property) == 0){
134@@ -753,7 +764,7 @@
135 else{
136 gtk_widget_show (priv->meta_data_h_box);
137 }
138- gtk_widget_queue_draw(GTK_WIDGET(self));
139+ gtk_widget_queue_draw(GTK_WIDGET(self));
140 }
141
142 static void
143@@ -773,7 +784,7 @@
144 MetadataWidget* widg = METADATA_WIDGET(metadata);
145 MetadataWidgetPrivate * priv = METADATA_WIDGET_GET_PRIVATE(widg);
146 priv->theme_change_occured = TRUE;
147- gtk_widget_queue_draw(GTK_WIDGET(metadata));
148+ gtk_widget_queue_draw (GTK_WIDGET(metadata));
149 }
150
151 static void

Subscribers

People subscribed via source and target branches