[nautilus-actions] Fix regression when displaying a path-based icon



commit 88d3511658b0c6b6ef4dc83a20a68fd7783599f8
Author: pierre <pierre vfedora10 virtuals pwi>
Date:   Mon Aug 9 13:52:30 2010 +0200

    Fix regression when displaying a path-based icon
    
    This regression was first introduced in 2.29.3, when replacing na_object_item_get_pixbuf()
    by na_utils_get_pixbuf().

 ChangeLog                 |    7 +++++++
 src/nact/nact-gtk-utils.c |   27 +++++++++++++++++++++------
 src/nact/nact-gtk-utils.h |    4 ++--
 3 files changed, 30 insertions(+), 8 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 137ac35..111b89d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2010-08-09 Pierre Wieser <pwieser trychlos org>
+
+	* src/nact/nact-gtk-utils.c:
+	* src/nact/nact-gtk-utils.h
+	(nact_gtk_utils_get_pixbuf, nact_gtk_utils_render):
+	Size parameter is actually of GtkIconSize type.
+
 2010-08-07 Pierre Wieser <pwieser trychlos org>
 
 	* configure.ac: Bump version number after unstable release.
diff --git a/src/nact/nact-gtk-utils.c b/src/nact/nact-gtk-utils.c
index 95eae55..ce63cf9 100644
--- a/src/nact/nact-gtk-utils.c
+++ b/src/nact/nact-gtk-utils.c
@@ -43,6 +43,9 @@
 #include "nact-gtk-utils.h"
 #include "nact-application.h"
 
+#define DEFAULT_WIDTH		22
+#define DEFAULT_HEIGHT		22
+
 /**
  * nact_gtk_utils_set_editable:
  * @widget: the #GtkWdiget.
@@ -110,18 +113,24 @@ nact_gtk_utils_set_editable( GtkObject *widget, gboolean editable )
  * Returns a pixbuf for the given widget.
  */
 GdkPixbuf *
-nact_gtk_utils_get_pixbuf( const gchar *name, GtkWidget *widget, gint size )
+nact_gtk_utils_get_pixbuf( const gchar *name, GtkWidget *widget, GtkIconSize size )
 {
 	static const gchar *thisfn = "nact_gtk_utils_get_pixbuf";
 	GdkPixbuf* pixbuf;
 	GError *error;
+	gint width, height;
 
 	error = NULL;
 	pixbuf = NULL;
 
+	if( !gtk_icon_size_lookup( size, &width, &height )){
+		width = DEFAULT_WIDTH;
+		height = DEFAULT_HEIGHT;
+	}
+
 	if( name && strlen( name )){
 		if( g_path_is_absolute( name )){
-			pixbuf = gdk_pixbuf_new_from_file_at_size( name, size, size, &error );
+			pixbuf = gdk_pixbuf_new_from_file_at_size( name, width, height, &error );
 			if( error ){
 				if( error->code == G_FILE_ERROR_NOENT ){
 					g_debug( "%s: gdk_pixbuf_new_from_file_at_size: name=%s, error=%s", thisfn, name, error->message );
@@ -140,7 +149,7 @@ nact_gtk_utils_get_pixbuf( const gchar *name, GtkWidget *widget, gint size )
 
 	if( !pixbuf ){
 		g_debug( "%s: null pixbuf, loading transparent image", thisfn );
-		pixbuf = gdk_pixbuf_new_from_file_at_size( PKGDATADIR "/transparent.png", size, size, NULL );
+		pixbuf = gdk_pixbuf_new_from_file_at_size( PKGDATADIR "/transparent.png", width, height, NULL );
 	}
 
 	return( pixbuf );
@@ -155,14 +164,20 @@ nact_gtk_utils_get_pixbuf( const gchar *name, GtkWidget *widget, gint size )
  * Displays the (maybe themed) image on the given widget.
  */
 void
-nact_gtk_utils_render( const gchar *name, GtkImage *widget, gint size )
+nact_gtk_utils_render( const gchar *name, GtkImage *widget, GtkIconSize size )
 {
 	GdkPixbuf* pixbuf;
+	gint width, height;
 
 	if( name ){
 		pixbuf = nact_gtk_utils_get_pixbuf( name, GTK_WIDGET( widget ), size );
+
 	} else {
-		pixbuf = gdk_pixbuf_new_from_file_at_size( PKGDATADIR "/transparent.png", size, size, NULL );
+		if( !gtk_icon_size_lookup( size, &width, &height )){
+			width = DEFAULT_WIDTH;
+			height = DEFAULT_HEIGHT;
+		}
+		pixbuf = gdk_pixbuf_new_from_file_at_size( PKGDATADIR "/transparent.png", width, height, NULL );
 	}
 
 	if( pixbuf ){
@@ -179,7 +194,7 @@ nact_gtk_utils_render( const gchar *name, GtkImage *widget, gint size )
  *  its size and position.
  * @entry: the #GtkEntry which is associated with the selected file.
  * @entry_name: the name of the entry in Preferences to be readen/written.
- * @default_dir_uri: the URI of the directory which should be set in there is
+ * @default_dir_uri: the URI of the directory which should be set if there is
  *  not yet any preference (see @entry_name)
  *
  * Opens a #GtkFileChooserDialog and let the user choose an existing file
diff --git a/src/nact/nact-gtk-utils.h b/src/nact/nact-gtk-utils.h
index 2ba5c80..70f9d81 100644
--- a/src/nact/nact-gtk-utils.h
+++ b/src/nact/nact-gtk-utils.h
@@ -47,8 +47,8 @@ void       nact_gtk_utils_set_editable( GtkObject *widget, gboolean editable );
 
 /* image utilities
  */
-GdkPixbuf *nact_gtk_utils_get_pixbuf( const gchar *name, GtkWidget *widget, gint size );
-void       nact_gtk_utils_render( const gchar *name, GtkImage *widget, gint size );
+GdkPixbuf *nact_gtk_utils_get_pixbuf( const gchar *name, GtkWidget *widget, GtkIconSize size );
+void       nact_gtk_utils_render( const gchar *name, GtkImage *widget, GtkIconSize size );
 
 /* standard dialog boxes
  */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]