Skip to content

Conversation

@beef331
Copy link

@beef331 beef331 commented May 29, 2025

Adds button to the header bar to add or remove a bookmark.
Bookmarks are stored inside a file at $XDG_CONFIG_HOME/Portfolio/bookmarks.

Copy link
Owner

@tchx84 tchx84 left a comment

Choose a reason for hiding this comment

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

hey @beef331 , thanks for working on this :) It would be a nice addition indeed.

I left some comments on how we could better integrate this, please check these comments and let me know if you have any questions.

Copy link
Owner

Choose a reason for hiding this comment

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

Maybe there's a way to reuse the already existent user-bookmarks-symbolic and handle the "filled" case with CSS?

Copy link
Author

Choose a reason for hiding this comment

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

I could be wrong, but I don't think it's possible to fill the svg's shape using CSS alone.

@beef331
Copy link
Author

beef331 commented Jun 18, 2025

Given the mess made more sense to rebase, sorry if it causes any issues. Still uncertain how to pipe signals around this I for one don't like the indirection it hurts my head.

@tchx84
Copy link
Owner

tchx84 commented Jun 24, 2025

Given the mess made more sense to rebase, sorry if it causes any issues. Still uncertain how to pipe signals around this I for one don't like the indirection it hurts my head.

No worries, I can still review it, but eventually we should fix this rebase, these older commits shouldn't show up.

Copy link
Owner

@tchx84 tchx84 left a comment

Choose a reason for hiding this comment

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

Looking much better :) But see my comments on how this model should be designed and used.

src/places.py Outdated
self._devices_listbox = utils.find_child_by_id(self._devices_group, "listbox")
self._bookmarks_listbox = utils.find_child_by_id(self._bookmarks_group, "listbox")

self._add_unadded_accessible_bookmarks()
Copy link
Owner

Choose a reason for hiding this comment

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

how about _populate_initial_bookmarks ?

for path in self._bookmarks.bookmarked:
notAdded = self._find_place_by_path(self._bookmarks_listbox, path) is None
if notAdded and os.path.isdir(path): # Might be a bookmarked path on a unmounted device
self._add_bookmark_place(path)
Copy link
Owner

Choose a reason for hiding this comment

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

Why do you need to check if it's in widget? If you're worried about duplicates, that's something you can deal with in the mode (e.g., using a set instead of a list). Same thing for available or unavailable bookmarks.

So this ideally look like:

for path in self._bookmarks.bookmarked:
    self._add_bookmark_place(path)

Copy link
Author

@beef331 beef331 Jul 2, 2025

Choose a reason for hiding this comment

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

One may connect a device which has paths stored in their bookmarks, the check was to not repeat add to the collection. As on start up it can be come disjointed from the stored list as there may not be bookmarks accessible at the time of opening.

Copy link
Owner

@tchx84 tchx84 left a comment

Choose a reason for hiding this comment

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

Looking much better :)

Can you try adding a custom PortfolioBookmarkButton class and move that "icon update" logic inside it?

So, the window widget will:

  1. Create the model (as it already does).
  2. Create the button widget, and passes the model (missing).
  3. Create the places widget, and passes the model (as it already does).
  4. Update the button widget "path" property when the path changes (missing).

And, the button class will:

  1. Handle the "clicked" event internally.
  2. Handle the updating of the icon internally, in one place.

If done as described, the Window widget can simply do something like self._bookmark_button.path = path, and the button can internally handle all bookmark-related logic like talking to the model and update the icon, in one place.

@beef331
Copy link
Author

beef331 commented Jul 2, 2025

Yea my uncertainty in how to do that is why it was not done 😄 I cannot find any reference in this codebase nor online how to properly do that.
I figured I just needed to do

class PortfolioBookmarkButton(Gtk.Button):
    __gtype_name__ = "PortfolioBookmarkButton"


    def __init(self):
        Gtk.Button.init(self)
        Gtk.connect("clicked", self._on_bookmark_toggle)

    def _on_bookmark_toggle(self, button):
        self._bookmarks.toggle_bookmark(button, path)
        if self._bookmarks.is_bookmarked(path):
            self.bookmark.props.icon_name = "bookmark-filled-symbolic"
        else:
            self.bookmark.props.icon_name = "bookmark-outline-symbolic"
            

Then inside the .ui change it to be PortfolioBookmarkButton instead of GtkButton, but that does not seem to work.

@tchx84
Copy link
Owner

tchx84 commented Jul 2, 2025

Yea my uncertainty in how to do that is why it was not done 😄 I cannot find any reference in this codebase nor online how to properly do that.

No problem, for now just add an empty GtkBox to the window.ui file and call it something like bookmark_box, then, on window.py, create the PortfolioBookmarkButton and add it to that GtkBox.

EDIT: there are existing examples of this, look for "placeholder" in window.ui.

@tchx84
Copy link
Owner

tchx84 commented Jul 2, 2025

@beef331 CI tests are failing, check the details. You need run pyflakes and black locally to fix these.

@beef331
Copy link
Author

beef331 commented Aug 5, 2025

Are there any more changes you want to see?

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