aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXavier Claessens <xclaesse@src.gnome.org>2009-01-31 01:08:29 +0800
committerXavier Claessens <xclaesse@src.gnome.org>2009-01-31 01:08:29 +0800
commit969df6cdc59df3e57c8c1619bd9a197124939c2d (patch)
tree811af868c2c3536ce320d2208a2b97fb2eb622be
parent885555ee46acc4f4fe96b04b554ee3a0f2ae4baa (diff)
downloadgsoc2013-empathy-969df6cdc59df3e57c8c1619bd9a197124939c2d.tar
gsoc2013-empathy-969df6cdc59df3e57c8c1619bd9a197124939c2d.tar.gz
gsoc2013-empathy-969df6cdc59df3e57c8c1619bd9a197124939c2d.tar.bz2
gsoc2013-empathy-969df6cdc59df3e57c8c1619bd9a197124939c2d.tar.lz
gsoc2013-empathy-969df6cdc59df3e57c8c1619bd9a197124939c2d.tar.xz
gsoc2013-empathy-969df6cdc59df3e57c8c1619bd9a197124939c2d.tar.zst
gsoc2013-empathy-969df6cdc59df3e57c8c1619bd9a197124939c2d.zip
Factor out some common code.
svn path=/trunk/; revision=2302
-rw-r--r--src/empathy-chat-window.c7
-rw-r--r--src/empathy-misc.c21
-rw-r--r--src/empathy-misc.h5
-rw-r--r--src/empathy-status-icon.c23
4 files changed, 31 insertions, 25 deletions
diff --git a/src/empathy-chat-window.c b/src/empathy-chat-window.c
index fdf1f5443..83f9c8166 100644
--- a/src/empathy-chat-window.c
+++ b/src/empathy-chat-window.c
@@ -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,
diff --git a/src/empathy-misc.c b/src/empathy-misc.c
index eb4baf3d4..0a943bb6d 100644
--- a/src/empathy-misc.c
+++ b/src/empathy-misc.c
@@ -24,9 +24,30 @@
#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)
{
diff --git a/src/empathy-misc.h b/src/empathy-misc.h
index cc407b4ba..0d0613048 100644
--- a/src/empathy-misc.h
+++ b/src/empathy-misc.h
@@ -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
diff --git a/src/empathy-status-icon.c b/src/empathy-status-icon.c
index 197b22401..d19075318 100644
--- a/src/empathy-status-icon.c
+++ b/src/empathy-status-icon.c
@@ -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,