[gnome-software/1754-improve-the-sources-dropdown: 5/6] gs-details-page: Move the Sources menu button away from the header bar




commit db4d0c0b41a7a6f686bd0e5d90989fad801713a8
Author: Milan Crha <mcrha redhat com>
Date:   Wed Aug 3 16:10:42 2022 +0200

    gs-details-page: Move the Sources menu button away from the header bar
    
    ... and place it below the app action buttons, to follow the suggested design.
    
    Closes https://gitlab.gnome.org/GNOME/gnome-software/-/issues/1754

 src/gs-details-page.c  |  39 ++++++--
 src/gs-details-page.ui | 239 +++++++++++++++++++++++++++++--------------------
 src/gs-shell.c         |  27 ------
 3 files changed, 170 insertions(+), 135 deletions(-)
---
diff --git a/src/gs-details-page.c b/src/gs-details-page.c
index 258814616..6d01bf254 100644
--- a/src/gs-details-page.c
+++ b/src/gs-details-page.c
@@ -92,6 +92,7 @@ struct _GsDetailsPage
        GAppInfoMonitor         *app_info_monitor; /* (owned) */
        GHashTable              *packaging_format_preference; /* gchar * ~> gint */
        GtkWidget               *app_reviews_dialog;
+       GtkCssProvider          *origin_css_provider; /* (nullable) (owned) */
        gboolean                 origin_by_packaging_format; /* when TRUE, change the 'app' to the most 
preferred
                                                                packaging format when the alternatives are 
found */
        gboolean                 is_narrow;
@@ -146,7 +147,8 @@ struct _GsDetailsPage
        GtkWidget               *origin_popover;
        GtkWidget               *origin_popover_list_box;
        GtkWidget               *origin_box;
-       GtkWidget               *origin_button;
+       GtkWidget               *origin_packaging_image;
+       GtkWidget               *origin_packaging_label;
        GtkWidget               *box_license;
        GsLicenseTile           *license_tile;
        GtkInfoBar              *translation_infobar;
@@ -257,6 +259,7 @@ static void
 gs_details_page_update_origin_button (GsDetailsPage *self,
                                      gboolean sensitive)
 {
+       const gchar *packaging_icon;
        g_autofree gchar *origin_ui = NULL;
 
        if (self->app == NULL ||
@@ -265,14 +268,32 @@ gs_details_page_update_origin_button (GsDetailsPage *self,
                return;
        }
 
-       origin_ui = gs_app_dup_origin_ui (self->app, TRUE);
-       if (origin_ui != NULL)
-               gtk_menu_button_set_label (GTK_MENU_BUTTON (self->origin_button), origin_ui);
-       else
-               gtk_menu_button_set_label (GTK_MENU_BUTTON (self->origin_button), "");
+       origin_ui = gs_app_dup_origin_ui (self->app, FALSE);
+       gtk_label_set_text (GTK_LABEL (self->origin_packaging_label), origin_ui != NULL ? origin_ui : "");
 
        gtk_widget_set_sensitive (self->origin_box, sensitive);
        gtk_widget_show (self->origin_box);
+
+       packaging_icon = gs_app_get_metadata_item (self->app, "GnomeSoftware::PackagingIcon");
+
+       if (packaging_icon != NULL) {
+               const gchar *packaging_base_css_color;
+               g_autofree gchar *css = NULL;
+
+               packaging_base_css_color = gs_app_get_metadata_item (self->app, 
"GnomeSoftware::PackagingBaseCssColor");
+
+               gtk_image_set_from_icon_name (GTK_IMAGE (self->origin_packaging_image), packaging_icon);
+
+               if (packaging_base_css_color == NULL)
+                       packaging_base_css_color = "window_fg_color";
+
+               css = g_strdup_printf ("color: @%s;\n", packaging_base_css_color);
+
+               gs_utils_widget_set_css (self->origin_packaging_image, &self->origin_css_provider, 
"packaging-color", css);
+               gtk_widget_show (self->origin_packaging_image);
+       } else {
+               gtk_widget_hide (self->origin_packaging_image);
+       }
 }
 
 static void
@@ -2295,6 +2316,7 @@ gs_details_page_dispose (GObject *object)
                g_hash_table_unref (self->packaging_format_preference);
                self->packaging_format_preference = NULL;
        }
+       g_clear_object (&self->origin_css_provider);
        g_clear_object (&self->app_local_file);
        g_clear_object (&self->app_reviews_dialog);
        g_clear_object (&self->plugin_loader);
@@ -2441,7 +2463,8 @@ gs_details_page_class_init (GsDetailsPageClass *klass)
        gtk_widget_class_bind_template_child (widget_class, GsDetailsPage, origin_popover);
        gtk_widget_class_bind_template_child (widget_class, GsDetailsPage, origin_popover_list_box);
        gtk_widget_class_bind_template_child (widget_class, GsDetailsPage, origin_box);
-       gtk_widget_class_bind_template_child (widget_class, GsDetailsPage, origin_button);
+       gtk_widget_class_bind_template_child (widget_class, GsDetailsPage, origin_packaging_image);
+       gtk_widget_class_bind_template_child (widget_class, GsDetailsPage, origin_packaging_label);
        gtk_widget_class_bind_template_child (widget_class, GsDetailsPage, box_license);
        gtk_widget_class_bind_template_child (widget_class, GsDetailsPage, license_tile);
        gtk_widget_class_bind_template_child (widget_class, GsDetailsPage, translation_infobar);
@@ -2515,8 +2538,6 @@ gs_details_page_init (GsDetailsPage *self)
        g_signal_connect (self->list_box_featured_review, "row-activated",
                          G_CALLBACK (featured_review_list_row_activated_cb), self);
 
-       gs_page_set_header_end_widget (GS_PAGE (self), self->origin_box);
-
        gs_details_page_read_packaging_format_preference (self);
 
        g_object_bind_property_full (self, "is-narrow", self->box_details_header, "spacing", 
G_BINDING_SYNC_CREATE,
diff --git a/src/gs-details-page.ui b/src/gs-details-page.ui
index 38aedc2db..8b0e88bf1 100644
--- a/src/gs-details-page.ui
+++ b/src/gs-details-page.ui
@@ -211,110 +211,165 @@
                                         </child>
 
                                         <child>
-                                          <object class="GtkBox" id="box_install_remove">
+                                          <object class="GtkBox" id="box_with_source">
+                                            <property name="orientation">vertical</property>
+                                            <property name="valign">center</property>
                                             <property name="spacing">9</property>
                                             <child>
-                                              <object class="GtkButton" id="button_install">
-                                                <property name="visible">False</property>
-                                                <property name="use_underline">True</property>
-                                                <property name="label" translatable="yes">_Install</property>
-                                                <property name="width_request">105</property>
-                                                <property name="can_focus">True</property>
-                                                <property name="receives_default">True</property>
-                                                <property name="halign">start</property>
-                                                <property name="valign">center</property>
-                                                <signal name="clicked" 
handler="gs_details_page_app_install_button_cb"/>
-                                                <style>
-                                                  <class name="suggested-action"/>
-                                                </style>
-                                              </object>
-                                            </child>
-                                            <child>
-                                              <object class="GtkButton" id="button_details_launch">
-                                                <property name="can_focus">True</property>
-                                                <!-- TRANSLATORS: A label for a button to execute the 
selected application. -->
-                                                <property name="label" translatable="yes">_Open</property>
-                                                <property name="use_underline">True</property>
-                                                <property name="valign">center</property>
-                                                <signal name="clicked" 
handler="gs_details_page_app_launch_button_cb"/>
-                                                <style>
-                                                  <class name="suggested-action"/>
-                                                </style>
-                                              </object>
-                                            </child>
-                                            <child>
-                                              <object class="GtkButton" id="button_update">
-                                                <property name="visible">False</property>
-                                                <property name="use_underline">True</property>
-                                                <property name="label" translatable="yes">_Update</property>
-                                                <property name="width_request">105</property>
-                                                <property name="can_focus">True</property>
-                                                <property name="receives_default">True</property>
-                                                <property name="halign">start</property>
-                                                <property name="valign">center</property>
-                                                <signal name="clicked" 
handler="gs_details_page_app_update_button_cb"/>
-                                              </object>
-                                            </child>
-                                            <child>
-                                              <object class="GtkButton" id="button_remove">
-                                                <property name="visible">False</property>
-                                                <property name="can_focus">True</property>
-                                                <property name="receives_default">True</property>
-                                                <property name="halign">start</property>
-                                                <property name="valign">center</property>
-                                                <signal name="clicked" 
handler="gs_details_page_app_remove_button_cb"/>
+                                              <object class="GtkBox" id="box_install_remove">
+                                                <property name="orientation">horizontal</property>
+                                                <property name="halign">center</property>
+                                                <property name="spacing">9</property>
                                                 <child>
-                                                  <object class="GtkImage">
-                                                    <property name="icon-name">user-trash-symbolic</property>
-                                                  </object>
-                                                </child>
-                                                <accessibility>
-                                                  <!-- TRANSLATORS: button text in the header when an 
application can be erased -->
-                                                  <property name="label" 
translatable="yes">Uninstall</property>
-                                                </accessibility>
-                                              </object>
-                                            </child>
-                                            <child>
-                                              <object class="GtkCenterBox">
-                                                <property name="visible" bind-source="button_cancel" 
bind-property="visible" bind-flags="sync-create"/>
-                                                <property name="orientation">vertical</property>
-                                                <property name="valign">center</property>
-                                                <child type="center">
-                                                  <object class="GsProgressButton" id="button_cancel">
+                                                  <object class="GtkButton" id="button_install">
                                                     <property name="visible">False</property>
                                                     <property name="use_underline">True</property>
-                                                    <property name="label" 
translatable="yes">_Cancel</property>
+                                                    <property name="label" 
translatable="yes">_Install</property>
+                                                    <property name="width_request">105</property>
                                                     <property name="can_focus">True</property>
                                                     <property name="receives_default">True</property>
+                                                    <property name="halign">start</property>
                                                     <property name="valign">center</property>
-                                                    <property name="margin-bottom">3</property>
-                                                    <signal name="clicked" 
handler="gs_details_page_app_cancel_button_cb"/>
+                                                    <signal name="clicked" 
handler="gs_details_page_app_install_button_cb"/>
                                                     <style>
-                                                      <class name="list-button"/>
+                                                      <class name="suggested-action"/>
                                                     </style>
                                                   </object>
                                                 </child>
-                                                <child type="end">
-                                                  <object class="GtkBox">
-                                                    <property name="visible" 
bind-source="label_progress_status" bind-property="visible" bind-flags="sync-create"/>
-                                                    <property name="spacing">3</property>
-                                                    <property name="halign">center</property>
-                                                    <property name="valign">start</property>
-                                                    <property name="vexpand">True</property>
+                                                <child>
+                                                  <object class="GtkButton" id="button_details_launch">
+                                                    <property name="can_focus">True</property>
+                                                    <!-- TRANSLATORS: A label for a button to execute the 
selected application. -->
+                                                    <property name="label" 
translatable="yes">_Open</property>
+                                                    <property name="use_underline">True</property>
+                                                    <property name="valign">center</property>
+                                                    <signal name="clicked" 
handler="gs_details_page_app_launch_button_cb"/>
                                                     <style>
-                                                      <class name="dim-label"/>
-                                                      <class name="install-progress-label"/>
+                                                      <class name="suggested-action"/>
                                                     </style>
+                                                  </object>
+                                                </child>
+                                                <child>
+                                                  <object class="GtkButton" id="button_update">
+                                                    <property name="visible">False</property>
+                                                    <property name="use_underline">True</property>
+                                                    <property name="label" 
translatable="yes">_Update</property>
+                                                    <property name="width_request">105</property>
+                                                    <property name="can_focus">True</property>
+                                                    <property name="receives_default">True</property>
+                                                    <property name="halign">start</property>
+                                                    <property name="valign">center</property>
+                                                    <signal name="clicked" 
handler="gs_details_page_app_update_button_cb"/>
+                                                  </object>
+                                                </child>
+                                                <child>
+                                                  <object class="GtkButton" id="button_remove">
+                                                    <property name="visible">False</property>
+                                                    <property name="can_focus">True</property>
+                                                    <property name="receives_default">True</property>
+                                                    <property name="halign">start</property>
+                                                    <property name="valign">center</property>
+                                                    <signal name="clicked" 
handler="gs_details_page_app_remove_button_cb"/>
                                                     <child>
-                                                      <object class="GtkLabel" id="label_progress_status">
+                                                      <object class="GtkImage">
+                                                        <property 
name="icon-name">user-trash-symbolic</property>
+                                                      </object>
+                                                    </child>
+                                                    <accessibility>
+                                                      <!-- TRANSLATORS: button text in the header when an 
application can be erased -->
+                                                      <property name="label" 
translatable="yes">Uninstall</property>
+                                                    </accessibility>
+                                                  </object>
+                                                </child>
+                                                <child>
+                                                  <object class="GtkCenterBox">
+                                                    <property name="visible" bind-source="button_cancel" 
bind-property="visible" bind-flags="sync-create"/>
+                                                    <property name="orientation">vertical</property>
+                                                    <property name="valign">center</property>
+                                                    <child type="center">
+                                                      <object class="GsProgressButton" id="button_cancel">
+                                                        <property name="visible">False</property>
+                                                        <property name="use_underline">True</property>
+                                                        <property name="label" 
translatable="yes">_Cancel</property>
+                                                        <property name="can_focus">True</property>
+                                                        <property name="receives_default">True</property>
+                                                        <property name="valign">center</property>
+                                                        <property name="margin-bottom">3</property>
+                                                        <signal name="clicked" 
handler="gs_details_page_app_cancel_button_cb"/>
+                                                        <style>
+                                                          <class name="list-button"/>
+                                                        </style>
+                                                      </object>
+                                                    </child>
+                                                    <child type="end">
+                                                      <object class="GtkBox">
+                                                        <property name="visible" 
bind-source="label_progress_status" bind-property="visible" bind-flags="sync-create"/>
+                                                        <property name="spacing">3</property>
+                                                        <property name="halign">center</property>
                                                         <property name="valign">start</property>
-                                                        <property name="label" 
translatable="yes">Downloading</property>
+                                                        <property name="vexpand">True</property>
+                                                        <style>
+                                                          <class name="dim-label"/>
+                                                          <class name="install-progress-label"/>
+                                                        </style>
+                                                        <child>
+                                                          <object class="GtkLabel" 
id="label_progress_status">
+                                                            <property name="valign">start</property>
+                                                            <property name="label" 
translatable="yes">Downloading</property>
+                                                          </object>
+                                                        </child>
+                                                        <child>
+                                                          <object class="GtkLabel" 
id="label_progress_percentage">
+                                                            <property name="valign">start</property>
+                                                            <property name="label">50%</property>
+                                                          </object>
+                                                        </child>
                                                       </object>
                                                     </child>
+                                                  </object>
+                                                </child>
+                                              </object>
+                                            </child>
+
+                                            <child>
+                                              <object class="GtkBox" id="origin_box">
+                                                <property name="orientation">horizontal</property>
+                                                <property name="spacing">4</property>
+                                                <property name="halign">center</property>
+                                                <property name="valign">center</property>
+                                                <child>
+                                                  <object class="GtkMenuButton" id="origin_button">
+                                                    <property name="can_focus">True</property>
+                                                    <property name="sensitive">True</property>
+                                                    <property name="always-show-arrow">True</property>
+                                                    <property name="popover">origin_popover</property>
+                                                    <style>
+                                                      <class name="flat"/>
+                                                    </style>
                                                     <child>
-                                                      <object class="GtkLabel" 
id="label_progress_percentage">
-                                                        <property name="valign">start</property>
-                                                        <property name="label">50%</property>
+                                                      <object class="GtkBox" id="origin_menu_btn_box">
+                                                        <property name="orientation">horizontal</property>
+                                                        <property name="spacing">4</property>
+                                                        <property name="halign">center</property>
+                                                        <property name="valign">center</property>
+                                                        <child>
+                                                          <object class="GtkImage" 
id="origin_packaging_image">
+                                                            <property name="pixel_size">16</property>
+                                                            <property 
name="icon_name">flatpak-symbolic</property>
+                                                            <property name="valign">center</property>
+                                                          </object>
+                                                        </child>
+                                                        <child>
+                                                          <object class="GtkLabel" 
id="origin_packaging_label">
+                                                            <property name="valign">center</property>
+                                                            <property name="max-width-chars">20</property>
+                                                            <property name="ellipsize">end</property>
+                                                            <attributes>
+                                                              <attribute name="weight" value="normal"/>
+                                                              <attribute name="scale" value="0.85"/>
+                                                            </attributes>
+                                                          </object>
+                                                        </child>
                                                       </object>
                                                     </child>
                                                   </object>
@@ -1000,20 +1055,6 @@
     </widgets>
   </object>
 
-  <object class="GtkBox" id="origin_box">
-    <property name="orientation">horizontal</property>
-    <property name="halign">fill</property>
-    <property name="spacing">9</property>
-    <child>
-      <object class="GtkMenuButton" id="origin_button">
-        <property name="can_focus">True</property>
-        <property name="sensitive">True</property>
-        <property name="always-show-arrow">True</property>
-        <property name="popover">origin_popover</property>
-      </object>
-    </child>
-  </object>
-
   <object class="GtkPopover" id="origin_popover">
     <property name="visible">False</property>
     <style>
diff --git a/src/gs-shell.c b/src/gs-shell.c
index cebbdfd88..165fc1fd6 100644
--- a/src/gs-shell.c
+++ b/src/gs-shell.c
@@ -71,7 +71,6 @@ struct _GsShell
        GsPluginLoader          *plugin_loader;
        GtkWidget               *header_start_widget;
        GtkWidget               *header_end_widget;
-       GtkWidget               *details_header_end_widget;
        GQueue                  *back_entry_stack;
        GPtrArray               *modal_dialogs;
        gchar                   *events_info_uri;
@@ -217,29 +216,6 @@ gs_shell_set_header_end_widget (GsShell *shell, GtkWidget *widget)
        }
 }
 
-static void
-gs_shell_set_details_header_end_widget (GsShell *shell, GtkWidget *widget)
-{
-       GtkWidget *old_widget;
-
-       old_widget = shell->details_header_end_widget;
-
-       if (shell->details_header_end_widget == widget)
-               return;
-
-       if (widget != NULL) {
-               g_object_ref (widget);
-               adw_header_bar_pack_end (ADW_HEADER_BAR (shell->details_header), widget);
-       }
-
-       shell->details_header_end_widget = widget;
-
-       if (old_widget != NULL) {
-               adw_header_bar_remove (ADW_HEADER_BAR (shell->details_header), old_widget);
-               g_object_unref (old_widget);
-       }
-}
-
 static void
 gs_shell_refresh_auto_updates_ui (GsShell *shell)
 {
@@ -551,9 +527,6 @@ stack_notify_visible_child_cb (GObject    *object,
        case GS_SHELL_MODE_SEARCH:
                gs_shell_set_header_end_widget (shell, widget);
                break;
-       case GS_SHELL_MODE_DETAILS:
-               gs_shell_set_details_header_end_widget (shell, widget);
-               break;
        default:
                g_assert (widget == NULL);
                break;


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