BuildContext* build_configure_dialog (BasicAutotoolsPlugin *plugin, BuildFunc func, GFile *file, IAnjutaBuilderCallback callback, gpointer user_data, GError **error) { GtkWindow *parent; gboolean run_autogen = FALSE; const gchar *project_root; GValue value = {0,}; const gchar *old_config_name; BuildContext* context = NULL; run_autogen = !directory_has_file (plugin->project_root_dir, "configure"); anjuta_shell_get_value (ANJUTA_PLUGIN (plugin)->shell, IANJUTA_PROJECT_MANAGER_PROJECT_ROOT_URI, &value, NULL); /* In case, a project is not loaded */ if (!G_VALUE_HOLDS_STRING (&value)) return NULL; project_root = g_value_get_string (&value); parent = GTK_WINDOW (ANJUTA_PLUGIN(plugin)->shell); old_config_name = build_configuration_get_name (build_configuration_list_get_selected (plugin->configurations)); if (build_dialog_configure (parent, project_root, plugin->configurations, &run_autogen)) { BuildConfiguration *config; GFile *build_file; gchar *build_uri; const gchar *args; config = build_configuration_list_get_selected (plugin->configurations); build_uri = build_configuration_list_get_build_uri (plugin->configurations, config); build_file = g_file_new_for_uri (build_uri); g_free (build_uri); args = build_configuration_get_args (config); if (run_autogen) { context = build_generate_dir (plugin, build_file, args, func, file, callback, user_data, error); } else { context = build_configure_dir (plugin, build_file, args, func, file, callback, user_data, error); } g_object_unref (build_file); if (context == NULL) { /* Restore previous configuration */ build_configuration_list_select (plugin->configurations, old_config_name); } } return context; }
static void update_type_list (AnjutaShell *shell, IAnjutaIterable *iter, const gchar *name) { gchar *list = NULL; GValue value = {0,}; if (iter) { ianjuta_iterable_first (iter, NULL); if (ianjuta_iterable_get_length (iter, NULL) > 0) { GString *s = g_string_sized_new(ianjuta_iterable_get_length (iter, NULL) * 10); do { IAnjutaSymbol *symbol = IANJUTA_SYMBOL (iter); const gchar *sname = ianjuta_symbol_get_string (symbol, IANJUTA_SYMBOL_FIELD_NAME, NULL); g_string_append(s, sname); g_string_append_c(s, ' '); } while (ianjuta_iterable_next (iter, NULL)); list = g_string_free(s, FALSE); } } anjuta_shell_get_value (shell, name, &value, NULL); if (G_VALUE_HOLDS_STRING(&value)) { const gchar *value_list = g_value_get_string (&value); if (list == NULL) { anjuta_shell_remove_value (shell, name, NULL); } else if (strcmp (list, value_list) == 0) { g_free (list); } else { g_value_take_string (&value, list); anjuta_shell_add_value (shell, name, &value, NULL); } } else { if (list != NULL) { g_value_init (&value, G_TYPE_STRING); g_value_take_string (&value, list); anjuta_shell_add_value (shell, name, &value, NULL); } } if (G_IS_VALUE (&value)) g_value_unset (&value); }
/** * anjuta_shell_get_valist: * @shell: A #AnjutaShell interface * @first_name: First value name * @first_type: First value type * @var_args: First value holder, Second value name, Second value type .... * * Gets a valist of values from the shell. The valist should be in the order - * value1, name2, type2, value2,... */ void anjuta_shell_get_valist (AnjutaShell *shell, const char *first_name, GType first_type, va_list var_args) { const char *name; GType type; g_return_if_fail (shell != NULL); g_return_if_fail (ANJUTA_IS_SHELL (shell)); g_return_if_fail (first_name != NULL); name = first_name; type = first_type; while (name) { GValue value = {0, }; GError *err = NULL; char *error; g_value_init (&value, type); anjuta_shell_get_value (shell, name, &value, &err); if (err) { g_warning ("Could not get value: %s", err->message); g_error_free (err); break; } G_VALUE_LCOPY (&value, var_args, 0, &error); if (error) { g_warning ("%s: %s", G_STRLOC, error); g_free (error); break; } g_value_unset (&value); name = va_arg (var_args, char *); if (name) { type = va_arg (var_args, GType); } } }
static GList* get_source_directories (AnjutaPlugin *plugin) { gchar *cwd; GList *node, *search_dirs = NULL; GList *slibs_dirs = NULL; GList *libs_dirs = NULL; GValue value = {0,}; GFile *file; return NULL; cwd = anjuta_util_get_current_dir(); file = g_file_new_for_path (cwd); search_dirs = g_list_prepend (search_dirs, g_file_get_uri (file)); g_object_unref (file); g_free (cwd); /* Check if a project is already open */ anjuta_shell_get_value (plugin->shell, IANJUTA_PROJECT_MANAGER_PROJECT_ROOT_URI, &value, NULL); /* Set source file search directories */ if (g_value_get_string (&value) != NULL) { IAnjutaProjectManager *pm; pm = anjuta_shell_get_interface (plugin->shell, IAnjutaProjectManager, NULL); if (pm) { slibs_dirs = ianjuta_project_manager_get_targets (pm, ANJUTA_PROJECT_TARGET | ANJUTA_PROJECT_SHAREDLIB, NULL); libs_dirs = ianjuta_project_manager_get_targets (pm, ANJUTA_PROJECT_TARGET | ANJUTA_PROJECT_STATICLIB, NULL); } } slibs_dirs = g_list_reverse (slibs_dirs); libs_dirs = g_list_reverse (libs_dirs); node = slibs_dirs; while (node) { gchar *path; GFile *parent = g_file_get_parent (node->data); path = g_file_get_uri (parent); g_object_unref (parent); search_dirs = g_list_prepend (search_dirs, path); node = g_list_next (node); } node = libs_dirs; while (node) { gchar *path; path = g_file_get_path (node->data); search_dirs = g_list_prepend (search_dirs, path); node = g_list_next (node); } g_list_foreach (slibs_dirs, (GFunc)g_free, NULL); g_list_free (slibs_dirs); g_list_foreach (libs_dirs, (GFunc)g_free, NULL); g_list_free (libs_dirs); return g_list_reverse (search_dirs); }