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

Improve Synchronization UI #897

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

runkaiz
Copy link

@runkaiz runkaiz commented May 15, 2022

Partially implements #837.

This is my first pull-request (well, first time attempting to contribute to a public open source project in fact). Code changes are minimum so please give me some advice if I am doing something wrong here, any help would be appreciated, just trying to gain some experience.

@Neui
Copy link
Contributor

Neui commented May 16, 2022

Not entirely sure if you want some feedback now, but:

  • You hide the button, but never make it .show() it again (at least from what I can see from the changes, I haven't tested the change). There is .set_visible() you can use with an boolean parameter. if you want to make it a one-liner.
  • print() is OK when debugging, just make sure to remove them before committing/submitting. (I'd say in a draft PR it would be OK, since code is likely to be changed anyway). You could also use the logging system to print stuff out like log.debug("xyz") if you think it could be useful later when debugging (you need to import logging and log = logging.getLogger(__name__) near the top of the file, like for example
    import logging
    import dataclasses
    from typing import Optional, List, Tuple
    from gi.repository import GObject, GLib, Gtk, Gdk
    log = logging.getLogger(__name__)

For the link stuff (mentioned in the linked issue), https://docs.gtk.org/gtk3/class.Label.html#links would be a start.

Edit: Also seeing it now, consider creating a branch in your repository to do the changes rather in your master. So you can name it better and don't accidentally overwrite/combine changes if you want to submit multiple changes (in separate PRs). I don't think GitHub lets you change the branch to merge from, so you can keep it for now.

…ile directly from the description.

Button hiding is now a one liner.

Description for file storage updated to be more accurate since it is not a sync service.

Remove extraneous print statement from previous commit.
@runkaiz runkaiz changed the title Hide button when default is detected Improve Synchronization UI May 16, 2022
The add panel now has the ability to detect which back-ends failed to initialize on start, and the developer can add corresponding error messages to help the user resolve dependency problems.
@runkaiz runkaiz marked this pull request as ready for review May 16, 2022 18:36
@runkaiz
Copy link
Author

runkaiz commented May 16, 2022

I believe most if not all of the requested changes have been applied. I might have misinterpreted the part about hiding the enable / disable button on the default back-end so I would appreciate it if someone can help me review this.

edit: typo

Copy link
Contributor

@Neui Neui left a comment

Choose a reason for hiding this comment

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

I am not sure if we should make a link to the XML file. At least for me, clicking on it does nothing, and if something did, it may encourage people to modify the file while GTG is still open.

Images would have been nice to look at. Just launch gnome-screenshot -i, select region, copy to clipboard and paste inside GitHub textbox thing.

Default

After fixing the .append() issue:
caldav not found

I don't quite like how it looks like. Maybe allow Caldav to be selectable, but name it like "caldav (error)" or something, so if you have multiple backends you can see which ones have an error.

@@ -151,7 +151,9 @@ def refresh_sync_status_label(self):
Refreshes the Gtk.Label that shows the current state of this backend
"""
if self.backend.is_default():
label = _("This is the default synchronization service")
xml_folder = GLib.filename_to_uri("/home/" + GLib.get_user_name() + "/.var/app/org.gnome.GTG/data/gtg/gtg_data.xml")
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't hardcode paths like that, especially this is flatpak only and not everyone uses the flatpak version (such as distros, developers or users who test locally/want the latest version).

Seems self.backend.get_path() should work.

def get_path(self) -> str:

label = _("This is the default synchronization service")
xml_folder = GLib.filename_to_uri("/home/" + GLib.get_user_name() + "/.var/app/org.gnome.GTG/data/gtg/gtg_data.xml")

label = "This is the default file storage backend. <a href='{}'>{}</a>.".format(xml_folder, _("Open the XML data file"))
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
label = "This is the default file storage backend. <a href='{}'>{}</a>.".format(xml_folder, _("Open the XML data file"))
label = _("This is the default file storage backend. <a href='{}'>Open the XML data file</a>.").format(xml_folder)

The outer text wasn't marked as translatable. Also you can inline the text for more context to the translators.

@@ -170,7 +172,16 @@ def on_combo_changed(self, widget=None):
"""
backend_name = self.combo_types.get_selected()
if backend_name is None:
if 'backend_caldav' in inactive_modules:
markup = '<big>Error: Python package \'caldev\' not installed.</big>'
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
markup = '<big>Error: Python package \'caldev\' not installed.</big>'
markup = '<big>{}</big>'.format(_('Error: Python package \'caldav\' not installed.'))

Typo in caldav, and make it translatable.

return


markup = '<big>Error: An unknown backend could not be loaded.</big>'
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
markup = '<big>Error: An unknown backend could not be loaded.</big>'
markup = '<big>{}</big>'.format(_('Error: An unknown backend could not be loaded.'))

Make it translatable.

@@ -67,10 +67,12 @@ def __init__(self):
# Something is wrong with this backend, skipping
log.warning("Backend %s could not be loaded: %r",
module_name, exception)
inactive_modules.append(module_name)
Copy link
Contributor

@Neui Neui May 29, 2022

Choose a reason for hiding this comment

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

Suggested change
inactive_modules.append(module_name)
inactive_modules.add(module_name)
Traceback (most recent call last):
  File "/app/lib/python3.9/site-packages/GTG/backends/__init__.py", line 65, in __init__
    __import__(extended_module_name)
  File "/app/lib/python3.9/site-packages/GTG/backends/backend_caldav.py", line 30, in <module>
    import caldav
ModuleNotFoundError: No module named 'caldav'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/app/lib/python3.9/site-packages/GTG/gtk/application.py", line 124, in do_startup
    for backend_dic in BackendFactory().get_saved_backends_list():
  File "/app/lib/python3.9/site-packages/GTG/backends/__init__.py", line 70, in __init__
    inactive_modules.append(module_name)
AttributeError: 'set' object has no attribute 'append'

You need to use .add() since it is a set, not an list.

continue
except Exception:
# Other exception log as errors
log.exception("Malformated backend %s:", module_name)
inactive_modules.append(module_name)
Copy link
Contributor

@Neui Neui May 29, 2022

Choose a reason for hiding this comment

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

Suggested change
inactive_modules.append(module_name)
inactive_modules.add(module_name)

Ditto. You need to use .add() since it is a set, not an list.

@@ -32,7 +32,7 @@
from GTG.backends.generic_backend import GenericBackend

log = logging.getLogger(__name__)

inactive_modules = set()
Copy link
Contributor

Choose a reason for hiding this comment

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

Might be better to move this to the BackendFactory class below. The Borg class it inherits is basically making it a singleton (state shared on every instance).

@nekohayo
Copy link
Member

The big refactoring has finally landed (see the pinned 0.7 tracking issue for details)!

Please rebase this to the latest master. Apologies for the inconvenience; the new codebase is expected to be much better to work with.

@nekohayo nekohayo marked this pull request as draft February 26, 2024 18:37
@nekohayo nekohayo added the plugins Plugins and extra backends label Feb 26, 2024
@nekohayo
Copy link
Member

Once this gets rebased, I would like @jaesivsm to help reviewing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement plugins Plugins and extra backends
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Synchronization backends dialog doesn't look nice when there are no truly available sync backends to add
4 participants