[ghex] appwin: Animate opening and closing of conversions pane



commit 9823a82bf6c48ca570a67a4603b9b68f0c18246c
Author: Logan Rathbone <poprocks gmail com>
Date:   Thu Apr 21 22:01:30 2022 -0400

    appwin: Animate opening and closing of conversions pane

 src/ghex-application-window.c     | 22 +++++++++++++++-------
 src/ghex-application-window.ui.in | 10 +++++++---
 2 files changed, 22 insertions(+), 10 deletions(-)
---
diff --git a/src/ghex-application-window.c b/src/ghex-application-window.c
index eb8351d..071d8dd 100644
--- a/src/ghex-application-window.c
+++ b/src/ghex-application-window.c
@@ -78,6 +78,7 @@ struct _GHexApplicationWindow
        GtkWidget *insert_mode_button;
        GtkWidget *statusbar;
        GtkWidget *pane_revealer;
+       GtkWidget *conversions_revealer;
 };
 
 /* GHexApplicationWindow - Globals for Properties and Signals */
@@ -1288,15 +1289,21 @@ toggle_conversions (GtkWidget *widget,
                GVariant *parameter)
 {
        GHexApplicationWindow *self = GHEX_APPLICATION_WINDOW(widget);
+       GtkRevealer *revealer = GTK_REVEALER (self->conversions_revealer);
 
-       (void)parameter, (void)action_name;             /* unused */
-
-       if (gtk_widget_is_visible (self->conversions_box)) {
-               gtk_widget_set_visible (self->conversions_box, FALSE);
+       if (gtk_revealer_get_reveal_child (revealer))
+       {
+               gtk_revealer_set_transition_type (revealer,
+                               GTK_REVEALER_TRANSITION_TYPE_SLIDE_DOWN);
+               gtk_revealer_set_reveal_child (revealer, FALSE);
                gtk_button_set_icon_name (GTK_BUTTON(self->pane_toggle_button),
                                "pan-up-symbolic");
-       } else {
-               gtk_widget_set_visible (self->conversions_box, TRUE);
+       }
+       else
+       {
+               gtk_revealer_set_transition_type (revealer,
+                               GTK_REVEALER_TRANSITION_TYPE_SLIDE_UP);
+               gtk_revealer_set_reveal_child (revealer, TRUE);
                gtk_button_set_icon_name (GTK_BUTTON(self->pane_toggle_button),
                                "pan-down-symbolic");
        }
@@ -1605,7 +1612,6 @@ ghex_application_window_init (GHexApplicationWindow *self)
        self->dialog_widget = hex_dialog_getview (self->dialog);
 
        gtk_box_append (GTK_BOX(self->conversions_box), self->dialog_widget);
-       gtk_widget_hide (self->conversions_box);
 
        /* CSS - conversions_box */
 
@@ -1993,6 +1999,8 @@ ghex_application_window_class_init(GHexApplicationWindowClass *klass)
                        statusbar);
        gtk_widget_class_bind_template_child (widget_class, GHexApplicationWindow,
                        pane_revealer);
+       gtk_widget_class_bind_template_child (widget_class, GHexApplicationWindow,
+                       conversions_revealer);
 }
 
 GtkWidget *
diff --git a/src/ghex-application-window.ui.in b/src/ghex-application-window.ui.in
index 0c46c44..8d098dc 100644
--- a/src/ghex-application-window.ui.in
+++ b/src/ghex-application-window.ui.in
@@ -270,11 +270,15 @@
                                        </object>
                                </child>
 
-                               <child> <!-- box just to put the conversions_pane; APPEND -->
-                                       <object class="GtkBox" id="conversions_box" />
+                               <child>
+                                       <object class="GtkRevealer" id="conversions_revealer">
+                                               <property name="transition-type">slide-up</property>
+                                               <child> <!-- box just to put the conversions_pane; APPEND -->
+                                                       <object class="GtkBox" id="conversions_box" />
+                                               </child>
+                                       </object>
                                </child>
 
-
                                <child> <!-- status_box -->
                                        <object class="GtkBox" id="status_box">
                                                <property name="orientation">horizontal</property>


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