aboutsummaryrefslogtreecommitdiffstats
path: root/e-util
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2010-09-15 01:38:47 +0800
committerMatthew Barnes <mbarnes@redhat.com>2010-09-15 01:49:08 +0800
commit95fe9256305bad92697bf1043efcbd61238cf94b (patch)
treeb1b8d204cba628580ab7097283c980c56507be14 /e-util
parentb6f61694d42b65d02d12c268e991fdf8b96f50bf (diff)
downloadgsoc2013-evolution-95fe9256305bad92697bf1043efcbd61238cf94b.tar
gsoc2013-evolution-95fe9256305bad92697bf1043efcbd61238cf94b.tar.gz
gsoc2013-evolution-95fe9256305bad92697bf1043efcbd61238cf94b.tar.bz2
gsoc2013-evolution-95fe9256305bad92697bf1043efcbd61238cf94b.tar.lz
gsoc2013-evolution-95fe9256305bad92697bf1043efcbd61238cf94b.tar.xz
gsoc2013-evolution-95fe9256305bad92697bf1043efcbd61238cf94b.tar.zst
gsoc2013-evolution-95fe9256305bad92697bf1043efcbd61238cf94b.zip
Fix a crapload of run-time warnings.
EConfig and EMAccountEditor are very, very brittle.
Diffstat (limited to 'e-util')
-rw-r--r--e-util/e-util.c38
-rw-r--r--e-util/e-util.h7
2 files changed, 40 insertions, 5 deletions
diff --git a/e-util/e-util.c b/e-util/e-util.c
index c5360f94a1..68662bd3d4 100644
--- a/e-util/e-util.c
+++ b/e-util/e-util.c
@@ -285,6 +285,44 @@ e_lookup_action_group (GtkUIManager *ui_manager,
}
/**
+ * e_builder_get_widget:
+ * @builder: a #GtkBuilder
+ * @widget_name: name of a widget in @builder
+ *
+ * Gets the widget named @widget_name. Note that this function does not
+ * increment the reference count of the returned widget. If @widget_name
+ * could not be found in the @builder<!-- -->'s object tree, a run-time
+ * warning is emitted since this usually indicates a programming error.
+ *
+ * This is a convenience function to work around the awkwardness of
+ * #GtkBuilder returning #GObject pointers, when the vast majority of
+ * the time you want a #GtkWidget pointer.
+ *
+ * If you need something from @builder other than a #GtkWidget, or you
+ * want to test for the existence of some widget name without incurring
+ * a run-time warning, use gtk_builder_get_object().
+ *
+ * Returns: the widget named @widget_name, or %NULL
+ **/
+GtkWidget *
+e_builder_get_widget (GtkBuilder *builder,
+ const gchar *widget_name)
+{
+ GObject *object;
+
+ g_return_val_if_fail (GTK_IS_BUILDER (builder), NULL);
+ g_return_val_if_fail (widget_name != NULL, NULL);
+
+ object = gtk_builder_get_object (builder, widget_name);
+ if (object == NULL) {
+ g_warning ("Could not find widget '%s'", widget_name);
+ return NULL;
+ }
+
+ return GTK_WIDGET (object);
+}
+
+/**
* e_load_ui_builder_definition:
* @builder: a #GtkBuilder
* @basename: basename of the UI definition file
diff --git a/e-util/e-util.h b/e-util/e-util.h
index 42749c1c25..71fc12f431 100644
--- a/e-util/e-util.h
+++ b/e-util/e-util.h
@@ -34,11 +34,6 @@
* for backward-compatibility (not that we really care about that). */
#include <libedataserver/e-data-server-util.h>
-/* Convenience macro to help migrate from libglade to GtkBuilder.
- * Use it as a direct replacement for glade_xml_get_widget(). */
-#define e_builder_get_widget(builder, name) \
- GTK_WIDGET (gtk_builder_get_object ((builder), (name)))
-
G_BEGIN_DECLS
typedef enum {
@@ -60,6 +55,8 @@ GtkAction * e_lookup_action (GtkUIManager *ui_manager,
const gchar *action_name);
GtkActionGroup *e_lookup_action_group (GtkUIManager *ui_manager,
const gchar *group_name);
+GtkWidget * e_builder_get_widget (GtkBuilder *builder,
+ const gchar *widget_name);
void e_load_ui_builder_definition (GtkBuilder *builder,
const gchar *basename);
gint e_action_compare_by_label (GtkAction *action1,