]> git.0d.be Git - empathy.git/blobdiff - src/empathy-new-chatroom-dialog.c
Updated Polish translation
[empathy.git] / src / empathy-new-chatroom-dialog.c
index fcbfc6a4a8ec202546aae4b261e970ca9a0df5d1..a2f3b4be943c382492f4aae4589ec42db4304648 100644 (file)
@@ -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);
        }
 
@@ -356,12 +360,35 @@ new_chatroom_dialog_model_add_columns (EmpathyNewChatroomDialog *dialog)
        gtk_tree_view_append_column (view, column);
 }
 
+static void
+update_join_button_sensitivity (EmpathyNewChatroomDialog *dialog)
+{
+       const gchar           *room;
+       gboolean               sensitive = FALSE;
+
+
+       room = gtk_entry_get_text (GTK_ENTRY (dialog->entry_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
 new_chatroom_dialog_update_widgets (EmpathyNewChatroomDialog *dialog)
 {
        EmpathyAccountChooser *account_chooser;
        const gchar           *protocol;
-       const gchar           *room;
 
        account_chooser = EMPATHY_ACCOUNT_CHOOSER (dialog->account_chooser);
 
@@ -386,13 +413,24 @@ new_chatroom_dialog_update_widgets (EmpathyNewChatroomDialog *dialog)
                gtk_widget_set_sensitive (dialog->entry_server, TRUE);
        }
 
-       room = gtk_entry_get_text (GTK_ENTRY (dialog->entry_room));
-       gtk_widget_set_sensitive (dialog->button_join, !EMP_STR_EMPTY (room));
+       update_join_button_sensitivity (dialog);
 
        /* Final set up of the dialog */
        gtk_widget_grab_focus (dialog->entry_room);
 }
 
+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_sensitivity (self);
+}
+
 static void
 new_chatroom_dialog_account_changed_cb (GtkComboBox             *combobox,
                                        EmpathyNewChatroomDialog *dialog)
@@ -410,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);
        }
 
@@ -418,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) {
@@ -492,9 +534,9 @@ new_chatroom_dialog_new_room_cb (EmpathyTpRoomlist        *room_list,
        selection = gtk_tree_view_get_selection (view);
        store = GTK_LIST_STORE (dialog->model);
        members = g_strdup_printf ("%d", empathy_chatroom_get_members_count (chatroom));
-       tooltip = g_strdup_printf (C_("Room/Join's roomlist tooltip. Parameters"
-               "are a channel name, yes/no, yes/no and a number.",
-               "<b>%s</b>\nInvite required: %s\nPassword required: %s\nMembers: %s"),
+       /* Translators: Room/Join's roomlist tooltip. Parameters are a channel name,
+       yes/no, yes/no and a number. */
+       tooltip = g_strdup_printf (_("<b>%s</b>\nInvite required: %s\nPassword required: %s\nMembers: %s"),
                empathy_chatroom_get_name (chatroom),
                empathy_chatroom_get_invite_only (chatroom) ? _("Yes") : _("No"),
                empathy_chatroom_get_need_password (chatroom) ? _("Yes") : _("No"),
@@ -632,10 +674,8 @@ new_chatroom_dialog_entry_changed_cb (GtkWidget                *entry,
                                      EmpathyNewChatroomDialog *dialog)
 {
        if (entry == dialog->entry_room) {
-               const gchar *room;
+               update_join_button_sensitivity (dialog);
 
-               room = gtk_entry_get_text (GTK_ENTRY (dialog->entry_room));
-               gtk_widget_set_sensitive (dialog->button_join, !EMP_STR_EMPTY (room));
                /* FIXME: Select the room in the list */
        }
 }