diff options
-rw-r--r-- | ChangeLog | 13 | ||||
-rw-r--r-- | libempathy-gtk/empathy-chat-window.c | 2 | ||||
-rw-r--r-- | libempathy-gtk/empathy-contact-dialogs.c | 30 | ||||
-rw-r--r-- | libempathy-gtk/empathy-contact-dialogs.h | 3 | ||||
-rw-r--r-- | libempathy-gtk/empathy-contact-list-view.c | 4 | ||||
-rw-r--r-- | libempathy-gtk/empathy-contact-widget.c | 77 | ||||
-rw-r--r-- | libempathy-gtk/empathy-contact-widget.h | 19 | ||||
-rw-r--r-- | libempathy-gtk/empathy-main-window.c | 22 | ||||
-rw-r--r-- | megaphone/src/megaphone-applet.c | 2 |
9 files changed, 113 insertions, 59 deletions
@@ -1,5 +1,18 @@ 2007-10-09 Xavier Claessens <xclaesse@gmail.com> + * libempathy-gtk/empathy-main-window.c: + * libempathy-gtk/empathy-contact-dialogs.c: + * libempathy-gtk/empathy-contact-list-view.c: + * libempathy-gtk/empathy-contact-dialogs.h: + * libempathy-gtk/empathy-contact-widget.c: + * libempathy-gtk/empathy-contact-widget.h: + * libempathy-gtk/empathy-chat-window.c: + * megaphone/src/megaphone-applet.c: More flexible API for + EmpathyContactWidget, we now have flags to set editable each fields. + Implement personal information menu item in main window. + +2007-10-09 Xavier Claessens <xclaesse@gmail.com> + * libempathy-gtk/empathy-contact-widget.glade: * libempathy-gtk/empathy-contact-widget.c: * libempathy-gtk/empathy-avatar-chooser.c: diff --git a/libempathy-gtk/empathy-chat-window.c b/libempathy-gtk/empathy-chat-window.c index 911fc51f3..6535500de 100644 --- a/libempathy-gtk/empathy-chat-window.c +++ b/libempathy-gtk/empathy-chat-window.c @@ -914,7 +914,7 @@ chat_window_info_activate_cb (GtkWidget *menuitem, empathy_contact_information_dialog_show (contact, GTK_WINDOW (priv->dialog), - FALSE); + FALSE, FALSE); } static gboolean diff --git a/libempathy-gtk/empathy-contact-dialogs.c b/libempathy-gtk/empathy-contact-dialogs.c index 553f85bcc..d032eab5a 100644 --- a/libempathy-gtk/empathy-contact-dialogs.c +++ b/libempathy-gtk/empathy-contact-dialogs.c @@ -110,7 +110,8 @@ empathy_subscription_dialog_show (EmpathyContact *contact, NULL); contact_widget = empathy_contact_widget_new (contact, - CONTACT_WIDGET_TYPE_SUBSCRIPTION); + EMPATHY_CONTACT_WIDGET_EDIT_ALIAS | + EMPATHY_CONTACT_WIDGET_EDIT_GROUPS); gtk_box_pack_end (GTK_BOX (hbox_subscription), contact_widget, TRUE, TRUE, @@ -146,13 +147,14 @@ contact_information_response_cb (GtkDialog *dialog, void empathy_contact_information_dialog_show (EmpathyContact *contact, GtkWindow *parent, - gboolean edit) + gboolean edit, + gboolean edit_groups) { GtkWidget *dialog; GtkWidget *button; GtkWidget *contact_widget; GList *l; - EmpathyContactWidgetType type; + EmpathyContactWidgetFlags flags = 0; g_return_if_fail (EMPATHY_IS_CONTACT (contact)); @@ -164,8 +166,6 @@ empathy_contact_information_dialog_show (EmpathyContact *contact, return; } - type = edit ? CONTACT_WIDGET_TYPE_EDIT : CONTACT_WIDGET_TYPE_SHOW; - /* Create dialog */ dialog = gtk_dialog_new (); gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE); @@ -179,9 +179,19 @@ empathy_contact_information_dialog_show (EmpathyContact *contact, button, GTK_RESPONSE_CLOSE); gtk_widget_show (button); - + /* Contact info widget */ - contact_widget = empathy_contact_widget_new (contact, type); + if (edit) { + flags |= EMPATHY_CONTACT_WIDGET_EDIT_ALIAS; + if (empathy_contact_is_user (contact)) { + flags |= EMPATHY_CONTACT_WIDGET_EDIT_ACCOUNT | + EMPATHY_CONTACT_WIDGET_EDIT_AVATAR; + } + } + if (edit_groups) { + flags |= EMPATHY_CONTACT_WIDGET_EDIT_GROUPS; + } + contact_widget = empathy_contact_widget_new (contact, flags); gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), contact_widget, TRUE, TRUE, 0); @@ -261,7 +271,11 @@ empathy_new_contact_dialog_show (GtkWindow *parent) gtk_widget_show (button); /* Contact info widget */ - contact_widget = empathy_contact_widget_new (NULL, CONTACT_WIDGET_TYPE_ADD); + contact_widget = empathy_contact_widget_new (NULL, + EMPATHY_CONTACT_WIDGET_EDIT_ALIAS | + EMPATHY_CONTACT_WIDGET_EDIT_ACCOUNT | + EMPATHY_CONTACT_WIDGET_EDIT_ID | + EMPATHY_CONTACT_WIDGET_EDIT_GROUPS); gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), contact_widget, TRUE, TRUE, 0); diff --git a/libempathy-gtk/empathy-contact-dialogs.h b/libempathy-gtk/empathy-contact-dialogs.h index 560ae8f2b..65ded4e7e 100644 --- a/libempathy-gtk/empathy-contact-dialogs.h +++ b/libempathy-gtk/empathy-contact-dialogs.h @@ -33,7 +33,8 @@ void empathy_subscription_dialog_show (EmpathyContact *contact, GtkWindow *parent); void empathy_contact_information_dialog_show (EmpathyContact *contact, GtkWindow *parent, - gboolean edit); + gboolean edit, + gboolean edit_groups); void empathy_new_contact_dialog_show (GtkWindow *parent); G_END_DECLS diff --git a/libempathy-gtk/empathy-contact-list-view.c b/libempathy-gtk/empathy-contact-list-view.c index 70a2b0c0a..e3816dda7 100644 --- a/libempathy-gtk/empathy-contact-list-view.c +++ b/libempathy-gtk/empathy-contact-list-view.c @@ -1402,10 +1402,10 @@ contact_list_view_action_cb (GtkAction *action, contact_list_view_voip_activated (view, contact); } else if (contact && strcmp (name, "Information") == 0) { - empathy_contact_information_dialog_show (contact, parent, FALSE); + empathy_contact_information_dialog_show (contact, parent, FALSE, FALSE); } else if (contact && strcmp (name, "Edit") == 0) { - empathy_contact_information_dialog_show (contact, parent, TRUE); + empathy_contact_information_dialog_show (contact, parent, TRUE, TRUE); } else if (contact && strcmp (name, "Remove") == 0) { /* FIXME: Ask for confirmation */ diff --git a/libempathy-gtk/empathy-contact-widget.c b/libempathy-gtk/empathy-contact-widget.c index 2d26f4a4b..afd434f3f 100644 --- a/libempathy-gtk/empathy-contact-widget.c +++ b/libempathy-gtk/empathy-contact-widget.c @@ -49,7 +49,7 @@ typedef struct { EmpathyContactFactory *factory; EmpathyContactManager *manager; EmpathyContact *contact; - EmpathyContactWidgetType type; + EmpathyContactWidgetFlags flags; GtkCellRenderer *renderer; guint widget_id_timeout; @@ -100,7 +100,7 @@ static void contact_widget_set_contact (EmpathyContactWidget EmpathyContact *contact); static void contact_widget_contact_setup (EmpathyContactWidget *information); static void contact_widget_contact_update (EmpathyContactWidget *information); -static gboolean contact_widget_update_contact (EmpathyContactWidget *information); +static void contact_widget_change_contact (EmpathyContactWidget *information); static void contact_widget_avatar_changed_cb (EmpathyAvatarChooser *chooser, EmpathyContactWidget *information); static void contact_widget_account_changed_cb (GtkComboBox *widget, @@ -150,16 +150,13 @@ enum { GtkWidget * empathy_contact_widget_new (EmpathyContact *contact, - EmpathyContactWidgetType type) + EmpathyContactWidgetFlags flags) { EmpathyContactWidget *information; GladeXML *glade; information = g_slice_new0 (EmpathyContactWidget); - if (type == CONTACT_WIDGET_TYPE_EDIT && empathy_contact_is_user (contact)) { - type = CONTACT_WIDGET_TYPE_EDIT_USER; - } - information->type = type; + information->flags = flags; information->factory = empathy_contact_factory_new (); glade = empathy_glade_get_file ("empathy-contact-widget.glade", @@ -319,7 +316,7 @@ contact_widget_can_add_contact_to_account (McAccount *account, static gboolean contact_widget_id_activate_timeout (EmpathyContactWidget *self) { - contact_widget_update_contact (self); + contact_widget_change_contact (self); return FALSE; } @@ -340,7 +337,7 @@ contact_widget_id_changed_cb (GtkEntry *entry, static void contact_widget_contact_setup (EmpathyContactWidget *information) { - if (information->type == CONTACT_WIDGET_TYPE_EDIT_USER) { + if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_AVATAR) { information->widget_avatar = empathy_avatar_chooser_new (); g_signal_connect (information->widget_avatar, "changed", G_CALLBACK (contact_widget_avatar_changed_cb), @@ -355,7 +352,7 @@ contact_widget_contact_setup (EmpathyContactWidget *information) gtk_widget_show (information->widget_avatar); /* Setup account label/chooser */ - if (information->type == CONTACT_WIDGET_TYPE_ADD) { + if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_ACCOUNT) { information->widget_account = empathy_account_chooser_new (); empathy_account_chooser_set_filter ( EMPATHY_ACCOUNT_CHOOSER (information->widget_account), @@ -376,7 +373,7 @@ contact_widget_contact_setup (EmpathyContactWidget *information) gtk_widget_show (information->widget_account); /* Setup id label/entry */ - if (information->type == CONTACT_WIDGET_TYPE_ADD) { + if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_ID) { information->widget_id = gtk_entry_new (); g_signal_connect (information->widget_id, "focus-out-event", G_CALLBACK (contact_widget_id_focus_out_cb), @@ -395,7 +392,7 @@ contact_widget_contact_setup (EmpathyContactWidget *information) gtk_widget_show (information->widget_id); /* Setup alias label/entry */ - if (information->type > CONTACT_WIDGET_TYPE_SHOW) { + if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_ALIAS) { information->widget_alias = gtk_entry_new (); g_signal_connect (information->widget_alias, "focus-out-event", G_CALLBACK (contact_widget_entry_alias_focus_event_cb), @@ -434,7 +431,7 @@ contact_widget_contact_update (EmpathyContactWidget *information) } /* Update account widget */ - if (information->type == CONTACT_WIDGET_TYPE_ADD) { + if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_ACCOUNT) { if (account) { g_signal_handlers_block_by_func (information->widget_account, contact_widget_account_changed_cb, @@ -445,9 +442,6 @@ contact_widget_contact_update (EmpathyContactWidget *information) contact_widget_account_changed_cb, information); } - if (!G_STR_EMPTY (id)) { - gtk_entry_set_text (GTK_ENTRY (information->widget_id), id); - } } else { if (account) { const gchar *name; @@ -455,9 +449,14 @@ contact_widget_contact_update (EmpathyContactWidget *information) name = mc_account_get_display_name (account); gtk_label_set_label (GTK_LABEL (information->widget_account), name); } - gtk_label_set_label (GTK_LABEL (information->widget_id), id); } + /* Update id widget */ + if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_ID) { + gtk_entry_set_text (GTK_ENTRY (information->widget_id), id ? id : ""); + } else { + gtk_label_set_label (GTK_LABEL (information->widget_id), id ? id : ""); + } /* Update other widgets */ if (information->contact) { contact_widget_name_notify_cb (information); @@ -476,28 +475,36 @@ contact_widget_contact_update (EmpathyContactWidget *information) } } -static gboolean -contact_widget_update_contact (EmpathyContactWidget *information) +static void +contact_widget_change_contact (EmpathyContactWidget *information) { - McAccount *account; - const gchar *id; + EmpathyContact *contact; + McAccount *account; account = empathy_account_chooser_get_account (EMPATHY_ACCOUNT_CHOOSER (information->widget_account)); - id = gtk_entry_get_text (GTK_ENTRY (information->widget_id)); + if (!account) { + return; + } - if (account && !G_STR_EMPTY (id)) { - EmpathyContact *contact; + if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_ID) { + const gchar *id; + + id = gtk_entry_get_text (GTK_ENTRY (information->widget_id)); + if (G_STR_EMPTY (id)) { + return; + } contact = empathy_contact_factory_get_from_id (information->factory, account, id); - contact_widget_set_contact (information, contact); - - if (contact) { - g_object_unref (contact); - } + } else { + contact = empathy_contact_factory_get_user (information->factory, + account); } - return FALSE; + if (contact) { + contact_widget_set_contact (information, contact); + g_object_unref (contact); + } } static void @@ -518,7 +525,7 @@ static void contact_widget_account_changed_cb (GtkComboBox *widget, EmpathyContactWidget *information) { - contact_widget_update_contact (information); + contact_widget_change_contact (information); } static gboolean @@ -526,7 +533,7 @@ contact_widget_id_focus_out_cb (GtkWidget *widget, GdkEventFocus *event, EmpathyContactWidget *information) { - contact_widget_update_contact (information); + contact_widget_change_contact (information); return FALSE; } @@ -578,7 +585,7 @@ contact_widget_avatar_notify_cb (EmpathyContactWidget *information) if (information->contact) { avatar = empathy_contact_get_avatar (information->contact); } - if (information->type == CONTACT_WIDGET_TYPE_EDIT_USER) { + if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_AVATAR) { g_signal_handlers_block_by_func (information->widget_avatar, contact_widget_avatar_changed_cb, information); @@ -596,7 +603,7 @@ contact_widget_avatar_notify_cb (EmpathyContactWidget *information) static void contact_widget_groups_setup (EmpathyContactWidget *information) { - if (information->type > CONTACT_WIDGET_TYPE_SHOW) { + if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_GROUPS) { information->manager = empathy_contact_manager_new (); contact_widget_model_setup (information); } @@ -605,7 +612,7 @@ contact_widget_groups_setup (EmpathyContactWidget *information) static void contact_widget_groups_update (EmpathyContactWidget *information) { - if (information->type > CONTACT_WIDGET_TYPE_SHOW && + if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_GROUPS && information->contact) { g_signal_connect_swapped (information->contact, "notify::groups", G_CALLBACK (contact_widget_groups_notify_cb), diff --git a/libempathy-gtk/empathy-contact-widget.h b/libempathy-gtk/empathy-contact-widget.h index 71fc06acb..3a2aed996 100644 --- a/libempathy-gtk/empathy-contact-widget.h +++ b/libempathy-gtk/empathy-contact-widget.h @@ -30,16 +30,17 @@ G_BEGIN_DECLS typedef enum { - CONTACT_WIDGET_TYPE_SHOW, /* used to show contact information */ - CONTACT_WIDGET_TYPE_EDIT, /* used to edit contact information */ - CONTACT_WIDGET_TYPE_ADD, /* used to add a new contact */ - CONTACT_WIDGET_TYPE_SUBSCRIPTION, /* used to accepte/reject a new contact */ - CONTACT_WIDGET_TYPE_EDIT_USER /* used to edit our own information */ -} EmpathyContactWidgetType; + EMPATHY_CONTACT_WIDGET_EDIT_ALIAS = 1 << 0, + EMPATHY_CONTACT_WIDGET_EDIT_AVATAR = 1 << 1, + EMPATHY_CONTACT_WIDGET_EDIT_ACCOUNT = 1 << 2, + EMPATHY_CONTACT_WIDGET_EDIT_ID = 1 << 3, + EMPATHY_CONTACT_WIDGET_EDIT_GROUPS = 1 << 4, +} EmpathyContactWidgetFlags; -GtkWidget * empathy_contact_widget_new (EmpathyContact *contact, - EmpathyContactWidgetType type); -EmpathyContact *empathy_contact_widget_get_contact (GtkWidget *widget); +GtkWidget * empathy_contact_widget_new (EmpathyContact *contact, + EmpathyContactWidgetFlags flags); +EmpathyContact *empathy_contact_widget_get_contact (GtkWidget *widget); G_END_DECLS + #endif /* __EMPATHY_CONTACT_WIDGET_H__ */ diff --git a/libempathy-gtk/empathy-main-window.c b/libempathy-gtk/empathy-main-window.c index 7867b949c..7543c456e 100644 --- a/libempathy-gtk/empathy-main-window.c +++ b/libempathy-gtk/empathy-main-window.c @@ -35,6 +35,7 @@ #include <libempathy/empathy-chatroom.h> #include <libempathy/empathy-contact-list.h> #include <libempathy/empathy-contact-manager.h> +#include <libempathy/empathy-contact-factory.h> #include "empathy-main-window.h" #include "empathy-contact-dialogs.h" @@ -67,7 +68,7 @@ typedef struct { EmpathyContactListView *list_view; EmpathyContactListStore *list_store; - MissionControl *mc; + MissionControl *mc; EmpathyChatroomManager *chatroom_manager; /* Main widgets */ @@ -662,7 +663,24 @@ static void main_window_edit_personal_information_cb (GtkWidget *widget, EmpathyMainWindow *window) { - //empathy_vcard_dialog_show (GTK_WINDOW (window->window)); + GSList *accounts; + + accounts = mission_control_get_online_connections (window->mc, NULL); + if (accounts) { + EmpathyContactFactory *factory; + EmpathyContact *contact; + McAccount *account; + + account = accounts->data; + factory = empathy_contact_factory_new (); + contact = empathy_contact_factory_get_user (factory, account); + empathy_contact_information_dialog_show (contact, + GTK_WINDOW (window->window), + TRUE, FALSE); + g_slist_foreach (accounts, (GFunc) g_object_unref, NULL); + g_slist_free (accounts); + g_object_unref (factory); + } } static void diff --git a/megaphone/src/megaphone-applet.c b/megaphone/src/megaphone-applet.c index c4e56da6e..993c68744 100644 --- a/megaphone/src/megaphone-applet.c +++ b/megaphone/src/megaphone-applet.c @@ -395,7 +395,7 @@ megaphone_applet_information_cb (BonoboUIComponent *uic, /* FIXME: We should grey out the menu item if there are no available contact */ if (priv->contact) { - empathy_contact_information_dialog_show (priv->contact, NULL, FALSE); + empathy_contact_information_dialog_show (priv->contact, NULL, FALSE, FALSE); } } |