[gnome-calendar/gbsneto/gtk4: 1/34] event-editor/alarm-row: Port to GTK4




commit 822361e9acf4f0fb5a37f279fc2703935bf177d7
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Mon Jan 10 15:56:09 2022 -0300

    event-editor/alarm-row: Port to GTK4
    
    Subclass AdwActionRow.

 src/gui/event-editor/gcal-alarm-row.c  | 13 +++++-------
 src/gui/event-editor/gcal-alarm-row.h  |  4 ++--
 src/gui/event-editor/gcal-alarm-row.ui | 36 +++++++++-------------------------
 3 files changed, 16 insertions(+), 37 deletions(-)
---
diff --git a/src/gui/event-editor/gcal-alarm-row.c b/src/gui/event-editor/gcal-alarm-row.c
index 9de60bd4..a1a4e002 100644
--- a/src/gui/event-editor/gcal-alarm-row.c
+++ b/src/gui/event-editor/gcal-alarm-row.c
@@ -28,15 +28,14 @@
 
 struct _GcalAlarmRow
 {
-  HdyActionRow        parent;
+  AdwActionRow        parent;
 
   GtkToggleButton    *volume_button;
-  GtkImage           *volume_icon;
 
   ECalComponentAlarm *alarm;
 };
 
-G_DEFINE_TYPE (GcalAlarmRow, gcal_alarm_row, HDY_TYPE_ACTION_ROW)
+G_DEFINE_TYPE (GcalAlarmRow, gcal_alarm_row, ADW_TYPE_ACTION_ROW)
 
 enum
 {
@@ -214,7 +213,7 @@ setup_alarm (GcalAlarmRow *self)
   duration = e_cal_component_alarm_trigger_get_duration (trigger);
   formatted_duration = format_alarm_duration (duration);
 
-  hdy_preferences_row_set_title (HDY_PREFERENCES_ROW (self), formatted_duration);
+  adw_preferences_row_set_title (ADW_PREFERENCES_ROW (self), formatted_duration);
 
   action = e_cal_component_alarm_get_action (self->alarm);
   gtk_toggle_button_set_active (self->volume_button, action == E_CAL_COMPONENT_ALARM_AUDIO);
@@ -248,9 +247,8 @@ on_sound_toggle_changed_cb (GtkToggleButton *button,
   e_cal_component_alarm_set_action (self->alarm, action);
 
   /* Update the volume icon */
-  gtk_image_set_from_icon_name (self->volume_icon,
-                                has_sound ? "audio-volume-high-symbolic" : "audio-volume-muted-symbolic",
-                                GTK_ICON_SIZE_BUTTON);
+  gtk_button_set_icon_name (GTK_BUTTON (self->volume_button),
+                            has_sound ? "audio-volume-high-symbolic" : "audio-volume-muted-symbolic");
 
 }
 
@@ -338,7 +336,6 @@ gcal_alarm_row_class_init (GcalAlarmRowClass *klass)
   gtk_widget_class_set_template_from_resource (widget_class, 
"/org/gnome/calendar/ui/event-editor/gcal-alarm-row.ui");
 
   gtk_widget_class_bind_template_child (widget_class, GcalAlarmRow, volume_button);
-  gtk_widget_class_bind_template_child (widget_class, GcalAlarmRow, volume_icon);
 
   gtk_widget_class_bind_template_callback (widget_class, on_remove_button_clicked_cb);
   gtk_widget_class_bind_template_callback (widget_class, on_sound_toggle_changed_cb);
diff --git a/src/gui/event-editor/gcal-alarm-row.h b/src/gui/event-editor/gcal-alarm-row.h
index 8c10f07a..3ab03399 100644
--- a/src/gui/event-editor/gcal-alarm-row.h
+++ b/src/gui/event-editor/gcal-alarm-row.h
@@ -20,14 +20,14 @@
 
 #pragma once
 
-#include <handy.h>
+#include <adwaita.h>
 #include <libecal/libecal.h>
 
 G_BEGIN_DECLS
 
 #define GCAL_TYPE_ALARM_ROW (gcal_alarm_row_get_type())
 
-G_DECLARE_FINAL_TYPE (GcalAlarmRow, gcal_alarm_row, GCAL, ALARM_ROW, HdyActionRow)
+G_DECLARE_FINAL_TYPE (GcalAlarmRow, gcal_alarm_row, GCAL, ALARM_ROW, AdwActionRow)
 
 GtkWidget*           gcal_alarm_row_new                          (ECalComponentAlarm *alarm);
 
diff --git a/src/gui/event-editor/gcal-alarm-row.ui b/src/gui/event-editor/gcal-alarm-row.ui
index bca8af50..da0933c8 100644
--- a/src/gui/event-editor/gcal-alarm-row.ui
+++ b/src/gui/event-editor/gcal-alarm-row.ui
@@ -1,46 +1,28 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
-  <template class="GcalAlarmRow" parent="HdyActionRow">
-    <property name="visible">True</property>
-    <property name="can_focus">False</property>
+  <template class="GcalAlarmRow" parent="AdwActionRow">
     <child>
       <object class="GtkBox">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
         <property name="valign">center</property>
         <property name="spacing">6</property>
         <child>
           <object class="GtkToggleButton" id="volume_button">
-            <property name="visible">True</property>
-            <property name="can_focus">True</property>
-            <property name="relief">none</property>
-            <property name="receives_default">True</property>
+            <property name="icon-name">audio-volume-high-symbolic</property>
             <property name="tooltip-text" translatable="yes">Toggles the sound of the alarm</property>
             <signal name="notify::active" handler="on_sound_toggle_changed_cb" object="GcalAlarmRow" 
swapped="no" />
-            <child>
-              <object class="GtkImage" id="volume_icon">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="icon_name">audio-volume-high-symbolic</property>
-              </object>
-            </child>
+            <style>
+              <class name="flat" />
+            </style>
           </object>
         </child>
         <child>
           <object class="GtkButton" id="remove_button">
-            <property name="visible">True</property>
-            <property name="can_focus">True</property>
-            <property name="relief">none</property>
-            <property name="receives_default">True</property>
+            <property name="icon-name">edit-delete-symbolic</property>
             <property name="tooltip-text" translatable="yes">Remove the alarm</property>
             <signal name="clicked" handler="on_remove_button_clicked_cb" object="GcalAlarmRow" swapped="no" 
/>
-            <child>
-              <object class="GtkImage">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="icon_name">edit-delete-symbolic</property>
-              </object>
-            </child>
+            <style>
+              <class name="flat" />
+            </style>
           </object>
         </child>
       </object>


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