From df77283dbff9bbd59477a649948bf9c24773bdbb Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Wed, 6 Jun 2007 16:29:00 +0000 Subject: New dialog: EmpathySubscriptionDialog. It uses EmpathyContactWidget to 2007-06-06 Xavier Claessens * libempathy-gtk/empathy-status-icon.c: * libempathy-gtk/empathy-subscription-dialog.glade: * libempathy-gtk/empathy-contact-widget.c: * libempathy-gtk/gossip-contact-list-view.c: * libempathy-gtk/empathy-subscription-dialog.c: * libempathy-gtk/Makefile.am: * libempathy-gtk/empathy-subscription-dialog.h: * libempathy/empathy-tp-contact-list.c: New dialog: EmpathySubscriptionDialog. It uses EmpathyContactWidget to display information about the contact who wants to get your presence. This dialog appears when clicking on the status icon when it blinks. You can also remove contacts when right-click on it in the roster. svn path=/trunk/; revision=125 --- libempathy-gtk/Makefile.am | 2 + libempathy-gtk/empathy-contact-widget.c | 14 ++ libempathy-gtk/empathy-status-icon.c | 4 +- libempathy-gtk/empathy-subscription-dialog.c | 111 +++++++++++ libempathy-gtk/empathy-subscription-dialog.glade | 244 +++++++++++++++++++++++ libempathy-gtk/empathy-subscription-dialog.h | 37 ++++ libempathy-gtk/gossip-contact-list-view.c | 21 +- 7 files changed, 424 insertions(+), 9 deletions(-) create mode 100644 libempathy-gtk/empathy-subscription-dialog.c create mode 100644 libempathy-gtk/empathy-subscription-dialog.glade create mode 100644 libempathy-gtk/empathy-subscription-dialog.h (limited to 'libempathy-gtk') diff --git a/libempathy-gtk/Makefile.am b/libempathy-gtk/Makefile.am index ebee9a566..e2c02eddd 100644 --- a/libempathy-gtk/Makefile.am +++ b/libempathy-gtk/Makefile.am @@ -13,6 +13,7 @@ libempathy_gtk_la_SOURCES = \ empathy-main-window.c empathy-main-window.h \ empathy-status-icon.c empathy-status-icon.h \ empathy-contact-widget.c empathy-contact-widget.h \ + empathy-subscription-dialog.c empathy-subscription-dialog.c \ gossip-accounts-dialog.c gossip-accounts-dialog.h \ gossip-account-widget-generic.c gossip-account-widget-generic.h \ gossip-account-widget-jabber.c gossip-account-widget-jabber.h \ @@ -50,6 +51,7 @@ glade_DATA = \ empathy-main-window.glade \ empathy-status-icon.glade \ empathy-contact-widget.glade \ + empathy-subscription-dialog.glade \ gossip-preferences.glade \ gossip-presence-chooser.glade \ gossip-accounts-dialog.glade \ diff --git a/libempathy-gtk/empathy-contact-widget.c b/libempathy-gtk/empathy-contact-widget.c index bb12283d4..a900ce119 100644 --- a/libempathy-gtk/empathy-contact-widget.c +++ b/libempathy-gtk/empathy-contact-widget.c @@ -211,6 +211,19 @@ static void contact_widget_destroy_cb (GtkWidget *widget, EmpathyContactWidget *information) { + g_signal_handlers_disconnect_by_func (information->contact, + contact_widget_name_notify_cb, + information); + g_signal_handlers_disconnect_by_func (information->contact, + contact_widget_presence_notify_cb, + information); + g_signal_handlers_disconnect_by_func (information->contact, + contact_widget_avatar_notify_cb, + information); + g_signal_handlers_disconnect_by_func (information->contact, + contact_widget_groups_notify_cb, + information); + g_object_unref (information->contact); g_slice_free (EmpathyContactWidget, information); } @@ -384,6 +397,7 @@ contact_widget_groups_populate_data (EmpathyContactWidget *information) manager = empathy_contact_manager_new (); all_groups = empathy_contact_manager_get_groups (manager); groups = gossip_contact_get_groups (information->contact); + g_object_unref (manager); for (l = groups; l; l = l->next) { const gchar *group_str; diff --git a/libempathy-gtk/empathy-status-icon.c b/libempathy-gtk/empathy-status-icon.c index 17fa9e5dc..d6e4cbe24 100644 --- a/libempathy-gtk/empathy-status-icon.c +++ b/libempathy-gtk/empathy-status-icon.c @@ -39,7 +39,7 @@ #include #include "empathy-status-icon.h" -#include "empathy-contact-widget.h" +#include "empathy-subscription-dialog.h" #include "gossip-presence-chooser.h" #include "gossip-preferences.h" #include "gossip-ui-utils.h" @@ -464,7 +464,7 @@ status_icon_event_subscribe_cb (StatusIconEvent *event) contact = GOSSIP_CONTACT (event->user_data); - //empathy_subscription_dialog_show (contact); + empathy_subscription_dialog_show (contact, NULL); g_object_unref (contact); } diff --git a/libempathy-gtk/empathy-subscription-dialog.c b/libempathy-gtk/empathy-subscription-dialog.c new file mode 100644 index 000000000..cd0508080 --- /dev/null +++ b/libempathy-gtk/empathy-subscription-dialog.c @@ -0,0 +1,111 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* + * Copyright (C) 2007 Collabora Ltd. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program 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 + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Authors: Xavier Claessens + */ + +#include + +#include +#include + +#include +#include +#include + +#include +#include + +#include "empathy-subscription-dialog.h" +#include "empathy-contact-widget.h" +#include "gossip-ui-utils.h" + +static GHashTable *dialogs = NULL; + +static void +subscription_dialog_response_cb (GtkDialog *dialog, + gint response, + GossipContact *contact) +{ + EmpathyContactManager *manager; + + manager = empathy_contact_manager_new (); + + if (response == GTK_RESPONSE_YES) { + empathy_contact_list_add (EMPATHY_CONTACT_LIST (manager), + contact, + _("I would like to add you to my contact list.")); + } + else if (response == GTK_RESPONSE_NO) { + empathy_contact_list_remove (EMPATHY_CONTACT_LIST (manager), + contact, + _("Sorry, I don't want you in my contact list.")); + } + + g_hash_table_remove (dialogs, contact); + g_object_unref (manager); +} + +void +empathy_subscription_dialog_show (GossipContact *contact, + GtkWindow *parent) +{ + GtkWidget *dialog; + GtkWidget *hbox_subscription; + + g_return_if_fail (GOSSIP_IS_CONTACT (contact)); + + if (!dialogs) { + dialogs = g_hash_table_new_full (gossip_contact_hash, + gossip_contact_equal, + (GDestroyNotify) g_object_unref, + (GDestroyNotify) gtk_widget_destroy); + } + + dialog = g_hash_table_lookup (dialogs, contact); + if (dialog) { + gtk_window_present (GTK_WINDOW (dialog)); + return; + } + + gossip_glade_get_file_simple ("empathy-subscription-dialog.glade", + "subscription_request_dialog", + NULL, + "subscription_request_dialog", &dialog, + "hbox_subscription", &hbox_subscription, + NULL); + + g_signal_connect (dialog, "response", + G_CALLBACK (subscription_dialog_response_cb), + contact); + + g_hash_table_insert (dialogs, g_object_ref (contact), dialog); + + gtk_box_pack_end (GTK_BOX (hbox_subscription), + empathy_contact_widget_new (contact), + TRUE, TRUE, + 0); + + if (parent) { + gtk_window_set_transient_for (GTK_WINDOW (dialog), parent); + } + + gtk_widget_show (dialog); +} + diff --git a/libempathy-gtk/empathy-subscription-dialog.glade b/libempathy-gtk/empathy-subscription-dialog.glade new file mode 100644 index 000000000..e43b8ea42 --- /dev/null +++ b/libempathy-gtk/empathy-subscription-dialog.glade @@ -0,0 +1,244 @@ + + + + + + + 5 + Subscription Request + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_CENTER_ON_PARENT + False + False + False + True + False + False + GDK_WINDOW_TYPE_HINT_DIALOG + GDK_GRAVITY_NORTH_WEST + True + False + False + + + + True + False + 2 + + + + True + GTK_BUTTONBOX_END + + + + True + True + True + Decide _Later + True + GTK_RELIEF_NORMAL + True + -6 + + + + + + True + True + True + GTK_RELIEF_NORMAL + True + -9 + + + + True + 0.5 + 0.5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + True + False + 2 + + + + True + gtk-no + 4 + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + _Deny + True + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + False + + + + + + + + + + + + True + True + True + True + GTK_RELIEF_NORMAL + True + -8 + + + + True + 0.5 + 0.5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + True + False + 2 + + + + True + gtk-yes + 4 + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + _Accept + True + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + False + + + + + + + + + + + 0 + False + True + GTK_PACK_END + + + + + + 5 + True + False + 12 + + + + True + gtk-dialog-question + 6 + 0.5 + 0 + 0 + 0 + + + 0 + False + False + + + + + + + + + 0 + True + True + + + + + + + diff --git a/libempathy-gtk/empathy-subscription-dialog.h b/libempathy-gtk/empathy-subscription-dialog.h new file mode 100644 index 000000000..0488722e6 --- /dev/null +++ b/libempathy-gtk/empathy-subscription-dialog.h @@ -0,0 +1,37 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* + * Copyright (C) 2007 Collabora Ltd. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program 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 + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Authors: Xavier Claessens + */ + +#ifndef __EMPATHY_SUBSCRIPTION_DIALOG_H__ +#define __EMPATHY_SUBSCRIPTION_DIALOG_H__ + +#include + +#include + +G_BEGIN_DECLS + +void empathy_subscription_dialog_show (GossipContact *contact, + GtkWindow *parent); + +G_END_DECLS + +#endif /* __EMPATHY_SUBSCRIPTION_DIALOG_H__ */ diff --git a/libempathy-gtk/gossip-contact-list-view.c b/libempathy-gtk/gossip-contact-list-view.c index 368ba8be4..b81ccfd40 100644 --- a/libempathy-gtk/gossip-contact-list-view.c +++ b/libempathy-gtk/gossip-contact-list-view.c @@ -806,7 +806,7 @@ contact_list_view_drag_data_received (GtkWidget *widget, gpointer user_data) { GossipContactListViewPriv *priv; - EmpathyContactManager *manager; + EmpathyContactList *list; GtkTreeModel *model; GtkTreePath *path; GtkTreeViewDropPosition position; @@ -825,9 +825,8 @@ contact_list_view_drag_data_received (GtkWidget *widget, id); /* FIXME: This is ambigous, an id can come from multiple accounts */ - manager = empathy_contact_manager_new (); - contact = empathy_contact_list_find (EMPATHY_CONTACT_LIST (manager), id); - g_object_unref (manager); + list = gossip_contact_list_store_get_list_iface (priv->store); + contact = empathy_contact_list_find (list, id); if (!contact) { gossip_debug (DEBUG_DOMAIN, "No contact found associated with drag & drop"); @@ -1449,9 +1448,12 @@ static void contact_list_view_action_cb (GtkAction *action, GossipContactListView *view) { - GossipContact *contact; - const gchar *name; - gchar *group; + GossipContactListViewPriv *priv; + GossipContact *contact; + const gchar *name; + gchar *group; + + priv = GET_PRIV (view); name = gtk_action_get_name (action); if (!name) { @@ -1471,6 +1473,11 @@ contact_list_view_action_cb (GtkAction *action, else if (contact && strcmp (name, "Edit") == 0) { } else if (contact && strcmp (name, "Remove") == 0) { + EmpathyContactList *list; + + list = gossip_contact_list_store_get_list_iface (priv->store); + empathy_contact_list_remove (list, contact, + _("Sorry, I don't want you in my contact list anymore.")); } else if (contact && strcmp (name, "Invite") == 0) { } -- cgit v1.2.3