edit-calendar-page: Add back button

And remove the remaining code (and a few extras) from the
calendar management dialog.
parent a2d15697
......@@ -211,4 +211,18 @@
</object>
</child>
</template>
<!-- Headerbar buttons -->
<object class="GtkButton" id="back_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<signal name="clicked" handler="on_back_button_clicked_cb" object="GcalEditCalendarPage" swapped="no" />
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="icon-name">go-previous-symbolic</property>
</object>
</child>
</object>
</interface>
......@@ -84,12 +84,6 @@ typedef enum
GCAL_ACCOUNT_TYPE_NOT_SUPPORTED
} GcalAccountType;
static void action_widget_activated (GtkWidget *widget,
gpointer user_data);
static void back_button_clicked (GtkButton *button,
gpointer user_data);
static void calendar_file_selected (GtkFileChooser *button,
gpointer user_data);
......@@ -139,65 +133,6 @@ import_file_extensions[] = {
".vcs"
};
static void
add_button_clicked (GtkWidget *button,
gpointer user_data)
{
GcalCalendarManagementDialog *self = GCAL_CALENDAR_MANAGEMENT_DIALOG (user_data);
GcalManager *manager;
manager = gcal_context_get_manager (self->context);
if (self->source != NULL)
{
/* Commit the new source */
gcal_manager_save_source (manager, self->source);
self->source = NULL;
gcal_calendar_management_dialog_set_mode (GCAL_CALENDAR_MANAGEMENT_DIALOG (user_data),
GCAL_CALENDAR_MANAGEMENT_MODE_NORMAL);
}
#if 0
if (self->remote_sources != NULL)
{
GList *l;
/* Commit each new remote source */
for (l = self->remote_sources; l != NULL; l = l->next)
gcal_manager_save_source (manager, l->data);
g_list_free (self->remote_sources);
self->remote_sources = NULL;
/* Go back to overview */
gcal_calendar_management_dialog_set_mode (GCAL_CALENDAR_MANAGEMENT_DIALOG (user_data),
GCAL_CALENDAR_MANAGEMENT_MODE_NORMAL);
}
#endif
}
static void
action_widget_activated (GtkWidget *widget,
gpointer user_data)
{
GcalCalendarManagementDialog *self = GCAL_CALENDAR_MANAGEMENT_DIALOG (user_data);
gint response = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (widget), "response"));
self->old_default_source = NULL;
gtk_dialog_response (GTK_DIALOG (user_data), response);
}
static void
back_button_clicked (GtkButton *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
calendar_visible_check_toggled (GObject *object,
GParamSpec *pspec,
......@@ -584,9 +519,6 @@ gcal_calendar_management_dialog_class_init (GcalCalendarManagementDialogClass *k
gtk_widget_class_bind_template_child (widget_class, GcalCalendarManagementDialog, headerbar);
gtk_widget_class_bind_template_child (widget_class, GcalCalendarManagementDialog, stack);
gtk_widget_class_bind_template_callback (widget_class, add_button_clicked);
gtk_widget_class_bind_template_callback (widget_class, action_widget_activated);
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, response_signal);
......
......@@ -33,6 +33,7 @@ struct _GcalEditCalendarPage
GtkWidget *account_box;
GtkLabel *account_label;
GtkWidget *account_dim_label;
GtkWidget *back_button;
GtkColorChooser *calendar_color_button;
GtkToggleButton *calendar_visible_check;
GtkWidget *calendar_url_button;
......@@ -227,6 +228,20 @@ update_calendar (GcalEditCalendarPage *self)
* Callbacks
*/
static void
on_back_button_clicked_cb (GtkButton *back_button,
GcalEditCalendarPage *self)
{
GcalCalendarManagementPage *page;
GCAL_ENTRY;
page = GCAL_CALENDAR_MANAGEMENT_PAGE (self);
gcal_calendar_management_page_switch_page (page, "calendars", NULL);
GCAL_EXIT;
}
static void
on_remove_button_clicked_cb (GtkButton *button,
GcalEditCalendarPage *self)
......@@ -292,13 +307,16 @@ gcal_edit_calendar_page_activate (GcalCalendarManagementPage *page,
gpointer data)
{
GcalEditCalendarPage *self;
GtkHeaderBar *headerbar;
GcalCalendar *calendar;
g_assert (GCAL_IS_CALENDAR (data));
self = GCAL_EDIT_CALENDAR_PAGE (page);
calendar = GCAL_CALENDAR (data);
headerbar = gcal_calendar_management_page_get_titlebar (page);
gtk_header_bar_pack_start (headerbar, self->back_button);
calendar = GCAL_CALENDAR (data);
setup_calendar (self, calendar);
}
......@@ -306,14 +324,18 @@ static void
gcal_edit_calendar_page_deactivate (GcalCalendarManagementPage *page)
{
GcalEditCalendarPage *self;
GtkHeaderBar *headerbar;
GcalManager *manager;
GCAL_ENTRY;
self = GCAL_EDIT_CALENDAR_PAGE (page);
manager = gcal_context_get_manager (self->context);
headerbar = gcal_calendar_management_page_get_titlebar (page);
gtk_container_remove (GTK_CONTAINER (headerbar), self->back_button);
update_calendar (self);
manager = gcal_context_get_manager (self->context);
gcal_manager_save_source (manager, gcal_calendar_get_source (self->calendar));
g_clear_object (&self->calendar);
......@@ -401,6 +423,7 @@ gcal_edit_calendar_page_class_init (GcalEditCalendarPageClass *klass)
gtk_widget_class_bind_template_child (widget_class, GcalEditCalendarPage, account_box);
gtk_widget_class_bind_template_child (widget_class, GcalEditCalendarPage, account_label);
gtk_widget_class_bind_template_child (widget_class, GcalEditCalendarPage, back_button);
gtk_widget_class_bind_template_child (widget_class, GcalEditCalendarPage, calendar_color_button);
gtk_widget_class_bind_template_child (widget_class, GcalEditCalendarPage, calendar_url_button);
gtk_widget_class_bind_template_child (widget_class, GcalEditCalendarPage, calendar_visible_check);
......@@ -409,6 +432,7 @@ gcal_edit_calendar_page_class_init (GcalEditCalendarPageClass *klass)
gtk_widget_class_bind_template_child (widget_class, GcalEditCalendarPage, name_entry);
gtk_widget_class_bind_template_child (widget_class, GcalEditCalendarPage, remove_button);
gtk_widget_class_bind_template_callback (widget_class, on_back_button_clicked_cb);
gtk_widget_class_bind_template_callback (widget_class, on_remove_button_clicked_cb);
gtk_widget_class_bind_template_callback (widget_class, on_settings_button_clicked_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