From 887408a6af57e71c5c3ed04eb8c442307e4151d9 Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Sun, 2 Dec 2007 14:05:51 +0000 Subject: Squashed commit of the following: commit a54ce7de2fc09f717f185fbc9b1d29e28cdcc2e7 Author: Xavier Claessens Date: Sun Dec 2 14:41:27 2007 +0100 Implement New Message on status icon menu too. commit f98dae2e18348db82f1460d4f8fb6ff49dc5fbc2 Author: Xavier Claessens Date: Sat Dec 1 00:49:56 2007 +0100 New message dialog svn path=/trunk/; revision=453 --- libempathy-gtk/Makefile.am | 9 +- libempathy-gtk/empathy-main-window.c | 3 +- libempathy-gtk/empathy-new-message-dialog.c | 136 ++++++++++++++++++++++++ libempathy-gtk/empathy-new-message-dialog.glade | 110 +++++++++++++++++++ libempathy-gtk/empathy-new-message-dialog.h | 33 ++++++ libempathy-gtk/empathy-status-icon.c | 3 +- 6 files changed, 289 insertions(+), 5 deletions(-) create mode 100644 libempathy-gtk/empathy-new-message-dialog.c create mode 100644 libempathy-gtk/empathy-new-message-dialog.glade create mode 100644 libempathy-gtk/empathy-new-message-dialog.h 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 + */ + +#include + +#include +#include + +#include +#include +#include + +#include +#include + +#include +#include + +#include + +#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 @@ + + + + + + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 5 + New message + False + GTK_WIN_POS_CENTER_ON_PARENT + GDK_WINDOW_TYPE_HINT_DIALOG + False + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 2 + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 2 + 2 + 6 + 6 + + + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + + + 1 + 2 + 1 + 2 + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 0 + Contact ID: + + + 1 + 2 + GTK_FILL + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 0 + Account: + + + GTK_FILL + + + + + + + + 1 + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + GTK_BUTTONBOX_END + + + True + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + gtk-cancel + True + -6 + + + + + True + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + gtk-ok + True + -5 + + + 1 + + + + + False + GTK_PACK_END + + + + + + 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 + */ + +#ifndef __EMPATHY_NEW_MESSAGE_DIALOG_H__ +#define __EMPATHY_NEW_MESSAGE_DIALOG_H__ + +#include + +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 -- cgit v1.2.3