[gnome-software: 57/110] Replace AdwDeck by AdwLeaflet




commit fe0b63b8b8330efb9da0999816a010ea70efd997
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Tue Aug 24 20:47:15 2021 -0300

    Replace AdwDeck by AdwLeaflet
    
    With 'can-unfold' set to FALSE, as per the migration guide.

 src/gs-shell.c          | 24 ++++++++++++------------
 src/gs-shell.ui         |  6 ++++--
 src/gs-update-dialog.c  | 30 +++++++++++++++---------------
 src/gs-update-dialog.ui |  7 ++++---
 4 files changed, 35 insertions(+), 32 deletions(-)
---
diff --git a/src/gs-shell.c b/src/gs-shell.c
index 5e1afc49b..7c4f0f750 100644
--- a/src/gs-shell.c
+++ b/src/gs-shell.c
@@ -72,8 +72,8 @@ struct _GsShell
        GQueue                  *back_entry_stack;
        GPtrArray               *modal_dialogs;
        gchar                   *events_info_uri;
-       AdwDeck                 *main_deck;
-       AdwDeck                 *details_deck;
+       AdwLeaflet              *main_leaflet;
+       AdwLeaflet              *details_leaflet;
        GtkStack                *stack_loading;
        GtkStack                *stack_main;
        GtkStack                *stack_sub;
@@ -597,15 +597,15 @@ gs_shell_change_mode (GsShell *shell,
 
        gtk_stack_set_visible_child_name (shell->stack_loading, "main");
        if (mode == GS_SHELL_MODE_DETAILS) {
-               adw_deck_set_visible_child_name (shell->details_deck, "details");
+               adw_leaflet_set_visible_child_name (shell->details_leaflet, "details");
        } else {
-               adw_deck_set_visible_child_name (shell->details_deck, "main");
-               /* We only change the main deck when not reaching the details
+               adw_leaflet_set_visible_child_name (shell->details_leaflet, "main");
+               /* We only change the main leaflet when not reaching the details
                 * page to preserve the navigation history in the UI's state.
-                * First change the page, then the deck, to avoid load of
+                * First change the page, then the leaflet, to avoid load of
                 * the previously shown page, which will be changed shortly after. */
                gtk_stack_set_visible_child_name (mode_is_main ? shell->stack_main : shell->stack_sub, 
page_name[mode]);
-               adw_deck_set_visible_child_name (shell->main_deck, mode_is_main ? "main" : "sub");
+               adw_leaflet_set_visible_child_name (shell->main_leaflet, mode_is_main ? "main" : "sub");
        }
 
        /* do any mode-specific actions */
@@ -648,7 +648,7 @@ overlay_get_child_position_cb (GtkOverlay   *overlay,
         * to position it below the header bar. The overlay can’t easily be
         * moved in the widget hierarchy so it doesn’t have the header bar as
         * a child, since there are several header bars in different pages of
-        * a AdwDeck. */
+        * a AdwLeaflet. */
        g_assert (gtk_widget_is_ancestor (self->main_header, GTK_WIDGET (overlay)));
 
        gtk_widget_get_preferred_size (widget, NULL, &overlay_natural_size);
@@ -2268,10 +2268,10 @@ gs_shell_get_mode (GsShell *shell)
        if (g_strcmp0 (gtk_stack_get_visible_child_name (shell->stack_loading), "loading") == 0)
                return GS_SHELL_MODE_LOADING;
 
-       if (g_strcmp0 (adw_deck_get_visible_child_name (shell->details_deck), "details") == 0)
+       if (g_strcmp0 (adw_leaflet_get_visible_child_name (shell->details_leaflet), "details") == 0)
                return GS_SHELL_MODE_DETAILS;
 
-       if (g_strcmp0 (adw_deck_get_visible_child_name (shell->main_deck), "main") == 0)
+       if (g_strcmp0 (adw_leaflet_get_visible_child_name (shell->main_leaflet), "main") == 0)
                name = gtk_stack_get_visible_child_name (shell->stack_main);
        else
                name = gtk_stack_get_visible_child_name (shell->stack_sub);
@@ -2561,9 +2561,9 @@ gs_shell_class_init (GsShellClass *klass)
        gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/Software/gs-shell.ui");
 
        gtk_widget_class_bind_template_child (widget_class, GsShell, main_header);
-       gtk_widget_class_bind_template_child (widget_class, GsShell, main_deck);
+       gtk_widget_class_bind_template_child (widget_class, GsShell, main_leaflet);
        gtk_widget_class_bind_template_child (widget_class, GsShell, details_header);
-       gtk_widget_class_bind_template_child (widget_class, GsShell, details_deck);
+       gtk_widget_class_bind_template_child (widget_class, GsShell, details_leaflet);
        gtk_widget_class_bind_template_child (widget_class, GsShell, stack_loading);
        gtk_widget_class_bind_template_child (widget_class, GsShell, stack_main);
        gtk_widget_class_bind_template_child (widget_class, GsShell, stack_sub);
diff --git a/src/gs-shell.ui b/src/gs-shell.ui
index 10d719ac7..716bb0aeb 100644
--- a/src/gs-shell.ui
+++ b/src/gs-shell.ui
@@ -154,12 +154,14 @@
               </object>
             </child>
             <child>
-              <object class="AdwDeck" id="details_deck">
+              <object class="AdwLeaflet" id="details_leaflet">
                 <property name="visible">True</property>
+                <property name="can-unfold">False</property>
                 <signal name="notify::visible-child" handler="stack_notify_visible_child_cb"/>
                 <child>
-                  <object class="AdwDeck" id="main_deck">
+                  <object class="AdwLeaflet" id="main_leaflet">
                     <property name="visible">True</property>
+                    <property name="can-unfold">False</property>
                     <signal name="notify::visible-child" handler="stack_notify_visible_child_cb"/>
                     <child>
                       <object class="GtkBox" id="main_box">
diff --git a/src/gs-update-dialog.c b/src/gs-update-dialog.c
index 71387e935..952bcc334 100644
--- a/src/gs-update-dialog.c
+++ b/src/gs-update-dialog.c
@@ -25,7 +25,7 @@ struct _GsUpdateDialog
        GCancellable    *cancellable;
        GsPluginLoader  *plugin_loader;
        GsApp           *app;
-       GtkWidget       *deck;
+       GtkWidget       *leaflet;
        GtkWidget       *list_box_installed_updates;
        GtkWidget       *spinner;
        GtkWidget       *stack;
@@ -45,15 +45,15 @@ static void gs_update_dialog_show_installed_updates (GsUpdateDialog *dialog);
 static void gs_update_dialog_show_update_details (GsUpdateDialog *dialog, GsApp *app);
 
 static void
-deck_child_transition_cb (AdwDeck *deck, GParamSpec *pspec, GsUpdateDialog *dialog)
+leaflet_child_transition_cb (AdwLeaflet *leaflet, GParamSpec *pspec, GsUpdateDialog *dialog)
 {
        GtkWidget *child;
 
-       if (adw_deck_get_transition_running (deck))
+       if (adw_leaflet_get_child_transition_running (leaflet))
                return;
 
-       while ((child = adw_deck_get_adjacent_child (deck, ADW_NAVIGATION_DIRECTION_FORWARD)))
-               adw_deck_remove (deck, child);
+       while ((child = adw_leaflet_get_adjacent_child (leaflet, ADW_NAVIGATION_DIRECTION_FORWARD)))
+               adw_leaflet_remove (leaflet, child);
 }
 
 static void
@@ -164,7 +164,7 @@ unset_focus (GtkWidget *widget)
 static void
 back_clicked_cb (GtkWidget *widget, GsUpdateDialog *dialog)
 {
-       adw_deck_navigate (ADW_DECK (dialog->deck), ADW_NAVIGATION_DIRECTION_BACK);
+       adw_leaflet_navigate (ADW_LEAFLET (dialog->leaflet), ADW_NAVIGATION_DIRECTION_BACK);
 }
 
 static void
@@ -205,8 +205,8 @@ gs_update_dialog_show_update_details (GsUpdateDialog *dialog, GsApp *app)
 
        gtk_widget_show (page);
 
-       adw_deck_add (ADW_DECK (dialog->deck), page);
-       adw_deck_set_visible_child (ADW_DECK (dialog->deck), page);
+       adw_leaflet_append (ADW_LEAFLET (dialog->leaflet), page);
+       adw_leaflet_set_visible_child (ADW_LEAFLET (dialog->leaflet), page);
 }
 
 static gboolean
@@ -221,7 +221,7 @@ key_pressed_cb (GtkEventControllerKey *key_controller,
        if ((!is_rtl && state == GDK_MOD1_MASK && keyval == GDK_KEY_Left) ||
            (is_rtl && state == GDK_MOD1_MASK && keyval == GDK_KEY_Right) ||
            keyval == GDK_KEY_Back) {
-               adw_deck_navigate (ADW_DECK (dialog->deck), ADW_NAVIGATION_DIRECTION_BACK);
+               adw_leaflet_navigate (ADW_LEAFLET (dialog->leaflet), ADW_NAVIGATION_DIRECTION_BACK);
                return GDK_EVENT_STOP;
        }
 
@@ -235,7 +235,7 @@ button_pressed_cb (GtkGestureClick *click_gesture,
                    gdouble          y,
                    GsUpdateDialog  *dialog)
 {
-       adw_deck_navigate (ADW_DECK (dialog->deck), ADW_NAVIGATION_DIRECTION_BACK);
+       adw_leaflet_navigate (ADW_LEAFLET (dialog->leaflet), ADW_NAVIGATION_DIRECTION_BACK);
        gtk_gesture_set_state (GTK_GESTURE (click_gesture), GTK_EVENT_SEQUENCE_CLAIMED);
 }
 
@@ -291,12 +291,12 @@ gs_update_dialog_constructed (GObject *object)
        if (dialog->app) {
                GtkWidget *child;
 
-               child = adw_deck_get_visible_child (ADW_DECK (dialog->deck));
-               adw_deck_remove (ADW_DECK (dialog->deck), child);
+               child = adw_leaflet_get_visible_child (ADW_LEAFLET (dialog->leaflet));
+               adw_leaflet_remove (ADW_LEAFLET (dialog->leaflet), child);
 
                gs_update_dialog_show_update_details (dialog, dialog->app);
 
-               child = adw_deck_get_visible_child (ADW_DECK (dialog->deck));
+               child = adw_leaflet_get_visible_child (ADW_LEAFLET (dialog->leaflet));
                /* It can be either the app details page or the OS update page */
                if (GS_IS_APP_DETAILS_PAGE (child))
                        gs_app_details_page_set_show_back_button (GS_APP_DETAILS_PAGE (child), FALSE);
@@ -375,13 +375,13 @@ gs_update_dialog_class_init (GsUpdateDialogClass *klass)
 
        gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/Software/gs-update-dialog.ui");
 
-       gtk_widget_class_bind_template_child (widget_class, GsUpdateDialog, deck);
+       gtk_widget_class_bind_template_child (widget_class, GsUpdateDialog, leaflet);
        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, leaflet_child_transition_cb);
        gtk_widget_class_bind_template_callback (widget_class, key_pressed_cb);
 
        gtk_widget_class_add_binding_action (widget_class, GDK_KEY_Escape, 0, "window.close", NULL);
diff --git a/src/gs-update-dialog.ui b/src/gs-update-dialog.ui
index 6b9dce640..b68447cf7 100644
--- a/src/gs-update-dialog.ui
+++ b/src/gs-update-dialog.ui
@@ -26,13 +26,14 @@
     </child>
 
     <child>
-      <object class="AdwDeck" id="deck">
+      <object class="AdwLeaflet" id="leaflet">
         <property name="visible">True</property>
         <property name="can_swipe_back">True</property>
+        <property name="can-unfold">False</property>
         <!-- We need both signals to support the animations being disabled, as
              notify::transition-running isn't emitted in that case. -->
-        <signal name="notify::visible-child" handler="deck_child_transition_cb" swapped="no"/>
-        <signal name="notify::transition-running" handler="deck_child_transition_cb" swapped="no"/>
+        <signal name="notify::visible-child" handler="leaflet_child_transition_cb" swapped="no"/>
+        <signal name="notify::transition-running" handler="leaflet_child_transition_cb" swapped="no"/>
         <child>
           <object class="GtkBox">
             <property name="visible">True</property>


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