empathy r1966 - in trunk: libempathy libempathy-gtk src



Author: xclaesse
Date: Fri Dec 12 15:49:15 2008
New Revision: 1966
URL: http://svn.gnome.org/viewvc/empathy?rev=1966&view=rev

Log:
Add empathy_init(), empathy_gtk_init() and empathy_gtk_init_with_args(). They have to be called by any process using libempathy.

Modified:
   trunk/libempathy-gtk/Makefile.am
   trunk/libempathy-gtk/empathy-ui-utils.c
   trunk/libempathy-gtk/empathy-ui-utils.h
   trunk/libempathy/Makefile.am
   trunk/libempathy/empathy-utils.c
   trunk/libempathy/empathy-utils.h
   trunk/src/Makefile.am
   trunk/src/empathy-logs.c
   trunk/src/empathy.c

Modified: trunk/libempathy-gtk/Makefile.am
==============================================================================
--- trunk/libempathy-gtk/Makefile.am	(original)
+++ trunk/libempathy-gtk/Makefile.am	Fri Dec 12 15:49:15 2008
@@ -2,6 +2,7 @@
 	-I.                                             \
 	-I$(top_srcdir)                                 \
 	-DDATADIR=\""$(datadir)"\"              	\
+	-DPKGDATADIR=\""$(pkgdatadir)"\"		\
 	$(EMPATHY_CFLAGS)				\
 	$(ENCHANT_CFLAGS)				\
 	$(WARN_CFLAGS)

Modified: trunk/libempathy-gtk/empathy-ui-utils.c
==============================================================================
--- trunk/libempathy-gtk/empathy-ui-utils.c	(original)
+++ trunk/libempathy-gtk/empathy-ui-utils.c	Fri Dec 12 15:49:15 2008
@@ -49,6 +49,47 @@
 #include <libempathy/empathy-utils.h>
 #include <libempathy/empathy-dispatcher.h>
 
+void
+empathy_gtk_init (int *argc, char ***argv)
+{
+	static gboolean initialized = FALSE;
+
+	if (initialized)
+		return;
+
+	empathy_init ();
+	gtk_init (argc, argv);
+	gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (),
+					   PKGDATADIR G_DIR_SEPARATOR_S "icons");
+
+	initialized = TRUE;
+}
+
+gboolean
+empathy_gtk_init_with_args (int *argc,
+			    char ***argv,
+			    char *parameter_string,
+			    GOptionEntry *entries,
+			    char *translation_domain,
+			    GError **error)
+{
+	static gboolean initialized = FALSE;
+	gboolean ret;
+
+	if (initialized)
+		return TRUE;
+
+	empathy_init ();
+	ret = gtk_init_with_args (argc, argv, parameter_string, entries,
+				  translation_domain, error);
+	gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (),
+					   PKGDATADIR G_DIR_SEPARATOR_S "icons");
+
+	initialized = TRUE;
+
+	return ret;
+}
+
 struct SizeData {
 	gint     width;
 	gint     height;

Modified: trunk/libempathy-gtk/empathy-ui-utils.h
==============================================================================
--- trunk/libempathy-gtk/empathy-ui-utils.h	(original)
+++ trunk/libempathy-gtk/empathy-ui-utils.h	Fri Dec 12 15:49:15 2008
@@ -46,6 +46,14 @@
 
 #define G_STR_EMPTY(x) ((x) == NULL || (x)[0] == '\0')
 
+void            empathy_gtk_init                        (int *argc,
+                                                         char ***argv);
+gboolean        empathy_gtk_init_with_args              (int *argc,
+                                                         char ***argv,
+                                                         char *parameter_string,
+                                                         GOptionEntry *entries,
+                                                         char *translation_domain,
+                                                         GError **error);
 /* Glade */
 void            empathy_glade_get_file_simple           (const gchar      *filename,
 							 const gchar      *root,

Modified: trunk/libempathy/Makefile.am
==============================================================================
--- trunk/libempathy/Makefile.am	(original)
+++ trunk/libempathy/Makefile.am	Fri Dec 12 15:49:15 2008
@@ -3,6 +3,7 @@
 	-I$(top_srcdir)                                 \
 	-I$(top_builddir)                               \
 	-DDATADIR=\""$(datadir)"\"              	\
+	-DLOCALEDIR=\""$(datadir)/locale"\"		\
 	$(LIBEMPATHY_CFLAGS)				\
 	$(WARN_CFLAGS)
 

Modified: trunk/libempathy/empathy-utils.c
==============================================================================
--- trunk/libempathy/empathy-utils.c	(original)
+++ trunk/libempathy/empathy-utils.c	Fri Dec 12 15:49:15 2008
@@ -43,6 +43,33 @@
 #define DEBUG_FLAG EMPATHY_DEBUG_OTHER
 #include "empathy-debug.h"
 
+void
+empathy_init (void)
+{
+	static gboolean initialized = FALSE;
+
+	if (initialized)
+		return;
+
+	/* Setup glib. Threads are required for async GIO. */
+	g_thread_init (NULL);
+	g_type_init ();
+
+	/* Setup gettext */
+	bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
+	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+	textdomain (GETTEXT_PACKAGE);
+
+	/* Setup debug output for empathy and telepathy-glib */
+	if (g_getenv ("EMPATHY_TIMING") != NULL) {
+		g_log_set_default_handler (tp_debug_timestamped_log_handler, NULL);
+	}
+	empathy_debug_set_flags (g_getenv ("EMPATHY_DEBUG"));
+	tp_debug_divert_messages (g_getenv ("EMPATHY_LOGFILE"));
+
+	initialized = TRUE;
+}
+
 gchar *
 empathy_substring (const gchar *str,
 		  gint         start,

Modified: trunk/libempathy/empathy-utils.h
==============================================================================
--- trunk/libempathy/empathy-utils.h	(original)
+++ trunk/libempathy/empathy-utils.h	Fri Dec 12 15:49:15 2008
@@ -42,6 +42,7 @@
 
 G_BEGIN_DECLS
 
+void         empathy_init                           (void);
 /* Strings */
 gchar *      empathy_substring                      (const gchar     *str,
 						    gint             start,

Modified: trunk/src/Makefile.am
==============================================================================
--- trunk/src/Makefile.am	(original)
+++ trunk/src/Makefile.am	Fri Dec 12 15:49:15 2008
@@ -1,11 +1,5 @@
 AM_CPPFLAGS =						\
 	-I$(top_srcdir)                          	\
-	-DPREFIX="\"$(prefix)"\"			\
-	-DSYSCONFDIR=\""$(sysconfdir)"\"		\
-	-DDATADIR=\""$(datadir)"\"              	\
-	-DPKGDATADIR=\""$(pkgdatadir)"\"		\
-	-DLIBDIR=\""$(libdir)"\"			\
-	-DLOCALEDIR=\""$(datadir)/locale"\"		\
 	$(EMPATHY_CFLAGS)				\
 	$(WARN_CFLAGS)
 

Modified: trunk/src/empathy-logs.c
==============================================================================
--- trunk/src/empathy-logs.c	(original)
+++ trunk/src/empathy-logs.c	Fri Dec 12 15:49:15 2008
@@ -21,15 +21,13 @@
  */
 
 #include <config.h>
-
-#include <string.h>
 #include <stdlib.h>
-
 #include <glib.h>
 #include <gtk/gtk.h>
 
 #include <libempathy/empathy-debug.h>
 #include <libempathy-gtk/empathy-log-window.h>
+#include <libempathy-gtk/empathy-ui-utils.h>
 
 static void
 destroy_cb (GtkWidget *dialog,
@@ -43,16 +41,10 @@
 {
 	GtkWidget *window;
 
-	gtk_init (&argc, &argv);
-
-	if (g_getenv ("EMPATHY_TIMING") != NULL) {
-		g_log_set_default_handler (tp_debug_timestamped_log_handler, NULL);
-	}
-	empathy_debug_set_flags (g_getenv ("EMPATHY_DEBUG"));
-	tp_debug_divert_messages (g_getenv ("EMPATHY_LOGFILE"));
+	empathy_gtk_init (&argc, &argv);
+	g_set_application_name (PACKAGE_NAME);
+	gtk_window_set_default_icon_name ("empathy");
 
-	gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (),
-					   PKGDATADIR G_DIR_SEPARATOR_S "icons");
 	window = empathy_log_window_show (NULL, NULL, FALSE, NULL);
 
 	g_signal_connect (window, "destroy",

Modified: trunk/src/empathy.c
==============================================================================
--- trunk/src/empathy.c	(original)
+++ trunk/src/empathy.c	Fri Dec 12 15:49:15 2008
@@ -44,6 +44,7 @@
 #include <libempathy/empathy-tp-group.h>
 
 #include <libempathy-gtk/empathy-conf.h>
+#include <libempathy-gtk/empathy-ui-utils.h>
 
 #include <extensions/extensions.h>
 
@@ -400,30 +401,16 @@
 		{ NULL }
 	};
 
-	bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
-	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
-	textdomain (GETTEXT_PACKAGE);
-
 	startup_timestamp = get_startup_timestamp ();
 
-	if (!gtk_init_with_args (&argc, &argv,
-				 _("- Empathy Instant Messenger"),
-				 options, GETTEXT_PACKAGE, &error)) {
-		g_warning ("Error in gtk init: %s", error->message);
+	if (!empathy_gtk_init_with_args (&argc, &argv,
+					 _("- Empathy Instant Messenger"),
+					 options, GETTEXT_PACKAGE, &error)) {
+		g_warning ("Error in empathy init: %s", error->message);
 		return EXIT_FAILURE;
 	}
-
-	if (g_getenv ("EMPATHY_TIMING") != NULL) {
-		g_log_set_default_handler (tp_debug_timestamped_log_handler, NULL);
-	}
-	empathy_debug_set_flags (g_getenv ("EMPATHY_DEBUG"));
-	tp_debug_divert_messages (g_getenv ("EMPATHY_LOGFILE"));
-
 	g_set_application_name (PACKAGE_NAME);
-
 	gtk_window_set_default_icon_name ("empathy");
-	gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (),
-					   PKGDATADIR G_DIR_SEPARATOR_S "icons");
 
         /* Setting up the bacon connection */
 	connection = bacon_message_connection_new ("empathy");



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