[anjuta] run-program: Save relative program URI in session file
- From: Sebastien Granjoux <sgranjoux src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [anjuta] run-program: Save relative program URI in session file
- Date: Wed, 8 Feb 2012 20:30:49 +0000 (UTC)
commit 07133d704a473c7220c97871fb576e9ac3a9ec2b
Author: SÃbastien Granjoux <seb sfo free fr>
Date: Wed Feb 8 21:14:46 2012 +0100
run-program: Save relative program URI in session file
plugins/run-program/parameters.c | 36 +++++++++++++-----------------------
plugins/run-program/plugin.c | 18 +++++++++---------
2 files changed, 22 insertions(+), 32 deletions(-)
---
diff --git a/plugins/run-program/parameters.c b/plugins/run-program/parameters.c
index 24e92c9..9d6b845 100644
--- a/plugins/run-program/parameters.c
+++ b/plugins/run-program/parameters.c
@@ -95,13 +95,13 @@ on_add_string_in_model (gpointer data, gpointer user_data)
}
static void
-on_add_uri_in_model (gpointer data, gpointer user_data)
+on_add_file_in_model (gpointer data, gpointer user_data)
{
GtkListStore* model = (GtkListStore *)user_data;
GtkTreeIter iter;
gchar *local;
- local = anjuta_util_get_local_path_from_uri ((const char *)data);
+ local = g_file_get_path ((GFile *)data);
gtk_list_store_append (model, &iter);
gtk_list_store_set (model, &iter, ENV_NAME_COLUMN, local, -1);
g_free (local);
@@ -263,23 +263,14 @@ save_dialog_data (RunDialog* dlg)
filename = gtk_entry_get_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (dlg->target))));
if ((filename != NULL) && (*filename != '\0'))
{
- GFile *file;
- gchar *uri;
-
file = g_file_new_for_path (filename);
- uri = g_file_get_uri (file);
- g_object_unref (file);
-
- if (uri != NULL)
+ find = g_list_find_custom (plugin->recent_target, file, (GCompareFunc)compare_file);
+ if (find)
{
- find = g_list_find_custom (plugin->recent_target, uri, (GCompareFunc)strcmp);
- if (find)
- {
- g_free (find->data);
- plugin->recent_target = g_list_delete_link (plugin->recent_target, find);
- }
- plugin->recent_target = g_list_prepend (plugin->recent_target, uri);
+ g_object_unref (G_OBJECT (find->data));
+ plugin->recent_target = g_list_delete_link (plugin->recent_target, find);
}
+ plugin->recent_target = g_list_prepend (plugin->recent_target, file);
}
/* Save working dir */
@@ -673,7 +664,7 @@ run_dialog_init (RunDialog *dlg, RunProgramPlugin *plugin)
model = GTK_TREE_MODEL (gtk_list_store_new (1, G_TYPE_STRING));
gtk_combo_box_set_model (dlg->target, model);
gtk_combo_box_set_entry_text_column( GTK_COMBO_BOX (dlg->target), 0);
- g_list_foreach (plugin->recent_target, on_add_uri_in_model, model);
+ g_list_foreach (plugin->recent_target, on_add_file_in_model, model);
anjuta_shell_get_value (ANJUTA_PLUGIN (plugin)->shell, IANJUTA_PROJECT_MANAGER_PROJECT_ROOT_URI, &value, NULL);
project_root_uri = G_VALUE_HOLDS_STRING (&value) ? g_value_get_string (&value) : NULL;
@@ -698,17 +689,16 @@ run_dialog_init (RunDialog *dlg, RunProgramPlugin *plugin)
for (node = exec_targets; node; node = g_list_next (node))
{
GList *target;
- gchar *uri = g_file_get_uri ((GFile *)node->data);
+ GFile *file = (GFile *)node->data;
for (target = plugin->recent_target; target; target = g_list_next (target))
{
- if (strcmp ((const gchar *)target->data, uri) == 0) break;
+ if (g_file_equal ((GFile *)target->data, file)) break;
}
if (target == NULL)
{
- on_add_uri_in_model (uri, model);
+ on_add_file_in_model (file, model);
}
- g_free (uri);
- g_object_unref (node->data);
+ g_object_unref (G_OBJECT (file));
}
g_list_free (exec_targets);
}
@@ -724,7 +714,7 @@ run_dialog_init (RunDialog *dlg, RunProgramPlugin *plugin)
{
gchar *local;
- local = anjuta_util_get_local_path_from_uri ((const char *)plugin->recent_target->data);
+ local = g_file_get_path ((GFile *)plugin->recent_target->data);
gtk_entry_set_text (GTK_ENTRY (child), local);
g_free (local);
}
diff --git a/plugins/run-program/plugin.c b/plugins/run-program/plugin.c
index 5272a99..7800ec4 100644
--- a/plugins/run-program/plugin.c
+++ b/plugins/run-program/plugin.c
@@ -162,7 +162,7 @@ on_session_save (AnjutaShell *shell, AnjutaSessionPhase phase, AnjutaSession *se
return;
anjuta_session_set_limited_string_list (session, "Execution", "Program arguments", &self->recent_args);
- anjuta_session_set_limited_string_list (session, "Execution", "Program uri", &self->recent_target);
+ anjuta_session_set_limited_relative_file_list (session, "Execution", "Program uri", &self->recent_target);
anjuta_session_set_int (session, "Execution", "Run in terminal", self->run_in_terminal + 1);
anjuta_session_set_limited_relative_file_list (session,"Execution", "Working directories", &self->recent_dirs);
anjuta_session_set_strv (session, "Execution", "Environment variables", self->environment_vars);
@@ -182,12 +182,9 @@ static void on_session_load (AnjutaShell *shell, AnjutaSessionPhase phase, Anjut
}
self->recent_args = anjuta_session_get_string_list (session, "Execution", "Program arguments");
- if (self->recent_target != NULL)
- {
- g_list_foreach (self->recent_target, (GFunc)g_free, NULL);
- g_list_free (self->recent_target);
- }
- self->recent_target = anjuta_session_get_string_list (session, "Execution", "Program uri");
+ g_list_foreach (self->recent_target, (GFunc)g_object_unref, NULL);
+ g_list_free (self->recent_target);
+ self->recent_target = anjuta_session_get_relative_file_list (session, "Execution", "Program uri");
/* The flag is store as 1 == FALSE, 2 == TRUE */
run_in_terminal = anjuta_session_get_int (session, "Execution", "Run in terminal");
@@ -388,7 +385,7 @@ run_plugin_finalize (GObject *obj)
{
RunProgramPlugin *self = ANJUTA_PLUGIN_RUN_PROGRAM (obj);
- g_list_foreach (self->recent_target, (GFunc)g_free, NULL);
+ g_list_foreach (self->recent_target, (GFunc)g_object_unref, NULL);
g_list_free (self->recent_target);
g_list_foreach (self->recent_args, (GFunc)g_free, NULL);
g_list_free (self->recent_args);
@@ -431,17 +428,20 @@ void
run_plugin_update_shell_value (RunProgramPlugin *plugin)
{
gchar *dir_uri;
+ gchar *target_uri;
/* Update Anjuta shell value */
+ target_uri = plugin->recent_target == NULL ? NULL : g_file_get_uri ((GFile *)plugin->recent_target->data);
dir_uri = plugin->recent_dirs == NULL ? NULL : g_file_get_uri ((GFile *)plugin->recent_dirs->data);
anjuta_shell_add (ANJUTA_PLUGIN (plugin)->shell,
- RUN_PROGRAM_URI, G_TYPE_STRING, plugin->recent_target == NULL ? NULL : plugin->recent_target->data,
+ RUN_PROGRAM_URI, G_TYPE_STRING, target_uri,
RUN_PROGRAM_ARGS, G_TYPE_STRING, plugin->recent_args == NULL ? NULL : plugin->recent_args->data,
RUN_PROGRAM_DIR, G_TYPE_STRING, dir_uri,
RUN_PROGRAM_ENV, G_TYPE_STRV, plugin->environment_vars == NULL ? NULL : plugin->environment_vars,
RUN_PROGRAM_NEED_TERM, G_TYPE_BOOLEAN, plugin->run_in_terminal,
NULL);
g_free (dir_uri);
+ g_free (target_uri);
}
void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]