summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammed Sadiq <sadiq@sadiqpk.org>2018-06-14 05:30:21 +0530
committerMohammed Sadiq <sadiq@sadiqpk.org>2018-06-14 05:30:21 +0530
commitdaf72e2e964b05b5c6ddeaa1f43a0966fd2ec98c (patch)
tree735d651319090fe1b96e3c92aac35ad9f64f298b
parent7e98741793b1365f2fd378efe2ad6e572b02fba6 (diff)
downloadgtk+-daf72e2e964b05b5c6ddeaa1f43a0966fd2ec98c.tar.gz
docs: Update getting started docs
We have removed references to private members in our examples. Let the docs be updated to reflect that.
-rw-r--r--docs/reference/gtk/getting_started.xml43
1 files changed, 19 insertions, 24 deletions
diff --git a/docs/reference/gtk/getting_started.xml b/docs/reference/gtk/getting_started.xml
index 212e092305..036b9f471c 100644
--- a/docs/reference/gtk/getting_started.xml
+++ b/docs/reference/gtk/getting_started.xml
@@ -488,23 +488,28 @@ example_app_window_class_init (ExampleAppWindowClass *class)
<para>In this step, we make our application show the content of
all the files that it is given on the commandline.</para>
- <para>To this end, we add a private struct to our application
+ <para>To this end, we add a member to the struct in application
window subclass and keep a reference to the #GtkStack there.
- The gtk_widget_class_bind_template_child_private() function
+ The first member of the struct should be the parent type from
+ which the class is derived. Here, ExampleAppWindow is derived
+ from GtkApplicationWindow.
+ The gtk_widget_class_bind_template_child() function
arranges things so that after instantiating the template, the
- @stack member of the private struct will point to the widget of
+ @stack member of the struct will point to the widget of
the same name from the template.</para>
<informalexample>
<programlisting><![CDATA[
...
-struct _ExampleAppWindowPrivate
+struct _ExampleAppWindow
{
+ GtkApplicationWindow parent;
+
GtkWidget *stack;
};
-G_DEFINE_TYPE_WITH_PRIVATE(ExampleAppWindow, example_app_window, GTK_TYPE_APPLICATION_WINDOW);
+G_DEFINE_TYPE (ExampleAppWindow, example_app_window, GTK_TYPE_APPLICATION_WINDOW)
...
@@ -513,7 +518,7 @@ example_app_window_class_init (ExampleAppWindowClass *class)
{
gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (class),
"/org/gtk/exampleapp/window.ui");
- gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppWindow, stack);
+ gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppWindow, stack);
}
...
@@ -533,25 +538,21 @@ void
example_app_window_open (ExampleAppWindow *win,
GFile *file)
{
- ExampleAppWindowPrivate *priv;
gchar *basename;
GtkWidget *scrolled, *view;
gchar *contents;
gsize length;
- priv = example_app_window_get_instance_private (win);
basename = g_file_get_basename (file);
scrolled = gtk_scrolled_window_new (NULL, NULL);
- gtk_widget_show (scrolled);
gtk_widget_set_hexpand (scrolled, TRUE);
gtk_widget_set_vexpand (scrolled, TRUE);
view = gtk_text_view_new ();
gtk_text_view_set_editable (GTK_TEXT_VIEW (view), FALSE);
gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (view), FALSE);
- gtk_widget_show (view);
gtk_container_add (GTK_CONTAINER (scrolled), view);
- gtk_stack_add_titled (GTK_STACK (priv->stack), scrolled, basename, basename);
+ gtk_stack_add_titled (GTK_STACK (win->stack), scrolled, basename, basename);
if (g_file_load_contents (file, NULL, &contents, &length, NULL, NULL))
{
@@ -718,14 +719,11 @@ example_app_class_init (ExampleAppClass *class)
static void
example_app_window_init (ExampleAppWindow *win)
{
- ExampleAppWindowPrivate *priv;
-
- priv = example_app_window_get_instance_private (win);
gtk_widget_init_template (GTK_WIDGET (win));
- priv->settings = g_settings_new ("org.gtk.exampleapp");
+ win->settings = g_settings_new ("org.gtk.exampleapp");
- g_settings_bind (priv->settings, "transition",
- priv->stack, "transition-type",
+ g_settings_bind (win->settings, "transition",
+ win->stack, "transition-type",
G_SETTINGS_BIND_DEFAULT);
}
@@ -823,7 +821,6 @@ static void
search_text_changed (GtkEntry *entry,
ExampleAppWindow *win)
{
- ExampleAppWindowPrivate *priv;
const gchar *text;
GtkWidget *tab;
GtkWidget *view;
@@ -835,9 +832,7 @@ search_text_changed (GtkEntry *entry,
if (text[0] == '\0')
return;
- priv = example_app_window_get_instance_private (win);
-
- tab = gtk_stack_get_visible_child (GTK_STACK (priv->stack));
+ tab = gtk_stack_get_visible_child (GTK_STACK (win->stack));
view = gtk_bin_get_child (GTK_BIN (tab));
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
@@ -978,12 +973,12 @@ example_app_window_init (ExampleAppWindow *win)
{
...
- action = (GAction*) g_property_action_new ("show-lines", priv->lines, "visible");
+ action = (GAction*) g_property_action_new ("show-lines", win->lines, "visible");
g_action_map_add_action (G_ACTION_MAP (win), action);
g_object_unref (action);
- g_object_bind_property (priv->lines, "visible",
- priv->lines_label, "visible",
+ g_object_bind_property (win->lines, "visible",
+ win->lines_label, "visible",
G_BINDING_DEFAULT);
}