From: Mohammed Sadiq Date: Thu, 14 Jun 2018 00:00:21 +0000 (+0530) Subject: docs: Update getting started docs X-Git-Tag: archive/raspbian/4.4.1+ds1-2+rpi1^2~18^2~22^2~175 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=daf72e2e964b05b5c6ddeaa1f43a0966fd2ec98c;p=gtk4.git docs: Update getting started docs We have removed references to private members in our examples. Let the docs be updated to reflect that. --- 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) In this step, we make our application show the content of all the files that it is given on the commandline. - To this end, we add a private struct to our application + 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. 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); }