[empathy] new-chatroom-dialog: unsensitive the join button when account is disconnected
- From: Guillaume Desmottes <gdesmott src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [empathy] new-chatroom-dialog: unsensitive the join button when account is disconnected
- Date: Tue, 1 Dec 2009 12:47:15 +0000 (UTC)
commit d7a092467227ecdcfb5173a1f26a6207606c2154
Author: Guillaume Desmottes <guillaume desmottes collabora co uk>
Date: Tue Dec 1 12:03:42 2009 +0000
new-chatroom-dialog: unsensitive the join button when account is disconnected
Trying to join a room with a not connected account leads to crash (#603393).
src/empathy-new-chatroom-dialog.c | 37 ++++++++++++++++++++++++++++++++++++-
1 files changed, 36 insertions(+), 1 deletions(-)
---
diff --git a/src/empathy-new-chatroom-dialog.c b/src/empathy-new-chatroom-dialog.c
index 663bd02..4a9f8d5 100644
--- a/src/empathy-new-chatroom-dialog.c
+++ b/src/empathy-new-chatroom-dialog.c
@@ -50,6 +50,9 @@ typedef struct {
EmpathyTpRoomlist *room_list;
/* Currently selected account */
TpAccount *account;
+ /* Signal id of the "status-changed" signal connected on the currently
+ * selected account */
+ gulong status_changed_id;
GtkWidget *window;
GtkWidget *vbox_widgets;
@@ -242,6 +245,7 @@ new_chatroom_dialog_destroy_cb (GtkWidget *widget,
g_object_unref (dialog->model);
if (dialog->account != NULL) {
+ g_signal_handler_disconnect (dialog->account, dialog->status_changed_id);
g_object_unref (dialog->account);
}
@@ -360,9 +364,24 @@ static void
update_join_button_sensitivy (EmpathyNewChatroomDialog *dialog)
{
const gchar *room;
+ gboolean sensitive = FALSE;
+
room = gtk_entry_get_text (GTK_ENTRY (dialog->entry_room));
- gtk_widget_set_sensitive (dialog->button_join, !EMP_STR_EMPTY (room));
+ if (EMP_STR_EMPTY (room))
+ goto out;
+
+ if (dialog->account == NULL)
+ goto out;
+
+ if (tp_account_get_connection_status (dialog->account, NULL) !=
+ TP_CONNECTION_STATUS_CONNECTED)
+ goto out;
+
+ sensitive = TRUE;
+
+out:
+ gtk_widget_set_sensitive (dialog->button_join, sensitive);
}
static void
@@ -401,6 +420,18 @@ new_chatroom_dialog_update_widgets (EmpathyNewChatroomDialog *dialog)
}
static void
+account_status_changed_cb (TpAccount *account,
+ guint old_status,
+ guint new_status,
+ guint reason,
+ gchar *dbus_error_name,
+ GHashTable *details,
+ EmpathyNewChatroomDialog *self)
+{
+ update_join_button_sensitivy (self);
+}
+
+static void
new_chatroom_dialog_account_changed_cb (GtkComboBox *combobox,
EmpathyNewChatroomDialog *dialog)
{
@@ -417,6 +448,7 @@ new_chatroom_dialog_account_changed_cb (GtkComboBox *combobox,
new_chatroom_dialog_model_clear (dialog);
if (dialog->account != NULL) {
+ g_signal_handler_disconnect (dialog->account, dialog->status_changed_id);
g_object_unref (dialog->account);
}
@@ -425,6 +457,9 @@ new_chatroom_dialog_account_changed_cb (GtkComboBox *combobox,
if (dialog->account == NULL)
goto out;
+ dialog->status_changed_id = g_signal_connect (dialog->account,
+ "status-changed", G_CALLBACK (account_status_changed_cb), dialog);
+
dialog->room_list = empathy_tp_roomlist_new (dialog->account);
if (dialog->room_list) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]