Changeset 263


Ignore:
Timestamp:
07/23/07 17:53:46 (5 years ago)
Author:
marc
Message:

Cleaned up code of the GUI.

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/locale/es/LC_MESSAGES/itaka.po

    r245 r263  
    291291msgstr "No se pudo grabar las preferencias" 
    292292 
    293 #: uigtk.py:938 
    294 msgid "Kurt Erickson <psychogenicshk@users.sourceforge.net> (Packaging)" 
    295 msgstr "Kurt Erickson <psychogenicshk@users.sourceforge.net> (Paquetes)" 
    296  
    297293#: uigtk.py:1008 
    298294msgid "Logging paused" 
  • trunk/locale/itaka.pot

    r238 r263  
    287287msgstr "" 
    288288 
    289 #: uigtk.py:938 
    290 msgid "Kurt Erickson <psychogenicshk@users.sourceforge.net> (Packaging)" 
    291 msgstr "" 
    292  
    293289#: uigtk.py:1008 
    294290msgid "Logging paused" 
  • trunk/uigtk.py

    r260 r263  
    155155        self.console.failure(caller, self.detailed_message, failure_type) 
    156156 
    157         # ERRORS require some more actions 
     157        # Errors require some more actions 
    158158        if failure_type == 'ERROR': 
    159159            # Show the window and its widgets, set the status icon blinking timeout 
     
    308308        self.window = gtk.Window(gtk.WINDOW_TOPLEVEL) 
    309309        self.window.connect('destroy', self.destroy) 
    310         self.window.connect('size-allocate', self.windowsizechanged) 
     310        self.window.connect('size-allocate', self._window_size_changed) 
    311311        self.window.set_title('Itaka') 
    312312        self.window.set_icon(self.icon_pixbuf) 
     
    319319        self.status_icon = gtk.StatusIcon() 
    320320        self.status_menu = gtk.Menu() 
     321 
    321322        if self.configuration['server']['authentication']: 
    322323            self.status_icon.set_from_pixbuf(gtk.gdk.pixbuf_new_from_file(os.path.join(self.itaka_globals.image_dir, 'itaka-secure.png'))) 
    323324        else: 
    324325            self.status_icon.set_from_pixbuf(self.icon_pixbuf) 
     326 
    325327        self.status_icon.set_tooltip('Itaka') 
    326328        self.status_icon.set_visible(True) 
     
    354356        self.status_menu.append(self.menu_item_start) 
    355357        self.status_menu.append(self.menu_item_stop) 
     358 
    356359        if self.itaka_globals.notify_available:  
    357360            self.status_menu.append(self.menu_item_separator) 
    358361            self.status_menu.append(self.menu_item_notifications) 
     362 
    359363        self.status_menu.append(self.menu_item_separator1) 
    360364        self.status_menu.append(self.menu_item_quit) 
     
    364368 
    365369        self.itaka_logo = gtk.Image() 
     370 
    366371        if self.configuration['server']['authentication']: 
    367372            self.itaka_logo.set_from_file(os.path.join(self.itaka_globals.image_dir, 'itaka-secure.png')) 
    368373        else: 
    369374            self.itaka_logo.set_from_file(os.path.join(self.itaka_globals.image_dir, 'itaka.png')) 
     375 
    370376        self.itaka_logo.show() 
    371377 
     
    380386 
    381387        self.button_preferences = gtk.Button('Preferences', gtk.STOCK_PREFERENCES) 
    382         self.button_preferences.connect('clicked', self.expandpreferences) 
     388        self.button_preferences.connect('clicked', self.expand_preferences) 
    383389 
    384390        # Set up some variables for our timeouts/animations 
     
    450456        self.hbox_log = gtk.HBox(False, 0) 
    451457        self.button_log_clear = gtk.Button(_('Clear')) 
    452         self.button_log_clearimage = gtk.Image() 
    453         self.button_log_clearimage.set_from_stock(gtk.STOCK_CLEAR, gtk.ICON_SIZE_BUTTON) 
    454         self.button_log_clear.set_image(self.button_log_clearimage) 
    455         self.button_log_clear.connect('clicked', self.clearlogger) 
     458        self.button_log_clear_image = gtk.Image() 
     459        self.button_log_clear_image.set_from_stock(gtk.STOCK_CLEAR, gtk.ICON_SIZE_BUTTON) 
     460        self.button_log_clear.set_image(self.button_log_clear_image) 
     461        self.button_log_clear.connect('clicked', self.clear_logger) 
    456462 
    457463        self.button_log_pause = gtk.ToggleButton(_('Pause')) 
    458         self.button_log_pauseimage = gtk.Image() 
    459         self.button_log_pauseimage.set_from_stock(gtk.STOCK_MEDIA_PAUSE, gtk.ICON_SIZE_BUTTON) 
    460         self.button_log_pause.set_image(self.button_log_pauseimage) 
     464        self.button_log_pause_image = gtk.Image() 
     465        self.button_log_pause_image.set_from_stock(gtk.STOCK_MEDIA_PAUSE, gtk.ICON_SIZE_BUTTON) 
     466        self.button_log_pause.set_image(self.button_log_pause_image) 
    461467        self.button_log_pause.connect('toggled', self.button_pause_log) 
    462468 
     
    473479        self.expander = gtk.Expander(None) 
    474480        self.expander.set_label_widget(self.label_log_box) 
    475         self.expander.connect('notify::expanded', self.expandlogger) 
     481        self.expander.connect('notify::expanded', self.expand_logger) 
    476482 
    477483        self.vbox.pack_start(self.hbox_status, False, False, 4) 
     
    542548        self.entry_preferences_pass = gtk.Entry() 
    543549        self.entry_preferences_pass.set_width_chars(11) 
     550 
     551        char = u'\u25cf' 
    544552        if self.itaka_globals.system == 'nt': 
    545553            char = '*' 
    546         else: 
    547             char = u'\u25cf' 
    548554 
    549555        self.entry_preferences_pass.set_invisible_char(char) 
     
    553559        self.check_preferences_auth = gtk.CheckButton() 
    554560        self.check_preferences_auth.connect('toggled', self._preferences_authentication_toggled) 
     561 
    555562        if self.configuration['server']['authentication']: 
    556563            self.check_preferences_auth.set_active(1) 
     
    574581        self.combo_preferences_format.append_text('JPG') 
    575582        self.combo_preferences_format.append_text('PNG') 
     583 
    576584        if self.configuration['screenshot']['format'] == 'jpeg': 
    577585            self.combo_preferences_format.set_active(0) 
     
    596604                self.combo_preferences_screenshot.set_active(0) 
    597605 
    598         self.button_preferences_close = gtk.Button('Close', gtk.STOCK_CLOSE) 
    599         self.button_preferences_close.connect('clicked', lambda wid: self.contractpreferences()) 
     606        self.button_preferences_close = gtk.Button('Close', gtk.STOCK_SAVE) 
     607        self.button_preferences_close.connect('clicked', self.contractpreferences) 
    600608         
    601609        self.button_preferences_about = gtk.Button('About', gtk.STOCK_ABOUT) 
    602         self.button_preferences_about.connect('clicked', lambda wid: self.about()) 
     610        self.button_preferences_about.connect('clicked', self.about) 
    603611 
    604612        self.hbox_preferences_1.pack_start(self.label_preferences_port, False, False, 12) 
     
    614622        self.hbox_preferences_6.pack_start(self.label_preferences_quality, False, False, 12) 
    615623        self.hbox_preferences_6.pack_end(self.spin_preferences_quality, False, False, 7) 
     624 
    616625        if not self.itaka_globals.system == 'nt': 
    617626            self.hbox_preferences_7.pack_start(self.label_preferences_screenshot, False, False, 12) 
    618627            self.hbox_preferences_7.pack_end(self.combo_preferences_screenshot, False, False, 7) 
     628 
    619629        self.hbox_preferences_8.pack_start(self.label_preferences_scale, False, False, 12) 
    620630        self.hbox_preferences_8.pack_end(self.spin_preferences_scale, False, False, 7) 
     631 
    621632        if self.itaka_globals.notify_available:  
    622633            self.hbox_preferences_9.pack_start(self.label_preferences_notifications, False, False, 12) 
    623634            self.hbox_preferences_9.pack_end(self.check_preferences_notifications, False, False, 7) 
     635 
    624636        self.hbox_preferences_10.pack_start(self.button_preferences_about, False, False, 7) 
    625637        self.hbox_preferences_10.pack_end(self.button_preferences_close, False, False, 7) 
     
    631643        self.vbox_preferences_items.pack_start(self.hbox_preferences_5, False, False, 0) 
    632644        self.vbox_preferences_items.pack_start(self.hbox_preferences_6, False, False, 0) 
     645 
    633646        if not self.itaka_globals.system == 'nt': 
    634647            self.vbox_preferences_items.pack_start(self.hbox_preferences_7, False, False, 0) 
     648 
    635649        self.vbox_preferences_items.pack_start(self.hbox_preferences_8, False, False, 0) 
     650 
    636651        if self.itaka_globals.notify_available:  
    637652            self.vbox_preferences_items.pack_start(self.hbox_preferences_9, False, False, 0) 
     
    647662        self.window.initial_size = self.window.get_size() 
    648663 
    649     def save_preferences(self): 
     664    def _save_preferences(self): 
    650665        """ 
    651666        Saves and hides the preferences dialog 
     
    657672        # Switch to the proper values 
    658673        self.format_value = str(self.combo_preferences_format.get_active_text()) 
     674 
    659675        if self.format_value == 'PNG': 
    660676            self.format_value = 'png' 
     
    666682        if self.itaka_globals.notify_available: 
    667683            self.notify_value = self.check_preferences_notifications.get_active() 
     684 
    668685            if self.notify_value: 
    669686                self.notify_value = True 
     
    690707 
    691708        self.scale_value = [self.spin_preferences_scale.get_value_as_int()] 
     709 
    692710        if self.scale_value[0] == 100: 
    693711            self.configuration['screenshot']['scale'] = False 
     
    749767                    [self.config_instance.update(section, key, value) for key, value in self.configurationdict[section].iteritems() if key not in self.current_configuration[section] or self.current_configuration[section][key] != value] 
    750768            except: 
    751                 self.log.failure(('Gui', 'save_preferences'), _('Could not save preferences'), 'ERROR') 
    752  
    753     def expandpreferences(self, *args): 
     769                self.log.failure(('Gui', '_save_preferences'), _('Could not save preferences'), 'ERROR') 
     770 
     771    def expand_preferences(self, *args): 
    754772        """ 
    755773        Expands the window for preferences 
     
    770788                _expander_size is set by our GtkWindow resize callback 
    771789                but we also set a expander_size_finalized variable here 
    772                 so that __windowsizechanged doesnt set the new expanded_size over  
     790                so that _window_size_changed doesnt set the new expanded_size over  
    773791                again as our window is expanding here.""" 
    774792                 
     
    804822                    return False 
    805823            else: 
    806                 self.timeout_expand = gobject.timeout_add(30, self.expandpreferences) 
     824                self.timeout_expand = gobject.timeout_add(30, self.expand_preferences) 
    807825 
    808826    def contractpreferences(self, *args): 
     
    835853                 
    836854                # Save our settings  
    837                 self.save_preferences() 
     855                self._save_preferences() 
    838856 
    839857                self.timeout_contract = None 
     
    842860            self.timeout_contract = gobject.timeout_add(30, self.contractpreferences) 
    843861 
    844     def windowsizechanged(self, widget=None, data=None): 
     862    def _window_size_changed(self, widget=None, data=None): 
    845863        """ 
    846864        Report the window size on change 
     
    868886         
    869887        @type widget: instance 
    870         @param widget: gtk.Widget 
     888        @SAVE widget: gtk.Widget 
    871889 
    872890        @type button: int 
    873         @param button: The button pressed. 
     891        @SAVE button: The button pressed. 
    874892 
    875893        @type time: unknown 
     
    884902                menu.show_all() 
    885903                menu.popup(None, None, None, 3, time) 
    886             pass 
    887904 
    888905    def status_icon_timeout_blink(self, time=3000): 
     
    932949    def about(self, *args): 
    933950        """ 
    934         Creates the About dialog 
     951        Creates the about dialog 
    935952        """ 
    936953 
     
    941958        self.about_dialog.set_copyright(u'© 2003-2007 Marc E.') 
    942959        self.about_dialog.set_comments('Screenshooting de mercado.') 
    943         self.about_dialog.set_authors(['Marc E. <santusmarc@users.sourceforge.net>', _('Kurt Erickson <psychogenicshk@users.sourceforge.net> (Packaging)')]) 
     960        self.about_dialog.set_authors(['Marc E. <santusmarc@users.sourceforge.net>', 'Kurt Erickson <psychogenicshk@users.sourceforge.net>']) 
    944961        self.about_dialog.set_artists(['Marc E. <santusmarc@users.sourceforge.net>', 'Tango Project (http://tango.freedesktop.org)']) 
    945962        self.about_dialog.set_license('''Itaka is free software; you can redistribute it and/or modify 
     
    957974Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA''') 
    958975        self.about_dialog.set_website('http://itaka.jardinpresente.com.ar') 
     976        self.about_dialog.set_website_label('Itaka website') 
     977        gtk.about_dialog_set_url_hook(None) 
    959978        self.about_dialog.set_logo(gtk.gdk.pixbuf_new_from_file(os.path.join(self.itaka_globals.image_dir, "itaka64x64.png"))) 
    960979        self.about_dialog.set_icon(self.icon_pixbuf) 
     
    962981        self.about_dialog.destroy() 
    963982 
    964     def expandlogger(self, expander, params): 
     983    def expand_logger(self, expander, params): 
    965984        """ 
    966985        Expand or contract the logger 
     
    9831002        return 
    9841003 
    985     def clearlogger(self, *args): 
     1004    def clear_logger(self, *args): 
    9861005        """ 
    9871006        Clear the log 
     
    11081127        @param widget: gtk.Widget 
    11091128        """ 
     1129 
    11101130        if self.check_widget(widget): 
    11111131            self.start_server() 
     
    12261246        gtk.main_quit() 
    12271247 
    1228     def literal_time_difference(self, dtime): 
     1248    def _literal_time_difference(self, dtime): 
    12291249        """ 
    12301250        Calculates the time difference from the last server request to  
     
    12991319        @type time: datetime.datetime 
    13001320        @param time: Time of the request 
    1301          
    1302         """ 
    1303  
    1304         self.counter = counter 
    1305         self.ip = ip 
    1306         self.time = time 
    1307  
    1308         self.log.verbose_message(_('Screenshot served to %s') % self.ip, _('Screenshot number %d served to %s') % (self.counter, self.ip), ['pixbuf', gtk.gdk.pixbuf_new_from_file(os.path.join(self.itaka_globals.image_dir, "itaka16x16-take.png"))]) 
    1309  
    1310         self.label_served.set_text(_('<b>Served</b>: %d') % (self.counter)) 
     1321        """ 
     1322 
     1323        self.log.verbose_message(_('Screenshot served to %s') % ip, _('Screenshot number %d served to %s') % (counter, self.ip), ['pixbuf', gtk.gdk.pixbuf_new_from_file(os.path.join(self.itaka_globals.image_dir, "itaka16x16-take.png"))]) 
     1324 
     1325        self.label_served.set_text(_('<b>Served</b>: %d') % (counter)) 
    13111326        self.label_served.set_use_markup(True) 
    1312         self.label_last_ip.set_text(_('<b>Client</b>: %s') % (self.ip)) 
     1327        self.label_last_ip.set_text(_('<b>Client</b>: %s') % (ip)) 
    13131328        self.label_last_ip.set_use_markup(True) 
    1314         self.status_icon.set_tooltip(_('Itaka - %s served') % (self.plural(self.counter, _('screenshot')))) 
     1329        self.status_icon.set_tooltip(_('Itaka - %s served') % (self.plural(counter, _('screenshot')))) 
    13151330 
    13161331        # Show the camera image on tray and interface for 1.5 seconds 
     
    13191334        else: 
    13201335            self.itaka_logo.set_from_file(os.path.join(self.itaka_globals.image_dir, 'itaka-take.png')) 
     1336 
    13211337        self.status_icon.set_from_file(os.path.join(self.itaka_globals.image_dir, 'itaka-take.png')) 
    13221338        gobject.timeout_add(1500, self.set_standard_images) 
    13231339 
    1324         # Call the update timer function, and add a timer to update the GUI of its 
    1325         # "Last screenshot taken" time 
    1326         self.literal_time_difference(time) 
     1340        # Add a timer to update the interface 
     1341        self._literal_time_difference(time) 
     1342 
    13271343        if hasattr(self, 'iagotimer'):  
    13281344            gobject.source_remove(self.iagotimer) 
    1329         self.iagotimer = gobject.timeout_add(60000, self.literal_time_difference, time) 
     1345 
     1346        self.iagotimer = gobject.timeout_add(60000, self._literal_time_difference, time) 
Note: See TracChangeset for help on using the changeset viewer.