empathy r1981 - trunk/libempathy-gtk



Author: xclaesse
Date: Tue Dec 16 09:23:47 2008
New Revision: 1981
URL: http://svn.gnome.org/viewvc/empathy?rev=1981&view=rev

Log:
Fix licence and clean up a bit the interface

Modified:
   trunk/libempathy-gtk/empathy-chat-simple-view.h
   trunk/libempathy-gtk/empathy-chat-view.c
   trunk/libempathy-gtk/empathy-chat-view.h
   trunk/libempathy-gtk/empathy-chat.c
   trunk/libempathy-gtk/empathy-log-window.c

Modified: trunk/libempathy-gtk/empathy-chat-simple-view.h
==============================================================================
--- trunk/libempathy-gtk/empathy-chat-simple-view.h	(original)
+++ trunk/libempathy-gtk/empathy-chat-simple-view.h	Tue Dec 16 09:23:47 2008
@@ -55,8 +55,8 @@
 	GtkTextViewClass parent_class;
 };
 
-GType            empathy_chat_simple_view_get_type             (void) G_GNUC_CONST;
-EmpathyChatSimpleView *empathy_chat_simple_view_new                  (void);
+GType                  empathy_chat_simple_view_get_type (void) G_GNUC_CONST;
+EmpathyChatSimpleView *empathy_chat_simple_view_new      (void);
 
 G_END_DECLS
 

Modified: trunk/libempathy-gtk/empathy-chat-view.c
==============================================================================
--- trunk/libempathy-gtk/empathy-chat-view.c	(original)
+++ trunk/libempathy-gtk/empathy-chat-view.c	Tue Dec 16 09:23:47 2008
@@ -1,6 +1,6 @@
 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
 /*
- * Copyright (C) 2002-2007 Imendio AB
+ * Copyright (C) 2008 Collabora Ltd.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License as
@@ -17,28 +17,16 @@
  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  * Boston, MA 02111-1307, USA.
  * 
- * Authors: Mikael Hallendal <micke imendio com>
- *          Richard Hult <richard imendio com>
- *          Martyn Russell <martyn imendio com>
+ * Authors: Xavier Claessens <xclaesse gmail com>
  */
 
 #include "config.h"
 
 #include <telepathy-glib/util.h>
-#include <libmissioncontrol/mc-account.h>
-
-#include <libempathy/empathy-utils.h>
 
 #include "empathy-chat-view.h"
-
-#include "empathy-chat.h"
-#include "empathy-conf.h"
-#include "empathy-ui-utils.h"
-
 #include "empathy-smiley-manager.h"
-
-#define DEBUG_FLAG EMPATHY_DEBUG_CHAT
-#include <libempathy/empathy-debug.h>
+#include "empathy-ui-utils.h"
 
 static void chat_view_base_init (gpointer klass);
 
@@ -74,99 +62,6 @@
 	}
 }
 
-/* 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;
-}
-
-typedef struct {
-	GdkPixbuf *pixbuf;
-	gchar     *token;
-} AvatarData;
-
-static void
-chat_view_avatar_cache_data_free (gpointer ptr)
-{
-	AvatarData *data = ptr;
-
-	g_object_unref (data->pixbuf);
-	g_free (data->token);
-	g_slice_free (AvatarData, data);
-}
-
-GdkPixbuf *
-empathy_chat_view_get_avatar_pixbuf_with_cache (EmpathyContact *contact)
-{
-	AvatarData        *data;
-	EmpathyAvatar     *avatar;
-	GdkPixbuf         *tmp_pixbuf;
-	GdkPixbuf         *pixbuf = NULL;
-
-	/* Check if avatar is in cache and if it's up to date */
-	avatar = empathy_contact_get_avatar (contact);
-	data = g_object_get_data (G_OBJECT (contact), "chat-view-avatar-cache");
-	if (data) {
-		if (avatar && !tp_strdiff (avatar->token, data->token)) {
-			/* We have the avatar in cache */
-			return data->pixbuf;
-		}
-	}
-
-	/* Avatar not in cache, create pixbuf */
-	tmp_pixbuf = empathy_pixbuf_avatar_from_contact_scaled (contact, 32, 32);
-	if (tmp_pixbuf) {
-		pixbuf = chat_view_pad_to_size (tmp_pixbuf, 32, 32, 6);
-		g_object_unref (tmp_pixbuf);
-	}
-	if (!pixbuf) {
-		return NULL;
-	}
-
-	/* Insert new pixbuf in cache */
-	data = g_slice_new0 (AvatarData);
-	data->token = g_strdup (avatar->token);
-	data->pixbuf = pixbuf;
-
-	g_object_set_data_full (G_OBJECT (contact), "chat-view-avatar-cache",
-				data, chat_view_avatar_cache_data_free);
-
-	return data->pixbuf;
-}
-
 void
 empathy_chat_view_scroll_down (EmpathyChatView *view)
 {
@@ -354,6 +249,132 @@
 	}
 }
 
+time_t
+empathy_chat_view_get_last_timestamp (EmpathyChatView *view)
+{
+	g_return_val_if_fail (EMPATHY_IS_CHAT_VIEW (view), 0);
+	
+	if (EMPATHY_TYPE_CHAT_VIEW_GET_IFACE (view)->get_last_timestamp) {
+		return EMPATHY_TYPE_CHAT_VIEW_GET_IFACE (view)->get_last_timestamp (view);
+	}
+	return 0;
+}
+
+void
+empathy_chat_view_set_last_timestamp (EmpathyChatView *view,
+				      time_t          timestamp)
+{
+	g_return_if_fail (EMPATHY_IS_CHAT_VIEW (view));
+	
+	if (EMPATHY_TYPE_CHAT_VIEW_GET_IFACE (view)->set_last_timestamp) {
+		EMPATHY_TYPE_CHAT_VIEW_GET_IFACE (view)->set_last_timestamp (view, timestamp);
+	}
+}
+
+EmpathyContact *
+empathy_chat_view_get_last_contact (EmpathyChatView *view)
+{
+	g_return_val_if_fail (EMPATHY_IS_CHAT_VIEW (view), NULL);
+	
+	if (EMPATHY_TYPE_CHAT_VIEW_GET_IFACE (view)->get_last_contact) {
+		return EMPATHY_TYPE_CHAT_VIEW_GET_IFACE (view)->get_last_contact (view);
+	}
+	return NULL;
+}
+
+/* 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;
+}
+
+typedef struct {
+	GdkPixbuf *pixbuf;
+	gchar     *token;
+} AvatarData;
+
+static void
+chat_view_avatar_cache_data_free (gpointer ptr)
+{
+	AvatarData *data = ptr;
+
+	g_object_unref (data->pixbuf);
+	g_free (data->token);
+	g_slice_free (AvatarData, data);
+}
+
+GdkPixbuf *
+empathy_chat_view_get_avatar_pixbuf_with_cache (EmpathyContact *contact)
+{
+	AvatarData        *data;
+	EmpathyAvatar     *avatar;
+	GdkPixbuf         *tmp_pixbuf;
+	GdkPixbuf         *pixbuf = NULL;
+
+	/* Check if avatar is in cache and if it's up to date */
+	avatar = empathy_contact_get_avatar (contact);
+	data = g_object_get_data (G_OBJECT (contact), "chat-view-avatar-cache");
+	if (data) {
+		if (avatar && !tp_strdiff (avatar->token, data->token)) {
+			/* We have the avatar in cache */
+			return data->pixbuf;
+		}
+	}
+
+	/* Avatar not in cache, create pixbuf */
+	tmp_pixbuf = empathy_pixbuf_avatar_from_contact_scaled (contact, 32, 32);
+	if (tmp_pixbuf) {
+		pixbuf = chat_view_pad_to_size (tmp_pixbuf, 32, 32, 6);
+		g_object_unref (tmp_pixbuf);
+	}
+	if (!pixbuf) {
+		return NULL;
+	}
+
+	/* Insert new pixbuf in cache */
+	data = g_slice_new0 (AvatarData);
+	data->token = g_strdup (avatar->token);
+	data->pixbuf = pixbuf;
+
+	g_object_set_data_full (G_OBJECT (contact), "chat-view-avatar-cache",
+				data, chat_view_avatar_cache_data_free);
+
+	return data->pixbuf;
+}
+
 GtkWidget *
 empathy_chat_view_get_smiley_menu (GCallback    callback,
 				   gpointer     user_data)
@@ -403,36 +424,3 @@
 	return menu;
 }
 
-time_t
-empathy_chat_view_get_last_timestamp (EmpathyChatView *view)
-{
-	g_return_val_if_fail (EMPATHY_IS_CHAT_VIEW (view), 0);
-	
-	if (EMPATHY_TYPE_CHAT_VIEW_GET_IFACE (view)->get_last_timestamp) {
-		return EMPATHY_TYPE_CHAT_VIEW_GET_IFACE (view)->get_last_timestamp (view);
-	}
-	return 0;
-}
-
-void
-empathy_chat_view_set_last_timestamp (EmpathyChatView *view,
-				      time_t          timestamp)
-{
-	g_return_if_fail (EMPATHY_IS_CHAT_VIEW (view));
-	
-	if (EMPATHY_TYPE_CHAT_VIEW_GET_IFACE (view)->set_last_timestamp) {
-		EMPATHY_TYPE_CHAT_VIEW_GET_IFACE (view)->set_last_timestamp (view, timestamp);
-	}
-}
-
-EmpathyContact *
-empathy_chat_view_get_last_contact (EmpathyChatView *view)
-{
-	g_return_val_if_fail (EMPATHY_IS_CHAT_VIEW (view), NULL);
-	
-	if (EMPATHY_TYPE_CHAT_VIEW_GET_IFACE (view)->get_last_contact) {
-		return EMPATHY_TYPE_CHAT_VIEW_GET_IFACE (view)->get_last_contact (view);
-	}
-	return NULL;
-}
-

Modified: trunk/libempathy-gtk/empathy-chat-view.h
==============================================================================
--- trunk/libempathy-gtk/empathy-chat-view.h	(original)
+++ trunk/libempathy-gtk/empathy-chat-view.h	Tue Dec 16 09:23:47 2008
@@ -1,6 +1,6 @@
 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
 /*
- * Copyright (C) 2002-2007 Imendio AB
+ * Copyright (C) 2008 Collabora Ltd.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License as
@@ -17,9 +17,7 @@
  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  * Boston, MA 02111-1307, USA.
  * 
- * Authors: Mikael Hallendal <micke imendio com>
- *          Richard Hult <richard imendio com>
- *          Martyn Russell <martyn imendio com>
+ * Authors: Xavier Claessens <xclaesse gmail com>
  */
 
 #ifndef __EMPATHY_CHAT_VIEW_H__
@@ -36,7 +34,6 @@
 #define EMPATHY_CHAT_VIEW(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), EMPATHY_TYPE_CHAT_VIEW, EmpathyChatView))
 #define EMPATHY_IS_CHAT_VIEW(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), EMPATHY_TYPE_CHAT_VIEW))
 #define EMPATHY_TYPE_CHAT_VIEW_GET_IFACE(o) (G_TYPE_INSTANCE_GET_INTERFACE ((o), EMPATHY_TYPE_CHAT_VIEW, EmpathyChatViewIface))
-#define empathy_chat_view_new(o)	EMPATHY_CHAT_VIEW(empathy_chat_simple_view_new(o))
 
 typedef struct _EmpathyChatView      EmpathyChatView;
 typedef struct _EmpathyChatViewIface EmpathyChatViewIface;
@@ -47,47 +44,47 @@
 	GTypeInterface   base_iface;
 
 	/* VTabled */
-void             (*append_message)       (EmpathyChatView *view,
-							 EmpathyMessage  *msg);
-void             (*append_event)         (EmpathyChatView *view,
-							 const gchar     *str);
-void             (*append_button)        (EmpathyChatView *view,
-							 const gchar     *message,
-							 GtkWidget       *button1,
-							 GtkWidget       *button2);
-void             (*set_margin)           (EmpathyChatView *view,
-							 gint             margin);
-void             (*scroll)               (EmpathyChatView *view,
-							 gboolean         allow_scrolling);
-void             (*scroll_down)          (EmpathyChatView *view);
-gboolean         (*get_selection_bounds) (EmpathyChatView *view,
-							 GtkTextIter     *start,
-							 GtkTextIter     *end);
-void             (*clear)                (EmpathyChatView *view);
-gboolean         (*find_previous)        (EmpathyChatView *view,
-							 const gchar     *search_criteria,
-							 gboolean         new_search);
-gboolean         (*find_next)            (EmpathyChatView *view,
-							 const gchar     *search_criteria,
-							 gboolean         new_search);
-void             (*find_abilities)       (EmpathyChatView *view,
-							 const gchar     *search_criteria,
-							 gboolean        *can_do_previous,
-							 gboolean        *can_do_next);
-void             (*highlight)            (EmpathyChatView *view,
-							 const gchar     *text);
-void             (*copy_clipboard)       (EmpathyChatView *view);
-EmpathyTheme *   (*get_theme)            (EmpathyChatView *view);
-void             (*set_theme)            (EmpathyChatView *view,
-							 EmpathyTheme    *theme);
-time_t           (*get_last_timestamp)   (EmpathyChatView *view);
-void             (*set_last_timestamp)   (EmpathyChatView *view,
-							 time_t           timestamp);
-EmpathyContact * (*get_last_contact)     (EmpathyChatView *view);
+	void             (*append_message)       (EmpathyChatView *view,
+						  EmpathyMessage  *msg);
+	void             (*append_event)         (EmpathyChatView *view,
+						  const gchar     *str);
+	void             (*append_button)        (EmpathyChatView *view,
+						  const gchar     *message,
+						  GtkWidget       *button1,
+						  GtkWidget       *button2);
+	void             (*set_margin)           (EmpathyChatView *view,
+						  gint             margin);
+	void             (*scroll)               (EmpathyChatView *view,
+						  gboolean         allow_scrolling);
+	void             (*scroll_down)          (EmpathyChatView *view);
+	gboolean         (*get_selection_bounds) (EmpathyChatView *view,
+						  GtkTextIter     *start,
+						  GtkTextIter     *end);
+	void             (*clear)                (EmpathyChatView *view);
+	gboolean         (*find_previous)        (EmpathyChatView *view,
+						  const gchar     *search_criteria,
+						  gboolean         new_search);
+	gboolean         (*find_next)            (EmpathyChatView *view,
+						  const gchar     *search_criteria,
+						  gboolean         new_search);
+	void             (*find_abilities)       (EmpathyChatView *view,
+						  const gchar     *search_criteria,
+						  gboolean        *can_do_previous,
+						  gboolean        *can_do_next);
+	void             (*highlight)            (EmpathyChatView *view,
+						  const gchar     *text);
+	void             (*copy_clipboard)       (EmpathyChatView *view);
+	EmpathyTheme *   (*get_theme)            (EmpathyChatView *view);
+	void             (*set_theme)            (EmpathyChatView *view,
+						  EmpathyTheme    *theme);
+	time_t           (*get_last_timestamp)   (EmpathyChatView *view);
+	void             (*set_last_timestamp)   (EmpathyChatView *view,
+						  time_t           timestamp);
+	EmpathyContact * (*get_last_contact)     (EmpathyChatView *view);
 
 };
 
-GType    empathy_chat_view_get_type          (void) G_GNUC_CONST;
+GType            empathy_chat_view_get_type             (void) G_GNUC_CONST;
 void             empathy_chat_view_append_message       (EmpathyChatView *view,
 							 EmpathyMessage  *msg);
 void             empathy_chat_view_append_event         (EmpathyChatView *view,
@@ -121,17 +118,16 @@
 							 EmpathyTheme    *theme);
 void             empathy_chat_view_set_margin           (EmpathyChatView *view,
 							 gint             margin);
-GtkWidget *      empathy_chat_view_get_smiley_menu      (GCallback        callback,
-							 gpointer         user_data);
 time_t           empathy_chat_view_get_last_timestamp   (EmpathyChatView *view);
 void             empathy_chat_view_set_last_timestamp   (EmpathyChatView *view,
 							 time_t           timestamp);
 EmpathyContact * empathy_chat_view_get_last_contact     (EmpathyChatView *view);
+
 GdkPixbuf *      empathy_chat_view_get_avatar_pixbuf_with_cache (EmpathyContact *contact);
+GtkWidget *      empathy_chat_view_get_smiley_menu      (GCallback        callback,
+							 gpointer         user_data);
 
 G_END_DECLS
 
-#include "empathy-chat-simple-view.h"
-
 #endif /* __EMPATHY_CHAT_VIEW_H__ */
 

Modified: trunk/libempathy-gtk/empathy-chat.c
==============================================================================
--- trunk/libempathy-gtk/empathy-chat.c	(original)
+++ trunk/libempathy-gtk/empathy-chat.c	Tue Dec 16 09:23:47 2008
@@ -48,6 +48,7 @@
 #include "empathy-contact-list-store.h"
 #include "empathy-contact-list-view.h"
 #include "empathy-contact-menu.h"
+#include "empathy-chat-simple-view.h"
 #include "empathy-ui-utils.h"
 
 #define DEBUG_FLAG EMPATHY_DEBUG_CHAT
@@ -1266,7 +1267,7 @@
 	g_object_unref (glade);
 
 	/* Add message GtkTextView. */
-	chat->view = empathy_chat_view_new ();
+	chat->view = EMPATHY_CHAT_VIEW (empathy_chat_simple_view_new ());
 	g_signal_connect (chat->view, "focus_in_event",
 			  G_CALLBACK (chat_text_view_focus_in_event_cb),
 			  chat);

Modified: trunk/libempathy-gtk/empathy-log-window.c
==============================================================================
--- trunk/libempathy-gtk/empathy-log-window.c	(original)
+++ trunk/libempathy-gtk/empathy-log-window.c	Tue Dec 16 09:23:47 2008
@@ -41,6 +41,7 @@
 #include "empathy-log-window.h"
 #include "empathy-account-chooser.h"
 #include "empathy-chat-view.h"
+#include "empathy-chat-simple-view.h"
 #include "empathy-ui-utils.h"
 
 #define DEBUG_FLAG EMPATHY_DEBUG_OTHER
@@ -207,13 +208,13 @@
 			  window);
 
 	/* Configure Search EmpathyChatView */
-	window->chatview_find = empathy_chat_view_new ();
+	window->chatview_find = EMPATHY_CHAT_VIEW (empathy_chat_simple_view_new ());
 	gtk_container_add (GTK_CONTAINER (window->scrolledwindow_find),
 			   GTK_WIDGET (window->chatview_find));
 	gtk_widget_show (GTK_WIDGET (window->chatview_find));
 
 	/* Configure Contacts EmpathyChatView */
-	window->chatview_chats = empathy_chat_view_new ();
+	window->chatview_chats = EMPATHY_CHAT_VIEW (empathy_chat_simple_view_new ());
 	gtk_container_add (GTK_CONTAINER (window->scrolledwindow_chats),
 			   GTK_WIDGET (window->chatview_chats));
 	gtk_widget_show (GTK_WIDGET (window->chatview_chats));



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