[libshumate/tintou/toggle-button-attributions] license: Use a toggle button to increase the visible surface by default




commit ad9b4896a2dfe13931a28850781aff52b0f95fe7
Author: Corentin Noël <tintou noel tf>
Date:   Wed May 11 23:06:03 2022 +0200

    license: Use a toggle button to increase the visible surface by default
    
    Allows to have a less busy screen by default.

 shumate/shumate-license.c | 32 +++++++++++++++++++++++++-------
 1 file changed, 25 insertions(+), 7 deletions(-)
---
diff --git a/shumate/shumate-license.c b/shumate/shumate-license.c
index e84b1b9..a517f09 100644
--- a/shumate/shumate-license.c
+++ b/shumate/shumate-license.c
@@ -23,6 +23,8 @@
  * A widget that displays license text.
  */
 
+#include <glib/gi18n.h>
+
 #include "shumate-license.h"
 
 enum
@@ -38,8 +40,11 @@ struct _ShumateLicense
 {
   GtkWidget parent_instance;
 
+  GtkWidget *revealer;
+  GtkWidget *revealer_box;
   GtkWidget *extra_text_label;
   GtkWidget *license_label;
+  GtkWidget *info_toggle_button;
   GPtrArray *map_sources;
 };
 
@@ -124,8 +129,8 @@ shumate_license_dispose (GObject *object)
   ShumateLicense *self = SHUMATE_LICENSE (object);
 
   g_clear_pointer (&self->map_sources, g_ptr_array_unref);
-  g_clear_pointer (&self->extra_text_label, gtk_widget_unparent);
-  g_clear_pointer (&self->license_label, gtk_widget_unparent);
+  g_clear_pointer (&self->revealer, gtk_widget_unparent);
+  g_clear_pointer (&self->info_toggle_button, gtk_widget_unparent);
 
   G_OBJECT_CLASS (shumate_license_parent_class)->dispose (object);
 }
@@ -191,9 +196,6 @@ shumate_license_init (ShumateLicense *self)
   self->license_label = gtk_label_new (NULL);
   self->extra_text_label = gtk_label_new (NULL);
 
-  g_object_set (gtk_widget_get_layout_manager (GTK_WIDGET (self)),
-                "orientation", GTK_ORIENTATION_VERTICAL,
-                NULL);
   g_object_set (self->license_label,
                 "wrap",   TRUE,
                 "xalign", 1.0f,
@@ -204,8 +206,24 @@ shumate_license_init (ShumateLicense *self)
                 "xalign", 1.0f,
                 NULL);
 
-  gtk_widget_insert_after (self->license_label, GTK_WIDGET (self), NULL);
-  gtk_widget_insert_after (self->extra_text_label, GTK_WIDGET (self), self->license_label);
+  self->revealer = gtk_revealer_new ();
+  gtk_widget_set_valign (self->revealer, GTK_ALIGN_CENTER);
+  gtk_revealer_set_transition_type (GTK_REVEALER (self->revealer), GTK_REVEALER_TRANSITION_TYPE_SLIDE_LEFT);
+  gtk_widget_insert_after (self->revealer, GTK_WIDGET (self), NULL);
+  self->info_toggle_button = gtk_toggle_button_new ();
+  gtk_widget_set_tooltip_text (self->info_toggle_button, _("Attributions"));
+  gtk_widget_set_valign (self->info_toggle_button, GTK_ALIGN_CENTER);
+  gtk_button_set_icon_name (GTK_BUTTON(self->info_toggle_button), "help-info-symbolic");
+  gtk_widget_insert_after (self->info_toggle_button, GTK_WIDGET (self), self->revealer);
+
+  self->revealer_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
+  gtk_widget_set_margin_end (self->revealer_box, 6);
+  gtk_revealer_set_child (GTK_REVEALER (self->revealer), self->revealer_box);
+
+  gtk_box_append (GTK_BOX(self->revealer_box), self->license_label);
+  gtk_box_append (GTK_BOX(self->revealer_box), self->extra_text_label);
+
+  g_object_bind_property (self->info_toggle_button, "active", self->revealer, "reveal-child", 
G_BINDING_BIDIRECTIONAL|G_BINDING_SYNC_CREATE);
 }
 
 


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