# HG changeset patch # User Drew Perttula # Date 2012-06-10 06:55:46 # Node ID 417e23dc0af05c8072b3d5ed800280863178ebf5 # Parent d5692ab6bc2aabd893a62cee9c43b7500b0f0be5 add marble-ice theme. use --reload to opt in to all autoreloading Ignore-this: d87e96e140fa5c7d43bc3cdc32b86a50 diff --git a/bin/curvecalc b/bin/curvecalc --- a/bin/curvecalc +++ b/bin/curvecalc @@ -30,7 +30,6 @@ from light9.curvecalc.curve import Curve from light9.curvecalc import curveview from light9.curvecalc.musicaccess import Music, currentlyPlayingSong from light9.wavelength import wavelength -from light9.uihelpers import toplevelat from light9.namespaces import L9 from light9.curvecalc.subterm import read_all_subs, savekey, graphPathForSubterms from light9.curvecalc.subtermview import add_one_subterm @@ -46,14 +45,19 @@ def makeGraph(): class Main(object): def __init__(self, graph, opts, song, curveset, subterms, music): - self.graph = graph - self.music = music - wtree = gtk.Builder() + self.graph, self.opts, self.song = graph, opts, song + self.curveset, self.subterms, self.music = curveset, subterms, music + + wtree = self.wtree = gtk.Builder() wtree.add_from_file(sibpath(__file__, "../light9/curvecalc/curvecalc.glade")) mainwin = wtree.get_object("MainWindow") mainwin.connect("destroy", self.onQuit) wtree.connect_signals(self) + gtk.rc_parse("theme/marble-ice/gtk-2.0/gtkrc") + gtk.rc_parse_string("""style "default" {font_name = "sans 7"}""") + if self.opts.reload: + self.refreshTheme() mainwin.show_all() mainwin.connect("delete-event", lambda *args: reactor.crash()) @@ -62,48 +66,14 @@ class Main(object): self.add_subterms_for_song(song, curveset, subterms, wtree.get_object("subterms") ) - - def refreshCurveView(): - mtimes = [os.path.getmtime(f) for f in [ - 'light9/curvecalc/curveview.py', - 'light9/curvecalc/zoomcontrol.py', - ]] - - if (not hasattr(self, 'curvesetView') or - self.curvesetView._mtimes != mtimes): - print "reload curveview.py" - curvesVBox = wtree.get_object("curves") - zoomControlBox = wtree.get_object("zoomControlBox") - [curvesVBox.remove(c) for c in curvesVBox.get_children()] - [zoomControlBox.remove(c) for c in - zoomControlBox.get_children()] - try: - linecache.clearcache() - reload(curveview) - # mem problem somewhere; need to hold a ref to this - self.curvesetView = curveview.Curvesetview( - curvesVBox, zoomControlBox, curveset) - self.curvesetView._mtimes = mtimes - - # curvesetview must already exist, since this - # makes 'add_curve' signals for all the initial - # curves - curveset.load(basename=os.path.join( - showconfig.curvesDir(), - showconfig.songFilenameFromURI(song)), - skipMusic=opts.skip_music) - # this is scheduled after some tk shuffling, to - # try to minimize the number of times we redraw - # the curve at startup. If tk is very slow, it's - # ok. You'll just get some wasted redraws. - self.curvesetView.goLive() - except Exception, e: - print "reload failed:", e - reactor.callLater(1, refreshCurveView) - refreshCurveView() + self.refreshCurveView() self.makeStatusLines(wtree.get_object("status")) + def refreshTheme(self): + gtk.rc_reparse_all() + reactor.callLater(1, self.refreshTheme) + def onQuit(self, *args): reactor.crash() # there's a hang after this, maybe in sem_wait in two @@ -165,8 +135,47 @@ class Main(object): signame, weak=False) master.show_all() + def refreshCurveView(self): + wtree = self.wtree + mtimes = [os.path.getmtime(f) for f in [ + 'light9/curvecalc/curveview.py', + 'light9/curvecalc/zoomcontrol.py', + ]] - def onReloadSubs(self): # wants to be ctrl-r too + if (not hasattr(self, 'curvesetView') or + self.curvesetView._mtimes != mtimes): + print "reload curveview.py" + curvesVBox = wtree.get_object("curves") + zoomControlBox = wtree.get_object("zoomControlBox") + [curvesVBox.remove(c) for c in curvesVBox.get_children()] + [zoomControlBox.remove(c) for c in + zoomControlBox.get_children()] + try: + linecache.clearcache() + reload(curveview) + # mem problem somewhere; need to hold a ref to this + self.curvesetView = curveview.Curvesetview( + curvesVBox, zoomControlBox, self.curveset) + self.curvesetView._mtimes = mtimes + + # curvesetview must already exist, since this + # makes 'add_curve' signals for all the initial + # curves + self.curveset.load(basename=os.path.join( + showconfig.curvesDir(), + showconfig.songFilenameFromURI(self.song)), + skipMusic=self.opts.skip_music) + # this is scheduled after some tk shuffling, to + # try to minimize the number of times we redraw + # the curve at startup. If tk is very slow, it's + # ok. You'll just get some wasted redraws. + self.curvesetView.goLive() + except Exception, e: + print "reload failed:", e + if self.opts.reload: + reactor.callLater(1, self.refreshCurveView) + + def onReloadSubs(self, *args): # wants to be ctrl-r too dispatcher.send('reload all subs') def onAddSubterm(self): @@ -190,6 +199,8 @@ def main(): help="ignore music and smooth_music curve files") parser.add_option("--debug", action="store_true", help="log at DEBUG") + parser.add_option("--reload", action="store_true", + help="live reload of themes and code") parser.add_option("--startup-only", action='store_true', help="quit after loading everything (for timing tests)") opts, args = parser.parse_args() @@ -203,7 +214,7 @@ def main(): except IndexError: song = currentlyPlayingSong() - music=Music() + music = Music() graph = makeGraph() curveset = Curveset(sliders=opts.sliders) @@ -233,6 +244,6 @@ def main(): log.debug("quitting now because of --startup-only") return - reactor.run() + prof.run(reactor.run, profile=False) main() diff --git a/light9/curvecalc/curvecalc.glade b/light9/curvecalc/curvecalc.glade --- a/light9/curvecalc/curvecalc.glade +++ b/light9/curvecalc/curvecalc.glade @@ -193,7 +193,6 @@ False Poin_ts True - True @@ -399,6 +398,7 @@ True False image2 + diff --git a/theme/marble-ice/README b/theme/marble-ice/README new file mode 100644 --- /dev/null +++ b/theme/marble-ice/README @@ -0,0 +1,5 @@ +GTK2 Theme: marble-ice +Engine: Thinice, Redmond95 + +Author: Floe +Comment: a Frankenstein-style creation from marble-look and Black Marble diff --git a/theme/marble-ice/gtk-2.0/gtkrc b/theme/marble-ice/gtk-2.0/gtkrc new file mode 100644 --- /dev/null +++ b/theme/marble-ice/gtk-2.0/gtkrc @@ -0,0 +1,60 @@ +# Sneaking through the code are we.? ;) +style "default" +{ + + GtkEntry::cursor_color = "#FFCE00" + GtkTextView::cursor_color = "#FFCE00" + NautilusIconContainer::frame_text = 1 + + fg[NORMAL] = "#CACAC6" + fg[ACTIVE] = "#CACAC6" + fg[INSENSITIVE] = "#000000" + fg[PRELIGHT] = "#E2E2E2" + fg[SELECTED] = "#E2E2E2" + + bg[ACTIVE] = "#484949" + bg[NORMAL] = "#5A5C5F" + bg[INSENSITIVE] = "#505050" + bg[PRELIGHT] = "#6A6C6F" + bg[SELECTED] = "#424446" + + base[NORMAL] = "#919499" + base[ACTIVE] = "#5A5C5F" + base[INSENSITIVE] = "#5A5C5F" + base[PRELIGHT] = "#646668" + base[SELECTED] = "#5A5C5F" + + text[NORMAL] = "#000000" + text[ACTIVE] = "#000000" + text[PRELIGHT] = "#000000" + text[SELECTED] = "#E0D6AD" + text[INSENSITIVE] = "#777777" + + engine "thinice" + { + # Do you want the scrollbar handles rectangular or a bit shaped? + rect_scrollbar = TRUE + + # The following variables are semi-generic, can be applied to + # different widget classes etc.. + + # Mark type 1 is used on scrollbar handles, handleboxes etc + mark_type1 = DOT + # Mark type 2 is used on scrollbar buttons + mark_type2 = ARROW + } +} + +style "togglebuttons" = "default" +{ + fg[NORMAL] = "#000000" + fg[ACTIVE] = "#000000" + fg[PRELIGHT] = "#000000" + fg[SELECTED] = "#000000" + engine "redmond95" { } +} + +class "GtkWidget" style "default" +class "GtkCheckButton" style "togglebuttons" +class "GtkRadioButton" style "togglebuttons" +