~jonobacon/acire/trunk

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# -*- coding: utf-8 -*-
### BEGIN LICENSE
# This file is in the public domain
### END LICENSE

import sys
import os
import gtk

from acire.acireconfig import getdatapath

class AboutAcireDialog(gtk.AboutDialog):
    __gtype_name__ = "AboutAcireDialog"

    def __init__(self):
        """__init__ - This function is typically not called directly.
        Creation of a AboutAcireDialog requires redeading the associated ui
        file and parsing the ui definition extrenally, 
        and then calling AboutAcireDialog.finish_initializing().
    
        Use the convenience function NewAboutAcireDialog to create 
        NewAboutAcireDialog objects.
    
        """
        pass

    def finish_initializing(self, builder):
        """finish_initalizing should be called after parsing the ui definition
        and creating a AboutAcireDialog object with it in order to finish
        initializing the start of the new AboutAcireDialog instance.
    
        """
        #get a reference to the builder and set up the signals
        self.builder = builder
        self.builder.connect_signals(self)

        #code for other initialization actions should be added here

def NewAboutAcireDialog():
    """NewAboutAcireDialog - returns a fully instantiated
    AboutAcireDialog object. Use this function rather than
    creating a AboutAcireDialog instance directly.
    
    """

    #look for the ui file that describes the ui
    ui_filename = os.path.join(getdatapath(), 'ui', 'AboutAcireDialog.ui')
    if not os.path.exists(ui_filename):
        ui_filename = None

    builder = gtk.Builder()
    builder.add_from_file(ui_filename)    
    dialog = builder.get_object("about_acire_dialog")
    dialog.finish_initializing(builder)
    return dialog

if __name__ == "__main__":
    dialog = NewAboutAcireDialog()
    dialog.show()
    gtk.main()