/** * anjuta_profile_manager_get_current : * @profile_manager: A #AnjutaProfileManager object. * * Return the current profile. * * Return value: (transfer none) (allow-none): a #AnjutaProfile object or %NULL * if the profile stack is empty. */ AnjutaProfile* anjuta_profile_manager_get_current (AnjutaProfileManager *profile_manager) { g_return_val_if_fail (ANJUTA_IS_PROFILE_MANAGER (profile_manager), NULL); if (profile_manager->priv->profiles_queue) return ANJUTA_PROFILE (profile_manager->priv->profiles_queue->data); else if (profile_manager->priv->profiles) return ANJUTA_PROFILE (profile_manager->priv->profiles->data); else return NULL; }
/** * anjuta_profile_manager_close: * @profile_manager: A #AnjutaProfileManager object. * * Close the #AnjutaProfileManager causing "descoped" to be emitted and * all queued and previous profiles to be released. This function is to be used * when destroying an Anjuta instance. */ void anjuta_profile_manager_close (AnjutaProfileManager *profile_manager) { AnjutaProfileManagerPriv *priv; g_return_if_fail (ANJUTA_IS_PROFILE_MANAGER (profile_manager)); priv = profile_manager->priv; if (priv->profiles) { AnjutaProfile *profile = ANJUTA_PROFILE (priv->profiles->data); /* Emit "descoped" so that other parts of anjuta can store * information about the currently loaded profile. */ anjuta_profile_unload (profile, NULL); g_list_free_full (priv->profiles, g_object_unref); priv->profiles = NULL; } if (priv->profiles_queue) { g_list_free_full (priv->profiles, g_object_unref); priv->profiles_queue = NULL; } }
static void anjuta_profile_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { AnjutaProfilePriv *priv = ANJUTA_PROFILE (object)->priv; g_return_if_fail (ANJUTA_IS_PROFILE (object)); switch (prop_id) { case PROP_PLUGIN_MANAGER: g_value_set_object (value, priv->plugin_manager); break; case PROP_PROFILE_NAME: g_value_set_string (value, priv->name); break; case PROP_PROFILE_PLUGINS: g_value_set_pointer (value, priv->plugins); break; case PROP_SYNC_FILE: g_value_set_object (value, priv->sync_file); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } }
static gboolean anjuta_profile_manager_load_profiles (AnjutaProfileManager *profile_manager, GError **error) { AnjutaProfileManagerPriv *priv; gboolean loaded = FALSE; priv = profile_manager->priv; /* If there is no freeze load profile now */ while ((priv->freeze_count <= 0) && (priv->profiles_queue != NULL)) { AnjutaProfile *previous_profile = NULL; GList *node; /* We need to load each profile one by one because a "system" profile * contains plugins which are never unloaded. */ if (priv->profiles) previous_profile = priv->profiles->data; node = g_list_last (priv->profiles_queue); priv->profiles_queue = g_list_remove_link (priv->profiles_queue, node); priv->profiles = g_list_concat (node, priv->profiles); /* Load profile. Note that loading a profile can trigger the load of * additional profile. Typically loading the default profile will * trigger the load of the last project profile. */ if (previous_profile != NULL) anjuta_profile_unload (previous_profile, NULL); loaded = anjuta_profile_load (ANJUTA_PROFILE (node->data), error); } return loaded; }
/** * anjuta_profile_get_plugins: * @profile: a #AnjutaProfile object. * * Get the profile current plugins list. * * Return value: the plugins list. */ GList* anjuta_profile_get_plugins (AnjutaProfile *profile) { AnjutaProfilePriv *priv; g_return_val_if_fail (ANJUTA_IS_PROFILE (profile), FALSE); priv = ANJUTA_PROFILE (profile)->priv; return priv->plugins; }
/** * anjuta_profile_get_name: * @profile: a #AnjutaProfile object. * * Get the profile name. * * Return value: the profile name. */ const gchar* anjuta_profile_get_name (AnjutaProfile *profile) { AnjutaProfilePriv *priv; g_return_val_if_fail (ANJUTA_IS_PROFILE (profile), NULL); priv = ANJUTA_PROFILE (profile)->priv; return priv->name; }
/** * anjuta_profile_new: * @name: the new profile name. * @plugin_manager: the #AnjutaPluginManager used by this profile. * * Create a new profile. * * Return value: the new #AnjutaProfile object. */ AnjutaProfile* anjuta_profile_new (const gchar* name, AnjutaPluginManager *plugin_manager) { GObject *profile; profile = g_object_new (ANJUTA_TYPE_PROFILE, "profile-name", name, "plugin-manager", plugin_manager, NULL); return ANJUTA_PROFILE (profile); }
/** * anjuta_profile_has_plugin: * @profile: a #AnjutaProfile object * @plugin: a #AnjutaPluginDescription * * Check if a plugin is included in the profile plugin list. * * Return value: TRUE if the plugin is included in the list. */ gboolean anjuta_profile_has_plugin (AnjutaProfile *profile, AnjutaPluginDescription *plugin) { AnjutaProfilePriv *priv; g_return_val_if_fail (ANJUTA_IS_PROFILE (profile), FALSE); g_return_val_if_fail (plugin != NULL, FALSE); priv = ANJUTA_PROFILE (profile)->priv; return (priv->plugins != NULL && g_list_find (priv->plugins, plugin) != NULL); }
static void anjuta_profile_finalize (GObject *object) { AnjutaProfilePriv *priv = ANJUTA_PROFILE (object)->priv; g_free (priv->name); if (priv->plugins) g_list_free (priv->plugins); g_hash_table_destroy (priv->plugins_hash); g_hash_table_destroy (priv->plugins_to_exclude_from_sync); G_OBJECT_CLASS (parent_class)->finalize (object); }
/** * anjuta_profile_remove_plugin: * @profile: a #AnjutaProfile object. * @plugin: a #AnjutaPluginDescription. * * Remove one plugin from the profile plugin list. */ void anjuta_profile_remove_plugin (AnjutaProfile *profile, AnjutaPluginDescription *plugin) { AnjutaProfilePriv *priv; g_return_if_fail (ANJUTA_IS_PROFILE (profile)); g_return_if_fail (plugin != NULL); priv = ANJUTA_PROFILE (profile)->priv; if (priv->plugins && g_list_find (priv->plugins, plugin) != NULL) { priv->plugins = g_list_remove (priv->plugins, plugin); g_signal_emit_by_name (profile, "plugin-removed", plugin); g_signal_emit_by_name (profile, "changed", priv->plugins); } }
/** * anjuta_profile_manager_pop: * @profile_manager: the #AnjutaProfileManager object. * @profile: the #AnjutaProfile to remove. * @error: error propagation and reporting. * * Remove a profile from the profile manager stack. If the manager is not * frozen, only the current profile can be removed. It will be unloaded and * the previous profile will be loaded. * If the manager is frozen, the current profile or the last pushed profile * can be removed. * * Return value: %TRUE on success, %FALSE otherwise. */ gboolean anjuta_profile_manager_pop (AnjutaProfileManager *profile_manager, AnjutaProfile *profile, GError **error) { AnjutaProfileManagerPriv *priv; g_return_val_if_fail (ANJUTA_IS_PROFILE_MANAGER (profile_manager), FALSE); priv = profile_manager->priv; /* First check in the queue */ if (priv->profiles_queue) { g_return_val_if_fail (priv->profiles_queue->data == profile, FALSE); priv->profiles_queue = g_list_remove (priv->profiles_queue, profile); g_signal_emit_by_name (profile_manager, "profile-popped", profile); g_object_unref (profile); return TRUE; } /* Then check in the current stack */ if (priv->profiles) { g_return_val_if_fail (priv->profiles->data == profile, FALSE); priv->profiles = g_list_remove (priv->profiles, profile); g_signal_emit_by_name (profile_manager, "profile-popped", profile); /* Restore the next profile in the stack */ anjuta_profile_unload (profile, NULL); g_object_unref (profile); if (priv->profiles) { return anjuta_profile_load (ANJUTA_PROFILE (priv->profiles->data), error); } return TRUE; } return FALSE; }
static void anjuta_profile_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { AnjutaProfilePriv *priv = ANJUTA_PROFILE (object)->priv; g_return_if_fail (ANJUTA_IS_PROFILE (object)); switch (prop_id) { case PROP_PLUGIN_MANAGER: priv->plugin_manager = g_value_get_object (value); break; case PROP_PROFILE_NAME: g_return_if_fail (g_value_get_string (value) != NULL); g_free (priv->name); priv->name = g_strdup (g_value_get_string (value)); break; case PROP_PROFILE_PLUGINS: if (priv->plugins) g_list_free (priv->plugins); if (g_value_get_pointer (value)) priv->plugins = g_list_copy (g_value_get_pointer (value)); else priv->plugins = NULL; break; case PROP_SYNC_FILE: if (priv->sync_file) g_object_unref (priv->sync_file); priv->sync_file = g_value_dup_object (value); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } }