calendar-management/calendars-page: Port to GTK4
This commit is contained in:
@@ -1,73 +1,62 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!-- Generated with glade 3.18.1 -->
|
|
||||||
<interface>
|
<interface>
|
||||||
<requires lib="gtk+" version="3.16"/>
|
|
||||||
<object class="GtkListBoxRow" id="row">
|
<object class="GtkListBoxRow" id="row">
|
||||||
<property name="width_request">100</property>
|
<property name="width_request">100</property>
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkGrid" id="grid">
|
<object class="GtkGrid" id="grid">
|
||||||
<property name="visible">True</property>
|
<property name="margin-top">12</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="margin-bottom">12</property>
|
||||||
<property name="border_width">12</property>
|
<property name="margin-start">12</property>
|
||||||
|
<property name="margin-end">12</property>
|
||||||
<property name="column_spacing">6</property>
|
<property name="column_spacing">6</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkImage" id="icon">
|
<object class="GtkImage" id="icon">
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
<property name="pixel_size">24</property>
|
<property name="pixel_size">24</property>
|
||||||
|
<layout>
|
||||||
|
<property name="column">0</property>
|
||||||
|
<property name="row">0</property>
|
||||||
|
<property name="row-span">2</property>
|
||||||
|
</layout>
|
||||||
<style>
|
<style>
|
||||||
<class name="calendar-color-image"/>
|
<class name="calendar-color-image"/>
|
||||||
</style>
|
</style>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
|
||||||
<property name="left_attach">0</property>
|
|
||||||
<property name="top_attach">0</property>
|
|
||||||
<property name="height">2</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkLabel" id="subtitle">
|
<object class="GtkLabel" id="subtitle">
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
<property name="hexpand">True</property>
|
<property name="hexpand">True</property>
|
||||||
<property name="xalign">0</property>
|
<property name="xalign">0</property>
|
||||||
|
<layout>
|
||||||
|
<property name="column">1</property>
|
||||||
|
<property name="row">1</property>
|
||||||
|
</layout>
|
||||||
<style>
|
<style>
|
||||||
<class name="dim-label"/>
|
<class name="dim-label"/>
|
||||||
</style>
|
</style>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
|
||||||
<property name="left_attach">1</property>
|
|
||||||
<property name="top_attach">1</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkLabel" id="title">
|
<object class="GtkLabel" id="title">
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
<property name="xalign">0</property>
|
<property name="xalign">0</property>
|
||||||
|
<layout>
|
||||||
|
<property name="column">1</property>
|
||||||
|
<property name="row">0</property>
|
||||||
|
</layout>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
|
||||||
<property name="left_attach">1</property>
|
|
||||||
<property name="top_attach">0</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
</child>
|
||||||
|
|
||||||
<!-- Visibility switch -->
|
<!-- Visibility switch -->
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkSwitch" id="switch">
|
<object class="GtkSwitch" id="switch">
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
<property name="hexpand">True</property>
|
<property name="hexpand">True</property>
|
||||||
<property name="halign">end</property>
|
<property name="halign">end</property>
|
||||||
<property name="valign">center</property>
|
<property name="valign">center</property>
|
||||||
|
<layout>
|
||||||
|
<property name="column">2</property>
|
||||||
|
<property name="row">0</property>
|
||||||
|
<property name="row-span">2</property>
|
||||||
|
</layout>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
|
||||||
<property name="left_attach">2</property>
|
|
||||||
<property name="top_attach">0</property>
|
|
||||||
<property name="height">2</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
|
|||||||
@@ -70,9 +70,9 @@ static GtkWidget*
|
|||||||
make_calendar_row (GcalCalendarsPage *self,
|
make_calendar_row (GcalCalendarsPage *self,
|
||||||
GcalCalendar *calendar)
|
GcalCalendar *calendar)
|
||||||
{
|
{
|
||||||
|
g_autoptr (GdkPaintable) color_paintable = NULL;
|
||||||
g_autofree gchar *parent_name = NULL;
|
g_autofree gchar *parent_name = NULL;
|
||||||
g_autoptr (GtkBuilder) builder = NULL;
|
g_autoptr (GtkBuilder) builder = NULL;
|
||||||
cairo_surface_t *surface;
|
|
||||||
const GdkRGBA *color;
|
const GdkRGBA *color;
|
||||||
GcalManager *manager;
|
GcalManager *manager;
|
||||||
GtkWidget *bottom_label;
|
GtkWidget *bottom_label;
|
||||||
@@ -95,9 +95,9 @@ make_calendar_row (GcalCalendarsPage *self,
|
|||||||
|
|
||||||
/* source color icon */
|
/* source color icon */
|
||||||
color = gcal_calendar_get_color (calendar);
|
color = gcal_calendar_get_color (calendar);
|
||||||
surface = get_circle_surface_from_color (color, 24);
|
color_paintable = get_circle_paintable_from_color (color, 24);
|
||||||
icon = GTK_WIDGET (gtk_builder_get_object (builder, "icon"));
|
icon = GTK_WIDGET (gtk_builder_get_object (builder, "icon"));
|
||||||
gtk_image_set_from_surface (GTK_IMAGE (icon), surface);
|
gtk_image_set_from_paintable (GTK_IMAGE (icon), color_paintable);
|
||||||
|
|
||||||
/* source name label */
|
/* source name label */
|
||||||
top_label = GTK_WIDGET (gtk_builder_get_object (builder, "title"));
|
top_label = GTK_WIDGET (gtk_builder_get_object (builder, "title"));
|
||||||
@@ -123,8 +123,6 @@ make_calendar_row (GcalCalendarsPage *self,
|
|||||||
bottom_label = GTK_WIDGET (gtk_builder_get_object (builder, "subtitle"));
|
bottom_label = GTK_WIDGET (gtk_builder_get_object (builder, "subtitle"));
|
||||||
gtk_label_set_label (GTK_LABEL (bottom_label), parent_name);
|
gtk_label_set_label (GTK_LABEL (bottom_label), parent_name);
|
||||||
|
|
||||||
g_clear_pointer (&surface, cairo_surface_destroy);
|
|
||||||
|
|
||||||
gtk_size_group_add_widget (self->sizegroup, row);
|
gtk_size_group_add_widget (self->sizegroup, row);
|
||||||
|
|
||||||
return row;
|
return row;
|
||||||
@@ -134,16 +132,15 @@ static void
|
|||||||
add_calendar (GcalCalendarsPage *self,
|
add_calendar (GcalCalendarsPage *self,
|
||||||
GcalCalendar *calendar)
|
GcalCalendar *calendar)
|
||||||
{
|
{
|
||||||
g_autoptr (GList) children = NULL;
|
GtkWidget *child;
|
||||||
GtkWidget *row;
|
GtkWidget *row;
|
||||||
ESource *source;
|
ESource *source;
|
||||||
GList *l;
|
|
||||||
|
|
||||||
children = gtk_container_get_children (GTK_CONTAINER (self->listbox));
|
for (child = gtk_widget_get_first_child (GTK_WIDGET (self->listbox));
|
||||||
|
child != NULL;
|
||||||
for (l = children; l; l = l->next)
|
child = gtk_widget_get_next_sibling (child))
|
||||||
{
|
{
|
||||||
if (g_object_get_data (l->data, "calendar") == calendar)
|
if (g_object_get_data (G_OBJECT (child), "calendar") == calendar)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,7 +149,7 @@ add_calendar (GcalCalendarsPage *self,
|
|||||||
row = make_calendar_row (self, calendar);
|
row = make_calendar_row (self, calendar);
|
||||||
g_object_set_data (G_OBJECT (row), "source", source);
|
g_object_set_data (G_OBJECT (row), "source", source);
|
||||||
g_object_set_data (G_OBJECT (row), "calendar", calendar);
|
g_object_set_data (G_OBJECT (row), "calendar", calendar);
|
||||||
gtk_container_add (GTK_CONTAINER (self->listbox), row);
|
gtk_list_box_append (self->listbox, row);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -160,18 +157,17 @@ static void
|
|||||||
remove_calendar (GcalCalendarsPage *self,
|
remove_calendar (GcalCalendarsPage *self,
|
||||||
GcalCalendar *calendar)
|
GcalCalendar *calendar)
|
||||||
{
|
{
|
||||||
g_autoptr (GList) children = NULL;
|
GtkWidget *child;
|
||||||
GList *aux;
|
|
||||||
|
|
||||||
children = gtk_container_get_children (GTK_CONTAINER (self->listbox));
|
for (child = gtk_widget_get_first_child (GTK_WIDGET (self->listbox));
|
||||||
|
child != NULL;
|
||||||
for (aux = children; aux != NULL; aux = aux->next)
|
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)
|
if (row_calendar && row_calendar == calendar)
|
||||||
{
|
{
|
||||||
gtk_widget_destroy (aux->data);
|
gtk_list_box_remove (self->listbox, child);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -269,13 +265,12 @@ on_calendar_color_changed_cb (GcalCalendar *calendar,
|
|||||||
GParamSpec *pspec,
|
GParamSpec *pspec,
|
||||||
GtkImage *icon)
|
GtkImage *icon)
|
||||||
{
|
{
|
||||||
cairo_surface_t *surface;
|
g_autoptr (GdkPaintable) color_paintable = NULL;
|
||||||
const GdkRGBA *color;
|
const GdkRGBA *color;
|
||||||
|
|
||||||
color = gcal_calendar_get_color (calendar);
|
color = gcal_calendar_get_color (calendar);
|
||||||
surface = get_circle_surface_from_color (color, 24);
|
color_paintable = get_circle_paintable_from_color (color, 24);
|
||||||
gtk_image_set_from_surface (GTK_IMAGE (icon), surface);
|
gtk_image_set_from_paintable (GTK_IMAGE (icon), color_paintable);
|
||||||
g_clear_pointer (&surface, cairo_surface_destroy);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|||||||
@@ -1,51 +1,38 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<interface>
|
<interface>
|
||||||
<template class="GcalCalendarsPage" parent="GtkBox">
|
<template class="GcalCalendarsPage" parent="GtkBox">
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="orientation">vertical</property>
|
<property name="orientation">vertical</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkOverlay">
|
<object class="GtkOverlay">
|
||||||
<property name="visible">True</property>
|
|
||||||
|
|
||||||
<child type="overlay">
|
<child type="overlay">
|
||||||
<object class="GtkRevealer" id="notification_revealer">
|
<object class="GtkRevealer" id="notification_revealer">
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="halign">center</property>
|
<property name="halign">center</property>
|
||||||
<property name="valign">start</property>
|
<property name="valign">start</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkFrame">
|
<object class="GtkFrame">
|
||||||
<property name="visible">True</property>
|
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkBox">
|
<object class="GtkBox">
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="spacing">12</property>
|
<property name="spacing">12</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkLabel" id="notification_label">
|
<object class="GtkLabel" id="notification_label">
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="use_markup">True</property>
|
<property name="use_markup">True</property>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkButton" id="notification_action_button">
|
<object class="GtkButton" id="notification_action_button">
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="label" translatable="yes">Undo</property>
|
<property name="label" translatable="yes">Undo</property>
|
||||||
<signal name="clicked" handler="on_undo_remove_button_clicked_cb" object="GcalCalendarsPage" swapped="no"/>
|
<signal name="clicked" handler="on_undo_remove_button_clicked_cb" object="GcalCalendarsPage" swapped="no"/>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkButton">
|
<object class="GtkButton">
|
||||||
<property name="visible">True</property>
|
<property name="icon-name">window-close-symbolic</property>
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="receives_default">True</property>
|
|
||||||
<property name="relief">none</property>
|
|
||||||
<property name="focus_on_click">False</property>
|
<property name="focus_on_click">False</property>
|
||||||
<signal name="clicked" handler="on_close_notification_button_clicked_cb" object="GcalCalendarsPage" swapped="no"/>
|
<signal name="clicked" handler="on_close_notification_button_clicked_cb" object="GcalCalendarsPage" swapped="no"/>
|
||||||
<child>
|
<style>
|
||||||
<object class="GtkImage">
|
<class name="flat" />
|
||||||
<property name="visible">True</property>
|
</style>
|
||||||
<property name="icon_name">window-close-symbolic</property>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
@@ -60,7 +47,6 @@
|
|||||||
|
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkScrolledWindow">
|
<object class="GtkScrolledWindow">
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="hexpand">True</property>
|
<property name="hexpand">True</property>
|
||||||
<property name="vexpand">True</property>
|
<property name="vexpand">True</property>
|
||||||
<property name="hscrollbar_policy">never</property>
|
<property name="hscrollbar_policy">never</property>
|
||||||
@@ -69,8 +55,10 @@
|
|||||||
|
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkListBox" id="listbox">
|
<object class="GtkListBox" id="listbox">
|
||||||
<property name="visible">True</property>
|
<property name="margin-top">24</property>
|
||||||
<property name="margin">24</property>
|
<property name="margin-bottom">24</property>
|
||||||
|
<property name="margin-start">24</property>
|
||||||
|
<property name="margin-end">24</property>
|
||||||
<property name="selection-mode">none</property>
|
<property name="selection-mode">none</property>
|
||||||
<signal name="row-activated" handler="on_listbox_row_activated_cb" object="GcalCalendarsPage" swapped="no" />
|
<signal name="row-activated" handler="on_listbox_row_activated_cb" object="GcalCalendarsPage" swapped="no" />
|
||||||
<style>
|
<style>
|
||||||
@@ -80,12 +68,11 @@
|
|||||||
|
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkListBoxRow" id="add_calendar_row">
|
<object class="GtkListBoxRow" id="add_calendar_row">
|
||||||
<property name="visible">True</property>
|
|
||||||
|
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkLabel">
|
<object class="GtkLabel">
|
||||||
<property name="visible">True</property>
|
<property name="hexpand">True</property>
|
||||||
<property name="expand">True</property>
|
<property name="vexpand">True</property>
|
||||||
<property name="xalign">0.5</property>
|
<property name="xalign">0.5</property>
|
||||||
<property name="yalign">0.5</property>
|
<property name="yalign">0.5</property>
|
||||||
<property name="label" translatable="yes">Add Calendar…</property>
|
<property name="label" translatable="yes">Add Calendar…</property>
|
||||||
|
|||||||
+24
-37
@@ -132,39 +132,27 @@ gcal_get_month_name (gint i)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gcal_get_surface_from_color:
|
* gcal_get_paintable_from_color:
|
||||||
* @color: a #GdkRGBA
|
* @color: a #GdkRGBA
|
||||||
* @size: the size of the surface
|
* @size: the size of the surface
|
||||||
*
|
*
|
||||||
* Creates a squared surface filled with @color. The
|
* Creates a squared surface filled with @color. The
|
||||||
* surface is always @size x @size.
|
* surface is always @size x @size.
|
||||||
*
|
*
|
||||||
* Returns: (transfer full): a #cairo_surface_t
|
* Returns: (transfer full): a #GdkPaintable
|
||||||
*/
|
*/
|
||||||
cairo_surface_t*
|
GdkPaintable*
|
||||||
gcal_get_surface_from_color (const GdkRGBA *color,
|
gcal_get_paintable_from_color (const GdkRGBA *color,
|
||||||
gint size)
|
gint size)
|
||||||
{
|
{
|
||||||
cairo_surface_t *surface;
|
g_autoptr (GtkSnapshot) snapshot = gtk_snapshot_new ();
|
||||||
cairo_t *cr;
|
|
||||||
|
|
||||||
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, size, size);
|
gtk_snapshot_append_color (snapshot, color, &GRAPHENE_RECT_INIT (0, 0, size, size));
|
||||||
cr = cairo_create (surface);
|
return gtk_snapshot_to_paintable (snapshot, &GRAPHENE_SIZE_INIT (size, size));
|
||||||
|
|
||||||
cairo_set_source_rgba (cr,
|
|
||||||
color->red,
|
|
||||||
color->green,
|
|
||||||
color->blue,
|
|
||||||
color->alpha);
|
|
||||||
cairo_rectangle (cr, 0, 0, size, size);
|
|
||||||
cairo_fill (cr);
|
|
||||||
cairo_destroy (cr);
|
|
||||||
|
|
||||||
return surface;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get_circle_surface_from_color:
|
* get_circle_paintable_from_color:
|
||||||
* @color: a #GdkRGBA
|
* @color: a #GdkRGBA
|
||||||
* @size: the size of the surface
|
* @size: the size of the surface
|
||||||
*
|
*
|
||||||
@@ -173,26 +161,25 @@ gcal_get_surface_from_color (const GdkRGBA *color,
|
|||||||
*
|
*
|
||||||
* Returns: (transfer full): a #cairo_surface_t
|
* Returns: (transfer full): a #cairo_surface_t
|
||||||
*/
|
*/
|
||||||
cairo_surface_t*
|
GdkPaintable*
|
||||||
get_circle_surface_from_color (const GdkRGBA *color,
|
get_circle_paintable_from_color (const GdkRGBA *color,
|
||||||
gint size)
|
gint size)
|
||||||
{
|
{
|
||||||
cairo_surface_t *surface;
|
g_autoptr (GtkSnapshot) snapshot = NULL;
|
||||||
cairo_t *cr;
|
GskRoundedRect rect;
|
||||||
|
|
||||||
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, size, size);
|
snapshot = gtk_snapshot_new ();
|
||||||
cr = cairo_create (surface);
|
|
||||||
|
|
||||||
cairo_set_source_rgba (cr,
|
gtk_snapshot_push_rounded_clip (snapshot,
|
||||||
color->red,
|
gsk_rounded_rect_init_from_rect (&rect,
|
||||||
color->green,
|
&GRAPHENE_RECT_INIT (0, 0, size, size),
|
||||||
color->blue,
|
size / 2.0));
|
||||||
color->alpha);
|
|
||||||
cairo_arc (cr, size / 2.0, size / 2.0, size / 2.0, 0., 2 * M_PI);
|
|
||||||
cairo_fill (cr);
|
|
||||||
cairo_destroy (cr);
|
|
||||||
|
|
||||||
return surface;
|
gtk_snapshot_append_color (snapshot, color, &GRAPHENE_RECT_INIT (0, 0, size, size));
|
||||||
|
|
||||||
|
gtk_snapshot_pop (snapshot);
|
||||||
|
|
||||||
|
return gtk_snapshot_to_paintable (snapshot, &GRAPHENE_SIZE_INIT (size, size));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -49,10 +49,10 @@ gchar* gcal_get_weekday (gint
|
|||||||
|
|
||||||
gchar* gcal_get_month_name (gint i);
|
gchar* gcal_get_month_name (gint i);
|
||||||
|
|
||||||
cairo_surface_t* gcal_get_surface_from_color (const GdkRGBA *color,
|
GdkPaintable* gcal_get_paintable_from_color (const GdkRGBA *color,
|
||||||
gint size);
|
gint size);
|
||||||
|
|
||||||
cairo_surface_t* get_circle_surface_from_color (const GdkRGBA *color,
|
GdkPaintable* get_circle_paintable_from_color (const GdkRGBA *color,
|
||||||
gint size);
|
gint size);
|
||||||
|
|
||||||
void get_color_name_from_source (ESource *source,
|
void get_color_name_from_source (ESource *source,
|
||||||
|
|||||||
Reference in New Issue
Block a user