Logo Search packages:      
Sourcecode: harpia version File versions  Download package

def harpia::preferences::Preferences::__init__ (   self,
  Editor 
)

      The Constructor. Loads the glade object, and initializes the GladeWindow object for signal connecting.

Definition at line 50 of file preferences.py.

00050                                   :
            """
                  The Constructor. Loads the glade object, and initializes the GladeWindow object for signal connecting.
            """
            
            self.m_oEditor = Editor
            self.m_sDataDir = os.environ['HARPIA_DATA_DIR']
            
            ## Imports the Glade file
            filename = self.m_sDataDir+'glade/preferences.glade'

            # The widget list
            widget_list = [ 'preferences',
                        'PREFGridInt',
                        'PREFShowGrid',
                        'PREFServer',
                        'PREFPort']

            # Signal Handlers from the Buttons Confirm and Cancel
            handlers = [  'on_preferences_confirm_clicked',
                      'on_preferences_cancel_clicked']

            # The Top window widget
            top_window = 'preferences'
            
            # Starts the GladeWindow, calling his __init__ method.
            GladeWindow.__init__(self, filename, top_window, widget_list, handlers)
        
            # Set the preferences Icon
            self.widgets['preferences'].set_icon_from_file(self.m_sDataDir+"images/harpia_ave.png")

        #---------------------------------
        
            ## The Homefolder where the preferences will be stored.
            if os.name=="nt":
00085                     self.HomeFolder = os.path.join(os.path.expanduser("~"),"harpiaFiles\\")
                else:
                    self.HomeFolder = os.path.expanduser("~/harpiaFiles/")
#        self.HomeFolder = "/tmp/.harpia/"

            ## The Config File Path
00091             self.configfile = self.HomeFolder + "harpia.conf"
            
            # If the path do not exist, creates one.
            if not( os.path.exists(self.HomeFolder) ):
                  os.makedirs(self.HomeFolder, mode=0700)

            # If the path do not exist, creates one copyint the default harpia.conf.
            if not( os.path.exists(self.configfile) ):
                  shutil.copy("harpia.conf", self.HomeFolder)

                print "TESTE" +  self.configfile       
            ## A binderytool object, with the preferences stored
00103             self.m_oPreferencesXML = bt.bind_file(self.configfile)


        #---------------------------------
        

        # Load Preferences
            for Preference in self.m_oPreferencesXML.harpia.editor.property:

                  if Preference.name == "show-grid":
                        if Preference.value == "false":
                              state = "False"
                        else:
                              state = "True"
                        self.widgets['PREFShowGrid'].set_active( eval(state) )
                
                  if Preference.name == "grid-int":
                        self.widgets['PREFGridInt'].set_value( int(Preference.value) )

                  if Preference.name == "server":
                        self.widgets['PREFServer'].set_text( unicode(Preference.value) ) 

                  if Preference.name == "port":
                        self.widgets['PREFPort'].set_value( int(Preference.value) )                

                    
    #----------------------------------------------------------------------

      def __del__(self):


Generated by  Doxygen 1.6.0   Back to index