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