Some notes and open issues about the port to GApplication/GtkApplication

Code

  • wip/gtkapp branch in git

Open issues

  • [FIXED] gedit foo.txt in a second instance running in a different CWD does not open the file but creates a new "foo.txt" (as the docs say, the file is open relative to the main instance CWD). We need to have a g_file_new_for_commandline_arg_with_cwd utility. Could it go in gio? Another possibility would be to move file parsing on the client side and pass "encoding:line:col" in the hint string... is this API abuse? would this impact "--wait"?
  • [FIXED - needs to merged in glib if ok, also I am not sure why we do present()] gedit second instance does not present the window. Do we need to get the startup timestamp from the GApplicationCommandLine? g_application_command_line_get_platform_data mentions the startup id, but I could not find any specific... what about a g_applicatin_command_line_get_timestamp utility?
  • quit session does not warn about unsaved files: it looks like we need to use g_application_inhibit but this is not a great fit for our current code where we expect to query "can exit now?" not keeping track of the state all the time... can inhibit be called in response to the quit sigal or is it to late? Note that if we must keep state instead of a lazy "can quit?" signal, we will probably have a regression since now when closing we check if a document has been modified externally. Last but not least, which flags do we need? Just LOGOUT or also SWITCH_USER?
  • figure out how to implement "--wait". According to desrt it is just a matter of keeping a ref to the command line object
  • [FIXED] figure out how to check if there is an existing window in the current workspace or if we need to create a new one
  • gedit -b will not be supported (desrt says that if we want to do it we need to split in a launcher and a service)
  • stdin support: we need a glib patch (https://bugzilla.gnome.org/show_bug.cgi?id=668210) and we need to change to use "-" explicitly instead of checking the TTY.

  • in the port I dropped the OSX code that kept the app alive with all the windows closed. We need to reimplement this on top of gapplication. desrt says he will be happy to take patches in glib/gtk if needed.

Testing

Things to check:

  • check both primary instance and secondary instance
  • check launching secondary instance more than once (to make sure they are independent)
  • check exit code is 1 for error cases and messages are printed on stderr

Test cases:

  • gedit -V: ok
  • gedit -h: ok
  • gedit -notexisting: ok
  • gedit --standalone: not tested
  • gedit --new-window/--new-document: not tested
  • gedit filename +line:col: not tested
  • opening gedit on a different workspace: not tested
  • opening gedit on a different viewport: not tested
  • gedit with stdin content: not tested
  • "wait" support: not tested
  • open remote files/uri: not tested
  • session shutdown with unsaved files: not tested

Apps/Gedit/Attic/GtkApp (last edited 2020-04-14 13:38:10 by SébastienWilmet)