2
# -*- coding: utf-8 -*-
4
# This file is in the public domain
11
# Check if we are working in the source tree or from the installed
12
# package and mangle the python path accordingly
13
if os.path.dirname(sys.argv[0]) != ".":
14
if sys.argv[0][0] == "/":
15
fullPath = os.path.dirname(sys.argv[0])
17
fullPath = os.getcwd() + "/" + os.path.dirname(sys.argv[0])
19
fullPath = os.getcwd()
20
sys.path.insert(0, os.path.dirname(fullPath))
22
from acire import AboutAcireDialog, PreferencesAcireDialog
23
from acire.acireconfig import getdatapath
25
class AcireWindow(gtk.Window):
26
__gtype_name__ = "AcireWindow"
29
"""__init__ - This function is typically not called directly.
30
Creation a AcireWindow requires redeading the associated ui
31
file and parsing the ui definition extrenally,
32
and then calling AcireWindow.finish_initializing().
34
Use the convenience function NewAcireWindow to create
40
def finish_initializing(self, builder):
41
"""finish_initalizing should be called after parsing the ui definition
42
and creating a AcireWindow object with it in order to finish
43
initializing the start of the new AcireWindow instance.
46
#get a reference to the builder and set up the signals
47
self.builder = builder
48
self.builder.connect_signals(self)
50
#uncomment the following code to read in preferences at start up
51
#dlg = PreferencesAcireDialog.NewPreferencesAcireDialog()
52
#self.preferences = dlg.get_preferences()
54
#code for other initialization actions should be added here
56
def about(self, widget, data=None):
57
"""about - display the about box for acire """
58
about = AboutAcireDialog.NewAboutAcireDialog()
59
response = about.run()
62
def preferences(self, widget, data=None):
63
"""preferences - display the preferences window for acire """
64
prefs = PreferencesAcireDialog.NewPreferencesAcireDialog()
65
response = prefs.run()
66
if response == gtk.RESPONSE_OK:
67
#make any updates based on changed preferences here
71
def quit(self, widget, data=None):
72
"""quit - signal handler for closing the AcireWindow"""
75
def on_destroy(self, widget, data=None):
76
"""on_destroy - called when the AcireWindow is close. """
77
#clean up code for saving application state should be added here
82
"""NewAcireWindow - returns a fully instantiated
83
AcireWindow object. Use this function rather than
84
creating a AcireWindow directly.
87
#look for the ui file that describes the ui
88
ui_filename = os.path.join(getdatapath(), 'ui', 'AcireWindow.ui')
89
if not os.path.exists(ui_filename):
92
builder = gtk.Builder()
93
builder.add_from_file(ui_filename)
94
window = builder.get_object("acire_window")
95
window.finish_initializing(builder)
98
if __name__ == "__main__":
99
#support for command line options
100
import logging, optparse
101
parser = optparse.OptionParser(version="%prog %ver")
102
parser.add_option("-v", "--verbose", action="store_true", dest="verbose", help="Show debug messages")
103
(options, args) = parser.parse_args()
105
#set the logging level to show debug messages
107
logging.basicConfig(level=logging.DEBUG)
108
logging.debug('logging enabled')
111
window = NewAcireWindow()