new-calendar-page: Add "Cancel" and "Add" header buttons

parent 804479eb
......@@ -55,33 +55,6 @@
</child>
</object>
</child>
<child>
<object class="GtkButton" id="cancel_button">
<property name="label" translatable="yes">Cancel</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<signal name="clicked" handler="cancel_button_clicked" object="GcalCalendarManagementDialog" swapped="no"/>
</object>
<packing>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkButton" id="add_button">
<property name="label" translatable="yes">Add</property>
<property name="sensitive">False</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<signal name="clicked" handler="add_button_clicked" object="GcalCalendarManagementDialog" swapped="no"/>
<style>
<class name="suggested-action"/>
</style>
</object>
<packing>
<property name="pack_type">end</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</template>
......
......@@ -211,4 +211,23 @@
</child>
</object>
<!-- Headerbar buttons -->
<object class="GtkButton" id="cancel_button">
<property name="visible">True</property>
<property name="label" translatable="yes">Cancel</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<signal name="clicked" handler="on_cancel_button_clicked_cb" object="GcalNewCalendarPage" swapped="no" />
</object>
<object class="GtkButton" id="add_button">
<property name="visible">True</property>
<property name="label" translatable="yes">Add</property>
<property name="sensitive">False</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<signal name="clicked" handler="on_add_button_clicked_cb" object="GcalNewCalendarPage" swapped="no" />
<style>
<class name="suggested-action"/>
</style>
</object>
</interface>
......@@ -57,9 +57,7 @@ struct _GcalCalendarManagementDialog
{
GtkDialog parent;
GtkWidget *add_button;
GtkWidget *back_button;
GtkWidget *cancel_button;
GtkWidget *headerbar;
GtkWidget *notebook;
GtkWidget *stack;
......@@ -86,9 +84,6 @@ typedef enum
GCAL_ACCOUNT_TYPE_NOT_SUPPORTED
} GcalAccountType;
static void add_button_clicked (GtkWidget *button,
gpointer user_data);
static void action_widget_activated (GtkWidget *widget,
gpointer user_data);
......@@ -102,10 +97,6 @@ static void calendar_visible_check_toggled (GObject *ob
GParamSpec *pspec,
gpointer user_data);
static void cancel_button_clicked (GtkWidget *button,
gpointer user_data);
static void on_file_activated (GSimpleAction *action,
GVariant *param,
gpointer user_data);
......@@ -222,15 +213,6 @@ calendar_visible_check_toggled (GObject *object,
gcal_calendar_set_visible (calendar, gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (object)));
}
static void
cancel_button_clicked (GtkWidget *button,
gpointer user_data)
{
GcalCalendarManagementDialog *self = GCAL_CALENDAR_MANAGEMENT_DIALOG (user_data);
gcal_calendar_management_dialog_set_mode (self, GCAL_CALENDAR_MANAGEMENT_MODE_NORMAL);
}
static void
response_signal (GtkDialog *dialog,
gint response_id,
......@@ -340,7 +322,7 @@ calendar_file_selected (GtkFileChooser *button,
gcal_calendar_management_dialog_set_source (GCAL_CALENDAR_MANAGEMENT_DIALOG (user_data), source);
gcal_calendar_management_dialog_set_mode (GCAL_CALENDAR_MANAGEMENT_DIALOG (user_data), GCAL_CALENDAR_MANAGEMENT_MODE_CREATE);
gtk_widget_set_sensitive (self->add_button, TRUE);
//gtk_widget_set_sensitive (self->add_button, TRUE);
}
static void
......@@ -404,7 +386,7 @@ on_local_activated (GSimpleAction *action,
gcal_calendar_management_dialog_set_source (GCAL_CALENDAR_MANAGEMENT_DIALOG (user_data), source);
gcal_calendar_management_dialog_set_mode (GCAL_CALENDAR_MANAGEMENT_DIALOG (user_data), GCAL_CALENDAR_MANAGEMENT_MODE_CREATE);
gtk_widget_set_sensitive (self->add_button, TRUE);
//gtk_widget_set_sensitive (self->add_button, TRUE);
}
static void
......@@ -598,9 +580,7 @@ gcal_calendar_management_dialog_class_init (GcalCalendarManagementDialogClass *k
/* bind things for/from the template class */
gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/org/gnome/calendar/calendar-management-dialog.ui");
gtk_widget_class_bind_template_child (widget_class, GcalCalendarManagementDialog, add_button);
gtk_widget_class_bind_template_child (widget_class, GcalCalendarManagementDialog, back_button);
gtk_widget_class_bind_template_child (widget_class, GcalCalendarManagementDialog, cancel_button);
gtk_widget_class_bind_template_child (widget_class, GcalCalendarManagementDialog, headerbar);
gtk_widget_class_bind_template_child (widget_class, GcalCalendarManagementDialog, stack);
......@@ -609,7 +589,6 @@ gcal_calendar_management_dialog_class_init (GcalCalendarManagementDialogClass *k
gtk_widget_class_bind_template_callback (widget_class, back_button_clicked);
gtk_widget_class_bind_template_callback (widget_class, calendar_file_selected);
gtk_widget_class_bind_template_callback (widget_class, calendar_visible_check_toggled);
gtk_widget_class_bind_template_callback (widget_class, cancel_button_clicked);
gtk_widget_class_bind_template_callback (widget_class, response_signal);
}
......@@ -645,8 +624,6 @@ gcal_calendar_management_dialog_set_mode (GcalCalendarManagementDialog *dial
gtk_header_bar_set_subtitle (GTK_HEADER_BAR (dialog->headerbar), NULL);
gtk_header_bar_set_show_close_button (GTK_HEADER_BAR (dialog->headerbar), FALSE);
gtk_stack_set_visible_child (GTK_STACK (dialog->stack), GTK_WIDGET (dialog->pages[GCAL_PAGE_NEW_CALENDAR]));
gtk_widget_set_visible (dialog->add_button, TRUE);
gtk_widget_set_visible (dialog->cancel_button, TRUE);
break;
case GCAL_CALENDAR_MANAGEMENT_MODE_EDIT:
......
......@@ -33,7 +33,9 @@ struct _GcalNewCalendarPage
{
GtkBox parent;
GtkWidget *add_button;
GtkEntry *calendar_address_entry;
GtkWidget *cancel_button;
GtkWidget *credentials_cancel_button;
GtkWidget *credentials_connect_button;
GtkWidget *credentials_dialog;
......@@ -210,7 +212,7 @@ discover_sources_cb (GObject *source,
&error))
{
/* Don't add an source with errors */
//gtk_widget_set_sensitive (self->add_button, FALSE);
gtk_widget_set_sensitive (self->add_button, FALSE);
/*
* If it's the first try and things went wrong, retry with the user
......@@ -378,8 +380,7 @@ validate_url_cb (GcalNewCalendarPage *self)
if (is_file)
{
self->remote_sources = g_list_append (self->remote_sources, source);
//gtk_widget_set_sensitive (self->add_button, source != NULL);
gtk_widget_set_sensitive (self->add_button, source != NULL);
return FALSE;
}
......@@ -501,6 +502,13 @@ on_url_entry_text_changed_cb (GtkEntry *entry,
GCAL_EXIT;
}
static void
on_cancel_button_clicked_cb (GtkWidget *button,
GcalCalendarManagementPage *page)
{
gcal_calendar_management_page_switch_page (page, "calendars", NULL);
}
/*
* GcalCalendarManagementPage iface
......@@ -518,18 +526,46 @@ gcal_new_calendar_page_get_title (GcalCalendarManagementPage *page)
return _("New Calendar");
}
static void
gcal_new_calendar_page_activate (GcalCalendarManagementPage *page,
gpointer page_data)
{
GcalNewCalendarPage *self;
GtkHeaderBar *headerbar;
GCAL_ENTRY;
self = GCAL_NEW_CALENDAR_PAGE (page);
headerbar = gcal_calendar_management_page_get_titlebar (page);
gtk_header_bar_pack_start (headerbar, self->cancel_button);
gtk_header_bar_pack_end (headerbar, self->add_button);
gtk_header_bar_set_show_close_button (headerbar, FALSE);
GCAL_EXIT;
}
static void
gcal_new_calendar_page_deactivate (GcalCalendarManagementPage *page)
{
GcalNewCalendarPage *self = GCAL_NEW_CALENDAR_PAGE (page);
GcalNewCalendarPage *self;
GtkHeaderBar *headerbar;
//g_clear_object (&self->source);
GCAL_ENTRY;
self = GCAL_NEW_CALENDAR_PAGE (page);
headerbar = gcal_calendar_management_page_get_titlebar (page);
gtk_container_remove (GTK_CONTAINER (headerbar), self->cancel_button);
gtk_container_remove (GTK_CONTAINER (headerbar), self->add_button);
gtk_header_bar_set_show_close_button (headerbar, TRUE);
if (self->remote_sources)
{
g_list_free_full (self->remote_sources, g_object_unref);
self->remote_sources = NULL;
}
GCAL_EXIT;
}
static void
......@@ -537,6 +573,7 @@ gcal_calendar_management_page_iface_init (GcalCalendarManagementPageInterface *i
{
iface->get_name = gcal_new_calendar_page_get_name;
iface->get_title = gcal_new_calendar_page_get_title;
iface->activate = gcal_new_calendar_page_activate;
iface->deactivate = gcal_new_calendar_page_deactivate;
}
......@@ -607,7 +644,9 @@ gcal_new_calendar_page_class_init (GcalNewCalendarPageClass *klass)
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/calendar/new-calendar-page.ui");
gtk_widget_class_bind_template_child (widget_class, GcalNewCalendarPage, add_button);
gtk_widget_class_bind_template_child (widget_class, GcalNewCalendarPage, calendar_address_entry);
gtk_widget_class_bind_template_child (widget_class, GcalNewCalendarPage, cancel_button);
gtk_widget_class_bind_template_child (widget_class, GcalNewCalendarPage, credentials_cancel_button);
gtk_widget_class_bind_template_child (widget_class, GcalNewCalendarPage, credentials_connect_button);
gtk_widget_class_bind_template_child (widget_class, GcalNewCalendarPage, credentials_dialog);
......@@ -617,6 +656,7 @@ gcal_new_calendar_page_class_init (GcalNewCalendarPageClass *klass)
gtk_widget_class_bind_template_child (widget_class, GcalNewCalendarPage, web_sources_revealer);
gtk_widget_class_bind_template_callback (widget_class, on_calendar_address_activated_cb);
gtk_widget_class_bind_template_callback (widget_class, on_cancel_button_clicked_cb);
gtk_widget_class_bind_template_callback (widget_class, on_credential_button_clicked_cb);
gtk_widget_class_bind_template_callback (widget_class, on_credential_entry_activate_cb);
gtk_widget_class_bind_template_callback (widget_class, on_url_entry_text_changed_cb);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment