[gtk+] Some GtkApplication cleanups
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] Some GtkApplication cleanups
- Date: Sat, 23 Oct 2010 20:52:39 +0000 (UTC)
commit 1be9b7f78203ce06429fc8fc066cb3a1ecfc1145
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Oct 23 21:24:24 2010 +0200
Some GtkApplication cleanups
Remove no-longer-needed vfuncs, no longer existing functions,
and improve the docs here and there.
gtk/gtkapplication.c | 41 ++++++++++++++++++++++++++++++-----------
gtk/gtkapplication.h | 3 ---
gtk/gtkwindow.c | 13 ++++++++-----
3 files changed, 38 insertions(+), 19 deletions(-)
---
diff --git a/gtk/gtkapplication.c b/gtk/gtkapplication.c
index 11af1ba..70c9754 100644
--- a/gtk/gtkapplication.c
+++ b/gtk/gtkapplication.c
@@ -44,11 +44,11 @@
* of a GTK+ application in a convenient fashion, without enforcing
* a one-size-fits-all application model.
*
- * Currently, GtkApplication handles application uniqueness, provides
- * some basic scriptability by exporting 'actions', implements some
- * standard actions itself (such as 'Quit') and provides a main window
- * whose life-cycle is automatically tied to the life-cycle of your
- * application.
+ * Currently, GtkApplication handles GTK+ initialization, application
+ * uniqueness, provides some basic scriptability by exporting 'actions',
+ * implements some standard actions itself (such as 'Quit') and manages
+ * a list of toplevel windows whose life-cycle is automatically tied to
+ * the life-cycle of your application.
*
* <example id="gtkapplication"><title>A simple application</title>
* <programlisting>
@@ -151,6 +151,20 @@ gtk_application_class_init (GtkApplicationClass *class)
g_type_class_add_private (class, sizeof (GtkApplicationPrivate));
}
+/**
+ * gtk_application_new:
+ * @application_id: the application id
+ * @flags: the application flags
+ *
+ * Creates a new #GtkApplication instance.
+ *
+ * This function calls g_type_init() for you. gtk_init() is called
+ * as soon as the application gets registered as the primary instance.
+ *
+ * The application id must be valid. See g_application_id_is_valid().
+ *
+ * Returns: a new #GtkApplication instance
+ */
GtkApplication *
gtk_application_new (const gchar *application_id,
GApplicationFlags flags)
@@ -181,12 +195,15 @@ void
gtk_application_add_window (GtkApplication *application,
GtkWindow *window)
{
+ GtkApplicationPrivate *priv;
+
g_return_if_fail (GTK_IS_APPLICATION (application));
- if (!g_list_find (application->priv->windows, window))
+ priv = application->priv;
+
+ if (!g_list_find (priv->windows, window))
{
- application->priv->windows = g_list_prepend (application->priv->windows,
- window);
+ priv->windows = g_list_prepend (priv->windows, window);
gtk_window_set_application (window, application);
g_application_hold (G_APPLICATION (application));
}
@@ -212,12 +229,14 @@ void
gtk_application_remove_window (GtkApplication *application,
GtkWindow *window)
{
+ GtkApplicationPrivate *priv;
+
g_return_if_fail (GTK_IS_APPLICATION (application));
- if (g_list_find (application->priv->windows, window))
+ priv = application->priv;
+ if (g_list_find (priv->windows, window))
{
- application->priv->windows = g_list_remove (application->priv->windows,
- window);
+ priv->windows = g_list_remove (priv->windows, window);
g_application_release (G_APPLICATION (application));
gtk_window_set_application (window, NULL);
}
diff --git a/gtk/gtkapplication.h b/gtk/gtkapplication.h
index c9c8571..8fafd4e 100644
--- a/gtk/gtkapplication.h
+++ b/gtk/gtkapplication.h
@@ -55,9 +55,6 @@ struct _GtkApplicationClass
{
GApplicationClass parent_class;
- /*< vfuncs >*/
- GtkWindow *(* create_window) (GtkApplication *application);
-
/*< private >*/
gpointer padding[12];
};
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index 08202a2..fb63d1c 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -2673,19 +2673,22 @@ void
gtk_window_set_application (GtkWindow *window,
GtkApplication *application)
{
+ GtkWindowPrivate *priv;
+
g_return_if_fail (GTK_IS_WINDOW (window));
- if (window->priv->application != application)
+ priv = window->priv;
+ if (priv->application != application)
{
gtk_window_release_application (window);
- window->priv->application = application;
+ priv->application = application;
- if (window->priv->application != NULL)
+ if (priv->application != NULL)
{
- g_object_ref (window->priv->application);
+ g_object_ref (priv->application);
- gtk_application_add_window (window->priv->application, window);
+ gtk_application_add_window (priv->application, window);
}
g_object_notify (G_OBJECT (window), "application");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]