aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2010-08-24 22:10:28 +0800
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2010-08-25 17:45:14 +0800
commitf867ae2b8bbe9b885419f9748465d96ce70755d9 (patch)
tree7fc748e2b95478e923b3d8ae1e491af4d596444d
parent8f678a31a63eccb4fc086a8caddb37b1a0e7de91 (diff)
downloadgsoc2013-empathy-f867ae2b8bbe9b885419f9748465d96ce70755d9.tar
gsoc2013-empathy-f867ae2b8bbe9b885419f9748465d96ce70755d9.tar.gz
gsoc2013-empathy-f867ae2b8bbe9b885419f9748465d96ce70755d9.tar.bz2
gsoc2013-empathy-f867ae2b8bbe9b885419f9748465d96ce70755d9.tar.lz
gsoc2013-empathy-f867ae2b8bbe9b885419f9748465d96ce70755d9.tar.xz
gsoc2013-empathy-f867ae2b8bbe9b885419f9748465d96ce70755d9.tar.zst
gsoc2013-empathy-f867ae2b8bbe9b885419f9748465d96ce70755d9.zip
irc-network-chooser: popup network chooser dialog when clicked
-rw-r--r--libempathy-gtk/empathy-irc-network-chooser.c63
1 files changed, 62 insertions, 1 deletions
diff --git a/libempathy-gtk/empathy-irc-network-chooser.c b/libempathy-gtk/empathy-irc-network-chooser.c
index 768abe2d6..ce71465c7 100644
--- a/libempathy-gtk/empathy-irc-network-chooser.c
+++ b/libempathy-gtk/empathy-irc-network-chooser.c
@@ -33,6 +33,7 @@
#include "empathy-irc-network-dialog.h"
#include "empathy-ui-utils.h"
+#include "empathy-irc-network-chooser-dialog.h"
#define DEBUG_FLAG EMPATHY_DEBUG_ACCOUNT | EMPATHY_DEBUG_IRC
#include <libempathy/empathy-debug.h>
@@ -47,10 +48,18 @@ enum {
PROP_SETTINGS = 1
};
+enum {
+ SIG_CHANGED,
+ LAST_SIGNAL
+};
+
+static guint signals[LAST_SIGNAL] = { 0 };
+
typedef struct {
EmpathyAccountSettings *settings;
EmpathyIrcNetworkManager *network_manager;
+ GtkWidget *dialog;
/* Displayed network */
EmpathyIrcNetwork *network;
} EmpathyIrcNetworkChooserPriv;
@@ -224,10 +233,53 @@ set_label_from_settings (EmpathyIrcNetworkChooser *self)
}
static void
+dialog_response_cb (GtkDialog *dialog,
+ gint response,
+ EmpathyIrcNetworkChooser *self)
+{
+ EmpathyIrcNetworkChooserPriv *priv = GET_PRIV (self);
+ EmpathyIrcNetworkChooserDialog *chooser =
+ EMPATHY_IRC_NETWORK_CHOOSER_DIALOG (priv->dialog);
+
+ if (response != GTK_RESPONSE_CLOSE &&
+ response != GTK_RESPONSE_DELETE_EVENT)
+ return;
+
+ if (empathy_irc_network_chooser_dialog_get_changed (chooser))
+ {
+ tp_clear_object (&priv->network);
+
+ priv->network = g_object_ref (
+ empathy_irc_network_chooser_dialog_get_network (chooser));
+
+ update_server_params (self);
+ set_label (self);
+
+ g_signal_emit (self, signals[SIG_CHANGED], 0);
+ }
+
+ gtk_widget_destroy (priv->dialog);
+ priv->dialog = NULL;
+}
+
+static void
clicked_cb (GtkButton *button,
gpointer user_data)
{
- /* TODO: open edit dialog */
+ EmpathyIrcNetworkChooserPriv *priv = GET_PRIV (button);
+
+ if (priv->dialog != NULL)
+ goto out;
+
+ priv->dialog = empathy_irc_network_chooser_dialog_new (priv->settings,
+ priv->network);
+ gtk_widget_show_all (priv->dialog);
+
+ tp_g_signal_connect_object (priv->dialog, "response",
+ G_CALLBACK (dialog_response_cb), button, 0);
+
+out:
+ empathy_window_present (GTK_WINDOW (priv->dialog));
}
static void
@@ -274,6 +326,15 @@ empathy_irc_network_chooser_class_init (EmpathyIrcNetworkChooserClass *klass)
EMPATHY_TYPE_ACCOUNT_SETTINGS,
G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+ signals[SIG_CHANGED] = g_signal_new ("changed",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0);
+
g_type_class_add_private (object_class,
sizeof (EmpathyIrcNetworkChooserPriv));
}