anjuta r4091 - in trunk: . plugins/build-basic-autotools
- From: sgranjoux svn gnome org
- To: svn-commits-list gnome org
- Subject: anjuta r4091 - in trunk: . plugins/build-basic-autotools
- Date: Sun, 20 Jul 2008 18:54:33 +0000 (UTC)
Author: sgranjoux
Date: Sun Jul 20 18:54:33 2008
New Revision: 4091
URL: http://svn.gnome.org/viewvc/anjuta?rev=4091&view=rev
Log:
* plugins/build-basic-autotools/configuration-list.c,
plugins/build-basic-autotools/configuration-list.h,
plugins/build-basic-autotools/build-options.c:
Fix #543889: Crash typing in configuration field
Modified:
trunk/ChangeLog
trunk/plugins/build-basic-autotools/build-options.c
trunk/plugins/build-basic-autotools/configuration-list.c
trunk/plugins/build-basic-autotools/configuration-list.h
Modified: trunk/plugins/build-basic-autotools/build-options.c
==============================================================================
--- trunk/plugins/build-basic-autotools/build-options.c (original)
+++ trunk/plugins/build-basic-autotools/build-options.c Sun Jul 20 18:54:33 2008
@@ -265,25 +265,28 @@
cfg = build_configuration_list_select (dlg->config_list, name);
- args_str = g_string_new (NULL);
- arg = build_configuration_get_args (cfg);
- if (arg)
+ if (cfg != NULL)
{
- for (; *arg != NULL; arg++)
+ args_str = g_string_new (NULL);
+ arg = build_configuration_get_args (cfg);
+ if (arg)
{
- gchar *quoted_arg = g_shell_quote (*arg);
+ for (; *arg != NULL; arg++)
+ {
+ gchar *quoted_arg = g_shell_quote (*arg);
- g_string_append (args_str, quoted_arg);
- g_free (quoted_arg);
- g_string_append_c (args_str, ' ');
+ g_string_append (args_str, quoted_arg);
+ g_free (quoted_arg);
+ g_string_append_c (args_str, ' ');
+ }
}
- }
- gtk_entry_set_text (GTK_ENTRY (dlg->args), args_str->str);
- g_string_free (args_str, TRUE);
+ gtk_entry_set_text (GTK_ENTRY (dlg->args), args_str->str);
+ g_string_free (args_str, TRUE);
- uri = build_configuration_list_get_build_uri (dlg->config_list, cfg);
- build_gtk_file_chooser_create_and_set_current_folder_uri (GTK_FILE_CHOOSER (dlg->build_dir_chooser), uri);
- g_free (uri);
+ uri = build_configuration_list_get_build_uri (dlg->config_list, cfg);
+ build_gtk_file_chooser_create_and_set_current_folder_uri (GTK_FILE_CHOOSER (dlg->build_dir_chooser), uri);
+ g_free (uri);
+ }
}
g_free (name);
}
@@ -359,7 +362,7 @@
{
name = gtk_combo_box_get_active_text (GTK_COMBO_BOX (dlg.combo));
}
- cfg = build_configuration_list_select (config_list, name);
+ cfg = build_configuration_list_create (config_list, name);
g_free (name);
args = gtk_entry_get_text (GTK_ENTRY (dlg.args));
Modified: trunk/plugins/build-basic-autotools/configuration-list.c
==============================================================================
--- trunk/plugins/build-basic-autotools/configuration-list.c (original)
+++ trunk/plugins/build-basic-autotools/configuration-list.c Sun Jul 20 18:54:33 2008
@@ -127,236 +127,6 @@
return unesc;
}
-#if 0
-
-/* Helper functions
- *---------------------------------------------------------------------------*/
-
-static void
-on_select_configuration (GtkComboBox *widget, gpointer user_data)
-{
- BuildConfigureDialog *dlg = (BuildConfigureDialog *)user_data;
- gchar *name;
-
- name = gtk_combo_box_get_active_text (GTK_COMBO_BOX (dlg->combo));
-
- if (*name == '\0')
- {
- /* Configuration name is mandatory disable Ok button */
- gtk_widget_set_sensitive (dlg->ok, FALSE);
- }
- else
- {
- GList *node;
-
- gtk_widget_set_sensitive (dlg->ok, TRUE);
-
- for (node = dlg->config_list; node != NULL; node = g_list_next (node))
- {
- BuildConfiguration *cfg = (BuildConfiguration *)node->data;
-
- if (strcmp (name, cfg->name) == 0)
- {
- /* Find existing configuration */
- if (cfg->args == NULL)
- {
- gtk_entry_set_text (GTK_ENTRY (dlg->args), "");
- }
- else
- {
- GString* args_str;
- gchar **arg;
-
- args_str = g_string_new (NULL);
- for (arg = cfg->args; *arg != NULL; arg++)
- {
- gchar *quoted_arg = g_shell_quote (*arg);
-
- g_string_append (args_str, quoted_arg);
- g_free (quoted_arg);
- g_string_append_c (args_str, ' ');
- }
- gtk_entry_set_text (GTK_ENTRY (dlg->args), args_str->str);
- g_string_free (args_str, TRUE);
- }
-
- if (cfg->build_uri == NULL)
- {
- /* No build directory defined, use source directory */
- gtk_file_chooser_set_uri (GTK_FILE_CHOOSER (dlg->build_dir_chooser), dlg->project_uri);
- }
- else
- {
- gchar *scheme;
-
- scheme = g_uri_parse_scheme (cfg->build_uri);
- if (scheme)
- {
- /* Absolute directory */
- g_free (scheme);
- build_gtk_file_chooser_create_and_set_current_folder_uri (GTK_FILE_CHOOSER (dlg->build_dir_chooser), cfg->build_uri);
- }
- else
- {
- GFile *dir;
- GFile *build_dir;
- gchar *build_uri;
-
- /* Relative directory */
- dir = g_file_new_for_uri (dlg->project_uri);
- build_dir = g_file_resolve_relative_path (dir,cfg->build_uri);
- g_object_unref (dir);
- build_uri = g_file_get_uri (build_dir);
- g_object_unref (build_dir);
- build_gtk_file_chooser_create_and_set_current_folder_uri (GTK_FILE_CHOOSER (dlg->build_dir_chooser), build_uri);
- g_free (build_uri);
- }
-
- }
- }
- }
- }
- g_free (name);
-}
-
-static void
-fill_dialog (BuildConfigureDialog *dlg)
-{
- GtkListStore* store = gtk_list_store_new(1, G_TYPE_STRING);
- GList *node;
- const DefaultBuildConfiguration *cfg;
-
- /* Add default entry if missing */
- for (cfg = default_config; cfg->name != NULL; cfg++)
- {
- for (node = g_list_first (dlg->config_list); node != NULL; node = g_list_next (node))
- {
- if (strcmp (((BuildConfiguration *)node->data)->name, cfg->name) == 0) break;
- }
- if (node == NULL)
- {
- /* Add configuration */
- BuildConfiguration *new_cfg;
-
- new_cfg = g_new (BuildConfiguration, 1);
- new_cfg->name = g_strdup (cfg->name);
- new_cfg->build_uri = g_strdup (cfg->build_uri);
- new_cfg->args = NULL;
- if (cfg->args)
- {
- g_shell_parse_argv (cfg->args, NULL, &new_cfg->args, NULL);
- }
-
- dlg->config_list = g_list_append (dlg->config_list, new_cfg);
- }
- }
-
- gtk_combo_box_set_model (GTK_COMBO_BOX(dlg->combo), GTK_TREE_MODEL(store));
- gtk_combo_box_entry_set_text_column (GTK_COMBO_BOX_ENTRY (dlg->combo), 0);
-
- for (node = g_list_first (dlg->config_list); node != NULL; node = g_list_next (node))
- {
- GtkTreeIter iter;
-
- gtk_list_store_append (store, &iter);
- gtk_list_store_set (store, &iter, 0, ((BuildConfiguration *)node->data)->name, -1);
- }
-}
-
-static void
-save_configuration (BuildConfigureDialog *dlg)
-{
- gchar *configuration;
- GList *node;
- BuildConfiguration *cfg;
- gchar *uri;
-
- configuration = gtk_combo_box_get_active_text (GTK_COMBO_BOX (dlg->combo));
-
- for (node = dlg->config_list; node != NULL; node = g_list_next (node))
- {
- cfg = (BuildConfiguration *)node->data;
-
- if (strcmp (configuration, cfg->name) == 0)
- {
- /* Move this configuration at the beginning */
- dlg->config_list = g_list_remove_link (dlg->config_list, node);
- dlg->config_list = g_list_concat (node, dlg->config_list);
- g_free (configuration);
- break;
- }
- }
- if (node == NULL)
- {
- /* Create a new configuration */
- dlg->config_list = g_list_prepend (dlg->config_list, g_new0 (BuildConfiguration, 1));
- node = dlg->config_list;
- cfg = (BuildConfiguration *)node->data;
- cfg->name = configuration;
- }
-
- g_strfreev (cfg->args);
- cfg->args = NULL;
- g_free (cfg->build_uri);
-
- g_shell_parse_argv (gtk_entry_get_text (GTK_ENTRY (dlg->args)), NULL, &cfg->args, NULL);
- uri = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (dlg->build_dir_chooser));
- cfg->build_uri = uri;
-}
-
-BuildConfiguration*
-build_dialog_configure (GtkWindow* parent, const gchar *project_root_uri, GList **config_list, gboolean *run_autogen)
-{
- GladeXML* gxml;
- BuildConfigureDialog dlg;
- BuildConfiguration *cfg;
-
- gint response;
-
- /* Get all dialog widgets */
- gxml = glade_xml_new (GLADE_FILE, CONFIGURE_DIALOG, NULL);
- dlg.win = glade_xml_get_widget (gxml, CONFIGURE_DIALOG);
- dlg.combo = glade_xml_get_widget(gxml, CONFIGURATION_COMBO);
- dlg.autogen = glade_xml_get_widget(gxml, RUN_AUTOGEN_CHECK);
- dlg.build_dir_chooser = glade_xml_get_widget(gxml, BUILD_DIR_CHOOSER);
- dlg.args = glade_xml_get_widget(gxml, CONFIGURE_ARGS_ENTRY);
- dlg.ok = glade_xml_get_widget(gxml, OK_BUTTON);
- g_object_unref (gxml);
-
- dlg.config_list = *config_list;
- dlg.project_uri = project_root_uri;
-
- /* Set run autogen option */
- if (*run_autogen) gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dlg.autogen), TRUE);
-
- g_signal_connect (dlg.combo, "changed", G_CALLBACK (on_select_configuration), &dlg);
-
- fill_dialog(&dlg);
- gtk_combo_box_set_active (GTK_COMBO_BOX (dlg.combo), 0);
-
- response = gtk_dialog_run (GTK_DIALOG (dlg.win));
-
- if (response == GTK_RESPONSE_OK)
- {
- save_configuration (&dlg);
- *config_list = dlg.config_list;
- *run_autogen = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dlg.autogen));
-
- cfg = build_configuration_copy ((BuildConfiguration *)dlg.config_list->data);
- build_gtk_file_chooser_keep_folder (GTK_FILE_CHOOSER (dlg.build_dir_chooser), cfg->build_uri);
- }
- else
- {
- cfg = NULL;
- }
- gtk_widget_destroy (GTK_WIDGET(dlg.win));
-
- return cfg;
-}
-
-#endif
-
-
/* Private functions
*---------------------------------------------------------------------------*/
@@ -451,6 +221,29 @@
return list->selected;
}
+BuildConfiguration *
+build_configuration_list_create (BuildConfigurationList *list, const gchar *name)
+{
+ BuildConfiguration *cfg = NULL;
+ BuildConfiguration *prev;
+
+ if (name == NULL) return NULL;
+
+ cfg = build_configuration_list_get (list, name);
+ if (cfg == NULL)
+ {
+ /* Add configuration */
+ cfg = g_new0 (BuildConfiguration, 1);
+ cfg->name = g_strdup (name);
+ for (prev = build_configuration_list_get_first (list); prev->next != NULL; prev = prev->next) ;
+ cfg->prev = prev;
+ prev->next = cfg;
+ }
+ list->selected = cfg;
+
+ return list->selected;
+}
+
void
build_configuration_list_from_string_list (BuildConfigurationList *list, GList *str_list)
{
Modified: trunk/plugins/build-basic-autotools/configuration-list.h
==============================================================================
--- trunk/plugins/build-basic-autotools/configuration-list.h (original)
+++ trunk/plugins/build-basic-autotools/configuration-list.h Sun Jul 20 18:54:33 2008
@@ -38,6 +38,7 @@
BuildConfiguration *build_configuration_next (BuildConfiguration *cfg);
BuildConfiguration *build_configuration_list_get (BuildConfigurationList *list, const gchar *name);
BuildConfiguration *build_configuration_list_select (BuildConfigurationList *list, const gchar *name);
+BuildConfiguration *build_configuration_list_create (BuildConfigurationList *list, const gchar *name);
void build_configuration_list_set_project_uri (BuildConfigurationList *list, const gchar *uri);
const gchar *build_configuration_get_translated_name (BuildConfiguration *cfg);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]