Gummi does not allow opening project files from the commandline
neoh4x0r opened this issue · comments
William L. DeRieux IV commented
Describe the bug
Opening a gummi project file from the commadline opens a tab with the contents of the file rather than opening a project.
To Reproduce
Steps to reproduce the behavior:
- Execute: gummi /path/to/project
System:
- OS: Debian 10/Buster
- Gummi v 0.8.2
Other related issues: #35
here is a proposed patch to fix this problem
The proposed solution is to check if the filename ends with .gummi and open it via the project manager or otherwise open the file using the tabmanager.
The issue related to associating .gummi project files (#35) isn't addressed by this, but this proposed patch would open the door for making it worthwhile.
diff --git a/src/main.c b/src/main.c
index ca7407b..786e13e 100644
--- a/src/main.c
+++ b/src/main.c
@@ -156,7 +156,22 @@ int main (int argc, char *argv[]) {
"No such file or directory\n", argv[i]);
exit(1);
}
- tabmanager_create_tab (A_LOAD, argv[i], NULL);
+ int filename_len = strlen(argv[i]);
+ if (filename_len >= 6 && strcmp(argv[i] + filename_len - 6, ".gummi") == 0) {
+ // mirrored from gui-menu.c::on_menu_projopen_activate
+ if (project_open_existing (argv[i])) {
+ statusbar_set_message (g_strdup_printf("Loading project %s", argv[i]));
+ projectgui_enable (gummi->project, gui->projectgui);
+ projectgui_list_projfiles (gummi->project->projfile);
+ tabmanager_set_active_tab (0);
+ }
+ else {
+ statusbar_set_message (g_strdup_printf("An error occurred while "
+ "loading project %s", argv[i]));
+ }
+ } else {
+ tabmanager_create_tab (A_LOAD, argv[i], NULL);
+ }
}
}