aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChandni Verma <chandniverma2112@gmail.com>2011-02-14 10:11:30 +0800
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2011-02-15 16:20:22 +0800
commit2d295e9cc7b2ce7a173144624e7226765a125c65 (patch)
tree89bc069160bf6df363dbeb1c3312e4bb2ad0ea2a
parentb3399c7cdfc007245179797e44f5edae1fc27dd3 (diff)
downloadgsoc2013-empathy-2d295e9cc7b2ce7a173144624e7226765a125c65.tar
gsoc2013-empathy-2d295e9cc7b2ce7a173144624e7226765a125c65.tar.gz
gsoc2013-empathy-2d295e9cc7b2ce7a173144624e7226765a125c65.tar.bz2
gsoc2013-empathy-2d295e9cc7b2ce7a173144624e7226765a125c65.tar.lz
gsoc2013-empathy-2d295e9cc7b2ce7a173144624e7226765a125c65.tar.xz
gsoc2013-empathy-2d295e9cc7b2ce7a173144624e7226765a125c65.tar.zst
gsoc2013-empathy-2d295e9cc7b2ce7a173144624e7226765a125c65.zip
Reset network list button
Fixes: https://bugzilla.gnome.org/show_bug.cgi?id=642264
-rw-r--r--libempathy-gtk/empathy-irc-network-chooser-dialog.c33
-rw-r--r--libempathy/empathy-irc-network-manager.c63
-rw-r--r--libempathy/empathy-irc-network-manager.h3
-rw-r--r--libempathy/empathy-irc-network.c21
-rw-r--r--libempathy/empathy-irc-network.h2
5 files changed, 110 insertions, 12 deletions
diff --git a/libempathy-gtk/empathy-irc-network-chooser-dialog.c b/libempathy-gtk/empathy-irc-network-chooser-dialog.c
index afe259364..f8c7ed9a0 100644
--- a/libempathy-gtk/empathy-irc-network-chooser-dialog.c
+++ b/libempathy-gtk/empathy-irc-network-chooser-dialog.c
@@ -47,6 +47,10 @@ enum {
PROP_NETWORK
};
+enum {
+ RESPONSE_RESET = 0
+};
+
typedef struct {
EmpathyAccountSettings *settings;
EmpathyIrcNetwork *network;
@@ -390,6 +394,32 @@ remove_network (EmpathyIrcNetworkChooserDialog *self)
}
static void
+reset_networks (EmpathyIrcNetworkChooserDialog *self)
+{
+ EmpathyIrcNetworkChooserDialogPriv *priv = GET_PRIV (self);
+ GSList *networks, *l;
+
+ networks = empathy_irc_network_manager_get_dropped_networks (
+ priv->network_manager);
+
+ for (l = networks; l != NULL; l = g_slist_next (l))
+ {
+ EmpathyIrcNetwork *network;
+ GtkTreeIter iter;
+
+ network = EMPATHY_IRC_NETWORK (l->data);
+ empathy_irc_network_activate (network);
+
+ gtk_list_store_insert_with_values (priv->store, &iter, -1,
+ COL_NETWORK_OBJ, network,
+ COL_NETWORK_NAME, empathy_irc_network_get_name (network),
+ -1);
+ }
+
+ g_slist_foreach (networks, (GFunc) g_object_unref, NULL);
+}
+
+static void
dialog_response_cb (GtkDialog *dialog,
gint response,
EmpathyIrcNetworkChooserDialog *self)
@@ -400,6 +430,8 @@ dialog_response_cb (GtkDialog *dialog,
edit_network (self);
else if (response == GTK_RESPONSE_REJECT)
remove_network (self);
+ else if (response == RESPONSE_RESET)
+ reset_networks (self);
}
static gboolean
@@ -549,6 +581,7 @@ empathy_irc_network_chooser_dialog_constructed (GObject *object)
GTK_STOCK_ADD, GTK_RESPONSE_OK,
GTK_STOCK_EDIT, GTK_RESPONSE_APPLY,
GTK_STOCK_REMOVE, GTK_RESPONSE_REJECT,
+ _("Reset _Networks List"), RESPONSE_RESET,
NULL);
priv->select_button = gtk_dialog_add_button (dialog, _("Select"),
diff --git a/libempathy/empathy-irc-network-manager.c b/libempathy/empathy-irc-network-manager.c
index 5e0530938..691c05df5 100644
--- a/libempathy/empathy-irc-network-manager.c
+++ b/libempathy/empathy-irc-network-manager.c
@@ -366,7 +366,7 @@ empathy_irc_network_manager_remove (EmpathyIrcNetworkManager *self,
}
static void
-append_network_to_list (const gchar *id,
+append_active_networks_to_list (const gchar *id,
EmpathyIrcNetwork *network,
GSList **list)
{
@@ -376,6 +376,42 @@ append_network_to_list (const gchar *id,
*list = g_slist_prepend (*list, g_object_ref (network));
}
+static void
+append_dropped_networks_to_list (const gchar *id,
+ EmpathyIrcNetwork *network,
+ GSList **list)
+{
+ if (!network->dropped)
+ return;
+
+ *list = g_slist_prepend (*list, g_object_ref (network));
+}
+
+static GSList *
+get_network_list (EmpathyIrcNetworkManager *self,
+ gboolean get_active)
+{
+ EmpathyIrcNetworkManagerPriv *priv;
+ GSList *irc_networks = NULL;
+
+ g_return_val_if_fail (EMPATHY_IS_IRC_NETWORK_MANAGER (self), NULL);
+
+ priv = GET_PRIV (self);
+
+ if (get_active)
+ {
+ g_hash_table_foreach (priv->networks,
+ (GHFunc) append_active_networks_to_list, &irc_networks);
+ }
+ else
+ {
+ g_hash_table_foreach (priv->networks,
+ (GHFunc) append_dropped_networks_to_list, &irc_networks);
+ }
+
+ return irc_networks;
+}
+
/**
* empathy_irc_network_manager_get_networks:
* @manager: an #EmpathyIrcNetworkManager
@@ -388,17 +424,22 @@ append_network_to_list (const gchar *id,
GSList *
empathy_irc_network_manager_get_networks (EmpathyIrcNetworkManager *self)
{
- EmpathyIrcNetworkManagerPriv *priv;
- GSList *irc_networks = NULL;
-
- g_return_val_if_fail (EMPATHY_IS_IRC_NETWORK_MANAGER (self), NULL);
-
- priv = GET_PRIV (self);
-
- g_hash_table_foreach (priv->networks, (GHFunc) append_network_to_list,
- &irc_networks);
+ return get_network_list (self, TRUE);
+}
- return irc_networks;
+/**
+ * empathy_irc_network_manager_get_dropped_networks:
+ * @manager: an #EmpathyIrcNetworkManager
+ *
+ * Get the list of dropped #EmpathyIrcNetworks associated with the given
+ * manager.
+ *
+ * Returns: a new #GSList of refed dropped #EmpathyIrcNetworks
+ */
+GSList *
+empathy_irc_network_manager_get_dropped_networks (EmpathyIrcNetworkManager *self)
+{
+ return get_network_list (self, FALSE);
}
/*
diff --git a/libempathy/empathy-irc-network-manager.h b/libempathy/empathy-irc-network-manager.h
index 11c84836f..19df2f7e1 100644
--- a/libempathy/empathy-irc-network-manager.h
+++ b/libempathy/empathy-irc-network-manager.h
@@ -74,6 +74,9 @@ void empathy_irc_network_manager_remove (EmpathyIrcNetworkManager *manager,
GSList * empathy_irc_network_manager_get_networks (
EmpathyIrcNetworkManager *manager);
+GSList * empathy_irc_network_manager_get_dropped_networks (
+ EmpathyIrcNetworkManager *manager);
+
EmpathyIrcNetwork * empathy_irc_network_manager_find_network_by_address (
EmpathyIrcNetworkManager *manager, const gchar *address);
diff --git a/libempathy/empathy-irc-network.c b/libempathy/empathy-irc-network.c
index d5b0bdcb9..68e071be8 100644
--- a/libempathy/empathy-irc-network.c
+++ b/libempathy/empathy-irc-network.c
@@ -206,7 +206,8 @@ empathy_irc_network_class_init (EmpathyIrcNetworkClass *klass)
* EmpathyIrcNetwork::modified:
* @network: the object that received the signal
*
- * Emitted when either a property or a server of the network is modified.
+ * Emitted when either a property or a server of the network is modified or
+ * when a network is activated.
*
*/
signals[MODIFIED] = g_signal_new (
@@ -220,6 +221,24 @@ empathy_irc_network_class_init (EmpathyIrcNetworkClass *klass)
}
/**
+ * empathy_irc_network_activate:
+ * @self: the name of the network
+ *
+ * Activates a #EmpathyIrcNetwork.
+ *
+ */
+void
+empathy_irc_network_activate (EmpathyIrcNetwork *self)
+{
+ g_return_if_fail (EMPATHY_IS_IRC_NETWORK (self));
+ g_return_if_fail (self->dropped);
+
+ self->dropped = FALSE;
+
+ g_signal_emit (self, signals[MODIFIED], 0);
+}
+
+/**
* empathy_irc_network_new:
* @name: the name of the network
*
diff --git a/libempathy/empathy-irc-network.h b/libempathy/empathy-irc-network.h
index 9d78f3c3f..a298ced9a 100644
--- a/libempathy/empathy-irc-network.h
+++ b/libempathy/empathy-irc-network.h
@@ -62,6 +62,8 @@ GType empathy_irc_network_get_type (void);
(G_TYPE_INSTANCE_GET_CLASS ((o), EMPATHY_TYPE_IRC_NETWORK, \
EmpathyIrcNetworkClass))
+void empathy_irc_network_activate (EmpathyIrcNetwork *self);
+
EmpathyIrcNetwork * empathy_irc_network_new (const gchar *name);
GSList * empathy_irc_network_get_servers (EmpathyIrcNetwork *network);