[gtk+/wip/action-descriptions: 1/7] GtkBuilder: add GtkApplication



commit 5c2dec6bf6ca4cc04e90e7b7cbcbbd6cbc167ea1
Author: Ryan Lortie <desrt desrt ca>
Date:   Sun Jun 16 16:29:50 2013 -0400

    GtkBuilder: add GtkApplication
    
    Add a GtkApplication (private) field to GtkBuilder

 docs/reference/gtk/gtk3-sections.txt |    2 +
 gtk/gtkbuilder.c                     |   61 ++++++++++++++++++++++++++++++++++
 gtk/gtkbuilder.h                     |    9 +++++
 3 files changed, 72 insertions(+), 0 deletions(-)
---
diff --git a/docs/reference/gtk/gtk3-sections.txt b/docs/reference/gtk/gtk3-sections.txt
index 73c5d2f..f5336bd 100644
--- a/docs/reference/gtk/gtk3-sections.txt
+++ b/docs/reference/gtk/gtk3-sections.txt
@@ -602,6 +602,8 @@ gtk_builder_add_callback_symbols
 gtk_builder_lookup_callback_symbol
 gtk_builder_set_translation_domain
 gtk_builder_get_translation_domain
+gtk_builder_set_application
+gtk_builder_get_application
 gtk_builder_get_type_from_name
 gtk_builder_value_from_string
 gtk_builder_value_from_string_type
diff --git a/gtk/gtkbuilder.c b/gtk/gtkbuilder.c
index a8ceb57..6164c4d 100644
--- a/gtk/gtkbuilder.c
+++ b/gtk/gtkbuilder.c
@@ -286,6 +286,7 @@ struct _GtkBuilderPrivate
   gchar *filename;
   gchar *resource_prefix;
   GType template_type;
+  GtkApplication *application;
 };
 
 G_DEFINE_TYPE_WITH_PRIVATE (GtkBuilder, gtk_builder, G_TYPE_OBJECT)
@@ -2514,3 +2515,63 @@ gtk_builder_new_from_string (const gchar *string,
 
   return builder;
 }
+
+/**
+ * gtk_builder_set_application:
+ * @builder: a #GtkBuilder
+ * @application: a #GtkApplication
+ *
+ * Sets the application associated with @builder.
+ *
+ * You only need this function if there is more than one #GApplication
+ * in your process.  @application cannot be %NULL.
+ *
+ * Since: 3.10
+ **/
+void
+gtk_builder_set_application (GtkBuilder     *builder,
+                             GtkApplication *application)
+{
+  g_return_if_fail (GTK_IS_BUILDER (builder));
+  g_return_if_fail (GTK_IS_APPLICATION (application));
+
+  if (builder->priv->application)
+    g_object_unref (builder->priv->application);
+
+  builder->priv->application = g_object_ref (application);
+}
+
+/**
+ * gtk_builder_get_application:
+ * @builder: a #GtkBuilder
+ *
+ * Gets the #GtkApplication associated with the builder.
+ *
+ * The #GtkApplication is used for creating action proxies as requested
+ * from XML that the builder is loading.
+ *
+ * By default, the builder uses the default application: the one from
+ * g_application_get_default().  If you want to use another application
+ * for constructing proxies, use gtk_builder_set_application().
+ *
+ * Returns: (transfer none): the application being used by the builder,
+ *     or %NULL
+ *
+ * Since: 3.10
+ **/
+GtkApplication *
+gtk_builder_get_application (GtkBuilder *builder)
+{
+  g_return_if_fail (GTK_IS_BUILDER (builder));
+
+  if (!builder->priv->application)
+    {
+      GApplication *application;
+
+      application = g_application_get_default ();
+      if (application && GTK_IS_APPLICATION (application))
+        builder->priv->application = g_object_ref (GTK_APPLICATION (application));
+    }
+
+  return builder->priv->application;
+}
diff --git a/gtk/gtkbuilder.h b/gtk/gtkbuilder.h
index 5bdbe0d..de41564 100644
--- a/gtk/gtkbuilder.h
+++ b/gtk/gtkbuilder.h
@@ -23,6 +23,7 @@
 #error "Only <gtk/gtk.h> can be included directly."
 #endif
 
+#include <gtk/gtkapplication.h>
 #include <gtk/gtkwidget.h>
 
 G_BEGIN_DECLS
@@ -200,6 +201,14 @@ GDK_AVAILABLE_IN_3_10
 GCallback    gtk_builder_lookup_callback_symbol  (GtkBuilder    *builder,
                                                  const gchar   *callback_name);
 
+GDK_AVAILABLE_IN_3_10
+void         gtk_builder_set_application         (GtkBuilder     *builder,
+                                                  GtkApplication *application);
+
+GDK_AVAILABLE_IN_3_10
+GtkApplication * gtk_builder_get_application     (GtkBuilder     *builder);
+
+
 /**
  * GTK_BUILDER_WARN_INVALID_CHILD_TYPE:
  * @object: the #GtkBuildable on which the warning ocurred


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