diff options
author | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2009-12-01 20:03:42 +0800 |
---|---|---|
committer | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2009-12-01 20:05:41 +0800 |
commit | d7a092467227ecdcfb5173a1f26a6207606c2154 (patch) | |
tree | 6ea4fdc91278ab5816fbb0ec1cc0af9ebfde0668 /src | |
parent | 63824875083611f8503deaff302887dd6c47a603 (diff) | |
download | gsoc2013-empathy-d7a092467227ecdcfb5173a1f26a6207606c2154.tar gsoc2013-empathy-d7a092467227ecdcfb5173a1f26a6207606c2154.tar.gz gsoc2013-empathy-d7a092467227ecdcfb5173a1f26a6207606c2154.tar.bz2 gsoc2013-empathy-d7a092467227ecdcfb5173a1f26a6207606c2154.tar.lz gsoc2013-empathy-d7a092467227ecdcfb5173a1f26a6207606c2154.tar.xz gsoc2013-empathy-d7a092467227ecdcfb5173a1f26a6207606c2154.tar.zst gsoc2013-empathy-d7a092467227ecdcfb5173a1f26a6207606c2154.zip |
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).
Diffstat (limited to 'src')
-rw-r--r-- | 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 663bd026a..4a9f8d557 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) { |