aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy-gtk
diff options
context:
space:
mode:
authorJonathan Tellier <jonathan.tellier@gmail.com>2009-08-27 00:52:45 +0800
committerjtellier <jonathan.tellier@collabora.co.uk>2009-08-29 02:27:43 +0800
commit435a811e440c3a5a79f504fa6f2850e63673f49a (patch)
tree0b3631df59ac2f7f935612b2e076e9ad0c2c7773 /libempathy-gtk
parent36e602e834790033aed3c8b82a93404efb1585ad (diff)
downloadgsoc2013-empathy-435a811e440c3a5a79f504fa6f2850e63673f49a.tar
gsoc2013-empathy-435a811e440c3a5a79f504fa6f2850e63673f49a.tar.gz
gsoc2013-empathy-435a811e440c3a5a79f504fa6f2850e63673f49a.tar.bz2
gsoc2013-empathy-435a811e440c3a5a79f504fa6f2850e63673f49a.tar.lz
gsoc2013-empathy-435a811e440c3a5a79f504fa6f2850e63673f49a.tar.xz
gsoc2013-empathy-435a811e440c3a5a79f504fa6f2850e63673f49a.tar.zst
gsoc2013-empathy-435a811e440c3a5a79f504fa6f2850e63673f49a.zip
Asking for confirmation before losing pending accounts changes.
If an account has pending changes, we now ask for a confirmation before: - Adding a new account - Closing the accounts dialog - Selecting a new account. Those are all options which discard pending changes.
Diffstat (limited to 'libempathy-gtk')
-rw-r--r--libempathy-gtk/empathy-account-widget.c33
-rw-r--r--libempathy-gtk/empathy-account-widget.h5
-rw-r--r--libempathy-gtk/empathy-ui-utils.c28
-rw-r--r--libempathy-gtk/empathy-ui-utils.h6
4 files changed, 67 insertions, 5 deletions
diff --git a/libempathy-gtk/empathy-account-widget.c b/libempathy-gtk/empathy-account-widget.c
index 02ca44cf3..684ff4c9c 100644
--- a/libempathy-gtk/empathy-account-widget.c
+++ b/libempathy-gtk/empathy-account-widget.c
@@ -61,6 +61,9 @@ typedef struct {
gboolean simple;
+ gboolean contains_pending_changes;
+ gboolean original_enabled_checkbox_value;
+
/* An EmpathyAccountWidget can be used to either create an account or
* modify it. When we are creating an account, this member is set to TRUE */
gboolean creating_account;
@@ -97,6 +100,7 @@ account_widget_set_control_buttons_sensitivity (EmpathyAccountWidget *self,
{
gtk_widget_set_sensitive (priv->apply_button, sensitive);
gtk_widget_set_sensitive (priv->cancel_button, sensitive);
+ priv->contains_pending_changes = sensitive;
}
}
@@ -109,10 +113,7 @@ account_widget_handle_control_buttons_sensitivity (EmpathyAccountWidget *self)
is_valid = empathy_account_settings_is_valid (priv->settings);
if (!priv->simple)
- {
- gtk_widget_set_sensitive (priv->apply_button, is_valid);
- gtk_widget_set_sensitive (priv->cancel_button, is_valid);
- }
+ account_widget_set_control_buttons_sensitivity (self, is_valid);
g_signal_emit (self, signals[HANDLE_APPLY], 0, is_valid);
}
@@ -1237,9 +1238,11 @@ do_constructed (GObject *obj)
priv->enabled_checkbox =
gtk_check_button_new_with_label (_("Enabled"));
+ priv->original_enabled_checkbox_value =
+ empathy_account_is_enabled (account);
gtk_toggle_button_set_active (
GTK_TOGGLE_BUTTON (priv->enabled_checkbox),
- empathy_account_is_enabled (account));
+ priv->original_enabled_checkbox_value);
g_object_get (priv->table_common_settings, "n-rows", &nb_rows,
"n-columns", &nb_columns, NULL);
@@ -1388,6 +1391,26 @@ empathy_account_widget_init (EmpathyAccountWidget *self)
/* public methods */
void
+empathy_account_widget_discard_pending_changes
+ (EmpathyAccountWidget *widget)
+{
+ EmpathyAccountWidgetPriv *priv = GET_PRIV (widget);
+
+ empathy_account_settings_discard_changes (priv->settings);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->enabled_checkbox),
+ priv->original_enabled_checkbox_value);
+ priv->contains_pending_changes = FALSE;
+}
+
+gboolean
+empathy_account_widget_contains_pending_changes (EmpathyAccountWidget *widget)
+{
+ EmpathyAccountWidgetPriv *priv = GET_PRIV (widget);
+
+ return priv->contains_pending_changes;
+}
+
+void
empathy_account_widget_handle_params (EmpathyAccountWidget *self,
const gchar *first_widget,
...)
diff --git a/libempathy-gtk/empathy-account-widget.h b/libempathy-gtk/empathy-account-widget.h
index d4111eba2..75214fac8 100644
--- a/libempathy-gtk/empathy-account-widget.h
+++ b/libempathy-gtk/empathy-account-widget.h
@@ -65,6 +65,11 @@ EmpathyAccountWidget * empathy_account_widget_new_for_protocol (
EmpathyAccountSettings *settings,
gboolean simple);
+gboolean empathy_account_widget_contains_pending_changes
+ (EmpathyAccountWidget *widget);
+void empathy_account_widget_discard_pending_changes
+ (EmpathyAccountWidget *widget);
+
G_END_DECLS
#endif /* __EMPATHY_ACCOUNT_WIDGET_H__ */
diff --git a/libempathy-gtk/empathy-ui-utils.c b/libempathy-gtk/empathy-ui-utils.c
index 3089c46ea..e7b8fce74 100644
--- a/libempathy-gtk/empathy-ui-utils.c
+++ b/libempathy-gtk/empathy-ui-utils.c
@@ -1551,3 +1551,31 @@ empathy_receive_file_with_file_chooser (EmpathyFTHandler *handler)
gtk_widget_show (widget);
}
+
+/** empathy_show_yes_no_question_dialog:
+ * @parent: The parent of the message dialog
+ * @message: The question message
+ * @response_callback: The callback connected to the "response" signal of
+ * the message dialog.
+ * @user_data: User data to pass to the @response_callback.
+ *
+ * A simple utility function to create a modal yes/no question message dialog
+ * and hooking to its "response" signal.
+ */
+void empathy_show_yes_no_question_dialog (GtkWindow *parent,
+ gchar *message,
+ GCallback response_callback,
+ gpointer user_data)
+{
+ GtkWidget *message_dialog;
+
+ message_dialog = gtk_message_dialog_new (parent,
+ GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_QUESTION,
+ GTK_BUTTONS_YES_NO,
+ message);
+
+ g_signal_connect (message_dialog, "response", response_callback, user_data);
+
+ gtk_widget_show (message_dialog);
+}
diff --git a/libempathy-gtk/empathy-ui-utils.h b/libempathy-gtk/empathy-ui-utils.h
index 39baeaf41..2d54f987c 100644
--- a/libempathy-gtk/empathy-ui-utils.h
+++ b/libempathy-gtk/empathy-ui-utils.h
@@ -113,6 +113,12 @@ gchar * empathy_make_absolute_url (const gchar *url);
gchar * empathy_make_absolute_url_len (const gchar *url,
guint len);
+/* Message Dialogs */
+void empathy_show_yes_no_question_dialog (GtkWindow *parent,
+ gchar *message,
+ GCallback response_callback,
+ gpointer user_data);
+
G_END_DECLS
#endif /* __EMPATHY_UI_UTILS_H__ */