# HG changeset patch
# Node ID 12428a1afe99
# Parent  62072a413983
diff --git a/gplugin/gplugin-manager.c b/gplugin/gplugin-manager.c
--- a/gplugin/gplugin-manager.c
+++ b/gplugin/gplugin-manager.c
@@ -65,10 +65,6 @@ enum {
  *****************************************************************************/
 struct _GPluginManager {
 	GObject parent;
-};
-
-typedef struct {
-	GObject parent;
 
 	GQueue *paths;
 	GHashTable *plugins;
@@ -78,9 +74,9 @@ typedef struct {
 	GHashTable *loaders_by_extension;
 
 	gboolean refresh_needed;
-} GPluginManagerPrivate;
+};
 
-G_DEFINE_TYPE_WITH_PRIVATE(GPluginManager, gplugin_manager, G_TYPE_OBJECT)
+G_DEFINE_TYPE(GPluginManager, gplugin_manager, G_TYPE_OBJECT)
 
 /******************************************************************************
  * Globals
@@ -275,36 +271,35 @@ static void
 gplugin_manager_finalize(GObject *obj)
 {
 	GPluginManager *manager = GPLUGIN_MANAGER(obj);
-	GPluginManagerPrivate *priv = gplugin_manager_get_instance_private(manager);
 
-	g_queue_free_full(priv->paths, g_free);
-	priv->paths = NULL;
+	g_queue_free_full(manager->paths, g_free);
+	manager->paths = NULL;
 
 	/* unload all of the loaded plugins */
 	g_hash_table_foreach(
-		priv->plugins,
+		manager->plugins,
 		gplugin_manager_foreach_unload_plugin,
 		NULL);
 
 	/* free all the data in the plugins hash table and destroy it */
 	g_hash_table_foreach_remove(
-		priv->plugins,
+		manager->plugins,
 		gplugin_manager_remove_list_value,
 		NULL);
-	g_clear_pointer(&priv->plugins, g_hash_table_destroy);
+	g_clear_pointer(&manager->plugins, g_hash_table_destroy);
 
 	/* destroy the filename view */
-	g_clear_pointer(&priv->plugins_filename_view, g_hash_table_destroy);
+	g_clear_pointer(&manager->plugins_filename_view, g_hash_table_destroy);
 
 	/* clean up our list of loaders */
-	g_clear_pointer(&priv->loaders, g_hash_table_destroy);
+	g_clear_pointer(&manager->loaders, g_hash_table_destroy);
 
 	/* free all the data in the loaders hash table and destroy it */
 	g_hash_table_foreach_remove(
-		priv->loaders_by_extension,
+		manager->loaders_by_extension,
 		gplugin_manager_remove_list_value,
 		NULL);
-	g_clear_pointer(&priv->loaders_by_extension, g_hash_table_destroy);
+	g_clear_pointer(&manager->loaders_by_extension, g_hash_table_destroy);
 
 	/* call the base class's destructor */
 	G_OBJECT_CLASS(gplugin_manager_parent_class)->finalize(obj);
@@ -445,23 +440,21 @@ gplugin_manager_class_init(GPluginManage
 static void
 gplugin_manager_init(GPluginManager *manager)
 {
-	GPluginManagerPrivate *priv = gplugin_manager_get_instance_private(manager);
-
-	priv->paths = g_queue_new();
+	manager->paths = g_queue_new();
 
 	/* the plugins hashtable is keyed on a plugin id and holds a GSList of all
 	 * plugins that share that id.
 	 */
-	priv->plugins =
+	manager->plugins =
 		g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL);
 
 	/* the filename view is hash table keyed on the filename of the plugin with
 	 * a value of the plugin itself.
 	 */
-	priv->plugins_filename_view =
+	manager->plugins_filename_view =
 		g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_object_unref);
 
-	priv->loaders =
+	manager->loaders =
 		g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_object_unref);
 
 	/* The loaders_by_extension hash table is keyed on the supported extensions
@@ -475,7 +468,7 @@ gplugin_manager_init(GPluginManager *man
 	 * to use by the filename and helps us to avoid iterating the loaders table
 	 * again and again.
 	 */
-	priv->loaders_by_extension = g_hash_table_new_full(
+	manager->loaders_by_extension = g_hash_table_new_full(
 		gplugin_manager_str_hash,
 		g_str_equal,
 		g_free,
@@ -548,7 +541,6 @@ gplugin_manager_private_uninit(void)
 void
 gplugin_manager_append_path(GPluginManager *manager, const gchar *path)
 {
-	GPluginManagerPrivate *priv = NULL;
 	GList *l = NULL;
 	gchar *normalized = NULL;
 
@@ -557,14 +549,12 @@ gplugin_manager_append_path(GPluginManag
 
 	normalized = gplugin_manager_normalize_path(path);
 
-	priv = gplugin_manager_get_instance_private(manager);
-
 	l = g_queue_find_custom(
-		priv->paths,
+		manager->paths,
 		normalized,
 		gplugin_manager_compare_paths);
 	if(l == NULL) {
-		g_queue_push_tail(priv->paths, normalized);
+		g_queue_push_tail(manager->paths, normalized);
 	} else {
 		g_free(normalized);
 	}
@@ -580,7 +570,6 @@ gplugin_manager_append_path(GPluginManag
 void
 gplugin_manager_prepend_path(GPluginManager *manager, const gchar *path)
 {
-	GPluginManagerPrivate *priv = NULL;
 	GList *l = NULL;
 	gchar *normalized = NULL;
 
@@ -589,14 +578,12 @@ gplugin_manager_prepend_path(GPluginMana
 
 	normalized = gplugin_manager_normalize_path(path);
 
-	priv = gplugin_manager_get_instance_private(manager);
-
 	l = g_queue_find_custom(
-		priv->paths,
+		manager->paths,
 		normalized,
 		gplugin_manager_compare_paths);
 	if(l == NULL) {
-		g_queue_push_head(priv->paths, normalized);
+		g_queue_push_head(manager->paths, normalized);
 	} else {
 		g_free(normalized);
 	}
@@ -612,7 +599,6 @@ gplugin_manager_prepend_path(GPluginMana
 void
 gplugin_manager_remove_path(GPluginManager *manager, const gchar *path)
 {
-	GPluginManagerPrivate *priv = NULL;
 	GList *l = NULL;
 	gchar *normalized = NULL;
 
@@ -621,15 +607,13 @@ gplugin_manager_remove_path(GPluginManag
 
 	normalized = gplugin_manager_normalize_path(path);
 
-	priv = gplugin_manager_get_instance_private(manager);
-
 	l = g_queue_find_custom(
-		priv->paths,
+		manager->paths,
 		normalized,
 		gplugin_manager_compare_paths);
 	if(l != NULL) {
 		g_free(l->data);
-		g_queue_delete_link(priv->paths, l);
+		g_queue_delete_link(manager->paths, l);
 	}
 
 	g_free(normalized);
@@ -644,13 +628,9 @@ gplugin_manager_remove_path(GPluginManag
 void
 gplugin_manager_remove_paths(GPluginManager *manager)
 {
-	GPluginManagerPrivate *priv = NULL;
-
 	g_return_if_fail(GPLUGIN_IS_MANAGER(manager));
 
-	priv = gplugin_manager_get_instance_private(manager);
-
-	g_queue_clear_full(priv->paths, g_free);
+	g_queue_clear_full(manager->paths, g_free);
 }
 
 /**
@@ -754,13 +734,9 @@ gplugin_manager_prepend_paths_from_envir
 GList *
 gplugin_manager_get_paths(GPluginManager *manager)
 {
-	GPluginManagerPrivate *priv = NULL;
-
 	g_return_val_if_fail(GPLUGIN_IS_MANAGER(manager), NULL);
 
-	priv = gplugin_manager_get_instance_private(manager);
-
-	return priv->paths->head;
+	return manager->paths->head;
 }
 
 /**
@@ -780,7 +756,6 @@ gplugin_manager_register_loader(
 	GPluginLoader *loader,
 	GError **error)
 {
-	GPluginManagerPrivate *priv = NULL;
 	GPluginLoader *found = NULL;
 	GSList *l = NULL, *exts = NULL;
 	const gchar *id = NULL;
@@ -788,10 +763,8 @@ gplugin_manager_register_loader(
 	g_return_val_if_fail(GPLUGIN_IS_MANAGER(manager), FALSE);
 	g_return_val_if_fail(GPLUGIN_IS_LOADER(loader), FALSE);
 
-	priv = gplugin_manager_get_instance_private(manager);
-
 	id = gplugin_loader_get_id(loader);
-	found = g_hash_table_lookup(priv->loaders, id);
+	found = g_hash_table_lookup(manager->loaders, id);
 	if(GPLUGIN_IS_LOADER(found)) {
 		g_set_error(
 			error,
@@ -802,7 +775,7 @@ gplugin_manager_register_loader(
 		return FALSE;
 	}
 
-	g_hash_table_insert(priv->loaders, g_strdup(id), g_object_ref(loader));
+	g_hash_table_insert(manager->loaders, g_strdup(id), g_object_ref(loader));
 
 	exts = gplugin_loader_get_supported_extensions(loader);
 	for(l = exts; l; l = l->next) {
@@ -813,7 +786,7 @@ gplugin_manager_register_loader(
 		 * we can prepend our loader.  But before we add ours, we remove any
 		 * old copies we might have of ours.
 		 */
-		existing = g_hash_table_lookup(priv->loaders_by_extension, ext);
+		existing = g_hash_table_lookup(manager->loaders_by_extension, ext);
 		for(ll = existing; ll; ll = ll->next) {
 			GPluginLoader *iter = GPLUGIN_LOADER(ll->data);
 			const gchar *ext_id = gplugin_loader_get_id(iter);
@@ -831,14 +804,14 @@ gplugin_manager_register_loader(
 
 		/* Now insert the updated slist back into the hash table */
 		g_hash_table_insert(
-			priv->loaders_by_extension,
+			manager->loaders_by_extension,
 			g_strdup(ext),
 			existing);
 	}
 	g_slist_free(exts);
 
 	/* make a note that we need to refresh */
-	priv->refresh_needed = TRUE;
+	manager->refresh_needed = TRUE;
 
 	return TRUE;
 }
@@ -860,18 +833,15 @@ gplugin_manager_unregister_loader(
 	GPluginLoader *loader,
 	GError **error)
 {
-	GPluginManagerPrivate *priv = NULL;
 	GSList *l = NULL, *exts = NULL;
 	const gchar *id = NULL;
 
 	g_return_val_if_fail(GPLUGIN_IS_MANAGER(manager), FALSE);
 	g_return_val_if_fail(GPLUGIN_IS_LOADER(loader), FALSE);
 
-	priv = gplugin_manager_get_instance_private(manager);
-
 	id = gplugin_loader_get_id(loader);
 
-	loader = g_hash_table_lookup(priv->loaders, id);
+	loader = g_hash_table_lookup(manager->loaders, id);
 	if(!GPLUGIN_IS_LOADER(loader)) {
 		g_set_error(
 			error,
@@ -890,7 +860,7 @@ gplugin_manager_unregister_loader(
 		const gchar *ext = NULL;
 
 		ext = (const gchar *)exts->data;
-		los = g_hash_table_lookup(priv->loaders_by_extension, ext);
+		los = g_hash_table_lookup(manager->loaders_by_extension, ext);
 
 		for(ll = los; ll; ll = ll->next) {
 			GPluginLoader *lo = GPLUGIN_LOADER(ll->data);
@@ -908,11 +878,11 @@ gplugin_manager_unregister_loader(
 			los = g_slist_remove(los, lo);
 			if(los) {
 				g_hash_table_insert(
-					priv->loaders_by_extension,
+					manager->loaders_by_extension,
 					g_strdup(ext),
 					los);
 			} else {
-				g_hash_table_remove(priv->loaders_by_extension, ext);
+				g_hash_table_remove(manager->loaders_by_extension, ext);
 			}
 
 			/* kill our ref to the loader */
@@ -924,7 +894,7 @@ gplugin_manager_unregister_loader(
 	}
 	g_slist_free(exts);
 
-	g_hash_table_remove(priv->loaders, id);
+	g_hash_table_remove(manager->loaders, id);
 
 	return TRUE;
 }
@@ -941,13 +911,9 @@ gplugin_manager_unregister_loader(
 GList *
 gplugin_manager_get_loaders(GPluginManager *manager)
 {
-	GPluginManagerPrivate *priv = NULL;
-
 	g_return_val_if_fail(GPLUGIN_IS_MANAGER(manager), FALSE);
 
-	priv = gplugin_manager_get_instance_private(manager);
-
-	return g_hash_table_get_values(priv->loaders);
+	return g_hash_table_get_values(manager->loaders);
 }
 
 /**
@@ -959,7 +925,6 @@ gplugin_manager_get_loaders(GPluginManag
 void
 gplugin_manager_refresh(GPluginManager *manager)
 {
-	GPluginManagerPrivate *priv = NULL;
 	GNode *root = NULL;
 	GList *error_messages = NULL, *l = NULL;
 	gchar *error_message = NULL;
@@ -967,14 +932,12 @@ gplugin_manager_refresh(GPluginManager *
 
 	g_return_if_fail(GPLUGIN_IS_MANAGER(manager));
 
-	priv = gplugin_manager_get_instance_private(manager);
+	/* build a tree of all possible plugins */
+	root = gplugin_file_tree_new(manager->paths->head);
 
-	/* build a tree of all possible plugins */
-	root = gplugin_file_tree_new(priv->paths->head);
+	manager->refresh_needed = TRUE;
 
-	priv->refresh_needed = TRUE;
-
-	while(priv->refresh_needed) {
+	while(manager->refresh_needed) {
 		GNode *dir = NULL;
 
 		if(error_messages) {
@@ -984,7 +947,7 @@ gplugin_manager_refresh(GPluginManager *
 			error_messages = NULL;
 		}
 
-		priv->refresh_needed = FALSE;
+		manager->refresh_needed = FALSE;
 
 		for(dir = root->children; dir; dir = dir->next) {
 			GPluginFileTreeEntry *e = dir->data;
@@ -1003,7 +966,7 @@ gplugin_manager_refresh(GPluginManager *
 				/* Build the path and see if we need to probe it! */
 				filename = g_build_filename(path, e->filename, NULL);
 				plugin =
-					g_hash_table_lookup(priv->plugins_filename_view, filename);
+					g_hash_table_lookup(manager->plugins_filename_view, filename);
 
 				if(plugin && GPLUGIN_IS_PLUGIN(plugin)) {
 					GPluginPluginState state = gplugin_plugin_get_state(plugin);
@@ -1020,7 +983,7 @@ gplugin_manager_refresh(GPluginManager *
 
 				/* grab the list of loaders for this extension */
 				l = g_hash_table_lookup(
-					priv->loaders_by_extension,
+					manager->loaders_by_extension,
 					e->extension);
 				for(; l; l = l->next) {
 					if(!GPLUGIN_IS_LOADER(l->data)) {
@@ -1107,14 +1070,14 @@ gplugin_manager_refresh(GPluginManager *
 
 					/* now insert into our view */
 					g_hash_table_replace(
-						priv->plugins_filename_view,
+						manager->plugins_filename_view,
 						real_filename,
 						g_object_ref(G_OBJECT(plugin)));
 
 					/* Grab the list of plugins with our id and prepend the new
 					 * plugin to it before updating it.
 					 */
-					l = g_hash_table_lookup(priv->plugins, id);
+					l = g_hash_table_lookup(manager->plugins, id);
 					for(ll = l; ll; ll = ll->next) {
 						GPluginPlugin *splugin = GPLUGIN_PLUGIN(ll->data);
 						gchar *sfilename = gplugin_plugin_get_filename(splugin);
@@ -1126,7 +1089,7 @@ gplugin_manager_refresh(GPluginManager *
 					}
 					if(!seen) {
 						l = g_slist_prepend(l, g_object_ref(plugin));
-						g_hash_table_insert(priv->plugins, g_strdup(id), l);
+						g_hash_table_insert(manager->plugins, g_strdup(id), l);
 					}
 
 					/* check if the plugin is supposed to be loaded on query,
@@ -1157,7 +1120,7 @@ gplugin_manager_refresh(GPluginManager *
 						 */
 						if(errors > 0) {
 							errors = 0;
-							priv->refresh_needed = TRUE;
+							manager->refresh_needed = TRUE;
 						}
 					}
 
@@ -1202,16 +1165,13 @@ gplugin_manager_foreach(
 	GPluginManagerForeachFunc func,
 	gpointer data)
 {
-	GPluginManagerPrivate *priv = NULL;
 	GHashTableIter iter;
 	gpointer id = NULL, plugins = NULL;
 
 	g_return_if_fail(GPLUGIN_IS_MANAGER(manager));
 	g_return_if_fail(func != NULL);
 
-	priv = gplugin_manager_get_instance_private(manager);
-
-	g_hash_table_iter_init(&iter, priv->plugins);
+	g_hash_table_iter_init(&iter, manager->plugins);
 	while(g_hash_table_iter_next(&iter, &id, &plugins)) {
 		func((gchar *)id, (GSList *)plugins, data);
 	}
@@ -1230,15 +1190,12 @@ gplugin_manager_foreach(
 GSList *
 gplugin_manager_find_plugins(GPluginManager *manager, const gchar *id)
 {
-	GPluginManagerPrivate *priv = NULL;
 	GSList *plugins_list = NULL, *l;
 
 	g_return_val_if_fail(GPLUGIN_IS_MANAGER(manager), NULL);
 	g_return_val_if_fail(id != NULL, NULL);
 
-	priv = gplugin_manager_get_instance_private(manager);
-
-	l = g_hash_table_lookup(priv->plugins, id);
+	l = g_hash_table_lookup(manager->plugins, id);
 	plugins_list = g_slist_copy_deep(l, (GCopyFunc)g_object_ref, NULL);
 
 	return plugins_list;
@@ -1336,16 +1293,13 @@ gplugin_manager_find_plugins_with_state(
 	GPluginManager *manager,
 	GPluginPluginState state)
 {
-	GPluginManagerPrivate *priv = NULL;
 	GSList *plugins = NULL;
 	GHashTableIter iter;
 	gpointer value = NULL;
 
 	g_return_val_if_fail(GPLUGIN_IS_MANAGER(manager), NULL);
 
-	priv = gplugin_manager_get_instance_private(manager);
-
-	g_hash_table_iter_init(&iter, priv->plugins);
+	g_hash_table_iter_init(&iter, manager->plugins);
 	while(g_hash_table_iter_next(&iter, NULL, &value)) {
 		GSList *l = NULL;
 
@@ -1771,7 +1725,6 @@ gplugin_manager_unload_plugin(
 GList *
 gplugin_manager_list_plugins(GPluginManager *manager)
 {
-	GPluginManagerPrivate *priv = NULL;
 	GQueue *queue = NULL;
 	GList *ret = NULL;
 	GHashTableIter iter;
@@ -1779,10 +1732,9 @@ gplugin_manager_list_plugins(GPluginMana
 
 	g_return_val_if_fail(GPLUGIN_IS_MANAGER(manager), NULL);
 
-	priv = gplugin_manager_get_instance_private(manager);
 	queue = g_queue_new();
 
-	g_hash_table_iter_init(&iter, priv->plugins);
+	g_hash_table_iter_init(&iter, manager->plugins);
 	while(g_hash_table_iter_next(&iter, &key, NULL)) {
 		g_queue_push_tail(queue, (gchar *)key);
 	}
