aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy-gtk
diff options
context:
space:
mode:
authorXavier Claessens <xclaesse@src.gnome.org>2007-05-02 00:21:04 +0800
committerXavier Claessens <xclaesse@src.gnome.org>2007-05-02 00:21:04 +0800
commit7281af564d14018e6ebb33bd2febb51228251552 (patch)
tree573feff246bcfb19f1829de73bf98d4b85bc0c5e /libempathy-gtk
parent90c1acfbd86f4033550637364fabfacb09b8bb1c (diff)
downloadgsoc2013-empathy-7281af564d14018e6ebb33bd2febb51228251552.tar
gsoc2013-empathy-7281af564d14018e6ebb33bd2febb51228251552.tar.gz
gsoc2013-empathy-7281af564d14018e6ebb33bd2febb51228251552.tar.bz2
gsoc2013-empathy-7281af564d14018e6ebb33bd2febb51228251552.tar.lz
gsoc2013-empathy-7281af564d14018e6ebb33bd2febb51228251552.tar.xz
gsoc2013-empathy-7281af564d14018e6ebb33bd2febb51228251552.tar.zst
gsoc2013-empathy-7281af564d14018e6ebb33bd2febb51228251552.zip
[darcs-to-svn @ move some code from GossipPrivateChat to GossipChatView]
svn path=/trunk/; revision=18
Diffstat (limited to 'libempathy-gtk')
-rw-r--r--libempathy-gtk/gossip-chat-view.c53
-rw-r--r--libempathy-gtk/gossip-private-chat.c42
2 files changed, 51 insertions, 44 deletions
diff --git a/libempathy-gtk/gossip-chat-view.c b/libempathy-gtk/gossip-chat-view.c
index cc6482ee8..046a5507c 100644
--- a/libempathy-gtk/gossip-chat-view.c
+++ b/libempathy-gtk/gossip-chat-view.c
@@ -246,6 +246,10 @@ static void chat_view_append_irc_message (GossipChatView *
GossipMessage *msg);
static void chat_view_append_fancy_message (GossipChatView *view,
GossipMessage *msg);
+static GdkPixbuf *chat_view_pad_to_size (GdkPixbuf *pixbuf,
+ gint width,
+ gint height,
+ gint extra_padding_right);
G_DEFINE_TYPE (GossipChatView, gossip_chat_view, GTK_TYPE_TEXT_VIEW);
@@ -1055,7 +1059,8 @@ chat_view_maybe_append_fancy_header (GossipChatView *view,
const gchar *line_top_tag;
const gchar *line_bottom_tag;
gboolean from_self;
- GdkPixbuf *avatar;
+ GdkPixbuf *pixbuf = NULL;
+ GdkPixbuf *avatar = NULL;
priv = GET_PRIV (view);
@@ -1111,7 +1116,12 @@ chat_view_maybe_append_fancy_header (GossipChatView *view,
line_top_tag,
NULL);
- avatar = gossip_pixbuf_avatar_from_contact_scaled (sender, 32, 32);
+ /* FIXME: we should have a cash of avatar pixbufs */
+ pixbuf = gossip_pixbuf_avatar_from_contact_scaled (sender, 32, 32);
+ if (pixbuf) {
+ avatar = chat_view_pad_to_size (pixbuf, 32, 32, 6);
+ g_object_unref (pixbuf);
+ }
if (avatar) {
GtkTextIter start;
@@ -1369,6 +1379,45 @@ chat_view_theme_changed_cb (GossipThemeManager *manager,
gossip_theme_manager_update_show_avatars (manager, view, show_avatars);
}
+/* Pads a pixbuf to the specified size, by centering it in a larger transparent
+ * pixbuf. Returns a new ref.
+ */
+static GdkPixbuf *
+chat_view_pad_to_size (GdkPixbuf *pixbuf,
+ gint width,
+ gint height,
+ gint extra_padding_right)
+{
+ gint src_width, src_height;
+ GdkPixbuf *padded;
+ gint x_offset, y_offset;
+
+ src_width = gdk_pixbuf_get_width (pixbuf);
+ src_height = gdk_pixbuf_get_height (pixbuf);
+
+ x_offset = (width - src_width) / 2;
+ y_offset = (height - src_height) / 2;
+
+ padded = gdk_pixbuf_new (gdk_pixbuf_get_colorspace (pixbuf),
+ TRUE, /* alpha */
+ gdk_pixbuf_get_bits_per_sample (pixbuf),
+ width + extra_padding_right,
+ height);
+
+ gdk_pixbuf_fill (padded, 0);
+
+ gdk_pixbuf_copy_area (pixbuf,
+ 0, /* source coords */
+ 0,
+ src_width,
+ src_height,
+ padded,
+ x_offset, /* dest coords */
+ y_offset);
+
+ return padded;
+}
+
GossipChatView *
gossip_chat_view_new (void)
{
diff --git a/libempathy-gtk/gossip-private-chat.c b/libempathy-gtk/gossip-private-chat.c
index c9a44bf04..17c55b19c 100644
--- a/libempathy-gtk/gossip-private-chat.c
+++ b/libempathy-gtk/gossip-private-chat.c
@@ -453,45 +453,3 @@ gossip_private_chat_new_with_channel (GossipContact *contact,
return chat;
}
-/* Pads a pixbuf to the specified size, by centering it in a larger transparent
- * pixbuf. Returns a new ref.
- */
-#if 0
-FIXME:
-static GdkPixbuf *
-private_chat_pad_to_size (GdkPixbuf *pixbuf,
- gint width,
- gint height,
- gint extra_padding_right)
-{
- gint src_width, src_height;
- GdkPixbuf *padded;
- gint x_offset, y_offset;
-
- src_width = gdk_pixbuf_get_width (pixbuf);
- src_height = gdk_pixbuf_get_height (pixbuf);
-
- x_offset = (width - src_width) / 2;
- y_offset = (height - src_height) / 2;
-
- padded = gdk_pixbuf_new (gdk_pixbuf_get_colorspace (pixbuf),
- TRUE, /* alpha */
- gdk_pixbuf_get_bits_per_sample (pixbuf),
- width + extra_padding_right,
- height);
-
- gdk_pixbuf_fill (padded, 0);
-
- gdk_pixbuf_copy_area (pixbuf,
- 0, /* source coords */
- 0,
- src_width,
- src_height,
- padded,
- x_offset, /* dest coords */
- y_offset);
-
- return padded;
-}
-#endif
-