Merge lp:~cjcurran/indicator-sound/banshee-fix-plus-random-slider-crasher into lp:indicator-sound/sound-menu-v2

Proposed by Conor Curran
Status: Merged
Merged at revision: 131
Proposed branch: lp:~cjcurran/indicator-sound/banshee-fix-plus-random-slider-crasher
Merge into: lp:indicator-sound/sound-menu-v2
Diff against target: 549 lines (+317/-45)
5 files modified
src/indicator-sound.c (+3/-0)
src/metadata-widget.c (+33/-26)
src/mpris2-controller.vala (+8/-4)
src/music-player-bridge.vala (+21/-3)
src/play-button.c (+252/-12)
To merge this branch: bzr merge lp:~cjcurran/indicator-sound/banshee-fix-plus-random-slider-crasher
Reviewer Review Type Date Requested Status
David Barth Needs Fixing
Review via email: mp+35080@code.launchpad.net

Description of the change

fixes for the bugs listed.

To post a comment you must log in.
Revision history for this message
David Barth (dbarth) wrote :

line 356: if delta is zero, it won't look cool

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

also, the theme change cb does nothing. add a comment in the code to state whether there is a TODO or whether it's a no-op on purpose.

136. By Conor Curran

merge comments acted upon

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/indicator-sound.c'
2--- src/indicator-sound.c 2010-09-08 15:10:36 +0000
3+++ src/indicator-sound.c 2010-09-10 13:02:44 +0000
4@@ -661,6 +661,7 @@
5 GtkWidget* slider_widget = volume_widget_get_ido_slider(VOLUME_WIDGET(priv->volume_widget));
6 GtkWidget* slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)slider_widget);
7 GtkRange* range = (GtkRange*)slider;
8+ g_return_val_if_fail(GTK_IS_RANGE(range), FALSE);
9 gdouble current_value = gtk_range_get_value(range);
10 gdouble new_value = current_value;
11 const gdouble five_percent = 5;
12@@ -729,6 +730,8 @@
13 GtkWidget* slider_widget = volume_widget_get_ido_slider(VOLUME_WIDGET(priv->volume_widget));
14 GtkWidget* slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)slider_widget);
15 GtkRange* range = (GtkRange*)slider;
16+ g_return_if_fail(GTK_IS_RANGE(range));
17+
18 gdouble value = gtk_range_get_value(range);
19 GtkAdjustment *adj = gtk_range_get_adjustment (GTK_RANGE (slider));
20 g_debug("indicator-sound-scroll - current slider value %f", value);
21
22=== modified file 'src/metadata-widget.c'
23--- src/metadata-widget.c 2010-09-07 16:57:49 +0000
24+++ src/metadata-widget.c 2010-09-10 13:02:44 +0000
25@@ -33,6 +33,7 @@
26
27 struct _MetadataWidgetPrivate
28 {
29+ gboolean theme_change_occured;
30 GtkWidget* hbox;
31 GtkWidget* album_art;
32 GString* image_path;
33@@ -40,18 +41,18 @@
34 GtkWidget* artist_label;
35 GtkWidget* piece_label;
36 GtkWidget* container_label;
37- GdkColor bevel_colour;
38- GdkColor eight_note_colour;
39 };
40
41 #define METADATA_WIDGET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), METADATA_WIDGET_TYPE, MetadataWidgetPrivate))
42
43 /* Prototypes */
44-static void metadata_widget_class_init (MetadataWidgetClass *klass);
45-static void metadata_widget_init (MetadataWidget *self);
46-static void metadata_widget_dispose (GObject *object);
47-static void metadata_widget_finalize (GObject *object);
48-static gboolean metadata_image_expose (GtkWidget *image, GdkEventExpose *event, gpointer user_data);
49+static void metadata_widget_class_init (MetadataWidgetClass *klass);
50+static void metadata_widget_init (MetadataWidget *self);
51+static void metadata_widget_dispose (GObject *object);
52+static void metadata_widget_finalize (GObject *object);
53+static gboolean metadata_image_expose (GtkWidget *image, GdkEventExpose *event, gpointer user_data);
54+//static void metadata_widget_style_changed_cb(GtkWidget *widget, gpointer user_data);
55+static void metadata_widget_set_style (GtkWidget* button, GtkStyle* style);
56
57 // keyevent consumers
58 static gboolean metadata_widget_button_press_event (GtkWidget *menuitem,
59@@ -61,15 +62,11 @@
60 gchar* property,
61 GValue* value,
62 gpointer userdata);
63-
64 static void metadata_widget_style_labels(MetadataWidget* self,
65 GtkLabel* label);
66-
67-void metadata_widget_set_style(GtkWidget* button, GtkStyle* style);
68 static void image_set_from_pixbuf (GtkWidget *widget,
69 MetadataWidget* metadata,
70 GdkPixbuf *source);
71-
72 static void draw_album_art_placeholder(GtkWidget *metadata);
73
74 G_DEFINE_TYPE (MetadataWidget, metadata_widget, GTK_TYPE_MENU_ITEM);
75@@ -95,7 +92,6 @@
76 g_debug("MetadataWidget::metadata_widget_init");
77
78 MetadataWidgetPrivate * priv = METADATA_WIDGET_GET_PRIVATE(self);
79-
80 GtkWidget *hbox;
81
82 hbox = gtk_hbox_new(FALSE, 0);
83@@ -114,7 +110,9 @@
84
85 gtk_box_pack_start (GTK_BOX (priv->hbox), priv->album_art, FALSE, FALSE, 0);
86
87- GtkWidget* vbox = gtk_vbox_new(FALSE, 0);
88+ priv->theme_change_occured = FALSE;
89+
90+ GtkWidget* vbox = gtk_vbox_new(FALSE, 0);
91
92 // artist
93 GtkWidget* artist;
94@@ -177,6 +175,7 @@
95 G_OBJECT_CLASS (metadata_widget_parent_class)->finalize (object);
96 }
97
98+
99 /**
100 * We override the expose method to enable primitive drawing of the
101 * empty album art image and rounded rectangles on the album art.
102@@ -188,7 +187,9 @@
103 MetadataWidget* widget = METADATA_WIDGET(user_data);
104 MetadataWidgetPrivate * priv = METADATA_WIDGET_GET_PRIVATE(widget);
105 if(priv->image_path->len > 0){
106- if(g_string_equal(priv->image_path, priv->old_image_path) == FALSE){
107+ if(g_string_equal(priv->image_path, priv->old_image_path) == FALSE ||
108+ priv->theme_change_occured == TRUE){
109+ priv->theme_change_occured = FALSE;
110 GdkPixbuf* pixbuf;
111 pixbuf = gdk_pixbuf_new_from_file(priv->image_path->str, NULL);
112 g_debug("metadata_load_new_image -> pixbuf from %s",
113@@ -216,6 +217,9 @@
114
115 cairo_t *cr;
116 cr = gdk_cairo_create (metadata->window);
117+ GtkStyle *style;
118+ style = gtk_widget_get_style (metadata);
119+
120 GtkAllocation alloc;
121 gtk_widget_get_allocation (metadata, &alloc);
122
123@@ -234,7 +238,11 @@
124
125 cairo_close_path (cr);
126
127- cairo_set_source_rgba (cr, 123.0f / 255.0f, 123.0f / 255.0f, 120.0f / 255.0f, .8f);
128+ cairo_set_source_rgba (cr,
129+ style->fg[0].red/65535.0,
130+ style->fg[0].green/65535.0,
131+ style->fg[0].blue/65535.0,
132+ 0.6);
133 cairo_set_line_width (cr, 2.0);
134
135 cairo_stroke (cr);
136@@ -256,7 +264,12 @@
137 pango_layout_set_font_description(layout, desc);
138 pango_font_description_free(desc);
139
140- cairo_set_source_rgba(cr, 1.0, 1.0, 1.0, 0.8);
141+ cairo_set_source_rgba (cr,
142+ style->fg[0].red/65535.0,
143+ style->fg[0].green/65535.0,
144+ style->fg[0].blue/65535.0,
145+ 0.8);
146+
147 pango_cairo_update_layout(cr, layout);
148 cairo_move_to (cr, alloc.x + alloc.width/6, alloc.y);
149 pango_cairo_show_layout(cr, layout);
150@@ -487,21 +500,15 @@
151 g_free(markup);
152 }
153
154-void
155+static void
156 metadata_widget_set_style(GtkWidget* metadata, GtkStyle* style)
157 {
158 g_return_if_fail(IS_METADATA_WIDGET(metadata));
159 MetadataWidget* widg = METADATA_WIDGET(metadata);
160 MetadataWidgetPrivate * priv = METADATA_WIDGET_GET_PRIVATE(widg);
161- if(style == NULL){
162- g_warning("metadata_widget_set_style -> style is NULL!");
163- return;
164- }
165- else{
166- g_debug("metadata_widget: about to set the style colours");
167- priv->eight_note_colour = style->fg[GTK_STATE_NORMAL];
168- priv->bevel_colour = style->bg[GTK_STATE_NORMAL];
169- }
170+ priv->theme_change_occured = TRUE;
171+ gtk_widget_queue_draw(GTK_WIDGET(metadata));
172+ g_debug("metadata_widget: theme change");
173 }
174
175 /**
176
177=== modified file 'src/mpris2-controller.vala'
178--- src/mpris2-controller.vala 2010-09-08 15:10:36 +0000
179+++ src/mpris2-controller.vala 2010-09-10 13:02:44 +0000
180@@ -53,7 +53,9 @@
181 [DBus (name = "org.freedesktop.DBus.Properties")]
182 public interface FreeDesktopProperties : DBus.Object{
183 // signals
184- public signal void PropertiesChanged(string source, HashTable<string, Value?> changed_properties, string[] invalid);
185+ public signal void PropertiesChanged(string source, HashTable<string,
186+ Value?> changed_properties,
187+ string[] invalid);
188 }
189
190 /*
191@@ -85,8 +87,7 @@
192 this.player.Seeked += onSeeked;
193
194 this.properties_interface = (FreeDesktopProperties) connection.get_object(root_interface.concat(".").concat(this.owner.name.down()),
195- "/org/mpris/MediaPlayer2",
196- "org.freedesktop.DBus.Properties");
197+ "/org/mpris/MediaPlayer2");
198 this.properties_interface.PropertiesChanged += property_changed_cb;
199
200 } catch (DBus.Error e) {
201@@ -97,7 +98,10 @@
202 public void property_changed_cb(string interface_source, HashTable<string, Value?> changed_properties, string[] invalid )
203 {
204 debug("properties-changed for interface %s and owner %s", interface_source, this.owner.name.down());
205- if(changed_properties == null || interface_source.has_prefix(this.root_interface) == false){
206+ debug("is the invalid array null : %s", (invalid == null).to_string());
207+ debug("invalid length : %i", invalid.length);
208+
209+ if(changed_properties == null || interface_source.has_prefix(this.root_interface) == false ){
210 warning("Property-changed hash is null or this is an interface that concerns us");
211 return;
212 }
213
214=== modified file 'src/music-player-bridge.vala'
215--- src/music-player-bridge.vala 2010-09-07 14:12:08 +0000
216+++ src/music-player-bridge.vala 2010-09-10 13:02:44 +0000
217@@ -58,15 +58,33 @@
218 continue;
219 }
220 GLib.AppInfo app_info = info as GLib.AppInfo;
221+ // TODO refactor to remove need for further name refactoring in the player controller
222+ // truncate should not do a down() on the name
223 PlayerController ctrl = new PlayerController(this.root_menu,
224- app_info.get_name(),
225+ truncate_player_name(app_info.get_name()),
226 calculate_menu_position(),
227 PlayerController.state.OFFLINE);
228- ctrl.set("app_info", app_info);
229- this.registered_clients.set(app_info.get_name().down().strip(), ctrl);
230+ ctrl.app_info = app_info;
231+ if(ctrl.app_info == null)
232+ warning("for some reason the app info is null");
233+
234+ this.registered_clients.set(truncate_player_name(app_info.get_name()), ctrl);
235 }
236 }
237
238+ private static string truncate_player_name(string app_info_name)
239+ {
240+ string result = app_info_name.down().strip();
241+
242+ var tokens = result.split(" ");
243+
244+ if(tokens.length > 1){
245+ result = tokens[0];
246+ }
247+ debug("truncate player name %s", result);
248+ return result;
249+ }
250+
251 private int calculate_menu_position()
252 {
253 if(this.registered_clients.size == 0){
254
255=== modified file 'src/play-button.c'
256--- src/play-button.c 2010-09-08 15:10:36 +0000
257+++ src/play-button.c 2010-09-10 13:02:44 +0000
258@@ -55,6 +55,18 @@
259 #define PLAY_WIDTH 28.0f
260 #define PLAY_HEIGHT 29.0f
261 #define PLAY_PADDING 5.0f
262+#define INNER_START_SHADE 0.98
263+#define INNER_END_SHADE 0.98
264+#define MIDDLE_START_SHADE 0.7
265+#define MIDDLE_END_SHADE 1.4
266+#define OUTER_START_SHADE 0.96
267+#define OUTER_END_SHADE 0.96
268+#define BUTTON_START_SHADE 1.1
269+#define BUTTON_END_SHADE 0.9
270+#define BUTTON_SHADOW_SHADE 0.8
271+#define INNER_COMPRESSED_START_SHADE 0.95
272+#define INNER_COMPRESSED_END_SHADE 1.05
273+
274
275 typedef struct _PlayButtonPrivate PlayButtonPrivate;
276
277@@ -70,6 +82,14 @@
278 GHashTable* command_coordinates;
279 };
280
281+typedef struct
282+{
283+ double r;
284+ double g;
285+ double b;
286+} CairoColorRGB;
287+
288+
289 #define PLAY_BUTTON_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), PLAY_BUTTON_TYPE, PlayButtonPrivate))
290
291 /* Gobject boiler plate */
292@@ -723,6 +743,201 @@
293 }
294
295 static void
296+_color_rgb_to_hls (gdouble *r,
297+ gdouble *g,
298+ gdouble *b)
299+{
300+ gdouble min;
301+ gdouble max;
302+ gdouble red;
303+ gdouble green;
304+ gdouble blue;
305+ gdouble h, l, s;
306+ gdouble delta;
307+
308+ red = *r;
309+ green = *g;
310+ blue = *b;
311+
312+ if (red > green)
313+ {
314+ if (red > blue)
315+ max = red;
316+ else
317+ max = blue;
318+
319+ if (green < blue)
320+ min = green;
321+ else
322+ min = blue;
323+ }
324+ else
325+ {
326+ if (green > blue)
327+ max = green;
328+ else
329+ max = blue;
330+
331+ if (red < blue)
332+ min = red;
333+ else
334+ min = blue;
335+ }
336+ l = (max+min)/2;
337+ if (fabs (max-min) < 0.0001)
338+ {
339+ h = 0;
340+ s = 0;
341+ }
342+ else
343+ {
344+ if (l <= 0.5)
345+ s = (max-min)/(max+min);
346+ else
347+ s = (max-min)/(2-max-min);
348+
349+ delta = (max -min) != 0 ? (max -min) : 1;
350+
351+ if(delta == 0)
352+ delta = 1;
353+ if (red == max)
354+ h = (green-blue)/delta;
355+ else if (green == max)
356+ h = 2+(blue-red)/delta;
357+ else if (blue == max)
358+ h = 4+(red-green)/delta;
359+
360+ h *= 60;
361+ if (h < 0.0)
362+ h += 360;
363+ }
364+
365+ *r = h;
366+ *g = l;
367+ *b = s;
368+}
369+
370+static void
371+_color_hls_to_rgb (gdouble *h,
372+ gdouble *l,
373+ gdouble *s)
374+{
375+ gdouble hue;
376+ gdouble lightness;
377+ gdouble saturation;
378+ gdouble m1, m2;
379+ gdouble r, g, b;
380+
381+ lightness = *l;
382+ saturation = *s;
383+
384+ if (lightness <= 0.5)
385+ m2 = lightness*(1+saturation);
386+ else
387+ m2 = lightness+saturation-lightness*saturation;
388+
389+ m1 = 2*lightness-m2;
390+
391+ if (saturation == 0)
392+ {
393+ *h = lightness;
394+ *l = lightness;
395+ *s = lightness;
396+ }
397+ else
398+ {
399+ hue = *h+120;
400+ while (hue > 360)
401+ hue -= 360;
402+ while (hue < 0)
403+ hue += 360;
404+
405+ if (hue < 60)
406+ r = m1+(m2-m1)*hue/60;
407+ else if (hue < 180)
408+ r = m2;
409+ else if (hue < 240)
410+ r = m1+(m2-m1)*(240-hue)/60;
411+ else
412+ r = m1;
413+
414+ hue = *h;
415+ while (hue > 360)
416+ hue -= 360;
417+ while (hue < 0)
418+ hue += 360;
419+
420+ if (hue < 60)
421+ g = m1+(m2-m1)*hue/60;
422+ else if (hue < 180)
423+ g = m2;
424+ else if (hue < 240)
425+ g = m1+(m2-m1)*(240-hue)/60;
426+ else
427+ g = m1;
428+
429+ hue = *h-120;
430+ while (hue > 360)
431+ hue -= 360;
432+ while (hue < 0)
433+ hue += 360;
434+
435+ if (hue < 60)
436+ b = m1+(m2-m1)*hue/60;
437+ else if (hue < 180)
438+ b = m2;
439+ else if (hue < 240)
440+ b = m1+(m2-m1)*(240-hue)/60;
441+ else
442+ b = m1;
443+
444+ *h = r;
445+ *l = g;
446+ *s = b;
447+ }
448+}
449+
450+static void
451+_color_shade (const CairoColorRGB *a, float k, CairoColorRGB *b)
452+{
453+ double red;
454+ double green;
455+ double blue;
456+
457+ red = a->r;
458+ green = a->g;
459+ blue = a->b;
460+
461+ if (k == 1.0)
462+ {
463+ b->r = red;
464+ b->g = green;
465+ b->b = blue;
466+ return;
467+ }
468+
469+ _color_rgb_to_hls (&red, &green, &blue);
470+
471+ green *= k;
472+ if (green > 1.0)
473+ green = 1.0;
474+ else if (green < 0.0)
475+ green = 0.0;
476+
477+ blue *= k;
478+ if (blue > 1.0)
479+ blue = 1.0;
480+ else if (blue < 0.0)
481+ blue = 0.0;
482+
483+ _color_hls_to_rgb (&red, &green, &blue);
484+
485+ b->r = red;
486+ b->g = green;
487+ b->b = blue;
488+}
489+
490+static void
491 draw (GtkWidget* button, cairo_t *cr)
492 {
493 g_return_if_fail(IS_PLAY_BUTTON(button));
494@@ -731,18 +946,43 @@
495 cairo_surface_t* surf = NULL;
496 cairo_t* cr_surf = NULL;
497
498- //double INNER_START[] = {229.0f/255.0f, 223.0f/255.0f, 215.0f/255.0f, 1.0f};
499- //double INNER_END[] = {183.0f / 255.0f, 178.0f / 255.0f, 172.0f / 255.0f, 1.0f};
500- double MIDDLE_START[] = {61.0f / 255.0f, 60.0f / 255.0f, 57.0f / 255.0f, 1.0f};
501- double MIDDLE_END[] = {94.0f / 255.0f,93.0f / 255.0f, 90.0f / 255.0f,1.0f};
502- double OUTER_START[] = {36.0f / 255.0f, 35.0f / 255.0f, 33.0f / 255.0f, 1.0f};
503- double OUTER_END[] = {123.0f / 255.0f, 123.0f / 255.0f, 120.0f / 255.0f, 1.0f};
504- double BUTTON_START[] = {252.0f / 255.0f, 251.0f / 255.0f, 251.0f / 255.0f,1.0f};
505- double BUTTON_END[] = {186.0f / 255.0f,180.0f / 255.0f, 170.0f / 255.0f, 1.0f};
506- double BUTTON_SHADOW[] = {0.0f / 255.0f, 0.0f / 255.0f, 0.0f / 255.0f, 0.75f};
507- double INNER_COMPRESSED_END[] = {61.0f / 255.0f, 60.0f / 255.0f, 57.0f / 255.0f, 1.0f};
508- double INNER_COMPRESSED_START[] = {36.0f / 255.0f, 35.0f / 255.0f, 33.0f / 255.0f, 1.0f};
509-
510+ GtkStyle *style;
511+
512+ CairoColorRGB bg_normal, fg_normal;
513+ CairoColorRGB color_inner[2], color_middle[2], color_outer[2], color_button[3], color_inner_compressed[2];
514+
515+ style = gtk_widget_get_style (button);
516+
517+ bg_normal.r = style->bg[0].red/65535.0;
518+ bg_normal.g = style->bg[0].green/65535.0;
519+ bg_normal.b = style->bg[0].blue/65535.0;
520+
521+ fg_normal.r = style->fg[0].red/65535.0;
522+ fg_normal.g = style->fg[0].green/65535.0;
523+ fg_normal.b = style->fg[0].blue/65535.0;
524+
525+ _color_shade (&bg_normal, INNER_START_SHADE, &color_inner[0]);
526+ _color_shade (&bg_normal, INNER_END_SHADE, &color_inner[1]);
527+ _color_shade (&bg_normal, MIDDLE_START_SHADE, &color_middle[0]);
528+ _color_shade (&bg_normal, MIDDLE_END_SHADE, &color_middle[1]);
529+ _color_shade (&bg_normal, OUTER_START_SHADE, &color_outer[0]);
530+ _color_shade (&bg_normal, OUTER_END_SHADE, &color_outer[1]);
531+ _color_shade (&fg_normal, BUTTON_START_SHADE, &color_button[0]);
532+ _color_shade (&fg_normal, BUTTON_END_SHADE, &color_button[1]);
533+ _color_shade (&bg_normal, BUTTON_SHADOW_SHADE, &color_button[2]);
534+ _color_shade (&bg_normal, INNER_COMPRESSED_START_SHADE, &color_inner_compressed[0]);
535+ _color_shade (&bg_normal, INNER_COMPRESSED_END_SHADE, &color_inner_compressed[1]);
536+
537+ double MIDDLE_END[] = {color_middle[0].r, color_middle[0].g, color_middle[0].b, 1.0f};
538+ double MIDDLE_START[] = {color_middle[1].r, color_middle[1].g, color_middle[1].b, 1.0f};
539+ double OUTER_END[] = {color_outer[0].r, color_outer[0].g, color_outer[0].b, 1.0f};
540+ double OUTER_START[] = {color_outer[1].r, color_outer[1].g, color_outer[1].b, 1.0f};
541+ double BUTTON_END[] = {color_button[0].r, color_button[0].g, color_button[0].b, 1.0f};
542+ double BUTTON_START[] = {color_button[1].r, color_button[1].g, color_button[1].b, 1.0f};
543+ double BUTTON_SHADOW[] = {color_button[2].r, color_button[2].g, color_button[2].b, 0.75f};
544+ double INNER_COMPRESSED_END[] = {color_inner_compressed[1].r, color_inner_compressed[1].g, color_inner_compressed[1].b, 1.0f};
545+ double INNER_COMPRESSED_START[] = {color_inner_compressed[0].r, color_inner_compressed[0].g, color_inner_compressed[0].b, 1.0f};
546+
547 // prev/next-background
548 draw_gradient (cr,
549 X,

Subscribers

People subscribed via source and target branches

to all changes: