empathy r2288 - in trunk: libempathy-gtk src



Author: xclaesse
Date: Fri Jan 30 17:07:45 2009
New Revision: 2288
URL: http://svn.gnome.org/viewvc/empathy?rev=2288&view=rev

Log:
Add a convenience function to avoid hacks when getting the pixbuf from the icon name.

Modified:
   trunk/libempathy-gtk/empathy-ui-utils.c
   trunk/libempathy-gtk/empathy-ui-utils.h
   trunk/src/empathy-chat-window.c
   trunk/src/empathy-status-icon.c

Modified: trunk/libempathy-gtk/empathy-ui-utils.c
==============================================================================
--- trunk/libempathy-gtk/empathy-ui-utils.c	(original)
+++ trunk/libempathy-gtk/empathy-ui-utils.c	Fri Jan 30 17:07:45 2009
@@ -544,14 +544,12 @@
 }
 
 GdkPixbuf *
-empathy_pixbuf_from_icon_name (const gchar *icon_name,
-			      GtkIconSize  icon_size)
+empathy_pixbuf_from_icon_name_sized (const gchar *icon_name,
+				     gint size)
 {
-	GtkIconTheme  *theme;
-	GdkPixbuf     *pixbuf = NULL;
-	GError        *error = NULL;
-	gint           w, h;
-	gint           size = 48;
+	GtkIconTheme *theme;
+	GdkPixbuf *pixbuf;
+	GError *error;
 
 	if (!icon_name) {
 		return NULL;
@@ -559,10 +557,6 @@
 
 	theme = gtk_icon_theme_get_default ();
 
-	if (gtk_icon_size_lookup (icon_size, &w, &h)) {
-		size = (w + h) / 2;
-	}
-
 	pixbuf = gtk_icon_theme_load_icon (theme,
 					   icon_name,
 					   size,
@@ -576,6 +570,24 @@
 	return pixbuf;
 }
 
+GdkPixbuf *
+empathy_pixbuf_from_icon_name (const gchar *icon_name,
+			      GtkIconSize  icon_size)
+{
+	gint           w, h;
+	gint           size = 48;
+
+	if (!icon_name) {
+		return NULL;
+	}
+
+	if (gtk_icon_size_lookup (icon_size, &w, &h)) {
+		size = (w + h) / 2;
+	}
+
+	return empathy_pixbuf_from_icon_name_sized (icon_name, size);
+}
+
 /* Stolen from GtkSourceView, hence the weird intendation. Please keep it like
  * that to make it easier to apply changes from the original code.
  */

Modified: trunk/libempathy-gtk/empathy-ui-utils.h
==============================================================================
--- trunk/libempathy-gtk/empathy-ui-utils.h	(original)
+++ trunk/libempathy-gtk/empathy-ui-utils.h	Fri Jan 30 17:07:45 2009
@@ -98,6 +98,8 @@
 							 gint              max_size);
 GdkPixbuf * empathy_pixbuf_from_icon_name               (const gchar      *icon_name,
 							 GtkIconSize       icon_size);
+GdkPixbuf * empathy_pixbuf_from_icon_name_sized         (const gchar      *icon_name,
+               gint              size);
 /* Text view */
 gboolean    empathy_text_iter_forward_search            (const GtkTextIter*iter,
 							 const gchar      *str,

Modified: trunk/src/empathy-chat-window.c
==============================================================================
--- trunk/src/empathy-chat-window.c	(original)
+++ trunk/src/empathy-chat-window.c	Fri Jan 30 17:07:45 2009
@@ -852,7 +852,7 @@
 	reason = notify_notification_get_closed_reason (notify);
 
 	if (reason == 2) {
-		empathy_chat_window_present_chat (chat);
+		g_idle_add ((GSourceFunc) notification_closed_idle_cb, chat);
 	}
 }
 
@@ -877,9 +877,8 @@
 	body = empathy_message_get_body (message);
 	pixbuf = empathy_pixbuf_avatar_from_contact_scaled (sender, 48, 48);
 	if (pixbuf == NULL) {
-		/* we use INVALID here so we fall pack to 48px */
-		pixbuf = empathy_pixbuf_from_icon_name (EMPATHY_IMAGE_NEW_MESSAGE,
-							GTK_ICON_SIZE_INVALID);
+		pixbuf = empathy_pixbuf_from_icon_name_sized
+				(EMPATHY_IMAGE_NEW_MESSAGE, 48);
 	}
 
 	if (priv->notification != NULL) {

Modified: trunk/src/empathy-status-icon.c
==============================================================================
--- trunk/src/empathy-status-icon.c	(original)
+++ trunk/src/empathy-status-icon.c	Fri Jan 30 17:07:45 2009
@@ -126,9 +126,8 @@
 			}
 
 			if (!pixbuf) {
-				/* we use INVALID here so we fall pack to 48px */
-				pixbuf = empathy_pixbuf_from_icon_name (priv->event->icon_name,
-									GTK_ICON_SIZE_INVALID);
+				pixbuf = empathy_pixbuf_from_icon_name_sized
+						(priv->event->icon_name, 48);
 			}
 
 			priv->notification = notify_notification_new_with_status_icon



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