aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libempathy-gtk/Makefile.am9
-rw-r--r--libempathy-gtk/empathy-main-window.c3
-rw-r--r--libempathy-gtk/empathy-new-message-dialog.c136
-rw-r--r--libempathy-gtk/empathy-new-message-dialog.glade110
-rw-r--r--libempathy-gtk/empathy-new-message-dialog.h33
-rw-r--r--libempathy-gtk/empathy-status-icon.c3
6 files changed, 289 insertions, 5 deletions
diff --git a/libempathy-gtk/Makefile.am b/libempathy-gtk/Makefile.am
index 71ec03bcd..2e9966536 100644
--- a/libempathy-gtk/Makefile.am
+++ b/libempathy-gtk/Makefile.am
@@ -50,7 +50,8 @@ libempathy_gtk_la_SOURCES = \
empathy-call-window.c \
empathy-avatar-chooser.c \
empathy-avatar-image.c \
- empathy-ui-utils.c
+ empathy-ui-utils.c \
+ empathy-new-message-dialog.c
# do not distribute generated files
nodist_libempathy_gtk_la_SOURCES =\
@@ -102,7 +103,8 @@ libempathy_gtk_headers = \
empathy-call-window.h \
empathy-avatar-chooser.h \
empathy-avatar-image.h \
- empathy-ui-utils.h
+ empathy-ui-utils.h \
+ empathy-new-message-dialog.h
libempathy_gtk_includedir = $(includedir)/libempathy-gtk/
libempathy_gtk_include_HEADERS = \
@@ -127,7 +129,8 @@ glade_DATA = \
empathy-spell-dialog.glade \
empathy-log-window.glade \
empathy-call-window.glade \
- empathy-chat.glade
+ empathy-chat.glade \
+ empathy-new-message-dialog.glade
empathy-gtk-enum-types.h: stamp-empathy-gtk-enum-types.h
@true
diff --git a/libempathy-gtk/empathy-main-window.c b/libempathy-gtk/empathy-main-window.c
index 57e866e87..cde7dbf67 100644
--- a/libempathy-gtk/empathy-main-window.c
+++ b/libempathy-gtk/empathy-main-window.c
@@ -53,6 +53,7 @@
#include "empathy-new-chatroom-dialog.h"
#include "empathy-chatrooms-window.h"
#include "empathy-log-window.h"
+#include "empathy-new-message-dialog.h"
#include "empathy-gtk-enum-types.h"
#define DEBUG_DOMAIN "MainWindow"
@@ -523,7 +524,7 @@ static void
main_window_chat_new_message_cb (GtkWidget *widget,
EmpathyMainWindow *window)
{
- //empathy_new_message_dialog_show (GTK_WINDOW (window->window));
+ empathy_new_message_dialog_show (GTK_WINDOW (window->window));
}
static void
diff --git a/libempathy-gtk/empathy-new-message-dialog.c b/libempathy-gtk/empathy-new-message-dialog.c
new file mode 100644
index 000000000..908f8f16e
--- /dev/null
+++ b/libempathy-gtk/empathy-new-message-dialog.c
@@ -0,0 +1,136 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2007 Collabora Ltd.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Authors: Xavier Claessens <xclaesse@gmail.com>
+ */
+
+#include <config.h>
+
+#include <string.h>
+#include <stdlib.h>
+
+#include <gtk/gtk.h>
+#include <glade/glade.h>
+#include <glib/gi18n.h>
+
+#include <libmissioncontrol/mc-account.h>
+#include <libmissioncontrol/mission-control.h>
+
+#include <libempathy/empathy-debug.h>
+#include <libempathy/empathy-utils.h>
+
+#include <libempathy-gtk/empathy-ui-utils.h>
+
+#include "empathy-new-message-dialog.h"
+#include "empathy-account-chooser.h"
+
+#define DEBUG_DOMAIN "NewMessageDialog"
+
+typedef struct {
+ GtkWidget *dialog;
+ GtkWidget *table_contact;
+ GtkWidget *account_chooser;
+ GtkWidget *entry_id;
+} EmpathyNewMessageDialog;
+
+
+static void
+new_message_dialog_response_cb (GtkWidget *widget,
+ gint response,
+ EmpathyNewMessageDialog *dialog)
+{
+ if (response == GTK_RESPONSE_OK) {
+ MissionControl *mc;
+ McAccount *account;
+ const gchar *id;
+
+ account = empathy_account_chooser_get_account (EMPATHY_ACCOUNT_CHOOSER (dialog->account_chooser));
+ id = gtk_entry_get_text (GTK_ENTRY (dialog->entry_id));
+ mc = empathy_mission_control_new ();
+
+ mission_control_request_channel_with_string_handle (mc,
+ account,
+ TP_IFACE_CHANNEL_TYPE_TEXT,
+ id,
+ TP_HANDLE_TYPE_CONTACT,
+ NULL, NULL);
+ g_object_unref (mc);
+ g_object_unref (account);
+ }
+
+ gtk_widget_destroy (widget);
+}
+
+static void
+new_message_dialog_destroy_cb (GtkWidget *widget,
+ EmpathyNewMessageDialog *dialog)
+{
+ g_free (dialog);
+}
+
+GtkWidget *
+empathy_new_message_dialog_show (GtkWindow *parent)
+{
+ static EmpathyNewMessageDialog *dialog = NULL;
+ GladeXML *glade;
+
+ if (dialog) {
+ gtk_window_present (GTK_WINDOW (dialog->dialog));
+ return dialog->dialog;
+ }
+
+ dialog = g_new0 (EmpathyNewMessageDialog, 1);
+
+ glade = empathy_glade_get_file ("empathy-new-message-dialog.glade",
+ "new_message_dialog",
+ NULL,
+ "new_message_dialog", &dialog->dialog,
+ "table_contact", &dialog->table_contact,
+ "entry_id", &dialog->entry_id,
+ NULL);
+
+ empathy_glade_connect (glade,
+ dialog,
+ "new_message_dialog", "destroy", new_message_dialog_destroy_cb,
+ "new_message_dialog", "response", new_message_dialog_response_cb,
+ NULL);
+
+ g_object_add_weak_pointer (G_OBJECT (dialog->dialog), (gpointer) &dialog);
+
+ g_object_unref (glade);
+
+ /* Create account chooser */
+ dialog->account_chooser = empathy_account_chooser_new ();
+ gtk_table_attach_defaults (GTK_TABLE (dialog->table_contact),
+ dialog->account_chooser,
+ 1, 2, 0, 1);
+ empathy_account_chooser_set_filter (EMPATHY_ACCOUNT_CHOOSER (dialog->account_chooser),
+ empathy_account_chooser_filter_is_connected,
+ NULL);
+ gtk_widget_show (dialog->account_chooser);
+
+ if (parent) {
+ gtk_window_set_transient_for (GTK_WINDOW (dialog->dialog),
+ GTK_WINDOW (parent));
+ }
+
+ gtk_widget_show (dialog->dialog);
+
+ return dialog->dialog;
+}
+
diff --git a/libempathy-gtk/empathy-new-message-dialog.glade b/libempathy-gtk/empathy-new-message-dialog.glade
new file mode 100644
index 000000000..f00814ff5
--- /dev/null
+++ b/libempathy-gtk/empathy-new-message-dialog.glade
@@ -0,0 +1,110 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
+<!--Generated with glade3 3.4.0 on Fri Nov 30 23:14:21 2007 -->
+<glade-interface>
+ <widget class="GtkDialog" id="new_message_dialog">
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="border_width">5</property>
+ <property name="title" translatable="yes">New message</property>
+ <property name="resizable">False</property>
+ <property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property>
+ <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
+ <property name="has_separator">False</property>
+ <child internal-child="vbox">
+ <widget class="GtkVBox" id="dialog-vbox1">
+ <property name="visible">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="spacing">2</property>
+ <child>
+ <widget class="GtkTable" id="table_contact">
+ <property name="visible">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="n_rows">2</property>
+ <property name="n_columns">2</property>
+ <property name="column_spacing">6</property>
+ <property name="row_spacing">6</property>
+ <child>
+ <widget class="GtkEntry" id="entry_id">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ </widget>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="label2">
+ <property name="visible">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Contact ID:</property>
+ </widget>
+ <packing>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="label1">
+ <property name="visible">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Account:</property>
+ </widget>
+ <packing>
+ <property name="x_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ </widget>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child internal-child="action_area">
+ <widget class="GtkHButtonBox" id="dialog-action_area1">
+ <property name="visible">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="layout_style">GTK_BUTTONBOX_END</property>
+ <child>
+ <widget class="GtkButton" id="button1">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="label" translatable="yes">gtk-cancel</property>
+ <property name="use_stock">True</property>
+ <property name="response_id">-6</property>
+ </widget>
+ </child>
+ <child>
+ <widget class="GtkButton" id="button2">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="label" translatable="yes">gtk-ok</property>
+ <property name="use_stock">True</property>
+ <property name="response_id">-5</property>
+ </widget>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="pack_type">GTK_PACK_END</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+ </widget>
+</glade-interface>
diff --git a/libempathy-gtk/empathy-new-message-dialog.h b/libempathy-gtk/empathy-new-message-dialog.h
new file mode 100644
index 000000000..27e461f9b
--- /dev/null
+++ b/libempathy-gtk/empathy-new-message-dialog.h
@@ -0,0 +1,33 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2007 Collabora Ltd.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Authors: Xavier Claessens <xclaesse@gmail.com>
+ */
+
+#ifndef __EMPATHY_NEW_MESSAGE_DIALOG_H__
+#define __EMPATHY_NEW_MESSAGE_DIALOG_H__
+
+#include <gtk/gtkwidget.h>
+
+G_BEGIN_DECLS
+
+GtkWidget *empathy_new_message_dialog_show (GtkWindow *parent);
+
+G_END_DECLS
+
+#endif /* __EMPATHY_NEW_MESSAGE_DIALOG_H__ */
diff --git a/libempathy-gtk/empathy-status-icon.c b/libempathy-gtk/empathy-status-icon.c
index 2cf8dc24b..4421ddc85 100644
--- a/libempathy-gtk/empathy-status-icon.c
+++ b/libempathy-gtk/empathy-status-icon.c
@@ -46,6 +46,7 @@
#include "empathy-ui-utils.h"
#include "empathy-accounts-dialog.h"
#include "empathy-images.h"
+#include "empathy-new-message-dialog.h"
#define GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), \
@@ -528,7 +529,7 @@ status_icon_new_message_cb (GtkWidget *widget,
priv = GET_PRIV (icon);
- //empathy_new_message_dialog_show (GTK_WINDOW (priv->window));
+ empathy_new_message_dialog_show (GTK_WINDOW (priv->window));
}
static void