Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gummi does not allow opening project files from the commandline #166

Open
neoh4x0r opened this issue Jan 25, 2022 · 0 comments
Open

Gummi does not allow opening project files from the commandline #166

neoh4x0r opened this issue Jan 25, 2022 · 0 comments

Comments

@neoh4x0r
Copy link

neoh4x0r commented Jan 25, 2022

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:

  1. 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);
+	    }
         }
     }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant