source-dialog: give back button some action
Makes it show, hide and go back to the correct page. Nothing deep by this point.
This commit is contained in:
committed by
Erick Pérez Castellanos
parent
e11c57f0a7
commit
35a622a27b
@@ -33,6 +33,7 @@
|
||||
<property name="vexpand">True</property>
|
||||
<property name="vhomogeneous">False</property>
|
||||
<property name="transition_type">crossfade</property>
|
||||
<signal name="notify::visible-child-name" handler="stack_visible_child_name_changed" object="GcalSourceDialog" swapped="no"/>
|
||||
<child>
|
||||
<object class="GtkScrolledWindow" id="main_scrolledwindow">
|
||||
<property name="visible">True</property>
|
||||
@@ -789,6 +790,7 @@
|
||||
<property name="visible">False</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<signal name="clicked" handler="back_button_clicked" object="GcalSourceDialog" swapped="no" />
|
||||
<child>
|
||||
<object class="GtkImage" id="back_button_image">
|
||||
<property name="visible">True</property>
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
typedef struct
|
||||
{
|
||||
GtkWidget *add_button;
|
||||
GtkWidget *back_button;
|
||||
GtkWidget *calendar_color_button;
|
||||
GtkWidget *cancel_button;
|
||||
GtkWidget *default_check;
|
||||
@@ -85,6 +86,16 @@ static void add_source (GcalManager *m
|
||||
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 (GtkFileChooserButton *button,
|
||||
gpointer user_data);
|
||||
|
||||
static void calendar_listbox_row_activated (GtkListBox *box,
|
||||
GtkListBoxRow *row,
|
||||
gpointer user_data);
|
||||
|
||||
static void clear_pages (GcalSourceDialog *dialog);
|
||||
|
||||
static void color_set (GtkColorButton *button,
|
||||
@@ -117,16 +128,13 @@ static void response_signal (GtkDialog *di
|
||||
gint response_id,
|
||||
gpointer user_data);
|
||||
|
||||
static void calendar_file_selected (GtkFileChooserButton *button,
|
||||
gpointer user_data);
|
||||
static void setup_source_details (GcalSourceDialog *dialog,
|
||||
ESource *source);
|
||||
|
||||
static void calendar_listbox_row_activated (GtkListBox *box,
|
||||
GtkListBoxRow *row,
|
||||
static void stack_visible_child_name_changed (GObject *object,
|
||||
GParamSpec *pspec,
|
||||
gpointer user_data);
|
||||
|
||||
static void setup_source_details (GcalSourceDialog *dialog,
|
||||
ESource *source);
|
||||
|
||||
static gboolean pulse_web_entry (GcalSourceDialog *dialog);
|
||||
|
||||
static void url_entry_text_changed (GObject *object,
|
||||
@@ -201,6 +209,31 @@ action_widget_activated (GtkWidget *widget,
|
||||
gtk_dialog_response (GTK_DIALOG (user_data), response);
|
||||
}
|
||||
|
||||
/**
|
||||
* back_button_clicked:
|
||||
*
|
||||
* Returns to the previous page.
|
||||
*
|
||||
* Returns:
|
||||
*/
|
||||
static void
|
||||
back_button_clicked (GtkButton *button,
|
||||
gpointer user_data)
|
||||
{
|
||||
GcalSourceDialogPrivate *priv = GCAL_SOURCE_DIALOG (user_data)->priv;
|
||||
|
||||
/*
|
||||
* TODO: when editing a GOA calendar, it should
|
||||
* go back to the GOA calendar selection page.
|
||||
*/
|
||||
|
||||
if (g_strcmp0 (gtk_stack_get_visible_child_name (GTK_STACK (priv->stack)), "edit"))
|
||||
{
|
||||
gtk_stack_set_visible_child_name (GTK_STACK (priv->stack), "main");
|
||||
gtk_widget_hide (GTK_WIDGET (button));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* clear_pages:
|
||||
*
|
||||
@@ -458,6 +491,28 @@ response_signal (GtkDialog *dialog,
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
stack_visible_child_name_changed (GObject *object,
|
||||
GParamSpec *pspec,
|
||||
gpointer user_data)
|
||||
{
|
||||
GcalSourceDialogPrivate *priv = GCAL_SOURCE_DIALOG (user_data)->priv;
|
||||
const gchar *visible_name;
|
||||
gboolean is_main;
|
||||
|
||||
visible_name = gtk_stack_get_visible_child_name (GTK_STACK (object));
|
||||
is_main = g_strcmp0 (visible_name, "main") == 0;
|
||||
|
||||
// Show the '<' button everywhere except "main" page
|
||||
gtk_widget_set_visible (priv->back_button, !is_main);
|
||||
|
||||
if (is_main)
|
||||
{
|
||||
gtk_header_bar_set_title (GTK_HEADER_BAR (priv->headerbar), _("Calendar Settings"));
|
||||
gtk_header_bar_set_subtitle (GTK_HEADER_BAR (priv->headerbar), NULL);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* calendar_file_selected:
|
||||
*
|
||||
@@ -1054,6 +1109,7 @@ gcal_source_dialog_class_init (GcalSourceDialogClass *klass)
|
||||
|
||||
gtk_widget_class_bind_template_child_private (widget_class, GcalSourceDialog, add_button);
|
||||
gtk_widget_class_bind_template_child_private (widget_class, GcalSourceDialog, add_calendar_menu_button);
|
||||
gtk_widget_class_bind_template_child_private (widget_class, GcalSourceDialog, back_button);
|
||||
gtk_widget_class_bind_template_child_private (widget_class, GcalSourceDialog, calendar_address_entry);
|
||||
gtk_widget_class_bind_template_child_private (widget_class, GcalSourceDialog, calendar_color_button);
|
||||
gtk_widget_class_bind_template_child_private (widget_class, GcalSourceDialog, calendars_listbox);
|
||||
@@ -1072,6 +1128,7 @@ gcal_source_dialog_class_init (GcalSourceDialogClass *klass)
|
||||
gtk_widget_class_bind_template_child_private (widget_class, GcalSourceDialog, web_sources_revealer);
|
||||
|
||||
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_listbox_row_activated);
|
||||
gtk_widget_class_bind_template_callback (widget_class, color_set);
|
||||
@@ -1080,6 +1137,7 @@ gcal_source_dialog_class_init (GcalSourceDialogClass *klass)
|
||||
gtk_widget_class_bind_template_callback (widget_class, name_entry_text_changed);
|
||||
gtk_widget_class_bind_template_callback (widget_class, new_name_entry_text_changed);
|
||||
gtk_widget_class_bind_template_callback (widget_class, response_signal);
|
||||
gtk_widget_class_bind_template_callback (widget_class, stack_visible_child_name_changed);
|
||||
gtk_widget_class_bind_template_callback (widget_class, url_entry_text_changed);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user