aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXavier Claessens <xclaesse@gmail.com>2007-06-07 00:29:00 +0800
committerXavier Claessens <xclaesse@src.gnome.org>2007-06-07 00:29:00 +0800
commitdf77283dbff9bbd59477a649948bf9c24773bdbb (patch)
tree6511fcf562f5b1f0d57ae9ad31b9e35ab3178231
parentc063bac41998b5106743a47426b737ab7c59640d (diff)
downloadgsoc2013-empathy-df77283dbff9bbd59477a649948bf9c24773bdbb.tar
gsoc2013-empathy-df77283dbff9bbd59477a649948bf9c24773bdbb.tar.gz
gsoc2013-empathy-df77283dbff9bbd59477a649948bf9c24773bdbb.tar.bz2
gsoc2013-empathy-df77283dbff9bbd59477a649948bf9c24773bdbb.tar.lz
gsoc2013-empathy-df77283dbff9bbd59477a649948bf9c24773bdbb.tar.xz
gsoc2013-empathy-df77283dbff9bbd59477a649948bf9c24773bdbb.tar.zst
gsoc2013-empathy-df77283dbff9bbd59477a649948bf9c24773bdbb.zip
New dialog: EmpathySubscriptionDialog. It uses EmpathyContactWidget to
2007-06-06 Xavier Claessens <xclaesse@gmail.com> * 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
-rw-r--r--ChangeLog15
-rw-r--r--libempathy-gtk/Makefile.am2
-rw-r--r--libempathy-gtk/empathy-contact-widget.c14
-rw-r--r--libempathy-gtk/empathy-status-icon.c4
-rw-r--r--libempathy-gtk/empathy-subscription-dialog.c111
-rw-r--r--libempathy-gtk/empathy-subscription-dialog.glade244
-rw-r--r--libempathy-gtk/empathy-subscription-dialog.h37
-rw-r--r--libempathy-gtk/gossip-contact-list-view.c21
-rw-r--r--libempathy/empathy-tp-contact-list.c1
9 files changed, 440 insertions, 9 deletions
diff --git a/ChangeLog b/ChangeLog
index 78d79ffff..d00a8287a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,21 @@
2007-06-06 Xavier Claessens <xclaesse@gmail.com>
* 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.
+
+2007-06-06 Xavier Claessens <xclaesse@gmail.com>
+
+ * libempathy-gtk/empathy-status-icon.c:
* 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 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 <libempathy/empathy-idle.h>
#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 <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,
+ 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 @@
+<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
+<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">
+
+<glade-interface>
+
+<widget class="GtkDialog" id="subscription_request_dialog">
+ <property name="border_width">5</property>
+ <property name="title" translatable="yes">Subscription Request</property>
+ <property name="type">GTK_WINDOW_TOPLEVEL</property>
+ <property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property>
+ <property name="modal">False</property>
+ <property name="resizable">False</property>
+ <property name="destroy_with_parent">False</property>
+ <property name="decorated">True</property>
+ <property name="skip_taskbar_hint">False</property>
+ <property name="skip_pager_hint">False</property>
+ <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
+ <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
+ <property name="focus_on_map">True</property>
+ <property name="urgency_hint">False</property>
+ <property name="has_separator">False</property>
+
+ <child internal-child="vbox">
+ <widget class="GtkVBox" id="dialog-vbox4">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">2</property>
+
+ <child internal-child="action_area">
+ <widget class="GtkHButtonBox" id="dialog-action_area4">
+ <property name="visible">True</property>
+ <property name="layout_style">GTK_BUTTONBOX_END</property>
+
+ <child>
+ <widget class="GtkButton" id="button19">
+ <property name="visible">True</property>
+ <property name="can_default">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">Decide _Later</property>
+ <property name="use_underline">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="response_id">-6</property>
+ </widget>
+ </child>
+
+ <child>
+ <widget class="GtkButton" id="button20">
+ <property name="visible">True</property>
+ <property name="can_default">True</property>
+ <property name="can_focus">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="response_id">-9</property>
+
+ <child>
+ <widget class="GtkAlignment" id="alignment3">
+ <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="hbox48">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">2</property>
+
+ <child>
+ <widget class="GtkImage" id="image8">
+ <property name="visible">True</property>
+ <property name="stock">gtk-no</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="label218">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">_Deny</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>
+ </widget>
+ </child>
+
+ <child>
+ <widget class="GtkButton" id="button21">
+ <property name="visible">True</property>
+ <property name="can_default">True</property>
+ <property name="has_default">True</property>
+ <property name="can_focus">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>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="pack_type">GTK_PACK_END</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkHBox" id="hbox_subscription">
+ <property name="border_width">5</property>
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">12</property>
+
+ <child>
+ <widget class="GtkImage" id="image5">
+ <property name="visible">True</property>
+ <property name="stock">gtk-dialog-question</property>
+ <property name="icon_size">6</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0</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>
+ <placeholder/>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+</widget>
+
+</glade-interface>
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 <xclaesse@gmail.com>
+ */
+
+#ifndef __EMPATHY_SUBSCRIPTION_DIALOG_H__
+#define __EMPATHY_SUBSCRIPTION_DIALOG_H__
+
+#include <gtk/gtk.h>
+
+#include <libempathy/gossip-contact.h>
+
+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) {
}
diff --git a/libempathy/empathy-tp-contact-list.c b/libempathy/empathy-tp-contact-list.c
index e54ebef38..3be79533a 100644
--- a/libempathy/empathy-tp-contact-list.c
+++ b/libempathy/empathy-tp-contact-list.c
@@ -471,6 +471,7 @@ tp_contact_list_add (EmpathyContactList *list,
handle = gossip_contact_get_handle (contact);
gossip_telepathy_group_add_member (priv->subscribe, handle, message);
+ gossip_telepathy_group_add_member (priv->publish, handle, message);
}
static void