Skip to content

Commit

Permalink
Merge branch 'main' into fix/directory-tree-bug
Browse files Browse the repository at this point in the history
  • Loading branch information
tomlin7 authored Apr 13, 2024
2 parents 9b9ac87 + 6b6f68e commit 6e6d7f5
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 13 deletions.
4 changes: 2 additions & 2 deletions biscuit/core/components/floating/menu/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ def add_item(self, text, command=lambda *_:...):
self.row += 1
return new_item

def add_checkable(self, text, command=lambda *_:...):
new_item = CheckableMenuItem(self.container, text, command)
def add_checkable(self, text, command=lambda *_:..., checked=False):
new_item = CheckableMenuItem(self.container, text, command, checked=checked)
new_item.grid(row=self.row, sticky=tk.EW, pady=0)
self.menu_items.append(new_item)

Expand Down
5 changes: 4 additions & 1 deletion biscuit/core/components/floating/menu/checkable.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@


class CheckableMenuItem(IconLabelButton):
def __init__(self, master, text, command=lambda *_:..., *args, **kwargs) -> None:
def __init__(self, master, text, command=lambda *_:..., checked=False, *args, **kwargs) -> None:
super().__init__(master, text, 'check', command, expandicon=False, iconsize=10, toggle=False, *args, **kwargs)

self.command = command
if checked:
self.toggle_icon()

self.bg, self.fg, self.hbg, self.hfg = self.base.theme.menu.item.values()
self.on_leave()

Expand Down
2 changes: 1 addition & 1 deletion biscuit/core/components/views/sidebar/explorer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def __init__(self, master, *args, **kwargs) -> None:
self.name = 'Explorer'

self.menu = ExplorerMenu(self, 'files')
self.menu.add_checkable("Open Editors", self.toggle_active_editors)
self.menu.add_checkable("Open Editors", self.toggle_active_editors, checked=True)
self.menu.add_separator(10)
self.menu.add_item("Search", self.base.commands.show_file_search)
self.add_button('ellipsis', self.menu.show)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ def __init__(self, master, *args, **kwargs) -> None:
self.bind('<Visibility>', self.reload_tree)

self.menu = SourceControlMenu(self, 'files')
self.menu.add_checkable("Show Staged", self.tree.toggle_staged)
self.menu.add_checkable("Show Staged", self.tree.toggle_staged, checked=True)
self.menu.add_separator(10)
self.menu.add_checkable("Show Changes", self.tree.toggle_changes)
self.menu.add_checkable("Show Changes", self.tree.toggle_changes, checked=True)
self.add_button('refresh', self.refresh)
self.add_button('ellipsis', self.menu.show)

Expand Down
16 changes: 10 additions & 6 deletions biscuit/core/components/views/sidebar/sourcecontrol/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from biscuit.core.utils import Button, Entry, Frame, IconButton
from biscuit.core.utils.iconlabelbutton import IconLabelButton
from biscuit.core.utils.scrollableframe import ScrollableFrame

from .changes import Changes
from .placeholder import ChangesTreePlaceholder
Expand All @@ -26,8 +27,13 @@ def __init__(self, master, *args, **kwargs) -> None:
# self.more.config(**self.base.theme.utils.button)
# self.more.pack(fill=tk.BOTH)

self.staged_changes_tree = StagedChanges(self, *args, **kwargs)
self.changes_tree = Changes(self, *args, **kwargs)
self.container = ScrollableFrame(self, **self.base.theme.views.sidebar.item)
self.container.canvas.config(**self.base.theme.views.sidebar.item)

self.staged_changes_tree = StagedChanges(self.container, *args, **kwargs)
self.container.add(self.staged_changes_tree, fill=tk.BOTH, expand=True)
self.changes_tree = Changes(self.container, *args, **kwargs)
self.container.add(self.changes_tree, fill=tk.BOTH, expand=True)

self.placeholder = ChangesTreePlaceholder(self)
self.placeholder.pack(fill=tk.BOTH, expand=True)
Expand Down Expand Up @@ -102,17 +108,15 @@ def toggle_changes(self, *_) -> None:
def enable_tree(self) -> None:
self.placeholder.pack_forget()
self.commitbox.pack(padx=(15, 10), pady=5, fill=tk.BOTH)
self.staged_changes_tree.pack(fill=tk.BOTH)
self.changes_tree.pack(fill=tk.BOTH)
self.container.pack(fill=tk.BOTH, expand=True)

self.staged_changes_tree.clear_tree()
self.changes_tree.clear_tree()
self.open_repo()

def disable_tree(self) -> None:
self.commitbox.pack_forget()
self.staged_changes_tree.pack_forget()
self.changes_tree.pack_forget()
self.container.pack_forget()
self.placeholder.pack(fill=tk.BOTH, expand=True)

def get_commit_message(self) -> str:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ def add_item(self, path, kind) -> None:
def git_remove_all(self, *_) -> None:
if staged := list(self.items.keys()):
self.base.git.repo.unstage_files(*staged)
self.master.open_repo()
self.master.master.open_repo()

0 comments on commit 6e6d7f5

Please sign in to comment.