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

misc improvements #562

Merged
merged 9 commits into from
Nov 6, 2023
Merged

misc improvements #562

merged 9 commits into from
Nov 6, 2023

Conversation

cmkohnen
Copy link
Collaborator

@cmkohnen cmkohnen commented Nov 4, 2023

  • Display used style in Figure Settings initial view and use correct design pattern (Inspired by gnome-control-center)
  • Fix startup with custom style (in user directory)
  • Don't inject an attribute into RcParams
  • Move Style class to vala and use proper getters and setters
  • Annotate all functions in style_manager
  • Fix parsing error triggering not found message
  • Check for ubuntu only on init to save resources
  • Move preview generation to style_io and use tmpfile instead of one in cache dir
  • Fix selected style not updating in some cases
  • Use classmethod instead of staticmethod for items
  • Implement file-like-wrapper to avoid in-memory buffers
  • Progressively parse columns and styles
  • fix migration issues
  • Use Context manager for file handling

Signed-off-by: Christoph Matthias Kohnen <christoph.kohnen@disroot.org>
Signed-off-by: Christoph Matthias Kohnen <christoph.kohnen@disroot.org>
Signed-off-by: Christoph Matthias Kohnen <christoph.kohnen@disroot.org>
Signed-off-by: Christoph Matthias Kohnen <christoph.kohnen@disroot.org>
Signed-off-by: Christoph Matthias Kohnen <christoph.kohnen@disroot.org>
src/file_io.py Outdated
return json.loads(file.load_bytes(None)[0].get_data())
wrapper = FileLikeWrapper.new_for_file_readonly(file)
return json.load(wrapper)
wrapper.close()
Copy link
Owner

Choose a reason for hiding this comment

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

Will it actually ever reach line 95 (closing the wrapper), as it typically stops the function after the return statement no?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, you are correct, my mistake. I've pushed a fix, where a contextmanager is used, taking care of closing the stream

@staticmethod
def new(params, xdata=None, ydata=None, **kwargs):
return DataItem(
@classmethod
Copy link
Owner

Choose a reason for hiding this comment

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

I've actually been working a lot with custom constructors at work, where I've been using class methods for the exact same purpose. Seems the better way to me, yes. Also coincidentally reminds me on what I've been working on at work.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The main reason, was that classmethods can be inherited. Say we introduce DataItemButWithInternalHistory which doesn't need its own new method, since it has no new properties to render. using the staticmethod we would only get a DataItem whereas a classmethod will indeed get the correct type.

Signed-off-by: Christoph Matthias Kohnen <christoph.kohnen@disroot.org>
Signed-off-by: Christoph Matthias Kohnen <christoph.kohnen@disroot.org>
Signed-off-by: Christoph Matthias Kohnen <christoph.kohnen@disroot.org>
Signed-off-by: Christoph Matthias Kohnen <christoph.kohnen@disroot.org>
@cmkohnen cmkohnen requested a review from sstendahl November 6, 2023 12:04
Copy link
Owner

@sstendahl sstendahl left a comment

Choose a reason for hiding this comment

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

Looks good to me.

for index, line in enumerate(wrapper.wrap_text()):
if index <= skip_rows:
for index, line in enumerate(wrapper.wrap_text(), -skip_rows):
if index < 0:
Copy link
Owner

Choose a reason for hiding this comment

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

Had to look twice to see why this unusual logic is used, but it makes line 118 cleaner. So seems more robust.

@cmkohnen cmkohnen merged commit e26affe into main Nov 6, 2023
6 checks passed
@sstendahl sstendahl deleted the misc-improvements branch November 15, 2023 14:30
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.

2 participants