source-dialog: properly save the source when the dialog is closed
This commit is contained in:
committed by
Erick Pérez Castellanos
parent
18fa205916
commit
cba97f8719
@@ -10,6 +10,7 @@
|
|||||||
<property name="width_request">450</property>
|
<property name="width_request">450</property>
|
||||||
<property name="default_width">550</property>
|
<property name="default_width">550</property>
|
||||||
<property name="default_height">500</property>
|
<property name="default_height">500</property>
|
||||||
|
<signal name="response" handler="response_signal" object="GcalSourceDialog" swapped="no"/>
|
||||||
<child internal-child="vbox">
|
<child internal-child="vbox">
|
||||||
<object class="GtkBox" id="vbox">
|
<object class="GtkBox" id="vbox">
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
|
|||||||
@@ -70,6 +70,10 @@ static void name_entry_text_changed (GObject *ob
|
|||||||
GParamSpec *pspec,
|
GParamSpec *pspec,
|
||||||
gpointer user_data);
|
gpointer user_data);
|
||||||
|
|
||||||
|
static void response_signal (GtkDialog *dialog,
|
||||||
|
gint response_id,
|
||||||
|
gpointer user_data);
|
||||||
|
|
||||||
G_DEFINE_TYPE_WITH_PRIVATE (GcalSourceDialog, gcal_source_dialog, GTK_TYPE_DIALOG)
|
G_DEFINE_TYPE_WITH_PRIVATE (GcalSourceDialog, gcal_source_dialog, GTK_TYPE_DIALOG)
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
@@ -100,6 +104,9 @@ action_widget_activated (GtkWidget *widget,
|
|||||||
|
|
||||||
priv->old_default_source = NULL;
|
priv->old_default_source = NULL;
|
||||||
|
|
||||||
|
/* save the source */
|
||||||
|
gcal_manager_save_source (priv->manager, priv->source);
|
||||||
|
|
||||||
gtk_dialog_response (GTK_DIALOG (user_data), response);
|
gtk_dialog_response (GTK_DIALOG (user_data), response);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -189,6 +196,28 @@ name_entry_text_changed (GObject *object,
|
|||||||
e_source_set_display_name (priv->source, gtk_entry_get_text (GTK_ENTRY (priv->name_entry)));
|
e_source_set_display_name (priv->source, gtk_entry_get_text (GTK_ENTRY (priv->name_entry)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* response_signal:
|
||||||
|
*
|
||||||
|
* Save the source when the dialog
|
||||||
|
* is close.
|
||||||
|
*
|
||||||
|
* Returns:
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
response_signal (GtkDialog *dialog,
|
||||||
|
gint response_id,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
GcalSourceDialogPrivate *priv = GCAL_SOURCE_DIALOG (dialog)->priv;
|
||||||
|
|
||||||
|
/* save the source */
|
||||||
|
if (priv->mode == GCAL_SOURCE_DIALOG_MODE_EDIT || response_id == GTK_RESPONSE_APPLY)
|
||||||
|
{
|
||||||
|
gcal_manager_save_source (priv->manager, priv->source);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
GcalSourceDialog *
|
GcalSourceDialog *
|
||||||
gcal_source_dialog_new (void)
|
gcal_source_dialog_new (void)
|
||||||
{
|
{
|
||||||
@@ -283,6 +312,7 @@ gcal_source_dialog_class_init (GcalSourceDialogClass *klass)
|
|||||||
gtk_widget_class_bind_template_callback (widget_class, default_check_toggled);
|
gtk_widget_class_bind_template_callback (widget_class, default_check_toggled);
|
||||||
gtk_widget_class_bind_template_callback (widget_class, description_label_link_activated);
|
gtk_widget_class_bind_template_callback (widget_class, description_label_link_activated);
|
||||||
gtk_widget_class_bind_template_callback (widget_class, name_entry_text_changed);
|
gtk_widget_class_bind_template_callback (widget_class, name_entry_text_changed);
|
||||||
|
gtk_widget_class_bind_template_callback (widget_class, response_signal);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|||||||
Reference in New Issue
Block a user