[gtk+/composite-templates-new: 7/9] GtkAboutDialog: Define children with a GtkBuilder template



commit a40cc210a8d7190979dfa415c81c534fcd866f96
Author: Tristan Van Berkom <tristanvb openismus com>
Date:   Fri Mar 22 21:51:40 2013 +0900

    GtkAboutDialog: Define children with a GtkBuilder template

 gtk/Makefile.am       |    9 +-
 gtk/gtk.gresource.xml |    3 +-
 gtk/gtkaboutdialog.c  |  286 ++++++++++++++-----------------------------
 gtk/gtkaboutdialog.ui |  329 +++++++++++++++++++++++++++++++++++++++++++++++++
 gtk/tests/templates.c |   11 ++
 po/POTFILES.in        |    1 +
 6 files changed, 440 insertions(+), 199 deletions(-)
---
diff --git a/gtk/Makefile.am b/gtk/Makefile.am
index 0b92543..c794612 100644
--- a/gtk/Makefile.am
+++ b/gtk/Makefile.am
@@ -1093,10 +1093,11 @@ DND_CURSORS = \
        cursor_dnd_move.png                             \
        cursor_dnd_none.png
 
-COMPOSITE_TEMPLATES =          \
-       gtkdialog.ui            \
-       gtkmessagedialog.ui     \
-       gtkinfobar.ui
+COMPOSITE_TEMPLATES =                  \
+       gtkaboutdialog.ui               \
+       gtkdialog.ui                    \
+       gtkinfobar.ui                   \
+       gtkmessagedialog.ui
 
 #
 # rules to generate built sources
diff --git a/gtk/gtk.gresource.xml b/gtk/gtk.gresource.xml
index df76b25..1aef6c6 100644
--- a/gtk/gtk.gresource.xml
+++ b/gtk/gtk.gresource.xml
@@ -11,8 +11,9 @@
     <file alias="cursor/dnd-none.png">cursor_dnd_none.png</file>
     <file alias="cursor/dnd-move.png">cursor_dnd_move.png</file>
     <file alias="cursor/dnd-copy.png">cursor_dnd_copy.png</file>
+    <file>gtkaboutdialog.ui</file>
     <file>gtkdialog.ui</file>
-    <file>gtkmessagedialog.ui</file>
     <file>gtkinfobar.ui</file>
+    <file>gtkmessagedialog.ui</file>
   </gresource>
 </gresources>
diff --git a/gtk/gtkaboutdialog.c b/gtk/gtkaboutdialog.c
index f50fed0..9cc2ba0 100644
--- a/gtk/gtkaboutdialog.c
+++ b/gtk/gtkaboutdialog.c
@@ -159,6 +159,9 @@ struct _GtkAboutDialogPrivate
   GtkWidget *credits_button;
   GtkWidget *license_button;
 
+  GtkWidget *credits_grid;
+  GtkWidget *license_view;
+
   GdkCursor *hand_cursor;
   GdkCursor *regular_cursor;
 
@@ -170,7 +173,9 @@ struct _GtkAboutDialogPrivate
   guint wrap_license : 1;
 };
 
-
+/* The indexes of the credits and license page in the builder xml */
+#define CREDITS_PAGE_ID  1
+#define LICENSE_PAGE_ID  2
 
 #define GTK_ABOUT_DIALOG_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GTK_TYPE_ABOUT_DIALOG, 
GtkAboutDialogPrivate))
 
@@ -222,6 +227,25 @@ static void                 display_license_page            (GtkWidget
 static void                 close_cb                        (GtkAboutDialog     *about);
 static gboolean             gtk_about_dialog_activate_link  (GtkAboutDialog     *about,
                                                              const gchar        *uri);
+static void                 credits_button_clicked          (GtkButton          *button,
+                                                            gpointer            data);
+static void                 license_button_clicked          (GtkButton          *button,
+                                                            gpointer            data);
+static gboolean             emit_activate_link              (GtkAboutDialog     *about,
+                                                            const gchar        *uri);
+static gboolean             text_view_key_press_event       (GtkWidget          *text_view,
+                                                            GdkEventKey        *event,
+                                                            GtkAboutDialog     *about);
+static gboolean             text_view_event_after           (GtkWidget          *text_view,
+                                                            GdkEvent           *event,
+                                                            GtkAboutDialog     *about);
+static gboolean             text_view_motion_notify_event   (GtkWidget          *text_view,
+                                                            GdkEventMotion     *event,
+                                                            GtkAboutDialog     *about);
+static gboolean             text_view_visibility_notify_event(GtkWidget          *text_view,
+                                                             GdkEventVisibility *event,
+                                                             GtkAboutDialog     *about);
+
 
 enum {
   ACTIVATE_LINK,
@@ -238,9 +262,11 @@ gtk_about_dialog_class_init (GtkAboutDialogClass *klass)
 {
   GObjectClass *object_class;
   GtkWidgetClass *widget_class;
+  GtkContainerClass *container_class;
 
   object_class = (GObjectClass *)klass;
   widget_class = (GtkWidgetClass *)klass;
+  container_class = (GtkContainerClass *)klass;
 
   object_class->set_property = gtk_about_dialog_set_property;
   object_class->get_property = gtk_about_dialog_get_property;
@@ -535,6 +561,43 @@ gtk_about_dialog_class_init (GtkAboutDialogClass *klass)
                                                          FALSE,
                                                          GTK_PARAM_READWRITE));
 
+  gtk_container_class_set_template (container_class,
+                                   GTK_TEMPLATE_SOURCE_RESOURCE,
+                                   "/org/gtk/libgtk/gtkaboutdialog.ui");
+  gtk_container_class_automate_child (container_class, "notebook", FALSE, GTK_AUTOMATE_CHILD_PRIVATE,
+                                     G_STRUCT_OFFSET (GtkAboutDialogPrivate, notebook));
+  gtk_container_class_automate_child (container_class, "logo_image", FALSE, GTK_AUTOMATE_CHILD_PRIVATE,
+                                     G_STRUCT_OFFSET (GtkAboutDialogPrivate, logo_image));
+  gtk_container_class_automate_child (container_class, "name_label", FALSE, GTK_AUTOMATE_CHILD_PRIVATE,
+                                     G_STRUCT_OFFSET (GtkAboutDialogPrivate, name_label));
+  gtk_container_class_automate_child (container_class, "version_label", FALSE, GTK_AUTOMATE_CHILD_PRIVATE,
+                                     G_STRUCT_OFFSET (GtkAboutDialogPrivate, version_label));
+  gtk_container_class_automate_child (container_class, "comments_label", FALSE, GTK_AUTOMATE_CHILD_PRIVATE,
+                                     G_STRUCT_OFFSET (GtkAboutDialogPrivate, comments_label));
+  gtk_container_class_automate_child (container_class, "copyright_label", FALSE, GTK_AUTOMATE_CHILD_PRIVATE,
+                                     G_STRUCT_OFFSET (GtkAboutDialogPrivate, copyright_label));
+  gtk_container_class_automate_child (container_class, "license_label", FALSE, GTK_AUTOMATE_CHILD_PRIVATE,
+                                     G_STRUCT_OFFSET (GtkAboutDialogPrivate, license_label));
+  gtk_container_class_automate_child (container_class, "website_label", FALSE, GTK_AUTOMATE_CHILD_PRIVATE,
+                                     G_STRUCT_OFFSET (GtkAboutDialogPrivate, website_label));
+  gtk_container_class_automate_child (container_class, "credits_button", FALSE, GTK_AUTOMATE_CHILD_PRIVATE,
+                                     G_STRUCT_OFFSET (GtkAboutDialogPrivate, credits_button));
+  gtk_container_class_automate_child (container_class, "license_button", FALSE, GTK_AUTOMATE_CHILD_PRIVATE,
+                                     G_STRUCT_OFFSET (GtkAboutDialogPrivate, license_button));
+  gtk_container_class_automate_child (container_class, "credits_grid", FALSE, GTK_AUTOMATE_CHILD_PRIVATE,
+                                     G_STRUCT_OFFSET (GtkAboutDialogPrivate, credits_grid));
+  gtk_container_class_automate_child (container_class, "textview", FALSE, GTK_AUTOMATE_CHILD_PRIVATE,
+                                     G_STRUCT_OFFSET (GtkAboutDialogPrivate, license_view));
+
+  gtk_container_class_declare_callbacks (container_class,
+                                        "credits_button_clicked", (GCallback)credits_button_clicked,
+                                        "license_button_clicked", (GCallback)license_button_clicked,
+                                        "emit_activate_link", (GCallback)emit_activate_link,
+                                        "text_view_event_after", (GCallback)text_view_event_after,
+                                        "text_view_key_press_event", (GCallback)text_view_key_press_event,
+                                        "text_view_visibility_notify_event", 
(GCallback)text_view_visibility_notify_event,
+                                        "text_view_motion_notify_event", 
(GCallback)text_view_motion_notify_event,
+                                        NULL);
 
   g_type_class_add_private (object_class, sizeof (GtkAboutDialogPrivate));
 }
@@ -642,10 +705,7 @@ license_button_clicked (GtkButton *button,
 static void
 gtk_about_dialog_init (GtkAboutDialog *about)
 {
-  GtkDialog *dialog = GTK_DIALOG (about);
   GtkAboutDialogPrivate *priv;
-  GtkWidget *vbox, *page_vbox, *hbox, *button, *close_button, *image;
-  GtkWidget *content_area, *action_area;
 
   /* Data */
   priv = GTK_ABOUT_DIALOG_GET_PRIVATE (about);
@@ -670,116 +730,12 @@ gtk_about_dialog_init (GtkAboutDialog *about)
 
   priv->license_type = GTK_LICENSE_UNKNOWN;
 
-  content_area = gtk_dialog_get_content_area (dialog);
-  action_area = gtk_dialog_get_action_area (dialog);
-
-  gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
-  gtk_box_set_spacing (GTK_BOX (content_area), 2); /* 2 * 5 + 2 = 12 */
-  gtk_container_set_border_width (GTK_CONTAINER (action_area), 5);
-
-  /* Widgets */
-  gtk_widget_push_composite_child ();
-
-  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
-  gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
-  gtk_box_pack_start (GTK_BOX (content_area), vbox, TRUE, TRUE, 0);
-
-  priv->logo_image = gtk_image_new ();
-  gtk_box_pack_start (GTK_BOX (vbox), priv->logo_image, FALSE, FALSE, 0);
-
-  priv->name_label = gtk_label_new (NULL);
-  gtk_label_set_selectable (GTK_LABEL (priv->name_label), TRUE);
-  gtk_label_set_justify (GTK_LABEL (priv->name_label), GTK_JUSTIFY_CENTER);
-  gtk_box_pack_start (GTK_BOX (vbox), priv->name_label, FALSE, FALSE, 0);
-
-  priv->notebook = gtk_notebook_new ();
-  gtk_box_pack_start (GTK_BOX (vbox), priv->notebook, TRUE, TRUE, 0);
-  gtk_widget_set_size_request (priv->notebook, 400, 100);
-
-  page_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
-  gtk_widget_show (page_vbox);
-  gtk_notebook_set_show_tabs (GTK_NOTEBOOK (priv->notebook), FALSE);
-  gtk_notebook_set_show_border (GTK_NOTEBOOK (priv->notebook), FALSE);
-  gtk_notebook_append_page (GTK_NOTEBOOK (priv->notebook), page_vbox, NULL);
-
-  priv->version_label = gtk_label_new (NULL);
-  gtk_label_set_selectable (GTK_LABEL (priv->version_label), TRUE);
-  gtk_label_set_justify (GTK_LABEL (priv->version_label), GTK_JUSTIFY_CENTER);
-  gtk_box_pack_start (GTK_BOX (page_vbox), priv->version_label, FALSE, FALSE, 0);
-
-  priv->comments_label = gtk_label_new (NULL);
-  gtk_label_set_selectable (GTK_LABEL (priv->comments_label), TRUE);
-  gtk_label_set_justify (GTK_LABEL (priv->comments_label), GTK_JUSTIFY_CENTER);
-  gtk_label_set_line_wrap (GTK_LABEL (priv->comments_label), TRUE);
-  gtk_box_pack_start (GTK_BOX (page_vbox), priv->comments_label, FALSE, FALSE, 0);
-
-  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
-  gtk_box_set_homogeneous (GTK_BOX (hbox), TRUE);
-  gtk_box_pack_start (GTK_BOX (page_vbox), hbox, FALSE, FALSE, 0);
-
-  priv->website_label = button = gtk_label_new ("");
-  gtk_widget_set_no_show_all (button, TRUE);
-  gtk_label_set_selectable (GTK_LABEL (button), TRUE);
-  gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
-  g_signal_connect_swapped (button, "activate-link",
-                            G_CALLBACK (emit_activate_link), about);
-
-  priv->license_label = gtk_label_new (NULL);
-  gtk_label_set_use_markup (GTK_LABEL (priv->license_label), TRUE);
-  gtk_label_set_selectable (GTK_LABEL (priv->license_label), TRUE);
-  gtk_label_set_justify (GTK_LABEL (priv->license_label), GTK_JUSTIFY_CENTER);
-  gtk_box_pack_end (GTK_BOX (page_vbox), priv->license_label, FALSE, FALSE, 0);
-  gtk_label_set_line_wrap (GTK_LABEL (priv->license_label), TRUE);
-
-  priv->copyright_label = gtk_label_new (NULL);
-  gtk_label_set_selectable (GTK_LABEL (priv->copyright_label), TRUE);
-  gtk_label_set_justify (GTK_LABEL (priv->copyright_label), GTK_JUSTIFY_CENTER);
-  gtk_box_pack_end (GTK_BOX (page_vbox), priv->copyright_label, FALSE, FALSE, 0);
-
-  gtk_widget_show (vbox);
-  gtk_widget_show (priv->notebook);
-  gtk_widget_show (priv->logo_image);
-  gtk_widget_show (priv->name_label);
-  gtk_widget_show (hbox);
-
-  /* Add the close button */
-  close_button = gtk_dialog_add_button (GTK_DIALOG (about),
-                                        GTK_STOCK_CLOSE, GTK_RESPONSE_CANCEL);
   gtk_dialog_set_default_response (GTK_DIALOG (about), GTK_RESPONSE_CANCEL);
 
-  /* Add the credits button */
-  button = gtk_toggle_button_new_with_mnemonic (_("C_redits"));
-  gtk_widget_set_can_default (button, TRUE);
-  image = gtk_image_new_from_stock (GTK_STOCK_ABOUT, GTK_ICON_SIZE_BUTTON);
-  gtk_button_set_image (GTK_BUTTON (button), image);
-  gtk_widget_set_no_show_all (button, TRUE);
-  gtk_box_pack_end (GTK_BOX (action_area), button, FALSE, TRUE, 0);
-  gtk_button_box_set_child_secondary (GTK_BUTTON_BOX (action_area), button, TRUE);
-  g_signal_connect (button, "clicked",
-                    G_CALLBACK (credits_button_clicked), about);
-  priv->credits_button = button;
-  priv->credits_page = 0;
-
-  /* Add the license button */
-  button = gtk_toggle_button_new_with_mnemonic (_("_License"));
-  gtk_widget_set_can_default (button, TRUE);
-  gtk_widget_set_no_show_all (button, TRUE);
-  gtk_box_pack_end (GTK_BOX (action_area), button, FALSE, TRUE, 0);
-  gtk_button_box_set_child_secondary (GTK_BUTTON_BOX (action_area), button, TRUE);
-  g_signal_connect (button, "clicked",
-                    G_CALLBACK (license_button_clicked), about);
-  priv->license_button = button;
-  priv->license_page = 0;
+  gtk_container_init_template (GTK_CONTAINER (about));
 
   switch_page (about, 0);
 
-  gtk_window_set_resizable (GTK_WINDOW (about), FALSE);
-
-  gtk_widget_pop_composite_child ();
-
-  gtk_widget_grab_default (close_button);
-  gtk_widget_grab_focus (close_button);
-
   /* force defaults */
   gtk_about_dialog_set_program_name (about, NULL);
   gtk_about_dialog_set_logo (about, NULL);
@@ -2080,15 +2036,12 @@ text_view_visibility_notify_event (GtkWidget          *text_view,
   return FALSE;
 }
 
-static GtkWidget *
-text_view_new (GtkAboutDialog  *about,
-               gchar          **strings,
-               GtkWrapMode      wrap_mode)
+static GtkTextBuffer *
+text_buffer_new (GtkAboutDialog  *about,
+                gchar          **strings)
 {
   gchar **p;
   gchar *q0, *q1, *q2, *r1, *r2;
-  GtkWidget *view;
-  GtkTextView *text_view;
   GtkTextBuffer *buffer;
   GdkColor *style_link_color;
   GdkColor *style_visited_link_color;
@@ -2119,12 +2072,7 @@ text_view_new (GtkAboutDialog  *about,
   else
     visited_link_color = default_visited_link_color;
 
-  view = gtk_text_view_new ();
-  text_view = GTK_TEXT_VIEW (view);
-  buffer = gtk_text_view_get_buffer (text_view);
-  gtk_text_view_set_cursor_visible (text_view, FALSE);
-  gtk_text_view_set_editable (text_view, FALSE);
-  gtk_text_view_set_wrap_mode (text_view, wrap_mode);
+  buffer = gtk_text_buffer_new (NULL);
 
   gtk_text_buffer_get_start_iter (buffer, &start_iter);
   gtk_text_buffer_get_start_iter (buffer, &end_iter);
@@ -2132,24 +2080,6 @@ text_view_new (GtkAboutDialog  *about,
   g_object_set (tag, "font-scale", PANGO_SCALE_SMALL, NULL);
   gtk_text_buffer_apply_tag (buffer, tag, &start_iter, &end_iter);
 
-  gtk_text_view_set_left_margin (text_view, 8);
-  gtk_text_view_set_right_margin (text_view, 8);
-
-  g_signal_connect (view, "key-press-event",
-                    G_CALLBACK (text_view_key_press_event), about);
-  g_signal_connect (view, "event-after",
-                    G_CALLBACK (text_view_event_after), about);
-  g_signal_connect (view, "motion-notify-event",
-                    G_CALLBACK (text_view_motion_notify_event), about);
-  g_signal_connect (view, "visibility-notify-event",
-                    G_CALLBACK (text_view_visibility_notify_event), about);
-
-  if (strings == NULL)
-    {
-      gtk_widget_hide (view);
-      return view;
-    }
-
   for (p = strings; *p; p++)
     {
       q0  = *p;
@@ -2236,8 +2166,7 @@ text_view_new (GtkAboutDialog  *about,
         gtk_text_buffer_insert_at_cursor (buffer, "\n", 1);
     }
 
-  gtk_widget_show (view);
-  return view;
+  return buffer;
 }
 
 static void
@@ -2262,6 +2191,7 @@ add_credits_section (GtkAboutDialog *about,
   gtk_widget_set_halign (label, GTK_ALIGN_END);
   gtk_widget_set_valign (label, GTK_ALIGN_CENTER);
   gtk_grid_attach (grid, label, 0, *row, 1, 1);
+  gtk_widget_show (label);
 
   for (p = people; *p; p++)
     {
@@ -2352,6 +2282,7 @@ add_credits_section (GtkAboutDialog *about,
       gtk_widget_set_halign (label, GTK_ALIGN_START);
       gtk_widget_set_valign (label, GTK_ALIGN_CENTER);
       gtk_grid_attach (grid, label, 1, *row, 1, 1);
+      gtk_widget_show (label);
       (*row)++;
     }
 
@@ -2362,43 +2293,18 @@ add_credits_section (GtkAboutDialog *about,
 }
 
 static void
-create_credits_page (GtkAboutDialog *about)
+populate_credits_page (GtkAboutDialog *about)
 {
   GtkAboutDialogPrivate *priv = about->priv;
-  GtkWidget *page_vbox;
-  GtkWidget *sw;
-  GtkWidget *grid;
   gint row;
 
-  page_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
-  gtk_widget_show (page_vbox);
-  priv->credits_page = gtk_notebook_append_page (GTK_NOTEBOOK (priv->notebook), page_vbox, NULL);
-
-  sw = gtk_scrolled_window_new (NULL, NULL);
-  gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_IN);
-  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
-                                  GTK_POLICY_NEVER,
-                                  GTK_POLICY_AUTOMATIC);
-  gtk_box_pack_start (GTK_BOX (page_vbox), sw, TRUE, TRUE, 0);
-
-  grid = gtk_grid_new ();
-  gtk_container_set_border_width (GTK_CONTAINER (grid), 5);
-  gtk_orientable_set_orientation (GTK_ORIENTABLE (grid), GTK_ORIENTATION_VERTICAL);
-  gtk_grid_set_column_spacing (GTK_GRID (grid), 8);
-  gtk_grid_set_row_spacing (GTK_GRID (grid), 2);
-  gtk_widget_set_halign (grid, GTK_ALIGN_CENTER);
-  gtk_widget_set_valign (grid, GTK_ALIGN_START);
-  gtk_container_add (GTK_CONTAINER (sw), grid);
-  gtk_style_context_add_class (gtk_widget_get_style_context (gtk_bin_get_child (GTK_BIN (sw))),
-                               GTK_STYLE_CLASS_VIEW);
-
   row = 0;
 
   if (priv->authors != NULL)
-    add_credits_section (about, GTK_GRID (grid), &row, _("Created by"), priv->authors);
+    add_credits_section (about, GTK_GRID (priv->credits_grid), &row, _("Created by"), priv->authors);
 
   if (priv->documenters != NULL)
-    add_credits_section (about, GTK_GRID (grid), &row, _("Documented by"), priv->documenters);
+    add_credits_section (about, GTK_GRID (priv->credits_grid), &row, _("Documented by"), priv->documenters);
 
   /* Don't show an untranslated gettext msgid */
   if (priv->translator_credits != NULL &&
@@ -2408,12 +2314,12 @@ create_credits_page (GtkAboutDialog *about)
       gchar **translators;
 
       translators = g_strsplit (priv->translator_credits, "\n", 0);
-      add_credits_section (about, GTK_GRID (grid), &row, _("Translated by"), translators);
+      add_credits_section (about, GTK_GRID (priv->credits_grid), &row, _("Translated by"), translators);
       g_strfreev (translators);
     }
 
   if (priv->artists != NULL)
-    add_credits_section (about, GTK_GRID (grid), &row, _("Artwork by"), priv->artists);
+    add_credits_section (about, GTK_GRID (priv->credits_grid), &row, _("Artwork by"), priv->artists);
 
   if (priv->credit_sections != NULL)
     {
@@ -2421,11 +2327,9 @@ create_credits_page (GtkAboutDialog *about)
       for (cs = priv->credit_sections; cs != NULL; cs = cs->next)
        {
          CreditSection *section = cs->data;
-         add_credits_section (about, GTK_GRID (grid), &row, section->heading, section->people);
+         add_credits_section (about, GTK_GRID (priv->credits_grid), &row, section->heading, section->people);
        }
     }
-
-  gtk_widget_show_all (sw);
 }
 
 static void
@@ -2436,37 +2340,28 @@ display_credits_page (GtkWidget *button,
   GtkAboutDialogPrivate *priv = about->priv;
 
   if (priv->credits_page == 0)
-    create_credits_page (about);
+    {
+      populate_credits_page (about);
+      priv->credits_page = CREDITS_PAGE_ID;
+    }
 
   switch_page (about, priv->credits_page);
 }
 
 static void
-create_license_page (GtkAboutDialog *about)
+populate_license_page (GtkAboutDialog *about)
 {
   GtkAboutDialogPrivate *priv = about->priv;
-  GtkWidget *page_vbox;
-  GtkWidget *sw;
-  GtkWidget *view;
+  GtkTextBuffer *buffer;
   gchar *strings[2];
 
-  page_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
-  priv->license_page = gtk_notebook_append_page (GTK_NOTEBOOK (priv->notebook), page_vbox, NULL);
-
-  sw = gtk_scrolled_window_new (NULL, NULL);
-  gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_IN);
-  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
-                                  GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
-  gtk_box_pack_start (GTK_BOX (page_vbox), sw, TRUE, TRUE, 0);
+  gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (priv->license_view), priv->wrap_license ? GTK_WRAP_WORD : 
GTK_WRAP_NONE);
 
   strings[0] = priv->license;
   strings[1] = NULL;
-  view = text_view_new (about, strings,
-                        priv->wrap_license ? GTK_WRAP_WORD : GTK_WRAP_NONE);
-
-  gtk_container_add (GTK_CONTAINER (sw), view);
-
-  gtk_widget_show_all (page_vbox);
+  buffer = text_buffer_new (about, strings);
+  gtk_text_view_set_buffer (GTK_TEXT_VIEW (priv->license_view), buffer);
+  g_object_unref (buffer);
 }
 
 static void
@@ -2477,7 +2372,10 @@ display_license_page (GtkWidget *button,
   GtkAboutDialogPrivate *priv = about->priv;
 
   if (priv->license_page == 0)
-    create_license_page (about);
+    {
+      populate_license_page (about);
+      priv->license_page = LICENSE_PAGE_ID;
+    }
 
   switch_page (about, priv->license_page);
 }
diff --git a/gtk/gtkaboutdialog.ui b/gtk/gtkaboutdialog.ui
new file mode 100644
index 0000000..aad9729
--- /dev/null
+++ b/gtk/gtkaboutdialog.ui
@@ -0,0 +1,329 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface domain="gtk30">
+  <!-- interface-requires gtk+ 3.10 -->
+  <object class="GtkImage" id="image1">
+    <property name="visible">True</property>
+    <property name="stock">gtk-about</property>
+  </object>
+  <template class="GtkAboutDialog" parent="GtkDialog">
+    <property name="border_width">5</property>
+    <property name="resizable">False</property>
+    <property name="type_hint">dialog</property>
+    <child internal-child="vbox">
+      <object class="GtkBox" id="dialog-vbox1">
+        <property name="orientation">vertical</property>
+        <property name="spacing">2</property>
+        <child internal-child="action_area">
+          <object class="GtkButtonBox" id="dialog-action_area1">
+            <property name="layout_style">end</property>
+           <property name="border_width">5</property>
+            <child>
+              <object class="GtkToggleButton" id="credits_button">
+                <property name="label" translatable="yes">C_redits</property>
+                <property name="can_focus">True</property>
+                <property name="can_default">True</property>
+                <property name="receives_default">True</property>
+                <property name="no_show_all">True</property>
+                <property name="image">image1</property>
+                <property name="use_underline">True</property>
+                <signal name="clicked" handler="credits_button_clicked" swapped="no"/>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="pack_type">end</property>
+                <property name="position">0</property>
+                <property name="secondary">True</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkToggleButton" id="license_button">
+                <property name="label" translatable="yes">_License</property>
+                <property name="can_focus">True</property>
+                <property name="can_default">True</property>
+                <property name="receives_default">True</property>
+                <property name="no_show_all">True</property>
+                <property name="use_underline">True</property>
+                <signal name="clicked" handler="license_button_clicked" swapped="no"/>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="pack_type">end</property>
+                <property name="position">1</property>
+                <property name="secondary">True</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkButton" id="close_button">
+                <property name="label">gtk-close</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="can_default">True</property>
+                <property name="is_focus">True</property>
+                <property name="has_default">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_stock">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">2</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="pack_type">end</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkBox" id="box">
+            <property name="visible">True</property>
+            <property name="border_width">5</property>
+            <property name="orientation">vertical</property>
+            <property name="spacing">12</property>
+            <child>
+              <object class="GtkImage" id="logo_image">
+                <property name="visible">True</property>
+                <property name="stock">gtk-missing-image</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkLabel" id="name_label">
+                <property name="visible">True</property>
+                <property name="label">name label</property>
+                <property name="justify">center</property>
+                <property name="selectable">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkNotebook" id="notebook">
+                <property name="width_request">400</property>
+                <property name="height_request">100</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="show_tabs">False</property>
+                <property name="show_border">False</property>
+                <child>
+                  <object class="GtkBox" id="page_vbox">
+                    <property name="visible">True</property>
+                    <property name="orientation">vertical</property>
+                    <property name="spacing">8</property>
+                    <child>
+                      <object class="GtkLabel" id="version_label">
+                        <property name="label">version 1.0</property>
+                        <property name="justify">center</property>
+                        <property name="selectable">True</property>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">False</property>
+                        <property name="position">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="comments_label">
+                        <property name="label">comments</property>
+                        <property name="justify">center</property>
+                        <property name="wrap">True</property>
+                        <property name="selectable">True</property>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">False</property>
+                        <property name="position">1</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkBox" id="hbox">
+                        <property name="visible">True</property>
+                        <property name="homogeneous">True</property>
+                        <child>
+                          <object class="GtkLabel" id="website_label">
+                            <property name="no_show_all">True</property>
+                            <property name="label">http://website.com</property>
+                            <property name="selectable">True</property>
+                            <signal name="activate-link" handler="emit_activate_link" swapped="yes"/>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">False</property>
+                            <property name="position">0</property>
+                          </packing>
+                        </child>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">False</property>
+                        <property name="position">2</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="license_label">
+                        <property name="label">license</property>
+                        <property name="use_markup">True</property>
+                        <property name="justify">center</property>
+                        <property name="wrap">True</property>
+                        <property name="selectable">True</property>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">False</property>
+                        <property name="pack_type">end</property>
+                        <property name="position">3</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="copyright_label">
+                        <property name="label">copyright</property>
+                        <property name="justify">center</property>
+                        <property name="wrap">True</property>
+                        <property name="selectable">True</property>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">False</property>
+                        <property name="pack_type">end</property>
+                        <property name="position">4</property>
+                      </packing>
+                    </child>
+                  </object>
+                </child>
+                <child type="tab">
+                  <placeholder/>
+                </child>
+                <child>
+                 <object class="GtkBox" id="credits_page">
+                   <property name="visible">True</property>
+                   <property name="can_focus">False</property>
+                   <property name="orientation">vertical</property>
+                   <property name="spacing">8</property>
+                   <child>
+                     <object class="GtkScrolledWindow" id="scrolledwindow1">
+                       <property name="visible">True</property>
+                       <property name="can_focus">True</property>
+                       <property name="hscrollbar_policy">never</property>
+                       <property name="shadow_type">in</property>
+                       <child>
+                         <object class="GtkViewport" id="viewport1">
+                           <property name="visible">True</property>
+                           <property name="can_focus">False</property>
+                           <style>
+                             <class name="view"/>
+                           </style>
+                           <child>
+                             <object class="GtkGrid" id="credits_grid">
+                               <property name="visible">True</property>
+                               <property name="can_focus">False</property>
+                               <property name="halign">center</property>
+                               <property name="valign">start</property>
+                               <property name="border_width">5</property>
+                               <property name="orientation">vertical</property>
+                               <property name="row_spacing">2</property>
+                               <property name="column_spacing">8</property>
+                               <child>
+                                 <placeholder/>
+                               </child>
+                               <child>
+                                 <placeholder/>
+                               </child>
+                               <child>
+                                 <placeholder/>
+                               </child>
+                               <child>
+                                 <placeholder/>
+                               </child>
+                               <child>
+                                 <placeholder/>
+                               </child>
+                               <child>
+                                 <placeholder/>
+                               </child>
+                             </object>
+                           </child>
+                         </object>
+                       </child>
+                     </object>
+                     <packing>
+                       <property name="expand">True</property>
+                       <property name="fill">True</property>
+                       <property name="position">0</property>
+                     </packing>
+                   </child>
+                 </object>
+                </child>
+                <child type="tab">
+                  <placeholder/>
+                </child>
+               <child>
+                 <object class="GtkBox" id="license_page">
+                   <property name="visible">True</property>
+                   <property name="can_focus">False</property>
+                   <property name="orientation">vertical</property>
+                   <property name="spacing">8</property>
+                   <child>
+                     <object class="GtkScrolledWindow" id="scrolledwindow2">
+                       <property name="visible">True</property>
+                       <property name="can_focus">True</property>
+                       <property name="hscrollbar_policy">never</property>
+                       <property name="shadow_type">in</property>
+                       <child>
+                         <object class="GtkTextView" id="textview">
+                           <property name="visible">True</property>
+                           <property name="can_focus">True</property>
+                           <property name="editable">False</property>
+                           <property name="left_margin">8</property>
+                           <property name="right_margin">8</property>
+                           <property name="cursor_visible">False</property>
+                           <signal name="key-press-event" handler="text_view_key_press_event" swapped="no"/>
+                           <signal name="visibility-notify-event" 
handler="text_view_visibility_notify_event" swapped="no"/>
+                           <signal name="event-after" handler="text_view_event_after" swapped="no"/>
+                           <signal name="motion-notify-event" handler="text_view_motion_notify_event" 
swapped="no"/>
+                         </object>
+                       </child>
+                     </object>
+                     <packing>
+                       <property name="expand">True</property>
+                       <property name="fill">True</property>
+                       <property name="position">0</property>
+                     </packing>
+                   </child>
+                 </object>
+               </child>
+                <child type="tab">
+                  <placeholder/>
+                </child>
+              </object>
+              <packing>
+                <property name="expand">True</property>
+                <property name="fill">True</property>
+                <property name="position">2</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">True</property>
+            <property name="fill">True</property>
+            <property name="position">1</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+    <action-widgets>
+      <action-widget response="-6">close_button</action-widget>
+    </action-widgets>
+  </template>
+</interface>
diff --git a/gtk/tests/templates.c b/gtk/tests/templates.c
index 0c4e350..d1a197b 100644
--- a/gtk/tests/templates.c
+++ b/gtk/tests/templates.c
@@ -56,6 +56,16 @@ test_message_dialog_basic (void)
 }
 
 static void
+test_about_dialog_basic (void)
+{
+  GtkWidget *dialog;
+
+  dialog = gtk_about_dialog_new ();
+  g_assert (GTK_IS_ABOUT_DIALOG (dialog));
+  gtk_widget_destroy (dialog);
+}
+
+static void
 test_info_bar_basic (void)
 {
   GtkWidget *infobar;
@@ -74,6 +84,7 @@ main (int argc, char **argv)
   g_test_add_func ("/Template/GtkDialog/Basic", test_dialog_basic);
   g_test_add_func ("/Template/GtkDialog/OverrideProperty", test_dialog_override_property);
   g_test_add_func ("/Template/GtkMessageDialog/Basic", test_message_dialog_basic);
+  g_test_add_func ("/Template/GtkAboutDialog/Basic", test_about_dialog_basic);
   g_test_add_func ("/Template/GtkInfoBar/Basic", test_info_bar_basic);
 
   return g_test_run();
diff --git a/po/POTFILES.in b/po/POTFILES.in
index bfb50a4..b011511 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -274,6 +274,7 @@ modules/printbackends/file/gtkprintbackendfile.c
 modules/printbackends/lpr/gtkprintbackendlpr.c
 modules/printbackends/papi/gtkprintbackendpapi.c
 modules/printbackends/test/gtkprintbackendtest.c
+[type: gettext/glade]gtk/gtkaboutdialog.ui
 [type: gettext/glade]gtk/gtkdialog.ui
 [type: gettext/glade]gtk/gtkinfobar.ui
 [type: gettext/glade]gtk/gtkmessagedialog.ui


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