ocarina: Page showing and hiding improvements
When hiding a page I want to switch to page n - 1, but gtk was moving me to n + 1. I also added a function to show, and optionally switch to, a page.
This commit is contained in:
parent
93a785dafa
commit
b373a88618
|
@ -31,8 +31,11 @@ def current_page():
|
|||
cur_num = body.get_current_page()
|
||||
return body.get_nth_page(cur_num)
|
||||
|
||||
def switch_to_page_n(n):
|
||||
body.set_current_page(n)
|
||||
|
||||
def switch_to_page(page):
|
||||
body.set_current_page(page_num(page))
|
||||
switch_to_page_n(page_num(page))
|
||||
|
||||
def switch_page(notebook, page, pagenum):
|
||||
cur_pg = current_page()
|
||||
|
@ -40,6 +43,17 @@ def switch_page(notebook, page, pagenum):
|
|||
cur_pg.invisible()
|
||||
next_pg.visible()
|
||||
|
||||
def hide_page(page):
|
||||
n = page_num(page)
|
||||
if n > 0:
|
||||
switch_to_page_n(n - 1)
|
||||
page.hide()
|
||||
|
||||
def show_page(page, switch = False):
|
||||
page.show()
|
||||
if switch == True:
|
||||
switch_to_page(page)
|
||||
|
||||
def cur_page_filter(text):
|
||||
current_page().filter(text)
|
||||
|
||||
|
|
|
@ -14,9 +14,9 @@ def set_label_text():
|
|||
|
||||
def set_visible():
|
||||
if queue.num_visible() == 0:
|
||||
QUEUE_PAGE.hide()
|
||||
body.hide_page(QUEUE_PAGE)
|
||||
else:
|
||||
QUEUE_PAGE.show()
|
||||
body.show_page(QUEUE_PAGE)
|
||||
|
||||
def fill_queue():
|
||||
attrs = ("id", "title", "lenstr", "artist", "album", "year")
|
||||
|
|
Loading…
Reference in New Issue