Window standalone module
The window is now a standalone module, and no longer accessed through ocarina.__init__.py
This commit is contained in:
parent
aa685005c9
commit
7efbe9b76c
|
@ -7,15 +7,17 @@ before = now()
|
|||
|
||||
import libsaria
|
||||
import ocarina
|
||||
from ocarina import window
|
||||
|
||||
from ocarina import collection
|
||||
|
||||
width = libsaria.init_pref("ocarina.window.width", 800)
|
||||
height = libsaria.init_pref("ocarina.window.height", 600)
|
||||
|
||||
win = ocarina.get_window((width, height))
|
||||
ocarina.set_window_title("%s Your Music Everywhere" % ocarina.__vers__)
|
||||
ocarina.set_window_icon("images/ocarina.png")
|
||||
window.init(width, height)
|
||||
window.set_title("%s Your Music Everywhere" % ocarina.__vers__)
|
||||
window.set_icon("images/ocarina.png")
|
||||
window.add(ocarina.get_tabs())
|
||||
|
||||
ocarina.add_tab("Playlist", collection.Playlist())
|
||||
ocarina.add_tab("Library", collection.Library())
|
||||
|
|
|
@ -22,20 +22,14 @@ gdk.threads_init()
|
|||
gobject.threads_init()
|
||||
|
||||
# Lazy loaded modules
|
||||
window = None
|
||||
tabs = None
|
||||
box = None
|
||||
|
||||
|
||||
# Function override variables
|
||||
get_tabs = None
|
||||
get_window = None
|
||||
|
||||
|
||||
# Global variables for some objects
|
||||
#main_window = None
|
||||
#main_tabs = None
|
||||
|
||||
def startup():
|
||||
global gtk
|
||||
import gtk
|
||||
|
@ -66,28 +60,3 @@ def add_tab(text, content):
|
|||
def remove_tab(text):
|
||||
global tabs
|
||||
tabs.remove_page(text)
|
||||
|
||||
|
||||
def get_window_once(size):
|
||||
global window
|
||||
global get_window
|
||||
import window
|
||||
window.init(size)
|
||||
window.add(get_tabs())
|
||||
get_window = get_window_rest
|
||||
return window.window
|
||||
def get_window_rest(size=None):
|
||||
global window
|
||||
if size != None:
|
||||
window.resize(size[0], size[1])
|
||||
return window.window
|
||||
get_window = get_window_once
|
||||
|
||||
def set_window_title(text):
|
||||
window = get_window()
|
||||
window.set_title(text)
|
||||
|
||||
def set_window_icon(path):
|
||||
if libsaria.path.exists(path):
|
||||
window = get_window()
|
||||
window.set_icon_from_file(path)
|
||||
|
|
|
@ -12,17 +12,20 @@ add = None
|
|||
resize = None
|
||||
connect = None
|
||||
|
||||
set_title = None
|
||||
|
||||
def init(size):
|
||||
def init(width, height):
|
||||
global window
|
||||
global add
|
||||
global resize
|
||||
global connect
|
||||
global set_title
|
||||
|
||||
window = gtk.Window(gtk.WINDOW_TOPLEVEL)
|
||||
add = window.add
|
||||
resize = window.resize
|
||||
connect = window.connect
|
||||
window = gtk.Window(gtk.WINDOW_TOPLEVEL)
|
||||
add = window.add
|
||||
resize = window.resize
|
||||
connect = window.connect
|
||||
set_title = window.set_title
|
||||
|
||||
connect("delete-event", ocarina.exit)
|
||||
connect("size-allocate", resized)
|
||||
|
@ -32,10 +35,16 @@ def init(size):
|
|||
dnd_list = [("text/uri-list", 0, TARGET_TYPE_URI_LIST)]
|
||||
window.drag_dest_set(mask, dnd_list, gtk.gdk.ACTION_COPY)
|
||||
|
||||
window.resize(size[0], size[1])
|
||||
resize(width, height)
|
||||
window.show()
|
||||
|
||||
|
||||
def set_icon(path):
|
||||
global window
|
||||
if libsaria.path.exists(path):
|
||||
window.set_icon_from_file(path)
|
||||
|
||||
|
||||
def resized(widget, geom):
|
||||
libsaria.prefs.set_pref("ocarina.window.width", geom.width)
|
||||
libsaria.prefs.set_pref("ocarina.window.height", geom.height)
|
||||
|
|
Loading…
Reference in New Issue