Branch: refs/heads/master Author: Jiří Techet techet@gmail.com Committer: Jiří Techet techet@gmail.com Date: Sun, 29 Mar 2015 19:38:50 UTC Commit: b0b5c94615796c193b9531bfd69957663bb664f0 https://github.com/geany/geany-plugins/commit/b0b5c94615796c193b9531bfd69957...
Log Message: ----------- projectorganizer: Fix for cases when base_path is relative
This is necessary at least for now until (if ever) the simplified project definition patch gets into Geany.
Modified Paths: -------------- projectorganizer/src/prjorg-menu.c projectorganizer/src/prjorg-project.c projectorganizer/src/prjorg-sidebar.c projectorganizer/src/prjorg-utils.c projectorganizer/src/prjorg-utils.h
Modified: projectorganizer/src/prjorg-menu.c 2 lines changed, 1 insertions(+), 1 deletions(-) =================================================================== @@ -185,7 +185,7 @@ static void on_swap_header_source(G_GNUC_UNUSED GtkMenuItem * menuitem, G_GNUC_U static void on_find_in_project(G_GNUC_UNUSED GtkMenuItem * menuitem, G_GNUC_UNUSED gpointer user_data) { if (geany_data->app->project) - search_show_find_in_files_dialog(geany_data->app->project->base_path); + search_show_find_in_files_dialog(get_project_base_path()); }
Modified: projectorganizer/src/prjorg-project.c 2 lines changed, 1 insertions(+), 1 deletions(-) =================================================================== @@ -473,7 +473,7 @@ void prjorg_project_open(GKeyFile * key_file) } g_slist_free(ext_list); /* the project directory is always first */ - prj_org->roots = g_slist_prepend(prj_org->roots, create_root(geany_data->app->project->base_path)); + prj_org->roots = g_slist_prepend(prj_org->roots, create_root(get_project_base_path()));
update_project( source_patterns,
Modified: projectorganizer/src/prjorg-sidebar.c 16 lines changed, 8 insertions(+), 8 deletions(-) =================================================================== @@ -219,7 +219,7 @@ static gchar *build_path(GtkTreeIter *iter) gchar *name;
if (!iter) - return g_strdup(geany_data->app->project->base_path); + return g_strdup(get_project_base_path());
node = *iter; model = GTK_TREE_MODEL(s_file_store); @@ -237,7 +237,7 @@ static gchar *build_path(GtkTreeIter *iter) }
if (topmost_selected(model, &node, TRUE)) - SETPTR(path, g_build_filename(geany_data->app->project->base_path, path, NULL)); + SETPTR(path, g_build_filename(get_project_base_path(), path, NULL)); else { gtk_tree_model_get(model, &node, FILEVIEW_COLUMN_NAME, &name, -1); @@ -291,7 +291,7 @@ static void on_add_external(G_GNUC_UNUSED GtkMenuItem * menuitem, G_GNUC_UNUSED GTK_WINDOW(geany->main_widgets->window), GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, _("_Cancel"), GTK_RESPONSE_CANCEL, _("Add"), GTK_RESPONSE_ACCEPT, NULL); - gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), geany_data->app->project->base_path); + gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), get_project_base_path());
if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) { @@ -358,7 +358,7 @@ static void find_file_recursive(GtkTreeIter *iter, gboolean case_sensitive, gboo gchar *path;
path = build_path(iter); - name = get_relative_path(geany_data->app->project->base_path, path); + name = get_relative_path(get_project_base_path(), path); g_free(path); } else @@ -372,7 +372,7 @@ static void find_file_recursive(GtkTreeIter *iter, gboolean case_sensitive, gboo gchar *path, *rel_path;
path = build_path(iter); - rel_path = get_relative_path(geany_data->app->project->base_path, path); + rel_path = get_relative_path(get_project_base_path(), path); msgwin_msg_add(COLOR_BLACK, -1, NULL, "%s", rel_path ? rel_path : path); g_free(path); g_free(rel_path); @@ -401,7 +401,7 @@ static void find_file(GtkTreeIter *iter) pattern = g_pattern_spec_new(pattern_str);
msgwin_clear_tab(MSG_MESSAGE); - msgwin_set_messages_dir(geany_data->app->project->base_path); + msgwin_set_messages_dir(get_project_base_path()); find_file_recursive(iter, case_sensitive, full_path, pattern); msgwin_switch_tab(MSG_MESSAGE, TRUE); } @@ -581,7 +581,7 @@ static void find_tags(const gchar *name, gboolean declaration, gboolean case_sen pspec = g_pattern_spec_new(name_case);
- msgwin_set_messages_dir(geany_data->app->project->base_path); + msgwin_set_messages_dir(get_project_base_path()); msgwin_clear_tab(MSG_MESSAGE); for (i = 0; i < tags_array->len; i++) /* TODO: binary search */ { @@ -592,7 +592,7 @@ static void find_tags(const gchar *name, gboolean declaration, gboolean case_sen gchar *scopestr = tag->scope ? g_strconcat(tag->scope, "::", NULL) : g_strdup(""); gchar *relpath; - relpath = get_relative_path(geany_data->app->project->base_path, tag->file->file_name); + relpath = get_relative_path(get_project_base_path(), tag->file->file_name); msgwin_msg_add(COLOR_BLACK, -1, NULL, "%s:%lu:\n\t[%s]\t %s%s%s", relpath, tag->line, tm_tag_type_name(tag), scopestr, tag->name, tag->arglist ? tag->arglist : ""); g_free(scopestr);
Modified: projectorganizer/src/prjorg-utils.c 25 lines changed, 25 insertions(+), 0 deletions(-) =================================================================== @@ -116,3 +116,28 @@ gchar *get_selection(void) else return editor_get_word_at_pos(doc->editor, -1, wc); } + + +gchar *get_project_base_path(void) +{ + GeanyProject *project = geany_data->app->project; + + if (project && !EMPTY(project->base_path)) + { + if (g_path_is_absolute(project->base_path)) + return g_strdup(project->base_path); + else + { /* build base_path out of project file name's dir and base_path */ + gchar *path; + gchar *dir = g_path_get_dirname(project->file_name); + + if (utils_str_equal(project->base_path, "./")) + return dir; + + path = g_build_filename(dir, project->base_path, NULL); + g_free(dir); + return path; + } + } + return NULL; +}
Modified: projectorganizer/src/prjorg-utils.h 1 lines changed, 1 insertions(+), 0 deletions(-) =================================================================== @@ -26,5 +26,6 @@ GSList *get_precompiled_patterns(gchar **patterns);
void open_file(gchar *utf8_name); gchar *get_selection(void); +gchar *get_project_base_path(void);
#endif
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).