← Back to team overview

ayatana-commits team mailing list archive

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

 

Ted Gould has proposed merging lp:~ted/indicator-sound/new-icon-helper into lp:indicator-sound.

Requested reviews:
  Indicator Applet Developers (indicator-applet-developers)


Use the libindicator helper function for images and also use GIcon to
create the icons on the IDO slider.
-- 
https://code.launchpad.net/~ted/indicator-sound/new-icon-helper/+merge/21111
Your team ayatana-commits is subscribed to branch lp:indicator-sound.
=== modified file 'src/indicator-sound.c'
--- src/indicator-sound.c	2010-03-04 15:52:59 +0000
+++ src/indicator-sound.c	2010-03-11 05:15:26 +0000
@@ -34,6 +34,7 @@
 #include <libindicator/indicator.h>
 #include <libindicator/indicator-object.h>
 #include <libindicator/indicator-service-manager.h>
+#include <libindicator/indicator-image-helper.h>
 
 #include "indicator-sound.h"
 #include "dbus-shared-names.h"
@@ -180,7 +181,7 @@
 {
     gchar* current_name = g_hash_table_lookup(volume_states, GINT_TO_POINTER(current_state));
     //g_debug("At start-up attempting to set the image to %s", current_name);
-	speaker_image = GTK_IMAGE(gtk_image_new_from_icon_name(current_name, GTK_ICON_SIZE_MENU));
+	speaker_image = indicator_image_helper(current_name);
 	gtk_widget_show(GTK_WIDGET(speaker_image));
 	return speaker_image;
 }
@@ -224,12 +225,23 @@
     // alternative callback mechanism which i could use again at some point.
 /*    g_signal_connect(slider, "change-value", G_CALLBACK(user_change_value_event_cb), newitem);     */
     
-    // Set images on the ido
+	/* Get the primary Image */
     primary_image = ido_scale_menu_item_get_primary_image((IdoScaleMenuItem*)volume_slider);    
-    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);
+
+	/* Build a GIcon for the theme fallbacks */
+	GIcon * primary_gicon = g_themed_icon_new_with_default_fallbacks(g_hash_table_lookup(volume_states, GINT_TO_POINTER(STATE_ZERO)));
+    gtk_image_set_from_gicon(GTK_IMAGE(primary_image), primary_gicon, GTK_ICON_SIZE_MENU);
+	g_object_unref(primary_gicon);
+
+	/* Get the secondary image */
     GtkWidget* secondary_image = ido_scale_menu_item_get_secondary_image((IdoScaleMenuItem*)volume_slider);                 
-    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);
-
+
+	/* Build a GIcon for fallbacks */
+	GIcon * secondary_gicon = g_themed_icon_new_with_default_fallbacks(g_hash_table_lookup(volume_states, GINT_TO_POINTER(STATE_HIGH)));
+    gtk_image_set_from_gicon(GTK_IMAGE(secondary_image), secondary_gicon, GTK_ICON_SIZE_MENU);
+	g_object_unref(secondary_gicon);
+
+	/* Make the widget visible to users */
     gtk_widget_show_all(volume_slider);
 
 	return TRUE;
@@ -327,7 +339,9 @@
 
     current_state = state;
     gchar* image_name = g_hash_table_lookup(volume_states, GINT_TO_POINTER(current_state));
-    gtk_image_set_from_icon_name(speaker_image, image_name, GTK_ICON_SIZE_MENU);
+	GtkImage * tempimage = indicator_image_helper(image_name);
+    gtk_image_set_from_pixbuf(speaker_image, gtk_image_get_pixbuf(tempimage));
+	g_object_ref_sink(tempimage);
 }
 
 


Follow ups