aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy-gtk/empathy-ui-utils.c
diff options
context:
space:
mode:
authorXavier Claessens <xclaesse@gmail.com>2009-04-16 20:27:48 +0800
committerXavier Claessens <xclaesse@src.gnome.org>2009-04-16 20:27:48 +0800
commit11e07f923c7bc1655cfd1609024304fa1c8fe2c3 (patch)
tree593087a8fcbefc6d5d1eec154853adaf2ac932e7 /libempathy-gtk/empathy-ui-utils.c
parent36ccb3786fa69009a63f14a498005b8d95449c72 (diff)
downloadgsoc2013-empathy-11e07f923c7bc1655cfd1609024304fa1c8fe2c3.tar
gsoc2013-empathy-11e07f923c7bc1655cfd1609024304fa1c8fe2c3.tar.gz
gsoc2013-empathy-11e07f923c7bc1655cfd1609024304fa1c8fe2c3.tar.bz2
gsoc2013-empathy-11e07f923c7bc1655cfd1609024304fa1c8fe2c3.tar.lz
gsoc2013-empathy-11e07f923c7bc1655cfd1609024304fa1c8fe2c3.tar.xz
gsoc2013-empathy-11e07f923c7bc1655cfd1609024304fa1c8fe2c3.tar.zst
gsoc2013-empathy-11e07f923c7bc1655cfd1609024304fa1c8fe2c3.zip
Port glade helpers to GtkBuilber
From: Xavier Claessens <xclaesse@gmail.com> svn path=/trunk/; revision=2841
Diffstat (limited to 'libempathy-gtk/empathy-ui-utils.c')
-rw-r--r--libempathy-gtk/empathy-ui-utils.c165
1 files changed, 48 insertions, 117 deletions
diff --git a/libempathy-gtk/empathy-ui-utils.c b/libempathy-gtk/empathy-ui-utils.c
index 9e8928e8e..a1f4a6bfc 100644
--- a/libempathy-gtk/empathy-ui-utils.c
+++ b/libempathy-gtk/empathy-ui-utils.c
@@ -37,7 +37,6 @@
#include <glib/gi18n-lib.h>
#include <gtk/gtk.h>
#include <gio/gio.h>
-#include <glade/glade.h>
#include <canberra-gtk.h>
#include <libmissioncontrol/mc-profile.h>
@@ -89,39 +88,33 @@ empathy_uri_regex_dup_singleton (void)
return g_regex_ref (uri_regex);
}
-struct SizeData {
- gint width;
- gint height;
- gboolean preserve_aspect_ratio;
-};
-
-static GladeXML *
-get_glade_file (const gchar *filename,
- const gchar *root,
- const gchar *domain,
- const gchar *first_required_widget,
- va_list args)
+static GtkBuilder *
+builder_get_file_valist (const gchar *filename,
+ const gchar *first_object,
+ va_list args)
{
- GladeXML *gui;
- const char *name;
- GtkWidget **widget_ptr;
-
- DEBUG ("Loading glade file %s", filename);
+ GtkBuilder *gui;
+ const gchar *name;
+ GObject **object_ptr;
+ GError *error = NULL;
- gui = glade_xml_new (filename, root, domain);
+ DEBUG ("Loading file %s", filename);
- if (!gui) {
- g_warning ("Couldn't find necessary glade file '%s'", filename);
+ gui = gtk_builder_new ();
+ if (!gtk_builder_add_from_file (gui, filename, &error)) {
+ DEBUG ("Error: %s", error->message);
+ g_clear_error (&error);
+ g_object_unref (gui);
+ return NULL;
}
- for (name = first_required_widget; name; name = va_arg (args, char *)) {
- widget_ptr = va_arg (args, void *);
+ for (name = first_object; name; name = va_arg (args, const gchar *)) {
+ object_ptr = va_arg (args, GObject**);
- *widget_ptr = glade_xml_get_widget (gui, name);
+ *object_ptr = gtk_builder_get_object (gui, name);
- if (!*widget_ptr) {
- g_warning ("Glade file '%s' is missing widget '%s'.",
- filename, name);
+ if (!*object_ptr) {
+ g_warning ("File is missing object '%s'.", name);
continue;
}
}
@@ -129,115 +122,47 @@ get_glade_file (const gchar *filename,
return gui;
}
-void
-empathy_glade_get_file_simple (const gchar *filename,
- const gchar *root,
- const gchar *domain,
- const gchar *first_required_widget, ...)
-{
- va_list args;
- GladeXML *gui;
-
- va_start (args, first_required_widget);
-
- gui = get_glade_file (filename,
- root,
- domain,
- first_required_widget,
- args);
-
- va_end (args);
-
- if (gui) {
- g_object_unref (gui);
- }
-}
-
-GladeXML *
-empathy_glade_get_file (const gchar *filename,
- const gchar *root,
- const gchar *domain,
- const gchar *first_required_widget, ...)
+GtkBuilder *
+empathy_builder_get_file (const gchar *filename,
+ const gchar *first_object,
+ ...)
{
- va_list args;
- GladeXML *gui;
-
- va_start (args, first_required_widget);
-
- gui = get_glade_file (filename,
- root,
- domain,
- first_required_widget,
- args);
+ GtkBuilder *gui;
+ va_list args;
+ va_start (args, first_object);
+ gui = builder_get_file_valist (filename, first_object, args);
va_end (args);
- if (!gui) {
- return NULL;
- }
-
return gui;
}
void
-empathy_glade_connect (GladeXML *gui,
- gpointer user_data,
- gchar *first_widget, ...)
+empathy_builder_connect (GtkBuilder *gui,
+ gpointer user_data,
+ gchar *first_object,
+ ...)
{
va_list args;
const gchar *name;
const gchar *signal;
- GtkWidget *widget;
- gpointer *callback;
-
- va_start (args, first_widget);
-
- for (name = first_widget; name; name = va_arg (args, char *)) {
- signal = va_arg (args, void *);
- callback = va_arg (args, void *);
-
- widget = glade_xml_get_widget (gui, name);
- if (!widget) {
- g_warning ("Glade file is missing widget '%s', aborting",
- name);
- continue;
- }
-
- g_signal_connect (widget,
- signal,
- G_CALLBACK (callback),
- user_data);
- }
-
- va_end (args);
-}
-
-void
-empathy_glade_setup_size_group (GladeXML *gui,
- GtkSizeGroupMode mode,
- gchar *first_widget, ...)
-{
- va_list args;
- GtkWidget *widget;
- GtkSizeGroup *size_group;
- const gchar *name;
-
- va_start (args, first_widget);
+ GObject *object;
+ GCallback callback;
- size_group = gtk_size_group_new (mode);
+ va_start (args, first_object);
+ for (name = first_object; name; name = va_arg (args, const gchar *)) {
+ signal = va_arg (args, const gchar *);
+ callback = va_arg (args, GCallback);
- for (name = first_widget; name; name = va_arg (args, char *)) {
- widget = glade_xml_get_widget (gui, name);
- if (!widget) {
- g_warning ("Glade file is missing widget '%s'", name);
+ object = gtk_builder_get_object (gui, name);
+ if (!object) {
+ g_warning ("File is missing object '%s'.", name);
continue;
}
- gtk_size_group_add_widget (size_group, widget);
+ g_signal_connect (object, signal, callback, user_data);
}
- g_object_unref (size_group);
-
va_end (args);
}
@@ -346,6 +271,12 @@ out:
return pixbuf;
}
+struct SizeData {
+ gint width;
+ gint height;
+ gboolean preserve_aspect_ratio;
+};
+
static void
pixbuf_from_avatar_size_prepared_cb (GdkPixbufLoader *loader,
int width,