Skip to content

Commit

Permalink
Merge pull request #228 from billyeatcookies/recents
Browse files Browse the repository at this point in the history
feat: add recent folders to welcome
  • Loading branch information
tomlin7 authored Feb 6, 2024
2 parents 8b09fa8 + e005935 commit f7f0ee3
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 9 deletions.
26 changes: 17 additions & 9 deletions biscuit/core/components/editors/misc/welcome.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import tkinter as tk

from ...utils import Frame, IconLabelButton, Label
from ...utils import Frame, IconLabelButton, Label, LinkLabel
from ..editor import BaseEditor


Expand All @@ -26,6 +27,7 @@ def __init__(self, master, exists=False, editable=False, *args, **kwargs) -> Non
self.description.grid(row=1, column=0, sticky=tk.W, pady=5)

self.create_start_group()
self.create_recent_group()

try:
self.logo = Label(self.right, image=self.base.settings.res.logo, **self.base.theme.editors.biscuit_labels)
Expand All @@ -35,14 +37,20 @@ def __init__(self, master, exists=False, editable=False, *args, **kwargs) -> Non

def create_start_group(self):
Label(self.left, text="Start", font=("Segoe UI", 15), **self.base.theme.editors.labels).grid(row=2, column=0, sticky=tk.W, pady=(40, 0))
start_group = Frame(self.left, **self.base.theme.editors)
start_group.grid(row=3, column=0, sticky=tk.EW)

IconLabelButton(start_group, "New File...", 'new-file', self.new_file).grid(row=0, column=0, sticky=tk.W, pady=2)
IconLabelButton(start_group, "Open File...", 'go-to-file', self.open_file).grid(row=1, column=0, sticky=tk.W, pady=2)
IconLabelButton(start_group, "Open Folder...", 'folder-opened', self.open_folder).grid(row=2, column=0, sticky=tk.W, pady=2)

#TODO add recents
start = Frame(self.left, **self.base.theme.editors)
start.grid(row=3, column=0, sticky=tk.EW)

IconLabelButton(start, "New File...", 'new-file', self.new_file).grid(row=0, column=0, sticky=tk.W, pady=2)
IconLabelButton(start, "Open File...", 'go-to-file', self.open_file).grid(row=1, column=0, sticky=tk.W, pady=2)
IconLabelButton(start, "Open Folder...", 'folder-opened', self.open_folder).grid(row=2, column=0, sticky=tk.W, pady=2)

def create_recent_group(self):
Label(self.left, text="Recent", font=("Segoe UI", 15), **self.base.theme.editors.labels).grid(row=4, column=0, sticky=tk.W, pady=(40, 0))
recents = Frame(self.left, **self.base.theme.editors)
recents.grid(row=5, column=0, sticky=tk.EW)

for i, p in enumerate(self.base.history.folder_history.list):
LinkLabel(recents, os.path.basename(p[0]), p[1]).grid(row=i, column=0, sticky=tk.W, pady=2)

def new_file(self, *_):
self.base.events.new_file()
Expand Down
1 change: 1 addition & 0 deletions biscuit/core/components/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from .iconbutton import IconButton
from .iconlabelbutton import IconLabelButton
from .label import Label, TruncatedLabel, WrappingLabel
from .linklabel import LinkLabel
from .menubutton import Menubutton
from .scrollableframe import ScrollableFrame
from .scrollbar import Scrollbar
Expand Down
14 changes: 14 additions & 0 deletions biscuit/core/components/utils/linklabel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import tkinter as tk

from .label import Label


class LinkLabel(Label):
"""A Flat style button"""
def __init__(self, master, text, command=lambda _: None, *args, **kwargs) -> None:
super().__init__(master, text=text, *args, **kwargs)
self.config(font=("Segoi UI", 10), **self.base.theme.utils.linklabel)
self.set_command(command)

def set_command(self, command) -> None:
self.bind('<Button-1>', command)
1 change: 1 addition & 0 deletions biscuit/core/settings/config/theme/theme.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ def __init__(self, *args, **kwargs) -> None:
theme = self.master

self.button = HighlightableThemeObject(self, theme.biscuit, "white", theme.biscuit_dark)
self.linklabel = ThemeObject(self, theme.secondary_background, theme.biscuit, self.highlightbackground)
self.colorlabel = ThemeObject(self, theme.biscuit, "white", theme.biscuit_dark)
self.tree = FrameThemeObject(self)
self.tree.item = ThemeObject(self.tree)
Expand Down

0 comments on commit f7f0ee3

Please sign in to comment.