aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy
diff options
context:
space:
mode:
authorChandni Verma <chandniverma2112@gmail.com>2011-02-14 10:11:30 +0800
committerChandni Verma <chandniverma2112@gmail.com>2011-02-15 01:08:46 +0800
commitc7e246e02d143268e0e8fc310c2078d312e4b91a (patch)
tree7e2bef519932cc37cea8ae670143ec86b6f3ff84 /libempathy
parent9314023680793975ddd928ca3f7b672b605da760 (diff)
downloadgsoc2013-empathy-c7e246e02d143268e0e8fc310c2078d312e4b91a.tar
gsoc2013-empathy-c7e246e02d143268e0e8fc310c2078d312e4b91a.tar.gz
gsoc2013-empathy-c7e246e02d143268e0e8fc310c2078d312e4b91a.tar.bz2
gsoc2013-empathy-c7e246e02d143268e0e8fc310c2078d312e4b91a.tar.lz
gsoc2013-empathy-c7e246e02d143268e0e8fc310c2078d312e4b91a.tar.xz
gsoc2013-empathy-c7e246e02d143268e0e8fc310c2078d312e4b91a.tar.zst
gsoc2013-empathy-c7e246e02d143268e0e8fc310c2078d312e4b91a.zip
Reset network list button
Fixes: https://bugzilla.gnome.org/show_bug.cgi?id=642264
Diffstat (limited to 'libempathy')
-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
4 files changed, 77 insertions, 12 deletions
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);