]> git.0d.be Git - empathy.git/commitdiff
Add empathy_init(), empathy_gtk_init() and empathy_gtk_init_with_args(). They have...
authorXavier Claessens <xclaesse@src.gnome.org>
Fri, 12 Dec 2008 15:49:15 +0000 (15:49 +0000)
committerXavier Claessens <xclaesse@src.gnome.org>
Fri, 12 Dec 2008 15:49:15 +0000 (15:49 +0000)
svn path=/trunk/; revision=1966

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

index 17cfa4dc6988b904d8f711bb3a23fa1725caf99a..d2801762d26c019e51d6f86a85b289f1491b59be 100644 (file)
@@ -2,6 +2,7 @@ AM_CPPFLAGS =                                           \
        -I.                                             \
        -I$(top_srcdir)                                 \
        -DDATADIR=\""$(datadir)"\"                      \
+       -DPKGDATADIR=\""$(pkgdatadir)"\"                \
        $(EMPATHY_CFLAGS)                               \
        $(ENCHANT_CFLAGS)                               \
        $(WARN_CFLAGS)
index cd5cf0766a29fc7b138c8b9a94ac1f3a254fce2b..693bd81371803adebb30dbc217aee6208460d3e7 100644 (file)
 #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;
index 4a6efc6d03e032ad30b9a1145c7ddb0efbdc854a..777ce8ee015502d38dd329ecced001bbb7949d29 100644 (file)
@@ -46,6 +46,14 @@ G_BEGIN_DECLS
 
 #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,
index a25c1e799345919cb7263906f776eb2d5937f1b9..fd6424b57c080637dd12f24c8742f52b95ba9790 100644 (file)
@@ -3,6 +3,7 @@ AM_CPPFLAGS =                                           \
        -I$(top_srcdir)                                 \
        -I$(top_builddir)                               \
        -DDATADIR=\""$(datadir)"\"                      \
+       -DLOCALEDIR=\""$(datadir)/locale"\"             \
        $(LIBEMPATHY_CFLAGS)                            \
        $(WARN_CFLAGS)
 
index 671595e68b55cbf1be3a200d80bed8c610cf5517..dc06081f35d0a48ef98885e8a079a572100e637b 100644 (file)
 #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,
index 51ddd231f710cf8c762152357c14ed00a1f109e8..9147b6991dfbf7f02492927f86b260a4b561e49e 100644 (file)
@@ -42,6 +42,7 @@
 
 G_BEGIN_DECLS
 
+void         empathy_init                           (void);
 /* Strings */
 gchar *      empathy_substring                      (const gchar     *str,
                                                    gint             start,
index 4112f65e40e4763e7a672e882dd05d049ebe32e7..d9c2b2aa4403c7eb4fe1ecc66dc9d7c0446f4f82 100644 (file)
@@ -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)
 
index f49207ebfb05e977aea5c69ec5f818fc7b34c5e0..f805f909448d39f904712392cc3a5a1c02f9c799 100644 (file)
  */
 
 #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 @@ main (int argc, char *argv[])
 {
        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",
index dc295be6de9af6236373076495a0795c8abee1a8..8a0bf5abd64ed1fe179f587877bbf03625f35933 100644 (file)
@@ -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 @@ main (int argc, char *argv[])
                { 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");