event-editor/reminders: Port to GTK4
This commit is contained in:
@@ -33,7 +33,7 @@ struct _GcalRemindersSection
|
||||
GtkBox parent;
|
||||
|
||||
GtkListBox *alarms_listbox;
|
||||
GtkPopover *alarms_popover;
|
||||
GtkWidget *alarms_popover;
|
||||
GtkListBoxRow *new_alarm_row;
|
||||
|
||||
GtkWidget *five_minutes_button;
|
||||
@@ -132,16 +132,19 @@ create_alarm (guint minutes)
|
||||
static void
|
||||
clear_alarms (GcalRemindersSection *self)
|
||||
{
|
||||
g_autoptr (GList) children = NULL;
|
||||
GList *l;
|
||||
GtkWidget *child;
|
||||
|
||||
g_ptr_array_set_size (self->alarms, 0);
|
||||
|
||||
children = gtk_container_get_children (GTK_CONTAINER (self->alarms_listbox));
|
||||
for (l = children; l != NULL; l = l->next)
|
||||
child = gtk_widget_get_first_child (GTK_WIDGET (self->alarms_listbox));
|
||||
while (child)
|
||||
{
|
||||
if (l->data != self->new_alarm_row)
|
||||
gtk_widget_destroy (l->data);
|
||||
GtkWidget *next = gtk_widget_get_next_sibling (child);
|
||||
|
||||
if (child != GTK_WIDGET (self->new_alarm_row))
|
||||
gtk_list_box_remove (self->alarms_listbox, child);
|
||||
|
||||
child = next;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -201,7 +204,7 @@ setup_alarms (GcalRemindersSection *self)
|
||||
|
||||
/* Add the row */
|
||||
row = create_alarm_row (self, alarm);
|
||||
gtk_container_add (GTK_CONTAINER (self->alarms_listbox), row);
|
||||
gtk_list_box_append (self->alarms_listbox, row);
|
||||
}
|
||||
|
||||
GCAL_EXIT;
|
||||
@@ -273,7 +276,7 @@ on_remove_alarm_cb (GcalAlarmRow *alarm_row,
|
||||
}
|
||||
}
|
||||
|
||||
gtk_container_remove (GTK_CONTAINER (self->alarms_listbox), GTK_WIDGET (alarm_row));
|
||||
gtk_list_box_remove (self->alarms_listbox, GTK_WIDGET (alarm_row));
|
||||
|
||||
GCAL_EXIT;
|
||||
}
|
||||
@@ -304,7 +307,7 @@ on_add_alarm_button_clicked_cb (GtkWidget *button,
|
||||
alarm = create_alarm (minutes);
|
||||
|
||||
row = create_alarm_row (self, alarm);
|
||||
gtk_container_add (GTK_CONTAINER (self->alarms_listbox), row);
|
||||
gtk_list_box_append (self->alarms_listbox, row);
|
||||
|
||||
g_ptr_array_add (self->alarms, alarm);
|
||||
|
||||
@@ -317,7 +320,7 @@ on_alarms_listbox_row_activated_cb (GtkListBox *alarms_listbox,
|
||||
GcalRemindersSection *self)
|
||||
{
|
||||
if (row == self->new_alarm_row)
|
||||
gtk_popover_popup (self->alarms_popover);
|
||||
gtk_popover_popup (GTK_POPOVER (self->alarms_popover));
|
||||
}
|
||||
|
||||
|
||||
@@ -370,6 +373,16 @@ gcal_event_editor_section_iface_init (GcalEventEditorSectionInterface *iface)
|
||||
* GObject overrides
|
||||
*/
|
||||
|
||||
static void
|
||||
gcal_reminders_section_dispose (GObject *object)
|
||||
{
|
||||
GcalRemindersSection *self = (GcalRemindersSection *)object;
|
||||
|
||||
g_clear_pointer (&self->alarms_popover, gtk_widget_unparent);
|
||||
|
||||
G_OBJECT_CLASS (gcal_reminders_section_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gcal_reminders_section_finalize (GObject *object)
|
||||
{
|
||||
@@ -427,6 +440,7 @@ gcal_reminders_section_class_init (GcalRemindersSectionClass *klass)
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
||||
|
||||
object_class->dispose = gcal_reminders_section_dispose;
|
||||
object_class->finalize = gcal_reminders_section_finalize;
|
||||
object_class->get_property = gcal_reminders_section_get_property;
|
||||
object_class->set_property = gcal_reminders_section_set_property;
|
||||
@@ -460,4 +474,5 @@ gcal_reminders_section_init (GcalRemindersSection *self)
|
||||
gtk_widget_init_template (GTK_WIDGET (self));
|
||||
|
||||
gtk_list_box_set_sort_func (self->alarms_listbox, sort_alarms_func, self, NULL);
|
||||
gtk_widget_set_parent (GTK_WIDGET (self->alarms_popover), GTK_WIDGET (self->new_alarm_row));
|
||||
}
|
||||
|
||||
@@ -1,30 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<template class="GcalRemindersSection" parent="GtkBox">
|
||||
<property name="can_focus">False</property>
|
||||
<property name="orientation">vertical</property>
|
||||
|
||||
<child>
|
||||
<object class="GtkListBox" id="alarms_listbox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="selection_mode">none</property>
|
||||
<signal name="row-activated" handler="on_alarms_listbox_row_activated_cb" object="GcalRemindersSection" swapped="no" />
|
||||
|
||||
<style>
|
||||
<class name="content" />
|
||||
<class name="boxed-list" />
|
||||
</style>
|
||||
|
||||
<child>
|
||||
<object class="GtkListBoxRow" id="new_alarm_row">
|
||||
<property name="visible">True</property>
|
||||
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="margin">12</property>
|
||||
<property name="hexpand">True</property>
|
||||
<property name="vexpand">True</property>
|
||||
<property name="margin-top">12</property>
|
||||
<property name="margin-bottom">12</property>
|
||||
<property name="margin-start">12</property>
|
||||
<property name="margin-end">12</property>
|
||||
<property name="label" translatable="yes">Add a Reminder…</property>
|
||||
</object>
|
||||
</child>
|
||||
@@ -37,92 +35,68 @@
|
||||
|
||||
</template>
|
||||
|
||||
<object class="GtkPopoverMenu" id="alarms_popover">
|
||||
<property name="can_focus">False</property>
|
||||
<object class="GtkPopover" id="alarms_popover">
|
||||
<property name="width_request">175</property>
|
||||
<property name="relative-to">new_alarm_row</property>
|
||||
<style>
|
||||
<class name="menu" />
|
||||
</style>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="border_width">12</property>
|
||||
<property name="margin-top">12</property>
|
||||
<property name="margin-bottom">12</property>
|
||||
<property name="margin-start">12</property>
|
||||
<property name="margin-end">12</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="GtkModelButton" id="five_minutes_button">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="text" translatable="yes">5 minutes</property>
|
||||
<signal name="clicked" handler="on_add_alarm_button_clicked_cb" object="GcalRemindersSection" swapped="no" />
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkModelButton" id="ten_minutes_button">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="text" translatable="yes">10 minutes</property>
|
||||
<signal name="clicked" handler="on_add_alarm_button_clicked_cb" object="GcalRemindersSection" swapped="no" />
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkModelButton" id="fifteen_minutes_button">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="text" translatable="yes">15 minutes</property>
|
||||
<signal name="clicked" handler="on_add_alarm_button_clicked_cb" object="GcalRemindersSection" swapped="no" />
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkModelButton" id="thirty_minutes_button">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="text" translatable="yes">30 minutes</property>
|
||||
<signal name="clicked" handler="on_add_alarm_button_clicked_cb" object="GcalRemindersSection" swapped="no" />
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkModelButton" id="one_hour_button">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="text" translatable="yes">1 hour</property>
|
||||
<signal name="clicked" handler="on_add_alarm_button_clicked_cb" object="GcalRemindersSection" swapped="no" />
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkModelButton" id="one_day_button">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="text" translatable="yes">1 day</property>
|
||||
<signal name="clicked" handler="on_add_alarm_button_clicked_cb" object="GcalRemindersSection" swapped="no" />
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkModelButton" id="two_days_button">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="text" translatable="yes">2 days</property>
|
||||
<signal name="clicked" handler="on_add_alarm_button_clicked_cb" object="GcalRemindersSection" swapped="no" />
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkModelButton" id="three_days_button">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="text" translatable="yes">3 days</property>
|
||||
<signal name="clicked" handler="on_add_alarm_button_clicked_cb" object="GcalRemindersSection" swapped="no" />
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkModelButton" id="one_week_button">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="text" translatable="yes">1 week</property>
|
||||
<signal name="clicked" handler="on_add_alarm_button_clicked_cb" object="GcalRemindersSection" swapped="no" />
|
||||
</object>
|
||||
|
||||
Reference in New Issue
Block a user