return v;
}
-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)
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);
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,
struct _EmpathyContactSelectorDialogClass {
GtkDialogClass parent_class;
- void (*got_response) (EmpathyContactSelectorDialog *self,
- TpConnection *connection,
- const gchar *contact_id);
-
gboolean (*account_filter) (EmpathyContactSelectorDialog *self,
TpAccount *account);
};
};
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);
}
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. */
got_contact_cb, GUINT_TO_POINTER (video), NULL, NULL);
g_object_unref (factory);
+
+out:
+ gtk_widget_destroy (GTK_WIDGET (dialog));
}
static gboolean
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;
}
/**
*/
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
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;
}
/**