diff options
-rw-r--r-- | libempathy-gtk/empathy-contact-selector-dialog.c | 56 | ||||
-rw-r--r-- | libempathy-gtk/empathy-contact-selector-dialog.h | 7 | ||||
-rw-r--r-- | libempathy-gtk/empathy-new-call-dialog.c | 24 | ||||
-rw-r--r-- | libempathy-gtk/empathy-new-message-dialog.c | 25 |
4 files changed, 65 insertions, 47 deletions
diff --git a/libempathy-gtk/empathy-contact-selector-dialog.c b/libempathy-gtk/empathy-contact-selector-dialog.c index 1f3e21a6d..58e0fff35 100644 --- a/libempathy-gtk/empathy-contact-selector-dialog.c +++ b/libempathy-gtk/empathy-contact-selector-dialog.c @@ -202,34 +202,6 @@ out: } static void -contact_selector_dialog_response_cb (GtkWidget *widget, - gint response, - EmpathyContactSelectorDialog *dialog) -{ - EmpathyContactSelectorDialogPriv *priv = GET_PRIV (dialog); - TpConnection *connection; - const gchar *id; - EmpathyContactSelectorDialogClass *class = \ - EMPATHY_CONTACT_SELECTOR_DIALOG_GET_CLASS (dialog); - - connection = empathy_account_chooser_get_connection ( - EMPATHY_ACCOUNT_CHOOSER (priv->account_chooser)); - id = gtk_entry_get_text (GTK_ENTRY (priv->entry_id)); - if (!connection || EMP_STR_EMPTY (id)) - { - gtk_widget_destroy (widget); - return; - } - - if (response == GTK_RESPONSE_ACCEPT) - { - class->got_response (dialog, connection, id); - } - - gtk_widget_destroy (widget); -} - -static void contact_selector_change_state_button_cb (GtkEditable *editable, EmpathyContactSelectorDialog *dialog) { @@ -331,9 +303,6 @@ empathy_contact_selector_dialog_init (EmpathyContactSelectorDialog *dialog) g_object_unref (completion); g_object_unref (model); - g_signal_connect (dialog, "response", - G_CALLBACK (contact_selector_dialog_response_cb), dialog); - empathy_builder_connect (gui, dialog, "entry_id", "changed", contact_selector_change_state_button_cb, NULL); @@ -435,6 +404,31 @@ empathy_contact_selector_dialog_class_init ( G_PARAM_READWRITE)); } +const gchar * +empathy_contact_selector_dialog_get_selected ( + EmpathyContactSelectorDialog *self, + TpConnection **connection) +{ + EmpathyContactSelectorDialogPriv *priv; + const char *id; + + g_return_val_if_fail (EMPATHY_IS_CONTACT_SELECTOR_DIALOG (self), NULL); + + priv = GET_PRIV (self); + + if (connection) + { + if (priv->show_account_chooser) + *connection = empathy_account_chooser_get_connection ( + EMPATHY_ACCOUNT_CHOOSER (priv->account_chooser)); + else + *connection = NULL; + } + + id = gtk_entry_get_text (GTK_ENTRY (priv->entry_id)); + return id; +} + void empathy_contact_selector_dialog_set_show_account_chooser ( EmpathyContactSelectorDialog *self, diff --git a/libempathy-gtk/empathy-contact-selector-dialog.h b/libempathy-gtk/empathy-contact-selector-dialog.h index 255d37ee1..d8a698ab5 100644 --- a/libempathy-gtk/empathy-contact-selector-dialog.h +++ b/libempathy-gtk/empathy-contact-selector-dialog.h @@ -38,10 +38,6 @@ typedef struct _EmpathyContactSelectorDialogClass \ struct _EmpathyContactSelectorDialogClass { GtkDialogClass parent_class; - void (*got_response) (EmpathyContactSelectorDialog *self, - TpConnection *connection, - const gchar *contact_id); - gboolean (*account_filter) (EmpathyContactSelectorDialog *self, TpAccount *account); }; @@ -55,6 +51,9 @@ struct _EmpathyContactSelectorDialog { }; GType empathy_contact_selector_dialog_get_type (void); +const gchar *empathy_contact_selector_dialog_get_selected ( + EmpathyContactSelectorDialog *self, + TpConnection **connection); void empathy_contact_selector_dialog_set_show_account_chooser ( EmpathyContactSelectorDialog *self, gboolean show_account_chooser); diff --git a/libempathy-gtk/empathy-new-call-dialog.c b/libempathy-gtk/empathy-new-call-dialog.c index 2437b4978..1a171af5a 100644 --- a/libempathy-gtk/empathy-new-call-dialog.c +++ b/libempathy-gtk/empathy-new-call-dialog.c @@ -90,13 +90,20 @@ got_contact_cb (EmpathyTpContactFactory *factory, } static void -empathy_new_call_dialog_got_response (EmpathyContactSelectorDialog *dialog, - TpConnection *connection, - const gchar *contact_id) +empathy_new_call_dialog_response (GtkDialog *dialog, int response_id) { EmpathyNewCallDialogPriv *priv = GET_PRIV (dialog); EmpathyTpContactFactory *factory; gboolean video; + TpConnection *connection; + const gchar *contact_id; + + if (response_id != GTK_RESPONSE_ACCEPT) goto out; + + contact_id = empathy_contact_selector_dialog_get_selected ( + EMPATHY_CONTACT_SELECTOR_DIALOG (dialog), &connection); + + if (EMP_STR_EMPTY (contact_id) || connection == NULL) goto out; /* check if video is enabled now because the dialog will be destroyed once * we return from this function. */ @@ -107,6 +114,9 @@ empathy_new_call_dialog_got_response (EmpathyContactSelectorDialog *dialog, got_contact_cb, GUINT_TO_POINTER (video), NULL, NULL); g_object_unref (factory); + +out: + gtk_widget_destroy (GTK_WIDGET (dialog)); } static gboolean @@ -204,15 +214,17 @@ empathy_new_call_dialog_class_init ( EmpathyNewCallDialogClass *class) { GObjectClass *object_class = G_OBJECT_CLASS (class); - EmpathyContactSelectorDialogClass *dialog_class = \ + GtkDialogClass *dialog_class = GTK_DIALOG_CLASS (class); + EmpathyContactSelectorDialogClass *selector_dialog_class = \ EMPATHY_CONTACT_SELECTOR_DIALOG_CLASS (class); g_type_class_add_private (class, sizeof (EmpathyNewCallDialogPriv)); object_class->constructor = empathy_new_call_dialog_constructor; - dialog_class->got_response = empathy_new_call_dialog_got_response; - dialog_class->account_filter = empathy_new_call_dialog_account_filter; + dialog_class->response = empathy_new_call_dialog_response; + + selector_dialog_class->account_filter = empathy_new_call_dialog_account_filter; } /** diff --git a/libempathy-gtk/empathy-new-message-dialog.c b/libempathy-gtk/empathy-new-message-dialog.c index 3b60b63d5..338da2760 100644 --- a/libempathy-gtk/empathy-new-message-dialog.c +++ b/libempathy-gtk/empathy-new-message-dialog.c @@ -58,11 +58,22 @@ G_DEFINE_TYPE(EmpathyNewMessageDialog, empathy_new_message_dialog, */ static void -empathy_new_message_dialog_got_response (EmpathyContactSelectorDialog *dialog, - TpConnection *connection, - const gchar *contact_id) +empathy_new_message_dialog_response (GtkDialog *dialog, int response_id) { + TpConnection *connection; + const gchar *contact_id; + + if (response_id != GTK_RESPONSE_ACCEPT) goto out; + + contact_id = empathy_contact_selector_dialog_get_selected ( + EMPATHY_CONTACT_SELECTOR_DIALOG (dialog), &connection); + + if (EMP_STR_EMPTY (contact_id) || connection == NULL) goto out; + empathy_dispatcher_chat_with_contact_id (connection, contact_id, NULL, NULL); + +out: + gtk_widget_destroy (GTK_WIDGET (dialog)); } static gboolean @@ -151,13 +162,15 @@ empathy_new_message_dialog_class_init ( EmpathyNewMessageDialogClass *class) { GObjectClass *object_class = G_OBJECT_CLASS (class); - EmpathyContactSelectorDialogClass *dialog_class = \ + GtkDialogClass *dialog_class = GTK_DIALOG_CLASS (class); + EmpathyContactSelectorDialogClass *selector_dialog_class = \ EMPATHY_CONTACT_SELECTOR_DIALOG_CLASS (class); object_class->constructor = empathy_new_message_dialog_constructor; - dialog_class->got_response = empathy_new_message_dialog_got_response; - dialog_class->account_filter = empathy_new_message_account_filter; + dialog_class->response = empathy_new_message_dialog_response; + + selector_dialog_class->account_filter = empathy_new_message_account_filter; } /** |