]> git.0d.be Git - empathy.git/blobdiff - libempathy-gtk/empathy-ui-utils.c
Use a flat namespace for internal includes
[empathy.git] / libempathy-gtk / empathy-ui-utils.c
index 967d59cda325f5259b3100037d07f9b44f84435e..1cadaf4176fbbbce85db5747fb861dfba14a7812 100644 (file)
  *          Jeroen Zwartepoorte
  */
 
-#include <config.h>
+#include "config.h"
 
-#include <string.h>
 #include <X11/Xatom.h>
 #include <gdk/gdkx.h>
 #include <glib/gi18n-lib.h>
-#include <gtk/gtk.h>
-#include <gio/gio.h>
 #include <gio/gdesktopappinfo.h>
 
-#include <telepathy-glib/util.h>
-#include <folks/folks.h>
-
 #include "empathy-ui-utils.h"
 #include "empathy-images.h"
 #include "empathy-live-search.h"
-#include "empathy-smiley-manager.h"
 
 #define DEBUG_FLAG EMPATHY_DEBUG_OTHER
-#include <libempathy/empathy-debug.h>
-#include <libempathy/empathy-utils.h>
-#include <libempathy/empathy-ft-factory.h>
+#include "empathy-debug.h"
+#include "empathy-utils.h"
+#include "empathy-ft-factory.h"
 
 void
 empathy_gtk_init (void)
@@ -82,8 +75,15 @@ empathy_gtk_init (void)
   initialized = TRUE;
 }
 
+enum _BuilderSource
+{
+  BUILDER_SOURCE_FILE,
+  BUILDER_SOURCE_RESOURCE
+};
+
 static GtkBuilder *
-builder_get_file_valist (const gchar *filename,
+builder_get_valist (const gchar *sourcename,
+    enum _BuilderSource source,
     const gchar *first_object,
     va_list args)
 {
@@ -91,16 +91,29 @@ builder_get_file_valist (const gchar *filename,
   const gchar *name;
   GObject **object_ptr;
   GError *error = NULL;
+  gboolean success;
 
-  DEBUG ("Loading file %s", filename);
+  DEBUG ("Loading %s '%s'", source == BUILDER_SOURCE_FILE ? "file" : "resource", sourcename);
 
   gui = gtk_builder_new ();
   gtk_builder_set_translation_domain (gui, GETTEXT_PACKAGE);
 
-  if (!gtk_builder_add_from_file (gui, filename, &error))
+  switch (source)
+    {
+    case BUILDER_SOURCE_FILE:
+      success = gtk_builder_add_from_file (gui, sourcename, &error);
+      break;
+    case BUILDER_SOURCE_RESOURCE:
+      success = gtk_builder_add_from_resource (gui, sourcename, &error);
+      break;
+    default:
+      g_assert_not_reached ();
+    }
+
+  if (!success)
     {
       g_critical ("GtkBuilder Error (%s): %s",
-          filename, error->message);
+          sourcename, error->message);
 
       g_clear_error (&error);
       g_object_unref (gui);
@@ -141,7 +154,22 @@ empathy_builder_get_file (const gchar *filename,
   va_list args;
 
   va_start (args, first_object);
-  gui = builder_get_file_valist (filename, first_object, args);
+  gui = builder_get_valist (filename, BUILDER_SOURCE_FILE, first_object, args);
+  va_end (args);
+
+  return gui;
+}
+
+GtkBuilder *
+empathy_builder_get_resource (const gchar *resourcename,
+    const gchar *first_object,
+    ...)
+{
+  GtkBuilder *gui;
+  va_list args;
+
+  va_start (args, first_object);
+  gui = builder_get_valist (resourcename, BUILDER_SOURCE_RESOURCE, first_object, args);
   va_end (args);
 
   return gui;