This pull request allow the usage of relative filepath in the Project file (.geany) and add a checkbox in the project config to active this option.
The aim is to be able to duplicate a project with a copy-paste or to save a project file (.geany) in git, svn or whatever.
issue #2483 You can view, comment on, or merge this pull request online at:
https://github.com/geany/geany/pull/2667
-- Commit Summary --
* On ouvre un chemin relatif, mais un soucis : * nettoyage * Ajout de la case à cocher * Ajout de la case "relative file" dans les propriété du projet * Enregistrement des fichiers en relatif ou absolu selon configuration de la session * remove spaces * Ability to load relative paths and absolute path from project file * Add checkbox in project properties to allow usage of relative paths in project file * Save relative or absolute file paths in project file depending on the project config
-- File Changes --
M data/geany.glade (36) M src/keyfile.c (58) M src/keyfile.h (4) M src/libmain.c (4) M src/project.c (29) M src/project.h (1)
-- Patch Links --
https://github.com/geany/geany/pull/2667.patch https://github.com/geany/geany/pull/2667.diff
@Keuronde pushed 1 commit.
c32ea62cc1cf89399eae65e7c8bb73bcdd831c11 bug corrected : segfault if started without project
Closed #2667.
Some bug were detected...
Reopened #2667.
Travis failed because I close the pull request during the check, and now that it is re-opened, I can launch it again. Can an admin help on this one ?
Can an admin help on this one ?
Here you go.
Ok, my bad, I didn't read the doc in detail, I use g_canonicalize_filename, which is for glib 2.58 or above. I will try again !
@Keuronde pushed 1 commit.
69d6357d8c50ac586efaf467d994ddd86b34c9a7 Remove g_canonical_path
@elextr requested changes on this pull request.
Not reviewed in detail yet.
This capability needs to be documented in the manual, including downsides and risks such as accidentally storing all files you have open in git and broadcasting that to the world. New settings not documented either.
if (ft == NULL) /* can happen when saving a new file when quitting */ ft = filetypes[GEANY_FILETYPES_NONE];
- locale_filename = utils_get_locale_from_utf8(doc->file_name); + /* project_root_folder contain a path only if the project use relative path */ + if(project_root_folder){ + file_root_folder = g_file_new_for_path(project_root_folder); + file_doc = g_file_new_for_path(doc->file_name); + relative_filename = g_file_get_relative_path(file_root_folder, file_doc); + if(relative_filename){ + /* Append './' so we know it is a relative filename */ + doc_filename = g_strconcat("./",relative_filename, NULL);
As `relative_filename` is in locale encoding technically you don't know if `./` is properly encoded to prepend (not append)
if (ft == NULL) /* can happen when saving a new file when quitting */ ft = filetypes[GEANY_FILETYPES_NONE];
- locale_filename = utils_get_locale_from_utf8(doc->file_name); + /* project_root_folder contain a path only if the project use relative path */ + if(project_root_folder){ + file_root_folder = g_file_new_for_path(project_root_folder); + file_doc = g_file_new_for_path(doc->file_name); + relative_filename = g_file_get_relative_path(file_root_folder, file_doc); + if(relative_filename){ + /* Append './' so we know it is a relative filename */ + doc_filename = g_strconcat("./",relative_filename, NULL); + }else{ + doc_filename = g_strconcat(doc->file_name, NULL);
Why are you concating nothing?
@@ -611,6 +618,10 @@ static void show_project_properties(gboolean show_build)
gtk_entry_set_text(GTK_ENTRY(e.patterns), entry_text); g_free(entry_text);
+ gtk_toggle_button_set_active( + GTK_TOGGLE_BUTTON(ui_lookup_widget(e.dialog, "checkbutton_project_dialog_file_relative")),
Didn't you lookup this widget above? Can't you use that pointer.
@@ -1218,6 +1242,21 @@ static gboolean open_session_file(gchar **tmp, guint len)
unescaped_filename = g_uri_unescape_string(tmp[7], NULL); locale_filename = utils_get_locale_from_utf8(unescaped_filename);
+ /* is the locale_filename absolute or relative ? */ + if(g_path_is_absolute(locale_filename) && root_folder) + { + geany_debug("Absolute path"); + } + else + { + geany_debug("Relative path %s, root folder %s", locale_filename, root_folder); + gchar *absolute_path; + absolute_path = g_strconcat(root_folder, &(locale_filename[1]), NULL);
What if the path is relative, but `root_folder` is null?
@Keuronde commented on this pull request.
if (ft == NULL) /* can happen when saving a new file when quitting */ ft = filetypes[GEANY_FILETYPES_NONE];
- locale_filename = utils_get_locale_from_utf8(doc->file_name); + /* project_root_folder contain a path only if the project use relative path */ + if(project_root_folder){ + file_root_folder = g_file_new_for_path(project_root_folder); + file_doc = g_file_new_for_path(doc->file_name); + relative_filename = g_file_get_relative_path(file_root_folder, file_doc); + if(relative_filename){ + /* Append './' so we know it is a relative filename */ + doc_filename = g_strconcat("./",relative_filename, NULL);
Make sense, I will change the behavior, I don't need to store "./" at the beginning of the path.
@Keuronde commented on this pull request.
if (ft == NULL) /* can happen when saving a new file when quitting */ ft = filetypes[GEANY_FILETYPES_NONE];
- locale_filename = utils_get_locale_from_utf8(doc->file_name); + /* project_root_folder contain a path only if the project use relative path */ + if(project_root_folder){ + file_root_folder = g_file_new_for_path(project_root_folder); + file_doc = g_file_new_for_path(doc->file_name); + relative_filename = g_file_get_relative_path(file_root_folder, file_doc); + if(relative_filename){ + /* Append './' so we know it is a relative filename */ + doc_filename = g_strconcat("./",relative_filename, NULL); + }else{ + doc_filename = g_strconcat(doc->file_name, NULL);
I didn't find/understand the g_strdup function, now I do.
@Keuronde commented on this pull request.
@@ -611,6 +618,10 @@ static void show_project_properties(gboolean show_build)
gtk_entry_set_text(GTK_ENTRY(e.patterns), entry_text); g_free(entry_text);
+ gtk_toggle_button_set_active( + GTK_TOGGLE_BUTTON(ui_lookup_widget(e.dialog, "checkbutton_project_dialog_file_relative")),
Right ! I will do that
@Keuronde commented on this pull request.
@@ -1218,6 +1242,21 @@ static gboolean open_session_file(gchar **tmp, guint len)
unescaped_filename = g_uri_unescape_string(tmp[7], NULL); locale_filename = utils_get_locale_from_utf8(unescaped_filename);
+ /* is the locale_filename absolute or relative ? */ + if(g_path_is_absolute(locale_filename) && root_folder) + { + geany_debug("Absolute path"); + } + else + { + geany_debug("Relative path %s, root folder %s", locale_filename, root_folder); + gchar *absolute_path; + absolute_path = g_strconcat(root_folder, &(locale_filename[1]), NULL);
Logic was crappy ! I correct that. If path is relative an root_folder is null, we have a problem, that shouldn't happen. The only way to produce it would be if you have relative path in your default session file... I think...
@Keuronde pushed 1 commit.
39e0b0753f1d5d2061b5d85fc54ac9062c20c320 Update after elextr pre-review
@Keuronde pushed 1 commit.
9ce85e9b9bc32203b53d39408e4260348eda83b5 Update documentation for this feature.
I have push a new commit taking into account your remarks (Was it the good way to proceed ?) I have update the documentation and add the tooltip.
@Keuronde commented on this pull request.
I didn't find a better way...
{
geany_debug("Relative path %s, root folder %s", locale_filename, root_folder); gchar *absolute_path; - absolute_path = g_strconcat(root_folder, &(locale_filename[1]), NULL); + absolute_path = g_strconcat(root_folder, "/", locale_filename, NULL);
Is there a better way to add a "path separator" than using "/" ? I didn't find any constant in the glib...
@elextr commented on this pull request.
{
geany_debug("Relative path %s, root folder %s", locale_filename, root_folder); gchar *absolute_path; - absolute_path = g_strconcat(root_folder, &(locale_filename[1]), NULL); + absolute_path = g_strconcat(root_folder, "/", locale_filename, NULL);
https://developer.gnome.org/glib/2.66/glib-Miscellaneous-Utility-Functions.h...
@Keuronde pushed 1 commit.
3d3c7fdff9e260c31c2fad506b27d4a0c91d5d61 Use G_DIR_SEPARATOR_S instead of "/"
Can I do something to help the integration of this pull request? I don't know if you are expecting something from me.
Regards
@Keuronde pushed 42 commits.
92382dcdbcccb7f531569dc291c33e275a2a9e44 Update to latest ctags main ae9a456a5d70ec6c457931ff7e2ba6ea515865ee Add patch to modify anonymous tag name 28fa776956d4547955b439466159496a22a2e21a Move EXTERNAL_PARSER_LIST to the beginning of BuiltInParsers 353ceff30518ea0291a1f8cae279d66dd0a1c469 Various parser updates to make them compatible with latest ctags main 04eec181710a1e8537b7f4f83e98658e3cf18907 Rename vStringItem to vStringChar 2927ec4dbb139528a07209d551897098425f3ebe attachParserField now takes an extra parameter 99a993fbfed30075610a30432ffe5ae1c3ae2fc3 useCork is now a bit field 3847b6c2a9e090a3362d35dac51c3859f628cacd Rename nestingLevelsGetNth() to nestingLevelsGetNthFromRoot() ccd5330a21318a0f39bcaf330dac1188e25ab6aa Update cobol and flex parsers to use latest ctags main definitions a2ecdab6d79b19806a5be3feae2058292620f0cc Update TM to use latest universal ctags fffb3c2bf2e78255a7b32540a6587f7c6ab6a6e3 Update tests 81c5a2e0ed653ccc36bd38483647a86d31556aa8 Update HACKING 0347e7411661401f7ef82c26c646c5123fba6653 Add the geany_ prefix to all parser files ab681681312acea05b2a484e99dd25647d21dddd Don't use tag identifier F 3f0bb8ed4c2073387eba6686774497f974da7424 Add a script performing update of Geany ctags from universal ctags 33fc269ea8d4d03453489ca55a9ca208ec15aae2 Add GNU regex bundle from upstream ctags and use it if missing b1c9096394c9819342747f1215274af469a19483 Add bundled fnmatch from upstream ctags c5303c9499bb6f0d632e0ca5b42e15f84d64ac52 Check for asprintf and tempnam and cleanup function checks d2740f21feb84b6f951398c6f683674b2b56bfed Remove unnecessary code when reading IPC socket port on Windows 9f5b430458192388a7bf611943fc61b2a8b44246 Update search phrase for search/replace dialogs (#2697) d9f8cdbad58d09f0c18ca8acccb49209263018f0 add comment_single configuration for kotlin (#2710) 7b7f0def021715a44ac1e8c3938becb28270b71f PO:(uk) Update translation b0160ec162e4d34a73307d02d41e073aa96e6987 Avoid redundant margin computation when creating a new Scintilla widget b08ae0fe65c0942dca20281d6841dc83406d8b5e Aggressively cache line height for computing margin sizes f600937dd8f592ff00150867537166b2d86aa4dd Use plain comparison instead of naive hashing 01604687a7f61aab7e841b2d2cfe9872d8856dfc Merge pull request #2666 from techee/ctags_sync5 e027e240c279040c2f6bc9ea0aaccc2cac2ca94e Merge pull request #2747 from geany/startup-speed 77630564ad5446df89e9973f74bd378a84fc817e Merge pull request #2724 from nomadbyte/po/uk 41624c411702d29834da0ff926f3c9f7c895bb47 Update of Turkish translation 2e2daf0e1817e553c393543c74ca1c807000168f On ouvre un chemin relatif, mais un soucis : 56e4588213e037225cac859648da6f7d9c9397c6 nettoyage 9a86033c86a4b5f7a1e5954ad2aaa2430844bf8e Ajout de la case à cocher c9c7e0ea581fba9a3ae4e03175d637314de0cfba Ajout de la case "relative file" dans les propriété du projet c52513b93d0a002c6dd3fb87a1d1f9254220871f Enregistrement des fichiers en relatif ou absolu selon configuration de la session 647b59c7e0a58d73266c33126402e94a26d5d100 remove spaces b3a92d3dfc80a9f8ad50cdf2b7bff79154387ff9 bug corrected : segfault if started without project dc7209da029c8b47a654ba0ada3300910eb04532 Bug correction 3f50c09dec3382359da689738c566e77ca7c9ae3 Remove g_canonical_path 3fe597c9429453712667e143057b9df1d8e911dd Update after elextr pre-review d24d0f21d6f642c87129a0c3e32ac4c31ea50b26 Update documentation for this feature. 025be1141ca85353d511a58589fbd4e5d60338cb Use G_DIR_SEPARATOR_S instead of "/" 6286d46db98886fa2460b953ee2a9df17a64b8d8 Merge branch 'openRelativePathInProject' of github.com:Keuronde/geany into openRelativePathInProject
I don't think its this PR, but it would be nice if the CI passed. But I don't have a clue what its problem is, maybe somebody who understands travis can look at it.
I had a look to the CI. Here is the meaning full error message.
E: Failed to fetch http://apt.postgresql.org/pub/repos/apt/dists/ **trusty-pgdg** /main/binary-i386/Packages
While building the environment, it try to install package from this repo.Trusty is a reference to an Ubuntu version of 2014, end of life 2019. Now postgresql is not delivering this package any more, we can see that here :
http://apt.postgresql.org/pub/repos/apt/dists/
@Keuronde ok, makes sense. According to https://wiki.ubuntu.com/Releases Xenial has also reached end of standard support (last month). I'll try changing `dist:` in `.travis.yml` to `bionic` and see what happens. Not that I understand why we use postgresql but thats another question.
Also I think you need to rebase, 210 changed files won't get reviewed but hopefully most are not actually changed by you.
Ok seems that the CI is up again with _Bionic_, could my PR have a try ?
github-comments@lists.geany.org