Merge lp:~ted/indicator-sound/new-icon-helper into lp:indicator-sound/0.1

Proposed by Ted Gould
Status: Merged
Merged at revision: not available
Proposed branch: lp:~ted/indicator-sound/new-icon-helper
Merge into: lp:indicator-sound/0.1
Diff against target: 57 lines (+20/-6)
1 file modified
src/indicator-sound.c (+20/-6)
To merge this branch: bzr merge lp:~ted/indicator-sound/new-icon-helper
Reviewer Review Type Date Requested Status
Conor Curran (community) Approve
Review via email: mp+21111@code.launchpad.net

Description of the change

Use the libindicator helper function for images and also use GIcon to
create the icons on the IDO slider.

To post a comment you must log in.
Revision history for this message
Conor Curran (cjcurran) wrote :

Will merge into existing working branch which in turn will be merged into trunk later on this morning

review: Approve

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-03-04 15:52:59 +0000
3+++ src/indicator-sound.c 2010-03-11 05:16:25 +0000
4@@ -34,6 +34,7 @@
5 #include <libindicator/indicator.h>
6 #include <libindicator/indicator-object.h>
7 #include <libindicator/indicator-service-manager.h>
8+#include <libindicator/indicator-image-helper.h>
9
10 #include "indicator-sound.h"
11 #include "dbus-shared-names.h"
12@@ -180,7 +181,7 @@
13 {
14 gchar* current_name = g_hash_table_lookup(volume_states, GINT_TO_POINTER(current_state));
15 //g_debug("At start-up attempting to set the image to %s", current_name);
16- speaker_image = GTK_IMAGE(gtk_image_new_from_icon_name(current_name, GTK_ICON_SIZE_MENU));
17+ speaker_image = indicator_image_helper(current_name);
18 gtk_widget_show(GTK_WIDGET(speaker_image));
19 return speaker_image;
20 }
21@@ -224,12 +225,23 @@
22 // alternative callback mechanism which i could use again at some point.
23 /* g_signal_connect(slider, "change-value", G_CALLBACK(user_change_value_event_cb), newitem); */
24
25- // Set images on the ido
26+ /* Get the primary Image */
27 primary_image = ido_scale_menu_item_get_primary_image((IdoScaleMenuItem*)volume_slider);
28- gtk_image_set_from_icon_name(GTK_IMAGE(primary_image), g_hash_table_lookup(volume_states, GINT_TO_POINTER(STATE_ZERO)), GTK_ICON_SIZE_MENU);
29+
30+ /* Build a GIcon for the theme fallbacks */
31+ GIcon * primary_gicon = g_themed_icon_new_with_default_fallbacks(g_hash_table_lookup(volume_states, GINT_TO_POINTER(STATE_ZERO)));
32+ gtk_image_set_from_gicon(GTK_IMAGE(primary_image), primary_gicon, GTK_ICON_SIZE_MENU);
33+ g_object_unref(primary_gicon);
34+
35+ /* Get the secondary image */
36 GtkWidget* secondary_image = ido_scale_menu_item_get_secondary_image((IdoScaleMenuItem*)volume_slider);
37- gtk_image_set_from_icon_name(GTK_IMAGE(secondary_image), g_hash_table_lookup(volume_states, GINT_TO_POINTER(STATE_HIGH)), GTK_ICON_SIZE_MENU);
38-
39+
40+ /* Build a GIcon for fallbacks */
41+ GIcon * secondary_gicon = g_themed_icon_new_with_default_fallbacks(g_hash_table_lookup(volume_states, GINT_TO_POINTER(STATE_HIGH)));
42+ gtk_image_set_from_gicon(GTK_IMAGE(secondary_image), secondary_gicon, GTK_ICON_SIZE_MENU);
43+ g_object_unref(secondary_gicon);
44+
45+ /* Make the widget visible to users */
46 gtk_widget_show_all(volume_slider);
47
48 return TRUE;
49@@ -327,7 +339,9 @@
50
51 current_state = state;
52 gchar* image_name = g_hash_table_lookup(volume_states, GINT_TO_POINTER(current_state));
53- gtk_image_set_from_icon_name(speaker_image, image_name, GTK_ICON_SIZE_MENU);
54+ GtkImage * tempimage = indicator_image_helper(image_name);
55+ gtk_image_set_from_pixbuf(speaker_image, gtk_image_get_pixbuf(tempimage));
56+ g_object_ref_sink(tempimage);
57 }
58
59

Subscribers

People subscribed via source and target branches