PROP_NETWORK
};
+enum {
+ RESPONSE_RESET = 0
+};
+
typedef struct {
EmpathyAccountSettings *settings;
EmpathyIrcNetwork *network;
g_object_unref (network);
}
+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,
edit_network (self);
else if (response == GTK_RESPONSE_REJECT)
remove_network (self);
+ else if (response == RESPONSE_RESET)
+ reset_networks (self);
}
static gboolean
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,
}
static void
-append_network_to_list (const gchar *id,
+append_active_networks_to_list (const gchar *id,
EmpathyIrcNetwork *network,
GSList **list)
{
*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
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);
}
/*
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);
* 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 (
G_TYPE_NONE, 0);
}
+/**
+ * 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
(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);