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

Hidden setting to override the text editor. #246

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

mgedmin
Copy link
Member

@mgedmin mgedmin commented Nov 29, 2023

Note that people who run gtimelog straight from Git will need to manually run make to recompile the gsettings schema, or gtimelog will segfault when you press Ctrl+E. Maybe I can add a check to see if the key exists before attempting to load it?

Also note that using gsettings is a pain when the schema is not installed globally, but you can use

dconf write /org/gtimelog/editor '"gvim %s"'

and then tweak it with dconf-editor.

Error handling is missing: if you set editor to gvim and gvim is not installed, you'll see a Python traceback on the console.

Application.prepare_args() is a separate static method so I could write unit tests for it, but I haven't done so. Instead I have experimented with values like gnome-terminal -e "vim %s" to test the , and it seems to work fine (gnome-terminal opens a new tab in my existing instance with Vim running inside, which is a bit startling).

Closes #113.

Copy link
Contributor

@icemac icemac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was using dconf write /org/gtimelog/editor '"open -a TextEdit.app %s"' on MacOS (after installing dconf via MacPorts) and it worked nicely even without recompiling anything and when running gtimelog as a real MacOS app as described in minddistrict/gtimelog-macosx#1.

Thank you very much.

On the other hand calling gsettings get org.gtimelog editor afterwards told me that the schema org.gtimelog is not there, so maybe mentioning the dconf way in the readme would be helpful for future MacOS users.

@mgedmin
Copy link
Member Author

mgedmin commented Nov 30, 2023

Not just Mac, when the schema is not installed into a system-wide location, you cannot use gsettings on it without first exporting GSETTINGS_SCHEMA_DIR=src/gtimelog/data/.

dconf-editor is the more user-friendly alternative. Does it run on Mac OS?

@mgedmin
Copy link
Member Author

mgedmin commented Dec 1, 2023

Note that people who run gtimelog straight from Git will need to manually run make to recompile the gsettings schema, or gtimelog will segfault when you press Ctrl+E. Maybe I can add a check to see if the key exists before attempting to load it?

Should I add the check? Then people will complain that they set the setting (with dconf) but it doesn't work at all. That's actually an argument towards not documenting the dconf write thing; if you set the setting using gsettings (after exporting GSETTINGS_SCHEMA_DIR, then you'll know that the updated schema was compiled correctly. But then I should document the exporting GSETTINGS_SCHEMA_DIR thing. Or add some UI for the setting in the preferences dialog.

Maybe gtimelog itself should add an mtime check and recompile the schema in src/gtimelog/data if the timestamp shows that it is outdated. Yay for reinventing GNU Make? Anyway I value developer convenience, being one myself.

The hardest problem in computer science is deciding what needs to be done. I am very good at enumerating possible approaches and then failing to pick one.

@icemac
Copy link
Contributor

icemac commented Dec 15, 2023

@mgedmin Sorry for letting you wait for so long for an answer.

The dconf write approach worked for me on Mac. dconf-editor exists, but it is not usable without installing an X.org server and a big pile of dependencies. (and even than it looks horrible and is nearly unusable)
I did not have a crash but on the other hand I also did not understand what to do with GSETTINGS_SCHEMA_DIR.

Probably the most convenient way for the users would be to have an option in the preferences dialog, even though it is the one which requires the most changes.

Note that people who run gtimelog straight from Git will need to
manually run ``make`` to recompile the gsettings schema, or gtimelog
will segfault when you press Ctrl+E.

Also note that using `gsettings` is a pain when the schema is not
installed globally, but you can use

    dconf write /org/gtimelog/editor '"gvim %s"'

and then tweak it with dconf-editor.

Error handling is missing: if you set editor to gvim and gvim is not
installed, you'll see a Python traceback on the console.

Application.prepare_args() is a separate static method so I could write
unit tests for it, but I haven't done so.

Closes #113.
@mgedmin
Copy link
Member Author

mgedmin commented Jan 30, 2024

Rebased to resolve merge conflicts.

I want to add some error handling before I merge this.

The error is only visible in report mode.
@mgedmin
Copy link
Member Author

mgedmin commented Apr 3, 2024

Current status: error reporting doesn't really work:

  • there's a message printed to the console/journal which nobody will see
  • if you go into report mode then you'll see an info bar with the error

I need to update the .ui file to add an info bar to the regular view, then make sure the error message shows in both info bars? Or somehow reparent the infobar widget when switching modes?

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

Successfully merging this pull request may close these issues.

Can no longer select editor in GTimeLog 0.11
2 participants