1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
3 * Copyright (C) 2007 Collabora Ltd.
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 * Authors: Xavier Claessens <xclaesse@gmail.com>
28 #include <glade/glade.h>
29 #include <glib/gi18n.h>
31 #include <libmissioncontrol/mc-account.h>
32 #include <libmissioncontrol/mission-control.h>
34 #include <libempathy/empathy-debug.h>
35 #include <libempathy/empathy-utils.h>
37 #include <libempathy-gtk/empathy-ui-utils.h>
39 #include "empathy-new-message-dialog.h"
40 #include "empathy-account-chooser.h"
42 #define DEBUG_DOMAIN "NewMessageDialog"
46 GtkWidget *table_contact;
47 GtkWidget *account_chooser;
49 } EmpathyNewMessageDialog;
53 new_message_dialog_response_cb (GtkWidget *widget,
55 EmpathyNewMessageDialog *dialog)
57 if (response == GTK_RESPONSE_OK) {
62 account = empathy_account_chooser_get_account (EMPATHY_ACCOUNT_CHOOSER (dialog->account_chooser));
63 id = gtk_entry_get_text (GTK_ENTRY (dialog->entry_id));
64 mc = empathy_mission_control_new ();
66 mission_control_request_channel_with_string_handle (mc,
68 TP_IFACE_CHANNEL_TYPE_TEXT,
70 TP_HANDLE_TYPE_CONTACT,
73 g_object_unref (account);
76 gtk_widget_destroy (widget);
80 new_message_dialog_destroy_cb (GtkWidget *widget,
81 EmpathyNewMessageDialog *dialog)
87 empathy_new_message_dialog_show (GtkWindow *parent)
89 static EmpathyNewMessageDialog *dialog = NULL;
93 gtk_window_present (GTK_WINDOW (dialog->dialog));
94 return dialog->dialog;
97 dialog = g_new0 (EmpathyNewMessageDialog, 1);
99 glade = empathy_glade_get_file ("empathy-new-message-dialog.glade",
100 "new_message_dialog",
102 "new_message_dialog", &dialog->dialog,
103 "table_contact", &dialog->table_contact,
104 "entry_id", &dialog->entry_id,
107 empathy_glade_connect (glade,
109 "new_message_dialog", "destroy", new_message_dialog_destroy_cb,
110 "new_message_dialog", "response", new_message_dialog_response_cb,
113 g_object_add_weak_pointer (G_OBJECT (dialog->dialog), (gpointer) &dialog);
115 g_object_unref (glade);
117 /* Create account chooser */
118 dialog->account_chooser = empathy_account_chooser_new ();
119 gtk_table_attach_defaults (GTK_TABLE (dialog->table_contact),
120 dialog->account_chooser,
122 empathy_account_chooser_set_filter (EMPATHY_ACCOUNT_CHOOSER (dialog->account_chooser),
123 empathy_account_chooser_filter_is_connected,
125 gtk_widget_show (dialog->account_chooser);
128 gtk_window_set_transient_for (GTK_WINDOW (dialog->dialog),
129 GTK_WINDOW (parent));
132 gtk_widget_show (dialog->dialog);
134 return dialog->dialog;