aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/Makefile.am1
-rw-r--r--src/empathy-chat-window.c67
-rw-r--r--src/empathy-invite-participant-dialog.c111
-rw-r--r--src/empathy-invite-participant-dialog.h46
4 files changed, 213 insertions, 12 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 26829a3bb..17662b115 100644
--- a/src/empathy-chat-window.c
+++ b/src/empathy-chat-window.c
@@ -57,6 +57,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>
@@ -820,10 +821,9 @@ chat_window_contacts_toggled_cb (GtkToggleAction *toggle_action,
}
static void
-chat_window_invite_participant_activate_cb (GtkAction *action,
- EmpathyChatWindow *window)
+chat_window_upgrade_to_muc (EmpathyChat *chat,
+ EmpathyContact *invitee)
{
- EmpathyChatWindowPriv *priv;
EmpathyDispatcher *dispatcher = empathy_dispatcher_dup_singleton ();
EmpathyTpChat *tp_chat;
TpConnection *connection;
@@ -832,14 +832,7 @@ chat_window_invite_participant_activate_cb (GtkAction *action,
GPtrArray *channels;
char *invitees[3] = { NULL, };
- priv = GET_PRIV (window);
-
- g_return_if_fail (priv->current_chat != NULL);
-
- /* FIXME: this is for upgrading a 1-to-1 channel to a MUC, inviting
- * a user to a MUC is much easier, and needs to be written */
-
- tp_chat = empathy_chat_get_tp_chat (priv->current_chat);
+ tp_chat = empathy_chat_get_tp_chat (chat);
connection = empathy_tp_chat_get_connection (tp_chat);
channel = empathy_tp_chat_get_channel (tp_chat);
@@ -848,7 +841,7 @@ chat_window_invite_participant_activate_cb (GtkAction *action,
g_ptr_array_add (channels, (char *) tp_proxy_get_object_path (channel));
invitees[0] = (char *) tp_channel_get_identifier (channel);
- // invitees[1] = /* FIXME: ask for this */
+ invitees[1] = (char *) empathy_contact_get_id (invitee);
props = tp_asv_new (
TP_IFACE_CHANNEL ".ChannelType", G_TYPE_STRING,
@@ -873,6 +866,56 @@ chat_window_invite_participant_activate_cb (GtkAction *action,
}
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);
+
+ /* FIXME: should filter out the existing participants from the
+ * list */
+ 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_OK)
+ {
+ EmpathyContact *contact;
+ TpHandleType handle_type;
+
+ contact = empathy_invite_participant_dialog_dup_selected_contact (EMPATHY_INVITE_PARTICIPANT_DIALOG (dialog));
+ tp_channel_get_handle (channel, &handle_type);
+
+ if (handle_type == TP_HANDLE_TYPE_CONTACT)
+ {
+ chat_window_upgrade_to_muc (priv->current_chat,
+ contact);
+ }
+ else
+ {
+ /* FIXME: do something with MUC */
+ g_warning ("Not implemented yet");
+ }
+
+ g_object_unref (contact);
+ }
+
+ gtk_widget_destroy (dialog);
+}
+
+static void
chat_window_close_activate_cb (GtkAction *action,
EmpathyChatWindow *window)
{
diff --git a/src/empathy-invite-participant-dialog.c b/src/empathy-invite-participant-dialog.c
new file mode 100644
index 000000000..07c12c9b0
--- /dev/null
+++ b/src/empathy-invite-participant-dialog.c
@@ -0,0 +1,111 @@
+/*
+ * empathy-invite-participant-dialog.c
+ *
+ * EmpathyInviteParticipantDialog
+ *
+ * (c) 2009, Collabora Ltd.
+ *
+ * Authors:
+ * Danielle Madeley <danielle.madeley@collabora.co.uk>
+ */
+
+#include <glib/gi18n.h>
+
+#include <libempathy/empathy-contact-manager.h>
+
+#include <libempathy-gtk/empathy-contact-selector.h>
+
+#include "empathy-invite-participant-dialog.h"
+
+#define GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), EMPATHY_TYPE_INVITE_PARTICIPANT_DIALOG, EmpathyInviteParticipantDialogPrivate))
+
+G_DEFINE_TYPE (EmpathyInviteParticipantDialog, empathy_invite_participant_dialog, GTK_TYPE_DIALOG);
+
+typedef struct _EmpathyInviteParticipantDialogPrivate EmpathyInviteParticipantDialogPrivate;
+struct _EmpathyInviteParticipantDialogPrivate
+{
+ GtkWidget *selector;
+};
+
+static void
+invite_participant_enable_join (GtkComboBox *selector,
+ GtkWidget *button)
+{
+ gtk_widget_set_sensitive (button, TRUE);
+}
+
+static void
+empathy_invite_participant_dialog_class_init (EmpathyInviteParticipantDialogClass *klass)
+{
+ GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+
+ g_type_class_add_private (gobject_class, sizeof (EmpathyInviteParticipantDialogPrivate));
+}
+
+static void
+empathy_invite_participant_dialog_init (EmpathyInviteParticipantDialog *self)
+{
+ EmpathyInviteParticipantDialogPrivate *priv = GET_PRIVATE (self);
+ EmpathyContactManager *manager = empathy_contact_manager_dup_singleton ();
+ GtkWidget *vbox = gtk_vbox_new (FALSE, 6);
+ GtkWidget *label = gtk_label_new (NULL);
+ GtkWidget *join_button;
+ char *str;
+
+ 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);
+
+ priv->selector = empathy_contact_selector_new (
+ EMPATHY_CONTACT_LIST (manager));
+
+ gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (vbox), priv->selector, FALSE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (self))),
+ vbox, TRUE, TRUE, 6);
+
+ gtk_widget_show_all (vbox);
+
+ gtk_dialog_add_button (GTK_DIALOG (self),
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
+ join_button = gtk_dialog_add_button (GTK_DIALOG (self),
+ "Invite", GTK_RESPONSE_OK);
+
+ gtk_dialog_set_has_separator (GTK_DIALOG (self), FALSE);
+
+ gtk_widget_set_sensitive (join_button, FALSE);
+ g_signal_connect (priv->selector, "changed",
+ G_CALLBACK (invite_participant_enable_join), join_button);
+
+ g_object_unref (manager);
+}
+
+EmpathyContact *
+empathy_invite_participant_dialog_dup_selected_contact (
+ EmpathyInviteParticipantDialog *self)
+{
+ EmpathyInviteParticipantDialogPrivate *priv;
+
+ g_return_val_if_fail (EMPATHY_IS_INVITE_PARTICIPANT_DIALOG (self), NULL);
+
+ priv = GET_PRIVATE (self);
+
+ return empathy_contact_selector_dup_selected (
+ EMPATHY_CONTACT_SELECTOR (priv->selector));
+}
+
+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..642733871
--- /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>
+
+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
+{
+ GtkDialog parent;
+};
+
+struct _EmpathyInviteParticipantDialogClass
+{
+ GtkDialogClass parent_class;
+};
+
+GType empathy_invite_participant_dialog_get_type (void);
+GtkWidget *empathy_invite_participant_dialog_new (GtkWindow *parent);
+EmpathyContact *empathy_invite_participant_dialog_dup_selected_contact (EmpathyInviteParticipantDialog *self);
+
+
+G_END_DECLS
+
+#endif