]> git.0d.be Git - empathy.git/blobdiff - libempathy-gtk/empathy-new-message-dialog.c
Port EmpathyNewMessageDialog to new API
[empathy.git] / libempathy-gtk / empathy-new-message-dialog.c
index 2c88f38f90eeb8896a110981cbd7a52d5a373de7..f6eb46a5fccaa674b74986a5d016651706f2c66d 100644 (file)
 #include <stdlib.h>
 
 #include <gtk/gtk.h>
-#include <glade/glade.h>
-#include <glib/gi18n.h>
+#include <glib/gi18n-lib.h>
 
 #include <libmissioncontrol/mc-account.h>
 #include <libmissioncontrol/mission-control.h>
 
+#include <libempathy/empathy-call-factory.h>
 #include <libempathy/empathy-contact-factory.h>
 #include <libempathy/empathy-contact-manager.h>
 #include <libempathy/empathy-dispatcher.h>
@@ -175,7 +175,7 @@ new_message_dialog_response_cb (GtkWidget               *widget,
 
        account = empathy_account_chooser_get_account (EMPATHY_ACCOUNT_CHOOSER (dialog->account_chooser));
        id = gtk_entry_get_text (GTK_ENTRY (dialog->entry_id));
-       if (!account || G_STR_EMPTY (id)) {
+       if (!account || EMP_STR_EMPTY (id)) {
                if (account) {
                        g_object_unref (account);
                }
@@ -184,10 +184,20 @@ new_message_dialog_response_cb (GtkWidget               *widget,
        }
 
        if (response == 1) {
-               empathy_dispatcher_call_with_contact_id (account, id);
-       }
-       else if (response == 2) {
-               empathy_dispatcher_chat_with_contact_id (account, id);
+               EmpathyContactFactory *factory;
+               EmpathyContact *contact;
+               EmpathyCallFactory *call_factory;
+
+               factory = empathy_contact_factory_dup_singleton ();
+               contact = empathy_contact_factory_get_from_id (factory, account, id);
+
+               call_factory = empathy_call_factory_get();
+               empathy_call_factory_new_call (call_factory, contact);
+
+               g_object_unref (contact);
+               g_object_unref (factory);
+       } else if (response == 2) {
+               empathy_dispatcher_chat_with_contact_id (account, id, NULL, NULL);
        }
 
        g_object_unref (account);
@@ -202,7 +212,7 @@ new_message_change_state_button_cb  (GtkEditable             *editable,
        gboolean     sensitive;
 
        id = gtk_entry_get_text (GTK_ENTRY (editable));
-       sensitive = !G_STR_EMPTY (id);
+       sensitive = !EMP_STR_EMPTY (id);
        
        gtk_widget_set_sensitive (dialog->button_chat, sensitive);
        gtk_widget_set_sensitive (dialog->button_call, sensitive);
@@ -220,7 +230,7 @@ GtkWidget *
 empathy_new_message_dialog_show (GtkWindow *parent)
 {
        static EmpathyNewMessageDialog *dialog = NULL;
-       GladeXML                       *glade;
+       GtkBuilder                     *gui;
        gchar                          *filename;
        GtkEntryCompletion             *completion;
        GtkListStore                   *model;
@@ -233,13 +243,11 @@ empathy_new_message_dialog_show (GtkWindow *parent)
        dialog = g_new0 (EmpathyNewMessageDialog, 1);
 
        /* create a contact manager */
-       dialog->contact_manager = empathy_contact_manager_new ();
+       dialog->contact_manager = empathy_contact_manager_dup_singleton ();
 
-       filename = empathy_file_lookup ("empathy-new-message-dialog.glade",
+       filename = empathy_file_lookup ("empathy-new-message-dialog.ui",
                                        "libempathy-gtk");
-       glade = empathy_glade_get_file (filename,
-                                       "new_message_dialog",
-                                       NULL,
+       gui = empathy_builder_get_file (filename,
                                        "new_message_dialog", &dialog->dialog,
                                        "table_contact", &dialog->table_contact,
                                        "entry_id", &dialog->entry_id,
@@ -263,7 +271,7 @@ empathy_new_message_dialog_show (GtkWindow *parent)
        g_object_unref(completion);
        g_object_unref(model);
 
-       empathy_glade_connect (glade, dialog,
+       empathy_builder_connect (gui, dialog,
                               "new_message_dialog", "destroy", new_message_dialog_destroy_cb,
                               "new_message_dialog", "response", new_message_dialog_response_cb,
                               "entry_id", "changed", new_message_change_state_button_cb,
@@ -271,7 +279,7 @@ empathy_new_message_dialog_show (GtkWindow *parent)
 
        g_object_add_weak_pointer (G_OBJECT (dialog->dialog), (gpointer) &dialog);
 
-       g_object_unref (glade);
+       g_object_unref (gui);
 
        /* Create account chooser */
        dialog->account_chooser = empathy_account_chooser_new ();
@@ -300,4 +308,3 @@ empathy_new_message_dialog_show (GtkWindow *parent)
 
        return dialog->dialog;
 }
-