diff options
-rw-r--r-- | ChangeLog | 17 | ||||
-rw-r--r-- | libempathy-gtk/Makefile.am | 4 | ||||
-rw-r--r-- | libempathy-gtk/empathy-contact-dialogs.c | 209 | ||||
-rw-r--r-- | libempathy-gtk/empathy-contact-dialogs.glade (renamed from libempathy-gtk/empathy-subscription-dialog.glade) | 68 | ||||
-rw-r--r-- | libempathy-gtk/empathy-contact-dialogs.h (renamed from libempathy-gtk/empathy-subscription-dialog.h) | 13 | ||||
-rw-r--r-- | libempathy-gtk/empathy-contact-widget.c | 4 | ||||
-rw-r--r-- | libempathy-gtk/empathy-contact-widget.glade | 213 | ||||
-rw-r--r-- | libempathy-gtk/empathy-status-icon.c | 2 | ||||
-rw-r--r-- | libempathy-gtk/empathy-subscription-dialog.c | 116 | ||||
-rw-r--r-- | libempathy-gtk/gossip-contact-list-view.c | 8 | ||||
-rw-r--r-- | libempathy-gtk/gossip-ui-utils.c | 15 | ||||
-rw-r--r-- | libempathy-gtk/gossip-ui-utils.h | 1 |
12 files changed, 364 insertions, 306 deletions
@@ -1,5 +1,22 @@ 2007-06-06 Xavier Claessens <xclaesse@gmail.com> + * libempathy-gtk/empathy-contact-dialogs.glade: + * libempathy-gtk/empathy-contact-widget.glade: + * libempathy-gtk/empathy-status-icon.c: + * libempathy-gtk/empathy-contact-dialogs.c: + * libempathy-gtk/empathy-contact-dialogs.h: + * libempathy-gtk/gossip-ui-utils.c: + * libempathy-gtk/empathy-subscription-dialog.glade: + * libempathy-gtk/empathy-contact-widget.c: + * libempathy-gtk/gossip-ui-utils.h: + * libempathy-gtk/gossip-contact-list-view.c: + * libempathy-gtk/empathy-subscription-dialog.c: + * libempathy-gtk/Makefile.am: + * libempathy-gtk/empathy-subscription-dialog.h: Implement editing and + viewing contact information with right click on the roster. + +2007-06-06 Xavier Claessens <xclaesse@gmail.com> + * libempathy-gtk/empathy-contact-widget.glade: * libempathy-gtk/empathy-contact-widget.c: * libempathy-gtk/empathy-contact-widget.h: diff --git a/libempathy-gtk/Makefile.am b/libempathy-gtk/Makefile.am index e2c02eddd..2c87b43f4 100644 --- a/libempathy-gtk/Makefile.am +++ b/libempathy-gtk/Makefile.am @@ -13,7 +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 \ + empathy-contact-dialogs.c empathy-contact-dialogs.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 \ @@ -51,7 +51,7 @@ glade_DATA = \ empathy-main-window.glade \ empathy-status-icon.glade \ empathy-contact-widget.glade \ - empathy-subscription-dialog.glade \ + empathy-contact-dialogs.glade \ gossip-preferences.glade \ gossip-presence-chooser.glade \ gossip-accounts-dialog.glade \ diff --git a/libempathy-gtk/empathy-contact-dialogs.c b/libempathy-gtk/empathy-contact-dialogs.c new file mode 100644 index 000000000..8f377d02d --- /dev/null +++ b/libempathy-gtk/empathy-contact-dialogs.c @@ -0,0 +1,209 @@ +/* -*- 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 <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 <libempathy/empathy-contact-manager.h> +#include <libempathy/empathy-contact-list.h> + +#include "empathy-contact-dialogs.h" +#include "empathy-contact-widget.h" +#include "gossip-ui-utils.h" + +static GHashTable *subscription_dialogs = NULL; +static GHashTable *information_dialogs = NULL; + +/* + * Subscription dialog + */ + +static void +subscription_dialog_response_cb (GtkDialog *dialog, + gint response, + GtkWidget *contact_widget) +{ + EmpathyContactManager *manager; + GossipContact *contact; + + manager = empathy_contact_manager_new (); + contact = empathy_contact_widget_get_contact (contact_widget); + empathy_contact_widget_save (contact_widget); + + 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 (subscription_dialogs, contact); + g_object_unref (manager); +} + +void +empathy_subscription_dialog_show (GossipContact *contact, + GtkWindow *parent) +{ + GtkWidget *dialog; + GtkWidget *hbox_subscription; + GtkWidget *contact_widget; + + g_return_if_fail (GOSSIP_IS_CONTACT (contact)); + + if (!subscription_dialogs) { + subscription_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 (subscription_dialogs, contact); + if (dialog) { + gtk_window_present (GTK_WINDOW (dialog)); + return; + } + + gossip_glade_get_file_simple ("empathy-contact-dialogs.glade", + "subscription_request_dialog", + NULL, + "subscription_request_dialog", &dialog, + "hbox_subscription", &hbox_subscription, + NULL); + + g_hash_table_insert (subscription_dialogs, g_object_ref (contact), dialog); + + contact_widget = empathy_contact_widget_new (contact, TRUE); + gtk_box_pack_end (GTK_BOX (hbox_subscription), + contact_widget, + TRUE, TRUE, + 0); + + g_signal_connect (dialog, "response", + G_CALLBACK (subscription_dialog_response_cb), + contact_widget); + + if (parent) { + gtk_window_set_transient_for (GTK_WINDOW (dialog), parent); + } + + gtk_widget_show (dialog); +} + +/* + * Information dialog + */ + +static void +contact_information_response_cb (GtkDialog *dialog, + gint response, + GtkWidget *contact_widget) +{ + GossipContact *contact; + + contact = empathy_contact_widget_get_contact (contact_widget); + empathy_contact_widget_save (contact_widget); + + g_hash_table_remove (information_dialogs, contact); +} + +void +empathy_contact_information_dialog_show (GossipContact *contact, + GtkWindow *parent, + gboolean edit) +{ + GtkWidget *dialog; + GtkWidget *button; + GtkWidget *contact_widget; + + g_return_if_fail (GOSSIP_IS_CONTACT (contact)); + + if (!information_dialogs) { + information_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 (information_dialogs, contact); + if (dialog) { + gtk_window_present (GTK_WINDOW (dialog)); + return; + } + + dialog = gtk_dialog_new (); + gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE); + gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE); + + if (edit) { + /* Cancel button */ + button = gtk_button_new_with_label (GTK_STOCK_CANCEL); + gtk_button_set_use_stock (GTK_BUTTON (button), TRUE); + gtk_dialog_add_action_widget (GTK_DIALOG (dialog), + button, + GTK_RESPONSE_CANCEL); + gtk_widget_show (button); + + button = gtk_button_new_with_label (GTK_STOCK_SAVE); + gtk_button_set_use_stock (GTK_BUTTON (button), TRUE); + gtk_dialog_add_action_widget (GTK_DIALOG (dialog), + button, + GTK_RESPONSE_OK); + gtk_widget_show (button); + } else { + /* Close button */ + button = gtk_button_new_with_label (GTK_STOCK_CLOSE); + gtk_button_set_use_stock (GTK_BUTTON (button), TRUE); + gtk_dialog_add_action_widget (GTK_DIALOG (dialog), + button, + GTK_RESPONSE_CLOSE); + gtk_widget_show (button); + } + + contact_widget = empathy_contact_widget_new (contact, edit); + gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), + contact_widget, + TRUE, TRUE, 0); + + g_signal_connect (dialog, "response", + G_CALLBACK (contact_information_response_cb), + contact_widget); + + g_hash_table_insert (information_dialogs, g_object_ref (contact), dialog); + + 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-contact-dialogs.glade index e43b8ea42..475844267 100644 --- a/libempathy-gtk/empathy-subscription-dialog.glade +++ b/libempathy-gtk/empathy-contact-dialogs.glade @@ -125,73 +125,11 @@ <property name="can_default">True</property> <property name="has_default">True</property> <property name="can_focus">True</property> + <property name="label">gtk-cancel</property> + <property name="use_stock">True</property> <property name="relief">GTK_RELIEF_NORMAL</property> <property name="focus_on_click">True</property> - <property name="response_id">-8</property> - - <child> - <widget class="GtkAlignment" id="alignment1"> - <property name="visible">True</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xscale">0</property> - <property name="yscale">0</property> - <property name="top_padding">0</property> - <property name="bottom_padding">0</property> - <property name="left_padding">0</property> - <property name="right_padding">0</property> - - <child> - <widget class="GtkHBox" id="hbox46"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">2</property> - - <child> - <widget class="GtkImage" id="image6"> - <property name="visible">True</property> - <property name="stock">gtk-yes</property> - <property name="icon_size">4</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label216"> - <property name="visible">True</property> - <property name="label" translatable="yes">_Accept</property> - <property name="use_underline">True</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> - <property name="width_chars">-1</property> - <property name="single_line_mode">False</property> - <property name="angle">0</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - </widget> - </child> - </widget> - </child> + <property name="response_id">-6</property> </widget> </child> </widget> diff --git a/libempathy-gtk/empathy-subscription-dialog.h b/libempathy-gtk/empathy-contact-dialogs.h index 0488722e6..809623d47 100644 --- a/libempathy-gtk/empathy-subscription-dialog.h +++ b/libempathy-gtk/empathy-contact-dialogs.h @@ -20,8 +20,8 @@ * Authors: Xavier Claessens <xclaesse@gmail.com> */ -#ifndef __EMPATHY_SUBSCRIPTION_DIALOG_H__ -#define __EMPATHY_SUBSCRIPTION_DIALOG_H__ +#ifndef __EMPATHY_CONTACT_DIALOGS_H__ +#define __EMPATHY_CONTACT_DIALOGS_H__ #include <gtk/gtk.h> @@ -29,9 +29,12 @@ G_BEGIN_DECLS -void empathy_subscription_dialog_show (GossipContact *contact, - GtkWindow *parent); +void empathy_subscription_dialog_show (GossipContact *contact, + GtkWindow *parent); +void empathy_contact_information_dialog_show (GossipContact *contact, + GtkWindow *parent, + gboolean edit); G_END_DECLS -#endif /* __EMPATHY_SUBSCRIPTION_DIALOG_H__ */ +#endif /* __EMPATHY_CONTACT_DIALOGS_H__ */ diff --git a/libempathy-gtk/empathy-contact-widget.c b/libempathy-gtk/empathy-contact-widget.c index cd50056ce..b8ed7efb0 100644 --- a/libempathy-gtk/empathy-contact-widget.c +++ b/libempathy-gtk/empathy-contact-widget.c @@ -275,7 +275,11 @@ contact_widget_contact_setup (EmpathyContactWidget *information) information); } else { information->widget_alias = gtk_label_new (NULL); + gtk_label_set_selectable (GTK_LABEL (information->widget_alias), TRUE); } + gtk_table_attach_defaults (GTK_TABLE (information->table_contact), + information->widget_alias, + 1, 2, 1, 2); gtk_widget_show (information->widget_alias); /* Setup id label */ diff --git a/libempathy-gtk/empathy-contact-widget.glade b/libempathy-gtk/empathy-contact-widget.glade index 7172a9623..d36971b78 100644 --- a/libempathy-gtk/empathy-contact-widget.glade +++ b/libempathy-gtk/empathy-contact-widget.glade @@ -22,7 +22,7 @@ <child> <widget class="GtkVBox" id="vbox_contact_widget"> <property name="homogeneous">False</property> - <property name="spacing">0</property> + <property name="spacing">6</property> <child> <widget class="GtkHBox" id="hbox_contact"> @@ -74,123 +74,108 @@ <property name="right_padding">0</property> <child> - <widget class="GtkTable" id="table_contact"> + <widget class="GtkVBox" id="vbox225"> <property name="visible">True</property> - <property name="n_rows">3</property> - <property name="n_columns">2</property> <property name="homogeneous">False</property> - <property name="row_spacing">6</property> - <property name="column_spacing">12</property> + <property name="spacing">6</property> <child> - <widget class="GtkLabel" id="label655"> + <widget class="GtkTable" id="table_contact"> <property name="visible">True</property> - <property name="label" translatable="yes">Identifier:</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> - <property name="width_chars">-1</property> - <property name="single_line_mode">False</property> - <property name="angle">0</property> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">1</property> - <property name="top_attach">0</property> - <property name="bottom_attach">1</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> + <property name="n_rows">2</property> + <property name="n_columns">2</property> + <property name="homogeneous">False</property> + <property name="row_spacing">6</property> + <property name="column_spacing">12</property> - <child> - <widget class="GtkLabel" id="label658"> - <property name="visible">True</property> - <property name="label" translatable="yes">Alias:</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> - <property name="width_chars">-1</property> - <property name="single_line_mode">False</property> - <property name="angle">0</property> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">1</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> + <child> + <widget class="GtkLabel" id="label655"> + <property name="visible">True</property> + <property name="label" translatable="yes">Identifier:</property> + <property name="use_underline">False</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="left_attach">0</property> + <property name="right_attach">1</property> + <property name="top_attach">0</property> + <property name="bottom_attach">1</property> + <property name="x_options">fill</property> + <property name="y_options"></property> + </packing> + </child> - <child> - <widget class="GtkLabel" id="label_id"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="label" translatable="yes"></property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">True</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> - <property name="width_chars">-1</property> - <property name="single_line_mode">False</property> - <property name="angle">0</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">0</property> - <property name="bottom_attach">1</property> - <property name="y_options"></property> - </packing> - </child> + <child> + <widget class="GtkLabel" id="label658"> + <property name="visible">True</property> + <property name="label" translatable="yes">Alias:</property> + <property name="use_underline">False</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="left_attach">0</property> + <property name="right_attach">1</property> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + <property name="x_options">fill</property> + <property name="y_options"></property> + </packing> + </child> - <child> - <widget class="GtkLabel" id="label680"> - <property name="visible">True</property> - <property name="label" translatable="yes">Presence:</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> - <property name="width_chars">-1</property> - <property name="single_line_mode">False</property> - <property name="angle">0</property> + <child> + <widget class="GtkLabel" id="label_id"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="label" translatable="yes"></property> + <property name="use_underline">False</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">True</property> + <property name="xalign">0</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">0</property> + <property name="bottom_attach">1</property> + <property name="y_options"></property> + </packing> + </child> </widget> <packing> - <property name="left_attach">0</property> - <property name="right_attach">1</property> - <property name="top_attach">2</property> - <property name="bottom_attach">3</property> - <property name="x_options">fill</property> - <property name="y_options"></property> + <property name="padding">0</property> + <property name="expand">True</property> + <property name="fill">True</property> </packing> </child> @@ -218,12 +203,13 @@ <child> <widget class="GtkLabel" id="label_status"> <property name="visible">True</property> + <property name="can_focus">True</property> <property name="label" translatable="yes"></property> <property name="use_underline">False</property> <property name="use_markup">True</property> <property name="justify">GTK_JUSTIFY_LEFT</property> <property name="wrap">True</property> - <property name="selectable">False</property> + <property name="selectable">True</property> <property name="xalign">0</property> <property name="yalign">0.5</property> <property name="xpad">0</property> @@ -241,12 +227,9 @@ </child> </widget> <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">2</property> - <property name="bottom_attach">3</property> - <property name="x_options">fill</property> - <property name="y_options">fill</property> + <property name="padding">0</property> + <property name="expand">True</property> + <property name="fill">True</property> </packing> </child> </widget> diff --git a/libempathy-gtk/empathy-status-icon.c b/libempathy-gtk/empathy-status-icon.c index d6e4cbe24..f8753820a 100644 --- a/libempathy-gtk/empathy-status-icon.c +++ b/libempathy-gtk/empathy-status-icon.c @@ -39,7 +39,7 @@ #include <libempathy/empathy-idle.h> #include "empathy-status-icon.h" -#include "empathy-subscription-dialog.h" +#include "empathy-contact-dialogs.h" #include "gossip-presence-chooser.h" #include "gossip-preferences.h" #include "gossip-ui-utils.h" diff --git a/libempathy-gtk/empathy-subscription-dialog.c b/libempathy-gtk/empathy-subscription-dialog.c deleted file mode 100644 index 578118581..000000000 --- a/libempathy-gtk/empathy-subscription-dialog.c +++ /dev/null @@ -1,116 +0,0 @@ -/* -*- 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 <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 <libempathy/empathy-contact-manager.h> -#include <libempathy/empathy-contact-list.h> - -#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, - GtkWidget *contact_widget) -{ - EmpathyContactManager *manager; - GossipContact *contact; - - manager = empathy_contact_manager_new (); - contact = empathy_contact_widget_get_contact (contact_widget); - empathy_contact_widget_save (contact_widget); - - 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; - GtkWidget *contact_widget; - - 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_hash_table_insert (dialogs, g_object_ref (contact), dialog); - - contact_widget = empathy_contact_widget_new (contact, TRUE); - gtk_box_pack_end (GTK_BOX (hbox_subscription), - contact_widget, - TRUE, TRUE, - 0); - - g_signal_connect (dialog, "response", - G_CALLBACK (subscription_dialog_response_cb), - contact_widget); - - if (parent) { - gtk_window_set_transient_for (GTK_WINDOW (dialog), parent); - } - - gtk_widget_show (dialog); -} - diff --git a/libempathy-gtk/gossip-contact-list-view.c b/libempathy-gtk/gossip-contact-list-view.c index b81ccfd40..b3c00a33b 100644 --- a/libempathy-gtk/gossip-contact-list-view.c +++ b/libempathy-gtk/gossip-contact-list-view.c @@ -47,9 +47,8 @@ #include "gossip-cell-renderer-expander.h" #include "gossip-cell-renderer-text.h" #include "gossip-ui-utils.h" +#include "empathy-contact-dialogs.h" //#include "gossip-chat-invite.h" -//#include "gossip-contact-info-dialog.h" -//#include "gossip-edit-contact-dialog.h" //#include "gossip-ft-window.h" //#include "gossip-log-window.h" @@ -1452,6 +1451,7 @@ contact_list_view_action_cb (GtkAction *action, GossipContact *contact; const gchar *name; gchar *group; + GtkWindow *parent; priv = GET_PRIV (view); @@ -1464,15 +1464,19 @@ contact_list_view_action_cb (GtkAction *action, contact = gossip_contact_list_view_get_selected (view); group = gossip_contact_list_view_get_selected_group (view); + parent = gossip_get_toplevel_window (GTK_WIDGET (view)); if (contact && strcmp (name, "Chat") == 0) { contact_list_view_action_activated (view, contact); } else if (contact && strcmp (name, "Information") == 0) { + empathy_contact_information_dialog_show (contact, parent, FALSE); } else if (contact && strcmp (name, "Edit") == 0) { + empathy_contact_information_dialog_show (contact, parent, TRUE); } else if (contact && strcmp (name, "Remove") == 0) { + /* FIXME: Ask for confirmation */ EmpathyContactList *list; list = gossip_contact_list_store_get_list_iface (priv->store); diff --git a/libempathy-gtk/gossip-ui-utils.c b/libempathy-gtk/gossip-ui-utils.c index f9628f014..f834ceb0c 100644 --- a/libempathy-gtk/gossip-ui-utils.c +++ b/libempathy-gtk/gossip-ui-utils.c @@ -1254,6 +1254,21 @@ gossip_window_present (GtkWindow *window, } } +GtkWindow * +gossip_get_toplevel_window (GtkWidget *widget) +{ + GtkWidget *toplevel; + + g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL); + + toplevel = gtk_widget_get_toplevel (widget); + if (GTK_IS_WINDOW (toplevel)) { + return GTK_WINDOW (toplevel); + } + + return NULL; +} + /* The URL opening code can't handle schemeless strings, so we try to be * smart and add http if there is no scheme or doesn't look like a mail * address. This should work in most cases, and let us click on strings diff --git a/libempathy-gtk/gossip-ui-utils.h b/libempathy-gtk/gossip-ui-utils.h index 987993798..5a0804a9f 100644 --- a/libempathy-gtk/gossip-ui-utils.h +++ b/libempathy-gtk/gossip-ui-utils.h @@ -98,6 +98,7 @@ gboolean gossip_text_iter_backward_search (const GtkTextIter *iter, gboolean gossip_window_get_is_visible (GtkWindow *window); void gossip_window_present (GtkWindow *window, gboolean steal_focus); +GtkWindow *gossip_get_toplevel_window (GtkWidget *widget); void gossip_url_show (const char *url); void gossip_toggle_button_set_state_quietly (GtkWidget *widget, GCallback callback, |