[gnome-builder/wip/chergert/debugger: 39/58] debugger: animate in debugger controls



commit 5d1616c8e87697aed9af1f02b8b590d090d0da7f
Author: Christian Hergert <chergert redhat com>
Date:   Sat Mar 25 00:42:34 2017 -0700

    debugger: animate in debugger controls
    
    This animates in the controls but deals with the behavior of having to
    show the widget before or hide the widget after the animation.

 libide/debugger/ide-debugger-controls.c        |    2 +-
 libide/debugger/ide-debugger-controls.h        |    2 +-
 libide/debugger/ide-debugger-controls.ui       |    2 +-
 libide/debugger/ide-debugger-workbench-addin.c |   52 +++++++++++++++++++++++-
 4 files changed, 54 insertions(+), 4 deletions(-)
---
diff --git a/libide/debugger/ide-debugger-controls.c b/libide/debugger/ide-debugger-controls.c
index a2be212..71295b0 100644
--- a/libide/debugger/ide-debugger-controls.c
+++ b/libide/debugger/ide-debugger-controls.c
@@ -23,7 +23,7 @@ struct _IdeDebuggerControls
   GtkBin parent_instance;
 };
 
-G_DEFINE_TYPE (IdeDebuggerControls, ide_debugger_controls, GTK_TYPE_BIN)
+G_DEFINE_TYPE (IdeDebuggerControls, ide_debugger_controls, GTK_TYPE_REVEALER)
 
 static void
 ide_debugger_controls_class_init (IdeDebuggerControlsClass *klass)
diff --git a/libide/debugger/ide-debugger-controls.h b/libide/debugger/ide-debugger-controls.h
index 0b4d4c1..9abdd07 100644
--- a/libide/debugger/ide-debugger-controls.h
+++ b/libide/debugger/ide-debugger-controls.h
@@ -27,7 +27,7 @@ G_BEGIN_DECLS
 
 #define IDE_TYPE_DEBUGGER_CONTROLS (ide_debugger_controls_get_type())
 
-G_DECLARE_FINAL_TYPE (IdeDebuggerControls, ide_debugger_controls, IDE, DEBUGGER_CONTROLS, GtkBin)
+G_DECLARE_FINAL_TYPE (IdeDebuggerControls, ide_debugger_controls, IDE, DEBUGGER_CONTROLS, GtkRevealer)
 
 IdeDebugger *ide_debugger_controls_get_debugger (IdeDebuggerControls *self);
 void         ide_debugger_controls_set_debugger (IdeDebuggerControls *self,
diff --git a/libide/debugger/ide-debugger-controls.ui b/libide/debugger/ide-debugger-controls.ui
index 558168e..c70abc8 100644
--- a/libide/debugger/ide-debugger-controls.ui
+++ b/libide/debugger/ide-debugger-controls.ui
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
-  <template class="IdeDebuggerControls" parent="GtkBin">
+  <template class="IdeDebuggerControls" parent="GtkRevealer">
     <child>
       <object class="GtkBox">
         <property name="orientation">horizontal</property>
diff --git a/libide/debugger/ide-debugger-workbench-addin.c b/libide/debugger/ide-debugger-workbench-addin.c
index 25cb184..ad5a94c 100644
--- a/libide/debugger/ide-debugger-workbench-addin.c
+++ b/libide/debugger/ide-debugger-workbench-addin.c
@@ -70,6 +70,43 @@ debugger_run_handler (IdeRunManager *run_manager,
 }
 
 static void
+debug_manager_notify_active (IdeDebuggerWorkbenchAddin *self,
+                             GParamSpec                *pspec,
+                             IdeDebugManager           *debug_manager)
+{
+  g_assert (IDE_IS_DEBUGGER_WORKBENCH_ADDIN (self));
+  g_assert (IDE_IS_DEBUG_MANAGER (debug_manager));
+
+  /*
+   * Instead of using a property binding, we use this signal callback so
+   * that we can adjust the reveal-child and visible. Otherwise the widgets
+   * will take up space+padding when reveal-child is FALSE.
+   */
+
+  if (ide_debug_manager_get_active (debug_manager))
+    {
+      gtk_widget_show (GTK_WIDGET (self->controls));
+      gtk_revealer_set_reveal_child (GTK_REVEALER (self->controls), TRUE);
+    }
+  else
+    {
+      gtk_revealer_set_reveal_child (GTK_REVEALER (self->controls), FALSE);
+    }
+}
+
+static void
+controls_notify_child_revealed (IdeDebuggerWorkbenchAddin *self,
+                                GParamSpec                *pspec,
+                                IdeDebuggerControls       *controls)
+{
+  g_assert (IDE_IS_DEBUGGER_WORKBENCH_ADDIN (self));
+  g_assert (IDE_IS_DEBUGGER_CONTROLS (controls));
+
+  if (!gtk_revealer_get_child_revealed (GTK_REVEALER (controls)))
+    gtk_widget_hide (GTK_WIDGET (controls));
+}
+
+static void
 ide_debugger_workbench_addin_load (IdeWorkbenchAddin *addin,
                                    IdeWorkbench      *workbench)
 {
@@ -95,8 +132,21 @@ ide_debugger_workbench_addin_load (IdeWorkbenchAddin *addin,
   headerbar = ide_workbench_get_headerbar (workbench);
 
   self->controls = g_object_new (IDE_TYPE_DEBUGGER_CONTROLS,
-                                 "visible", TRUE,
+                                 "transition-duration", 500,
+                                 "transition-type", GTK_REVEALER_TRANSITION_TYPE_SLIDE_RIGHT,
+                                 "reveal-child", FALSE,
+                                 "visible", FALSE,
                                  NULL);
+  g_signal_connect_object (debug_manager,
+                           "notify::active",
+                           G_CALLBACK (debug_manager_notify_active),
+                           self,
+                           G_CONNECT_SWAPPED);
+  g_signal_connect_object (self->controls,
+                           "notify::child-revealed",
+                           G_CALLBACK (controls_notify_child_revealed),
+                           self,
+                           G_CONNECT_SWAPPED);
   ide_workbench_header_bar_insert_left (headerbar,
                                         GTK_WIDGET (self->controls),
                                         GTK_PACK_START,


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