]> git.0d.be Git - empathy.git/commitdiff
Factor out some common code.
authorXavier Claessens <xclaesse@src.gnome.org>
Fri, 30 Jan 2009 17:08:29 +0000 (17:08 +0000)
committerXavier Claessens <xclaesse@src.gnome.org>
Fri, 30 Jan 2009 17:08:29 +0000 (17:08 +0000)
svn path=/trunk/; revision=2302

src/empathy-chat-window.c
src/empathy-misc.c
src/empathy-misc.h
src/empathy-status-icon.c

index fdf1f54439b42f973f9c6745d6427b750d050681..83f9c81666cafa96491302442a03d9337c1de06e 100644 (file)
@@ -893,11 +893,8 @@ chat_window_show_or_update_notification (EmpathyChatWindow *window,
                                  empathy_contact_get_name (sender));
        body = empathy_message_get_body (message);
        escaped = g_markup_escape_text (body, -1);
-       pixbuf = empathy_pixbuf_avatar_from_contact_scaled (sender, 48, 48);
-       if (pixbuf == NULL) {
-               pixbuf = empathy_pixbuf_from_icon_name_sized
-                               (EMPATHY_IMAGE_NEW_MESSAGE, 48);
-       }
+
+       pixbuf = empathy_misc_get_pixbuf_for_notification (sender, EMPATHY_IMAGE_NEW_MESSAGE);
 
        if (priv->notification != NULL) {
                notify_notification_update (priv->notification,
index eb4baf3d4dc78195a988503625382da399168209..0a943bb6dc7018a5bcff10945276e85bca171f44 100644 (file)
 #include "empathy-misc.h"
 
 #include <libempathy/empathy-utils.h>
+#include <libempathy-gtk/empathy-ui-utils.h>
 #include <libempathy-gtk/empathy-conf.h>
 
 /* public methods */
+
+GdkPixbuf *
+empathy_misc_get_pixbuf_for_notification (EmpathyContact *contact,
+                                         const char *icon_name)
+{
+       GdkPixbuf *pixbuf = NULL;
+
+       if (contact != NULL) {
+               pixbuf = empathy_pixbuf_avatar_from_contact_scaled (contact,
+                                                                   48, 48);
+       }
+
+       if (!pixbuf) {
+               pixbuf = empathy_pixbuf_from_icon_name_sized
+                                       (icon_name, 48);
+       }
+
+       return pixbuf;
+}
+
 gboolean
 empathy_notification_is_enabled (void)
 {
index cc407b4ba5cc71641ff3696528e4f02f4c1a06ce..0d0613048ec95c8652aefbdcf67c0ab6f312f51f 100644 (file)
@@ -25,6 +25,9 @@
 #define __EMPATHY_MISC_H__
 
 #include <glib.h>
+#include <gdk-pixbuf/gdk-pixbuf.h>
+
+#include <libempathy/empathy-contact.h>
 
 G_BEGIN_DECLS
 
@@ -38,6 +41,8 @@ typedef enum {
 } NotificationClosedReason;
 
 gboolean    empathy_notification_is_enabled  (void);
+GdkPixbuf * empathy_misc_get_pixbuf_for_notification (EmpathyContact *contact,
+                                                      const char *icon_name);
 
 G_END_DECLS
 
index 197b22401f48e71b32a7f976db8d9a84ff3ba31e..d1907531823ab6b8a1991f75e52154af06c7de87 100644 (file)
@@ -101,7 +101,7 @@ status_icon_notification_closed_cb (NotifyNotification *notification,
        /* the notification has been closed by the user, see the
         * DesktopNotification spec.
         */
-       if (reason == 2) {
+       if (reason == NOTIFICATION_CLOSED_DISMISSED) {
                g_idle_add ((GSourceFunc) activate_event, priv->event);
        } else {
                /* inhibit other updates for this event */
@@ -109,24 +109,6 @@ status_icon_notification_closed_cb (NotifyNotification *notification,
        }
 }
 
-static GdkPixbuf *
-get_pixbuf_for_event (EmpathyEvent *event)
-{
-       GdkPixbuf *pixbuf = NULL;
-
-       if (event->contact != NULL) {
-               pixbuf = empathy_pixbuf_avatar_from_contact_scaled (event->contact,
-                                                                   48, 48);
-       }
-
-       if (!pixbuf) {
-               pixbuf = empathy_pixbuf_from_icon_name_sized
-                                       (event->icon_name, 48);
-       }
-
-       return pixbuf;
-}
-
 static void
 notification_close_helper (EmpathyStatusIconPriv *priv)
 {
@@ -150,7 +132,8 @@ status_icon_update_notification (EmpathyStatusIcon *icon)
        }
 
        if (priv->event) {
-               pixbuf = get_pixbuf_for_event (priv->event);
+               pixbuf = empathy_misc_get_pixbuf_for_notification (priv->event->contact,
+                                                                  priv->event->icon_name);
 
                if (priv->notification) {
                        notify_notification_update (priv->notification,