[gnome-calendar/gbsneto/gtk4: 24/37] quick-add-popover: Port to GTK4
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calendar/gbsneto/gtk4: 24/37] quick-add-popover: Port to GTK4
- Date: Wed, 26 Jan 2022 16:31:54 +0000 (UTC)
commit ffd29465e36abb64d54000d535c830fe259a1e6b
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Fri Jan 14 12:25:52 2022 -0300
quick-add-popover: Port to GTK4
src/gui/gcal-quick-add-popover.c | 49 +++---
src/gui/gcal-quick-add-popover.ui | 326 +++++++++++++++-----------------------
2 files changed, 144 insertions(+), 231 deletions(-)
---
diff --git a/src/gui/gcal-quick-add-popover.c b/src/gui/gcal-quick-add-popover.c
index b6138834..42ae69c2 100644
--- a/src/gui/gcal-quick-add-popover.c
+++ b/src/gui/gcal-quick-add-popover.c
@@ -88,7 +88,7 @@ create_calendar_row (GcalManager *manager,
paintable = get_circle_paintable_from_color (color, 16);
icon = gtk_image_new_from_paintable (paintable);
- gtk_container_add (GTK_CONTAINER (box), icon);
+ gtk_box_append (GTK_BOX (box), icon);
gtk_style_context_add_class (gtk_widget_get_style_context (icon), "calendar-color-image");
@@ -96,11 +96,12 @@ create_calendar_row (GcalManager *manager,
label = gtk_label_new (gcal_calendar_get_name (calendar));
gtk_widget_set_margin_end (label, 12);
- gtk_container_add (GTK_CONTAINER (box), label);
+ gtk_box_append (GTK_BOX (box), label);
/* Selected icon */
- selected_icon = gtk_image_new_from_icon_name ("emblem-ok-symbolic", GTK_ICON_SIZE_BUTTON);
- gtk_container_add (GTK_CONTAINER (box), selected_icon);
+ selected_icon = gtk_image_new_from_icon_name ("emblem-ok-symbolic");
+ gtk_widget_hide (selected_icon);
+ gtk_box_append (GTK_BOX (box), selected_icon);
/* The row itself */
row = gtk_list_box_row_new ();
@@ -108,7 +109,7 @@ create_calendar_row (GcalManager *manager,
read_only = gcal_calendar_is_read_only (calendar);
gtk_widget_set_sensitive (row, !read_only);
- gtk_container_add (GTK_CONTAINER (row), box);
+ gtk_list_box_row_set_child (GTK_LIST_BOX_ROW (row), box);
/* Setup also a cool tooltip */
get_source_parent_name_color (manager, gcal_calendar_get_source (calendar), &parent_name, NULL);
@@ -130,11 +131,6 @@ create_calendar_row (GcalManager *manager,
g_object_set_data (G_OBJECT (row), "color-icon", icon);
g_object_set_data (G_OBJECT (row), "name-label", label);
- gtk_widget_show (label);
- gtk_widget_show (icon);
- gtk_widget_show (box);
- gtk_widget_show (row);
-
g_free (parent_name);
g_free (tooltip);
@@ -149,26 +145,19 @@ static GtkWidget*
get_row_for_calendar (GcalQuickAddPopover *self,
GcalCalendar *calendar)
{
- GList *children, *l;
GtkWidget *row;
- row = NULL;
- children = gtk_container_get_children (GTK_CONTAINER (self->calendars_listbox));
-
- for (l = children; l != NULL; l = g_list_next (l))
+ for (row = gtk_widget_get_first_child (self->calendars_listbox);
+ row;
+ row = gtk_widget_get_next_sibling (row))
{
- GcalCalendar *row_calendar = g_object_get_data (l->data, "calendar");
+ GcalCalendar *row_calendar = g_object_get_data (G_OBJECT (row), "calendar");
if (row_calendar == calendar)
- {
- row = l->data;
- break;
- }
+ return row;
}
- g_list_free (children);
-
- return row;
+ return NULL;
}
static void
@@ -521,9 +510,9 @@ on_calendar_added (GcalManager *manager,
default_calendar = gcal_manager_get_default_calendar (manager);
row = create_calendar_row (manager, calendar);
- gtk_container_add (GTK_CONTAINER (self->calendars_listbox), row);
+ gtk_list_box_append (GTK_LIST_BOX (self->calendars_listbox), row);
- /* Select the default source whe first adding events */
+ /* Select the default source when first adding events */
if (calendar == default_calendar && !self->selected_row)
select_row (self, GTK_LIST_BOX_ROW (row));
}
@@ -545,7 +534,7 @@ on_calendar_changed (GcalManager *manager,
if (read_only)
{
if (row)
- gtk_container_remove (GTK_CONTAINER (self->calendars_listbox), row);
+ gtk_list_box_remove (GTK_LIST_BOX (self->calendars_listbox), row);
return;
}
@@ -592,7 +581,7 @@ on_calendar_removed (GcalManager *manager,
if (!row)
return;
- gtk_container_remove (GTK_CONTAINER (self->calendars_listbox), row);
+ gtk_list_box_remove (GTK_LIST_BOX (self->calendars_listbox), row);
}
/* Sort the calendars by their display name */
@@ -682,7 +671,7 @@ edit_or_create_event (GcalQuickAddPopover *self,
/* Gather the summary */
if (gtk_entry_get_text_length (GTK_ENTRY (self->summary_entry)) > 0)
- summary = gtk_entry_get_text (GTK_ENTRY (self->summary_entry));
+ summary = gtk_editable_get_text (GTK_EDITABLE (self->summary_entry));
else
summary = _("Unnamed event");
@@ -825,7 +814,7 @@ gcal_quick_add_popover_closed (GtkPopover *popover)
self = GCAL_QUICK_ADD_POPOVER (popover);
/* Clear text */
- gtk_entry_set_text (GTK_ENTRY (self->summary_entry), "");
+ gtk_editable_set_text (GTK_EDITABLE (self->summary_entry), "");
/* Select the default row again */
update_default_calendar_row (self);
@@ -852,7 +841,7 @@ gcal_quick_add_popover_class_init (GcalQuickAddPopoverClass *klass)
* @self: a #GcalQuickAddPopover
* @event: the new #GcalEvent
*
- * Emited when the user clicks 'Edit event' button.
+ * Emitted when the user clicks 'Edit event' button.
*/
signals[EDIT_EVENT] = g_signal_new ("edit-event",
GCAL_TYPE_QUICK_ADD_POPOVER,
diff --git a/src/gui/gcal-quick-add-popover.ui b/src/gui/gcal-quick-add-popover.ui
index ff381bc9..9581e833 100644
--- a/src/gui/gcal-quick-add-popover.ui
+++ b/src/gui/gcal-quick-add-popover.ui
@@ -3,242 +3,166 @@
<requires lib="gtk+" version="3.16"/>
<template class="GcalQuickAddPopover" parent="GtkPopover">
<property name="width_request">350</property>
- <property name="can_focus">False</property>
<signal name="show" handler="gtk_widget_grab_focus" object="summary_entry" swapped="yes" />
<child>
<object class="GtkStack" id="stack">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="vexpand">True</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="hhomogeneous">False</property>
<property name="vhomogeneous">True</property>
<property name="transition_type">slide-left-right</property>
<property name="interpolate_size">True</property>
<child>
- <object class="GtkGrid">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="row_spacing">12</property>
- <property name="column_spacing">12</property>
- <child>
- <object class="GtkLabel" id="title_label">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="hexpand">True</property>
- <attributes>
- <attribute name="weight" value="bold"/>
- </attributes>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">0</property>
- <property name="width">3</property>
- </packing>
- </child>
- <child>
- <object class="GtkEntry" id="summary_entry">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="hexpand">True</property>
- <signal name="notify::text" handler="summary_entry_text_changed"
object="GcalQuickAddPopover" swapped="no" />
- <signal name="activate" handler="summary_entry_activated" object="GcalQuickAddPopover"
swapped="no" />
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">1</property>
- <property name="width">3</property>
- </packing>
- </child>
- <child>
- <object class="GtkButton" id="select_calendar_button">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="hexpand">True</property>
- <signal name="clicked" handler="select_calendar_button_clicked" object="GcalQuickAddPopover"
swapped="yes" />
+ <object class="GtkStackPage">
+ <property name="name">events</property>
+ <property name="child">
+ <object class="GtkGrid">
+ <property name="row_spacing">12</property>
+ <property name="column_spacing">12</property>
<child>
- <object class="GtkBox">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="spacing">12</property>
- <child>
- <object class="GtkImage" id="color_image">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="stock">gtk-missing-image</property>
- <style>
- <class name="calendar-color-image"/>
- </style>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="calendar_name_label">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="hexpand">True</property>
- <property name="xalign">0</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
+ <object class="GtkLabel" id="title_label">
+ <property name="hexpand">True</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ </attributes>
+ <layout>
+ <property name="column">0</property>
+ <property name="row">0</property>
+ <property name="column-span">3</property>
+ </layout>
+ </object>
+ </child>
+ <child>
+ <object class="GtkEntry" id="summary_entry">
+ <property name="hexpand">True</property>
+ <signal name="notify::text" handler="summary_entry_text_changed"
object="GcalQuickAddPopover" swapped="no" />
+ <signal name="activate" handler="summary_entry_activated" object="GcalQuickAddPopover"
swapped="no" />
+ <layout>
+ <property name="column">0</property>
+ <property name="row">1</property>
+ <property name="column-span">3</property>
+ </layout>
+ </object>
+ </child>
+ <child>
+ <object class="GtkButton" id="select_calendar_button">
+ <property name="hexpand">True</property>
+ <signal name="clicked" handler="select_calendar_button_clicked"
object="GcalQuickAddPopover" swapped="yes" />
+ <layout>
+ <property name="column">0</property>
+ <property name="row">2</property>
+ <property name="column-span">3</property>
+ </layout>
<child>
- <object class="GtkImage">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="icon_name">go-next-symbolic</property>
+ <object class="GtkBox">
+ <property name="spacing">12</property>
+ <child>
+ <object class="GtkImage" id="color_image">
+ <style>
+ <class name="calendar-color-image"/>
+ </style>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel" id="calendar_name_label">
+ <property name="hexpand">True</property>
+ <property name="xalign">0</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkImage">
+ <property name="icon_name">go-next-symbolic</property>
+ </object>
+ </child>
</object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">2</property>
- </packing>
</child>
</object>
</child>
+ <child>
+ <object class="GtkButton" id="edit_button">
+ <property name="label" translatable="yes">Edit Details…</property>
+ <property name="margin_top">6</property>
+ <signal name="clicked" handler="edit_or_create_event" object="GcalQuickAddPopover"
swapped="yes" />
+ <layout>
+ <property name="column">0</property>
+ <property name="row">3</property>
+ </layout>
+ </object>
+ </child>
+ <child>
+ <object class="GtkButton" id="add_button">
+ <property name="label" translatable="yes">Add</property>
+ <property name="sensitive">False</property>
+ <property name="margin_top">6</property>
+ <signal name="clicked" handler="edit_or_create_event" object="GcalQuickAddPopover"
swapped="yes" />
+ <layout>
+ <property name="column">2</property>
+ <property name="row">3</property>
+ </layout>
+ <style>
+ <class name="suggested-action"/>
+ </style>
+ </object>
+ </child>
</object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">2</property>
- <property name="width">3</property>
- </packing>
- </child>
- <child>
- <object class="GtkButton" id="edit_button">
- <property name="label" translatable="yes">Edit Details…</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="margin_top">6</property>
- <signal name="clicked" handler="edit_or_create_event" object="GcalQuickAddPopover"
swapped="yes" />
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">3</property>
- </packing>
- </child>
- <child>
- <object class="GtkButton" id="add_button">
- <property name="label" translatable="yes">Add</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="sensitive">False</property>
- <property name="margin_top">6</property>
- <signal name="clicked" handler="edit_or_create_event" object="GcalQuickAddPopover"
swapped="yes" />
- <style>
- <class name="suggested-action"/>
- </style>
- </object>
- <packing>
- <property name="left_attach">2</property>
- <property name="top_attach">3</property>
- </packing>
- </child>
+ </property>
</object>
- <packing>
- <property name="name">events</property>
- </packing>
</child>
<child>
- <object class="GtkBox">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="orientation">vertical</property>
- <property name="spacing">6</property>
- <child>
+ <object class="GtkStackPage">
+ <property name="name">calendars</property>
+ <property name="child">
<object class="GtkBox">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">6</property>
<child>
- <object class="GtkButton" id="back_button">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="relief">none</property>
- <signal name="clicked" handler="back_button_clicked" object="GcalQuickAddPopover"
swapped="yes" />
- <style>
- <class name="image-button"/>
- </style>
- <child>
- <object class="GtkImage">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
+ <object class="GtkCenterBox">
+ <child type="start">
+ <object class="GtkButton" id="back_button">
<property name="icon_name">go-previous-symbolic</property>
+ <signal name="clicked" handler="back_button_clicked" object="GcalQuickAddPopover"
swapped="yes" />
+ <style>
+ <class name="flat"/>
+ </style>
+ </object>
+ </child>
+ <child type="center">
+ <object class="GtkLabel">
+ <property name="label" translatable="yes">Calendar</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ </attributes>
</object>
</child>
</object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child type="center">
- <object class="GtkLabel">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">Calendar</property>
- <attributes>
- <attribute name="weight" value="bold"/>
- </attributes>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
</child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkScrolledWindow">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="hexpand">True</property>
- <property name="vexpand">True</property>
- <property name="shadow_type">in</property>
<child>
- <object class="GtkViewport">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="shadow_type">none</property>
+ <object class="GtkScrolledWindow">
+ <property name="hexpand">True</property>
+ <property name="vexpand">True</property>
<child>
- <object class="GtkListBox" id="calendars_listbox">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="selection_mode">none</property>
- <signal name="row-activated" handler="select_row" object="GcalQuickAddPopover"
swapped="yes" />
- <style>
- <class name="calendars-list"/>
- </style>
+ <object class="GtkViewport">
+ <property name="scroll-to-focus">True</property>
+ <child>
+ <object class="GtkListBox" id="calendars_listbox">
+ <property name="selection_mode">none</property>
+ <signal name="row-activated" handler="select_row" object="GcalQuickAddPopover"
swapped="yes" />
+ <style>
+ <class name="calendars-list"/>
+ </style>
+ </object>
+ </child>
</object>
</child>
</object>
</child>
</object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
+ </property>
</object>
- <packing>
- <property name="name">calendars</property>
- <property name="position">1</property>
- </packing>
</child>
</object>
</child>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]