[gnome-clocks/bilelmoussaoui/redesign: 10/10] Timer Row fixes



commit 704451560ff9c10d699774ef15bc0c48b268c262
Author: Bilal Elmoussaoui <bil elmoussaoui gmail com>
Date:   Fri Sep 20 21:12:47 2019 +0200

    Timer Row fixes

 data/ui/timerrow.ui |  6 ++----
 src/timer.vala      | 20 ++++++++++++++++++++
 src/widgets.vala    | 14 +++++++++++---
 3 files changed, 33 insertions(+), 7 deletions(-)
---
diff --git a/data/ui/timerrow.ui b/data/ui/timerrow.ui
index da719f3..d7d8780 100644
--- a/data/ui/timerrow.ui
+++ b/data/ui/timerrow.ui
@@ -22,7 +22,7 @@
     <property name="can_focus">False</property>
     <property name="valign">start</property>
     <child>
-      <object class="GtkBox">
+      <object class="GtkBox" id="timer_box">
         <property name="visible">True</property>
         <property name="can_focus">False</property>
         <property name="orientation">vertical</property>
@@ -366,12 +366,11 @@
       <packing>
         <property name="expand">False</property>
         <property name="fill">True</property>
-        <property name="padding">24</property>
         <property name="position">0</property>
       </packing>
     </child>
     <child>
-      <object class="GtkBox">
+      <object class="GtkBox" id="actions_box">
         <property name="visible">True</property>
         <property name="can_focus">False</property>
         <property name="orientation">vertical</property>
@@ -490,7 +489,6 @@
       <packing>
         <property name="expand">False</property>
         <property name="fill">True</property>
-        <property name="padding">18</property>
         <property name="pack_type">end</property>
         <property name="position">1</property>
       </packing>
diff --git a/src/timer.vala b/src/timer.vala
index 4aa9954..431f3fa 100644
--- a/src/timer.vala
+++ b/src/timer.vala
@@ -125,6 +125,11 @@ public class Row : Gtk.Box {
     [GtkChild]
     private Gtk.Box countdown_frame;
     [GtkChild]
+    private Gtk.Box actions_box;
+
+    [GtkChild]
+    private Gtk.Box timer_box;
+    [GtkChild]
     private Gtk.Stack timer_stack;
     [GtkChild]
     private Gtk.Stack start_stack;
@@ -150,6 +155,21 @@ public class Row : Gtk.Box {
                 timeout_id = 0;
             }
         });
+        this.size_allocate.connect((widget, allocation) => {
+            if (allocation.width > 550) {
+                this.set_orientation(Gtk.Orientation.HORIZONTAL);
+                this.margin = 24;
+                actions_box.set_orientation(Gtk.Orientation.VERTICAL);
+                actions_box.margin = 24;
+                timer_box.margin = 24;
+            } else {
+                this.margin = 0;
+                timer_box.margin = 12;
+                actions_box.margin = 6;
+                this.set_orientation(Gtk.Orientation.VERTICAL);
+                actions_box.set_orientation(Gtk.Orientation.HORIZONTAL);
+            }
+        });
 
         // Force LTR since we do not want to reverse [hh] : [mm] : [ss]
         grid_spinbuttons.set_direction (Gtk.TextDirection.LTR);
diff --git a/src/widgets.vala b/src/widgets.vala
index dde0cfb..1e2ffc8 100644
--- a/src/widgets.vala
+++ b/src/widgets.vala
@@ -308,9 +308,16 @@ public class ContentView : Gtk.Bin {
         list_box.halign = Gtk.Align.FILL;
         list_box.valign = Gtk.Align.START;
         list_box.selection_mode = Gtk.SelectionMode.NONE;
-        list_box.margin = 24;
         list_box.get_style_context ().add_class ("frame");
         list_box.set_header_func(list_header_func);
+
+        list_box.size_allocate.connect((widget, allocation) => {
+            if (allocation.width < 550) {
+                widget.margin = 0;
+            } else {
+                widget.margin = 24;
+            }
+        });
         /*
         list_box.child_activated.connect ((child) => {
             var item = model.get_item (child.get_index ()) as ContentItem;
@@ -323,8 +330,8 @@ public class ContentView : Gtk.Bin {
         var scrolled_window = new Gtk.ScrolledWindow (null, null);
 
         var column = new Hdy.Column();
-        column.set_maximum_width(800);
-        column.set_linear_growth_width(800);
+        column.set_maximum_width(1200);
+        column.set_linear_growth_width(1200);
 
         column.add (list_box);
 
@@ -452,6 +459,7 @@ public class ContentView : Gtk.Bin {
 
             list_box_row.show_all ();
 
+            list_box_row.queue_allocate ();
             return list_box_row;
         });
     }


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