calendar-management: Switch to GtkColorDialogButton

This commit is contained in:
Georges Basile Stavracas Neto
2023-03-16 12:30:15 +00:00
parent 4df39fa2ce
commit ac526c5a22
4 changed files with 28 additions and 16 deletions
@@ -34,7 +34,7 @@ struct _GcalEditCalendarPage
GtkLabel *account_label;
GtkWidget *account_dim_label;
GtkWidget *back_button;
GtkColorChooser *calendar_color_button;
GtkColorDialogButton *calendar_color_button;
GtkCheckButton *calendar_visible_check;
GtkWidget *calendar_url_button;
GtkCheckButton *default_check;
@@ -186,7 +186,7 @@ setup_calendar (GcalEditCalendarPage *self,
gtk_label_set_label (self->account_label, name);
}
gtk_color_chooser_set_rgba (self->calendar_color_button, gcal_calendar_get_color (calendar));
gtk_color_dialog_button_set_rgba (self->calendar_color_button, gcal_calendar_get_color (calendar));
gtk_editable_set_text (GTK_EDITABLE (self->name_entry), gcal_calendar_get_name (calendar));
gtk_check_button_set_active (self->calendar_visible_check, gcal_calendar_get_visible (calendar));
@@ -199,17 +199,17 @@ static void
update_calendar (GcalEditCalendarPage *self)
{
GcalManager *manager;
GdkRGBA color;
const GdkRGBA *color;
GCAL_ENTRY;
g_assert (self->calendar != NULL);
manager = gcal_context_get_manager (self->context);
gtk_color_chooser_get_rgba (self->calendar_color_button, &color);
color = gtk_color_dialog_button_get_rgba (self->calendar_color_button);
gcal_calendar_set_name (self->calendar, gtk_editable_get_text (GTK_EDITABLE (self->name_entry)));
gcal_calendar_set_color (self->calendar, &color);
gcal_calendar_set_color (self->calendar, color);
if (gtk_check_button_get_active (self->default_check))
gcal_manager_set_default_calendar (manager, self->calendar);
@@ -119,8 +119,14 @@
</child>
<child>
<object class="GtkColorButton" id="calendar_color_button">
<object class="GtkColorDialogButton" id="calendar_color_button">
<property name="halign">start</property>
<property name="dialog">
<object class="GtkColorDialog">
<property name="modal">True</property>
<property name="with-alpha">False</property>
</object>
</property>
<layout>
<property name="row">3</property>
<property name="column">1</property>
@@ -54,7 +54,7 @@ struct _GcalNewCalendarPage
GtkWindow *credentials_dialog;
GtkEntry *credentials_password_entry;
GtkEntry *credentials_user_entry;
GtkColorChooser *local_calendar_color_button;
GtkColorDialogButton *local_calendar_color_button;
GtkEntry *local_calendar_name_entry;
GtkWidget *web_sources_listbox;
GtkWidget *web_sources_revealer;
@@ -160,11 +160,11 @@ update_local_source (GcalNewCalendarPage *self)
{
g_autofree gchar *color_string = NULL;
ESourceExtension *ext;
const GdkRGBA *color;
ESource *source;
GdkRGBA color;
gtk_color_chooser_get_rgba (self->local_calendar_color_button, &color);
color_string = gdk_rgba_to_string (&color);
color = gtk_color_dialog_button_get_rgba (self->local_calendar_color_button);
color_string = gdk_rgba_to_string (color);
/* Create the new source and add the needed extensions */
source = e_source_new (NULL, NULL, NULL);
@@ -482,9 +482,9 @@ on_local_calendar_name_entry_text_changed_cb (GtkEntry *entry,
}
static void
on_local_calendar_color_button_color_changed_cb (GtkColorChooser *chooser,
GParamSpec *pspec,
GcalNewCalendarPage *self)
on_local_calendar_color_button_rgba_changed_cb (GtkColorChooser *chooser,
GParamSpec *pspec,
GcalNewCalendarPage *self)
{
update_local_source (self);
}
@@ -676,7 +676,7 @@ gcal_new_calendar_page_class_init (GcalNewCalendarPageClass *klass)
gtk_widget_class_bind_template_callback (widget_class, on_credential_entry_activate_cb);
gtk_widget_class_bind_template_callback (widget_class, on_file_chooser_button_file_changed_cb);
gtk_widget_class_bind_template_callback (widget_class, on_local_calendar_name_entry_text_changed_cb);
gtk_widget_class_bind_template_callback (widget_class, on_local_calendar_color_button_color_changed_cb);
gtk_widget_class_bind_template_callback (widget_class, on_local_calendar_color_button_rgba_changed_cb);
gtk_widget_class_bind_template_callback (widget_class, on_url_entry_text_changed_cb);
gtk_widget_class_bind_template_callback (widget_class, on_web_description_label_link_activated_cb);
}
@@ -34,9 +34,15 @@
<property name="activatable-widget">local_calendar_color_button</property>
<child>
<object class="GtkColorButton" id="local_calendar_color_button">
<object class="GtkColorDialogButton" id="local_calendar_color_button">
<property name="valign">center</property>
<signal name="notify::color" handler="on_local_calendar_color_button_color_changed_cb" object="GcalNewCalendarPage" swapped="no" />
<property name="dialog">
<object class="GtkColorDialog">
<property name="modal">True</property>
<property name="with-alpha">False</property>
</object>
</property>
<signal name="notify::rgba" handler="on_local_calendar_color_button_rgba_changed_cb" object="GcalNewCalendarPage" swapped="no" />
</object>
</child>