event-editor/alarm-row: Port to GTK4
Subclass AdwActionRow.
This commit is contained in:
@@ -28,15 +28,14 @@
|
|||||||
|
|
||||||
struct _GcalAlarmRow
|
struct _GcalAlarmRow
|
||||||
{
|
{
|
||||||
HdyActionRow parent;
|
AdwActionRow parent;
|
||||||
|
|
||||||
GtkToggleButton *volume_button;
|
GtkToggleButton *volume_button;
|
||||||
GtkImage *volume_icon;
|
|
||||||
|
|
||||||
ECalComponentAlarm *alarm;
|
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
|
enum
|
||||||
{
|
{
|
||||||
@@ -214,7 +213,7 @@ setup_alarm (GcalAlarmRow *self)
|
|||||||
duration = e_cal_component_alarm_trigger_get_duration (trigger);
|
duration = e_cal_component_alarm_trigger_get_duration (trigger);
|
||||||
formatted_duration = format_alarm_duration (duration);
|
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);
|
action = e_cal_component_alarm_get_action (self->alarm);
|
||||||
gtk_toggle_button_set_active (self->volume_button, action == E_CAL_COMPONENT_ALARM_AUDIO);
|
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);
|
e_cal_component_alarm_set_action (self->alarm, action);
|
||||||
|
|
||||||
/* Update the volume icon */
|
/* Update the volume icon */
|
||||||
gtk_image_set_from_icon_name (self->volume_icon,
|
gtk_button_set_icon_name (GTK_BUTTON (self->volume_button),
|
||||||
has_sound ? "audio-volume-high-symbolic" : "audio-volume-muted-symbolic",
|
has_sound ? "audio-volume-high-symbolic" : "audio-volume-muted-symbolic");
|
||||||
GTK_ICON_SIZE_BUTTON);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -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_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_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_remove_button_clicked_cb);
|
||||||
gtk_widget_class_bind_template_callback (widget_class, on_sound_toggle_changed_cb);
|
gtk_widget_class_bind_template_callback (widget_class, on_sound_toggle_changed_cb);
|
||||||
|
|||||||
@@ -20,14 +20,14 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <handy.h>
|
#include <adwaita.h>
|
||||||
#include <libecal/libecal.h>
|
#include <libecal/libecal.h>
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
#define GCAL_TYPE_ALARM_ROW (gcal_alarm_row_get_type())
|
#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);
|
GtkWidget* gcal_alarm_row_new (ECalComponentAlarm *alarm);
|
||||||
|
|
||||||
|
|||||||
@@ -1,46 +1,28 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<interface>
|
<interface>
|
||||||
<template class="GcalAlarmRow" parent="HdyActionRow">
|
<template class="GcalAlarmRow" parent="AdwActionRow">
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkBox">
|
<object class="GtkBox">
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
<property name="valign">center</property>
|
<property name="valign">center</property>
|
||||||
<property name="spacing">6</property>
|
<property name="spacing">6</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkToggleButton" id="volume_button">
|
<object class="GtkToggleButton" id="volume_button">
|
||||||
<property name="visible">True</property>
|
<property name="icon-name">audio-volume-high-symbolic</property>
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="relief">none</property>
|
|
||||||
<property name="receives_default">True</property>
|
|
||||||
<property name="tooltip-text" translatable="yes">Toggles the sound of the alarm</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" />
|
<signal name="notify::active" handler="on_sound_toggle_changed_cb" object="GcalAlarmRow" swapped="no" />
|
||||||
<child>
|
<style>
|
||||||
<object class="GtkImage" id="volume_icon">
|
<class name="flat" />
|
||||||
<property name="visible">True</property>
|
</style>
|
||||||
<property name="can_focus">False</property>
|
|
||||||
<property name="icon_name">audio-volume-high-symbolic</property>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkButton" id="remove_button">
|
<object class="GtkButton" id="remove_button">
|
||||||
<property name="visible">True</property>
|
<property name="icon-name">edit-delete-symbolic</property>
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="relief">none</property>
|
|
||||||
<property name="receives_default">True</property>
|
|
||||||
<property name="tooltip-text" translatable="yes">Remove the alarm</property>
|
<property name="tooltip-text" translatable="yes">Remove the alarm</property>
|
||||||
<signal name="clicked" handler="on_remove_button_clicked_cb" object="GcalAlarmRow" swapped="no" />
|
<signal name="clicked" handler="on_remove_button_clicked_cb" object="GcalAlarmRow" swapped="no" />
|
||||||
<child>
|
<style>
|
||||||
<object class="GtkImage">
|
<class name="flat" />
|
||||||
<property name="visible">True</property>
|
</style>
|
||||||
<property name="can_focus">False</property>
|
|
||||||
<property name="icon_name">edit-delete-symbolic</property>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
|
|||||||
Reference in New Issue
Block a user