[gnome-calendar] time-selector: Put the spinbuttons in a box and force it to be LTR



commit 301beb25348458faa5e25fa6963559987aeb1f1e
Author: Yosef Or Boczko <yoseforb gmail com>
Date:   Tue Mar 15 21:46:36 2022 +0200

    time-selector: Put the spinbuttons in a box and force it to be LTR
    
    #558
    
    Signed-off-by: Yosef Or Boczko <yoseforb gmail com>

 src/gui/event-editor/gcal-time-selector.c  |  5 ++++
 src/gui/event-editor/gcal-time-selector.ui | 47 +++++++++++++++++-------------
 2 files changed, 31 insertions(+), 21 deletions(-)
---
diff --git a/src/gui/event-editor/gcal-time-selector.c b/src/gui/event-editor/gcal-time-selector.c
index f0c2b8ae..3a2e9cd5 100644
--- a/src/gui/event-editor/gcal-time-selector.c
+++ b/src/gui/event-editor/gcal-time-selector.c
@@ -30,6 +30,7 @@ struct _GcalTimeSelector
   GtkAdjustment *hour_adjustment;
   GtkAdjustment *minute_adjustment;
 
+  GtkWidget *time_box;
   GtkWidget *hour_spin;
   GtkWidget *minute_spin;
   GtkWidget *period_combo;
@@ -210,6 +211,7 @@ gcal_time_selector_class_init (GcalTimeSelectorClass *klass)
 
   gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), 
"/org/gnome/calendar/ui/event-editor/gcal-time-selector.ui");
 
+  gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (klass), GcalTimeSelector, time_box);
   gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (klass), GcalTimeSelector, hour_adjustment);
   gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (klass), GcalTimeSelector, hour_spin);
   gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (klass), GcalTimeSelector, minute_adjustment);
@@ -226,6 +228,9 @@ gcal_time_selector_init (GcalTimeSelector *self)
   self->time = g_date_time_new_now_local ();
 
   gtk_widget_init_template (GTK_WIDGET (self));
+
+  if (gtk_widget_get_direction (GTK_WIDGET (self)) == GTK_TEXT_DIR_RTL)
+    gtk_widget_set_direction (self->time_box, GTK_TEXT_DIR_LTR);
 }
 
 /* Public API */
diff --git a/src/gui/event-editor/gcal-time-selector.ui b/src/gui/event-editor/gcal-time-selector.ui
index 51b1d877..d3a32c29 100644
--- a/src/gui/event-editor/gcal-time-selector.ui
+++ b/src/gui/event-editor/gcal-time-selector.ui
@@ -3,33 +3,38 @@
   <template class="GcalTimeSelector" parent="GtkBox">
     <property name="spacing">6</property>
 
-    <!-- Hour -->
     <child>
-      <object class="GtkSpinButton" id="hour_spin">
-        <property name="xalign">0.5</property>
-        <property name="orientation">vertical</property>
-        <property name="adjustment">hour_adjustment</property>
-        <signal name="output" handler="on_output" object="GcalTimeSelector" swapped="no"/>
-      </object>
-    </child>
+      <object class="GtkBox" id="time_box">
+        <property name="spacing">6</property>
 
-    <child>
-      <object class="GtkLabel" id="label1">
-        <property name="label" translatable="yes">:</property>
-      </object>
-    </child>
+        <!-- Hour -->
+        <child>
+          <object class="GtkSpinButton" id="hour_spin">
+            <property name="xalign">0.5</property>
+            <property name="orientation">vertical</property>
+            <property name="adjustment">hour_adjustment</property>
+            <signal name="output" handler="on_output" object="GcalTimeSelector" swapped="no"/>
+          </object>
+        </child>
 
-    <!-- Minute -->
-    <child>
-      <object class="GtkSpinButton" id="minute_spin">
-        <property name="xalign">0.5</property>
-        <property name="orientation">vertical</property>
-        <property name="adjustment">minute_adjustment</property>
-        <signal name="output" handler="on_output" object="GcalTimeSelector" swapped="no"/>
+        <child>
+          <object class="GtkLabel" id="label1">
+            <property name="label" translatable="yes">:</property>
+          </object>
+        </child>
+
+        <!-- Minute -->
+        <child>
+          <object class="GtkSpinButton" id="minute_spin">
+            <property name="xalign">0.5</property>
+            <property name="orientation">vertical</property>
+            <property name="adjustment">minute_adjustment</property>
+            <signal name="output" handler="on_output" object="GcalTimeSelector" swapped="no"/>
+          </object>
+        </child>
       </object>
     </child>
 
-
     <!-- AM/PM -->
     <child>
       <object class="GtkComboBoxText" id="period_combo">


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