calendar-management/new-calendar: Move add button to dialog
Move the add button from the headerbar into the dialog, make it a pill button, and update the button label with the number of calendars that will be added.
This commit is contained in:
@@ -20,6 +20,8 @@
|
|||||||
|
|
||||||
#define G_LOG_DOMAIN "GcalNewCalendarPage"
|
#define G_LOG_DOMAIN "GcalNewCalendarPage"
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
#include <glib/gi18n.h>
|
#include <glib/gi18n.h>
|
||||||
|
|
||||||
#include "gcal-context.h"
|
#include "gcal-context.h"
|
||||||
@@ -136,13 +138,36 @@ calendar_path_to_name_suggestion (GFile *file)
|
|||||||
static void
|
static void
|
||||||
update_add_button (GcalNewCalendarPage *self)
|
update_add_button (GcalNewCalendarPage *self)
|
||||||
{
|
{
|
||||||
|
g_autofree gchar *add_button_label = NULL;
|
||||||
gboolean valid;
|
gboolean valid;
|
||||||
|
uint32_t n_calendars;
|
||||||
|
|
||||||
valid = (self->local_source != NULL || self->remote_sources != NULL) &&
|
valid = (self->local_source != NULL || self->remote_sources != NULL) &&
|
||||||
self->calendar_address_entry_state != ENTRY_STATE_VALIDATING &&
|
self->calendar_address_entry_state != ENTRY_STATE_VALIDATING &&
|
||||||
self->calendar_address_entry_state != ENTRY_STATE_INVALID;
|
self->calendar_address_entry_state != ENTRY_STATE_INVALID;
|
||||||
|
|
||||||
gtk_widget_set_sensitive (self->add_button, valid);
|
gtk_widget_set_sensitive (self->add_button, valid);
|
||||||
|
|
||||||
|
n_calendars = 0;
|
||||||
|
if (self->local_source)
|
||||||
|
n_calendars++;
|
||||||
|
if (self->remote_sources)
|
||||||
|
n_calendars += self->remote_sources->len;
|
||||||
|
|
||||||
|
if (n_calendars > 0)
|
||||||
|
{
|
||||||
|
add_button_label = g_strdup_printf (g_dngettext (GETTEXT_PACKAGE,
|
||||||
|
"Add Calendar",
|
||||||
|
"Add %1$u Calendars",
|
||||||
|
n_calendars),
|
||||||
|
n_calendars);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
add_button_label = g_strdup (_("Add Calendar"));
|
||||||
|
}
|
||||||
|
|
||||||
|
gtk_button_set_label (GTK_BUTTON (self->add_button), add_button_label);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|||||||
@@ -15,17 +15,6 @@
|
|||||||
</object>
|
</object>
|
||||||
</property>
|
</property>
|
||||||
|
|
||||||
<child type="end">
|
|
||||||
<object class="GtkButton" id="add_button">
|
|
||||||
<property name="label" translatable="yes">Add</property>
|
|
||||||
<property name="sensitive">False</property>
|
|
||||||
<signal name="clicked" handler="on_add_button_clicked_cb" object="GcalNewCalendarPage" swapped="no" />
|
|
||||||
<style>
|
|
||||||
<class name="suggested-action"/>
|
|
||||||
</style>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
|
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
|
|
||||||
@@ -199,6 +188,25 @@
|
|||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
|
|
||||||
|
<child>
|
||||||
|
<object class="AdwPreferencesGroup">
|
||||||
|
|
||||||
|
<child>
|
||||||
|
<object class="GtkButton" id="add_button">
|
||||||
|
<property name="halign">center</property>
|
||||||
|
<property name="label" translatable="yes">Add Calendar</property>
|
||||||
|
<property name="sensitive">False</property>
|
||||||
|
<signal name="clicked" handler="on_add_button_clicked_cb" object="GcalNewCalendarPage" swapped="no" />
|
||||||
|
<style>
|
||||||
|
<class name="pill"/>
|
||||||
|
<class name="suggested-action"/>
|
||||||
|
</style>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
|
||||||
</object>
|
</object>
|
||||||
</property>
|
</property>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user