[gnome-software: 45/110] Use AdwWindowTitle for headerbar titles




commit 8842173a7e8d79a08c685168f05f3edb23d8762c
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Tue Aug 24 09:30:41 2021 -0300

    Use AdwWindowTitle for headerbar titles
    
    AdwHeaderBar does not have a title and subtitle anymore, this is
    handled as a separate widget called AdwWindowTitle. Use it instead.

 src/gs-app-details-page.c  | 15 ++++++++-------
 src/gs-app-details-page.ui |  3 +++
 src/gs-os-update-page.c    |  7 ++++---
 src/gs-os-update-page.ui   |  6 +++++-
 src/gs-shell.ui            | 12 ++++++++----
 src/gs-update-dialog.c     |  6 +++---
 src/gs-update-dialog.ui    |  6 +++++-
 7 files changed, 36 insertions(+), 19 deletions(-)
---
diff --git a/src/gs-app-details-page.c b/src/gs-app-details-page.c
index b2caa1c16..6f34ba819 100644
--- a/src/gs-app-details-page.c
+++ b/src/gs-app-details-page.c
@@ -56,6 +56,7 @@ struct _GsAppDetailsPage
        GtkWidget       *permissions_section_box;
        GtkWidget       *permissions_section_content;
        GtkWidget       *scrolledwindow_details;
+       AdwWindowTitle  *window_title;
 
        GsApp           *app;  /* (owned) (nullable) */
 };
@@ -139,8 +140,7 @@ set_updates_description_ui (GsAppDetailsPage *page, GsApp *app)
        kind = gs_app_get_kind (app);
        if (kind == AS_COMPONENT_KIND_GENERIC &&
            gs_app_get_special_kind (app) == GS_APP_SPECIAL_KIND_OS_UPDATE) {
-               adw_header_bar_set_title (ADW_HEADER_BAR (page->header_bar),
-                                         gs_app_get_name (app));
+               adw_window_title_set_title (page->window_title, gs_app_get_name (app));
        } else if (gs_app_get_source_default (app) != NULL &&
                   gs_app_get_update_version (app) != NULL) {
                g_autofree gchar *tmp = NULL;
@@ -153,13 +153,13 @@ set_updates_description_ui (GsAppDetailsPage *page, GsApp *app)
                tmp = g_strdup_printf (_("%s %s"),
                                       gs_app_get_source_default (app),
                                       gs_app_get_update_version (app));
-               adw_header_bar_set_title (ADW_HEADER_BAR (page->header_bar), tmp);
+               adw_window_title_set_title (page->window_title, tmp);
        } else if (gs_app_get_source_default (app) != NULL) {
-               adw_header_bar_set_title (ADW_HEADER_BAR (page->header_bar),
-                                         gs_app_get_source_default (app));
+               adw_window_title_set_title (page->window_title,
+                                           gs_app_get_source_default (app));
        } else {
-               adw_header_bar_set_title (ADW_HEADER_BAR (page->header_bar),
-                                         gs_app_get_update_version (app));
+               adw_window_title_set_title (page->window_title,
+                                           gs_app_get_update_version (app));
        }
 
        /* set update header */
@@ -411,6 +411,7 @@ gs_app_details_page_class_init (GsAppDetailsPageClass *klass)
        gtk_widget_class_bind_template_child (widget_class, GsAppDetailsPage, permissions_section_box);
        gtk_widget_class_bind_template_child (widget_class, GsAppDetailsPage, permissions_section_content);
        gtk_widget_class_bind_template_child (widget_class, GsAppDetailsPage, scrolledwindow_details);
+       gtk_widget_class_bind_template_child (widget_class, GsAppDetailsPage, window_title);
        gtk_widget_class_bind_template_callback (widget_class, back_clicked_cb);
 }
 
diff --git a/src/gs-app-details-page.ui b/src/gs-app-details-page.ui
index aa3c0065b..ebbcaff9a 100644
--- a/src/gs-app-details-page.ui
+++ b/src/gs-app-details-page.ui
@@ -8,6 +8,9 @@
       <object class="AdwHeaderBar" id="header_bar">
         <property name="show_close_button">True</property>
         <property name="visible">True</property>
+        <property name="title-widget">
+          <object class="AdwWindowTitle" id="window_title" />
+        </property>
         <child>
           <object class="GtkButton" id="back_button">
             <property name="visible">True</property>
diff --git a/src/gs-os-update-page.c b/src/gs-os-update-page.c
index b155131d1..813d7b05b 100644
--- a/src/gs-os-update-page.c
+++ b/src/gs-os-update-page.c
@@ -54,6 +54,7 @@ struct _GsOsUpdatePage
        GtkWidget       *box;
        GtkWidget       *group;
        GtkWidget       *header_bar;
+       AdwWindowTitle  *window_title;
 
        GsApp           *app;  /* (owned) (nullable) */
        GtkWidget       *list_boxes[GS_OS_UPDATE_PAGE_SECTION_LAST];
@@ -404,8 +405,7 @@ gs_os_update_page_set_app (GsOsUpdatePage *page, GsApp *app)
        }
 
        if (app) {
-               adw_header_bar_set_title (ADW_HEADER_BAR (page->header_bar),
-                                         gs_app_get_name (app));
+               adw_window_title_set_title (page->window_title, gs_app_get_name (app));
                adw_preferences_group_set_description (ADW_PREFERENCES_GROUP (page->group),
                                                       gs_app_get_description (app));
 
@@ -422,7 +422,7 @@ gs_os_update_page_set_app (GsOsUpdatePage *page, GsApp *app)
                        gtk_list_box_insert (GTK_LIST_BOX (page->list_boxes[section]), row, -1);
                }
        } else {
-               adw_header_bar_set_title (ADW_HEADER_BAR (page->header_bar), NULL);
+               adw_window_title_set_title (page->window_title, NULL);
                adw_preferences_group_set_description (ADW_PREFERENCES_GROUP (page->group), NULL);
        }
 
@@ -520,6 +520,7 @@ gs_os_update_page_class_init (GsOsUpdatePageClass *klass)
        gtk_widget_class_bind_template_child (widget_class, GsOsUpdatePage, box);
        gtk_widget_class_bind_template_child (widget_class, GsOsUpdatePage, group);
        gtk_widget_class_bind_template_child (widget_class, GsOsUpdatePage, header_bar);
+       gtk_widget_class_bind_template_child (widget_class, GsOsUpdatePage, window_title);
 }
 
 /**
diff --git a/src/gs-os-update-page.ui b/src/gs-os-update-page.ui
index 77b3ca7df..bbe1a743b 100644
--- a/src/gs-os-update-page.ui
+++ b/src/gs-os-update-page.ui
@@ -6,8 +6,12 @@
 
     <child>
       <object class="AdwHeaderBar" id="header_bar">
-        <property name="show_close_button">True</property>
         <property name="visible">True</property>
+        <property name="show_start_title_buttons">True</property>
+        <property name="show_end_title_buttons">True</property>
+        <property name="title-widget">
+          <object class="AdwWindowTitle" id="window_title" />
+        </property>
       </object>
     </child>
     <child>
diff --git a/src/gs-shell.ui b/src/gs-shell.ui
index bcf9f191f..3e3bf9963 100644
--- a/src/gs-shell.ui
+++ b/src/gs-shell.ui
@@ -170,7 +170,7 @@
                             <property name="visible">True</property>
                             <property name="can-focus">False</property>
                             <property name="hexpand">True</property>
-                            <property name="show-close-button">True</property>
+                            <property name="show-end-title-buttons">True</property>
                             <property name="centering-policy">strict</property>
                             <child>
                               <object class="GtkToggleButton" id="search_button">
@@ -373,8 +373,8 @@
                           <object class="AdwHeaderBar" id="sub_header">
                             <property name="visible">True</property>
                             <property name="can-focus">False</property>
+                            <property name="show-end-title-buttons">True</property>
                             <property name="hexpand">True</property>
-                            <property name="show-close-button">True</property>
                             <child>
                               <object class="GtkButton" id="button_back">
                                 <property name="visible">True</property>
@@ -459,8 +459,12 @@
                         <property name="visible">True</property>
                         <property name="can-focus">False</property>
                         <property name="hexpand">True</property>
-                        <property name="show-close-button">True</property>
-                        <property name="title" bind-source="details_page" bind-property="title" 
bind-flags="sync-create"/>
+                        <property name="show-end-title-buttons">True</property>
+                        <property name="title-widget">
+                          <object class="AdwWindowTitle">
+                            <property name="title" bind-source="details_page" bind-property="title" 
bind-flags="sync-create"/>
+                          </object>
+                        </property>
                         <child>
                           <object class="GtkButton" id="button_back2">
                             <property name="visible">True</property>
diff --git a/src/gs-update-dialog.c b/src/gs-update-dialog.c
index b458e78ff..71387e935 100644
--- a/src/gs-update-dialog.c
+++ b/src/gs-update-dialog.c
@@ -29,6 +29,7 @@ struct _GsUpdateDialog
        GtkWidget       *list_box_installed_updates;
        GtkWidget       *spinner;
        GtkWidget       *stack;
+       AdwWindowTitle  *window_title;
 };
 
 G_DEFINE_TYPE (GsUpdateDialog, gs_update_dialog, ADW_TYPE_WINDOW)
@@ -103,7 +104,6 @@ get_installed_updates_cb (GsPluginLoader *plugin_loader,
        /* set the header title using any one of the applications */
        install_date = gs_app_get_install_date (gs_app_list_index (list, 0));
        if (install_date > 0) {
-               GtkWidget *header;
                g_autoptr(GDateTime) date = NULL;
                g_autofree gchar *date_str = NULL;
                g_autofree gchar *subtitle = NULL;
@@ -116,8 +116,7 @@ get_installed_updates_cb (GsPluginLoader *plugin_loader,
                   The date format is defined by the locale's preferred date representation
                   ("%x" in strftime.) */
                subtitle = g_strdup_printf (_("Installed on %s"), date_str);
-               header = gtk_dialog_get_header_bar (GTK_DIALOG (dialog));
-               gtk_header_bar_set_subtitle (GTK_HEADER_BAR (header), subtitle);
+               adw_window_title_set_subtitle (dialog->window_title, subtitle);
        }
 
        gtk_stack_set_visible_child_name (GTK_STACK (dialog->stack), "installed-updates-list");
@@ -380,6 +379,7 @@ gs_update_dialog_class_init (GsUpdateDialogClass *klass)
        gtk_widget_class_bind_template_child (widget_class, GsUpdateDialog, list_box_installed_updates);
        gtk_widget_class_bind_template_child (widget_class, GsUpdateDialog, spinner);
        gtk_widget_class_bind_template_child (widget_class, GsUpdateDialog, stack);
+       gtk_widget_class_bind_template_child (widget_class, GsUpdateDialog, window_title);
        gtk_widget_class_bind_template_callback (widget_class, button_pressed_cb);
        gtk_widget_class_bind_template_callback (widget_class, deck_child_transition_cb);
        gtk_widget_class_bind_template_callback (widget_class, key_pressed_cb);
diff --git a/src/gs-update-dialog.ui b/src/gs-update-dialog.ui
index ed85f4f12..6b9dce640 100644
--- a/src/gs-update-dialog.ui
+++ b/src/gs-update-dialog.ui
@@ -41,7 +41,11 @@
               <object class="AdwHeaderBar">
                 <property name="show_close_button">True</property>
                 <property name="visible">True</property>
-                <property name="title" bind-source="GsUpdateDialog" bind-property="title" 
bind-flags="sync-create"/>
+                <property name="title-widget">
+                  <object class="AdwWindowTitle" id="window_title">
+                    <property name="title" bind-source="GsUpdateDialog" bind-property="title" 
bind-flags="sync-create"/>
+                  </object>
+                </property>
               </object>
             </child>
             <child>


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