diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.am | 1 | ||||
-rw-r--r-- | src/empathy-chat-window.c | 99 | ||||
-rw-r--r-- | src/empathy-chat-window.ui | 7 | ||||
-rw-r--r-- | src/empathy-invite-participant-dialog.c | 65 | ||||
-rw-r--r-- | src/empathy-invite-participant-dialog.h | 46 |
5 files changed, 215 insertions, 3 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index ecec8923f..3370f9bed 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -44,6 +44,7 @@ empathy_handwritten_source = \ empathy-import-pidgin.c empathy-import-pidgin.h \ empathy-import-utils.c empathy-import-utils.h \ empathy-import-widget.c empathy-import-widget.h \ + empathy-invite-participant-dialog.c empathy-invite-participant-dialog.h \ empathy-main-window.c empathy-main-window.h \ empathy-new-chatroom-dialog.c empathy-new-chatroom-dialog.h \ empathy-preferences.c empathy-preferences.h \ diff --git a/src/empathy-chat-window.c b/src/empathy-chat-window.c index 658e59426..5ad66fd26 100644 --- a/src/empathy-chat-window.c +++ b/src/empathy-chat-window.c @@ -35,14 +35,14 @@ #include <glib/gi18n.h> #include <libnotify/notification.h> -#include <telepathy-glib/account-manager.h> -#include <telepathy-glib/util.h> +#include <telepathy-glib/telepathy-glib.h> #include <libempathy/empathy-contact.h> #include <libempathy/empathy-message.h> -#include <libempathy/empathy-dispatcher.h> #include <libempathy/empathy-chatroom-manager.h> #include <libempathy/empathy-utils.h> +#include <libempathy/empathy-tp-contact-factory.h> +#include <libempathy/empathy-contact-list.h> #include <libempathy-gtk/empathy-images.h> #include <libempathy-gtk/empathy-conf.h> @@ -56,6 +56,7 @@ #include "empathy-chat-window.h" #include "empathy-about-dialog.h" +#include "empathy-invite-participant-dialog.h" #define DEBUG_FLAG EMPATHY_DEBUG_CHAT #include <libempathy/empathy-debug.h> @@ -346,6 +347,32 @@ chat_window_menu_context_update (EmpathyChatWindowPriv *priv, } static void +chat_window_conversation_menu_update (EmpathyChatWindowPriv *priv, + EmpathyChatWindow *self) +{ + EmpathyTpChat *tp_chat; + TpConnection *connection; + GtkAction *action; + gboolean sensitive = FALSE; + + g_return_if_fail (priv->current_chat != NULL); + + action = gtk_ui_manager_get_action (priv->ui_manager, + "/chats_menubar/menu_conv/menu_conv_invite_participant"); + tp_chat = empathy_chat_get_tp_chat (priv->current_chat); + + if (tp_chat != NULL) { + connection = empathy_tp_chat_get_connection (tp_chat); + + sensitive = empathy_tp_chat_can_add_contact (tp_chat) && + (tp_connection_get_status (connection, NULL) == + TP_CONNECTION_STATUS_CONNECTED); + } + + gtk_action_set_sensitive (action, sensitive); +} + +static void chat_window_contact_menu_update (EmpathyChatWindowPriv *priv, EmpathyChatWindow *window) { @@ -536,6 +563,8 @@ chat_window_update (EmpathyChatWindow *window) chat_window_menu_context_update (priv, num_pages); + chat_window_conversation_menu_update (priv, window); + chat_window_contact_menu_update (priv, window); @@ -819,6 +848,69 @@ chat_window_contacts_toggled_cb (GtkToggleAction *toggle_action, } static void +got_contact_cb (EmpathyTpContactFactory *factory, + EmpathyContact *contact, + const GError *error, + gpointer user_data, + GObject *object) +{ + EmpathyTpChat *tp_chat = EMPATHY_TP_CHAT (user_data); + + if (error != NULL) { + DEBUG ("Failed: %s", error->message); + return; + } else { + empathy_contact_list_add (EMPATHY_CONTACT_LIST (tp_chat), + contact, _("Inviting you to this room")); + } +} + +static void +chat_window_invite_participant_activate_cb (GtkAction *action, + EmpathyChatWindow *window) +{ + EmpathyChatWindowPriv *priv; + GtkWidget *dialog; + EmpathyTpChat *tp_chat; + TpChannel *channel; + int response; + + priv = GET_PRIV (window); + + g_return_if_fail (priv->current_chat != NULL); + + tp_chat = empathy_chat_get_tp_chat (priv->current_chat); + channel = empathy_tp_chat_get_channel (tp_chat); + + dialog = empathy_invite_participant_dialog_new ( + GTK_WINDOW (priv->dialog)); + gtk_widget_show (dialog); + + response = gtk_dialog_run (GTK_DIALOG (dialog)); + + if (response == GTK_RESPONSE_ACCEPT) { + TpConnection *connection; + EmpathyTpContactFactory *factory; + const char *id; + + id = empathy_contact_selector_dialog_get_selected ( + EMPATHY_CONTACT_SELECTOR_DIALOG (dialog), NULL); + if (EMP_STR_EMPTY (id)) goto out; + + connection = tp_channel_borrow_connection (channel); + factory = empathy_tp_contact_factory_dup_singleton (connection); + + empathy_tp_contact_factory_get_from_id (factory, id, + got_contact_cb, tp_chat, NULL, NULL); + + g_object_unref (factory); + } + +out: + gtk_widget_destroy (dialog); +} + +static void chat_window_close_activate_cb (GtkAction *action, EmpathyChatWindow *window) { @@ -1725,6 +1817,7 @@ empathy_chat_window_init (EmpathyChatWindow *window) "menu_conv_clear", "activate", chat_window_clear_activate_cb, "menu_conv_favorite", "toggled", chat_window_favorite_toggled_cb, "menu_conv_toggle_contacts", "toggled", chat_window_contacts_toggled_cb, + "menu_conv_invite_participant", "activate", chat_window_invite_participant_activate_cb, "menu_conv_close", "activate", chat_window_close_activate_cb, "menu_edit", "activate", chat_window_edit_activate_cb, "menu_edit_cut", "activate", chat_window_cut_activate_cb, diff --git a/src/empathy-chat-window.ui b/src/empathy-chat-window.ui index 57326a3e3..88d099c16 100644 --- a/src/empathy-chat-window.ui +++ b/src/empathy-chat-window.ui @@ -39,6 +39,12 @@ </object> </child> <child> + <object class="GtkAction" id="menu_conv_invite_participant"> + <property name="name">menu_conv_invite_participant</property> + <property name="label" translatable="yes">Invite _Participant...</property> + </object> + </child> + <child> <object class="GtkAction" id="menu_conv_close"> <property name="stock_id">gtk-close</property> <property name="name">menu_conv_close</property> @@ -145,6 +151,7 @@ <menuitem action="menu_conv_insert_smiley"/> <menuitem action="menu_conv_favorite"/> <menuitem action="menu_conv_toggle_contacts"/> + <menuitem action="menu_conv_invite_participant"/> <separator/> <menuitem action="menu_conv_close"/> </menu> diff --git a/src/empathy-invite-participant-dialog.c b/src/empathy-invite-participant-dialog.c new file mode 100644 index 000000000..70332d1ff --- /dev/null +++ b/src/empathy-invite-participant-dialog.c @@ -0,0 +1,65 @@ +/* + * empathy-invite-participant-dialog.c + * + * EmpathyInviteParticipantDialog + * + * (c) 2009, Collabora Ltd. + * + * Authors: + * Danielle Madeley <danielle.madeley@collabora.co.uk> + */ + +#include <glib/gi18n.h> + +#include "empathy-invite-participant-dialog.h" + +G_DEFINE_TYPE (EmpathyInviteParticipantDialog, + empathy_invite_participant_dialog, EMPATHY_TYPE_CONTACT_SELECTOR_DIALOG); + +static void +empathy_invite_participant_dialog_class_init (EmpathyInviteParticipantDialogClass *klass) +{ +} + +static void +empathy_invite_participant_dialog_init (EmpathyInviteParticipantDialog *self) +{ + EmpathyContactSelectorDialog *parent = EMPATHY_CONTACT_SELECTOR_DIALOG (self); + GtkWidget *label; + char *str; + + label = gtk_label_new (NULL); + str = g_strdup_printf ( + "<span size=\"x-large\" weight=\"bold\">%s</span>\n\n%s", + _("Invite Participant"), + _("Choose a contact to invite into the conversation:")); + gtk_label_set_markup (GTK_LABEL (label), str); + g_free (str); + + gtk_box_pack_start (GTK_BOX (parent->vbox), label, FALSE, TRUE, 0); + /* move to the top -- wish there was a better way to do this */ + gtk_box_reorder_child (GTK_BOX (parent->vbox), label, 0); + gtk_widget_show (label); + + parent->button_action = gtk_dialog_add_button (GTK_DIALOG (self), + "Invite", GTK_RESPONSE_ACCEPT); + gtk_widget_set_sensitive (parent->button_action, FALSE); + + gtk_window_set_title (GTK_WINDOW (self), _("Invite Participant")); + gtk_window_set_role (GTK_WINDOW (self), "invite_participant"); + empathy_contact_selector_dialog_set_show_account_chooser ( + EMPATHY_CONTACT_SELECTOR_DIALOG (self), FALSE); +} + +GtkWidget * +empathy_invite_participant_dialog_new (GtkWindow *parent) +{ + GtkWidget *self = g_object_new (EMPATHY_TYPE_INVITE_PARTICIPANT_DIALOG, NULL); + + if (parent != NULL) + { + gtk_window_set_transient_for (GTK_WINDOW (self), parent); + } + + return self; +} diff --git a/src/empathy-invite-participant-dialog.h b/src/empathy-invite-participant-dialog.h new file mode 100644 index 000000000..561e10738 --- /dev/null +++ b/src/empathy-invite-participant-dialog.h @@ -0,0 +1,46 @@ +/* + * empathy-invite-participant-dialog.h + * + * EmpathyInviteParticipantDialog + * + * (c) 2009, Collabora Ltd. + * + * Authors: + * Danielle Madeley <danielle.madeley@collabora.co.uk> + */ + +#ifndef __EMPATHY_INVITE_PARTICIPANT_DIALOG_H__ +#define __EMPATHY_INVITE_PARTICIPANT_DIALOG_H__ + +#include <gtk/gtk.h> + +#include <libempathy-gtk/empathy-contact-selector-dialog.h> + +G_BEGIN_DECLS + +#define EMPATHY_TYPE_INVITE_PARTICIPANT_DIALOG (empathy_invite_participant_dialog_get_type ()) +#define EMPATHY_INVITE_PARTICIPANT_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EMPATHY_TYPE_INVITE_PARTICIPANT_DIALOG, EmpathyInviteParticipantDialog)) +#define EMPATHY_INVITE_PARTICIPANT_DIALOG_CLASS(obj) (G_TYPE_CHECK_CLASS_CAST ((obj), EMPATHY_TYPE_INVITE_PARTICIPANT_DIALOG, EmpathyInviteParticipantDialogClass)) +#define EMPATHY_IS_INVITE_PARTICIPANT_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EMPATHY_TYPE_INVITE_PARTICIPANT_DIALOG)) +#define EMPATHY_IS_INVITE_PARTICIPANT_DIALOG_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE ((obj), EMPATHY_TYPE_INVITE_PARTICIPANT_DIALOG)) +#define EMPATHY_INVITE_PARTICIPANT_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EMPATHY_TYPE_INVITE_PARTICIPANT_DIALOG, EmpathyInviteParticipantDialogClass)) + +typedef struct _EmpathyInviteParticipantDialog EmpathyInviteParticipantDialog; +typedef struct _EmpathyInviteParticipantDialogClass EmpathyInviteParticipantDialogClass; + +struct _EmpathyInviteParticipantDialog +{ + EmpathyContactSelectorDialog parent; +}; + +struct _EmpathyInviteParticipantDialogClass +{ + EmpathyContactSelectorDialogClass parent_class; +}; + +GType empathy_invite_participant_dialog_get_type (void); +GtkWidget *empathy_invite_participant_dialog_new (GtkWindow *parent); + +G_END_DECLS + +#endif |