aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXavier Claessens <xclaesse@gmail.com>2007-06-07 02:21:00 +0800
committerXavier Claessens <xclaesse@src.gnome.org>2007-06-07 02:21:00 +0800
commit51f7f13d735f8db9ead25711641f2974c18b2737 (patch)
tree1ead7bbe3e4321ed9a48b03962a6345ef9a434ef
parenta79ee78e13ce6c890925e8fab0cc70c30c80cc8a (diff)
downloadgsoc2013-empathy-51f7f13d735f8db9ead25711641f2974c18b2737.tar
gsoc2013-empathy-51f7f13d735f8db9ead25711641f2974c18b2737.tar.gz
gsoc2013-empathy-51f7f13d735f8db9ead25711641f2974c18b2737.tar.bz2
gsoc2013-empathy-51f7f13d735f8db9ead25711641f2974c18b2737.tar.lz
gsoc2013-empathy-51f7f13d735f8db9ead25711641f2974c18b2737.tar.xz
gsoc2013-empathy-51f7f13d735f8db9ead25711641f2974c18b2737.tar.zst
gsoc2013-empathy-51f7f13d735f8db9ead25711641f2974c18b2737.zip
EmpatchContactWidget has 2 modes: editable or not.
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: * libempathy-gtk/empathy-subscription-dialog.c: EmpatchContactWidget has 2 modes: editable or not. svn path=/trunk/; revision=127
-rw-r--r--ChangeLog8
-rw-r--r--libempathy-gtk/empathy-contact-widget.c67
-rw-r--r--libempathy-gtk/empathy-contact-widget.glade24
-rw-r--r--libempathy-gtk/empathy-contact-widget.h6
-rw-r--r--libempathy-gtk/empathy-subscription-dialog.c21
5 files changed, 80 insertions, 46 deletions
diff --git a/ChangeLog b/ChangeLog
index b8cea4127..da0983dd8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
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:
+ * libempathy-gtk/empathy-subscription-dialog.c: EmpatchContactWidget
+ has 2 modes: editable or not.
+
+2007-06-06 Xavier Claessens <xclaesse@gmail.com>
+
* po/POTFILES.in: Updated with new files.
2007-06-06 Xavier Claessens <xclaesse@gmail.com>
diff --git a/libempathy-gtk/empathy-contact-widget.c b/libempathy-gtk/empathy-contact-widget.c
index a900ce119..cd50056ce 100644
--- a/libempathy-gtk/empathy-contact-widget.c
+++ b/libempathy-gtk/empathy-contact-widget.c
@@ -37,19 +37,21 @@
typedef struct {
GossipContact *contact;
gboolean is_user;
+ gboolean editable;
gboolean changes_made;
GtkCellRenderer *renderer;
GtkWidget *vbox_contact_widget;
GtkWidget *vbox_contact;
+ GtkWidget *widget_avatar;
GtkWidget *label_id;
GtkWidget *entry_alias;
+ GtkWidget *widget_alias;
GtkWidget *image_state;
GtkWidget *label_status;
GtkWidget *table_contact;
GtkWidget *hbox_contact;
- GtkWidget *image_avatar;
GtkWidget *vbox_groups;
GtkWidget *entry_group;
@@ -122,7 +124,8 @@ enum {
};
GtkWidget *
-empathy_contact_widget_new (GossipContact *contact)
+empathy_contact_widget_new (GossipContact *contact,
+ gboolean editable)
{
EmpathyContactWidget *information;
GladeXML *glade;
@@ -134,6 +137,7 @@ empathy_contact_widget_new (GossipContact *contact)
information->contact = g_object_ref (contact);
user_contact = gossip_contact_get_user (contact);
information->is_user = gossip_contact_equal (contact, user_contact);
+ information->editable = editable;
glade = gossip_glade_get_file ("empathy-contact-widget.glade",
"vbox_contact_widget",
@@ -141,7 +145,6 @@ empathy_contact_widget_new (GossipContact *contact)
"vbox_contact_widget", &information->vbox_contact_widget,
"vbox_contact", &information->vbox_contact,
"label_id", &information->label_id,
- "entry_alias", &information->entry_alias,
"image_state", &information->image_state,
"label_status", &information->label_status,
"table_contact", &information->table_contact,
@@ -161,7 +164,6 @@ empathy_contact_widget_new (GossipContact *contact)
gossip_glade_connect (glade,
information,
"vbox_contact_widget", "destroy", contact_widget_destroy_cb,
- "entry_alias", "changed", contact_widget_entry_alias_changed_cb,
"entry_group", "changed", contact_widget_entry_group_changed_cb,
"entry_group", "activate", contact_widget_entry_group_activate_cb,
"button_group", "clicked", contact_widget_button_group_clicked_cb,
@@ -193,11 +195,13 @@ empathy_contact_widget_save (GtkWidget *widget)
g_return_if_fail (GTK_IS_WIDGET (widget));
information = g_object_get_data (G_OBJECT (widget), "EmpathyContactWidget");
- if (!information || !information->changes_made) {
+ if (!information ||
+ !information->editable ||
+ !information->changes_made) {
return;
}
- name = gtk_entry_get_text (GTK_ENTRY (information->entry_alias));
+ name = gtk_entry_get_text (GTK_ENTRY (information->widget_alias));
groups = contact_widget_model_find_selected (information);
gossip_contact_set_name (information->contact, name);
@@ -207,6 +211,21 @@ empathy_contact_widget_save (GtkWidget *widget)
g_list_free (groups);
}
+GossipContact *
+empathy_contact_widget_get_contact (GtkWidget *widget)
+{
+ EmpathyContactWidget *information;
+
+ g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
+
+ information = g_object_get_data (G_OBJECT (widget), "EmpathyContactWidget");
+ if (!information) {
+ return NULL;
+ }
+
+ return information->contact;
+}
+
static void
contact_widget_destroy_cb (GtkWidget *widget,
EmpathyContactWidget *information)
@@ -241,14 +260,29 @@ contact_widget_contact_setup (EmpathyContactWidget *information)
G_CALLBACK (contact_widget_avatar_notify_cb),
information);
- information->image_avatar = gtk_image_new ();
+ /* FIXME: Use GossipAvatarImage if (editable && is_user) */
+ information->widget_avatar = gtk_image_new ();
gtk_box_pack_end (GTK_BOX (information->hbox_contact),
- information->image_avatar,
+ information->widget_avatar,
FALSE, FALSE,
6);
+ /* Setup alias entry or label */
+ if (information->editable) {
+ information->widget_alias = gtk_entry_new ();
+ g_signal_connect (information->widget_alias, "changed",
+ G_CALLBACK (contact_widget_entry_alias_changed_cb),
+ information);
+ } else {
+ information->widget_alias = gtk_label_new (NULL);
+ }
+ gtk_widget_show (information->widget_alias);
+
+ /* Setup id label */
gtk_label_set_text (GTK_LABEL (information->label_id),
gossip_contact_get_id (information->contact));
+
+ /* Update all widgets */
contact_widget_name_notify_cb (information);
contact_widget_presence_notify_cb (information);
contact_widget_avatar_notify_cb (information);
@@ -257,8 +291,13 @@ contact_widget_contact_setup (EmpathyContactWidget *information)
static void
contact_widget_name_notify_cb (EmpathyContactWidget *information)
{
- gtk_entry_set_text (GTK_ENTRY (information->entry_alias),
- gossip_contact_get_name (information->contact));
+ if (information->editable) {
+ gtk_entry_set_text (GTK_ENTRY (information->widget_alias),
+ gossip_contact_get_name (information->contact));
+ } else {
+ gtk_label_set_label (GTK_LABEL (information->widget_alias),
+ gossip_contact_get_name (information->contact));
+ }
}
static void
@@ -281,19 +320,19 @@ contact_widget_avatar_notify_cb (EmpathyContactWidget *information)
48, 48);
if (avatar_pixbuf) {
- gtk_image_set_from_pixbuf (GTK_IMAGE (information->image_avatar),
+ gtk_image_set_from_pixbuf (GTK_IMAGE (information->widget_avatar),
avatar_pixbuf);
- gtk_widget_show (information->image_avatar);
+ gtk_widget_show (information->widget_avatar);
g_object_unref (avatar_pixbuf);
} else {
- gtk_widget_hide (information->image_avatar);
+ gtk_widget_hide (information->widget_avatar);
}
}
static void
contact_widget_groups_setup (EmpathyContactWidget *information)
{
- if (!information->is_user) {
+ if (information->editable) {
contact_widget_model_setup (information);
g_signal_connect_swapped (information->contact, "notify::groups",
diff --git a/libempathy-gtk/empathy-contact-widget.glade b/libempathy-gtk/empathy-contact-widget.glade
index 178c52eb8..7172a9623 100644
--- a/libempathy-gtk/empathy-contact-widget.glade
+++ b/libempathy-gtk/empathy-contact-widget.glade
@@ -141,12 +141,13 @@
<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">False</property>
+ <property name="selectable">True</property>
<property name="xalign">0</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
@@ -166,27 +167,6 @@
</child>
<child>
- <widget class="GtkEntry" id="entry_alias">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="editable">True</property>
- <property name="visibility">True</property>
- <property name="max_length">0</property>
- <property name="text" translatable="yes"></property>
- <property name="has_frame">True</property>
- <property name="invisible_char">●</property>
- <property name="activates_default">False</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>
- <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>
diff --git a/libempathy-gtk/empathy-contact-widget.h b/libempathy-gtk/empathy-contact-widget.h
index c61d97335..4b7102e8f 100644
--- a/libempathy-gtk/empathy-contact-widget.h
+++ b/libempathy-gtk/empathy-contact-widget.h
@@ -29,8 +29,10 @@
G_BEGIN_DECLS
-GtkWidget * empathy_contact_widget_new (GossipContact *contact);
-void empathy_contact_widget_save (GtkWidget *widget);
+GtkWidget * empathy_contact_widget_new (GossipContact *contact,
+ gboolean editable);
+void empathy_contact_widget_save (GtkWidget *widget);
+GossipContact *empathy_contact_widget_get_contact (GtkWidget *widget);
G_END_DECLS
#endif /* __EMPATHY_CONTACT_WIDGET_H__ */
diff --git a/libempathy-gtk/empathy-subscription-dialog.c b/libempathy-gtk/empathy-subscription-dialog.c
index cd0508080..578118581 100644
--- a/libempathy-gtk/empathy-subscription-dialog.c
+++ b/libempathy-gtk/empathy-subscription-dialog.c
@@ -39,13 +39,16 @@
static GHashTable *dialogs = NULL;
static void
-subscription_dialog_response_cb (GtkDialog *dialog,
- gint response,
- GossipContact *contact)
+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),
@@ -68,6 +71,7 @@ empathy_subscription_dialog_show (GossipContact *contact,
{
GtkWidget *dialog;
GtkWidget *hbox_subscription;
+ GtkWidget *contact_widget;
g_return_if_fail (GOSSIP_IS_CONTACT (contact));
@@ -91,17 +95,18 @@ empathy_subscription_dialog_show (GossipContact *contact,
"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);
+ contact_widget = empathy_contact_widget_new (contact, TRUE);
gtk_box_pack_end (GTK_BOX (hbox_subscription),
- empathy_contact_widget_new (contact),
+ 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);
}