[gnome-calendar/gbsneto/gtk4: 16/21] calendar-popover: Port to GTK4
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calendar/gbsneto/gtk4: 16/21] calendar-popover: Port to GTK4
- Date: Mon, 7 Feb 2022 22:45:37 +0000 (UTC)
commit 49b1868e01968af2b8b9986ae9393a87caaf1743
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Wed Jan 26 13:16:49 2022 -0300
calendar-popover: Port to GTK4
src/gui/gcal-calendar-popover.c | 42 +++++++++++++++------------------
src/gui/gcal-calendar-popover.ui | 50 ++++++++++++++++++----------------------
2 files changed, 40 insertions(+), 52 deletions(-)
---
diff --git a/src/gui/gcal-calendar-popover.c b/src/gui/gcal-calendar-popover.c
index 1b5775df..256d388f 100644
--- a/src/gui/gcal-calendar-popover.c
+++ b/src/gui/gcal-calendar-popover.c
@@ -61,20 +61,19 @@ make_calendar_row (GcalCalendar *calendar)
{
g_autoptr (GdkPaintable) paintable = NULL;
GtkWidget *label, *icon, *checkbox, *box, *row;
- GtkStyleContext *context;
const GdkRGBA *color;
row = gtk_list_box_row_new ();
/* apply some nice styling */
- context = gtk_widget_get_style_context (row);
- gtk_style_context_add_class (context, "button");
- gtk_style_context_add_class (context, "flat");
- gtk_style_context_add_class (context, "menuitem");
+ gtk_widget_add_css_class (row, "button");
+ gtk_widget_add_css_class (row, "flat");
+ gtk_widget_add_css_class (row, "menuitem");
/* main box */
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
- gtk_container_set_border_width (GTK_CONTAINER (box), 6);
+ gtk_widget_set_margin_start (box, 6);
+ gtk_widget_set_margin_end (box, 6);
/* source color icon */
color = gcal_calendar_get_color (calendar);
@@ -96,16 +95,14 @@ make_calendar_row (GcalCalendar *calendar)
"active",
G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
- gtk_container_add (GTK_CONTAINER (box), icon);
- gtk_container_add (GTK_CONTAINER (box), label);
- gtk_container_add (GTK_CONTAINER (box), checkbox);
- gtk_container_add (GTK_CONTAINER (row), box);
+ gtk_box_append (GTK_BOX (box), icon);
+ gtk_box_append (GTK_BOX (box), label);
+ gtk_box_append (GTK_BOX (box), checkbox);
+ gtk_list_box_row_set_child (GTK_LIST_BOX_ROW (row), box);
g_object_set_data (G_OBJECT (row), "check", checkbox);
g_object_set_data (G_OBJECT (row), "calendar", calendar);
- gtk_widget_show_all (row);
-
return row;
}
@@ -116,25 +113,24 @@ add_calendar (GcalCalendarPopover *self,
GtkWidget *row;
row = make_calendar_row (calendar);
- gtk_container_add (GTK_CONTAINER (self->calendar_listbox), row);
+ gtk_list_box_append (GTK_LIST_BOX (self->calendar_listbox), row);
}
static void
remove_calendar (GcalCalendarPopover *self,
GcalCalendar *calendar)
{
- g_autoptr (GList) children = NULL;
- GList *aux;
-
- children = gtk_container_get_children (GTK_CONTAINER (self->calendar_listbox));
+ GtkWidget *child;
- for (aux = children; aux != NULL; aux = aux->next)
+ for (child = gtk_widget_get_first_child (self->calendar_listbox);
+ child;
+ child = gtk_widget_get_next_sibling (child))
{
- GcalCalendar *row_calendar = g_object_get_data (G_OBJECT (aux->data), "calendar");
+ GcalCalendar *row_calendar = g_object_get_data (G_OBJECT (child), "calendar");
if (row_calendar && row_calendar == calendar)
{
- gtk_widget_destroy (aux->data);
+ gtk_list_box_remove (GTK_LIST_BOX (self->calendar_listbox), child);
break;
}
}
@@ -248,11 +244,9 @@ on_listbox_row_activated_cb (GtkListBox *listbox,
GtkListBoxRow *row,
GcalCalendarPopover *self)
{
- GtkToggleButton *check;
-
- check = (GtkToggleButton *) g_object_get_data (G_OBJECT (row), "check");
+ GtkCheckButton *check = g_object_get_data (G_OBJECT (row), "check");
- gtk_toggle_button_set_active (check, !gtk_toggle_button_get_active (check));
+ gtk_check_button_set_active (check, !gtk_check_button_get_active (check));
}
diff --git a/src/gui/gcal-calendar-popover.ui b/src/gui/gcal-calendar-popover.ui
index a451af16..a2b4a147 100644
--- a/src/gui/gcal-calendar-popover.ui
+++ b/src/gui/gcal-calendar-popover.ui
@@ -1,23 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="GcalCalendarPopover" parent="GtkPopover">
- <property name="can_focus">False</property>
<property name="position">bottom</property>
- <property name="constrain_to">none</property>
<child>
<object class="GtkBox">
- <property name="visible">True</property>
<property name="orientation">vertical</property>
- <property name="margin">6</property>
<child>
<object class="GtkScrolledWindow">
- <property name="visible">True</property>
<property name="hscrollbar_policy">never</property>
<property name="max_content_height">450</property>
<property name="propagate-natural-height">True</property>
<child>
<object class="GtkListBox" id="calendar_listbox">
- <property name="visible">True</property>
<property name="hexpand">True</property>
<property name="selection_mode">none</property>
<signal name="row-activated" handler="on_listbox_row_activated_cb"
object="GcalCalendarPopover" swapped="no"/>
@@ -31,14 +25,12 @@
<child>
<object class="GtkSeparator">
- <property name="visible">True</property>
</object>
</child>
<!-- Synchronize -->
<child>
<object class="GtkModelButton" id="synchronize_button">
- <property name="visible">True</property>
<property name="action-name">app.sync</property>
<property name="text" translatable="yes">_Synchronize Calendars</property>
</object>
@@ -46,7 +38,6 @@
<child>
<object class="GtkModelButton" id="calendar_settings_button">
- <property name="visible">True</property>
<property name="action_name">win.show-calendars</property>
<property name="text" translatable="yes">Manage Calendars…</property>
</object>
@@ -57,35 +48,38 @@
<!-- Icon -->
<object class="GtkStack" id="icon_stack">
- <property name="visible">True</property>
<property name="transition-type">crossfade</property>
<property name="transition-duration">250</property>
<child>
- <object class="GtkImage" id="calendar_image">
- <property name="visible">True</property>
- <property name="icon_name">x-office-calendar-symbolic</property>
- </object>
- <packing>
+ <object class="GtkStackPage">
<property name="name">icon</property>
- </packing>
+ <property name="child">
+ <object class="GtkImage" id="calendar_image">
+ <property name="icon_name">x-office-calendar-symbolic</property>
+ </object>
+ </property>
+ </object>
</child>
<child>
- <object class="GtkSpinner" id="refreshing_spinner">
- <property name="active">True</property>
- <property name="tooltip_text" translatable="yes" context="tooltip">Synchronizing remote
calendars…</property>
- </object>
- <packing>
+ <object class="GtkStackPage">
<property name="name">spinner</property>
- </packing>
+ <property name="child">
+ <object class="GtkSpinner" id="refreshing_spinner">
+ <property name="spinning">True</property>
+ <property name="tooltip_text" translatable="yes" context="tooltip">Synchronizing remote
calendars…</property>
+ </object>
+ </property>
+ </object>
</child>
<child>
- <object class="GtkImage" id="success_image">
- <property name="visible">True</property>
- <property name="icon_name">emblem-ok-symbolic</property>
- </object>
- <packing>
+ <object class="GtkStackPage">
<property name="name">success</property>
- </packing>
+ <property name="child">
+ <object class="GtkImage" id="success_image">
+ <property name="icon_name">emblem-ok-symbolic</property>
+ </object>
+ </property>
+ </object>
</child>
</object>
</interface>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]