]> git.0d.be Git - empathy.git/commitdiff
Add a convenience function to avoid hacks when getting the pixbuf from the icon name.
authorXavier Claessens <xclaesse@src.gnome.org>
Fri, 30 Jan 2009 17:07:45 +0000 (17:07 +0000)
committerXavier Claessens <xclaesse@src.gnome.org>
Fri, 30 Jan 2009 17:07:45 +0000 (17:07 +0000)
svn path=/trunk/; revision=2288

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

index 7c6166839dd0ba8740175a23ec3a235573a444ea..1c20c2c9af58126553487c22bc1fb62ed260b007 100644 (file)
@@ -544,14 +544,12 @@ empathy_pixbuf_scale_down_if_necessary (GdkPixbuf *pixbuf, gint max_size)
 }
 
 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 @@ empathy_pixbuf_from_icon_name (const gchar *icon_name,
 
        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 @@ empathy_pixbuf_from_icon_name (const gchar *icon_name,
        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.
  */
index 455ddd7a2e8c885223793d94f665be006b0b8a6b..97fb271b3286d9b4505280b95b051599d25c8fe7 100644 (file)
@@ -98,6 +98,8 @@ GdkPixbuf * empathy_pixbuf_scale_down_if_necessary      (GdkPixbuf        *pixbu
                                                         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,
index 1bc9f2056b9d67ac55cd1514ed7da09144317161..e080a53174d8b11715d0fea189095c58c8a0f726 100644 (file)
@@ -852,7 +852,7 @@ chat_window_notification_closed_cb (NotifyNotification *notify,
        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 @@ chat_window_show_or_update_notification (EmpathyMessage *message,
        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) {
index 4c796456665d91e29542f4ac19e4c367b771590a..86a2c84fa8bf1dfe83f4706df7c1aa9b235af186 100644 (file)
@@ -126,9 +126,8 @@ status_icon_update_notification (EmpathyStatusIcon *icon)
                        }
 
                        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