- Timestamp:
- 07/15/07 16:17:47 (5 years ago)
- Location:
- trunk
- Files:
-
- 15 edited
-
. (modified) (1 prop)
-
ChangeLog (modified) (1 diff)
-
config.py (modified) (10 diffs)
-
console.py (modified) (4 diffs)
-
debian (modified) (1 prop)
-
itaka.py (modified) (5 diffs)
-
locale (modified) (1 prop)
-
locale/es (modified) (1 prop)
-
locale/es/LC_MESSAGES (modified) (1 prop)
-
locale/es/LC_MESSAGES/itaka.po (modified) (1 diff)
-
screenshot.py (modified) (8 diffs)
-
server.py (modified) (9 diffs)
-
share (modified) (1 prop)
-
share/images (modified) (1 prop)
-
uigtk.py (modified) (49 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:ignore
-
old new 1 1 *.pyc 2 *.pyw 2 3 .project 3 4 .~
-
- Property svn:ignore
-
trunk/ChangeLog
r237 r241 1 1.0: 1 1.0 (Say no more): 2 * Added interface translations #4 3 * Switch to GPLv3 2 4 * Added RPM packages 3 * Added interface translations #44 5 * Simplified and improved Makefile 5 * Switch to GPLv3.6 * Cleaning of the code to try to be at least more compatible with PEP-8. 6 7 7 8 0.2 (I've been watching you...): -
trunk/config.py
r236 r241 21 21 # $Id$ 22 22 23 """ Itaka configuration parser and engine """ 24 25 # It works by the core initiating the main instance, and the 26 # modules accessing the global values variables set up by the initation. 27 28 import ConfigParser, os, sys, shutil, traceback 29 30 # Set up instance 31 config = ConfigParser.ConfigParser() 32 33 #: Configuration file 34 local_config = os.path.join(os.path.dirname(os.path.abspath(sys.argv[0])), "itaka.conf") 35 36 #: Version 37 version = '1.0' 38 #: SVN Revision 39 revision = '$Rev$' 40 41 #: System 23 """ Itaka configuration engine """ 24 25 __version__ = '1.0' 26 __revision__ = '$Rev$' 27 28 import os 29 import sys 30 import ConfigParser 31 import shutil 32 import traceback 33 34 #: Availability of libnotify 35 notify_available = False 36 37 try: 38 import pynotify 39 notify_available = True 40 41 if not pynotify.init('Itaka'): 42 print_warning(_('Pynotify module is failing, disabling notifications')) 43 notify_available = False 44 except ImportError: 45 print_warning(_('Pynotify module is missing, disabling notifications')) 46 notify_available = False 47 48 config_instance = ConfigParser.ConfigParser() 49 image_dir = os.path.join(os.path.dirname(os.path.abspath(sys.argv[0])), 'share/images/') 42 50 system = os.name 43 51 44 #: Platform45 platform = None46 if (sys.platform.startswith('darwin')): platform = 'darwin'47 48 #: Images directory49 image_dir = os.path.join(os.path.dirname(os.path.abspath(sys.argv[0])), 'share/images/')50 51 52 #: To be changed on install to specify where the installed files actually are 52 prefix = '/usr/share/itaka/images/'53 if os.path.exists( prefix):53 image_prefix = '/usr/share/itaka/images/' 54 if os.path.exists(image_prefix): 54 55 image_dir = prefix 55 56 56 # See if our images are there before starting57 57 if not os.path.exists(image_dir): 58 58 print_error(_('Could not find images directory %s' % (image_dir))) … … 61 61 #: Save path for screenshots (system-specific specified later on) 62 62 save_path = os.getcwd() 63 64 """ Console output verbosity 65 'normal' is for all normal operation mesages and warnings (not including errors) 66 'debug' is for all messages through self.console.debug 67 'quiet' is to quiet all errors and warnings. (totally quiet is in conjunction 68 with 'normal' = False, which quiets normal messages too) 69 """ 70 console_verbosity = {'normal': False, 'debug': False, 'quiet': False} 71 72 #: Globally acessable configuration values 73 configuration_values = {} 63 74 64 75 if os.environ.get('HOME'): … … 67 78 save_path = os.environ.get('TMP') or os.environ.get('TEMP') 68 79 69 #: Availability of libnotify 70 notifyavailable = False 71 72 if system == 'posix' and platform != 'darwin': 73 try: 74 import pynotify 75 notifyavailable = True 76 77 if not pynotify.init('Itaka'): 78 print_warning(_('Pynotify module is failing, disabling notifications')) 79 notifyavailable = False 80 except ImportError: 81 print_warning(_('Pynotify module is missing, disabling notifications')) 82 notifyavailable = False 83 84 #: Console output setting 85 # 'normal' is for all normal operation mesages and warnings (not including errors) 86 # 'debug' is for all messages through self.console.debug 87 # 'quiet' is to quiet all errors and warnings. (totally quiet is in conjunction with 'normal') 88 output = {'normal': False, 'debug': False, 'quiet': False} 89 90 #: User's configuration values 91 values = {} 92 93 #: Default HTML header. 80 #: Default HTML headers and footers for the server. 94 81 # Putting <meta http-equiv="Refresh" content="5; url=http://localhost:8000"> is very useful for debugging 95 head html = '''<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">82 head_html = '''<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> 96 83 <html> 97 84 <head> … … 103 90 ''' 104 91 105 #: Default HTML footer. 106 footerhtml = ''' 92 footer_html = ''' 107 93 </div> 108 94 </body> … … 116 102 def __init__(self, arguments=None): 117 103 """ 118 Configuration engine constructor. It also handles whether the L{output} setting is set to print everything to the console 104 Configuration engine constructor. It also handles whether the 105 L{console_verbosity} setting is set to debug. 119 106 120 107 @type arguments: tuple 121 108 @param arguments: A tuple of sys.argv 122 109 """ 110 123 111 if arguments is not None and len(arguments) > 1 and arguments[-1] == '-debug': 124 global output125 output= {'normal': True, 'debug': True, 'quiet': False}112 global console_verbosity 113 console_verbosity = {'normal': True, 'debug': True, 'quiet': False} 126 114 print_m(_('Initializing in debug mode')) 127 115 128 116 #: Default configuration sections and values 129 self.defaultoptions = ( 130 {'server': (('port', 8000), ('authentication', False), ('username', 'user'), ('password', 'password'), ('notify', notifyavailable))}, 131 {'screenshot': (('format', 'jpeg'), ('quality', 30), ('path', save_path), ('currentwindow', False), ('scale', False), ('scalepercent', 100))}, 132 {'html': (('html', '<img src="screenshot" alt="If you are seeing this message it means there was an error in Itaka or you are using a text-only browser.">'), ('authfailure', '<p><strong>Sorry, but you cannot access this resource without authorization.</strong></p>'))} 133 ) 117 self.default_options = ( 118 {'server': ( 119 ('port', 8000), ('authentication', False), 120 ('username', 'user'), ('password', 'password'), 121 ('notify', notify_available) 122 )}, 123 124 {'screenshot': ( 125 ('format', 'jpeg'), ('quality', 30), ('path', save_path), 126 ('currentwindow', False), ('scale', False), 127 ('scalepercent', 100) 128 )}, 129 130 {'html': ( 131 ('html', '<img src="screenshot" alt="If you are seeing this message it means there was an error in Itaka or you are using a text-only browser.">'), 132 ('authfailure', '<p><strong>Sorry, but you cannot access this resource without authorization.</strong></p>') 133 )} 134 ) 134 135 135 136 def load(self): … … 141 142 """ 142 143 143 self.configfile = None 144 self.config_file = os.path.join(os.path.dirname(os.path.abspath(sys.argv[0])), "itaka.conf") 145 146 global configuration_values 147 configuration_values = {} 144 148 145 149 # Check routine … … 148 152 self.create(os.path.join(os.environ['HOME'], '.itaka/itaka.conf')) 149 153 else: 150 self.config file = os.path.join(os.environ['HOME'], '.itaka/itaka.conf')154 self.config_file = os.path.join(os.environ['HOME'], '.itaka/itaka.conf') 151 155 elif (system == 'nt'): 152 156 if not (os.path.exists(os.path.join(os.environ['APPDATA'], 'itaka/itaka.ini'))): 153 157 self.create(os.path.join(os.environ['APPDATA'], 'itaka/itaka.ini')) 154 158 else: 155 self.config file = os.path.join(os.environ['APPDATA'], 'itaka/itaka.ini')159 self.config_file = os.path.join(os.environ['APPDATA'], 'itaka/itaka.ini') 156 160 else: 157 # Generic system/paths (using local) 158 if (os.path.exists(local_config)): 159 self.configfile = local_config 160 else: 161 self.create(local_config) 161 # Generic path 162 if not os.path.exists(self.config_file): 163 self.create(self.config_file) 164 162 165 # Read and assign values from the configuration file 163 166 try: 164 config .read(self.configfile)165 if output['normal']:166 print_m(_('Loaded configuration %s' % (self.config file)))167 config_instance.read(self.config_file) 168 if console_verbosity['normal']: 169 print_m(_('Loaded configuration %s' % (self.config_file))) 167 170 168 171 except: 169 if output['normal']: print_error(_('Could not read configuration file (%s)' % (self.configfile))) 170 if output['debug']: traceback.print_exc() 171 172 """ Retrieve values and return them as a dict """ 173 global values 174 values = {} 172 if console_verbosity['normal']: print_error(_('Could not read configuration file (%s)' % (self.config_file))) 173 if console_verbosity['debug']: traceback.print_exc() 174 175 175 # Get values as a dict and return it 176 for section in config .sections():177 values[section] = dict(config.items(section))176 for section in config_instance.sections(): 177 configuration_values[section] = dict(config_instance.items(section)) 178 178 # Convert 'False' and 'True' into booleans, and numbers into ints 179 179 # Add config options that are not there 180 for option, value in values[section].iteritems():180 for option, value in configuration_values[section].iteritems(): 181 181 if value.strip() == 'True': 182 values[section][option] = True182 configuration_values[section][option] = True 183 183 elif value.strip() == 'False': 184 values[section][option] = False184 configuration_values[section][option] = False 185 185 elif value.isdigit(): 186 values[section][option] = int(value)186 configuration_values[section][option] = int(value) 187 187 188 188 # Compare it to our default configuration set, to see if there is anything missing … … 191 191 # dont have to reload 192 192 brokenwarning = False 193 for configdict in self.default options:193 for configdict in self.default_options: 194 194 for section in configdict: 195 if not values.has_key(section):196 if not output['quiet'] and not brokenwarning:195 if not configuration_values.has_key(section): 196 if not console_verbosity['quiet'] and not brokenwarning: 197 197 print_warning(_('Detected old or broken configuration file. Fixing')) 198 198 brokenwarning = True 199 config .add_section(section)200 values[section] = {}199 config_instance.add_section(section) 200 configuration_values[section] = {} 201 201 for keyset in configdict[section]: 202 202 key, val = keyset 203 203 self.update(section, key, val) 204 values[section][key] = val204 configuration_values[section][key] = val 205 205 else: 206 206 # Check if all the key:vals are in the section 207 207 for keyset in configdict[section]: 208 208 key, val = keyset 209 if not values[section].has_key(key):210 if not output['quiet'] and not brokenwarning:209 if not configuration_values[section].has_key(key): 210 if not console_verbosity['quiet'] and not brokenwarning: 211 211 print_warning(_('Detected old or broken configuration file. Fixing')) 212 212 self.update(section, key, val) 213 values[section][key] = val213 configuration_values[section][key] = val 214 214 brokenwarning = True 215 return values215 return configuration_values 216 216 217 217 def save(self, valuesdict): … … 226 226 for section in valuesdict.keys(): 227 227 for key, value in valuesdict[section].items(): 228 config .set(section, key, value)228 config_instance.set(section, key, value) 229 229 230 230 # Save 231 231 try: 232 config .write(open(self.configfile, 'w'))233 if output['normal']: print_m(_('Saving configuration'))232 config_instance.write(open(self.config_file, 'w')) 233 if console_verbosity['normal']: print_m(_('Saving configuration')) 234 234 except: 235 if not output['quiet']: print_error(_('Could not write configuration file %s' % (self.configfile)))236 if output['debug']: traceback.print_exc()235 if not console_verbosity['quiet']: print_error(_('Could not write configuration file %s' % (self.config_file))) 236 if console_verbosity['debug']: traceback.print_exc() 237 237 238 238 def update(self, section, key, value): 239 239 """ 240 240 Update a specific key's value 241 241 242 242 @type section: str 243 243 @param section: String of the section of the key to update … … 247 247 @param value: Value of the key to update 248 248 """ 249 250 config .set(section, key, value)251 252 try: 253 config .write(open(self.configfile, 'w'))254 if output['debug']: print_m(_('Updating configuration key %s to %s' % (key, value)))249 250 config_instance.set(section, key, value) 251 252 try: 253 config_instance.write(open(self.config_file, 'w')) 254 if console_verbosity['debug']: print_m(_('Updating configuration key %s to %s' % (key, value))) 255 255 except: 256 if not output['quiet']: print_error(_('Could not write configuration file %s' % (self.configfile)))257 if output['debug']: traceback.print_exc()256 if not console_verbosity['quiet']: print_error(_('Could not write configuration file %s' % (self.config_file))) 257 if console_verbosity['debug']: traceback.print_exc() 258 258 259 259 def create(self, path): 260 260 """ 261 261 Create a configuration file from default values 262 262 263 263 @type path: str 264 264 @param path: Path to the configuration file 265 265 """ 266 267 if output['normal']: print_m(_('Creating default configuration'))266 267 if console_verbosity['normal']: print_m(_('Creating default configuration')) 268 268 269 269 # Set default sections and options 270 for configdict in self.default options:270 for configdict in self.default_options: 271 271 for section in configdict: 272 config .add_section(section)272 config_instance.add_section(section) 273 273 for keyset in configdict[section]: 274 274 key, val = keyset 275 config.set(section, key, val) 276 277 # Check if the directory exists, if not create it 278 # and write the config file with its variables 275 config_instance.set(section, key, val) 276 279 277 if not (os.path.exists(os.path.dirname(path))): 280 278 shutil.os.mkdir(os.path.dirname(path)) 281 279 282 280 try: 283 config .write(open(path, 'w'))281 config_instance.write(open(path, 'w')) 284 282 except: 285 if not output['quiet']: print_error(_('Could not write configuration file %s' % (path)))286 if output['debug']: traceback.print_exc()287 288 self.config file = path283 if not console_verbosity['quiet']: print_error(_('Could not write configuration file %s' % (path))) 284 if console_verbosity['debug']: traceback.print_exc() 285 286 self.config_file = path -
trunk/console.py
r236 r241 125 125 """ 126 126 127 def __init__(self, itaka globals):127 def __init__(self, itaka_globals): 128 128 """ 129 129 Constructor for console output handler 130 130 131 131 @type itakaglobals: module 132 @param itakaglobals: Configuration module 132 @param itakaglobals: Configuration module globals 133 133 """ 134 134 135 self.itaka globals = itakaglobals136 if self.itaka globals.output['normal']:135 self.itaka_globals = itaka_globals 136 if self.itaka_globals.console_verbosity['normal']: 137 137 BaseMessage(_('Itaka %s starting') % (itakaglobals.version)) 138 138 … … 142 142 """ 143 143 144 if self.itaka globals.output['normal']:144 if self.itaka_globals.console_verbosity['normal']: 145 145 BaseMessage(_('Itaka shutting down')) 146 146 … … 153 153 """ 154 154 155 if self.itaka globals.output['normal']:155 if self.itaka_globals.console_verbosity['normal']: 156 156 BaseMessage(message) 157 157 158 def failure(self, caller, message, failure type='ERROR'):158 def failure(self, caller, message, failure_type='ERROR'): 159 159 """ 160 160 Failure handler abstract … … 166 166 @param message: Message to print to the console 167 167 168 @type failure type: str169 @param failure type: What kind of failure it is, either 'ERROR' (default), 'WARNING' or 'DEBUG'168 @type failure_type: str 169 @param failure_type: What kind of failure it is, either 'ERROR' (default), 'WARNING' or 'DEBUG' 170 170 """ 171 171 172 if failure type == 'ERROR':173 if not self.itaka globals.output['quiet']:174 BaseFailureMessage(self.itaka globals.output['quiet'], caller, message, failuretype)172 if failure_type == 'ERROR': 173 if not self.itaka_globals.console_verbosity['quiet']: 174 BaseFailureMessage(self.itaka_globals.console_verbosity['quiet'], caller, message, failure_type) 175 175 176 elif failure type == 'WARNING':177 if self.itaka globals.output['normal']:178 BaseFailureMessage(self.itaka globals.output['normal'], caller, message, failuretype)176 elif failure_type == 'WARNING': 177 if self.itaka_globals.console_verbosity['normal']: 178 BaseFailureMessage(self.itaka_globals.console_verbosity['normal'], caller, message, failure_type) 179 179 180 elif failure type == 'DEBUG':181 if self.itaka globals.output['debug']:182 BaseFailureMessage(self.itaka globals.output['debug'], caller, message, failuretype)180 elif failure_type == 'DEBUG': 181 if self.itaka_globals.console_verbosity['debug']: 182 BaseFailureMessage(self.itaka_globals.console_verbosity['debug'], caller, message, failure_type) 183 183 -
trunk/debian
- Property svn:ignore
-
old new 1 1 *.pyc 2 *.pyw 2 3 .project 3 4 .~
-
- Property svn:ignore
-
trunk/itaka.py
r237 r241 23 23 """ Itaka core """ 24 24 25 import sys, os, traceback, gettext, locale, __builtin__ 25 import sys 26 import os 27 import traceback 28 import gettext 29 import locale 30 import __builtin__ 31 26 32 locale.setlocale(locale.LC_ALL, '') 27 33 __builtin__._ = gettext.gettext 28 34 29 # Itaka coremodules35 # Itaka modules 30 36 try: 31 37 import console 32 import config as itaka globals38 import config as itaka_globals 33 39 import uigtk as igui 34 40 except ImportError: … … 36 42 traceback.print_exc() 37 43 sys.exit(1) 38 39 44 40 45 #: Locales directory … … 54 59 gettext.textdomain('itaka') 55 60 56 valid arguments = ('-help', '-debug')61 valid_arguments = ('-help', '-debug') 57 62 arguments = sys.argv 58 63 59 64 # Only one option at a time 60 if len(arguments) > 2 or (len(arguments) == 2 and arguments[-1] not in validarguments or arguments[-1] == validarguments[0]): 65 if len(arguments) > 2 or (len(arguments) == 2 and arguments[-1] \ 66 not in valid_arguments or arguments[-1] == valid_arguments[0]): 61 67 print _('Usage: %s (-debug|-help)') % (arguments[0]) 62 68 sys.exit(1) … … 66 72 try: 67 73 # Initiate our Console and Configuration engines 68 config instance = itakaglobals.ConfigParser(arguments)69 config instance.load()74 config_instance = itaka_globals.ConfigParser(arguments) 75 config_instance.load() 70 76 71 77 try: 72 # Initiate console with a reference to our global configuration values 73 console = console.Console(itakaglobals) 78 # Initiate console with a reference to our global configuration values, 79 # not the user's configuration 80 console_instance = console.Console(itaka_globals) 74 81 except: 75 82 print_error(_('Could not initiate Console engine')) … … 83 90 if __name__ == "__main__": 84 91 try: 85 gui = igui.Gui(console , (itakaglobals, configinstance))92 gui = igui.Gui(console_instance, (itaka_globals, config_instance)) 86 93 gui.main() 87 94 except Exception, e: 88 console .failure(('Itaka', 'core'), _('Could not initiate GUI: %s') % (e), 'ERROR')89 if itaka globals.output['debug']:95 console_instance.failure(('Itaka', 'core'), _('Could not initiate GUI: %s') % (e), 'ERROR') 96 if itaka_globals.console_verbosity['debug']: 90 97 traceback.print_exc() 91 98 sys.exit(1) -
trunk/locale
-
Property
svn:ignore
set to
*.pyc
*.pyw
.project
.~
*.pida
*.bak
.*.swp
.*.swo
.DS_Store
-
Property
svn:ignore
set to
-
trunk/locale/es
-
Property
svn:ignore
set to
*.pyc
*.pyw
.project
.~
*.pida
*.bak
.*.swp
.*.swo
.DS_Store
-
Property
svn:ignore
set to
-
trunk/locale/es/LC_MESSAGES
-
Property
svn:ignore
set to
*.pyc
*.pyw
.project
.~
*.pida
*.bak
.*.swp
.*.swo
.DS_Store
-
Property
svn:ignore
set to
-
trunk/locale/es/LC_MESSAGES/itaka.po
r238 r241 297 297 #: uigtk.py:1008 298 298 msgid "Logging paused" 299 msgstr "Registro det uvido"299 msgstr "Registro detenido" 300 300 301 301 #: uigtk.py:1030 -
trunk/screenshot.py
r236 r241 23 23 """ Itaka screenshot engine """ 24 24 25 import gc, os, gtk, pygtk, error, traceback 25 import gc 26 import os 27 import gtk 28 import pygtk 26 29 pygtk.require("2.0") 30 import error 31 import traceback 27 32 28 33 class Screenshot: … … 31 36 """ 32 37 33 def __init__(self, gui instance, scalingmethod=gtk.gdk.INTERP_BILINEAR):38 def __init__(self, gui_instance, scaling_method=gtk.gdk.INTERP_BILINEAR): 34 39 """ 35 40 Constructor 36 41 37 @type scaling method: gtk.gdk.INTERP_TYPE38 @param scaling method: A type of interpolation for screenshot scaling. U{http://pygtk.org/pygtk2reference/class-gdkpixbuf.html#method-gdkpixbuf--scale-simple}42 @type scaling_method: gtk.gdk.INTERP_TYPE 43 @param scaling_method: A type of interpolation for screenshot scaling. U{http://pygtk.org/pygtk2reference/class-gdkpixbuf.html#method-gdkpixbuf--scale-simple} 39 44 40 @type gui instance: instance41 @param gui instance: An instance of our L{Gui} class45 @type gui_instance: instance 46 @param gui_instance: An instance of our L{Gui} class 42 47 """ 43 48 44 self.gui = gui instance45 self.itaka globals = self.gui.itakaglobals49 self.gui = gui_instance 50 self.itaka_globals = self.gui.itaka_globals 46 51 self.configuration = self.gui.configuration 47 52 self.console = self.gui.console 48 self.scaling method = scalingmethod53 self.scaling_method = scaling_method 49 54 50 55 #: Whether our current window method failed or not 51 self.current windowfailed = False56 self.current_window_failed = False 52 57 53 58 #: Final absolute path to the screenshot file 54 self.shot File = os.path.join(self.configuration['screenshot']['path'], 'itakashot.%s' % (self.configuration['screenshot']['format']))59 self.shot_file = os.path.join(self.configuration['screenshot']['path'], 'itakashot.%s' % (self.configuration['screenshot']['format'])) 55 60 56 self.root screen = gtk.gdk.screen_get_default()57 self.root window = gtk.gdk.get_default_root_window()61 self.root_screen = gtk.gdk.screen_get_default() 62 self.root_window = gtk.gdk.get_default_root_window() 58 63 59 self.screen width = gtk.gdk.screen_width()60 self.screen height = gtk.gdk.screen_height()64 self.screen_width = gtk.gdk.screen_width() 65 self.screen_height = gtk.gdk.screen_height() 61 66 62 67 def find_current_active_window(self): … … 68 73 """ 69 74 70 if self.rootscreen.supports_net_wm_hint("_NET_ACTIVE_WINDOW") and self.rootscreen.supports_net_wm_hint("_NET_WM_WINDOW_TYPE"): 71 self.activewindow = self.rootscreen.get_active_window() 75 if self.root_screen.supports_net_wm_hint("_NET_ACTIVE_WINDOW") and \ 76 self.root_screen.supports_net_wm_hint("_NET_WM_WINDOW_TYPE"): 77 self.active_window = self.root_screen.get_active_window() 72 78 73 79 # Calculate the size of the window including window manager decorations 74 self.relativex, self.relativey, self.winw, self.winh, self.d = self.active window.get_geometry()75 self.window width = self.winw + (self.relativex*2)76 self.window height = self.winh + (self.relativey+self.relativex)80 self.relativex, self.relativey, self.winw, self.winh, self.d = self.active_window.get_geometry() 81 self.window_width = self.winw + (self.relativex*2) 82 self.window_height = self.winh + (self.relativey+self.relativex) 77 83 78 84 # Calculate the position of where the window manager decorations start 79 85 # get_position() will return the position of the window relative to the WM 80 self.window positionx, self.windowpositiony = self.activewindow.get_root_origin()86 self.window_positionx, self.window_positiony = self.active_window.get_root_origin() 81 87 else: 82 self.current windowfailed = True88 self.current_window_failed = True 83 89 raise error.ItakaScreenshotErrorWmHints, _('Window Manager does not support _NET_WM hints') 84 90 85 91 # We do not want to grab the desktop window 86 if self.active window.property_get("_NET_WM_WINDOW_TYPE")[-1][0] == '_NET_WM_WINDOW_TYPE_DESKTOP':87 self.current windowfailed = True92 if self.active_window.property_get("_NET_WM_WINDOW_TYPE")[-1][0] == '_NET_WM_WINDOW_TYPE_DESKTOP': 93 self.current_window_failed = True 88 94 raise error.ItakaScreenshotErrorActiveDesktop, _('Active window is desktop') 89 95 90 return (self.window width, self.windowheight, self.windowpositionx, self.windowpositiony)96 return (self.window_width, self.window_height, self.window_positionx, self.window_positiony) 91 97 92 98 def take_screenshot(self): … … 95 101 96 102 @rtype: str 97 @return: Path to the screenshot (L{self.shot File})103 @return: Path to the screenshot (L{self.shot_file}) 98 104 """ 99 105 … … 102 108 self.configuration = self.gui.configuration 103 109 104 if self.configuration['screenshot']['currentwindow'] and not self.itaka globals.system == 'nt':110 if self.configuration['screenshot']['currentwindow'] and not self.itaka_globals.system == 'nt': 105 111 try: 106 self.current window = self.find_current_active_window()112 self.current_window = self.find_current_active_window() 107 113 except error.ItakaScreenshotErrorWmHints: 108 114 self.gui.log.failure(('Screenshot', 'take_screenshot'), (_('Can not grab the current window'), _('Can not grab the current window because your window manager does not support NET_WM_* hints')), 'WARNING') … … 110 116 self.gui.log.failure(('Screenshot', 'take_screenshot'), (_('Not grabing the desktop as the current window'), _('Your focus was on the destop when a client requested a screenshot, Itaka instead took a screenshot of the whole screen')), 'WARNING') 111 117 112 if not self.current windowfailed:118 if not self.current_window_failed: 113 119 # Make the window size also the screen size for scaling purposes 114 self.active windowwidth = self.currentwindow[0]115 self.active windowheight = self.currentwindow[1]120 self.active_windowwidth = self.current_window[0] 121 self.active_windowheight = self.current_window[1] 116 122 117 123 self.screenshot = gtk.gdk.Pixbuf.get_from_drawable( 118 gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, True, 8, self.active windowwidth, self.activewindowheight),119 self.root window,124 gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, True, 8, self.active_windowwidth, self.active_windowheight), 125 self.root_window, 120 126 gtk.gdk.colormap_get_system(), 121 self.current window[2], self.currentwindow[3], 0, 0, self.activewindowwidth, self.activewindowheight)127 self.current_window[2], self.current_window[3], 0, 0, self.active_windowwidth, self.active_windowheight) 122 128 123 if self.current windowfailed or not self.configuration['screenshot']['currentwindow'] or self.itakaglobals.system == 'nt':129 if self.current_window_failed or not self.configuration['screenshot']['currentwindow'] or self.itaka_globals.system == 'nt': 124 130 self.screenshot = gtk.gdk.Pixbuf.get_from_drawable( 125 gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, True, 8, self.screen width, self.screenheight),126 self.root window,131 gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, True, 8, self.screen_width, self.screen_height), 132 self.root_window, 127 133 gtk.gdk.colormap_get_system(), 128 0, 0, 0, 0, self.screen width, self.screenheight)134 0, 0, 0, 0, self.screen_width, self.screen_height) 129 135 130 136 # GTK manages errors this way 131 137 if not hasattr(self, 'screenshot') or self.screenshot is None: 132 138 # Reset the failure flag 133 self.current windowfailed = False139 self.current_window_failed = False 134 140 self.gui.log.failure(('Screenshot', 'take_screenshot'), (_('Could not grab screenshot'), _('GTK+ could not grab a screenshot of the screen')), 'ERROR') 135 141 raise error.ItakaScreenshotError, _('Could not grab screenshot, GTK+ error') … … 140 146 self.configuration['screenshot']['scalepercent'] = 1 141 147 142 if self.configuration['screenshot']['currentwindow'] and not self.current windowfailed and not self.itakaglobals.system == 'nt':143 self.scale width = self.activewindowwidth * int(self.configuration['screenshot']['scalepercent']) / 100144 self.scale height = self.activewindowheight * int(self.configuration['screenshot']['scalepercent']) / 100148 if self.configuration['screenshot']['currentwindow'] and not self.current_window_failed and not self.itaka_globals.system == 'nt': 149 self.scale_width = self.active_windowwidth * int(self.configuration['screenshot']['scalepercent']) / 100 150 self.scale_height = self.active_windowheight * int(self.configuration['screenshot']['scalepercent']) / 100 145 151 else: 146 self.scale width = self.screenwidth * int(self.configuration['screenshot']['scalepercent']) / 100147 self.scale height = self.screenheight * int(self.configuration['screenshot']['scalepercent']) / 100148 self.screenshot = self.screenshot.scale_simple(self.scale width, self.scaleheight, self.scalingmethod)152 self.scale_width = self.screen_width * int(self.configuration['screenshot']['scalepercent']) / 100 153 self.scale_height = self.screen_height * int(self.configuration['screenshot']['scalepercent']) / 100 154 self.screenshot = self.screenshot.scale_simple(self.scale_width, self.scale_height, self.scaling_method) 149 155 150 156 # Save the screnshot, checking before if to set JPEG quality 151 157 try: 152 158 if self.configuration['screenshot']['format'] == 'jpeg': 153 self.screenshot.save(self.shot File, self.configuration['screenshot']['format'].lower(), {"quality":str(self.configuration['screenshot']['quality'])})159 self.screenshot.save(self.shot_file, self.configuration['screenshot']['format'].lower(), {"quality":str(self.configuration['screenshot']['quality'])}) 154 160 else: 155 self.screenshot.save(self.shot File, self.configuration['screenshot']['format'].lower())161 self.screenshot.save(self.shot_file, self.configuration['screenshot']['format'].lower()) 156 162 except: 157 163 self.gui.log.failure(('Screenshot','take_screenshot'), (_('Could not save screenshot'), _('Could not save screenshot %s') % (traceback.format_exc())), 'ERROR') … … 164 170 165 171 # Reset the failure flag 166 self.current windowfailed = False172 self.current_window_failed = False 167 173 168 return self.shot File174 return self.shot_file -
trunk/server.py
r236 r241 23 23 """ Itaka server engine """ 24 24 25 import datetime, os, traceback, sys 25 import datetime 26 import os 27 import traceback 28 import sys 26 29 27 30 try: … … 174 177 """ 175 178 176 def __init__(self, gui instance):179 def __init__(self, gui_instance): 177 180 """ 178 181 Constructor. Overrides BaseHTTPServer's __init__ to create our resources on-the-fly 179 182 180 @type gui instance: instance181 @param gui instance: An instance of our L{Gui} class182 """ 183 184 self.gui = gui instance185 self.itaka globals = self.gui.itakaglobals183 @type gui_instance: instance 184 @param gui_instance: An instance of our L{Gui} class 185 """ 186 187 self.gui = gui_instance 188 self.itaka_globals = self.gui.itaka_globals 186 189 self.configuration = self.gui.configuration 187 190 self.console = self.gui.console … … 191 194 # Here we use our own static.Data special child resource because we need Authentication handling 192 195 # Otherwise we would just use our own self.add_static_resource 193 self.root = RootResource(self.gui, self.itaka globals.headhtml + self.configuration['html']['html'] + self.itakaglobals.footerhtml)196 self.root = RootResource(self.gui, self.itaka_globals.head_html + self.configuration['html']['html'] + self.itaka_globals.footer_html) 194 197 self.add_child_to_resource('root', '', self.root) 195 198 self.add_child_to_resource('root', 'screenshot', ScreenshotResource(self.gui)) … … 203 206 """ 204 207 205 def __init__(self, gui instance, data, type='text/html; charset=UTF-8'):208 def __init__(self, gui_instance, data, type='text/html; charset=UTF-8'): 206 209 207 210 """ 208 211 Constructor that inherits code from resource.Resource->static.Data 209 212 210 @type gui instance: instance211 @param gui instance: An instance of our L{Gui} class213 @type gui_instance: instance 214 @param gui_instance: An instance of our L{Gui} class 212 215 213 216 @type html: string … … 218 221 """ 219 222 220 self.gui = gui instance223 self.gui = gui_instance 221 224 self.console = self.gui.console 222 self.itaka globals = self.gui.itakaglobals225 self.itaka_globals = self.gui.itaka_globals 223 226 self.configuration = self.gui.configuration 224 227 … … 228 231 self.type = type 229 232 230 self.noauth = self.itaka globals.headhtml + self.configuration['html']['authfailure'] + self.itakaglobals.footerhtml233 self.noauth = self.itaka_globals.head_html + self.configuration['html']['authfailure'] + self.itaka_globals.footer_html 231 234 232 235 def _promptAuth(self): … … 288 291 """ 289 292 290 def __init__(self, gui instance):293 def __init__(self, gui_instance): 291 294 """ 292 295 Constructor 293 296 294 @type gui instance: instance295 @param gui instance: An instance of our L{Gui} class296 """ 297 298 self.gui = gui instance297 @type gui_instance: instance 298 @param gui_instance: An instance of our L{Gui} class 299 """ 300 301 self.gui = gui_instance 299 302 self.console = self.gui.console 300 self.itaka globals = self.gui.itakaglobals303 self.itaka_globals = self.gui.itaka_globals 301 304 self.screenshot = screenshot.Screenshot(self.gui) 302 305 … … 324 327 if (self.request.uri == "/screenshot"): 325 328 try: 326 self.shot File = self.screenshot.take_screenshot()329 self.shot_file = self.screenshot.take_screenshot() 327 330 except error.ItakaScreenshotError: 328 331 return 329 332 330 333 self.request.setHeader('Content-Type', "image/" + self.configuration['screenshot']['format']) 331 self.request.setHeader('Content-Length', str(len(self.shot File)))334 self.request.setHeader('Content-Length', str(len(self.shot_file))) 332 335 self.request.setHeader('Connection', 'close') 333 336 334 337 self.counter += 1 335 338 336 if self.configuration['server']['notify'] and self.itaka globals.notifyavailable:339 if self.configuration['server']['notify'] and self.itaka_globals.notify_available: 337 340 import pynotify 338 uri = "file://" + (os.path.join(self.itaka globals.image_dir, "itaka-take.png"))341 uri = "file://" + (os.path.join(self.itaka_globals.image_dir, "itaka-take.png")) 339 342 340 343 n = pynotify.Notification(_('Screenshot taken'), _('%s requested screenshot' % (self.ip)), uri) … … 345 348 self.gui.update_gui(self.counter, self.ip, self.time) 346 349 347 return open(self.shot File, 'rb').read()350 return open(self.shot_file, 'rb').read() -
trunk/share
- Property svn:ignore
-
old new 1 1 *.pyc 2 *.pyw 2 3 .project 3 4 .~
-
- Property svn:ignore
-
trunk/share/images
- Property svn:ignore
-
old new 1 1 *.pyc 2 *.pyw 2 3 .project 3 4 .~
-
- Property svn:ignore
-
trunk/uigtk.py
r238 r241 23 23 """ Itaka GTK+ GUI """ 24 24 25 import sys, os, datetime, traceback, copy 25 import sys 26 import os 27 import datetime 28 import traceback 29 import copy 26 30 27 31 try: … … 66 70 """ 67 71 68 def __init__(self, gui instance, console, configuration):72 def __init__(self, gui_instance, console, configuration): 69 73 """ 70 74 Constructor 71 75 72 @type gui instance: instance73 @param gui instance: Instance of L{Gui}76 @type gui_instance: instance 77 @param gui_instance: Instance of L{Gui} 74 78 75 79 @type console: instance … … 80 84 """ 81 85 82 self.gui = gui instance86 self.gui = gui_instance 83 87 self.console = console 84 88 self.configuration = configuration … … 115 119 self._write_gui_log(message, None, icon, False) 116 120 117 def detailed_message(self, message, detailed message, icon=None):121 def detailed_message(self, message, detailed_message, icon=None): 118 122 """ 119 123 Write detailed message on Gui log widgets … … 122 126 @param message: Message to be inserted in the events log 123 127 124 @type detailed message: str125 @param detailed message: Message to be inserted in the detailed log128 @type detailed_message: str 129 @param detailed_message: Message to be inserted in the detailed log 126 130 127 131 @type icon: tuple … … 129 133 """ 130 134 131 self.console.message(detailed message)132 self._write_gui_log(message, detailed message, icon, False, False)133 134 def failure(self, caller, message, failure type='ERROR'):135 self.console.message(detailed_message) 136 self._write_gui_log(message, detailed_message, icon, False, False) 137 138 def failure(self, caller, message, failure_type='ERROR'): 135 139 """ 136 140 Write failure message on Gui log widgets … … 142 146 @param message: A tuple containing first the simple message to the events log, and then the detailed message for the detailed log 143 147 144 @type failure type: str145 @param failure type: What kind of failure it is, either 'ERROR' (default), 'WARNING' or 'DEBUG'146 """ 147 148 self.simple message = message[0]149 self.detailed message = message[1]150 151 self.console.failure(caller, self.detailed message, failuretype)148 @type failure_type: str 149 @param failure_type: What kind of failure it is, either 'ERROR' (default), 'WARNING' or 'DEBUG' 150 """ 151 152 self.simple_message = message[0] 153 self.detailed_message = message[1] 154 155 self.console.failure(caller, self.detailed_message, failure_type) 152 156 153 157 # ERRORS require some more actions 154 if failure type == 'ERROR':158 if failure_type == 'ERROR': 155 159 # Show the window and its widgets, set the status icon blinking timeout 156 160 if not self.gui.window.get_property("visible"): 157 161 self.gui.window.present() 158 self.gui.status icon_blinktimeout()162 self.gui.status_icon_timeout_blink() 159 163 self.gui.window.move(self.gui.window_position[0], self.gui.window_position[1]) 160 164 … … 165 169 self.gui.stop_server(None, True) 166 170 167 self._write_gui_log(self.simple message, self.detailedmessage, self._get_failure_icon(failuretype), True, True)168 169 def _get_failure_icon(self, failure type):171 self._write_gui_log(self.simple_message, self.detailed_message, self._get_failure_icon(failure_type), True, True) 172 173 def _get_failure_icon(self, failure_type): 170 174 """ 171 175 Return a default stock icon for a failure type 172 176 173 @type failure type: str174 @param failure type: What kind of failure it is, either 'ERROR' (default), 'WARNING' or 'DEBUG'177 @type failure_type: str 178 @param failure_type: What kind of failure it is, either 'ERROR' (default), 'WARNING' or 'DEBUG' 175 179 176 180 @rtype: tuple … … 180 184 icon = ['stock', 'STOCK_DIALOG_ERROR'] 181 185 182 if failure type == "WARNING":186 if failure_type == "WARNING": 183 187 icon = ['stock', 'STOCK_DIALOG_WARNING'] 184 elif failure type == "DEBUG":188 elif failure_type == "DEBUG": 185 189 icon = ['stock', 'STOCK_DIALOG_INFO'] 186 190 187 191 return icon 188 192 189 def _write_gui_log(self, message, detailed message=None, icon=None, unpauselogger=True, failure=False):193 def _write_gui_log(self, message, detailed_message=None, icon=None, unpause_logger=True, failure=False): 190 194 """ 191 195 Private method to write to both Gui logs … … 194 198 @param message: Message to be inserted 195 199 196 @type detailed message: str197 @param detailed message: Optional detailed message if the event log and detailed log messages differ200 @type detailed_message: str 201 @param detailed_message: Optional detailed message if the event log and detailed log messages differ 198 202 199 203 @type icon: tuple 200 204 @param icon: The first argument is a string of either 'stock' or 'pixbuf', and the second is a string of gtk.STOCK_ICON or a gtk.gdk.pixbuf object (without the 'gtk.' prefix) 201 205 202 @type unpause logger: bool203 @param unpause logger: Whether to unpause the GUI Logger206 @type unpause_logger: bool 207 @param unpause_logger: Whether to unpause the GUI Logger 204 208 205 209 @type failure: bool … … 207 211 """ 208 212 209 if detailed message is None:210 detailed message = message213 if detailed_message is None: 214 detailed_message = message 211 215 212 216 # Only write messages when the logging is unpaused. Unless we are told otherwise 213 217 if self.gui.log_paused(): 214 if unpause logger:218 if unpause_logger: 215 219 self.gui.unpause_log(True) 216 220 self._write_events_log(message, icon, failure) 217 self._write_detailed_log(detailed message)221 self._write_detailed_log(detailed_message) 218 222 else: 219 223 self._write_events_log(message, icon, failure) 220 self._write_detailed_log(detailed message)224 self._write_detailed_log(detailed_message) 221 225 222 226 def _write_events_log(self, message, icon=None, failure=False): … … 236 240 if icon is not None: 237 241 if icon[0] == "stock": 238 self.inserted_iter = self.gui.log eventsstore.append([self.gui.logeventstreeview.render_icon(stock_id=getattr(gtk, icon[1]), size=gtk.ICON_SIZE_MENU, detail=None), message])242 self.inserted_iter = self.gui.log_events_store.append([self.gui.log_events_tree_view.render_icon(stock_id=getattr(gtk, icon[1]), size=gtk.ICON_SIZE_MENU, detail=None), message]) 239 243 # Select the iter if it's a failure 240 244 if failure: 241 self.selection = self.gui.log eventstreeview.get_selection()245 self.selection = self.gui.log_events_tree_view.get_selection() 242 246 self.selection.select_iter(self.inserted_iter) 243 247 else: 244 self.inserted_iter = self.gui.log eventsstore.append([icon[1], message])245 else: 246 self.inserted_iter = self.gui.log eventsstore.append([icon, message])248 self.inserted_iter = self.gui.log_events_store.append([icon[1], message]) 249 else: 250 self.inserted_iter = self.gui.log_events_store.append([icon, message]) 247 251 248 252 # Scroll 249 self.gui.log eventstreeview.scroll_to_cell(self.gui.logeventstreeview.get_model().get_path(self.inserted_iter))253 self.gui.log_events_tree_view.scroll_to_cell(self.gui.log_events_tree_view.get_model().get_path(self.inserted_iter)) 250 254 251 255 def _write_detailed_log(self, message, bold=True): … … 263 267 264 268 if bold: 265 self.gui.log detailsbuffer.insert_with_tags_by_name(self.gui.logdetailsbuffer.get_end_iter(), message, 'bold-text')266 else: 267 self.gui.log detailsbuffer.insert_at_cursor(message, len(message))269 self.gui.log_details_buffer.insert_with_tags_by_name(self.gui.log_details_buffer.get_end_iter(), message, 'bold-text') 270 else: 271 self.gui.log_details_buffer.insert_at_cursor(message, len(message)) 268 272 269 273 # Automatically scroll. Use wrap until fix 270 self.gui.logdetailstextview.scroll_mark_onscreen(self.gui.logdetailsbuffer.get_insert()) 274 self.gui.log_details_text_view.scroll_mark_onscreen(self.gui.log_details_buffer.get_insert()) 275 271 276 272 277 class Gui: … … 275 280 """ 276 281 277 def __init__(self, console instance, configuration):282 def __init__(self, console_instance, configuration): 278 283 """ 279 284 Constructor 280 285 281 @type console instance: instance282 @param console instance: An instance of the L{Console} class286 @type console_instance: instance 287 @param console_instance: An instance of the L{Console} class 283 288 284 289 @type configuration: tuple … … 287 292 288 293 # Load our configuration and console instances and values 289 self.console = console instance290 self.itaka globals = configuration[0]294 self.console = console_instance 295 self.itaka_globals = configuration[0] 291 296 292 297 # The configuration instance has the user's preferences already loaded 293 self.config instance = configuration[1]294 self.configuration = self.itaka globals.values298 self.config_instance = configuration[1] 299 self.configuration = self.itaka_globals.configuration_values 295 300 296 301 # Instances of our Gui Logging class and Screenshot Server 297 302 self.server = iserver.ScreenshotServer(self) 298 303 self.log = GuiLog(self, self.console, self.configuration) 299 self.log paused = False304 self.log_is_paused = False 300 305 301 306 # Start defining widgets 302 self.icon_pixbuf = gtk.gdk.pixbuf_new_from_file(os.path.join(self.itaka globals.image_dir, 'itaka.png'))307 self.icon_pixbuf = gtk.gdk.pixbuf_new_from_file(os.path.join(self.itaka_globals.image_dir, 'itaka.png')) 303 308 self.window = gtk.Window(gtk.WINDOW_TOPLEVEL) 304 309 self.window.connect('destroy', self.destroy) … … 312 317 313 318 # Create our tray icon 314 self.status Icon = gtk.StatusIcon()315 self.status menu = gtk.Menu()319 self.status_icon = gtk.StatusIcon() 320 self.status_menu = gtk.Menu() 316 321 if self.configuration['server']['authentication']: 317 self.status Icon.set_from_pixbuf(gtk.gdk.pixbuf_new_from_file(os.path.join(self.itakaglobals.image_dir, 'itaka-secure.png')))318 else: 319 self.status Icon.set_from_pixbuf(self.icon_pixbuf)320 self.status Icon.set_tooltip('Itaka')321 self.status Icon.set_visible(True)322 self.status Icon.connect('activate', self.statusicon_activate)323 self.status Icon.connect('popup-menu', self.statusicon_menu, self.statusmenu)324 325 self.start image = gtk.Image()326 self.start image.set_from_stock(gtk.STOCK_EXECUTE, gtk.ICON_SIZE_MENU)327 328 self.stop image = gtk.Image()329 self.stop image.set_from_stock(gtk.STOCK_STOP, gtk.ICON_SIZE_MENU)330 self.menu itemstart = gtk.ImageMenuItem(_('St_art'))331 self.menu itemstart.set_image(self.startimage)332 self.menu itemstart.connect('activate', self.start_server, True)333 self.menu itemstop = gtk.ImageMenuItem(_('St_op'))334 self.menu itemstop.set_image(self.stopimage)335 self.menu itemstop.connect('activate', self.stop_server, True)336 self.menu itemstop.set_sensitive(False)337 338 if self.itaka globals.notifyavailable:339 self.menu itemnotifications = gtk.CheckMenuItem(_('Show _Notifications'))322 self.status_icon.set_from_pixbuf(gtk.gdk.pixbuf_new_from_file(os.path.join(self.itaka_globals.image_dir, 'itaka-secure.png'))) 323 else: 324 self.status_icon.set_from_pixbuf(self.icon_pixbuf) 325 self.status_icon.set_tooltip('Itaka') 326 self.status_icon.set_visible(True) 327 self.status_icon.connect('activate', self.status_icon_activate) 328 self.status_icon.connect('popup-menu', self.status_icon_menu, self.status_menu) 329 330 self.start_image = gtk.Image() 331 self.start_image.set_from_stock(gtk.STOCK_EXECUTE, gtk.ICON_SIZE_MENU) 332 333 self.stop_image = gtk.Image() 334 self.stop_image.set_from_stock(gtk.STOCK_STOP, gtk.ICON_SIZE_MENU) 335 self.menu_item_start = gtk.ImageMenuItem(_('St_art')) 336 self.menu_item_start.set_image(self.start_image) 337 self.menu_item_start.connect('activate', self.start_server, True) 338 self.menu_item_stop = gtk.ImageMenuItem(_('St_op')) 339 self.menu_item_stop.set_image(self.stop_image) 340 self.menu_item_stop.connect('activate', self.stop_server, True) 341 self.menu_item_stop.set_sensitive(False) 342 343 if self.itaka_globals.notify_available: 344 self.menu_item_notifications = gtk.CheckMenuItem(_('Show _Notifications')) 340 345 if self.configuration['server']['notify']: 341 self.menu itemnotifications.set_active(True)342 self.menu itemnotifications.connect('toggled', self.statusicon_notify)343 344 self.menu itemseparator = gtk.SeparatorMenuItem()345 self.menu itemseparator1 = gtk.SeparatorMenuItem()346 self.menu itemquit = gtk.ImageMenuItem(gtk.STOCK_QUIT)347 self.menu itemquit.connect('activate', self.destroy)348 349 self.status menu.append(self.menuitemstart)350 self.status menu.append(self.menuitemstop)351 if self.itaka globals.notifyavailable:352 self.status menu.append(self.menuitemseparator)353 self.status menu.append(self.menuitemnotifications)354 self.status menu.append(self.menuitemseparator1)355 self.status menu.append(self.menuitemquit)346 self.menu_item_notifications.set_active(True) 347 self.menu_item_notifications.connect('toggled', self.status_icon_notify) 348 349 self.menu_item_separator = gtk.SeparatorMenuItem() 350 self.menu_item_separator1 = gtk.SeparatorMenuItem() 351 self.menu_item_quit = gtk.ImageMenuItem(gtk.STOCK_QUIT) 352 self.menu_item_quit.connect('activate', self.destroy) 353 354 self.status_menu.append(self.menu_item_start) 355 self.status_menu.append(self.menu_item_stop) 356 if self.itaka_globals.notify_available: 357 self.status_menu.append(self.menu_item_separator) 358 self.status_menu.append(self.menu_item_notifications) 359 self.status_menu.append(self.menu_item_separator1) 360 self.status_menu.append(self.menu_item_quit) 356 361 357 362 self.vbox = gtk.VBox(False, 6) 358 363 self.box = gtk.HBox(False, 0) 359 364 360 self.itaka Logo = gtk.Image()365 self.itaka_logo = gtk.Image() 361 366 if self.configuration['server']['authentication']: 362 self.itaka Logo.set_from_file(os.path.join(self.itakaglobals.image_dir, 'itaka-secure.png'))363 else: 364 self.itaka Logo.set_from_file(os.path.join(self.itakaglobals.image_dir, 'itaka.png'))365 self.itaka Logo.show()366 367 self.box.pack_start(self.itaka Logo, False, False, 35)368 369 self.button Startstop = gtk.ToggleButton(_('Start'), gtk.STOCK_PREFERENCES)370 self.start stopimage = gtk.Image()371 372 self.start stopimage.set_from_stock(gtk.STOCK_EXECUTE, gtk.ICON_SIZE_BUTTON)373 self.button Startstop.set_image(self.startstopimage)374 self.button Startstop.connect('toggled', self.button_start_server)375 376 self. preferencesButton= gtk.Button('Preferences', gtk.STOCK_PREFERENCES)377 self. preferencesButton.connect('clicked', self.expandpreferences)367 self.itaka_logo.set_from_file(os.path.join(self.itaka_globals.image_dir, 'itaka-secure.png')) 368 else: 369 self.itaka_logo.set_from_file(os.path.join(self.itaka_globals.image_dir, 'itaka.png')) 370 self.itaka_logo.show() 371 372 self.box.pack_start(self.itaka_logo, False, False, 35) 373 374 self.button_start_stop = gtk.ToggleButton(_('Start'), gtk.STOCK_PREFERENCES) 375 self.start_stop_image = gtk.Image() 376 377 self.start_stop_image.set_from_stock(gtk.STOCK_EXECUTE, gtk.ICON_SIZE_BUTTON) 378 self.button_start_stop.set_image(self.start_stop_image) 379 self.button_start_stop.connect('toggled', self.button_start_server) 380 381 self.button_preferences = gtk.Button('Preferences', gtk.STOCK_PREFERENCES) 382 self.button_preferences.connect('clicked', self.expandpreferences) 378 383 379 384 # Set up some variables for our timeouts/animations 380 self.preferences hidden = False381 self.preferences expanded = False382 self. contracttimeout = None383 self. expandtimeout= None384 self. blinktimeout= None385 386 self.box.pack_start(self.button Startstop, True, True, 5)387 self.box.pack_start(self. preferencesButton, True, True, 8)385 self.preferences_hidden = False 386 self.preferences_expanded = False 387 self.timeout_contract = None 388 self.timeout_expand = None 389 self.timeout_blink = None 390 391 self.box.pack_start(self.button_start_stop, True, True, 5) 392 self.box.pack_start(self.button_preferences, True, True, 8) 388 393 389 394 self.vbox.pack_start(self.box, False, False, 0) 390 395 391 self. statusBox= gtk.HBox(False, 0)392 self.label Served = gtk.Label()393 self.label Lastip = gtk.Label()394 self.label Time = gtk.Label()395 396 self. statusBox.pack_start(self.labelLastip, True, False, 0)397 self. statusBox.pack_start(self.labelTime, True, False, 0)398 self. statusBox.pack_start(self.labelServed, True, False, 0)396 self.hbox_status = gtk.HBox(False, 0) 397 self.label_served = gtk.Label() 398 self.label_last_ip = gtk.Label() 399 self.label_time = gtk.Label() 400 401 self.hbox_status.pack_start(self.label_last_ip, True, False, 0) 402 self.hbox_status.pack_start(self.label_time, True, False, 0) 403 self.hbox_status.pack_start(self.label_served, True, False, 0) 399 404 400 405 # Logger widget (displayed when expanded) 401 self. logvbox= gtk.VBox(False, 0)402 self. lognotebook= gtk.Notebook()403 self. lognotebook.set_tab_pos(gtk.POS_BOTTOM)404 405 self.l ogeventslabel= gtk.Label(_('Events'))406 self.l ogdetailslabel= gtk.Label(_('Details'))407 408 self. logeventsscroll= gtk.ScrolledWindow()409 self. logeventsscroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)410 self. logeventsscroll.set_shadow_type(gtk.SHADOW_NONE)411 412 self.log eventsstore = gtk.ListStore(gtk.gdk.Pixbuf, str)413 self.log eventstreeview = gtk.TreeView(self.logeventsstore)414 self.log eventstreeview.set_property('headers-visible', False)415 self.log eventstreeview.set_property('rules-hint', True)416 417 self. logeventscolumnicon = gtk.TreeViewColumn()418 self. logeventscolumntext= gtk.TreeViewColumn()419 self.log eventstreeview.append_column(self.logeventscolumnicon)420 self.log eventstreeview.append_column(self.logeventscolumntext)421 422 self. logeventscellpixbuf= gtk.CellRendererPixbuf()423 self. logeventscolumnicon.pack_start(self.logeventscellpixbuf)424 self. logeventscolumnicon.add_attribute(self.logeventscellpixbuf, 'pixbuf', 0)425 426 self. logeventscelltext= gtk.CellRendererText()427 self. logeventscolumntext.pack_start(self.logeventscelltext, True)428 self. logeventscolumntext.add_attribute(self.logeventscelltext, 'text', 1)429 self. logeventsscroll.add(self.logeventstreeview)430 431 self. logdetailsscroll= gtk.ScrolledWindow()432 self. logdetailsscroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)433 self. logdetailsscroll.set_shadow_type(gtk.SHADOW_NONE)434 self.log detailstextview = gtk.TextView()435 self.log detailstextview.set_wrap_mode(gtk.WRAP_WORD)436 self.log detailstextview.set_editable(False)437 self.log detailstextview.set_size_request(-1, 160)438 self.log detailsbuffer = self.logdetailstextview.get_buffer()439 self.log detailsbuffer.create_tag ('bold-text', weight = pango.WEIGHT_BOLD)440 self. logdetailsscroll.add(self.logdetailstextview)441 442 self. lognotebook.append_page(self.logeventsscroll, self.logeventslabel)443 self. lognotebook.append_page(self.logdetailsscroll, self.logdetailslabel)444 445 self. loghbox= gtk.HBox(False, 0)446 self. logclearbutton= gtk.Button(_('Clear'))447 self. logclearbuttonimage = gtk.Image()448 self. logclearbuttonimage.set_from_stock(gtk.STOCK_CLEAR, gtk.ICON_SIZE_BUTTON)449 self. logclearbutton.set_image(self.logclearbuttonimage)450 self. logclearbutton.connect('clicked', self.clearlogger)451 452 self. logpausebutton= gtk.ToggleButton(_('Pause'))453 self. logpausebuttonimage = gtk.Image()454 self. logpausebuttonimage.set_from_stock(gtk.STOCK_MEDIA_PAUSE, gtk.ICON_SIZE_BUTTON)455 self. logpausebutton.set_image(self.logpausebuttonimage)456 self. logpausebutton.connect('toggled', self.button_pause_log)457 458 self. loghbox.pack_end(self.logclearbutton, False, False, 4)459 self. loghbox.pack_end(self.logpausebutton, False, False, 4)460 461 self. logvbox.pack_start(self.lognotebook, False, False, 4)462 self. logvbox.pack_start(self.loghbox, False, False, 4)463 464 self.l ogboxLabel= gtk.Label(_('<b>Server log</b>'))465 self.l ogboxLabel.set_use_markup(True)406 self.vbox_log = gtk.VBox(False, 0) 407 self.notebook_log = gtk.Notebook() 408 self.notebook_log.set_tab_pos(gtk.POS_BOTTOM) 409 410 self.label_log_events = gtk.Label(_('Events')) 411 self.label_log_details = gtk.Label(_('Details')) 412 413 self.scroll_log_events = gtk.ScrolledWindow() 414 self.scroll_log_events.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) 415 self.scroll_log_events.set_shadow_type(gtk.SHADOW_NONE) 416 417 self.log_events_store = gtk.ListStore(gtk.gdk.Pixbuf, str) 418 self.log_events_tree_view = gtk.TreeView(self.log_events_store) 419 self.log_events_tree_view.set_property('headers-visible', False) 420 self.log_events_tree_view.set_property('rules-hint', True) 421 422 self.column_log_events_icon = gtk.TreeViewColumn() 423 self.column_log_events = gtk.TreeViewColumn() 424 self.log_events_tree_view.append_column(self.column_log_events_icon) 425 self.log_events_tree_view.append_column(self.column_log_events) 426 427 self.cell_pixbuf_log_events = gtk.CellRendererPixbuf() 428 self.column_log_events_icon.pack_start(self.cell_pixbuf_log_events) 429 self.column_log_events_icon.add_attribute(self.cell_pixbuf_log_events, 'pixbuf', 0) 430 431 self.cell_text_log_events = gtk.CellRendererText() 432 self.column_log_events.pack_start(self.cell_text_log_events, True) 433 self.column_log_events.add_attribute(self.cell_text_log_events, 'text', 1) 434 self.scroll_log_events.add(self.log_events_tree_view) 435 436 self.scroll_log_details = gtk.ScrolledWindow() 437 self.scroll_log_details.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) 438 self.scroll_log_details.set_shadow_type(gtk.SHADOW_NONE) 439 self.log_details_text_view = gtk.TextView() 440 self.log_details_text_view.set_wrap_mode(gtk.WRAP_WORD) 441 self.log_details_text_view.set_editable(False) 442 self.log_details_text_view.set_size_request(-1, 160) 443 self.log_details_buffer = self.log_details_text_view.get_buffer() 444 self.log_details_buffer.create_tag ('bold-text', weight = pango.WEIGHT_BOLD) 445 self.scroll_log_details.add(self.log_details_text_view) 446 447 self.notebook_log.append_page(self.scroll_log_events, self.label_log_events) 448 self.notebook_log.append_page(self.scroll_log_details, self.label_log_details) 449 450 self.hbox_log = gtk.HBox(False, 0) 451 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) 456 457 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) 461 self.button_log_pause.connect('toggled', self.button_pause_log) 462 463 self.hbox_log.pack_end(self.button_log_clear, False, False, 4) 464 self.hbox_log.pack_end(self.button_log_pause, False, False, 4) 465 466 self.vbox_log.pack_start(self.notebook_log, False, False, 4) 467 self.vbox_log.pack_start(self.hbox_log, False, False, 4) 468 469 self.label_log_box = gtk.Label(_('<b>Server log</b>')) 470 self.label_log_box.set_use_markup(True) 466 471 467 472 self.expander_size_finalized = False 468 473 self.expander = gtk.Expander(None) 469 self.expander.set_label_widget(self.l ogboxLabel)474 self.expander.set_label_widget(self.label_log_box) 470 475 self.expander.connect('notify::expanded', self.expandlogger) 471 476 472 self.vbox.pack_start(self. statusBox, False, False, 4)477 self.vbox.pack_start(self.hbox_status, False, False, 4) 473 478 self.vbox.pack_start(self.expander, False, False, 0) 474 479 self.expander.set_sensitive(False) 475 480 476 481 # This is are the preference widgets that are going to be added and shown later 477 self. preferencesVBox= gtk.VBox(False, 7)478 self. preferencesVBoxitems = gtk.VBox(False, 5)479 self. preferencesVBoxitems.set_border_width(2)482 self.vbox_preferences = gtk.VBox(False, 7) 483 self.vbox_preferences_items = gtk.VBox(False, 5) 484 self.vbox_preferences_items.set_border_width(2) 480 485 481 486 # Create our Hboxes 482 487 for n in xrange(1, 10+1): 483 setattr(self, ' preferencesHBox%d' % (n), gtk.HBox(False, 0))484 485 self. preferencesFramesettings = gtk.Frame()486 self. preferencesSettingslabel= gtk.Label(_('<b>Preferences</b>'))487 self. preferencesSettingslabel.set_use_markup(True)488 self. preferencesFramesettings.set_label_widget(self.preferencesSettingslabel)489 self. preferencesFramesettings.set_label_align(0.5, 0.5)490 491 self. preferencesLabelport = gtk.Label(_('Port'))492 self. preferencesLabelport.set_justify(gtk.JUSTIFY_LEFT)493 self. preferencesLabelport.set_alignment(0, 0.60)494 495 self. preferencesLabelauth = gtk.Label(_('Authentication'))496 self. preferencesLabelauth.set_justify(gtk.JUSTIFY_LEFT)497 self. preferencesLabelauth.set_alignment(0, 0.60)498 499 self. preferencesLabeluser = gtk.Label(_('Username'))500 self. preferencesLabeluser.set_justify(gtk.JUSTIFY_LEFT)501 self. preferencesLabeluser.set_alignment(0, 0.60)502 503 self. preferencesLabelpass = gtk.Label(_('Password'))504 self. preferencesLabelpass.set_justify(gtk.JUSTIFY_LEFT)505 self. preferencesLabelpass.set_alignment(0, 0.60)506 507 self. preferencesLabelformat = gtk.Label(_('Format'))508 self. preferencesLabelformat.set_justify(gtk.JUSTIFY_LEFT)509 self. preferencesLabelformat.set_alignment(0, 0.50)510 511 self. preferencesLabelquality = gtk.Label(_('Quality'))512 self. preferencesLabelquality.set_justify(gtk.JUSTIFY_LEFT)513 self. preferencesLabelquality.set_alignment(0, 0.50)514 515 self. preferencesLabelscale = gtk.Label(_('Scale'))516 self. preferencesLabelscale.set_justify(gtk.JUSTIFY_LEFT)517 self. preferencesLabelscale.set_alignment(0, 0.50)518 519 if not self.itaka globals.system == 'nt':520 self. preferencesLabelscreenshot = gtk.Label(_('Window'))521 self. preferencesLabelscreenshot.set_justify(gtk.JUSTIFY_LEFT)522 self. preferencesLabelscreenshot.set_alignment(0, 0.50)523 524 if self.itaka globals.notifyavailable:525 self. preferencesLabelnotifications = gtk.Label(_('Notifications'))526 self. preferencesLabelnotifications.set_justify(gtk.JUSTIFY_LEFT)527 self. preferencesLabelnotifications.set_alignment(0, 0.50)528 529 self.adjustment port = gtk.Adjustment(float(self.configuration['server']['port']), 1024, 65535, 1, 0, 0)530 self. preferencesSpinport = gtk.SpinButton(self.adjustmentport)531 self. preferencesSpinport.set_numeric(True)532 533 self. preferencesEntryuser = gtk.Entry()534 self. preferencesEntryuser.set_width_chars(11)535 self. preferencesEntryuser.set_text(self.configuration['server']['username'])536 537 self. preferencesEntrypass = gtk.Entry()538 self. preferencesEntrypass.set_width_chars(11)539 if self.itaka globals.system == 'nt':488 setattr(self, 'hbox_preferences_%d' % (n), gtk.HBox(False, 0)) 489 490 self.frame_preference_settings = gtk.Frame() 491 self.label_preferences_settings = gtk.Label(_('<b>Preferences</b>')) 492 self.label_preferences_settings.set_use_markup(True) 493 self.frame_preference_settings.set_label_widget(self.label_preferences_settings) 494 self.frame_preference_settings.set_label_align(0.5, 0.5) 495 496 self.label_preferences_port = gtk.Label(_('Port')) 497 self.label_preferences_port.set_justify(gtk.JUSTIFY_LEFT) 498 self.label_preferences_port.set_alignment(0, 0.60) 499 500 self.label_preferences_auth = gtk.Label(_('Authentication')) 501 self.label_preferences_auth.set_justify(gtk.JUSTIFY_LEFT) 502 self.label_preferences_auth.set_alignment(0, 0.60) 503 504 self.label_preferences_user = gtk.Label(_('Username')) 505 self.label_preferences_user.set_justify(gtk.JUSTIFY_LEFT) 506 self.label_preferences_user.set_alignment(0, 0.60) 507 508 self.label_preferences_pass = gtk.Label(_('Password')) 509 self.label_preferences_pass.set_justify(gtk.JUSTIFY_LEFT) 510 self.label_preferences_pass.set_alignment(0, 0.60) 511 512 self.label_preferences_format = gtk.Label(_('Format')) 513 self.label_preferences_format.set_justify(gtk.JUSTIFY_LEFT) 514 self.label_preferences_format.set_alignment(0, 0.50) 515 516 self.label_preferences_quality = gtk.Label(_('Quality')) 517 self.label_preferences_quality.set_justify(gtk.JUSTIFY_LEFT) 518 self.label_preferences_quality.set_alignment(0, 0.50) 519 520 self.label_preferences_scale = gtk.Label(_('Scale')) 521 self.label_preferences_scale.set_justify(gtk.JUSTIFY_LEFT) 522 self.label_preferences_scale.set_alignment(0, 0.50) 523 524 if not self.itaka_globals.system == 'nt': 525 self.label_preferences_screenshot = gtk.Label(_('Window')) 526 self.label_preferences_screenshot.set_justify(gtk.JUSTIFY_LEFT) 527 self.label_preferences_screenshot.set_alignment(0, 0.50) 528 529 if self.itaka_globals.notify_available: 530 self.label_preferences_notifications = gtk.Label(_('Notifications')) 531 self.label_preferences_notifications.set_justify(gtk.JUSTIFY_LEFT) 532 self.label_preferences_notifications.set_alignment(0, 0.50) 533 534 self.adjustment_preferences_port = gtk.Adjustment(float(self.configuration['server']['port']), 1024, 65535, 1, 0, 0) 535 self.spin_preferences_port = gtk.SpinButton(self.adjustment_preferences_port) 536 self.spin_preferences_port.set_numeric(True) 537 538 self.entry_preferences_user = gtk.Entry() 539 self.entry_preferences_user.set_width_chars(11) 540 self.entry_preferences_user.set_text(self.configuration['server']['username']) 541 542 self.entry_preferences_pass = gtk.Entry() 543 self.entry_preferences_pass.set_width_chars(11) 544 if self.itaka_globals.system == 'nt': 540 545 char = '*' 541 546 else: 542 547 char = u'\u25cf' 543 548 544 self. preferencesEntrypass.set_invisible_char(char)545 self. preferencesEntrypass.set_visibility(False)546 self. preferencesEntrypass.set_text(self.configuration['server']['password'])547 548 self. preferencesCheckauth = gtk.CheckButton()549 self. preferencesCheckauth.connect('toggled', self._preferences_authentication_toggled)549 self.entry_preferences_pass.set_invisible_char(char) 550 self.entry_preferences_pass.set_visibility(False) 551 self.entry_preferences_pass.set_text(self.configuration['server']['password']) 552 553 self.check_preferences_auth = gtk.CheckButton() 554 self.check_preferences_auth.connect('toggled', self._preferences_authentication_toggled) 550 555 if self.configuration['server']['authentication']: 551 self. preferencesCheckauth.set_active(1)556 self.check_preferences_auth.set_active(1) 552 557 else: 553 self. preferencesCheckauth.set_active(0)558 self.check_preferences_auth.set_active(0) 554 559 555 560 if not self.configuration['server']['authentication']: 556 self. preferencesEntryuser.set_sensitive(False)557 self. preferencesEntrypass.set_sensitive(False)558 559 self.adjustment quality = gtk.Adjustment(float(self.configuration['screenshot']['quality']), 0, 100, 1, 0, 0)560 self. preferencesSpinquality = gtk.SpinButton(self.adjustmentquality)561 self. preferencesSpinquality.set_numeric(True)562 563 self.adjustment scale = gtk.Adjustment(float(self.configuration['screenshot']['scalepercent']), 1, 100, 1, 0, 0)564 self. preferencesSpinscale = gtk.SpinButton(self.adjustmentscale)565 self. preferencesSpinscale.set_numeric(True)566 567 self. preferencesComboformat = gtk.combo_box_new_text()568 self. preferencesComboformat.connect('changed', self._preferences_combo_changed)569 self. preferencesComboformat.append_text('JPG')570 self. preferencesComboformat.append_text('PNG')561 self.entry_preferences_user.set_sensitive(False) 562 self.entry_preferences_pass.set_sensitive(False) 563 564 self.adjustment_preferences_quality = gtk.Adjustment(float(self.configuration['screenshot']['quality']), 0, 100, 1, 0, 0) 565 self.spin_preferences_quality = gtk.SpinButton(self.adjustment_preferences_quality) 566 self.spin_preferences_quality.set_numeric(True) 567 568 self.adjustment_preferences_scale = gtk.Adjustment(float(self.configuration['screenshot']['scalepercent']), 1, 100, 1, 0, 0) 569 self.spin_preferences_scale = gtk.SpinButton(self.adjustment_preferences_scale) 570 self.spin_preferences_scale.set_numeric(True) 571 572 self.combo_preferences_format = gtk.combo_box_new_text() 573 self.combo_preferences_format.connect('changed', self._preferences_combo_changed) 574 self.combo_preferences_format.append_text('JPG') 575 self.combo_preferences_format.append_text('PNG') 571 576 if self.configuration['screenshot']['format'] == 'jpeg': 572 self. preferencesComboformat.set_active(0)577 self.combo_preferences_format.set_active(0) 573 578 else: 574 self. preferencesComboformat.set_active(1)575 self. preferencesHBox6.set_sensitive(False)576 577 if self.itaka globals.notifyavailable:578 self. preferencesChecknotifications = gtk.CheckButton()579 self.combo_preferences_format.set_active(1) 580 self.hbox_preferences_6.set_sensitive(False) 581 582 if self.itaka_globals.notify_available: 583 self.check_preferences_notifications = gtk.CheckButton() 579 584 if self.configuration['server']['notify']: 580 self. preferencesChecknotifications.set_active(1)585 self.check_preferences_notifications.set_active(1) 581 586 else: 582 self. preferencesChecknotifications.set_active(0)583 584 if not self.itaka globals.system == 'nt':585 self. preferencesComboscreenshot = gtk.combo_box_new_text()586 self. preferencesComboscreenshot.append_text(_('Fullscreen'))587 self. preferencesComboscreenshot.append_text(_('Active window'))587 self.check_preferences_notifications.set_active(0) 588 589 if not self.itaka_globals.system == 'nt': 590 self.combo_preferences_screenshot = gtk.combo_box_new_text() 591 self.combo_preferences_screenshot.append_text(_('Fullscreen')) 592 self.combo_preferences_screenshot.append_text(_('Active window')) 588 593 if self.configuration['screenshot']['currentwindow']: 589 self. preferencesComboscreenshot.set_active(1)594 self.combo_preferences_screenshot.set_active(1) 590 595 else: 591 self. preferencesComboscreenshot.set_active(0)592 593 self. preferencesButtonClose = gtk.Button('Close', gtk.STOCK_CLOSE)594 self. preferencesButtonClose.connect('clicked', lambda wid: self.contractpreferences())595 596 self. preferencesButtonAbout = gtk.Button('About', gtk.STOCK_ABOUT)597 self. preferencesButtonAbout.connect('clicked', lambda wid: self.about())598 599 self. preferencesHBox1.pack_start(self.preferencesLabelport, False, False, 12)600 self. preferencesHBox1.pack_end(self.preferencesSpinport, False, False, 7)601 self. preferencesHBox2.pack_start(self.preferencesLabelauth, False, False, 12)602 self. preferencesHBox3.pack_start(self.preferencesLabeluser, False, False, 12)603 self. preferencesHBox4.pack_end(self.preferencesEntrypass, False, False, 7)604 self. preferencesHBox4.pack_start(self.preferencesLabelpass, False, False, 12)605 self. preferencesHBox3.pack_end(self.preferencesEntryuser, False, False, 7)606 self. preferencesHBox2.pack_end(self.preferencesCheckauth, False, False, 7)607 self. preferencesHBox5.pack_start(self.preferencesLabelformat, False, False, 12)608 self. preferencesHBox5.pack_end(self.preferencesComboformat, False, False, 7)609 self. preferencesHBox6.pack_start(self.preferencesLabelquality, False, False, 12)610 self. preferencesHBox6.pack_end(self.preferencesSpinquality, False, False, 7)611 if not self.itaka globals.system == 'nt':612 self. preferencesHBox7.pack_start(self.preferencesLabelscreenshot, False, False, 12)613 self. preferencesHBox7.pack_end(self.preferencesComboscreenshot, False, False, 7)614 self. preferencesHBox8.pack_start(self.preferencesLabelscale, False, False, 12)615 self. preferencesHBox8.pack_end(self.preferencesSpinscale, False, False, 7)616 if self.itaka globals.notifyavailable:617 self. preferencesHBox9.pack_start(self.preferencesLabelnotifications, False, False, 12)618 self. preferencesHBox9.pack_end(self.preferencesChecknotifications, False, False, 7)619 self. preferencesHBox10.pack_start(self.preferencesButtonAbout, False, False, 7)620 self. preferencesHBox10.pack_end(self.preferencesButtonClose, False, False, 7)621 622 self. preferencesVBoxitems.pack_start(self.preferencesHBox1, False, False, 0)623 self. preferencesVBoxitems.pack_start(self.preferencesHBox2, False, False, 0)624 self. preferencesVBoxitems.pack_start(self.preferencesHBox3, False, False, 0)625 self. preferencesVBoxitems.pack_start(self.preferencesHBox4, False, False, 0)626 self. preferencesVBoxitems.pack_start(self.preferencesHBox5, False, False, 0)627 self. preferencesVBoxitems.pack_start(self.preferencesHBox6, False, False, 0)628 if not self.itaka globals.system == 'nt':629 self. preferencesVBoxitems.pack_start(self.preferencesHBox7, False, False, 0)630 self. preferencesVBoxitems.pack_start(self.preferencesHBox8, False, False, 0)631 if self.itaka globals.notifyavailable:632 self. preferencesVBoxitems.pack_start(self.preferencesHBox9, False, False, 0)633 634 self. preferencesFramesettings.add(self.preferencesVBoxitems)635 self. preferencesVBox.pack_start(self.preferencesFramesettings, False, False, 0)636 self. preferencesVBox.pack_start(self.preferencesHBox10, False, False, 4)596 self.combo_preferences_screenshot.set_active(0) 597 598 self.button_preferences_close = gtk.Button('Close', gtk.STOCK_CLOSE) 599 self.button_preferences_close.connect('clicked', lambda wid: self.contractpreferences()) 600 601 self.button_preferences_about = gtk.Button('About', gtk.STOCK_ABOUT) 602 self.button_preferences_about.connect('clicked', lambda wid: self.about()) 603 604 self.hbox_preferences_1.pack_start(self.label_preferences_port, False, False, 12) 605 self.hbox_preferences_1.pack_end(self.spin_preferences_port, False, False, 7) 606 self.hbox_preferences_2.pack_start(self.label_preferences_auth, False, False, 12) 607 self.hbox_preferences_3.pack_start(self.label_preferences_user, False, False, 12) 608 self.hbox_preferences_4.pack_end(self.entry_preferences_pass, False, False, 7) 609 self.hbox_preferences_4.pack_start(self.label_preferences_pass, False, False, 12) 610 self.hbox_preferences_3.pack_end(self.entry_preferences_user, False, False, 7) 611 self.hbox_preferences_2.pack_end(self.check_preferences_auth, False, False, 7) 612 self.hbox_preferences_5.pack_start(self.label_preferences_format, False, False, 12) 613 self.hbox_preferences_5.pack_end(self.combo_preferences_format, False, False, 7) 614 self.hbox_preferences_6.pack_start(self.label_preferences_quality, False, False, 12) 615 self.hbox_preferences_6.pack_end(self.spin_preferences_quality, False, False, 7) 616 if not self.itaka_globals.system == 'nt': 617 self.hbox_preferences_7.pack_start(self.label_preferences_screenshot, False, False, 12) 618 self.hbox_preferences_7.pack_end(self.combo_preferences_screenshot, False, False, 7) 619 self.hbox_preferences_8.pack_start(self.label_preferences_scale, False, False, 12) 620 self.hbox_preferences_8.pack_end(self.spin_preferences_scale, False, False, 7) 621 if self.itaka_globals.notify_available: 622 self.hbox_preferences_9.pack_start(self.label_preferences_notifications, False, False, 12) 623 self.hbox_preferences_9.pack_end(self.check_preferences_notifications, False, False, 7) 624 self.hbox_preferences_10.pack_start(self.button_preferences_about, False, False, 7) 625 self.hbox_preferences_10.pack_end(self.button_preferences_close, False, False, 7) 626 627 self.vbox_preferences_items.pack_start(self.hbox_preferences_1, False, False, 0) 628 self.vbox_preferences_items.pack_start(self.hbox_preferences_2, False, False, 0) 629 self.vbox_preferences_items.pack_start(self.hbox_preferences_3, False, False, 0) 630 self.vbox_preferences_items.pack_start(self.hbox_preferences_4, False, False, 0) 631 self.vbox_preferences_items.pack_start(self.hbox_preferences_5, False, False, 0) 632 self.vbox_preferences_items.pack_start(self.hbox_preferences_6, False, False, 0) 633 if not self.itaka_globals.system == 'nt': 634 self.vbox_preferences_items.pack_start(self.hbox_preferences_7, False, False, 0) 635 self.vbox_preferences_items.pack_start(self.hbox_preferences_8, False, False, 0) 636 if self.itaka_globals.notify_available: 637 self.vbox_preferences_items.pack_start(self.hbox_preferences_9, False, False, 0) 638 639 self.frame_preference_settings.add(self.vbox_preferences_items) 640 self.vbox_preferences.pack_start(self.frame_preference_settings, False, False, 0) 641 self.vbox_preferences.pack_start(self.hbox_preferences_10, False, False, 4) 637 642 638 643 self.window.add(self.vbox) … … 648 653 649 654 # So we can mess with the values in the running one and not mess up our comparison 650 self.current configuration = copy.deepcopy(self.configuration)655 self.current_configuration = copy.deepcopy(self.configuration) 651 656 652 657 # Switch to the proper values 653 formatvalue = str(self.preferencesComboformat.get_active_text())654 if formatvalue == 'PNG':655 formatvalue = 'png'658 self.format_value = str(self.combo_preferences_format.get_active_text()) 659 if self.format_value == 'PNG': 660 self.format_value = 'png' 656 661 self.configuration['screenshot']['format'] = 'png' 657 662 else: 658 formatvalue = 'jpeg'663 self.format_value = 'jpeg' 659 664 self.configuration['screenshot']['format'] = 'jpeg' 660 665 661 if self.itaka globals.notifyavailable:662 notifyvalue = self.preferencesChecknotifications.get_active()663 if notifyvalue:664 notifyvalue = True665 self.menu itemnotifications.set_active(True)666 if self.itaka_globals.notify_available: 667 self.notify_value = self.check_preferences_notifications.get_active() 668 if self.notify_value: 669 self.notify_value = True 670 self.menu_item_notifications.set_active(True) 666 671 self.configuration['server']['notify'] = True 667 672 else: 668 notifyvalue = False669 self.menu itemnotifications.set_active(False)673 self.notify_value = False 674 self.menu_item_notifications.set_active(False) 670 675 self.configuration['server']['notify'] = False 671 676 else: 672 notifyvalue = False677 self.notify_value = False 673 678 self.configuration['server']['notify'] = False 674 679 675 if not self.itaka globals.system == 'nt':676 if self. preferencesComboscreenshot.get_active_text() == _('Active window'):680 if not self.itaka_globals.system == 'nt': 681 if self.combo_preferences_screenshot.get_active_text() == _('Active window'): 677 682 self.configuration['screenshot']['currentwindow'] = True 678 s creenshotvalue = True683 self.screenshot_value = True 679 684 else: 680 685 self.configuration['screenshot']['currentwindow'] = False 681 s creenshotvalue = False682 else: 683 s creenshotvalue = False686 self.screenshot_value = False 687 else: 688 self.screenshot_value = False 684 689 self.configuration['screenshot']['currentwindow'] = False 685 690 686 s cale = [self.preferencesSpinscale.get_value_as_int()]687 if s cale[0] == 100:691 self.scale_value = [self.spin_preferences_scale.get_value_as_int()] 692 if self.scale_value[0] == 100: 688 693 self.configuration['screenshot']['scale'] = False 689 s cale.append(False)694 self.scale_value.append(False) 690 695 else: 691 696 self.configuration['screenshot']['scale'] = True 692 s cale.append(True)693 694 if self.configuration['screenshot']['scalepercent'] != s cale[0]:695 self.configuration['screenshot']['scalepercent'] = s cale[0]697 self.scale_value.append(True) 698 699 if self.configuration['screenshot']['scalepercent'] != self.scale_value[0]: 700 self.configuration['screenshot']['scalepercent'] = self.scale_value[0] 696 701 697 702 # Build a configuration dictionary to send to the configuration engine's … … 704 709 'screenshot': 705 710 {'path': self.configuration['screenshot']['path'], 706 'format': formatvalue,707 'quality': self. preferencesSpinquality.get_value_as_int(),708 'currentwindow': s creenshotvalue,709 'scale': s cale[1],710 'scalepercent': s cale[0]},711 'format': self.format_value, 712 'quality': self.spin_preferences_quality.get_value_as_int(), 713 'currentwindow': self.screenshot_value, 714 'scale': self.scale_value[1], 715 'scalepercent': self.scale_value[0]}, 711 716 712 717 'server': 713 {'username': self. preferencesEntryuser.get_text(),714 'authentication': self. preferencesCheckauth.get_active(),715 'notify': notifyvalue,716 'password': self. preferencesEntrypass.get_text(),717 'port': self. preferencesSpinport.get_value_as_int()}718 {'username': self.entry_preferences_user.get_text(), 719 'authentication': self.check_preferences_auth.get_active(), 720 'notify': self.notify_value, 721 'password': self.entry_preferences_pass.get_text(), 722 'port': self.spin_preferences_port.get_value_as_int()} 718 723 } 719 724 720 725 # Set them for local use now 721 if self.configuration['screenshot']['quality'] != self. preferencesSpinquality.get_value_as_int():722 self.configuration['screenshot']['quality'] = self. preferencesSpinquality.get_value_as_int()723 724 if self.configuration['server']['port'] != self. preferencesSpinport.get_value_as_int():725 self.configuration['server']['port'] = self. preferencesSpinport.get_value_as_int()726 if self.configuration['screenshot']['quality'] != self.spin_preferences_quality.get_value_as_int(): 727 self.configuration['screenshot']['quality'] = self.spin_preferences_quality.get_value_as_int() 728 729 if self.configuration['server']['port'] != self.spin_preferences_port.get_value_as_int(): 730 self.configuration['server']['port'] = self.spin_preferences_port.get_value_as_int() 726 731 self.restart_server() 727 732 728 if self.configuration['server']['authentication'] is not self. preferencesCheckauth.get_active():729 self.configuration['server']['authentication'] = self. preferencesCheckauth.get_active()730 731 if self.configuration['server']['username'] != self. preferencesEntryuser.get_text():732 self.configuration['server']['username'] = self. preferencesEntryuser.get_text()733 734 if self.configuration['server']['password'] != self. preferencesEntrypass.get_text():735 self.configuration['server']['password'] = self. preferencesEntrypass.get_text()733 if self.configuration['server']['authentication'] is not self.check_preferences_auth.get_active(): 734 self.configuration['server']['authentication'] = self.check_preferences_auth.get_active() 735 736 if self.configuration['server']['username'] != self.entry_preferences_user.get_text(): 737 self.configuration['server']['username'] = self.entry_preferences_user.get_text() 738 739 if self.configuration['server']['password'] != self.entry_preferences_pass.get_text(): 740 self.configuration['server']['password'] = self.entry_preferences_pass.get_text() 736 741 737 742 # Check if the configuration changed 738 if (self.configurationdict != self.current configuration):743 if (self.configurationdict != self.current_configuration): 739 744 740 745 # Update the needed keys 741 746 try: 742 # self.config instance.save(self.configurationdict)747 # self.config_instance.save(self.configurationdict) 743 748 for section in self.configurationdict: 744 [self.config instance.update(section, key, value) for key, value in self.configurationdict[section].iteritems() if key not in self.currentconfiguration[section] or self.currentconfiguration[section][key] != value]749 [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] 745 750 except: 746 751 self.log.failure(('Gui', 'save_preferences'), _('Could not save preferences'), 'ERROR') … … 754 759 # See configure-event signal of gtk.Widget 755 760 # start timer, resize, catch configure-notify, set up idle handler, when idle resize to what the size should be at this point of time, repeat 756 if not self.preferences expanded:757 if self. expandtimeoutis not None:761 if not self.preferences_expanded: 762 if self.timeout_expand is not None: 758 763 """NOTE: GTK+ GtkWidget.size_request() method can give you the amount of size a widget will take 759 however, it has to be show()ned before. For our little hack, we show the preferencesVBoxwidgets764 however, it has to be show()ned before. For our little hack, we show the vbox_preferences widgets 760 765 but not itself, which should yield a close enough calculation.""" 761 self. preferencesFramesettings.show_all()762 self. preferencesHBox10.show_all()766 self.frame_preference_settings.show_all() 767 self.hbox_preferences_10.show_all() 763 768 764 769 """If the logger is expanded, use that as the initial size. … … 776 781 777 782 self.increment = 33 778 if self.window.current_size[1] < self.window.normal_size[1]+self. preferencesVBox.size_request()[1]:783 if self.window.current_size[1] < self.window.normal_size[1]+self.vbox_preferences.size_request()[1]: 779 784 # Avoid overexpanding our calculation 780 if self.window.current_size[1]+self.increment > self.window.normal_size[1]+self. preferencesVBox.size_request()[1]:781 self.increment = (self.window.normal_size[1]+self. preferencesVBox.size_request()[1] - self.window.current_size[1])785 if self.window.current_size[1]+self.increment > self.window.normal_size[1]+self.vbox_preferences.size_request()[1]: 786 self.increment = (self.window.normal_size[1]+self.vbox_preferences.size_request()[1] - self.window.current_size[1]) 782 787 783 788 self.window.resize(self.window.current_size[0], self.window.current_size[1]+self.increment) … … 785 790 else: 786 791 # Its done expanding, add our widgets or display it if it has been done already 787 self. preferencesButton.set_sensitive(False)788 self.preferences expanded = True792 self.button_preferences.set_sensitive(False) 793 self.preferences_expanded = True 789 794 790 795 # Reload our configuration and show the preferences 791 self.configuration = self.config instance.load()792 if self.preferences hidden:793 self. preferencesVBox.show_all()796 self.configuration = self.config_instance.load() 797 if self.preferences_hidden: 798 self.vbox_preferences.show_all() 794 799 else: 795 self.vbox.pack_start(self. preferencesVBox, False, False, 0)796 self. preferencesVBox.show_all()800 self.vbox.pack_start(self.vbox_preferences, False, False, 0) 801 self.vbox_preferences.show_all() 797 802 798 self. expandtimeout= None803 self.timeout_expand = None 799 804 return False 800 805 else: 801 self. expandtimeout= gobject.timeout_add(30, self.expandpreferences)806 self.timeout_expand = gobject.timeout_add(30, self.expandpreferences) 802 807 803 808 def contractpreferences(self, *args): … … 806 811 """ 807 812 808 if self. contracttimeout is not None:813 if self.timeout_contract is not None: 809 814 # If you dont use the normal_size proxy to our window sizes, 810 815 # it generates a nice effect of doing the animation when closing the expander also. … … 816 821 self.window.normal_size = self.window.initial_size 817 822 818 if self. preferencesVBox.get_property("visible"):819 self. preferencesVBox.hide_all()823 if self.vbox_preferences.get_property("visible"): 824 self.vbox_preferences.hide_all() 820 825 821 826 if self.window.current_size[1] > self.window.normal_size[1]: … … 824 829 else: 825 830 # Done, set some variables and stop our timer 826 self.preferences expanded = False827 self.preferences hidden = True831 self.preferences_expanded = False 832 self.preferences_hidden = True 828 833 self.expander.size_finalized = False 829 self. preferencesButton.set_sensitive(True)834 self.button_preferences.set_sensitive(True) 830 835 831 836 # Save our settings 832 837 self.save_preferences() 833 838 834 self. contracttimeout = None839 self.timeout_contract = None 835 840 return False 836 841 else: 837 self. contracttimeout = gobject.timeout_add(30, self.contractpreferences)842 self.timeout_contract = gobject.timeout_add(30, self.contractpreferences) 838 843 839 844 def windowsizechanged(self, widget=None, data=None): … … 854 859 self.expander_size = self.window.current_size 855 860 # If the preferences were expanded before the logger 856 if self.preferences expanded:861 if self.preferences_expanded: 857 862 # Cant assign tuple items 858 self.expander_size = [self.expander_size[0], self.expander_size[1] - self. preferencesVBox.size_request()[1]]859 860 def status icon_menu(self, widget, button, time, menu):863 self.expander_size = [self.expander_size[0], self.expander_size[1] - self.vbox_preferences.size_request()[1]] 864 865 def status_icon_menu(self, widget, button, time, menu): 861 866 """ 862 867 Display the menu on the status icon … … 881 886 pass 882 887 883 def status icon_blinktimeout(self, time=3000):888 def status_icon_timeout_blink(self, time=3000): 884 889 """ 885 890 Sets the timeout in miliseconds to blink and stop blinking the status icon … … 889 894 """ 890 895 891 if self. blinktimeoutis None:892 self.status Icon.set_blinking(True)893 self. blinktimeout = gobject.timeout_add(time, self.statusicon_blinktimeout)894 else: 895 self.status Icon.set_blinking(False)896 self. blinktimeout= None896 if self.timeout_blink is None: 897 self.status_icon.set_blinking(True) 898 self.timeout_blink = gobject.timeout_add(time, self.status_icon_timeout_blink) 899 else: 900 self.status_icon.set_blinking(False) 901 self.timeout_blink = None 897 902 return False 898 903 899 def status icon_activate(self, widget):904 def status_icon_activate(self, widget): 900 905 """ 901 906 Toggle the window visibility from the status icon when clicked … … 912 917 self.window.show() 913 918 914 def status icon_notify(self, widget):919 def status_icon_notify(self, widget): 915 920 """ 916 921 Disable or enable notifications on the fly from the status icon … … 920 925 """ 921 926 922 if self.check widget(self.menuitemnotifications):927 if self.check_widget(self.menu_item_notifications): 923 928 self.configuration['server']['notify'] = True 924 929 else: … … 930 935 """ 931 936 932 self.about dialog = gtk.AboutDialog()933 self.about dialog.set_transient_for(self.window)934 self.about dialog.set_name('Itaka')935 self.about dialog.set_version(self.itakaglobals.version)936 self.about dialog.set_copyright(u'© 2003-2007 Marc E.')937 self.about dialog.set_comments('Screenshooting de mercado.')938 self.about dialog.set_authors(['Marc E. <santusmarc@users.sourceforge.net>', _('Kurt Erickson <psychogenicshk@users.sourceforge.net> (Packaging)')])939 self.about dialog.set_artists(['Marc E. <santusmarc@users.sourceforge.net>', 'Tango Project (http://tango.freedesktop.org)'])940 self.about dialog.set_license('''Itaka is free software; you can redistribute it and/or modify937 self.about_dialog = gtk.about_dialog() 938 self.about_dialog.set_transient_for(self.window) 939 self.about_dialog.set_name('Itaka') 940 self.about_dialog.set_version(self.itaka_globals.__version__) 941 self.about_dialog.set_copyright(u'© 2003-2007 Marc E.') 942 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)')]) 944 self.about_dialog.set_artists(['Marc E. <santusmarc@users.sourceforge.net>', 'Tango Project (http://tango.freedesktop.org)']) 945 self.about_dialog.set_license('''Itaka is free software; you can redistribute it and/or modify 941 946 it under the terms of the GNU General Public License as published by 942 the Free Software Foundation; either version 2of the License, or947 the Free Software Foundation; either version 3 of the License, or 943 948 any later version. 944 949 … … 951 956 along with Itaka; if not, write to the Free Software 952 957 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA''') 953 self.about dialog.set_website('http://itaka.jardinpresente.com.ar')954 self.about dialog.set_logo(gtk.gdk.pixbuf_new_from_file(os.path.join(self.itakaglobals.image_dir, "itaka64x64.png")))955 self.about dialog.set_icon(self.icon_pixbuf)956 self.about dialog.run()957 self.about dialog.destroy()958 self.about_dialog.set_website('http://itaka.jardinpresente.com.ar') 959 self.about_dialog.set_logo(gtk.gdk.pixbuf_new_from_file(os.path.join(self.itaka_globals.image_dir, "itaka64x64.png"))) 960 self.about_dialog.set_icon(self.icon_pixbuf) 961 self.about_dialog.run() 962 self.about_dialog.destroy() 958 963 959 964 def expandlogger(self, expander, params): … … 970 975 if self.expander.get_expanded(): 971 976 # Show the debugvbox() and it's subwidgets 972 self. logvbox.show_all()973 974 self.expander.add(self. logvbox)977 self.vbox_log.show_all() 978 979 self.expander.add(self.vbox_log) 975 980 else: 976 981 self.expander.remove(self.expander.child) … … 983 988 """ 984 989 985 self.log eventsstore.clear()986 self.log detailsbuffer.set_text("")990 self.log_events_store.clear() 991 self.log_details_buffer.set_text("") 987 992 988 993 def button_pause_log(self, widget): … … 994 999 """ 995 1000 996 if self.check widget(widget):1001 if self.check_widget(widget): 997 1002 if not self.log_paused(): 998 1003 self.pause_log() … … 1006 1011 """ 1007 1012 1008 self.log eventsstore.append([self.logeventstreeview.render_icon(stock_id=gtk.STOCK_MEDIA_PAUSE, size=gtk.ICON_SIZE_MENU, detail=None), _('Logging paused')])1009 1010 self.log eventstreeview.set_sensitive(False)1011 self.log detailstextview.set_sensitive(False)1013 self.log_events_store.append([self.log_events_tree_view.render_icon(stock_id=gtk.STOCK_MEDIA_PAUSE, size=gtk.ICON_SIZE_MENU, detail=None), _('Logging paused')]) 1014 1015 self.log_events_tree_view.set_sensitive(False) 1016 self.log_details_text_view.set_sensitive(False) 1012 1017 1013 1018 self.server.remove_log_observer() 1014 self.log paused = True1019 self.log_is_paused = True 1015 1020 1016 1021 def unpause_log(self, foreign=False): … … 1024 1029 self.server.add_log_observer(self.log.twisted_observer) 1025 1030 if (foreign): 1026 self. logpausebutton.set_active(False)1027 self.log detailstextview.set_sensitive(True)1028 self.log eventstreeview.set_sensitive(True)1029 1030 self.log eventsstore.append([self.logeventstreeview.render_icon(stock_id=gtk.STOCK_MEDIA_PLAY, size=gtk.ICON_SIZE_MENU, detail=None), _('Logging resumed')])1031 1032 self.log paused = False1031 self.button_log_pause.set_active(False) 1032 self.log_details_text_view.set_sensitive(True) 1033 self.log_events_tree_view.set_sensitive(True) 1034 1035 self.log_events_store.append([self.log_events_tree_view.render_icon(stock_id=gtk.STOCK_MEDIA_PLAY, size=gtk.ICON_SIZE_MENU, detail=None), _('Logging resumed')]) 1036 1037 self.log_is_paused = False 1033 1038 1034 1039 def log_paused(self): … … 1037 1042 1038 1043 @rtype: bool 1039 @return: True if the Gui log is paused . False otherwise1040 """ 1041 1042 return self.log paused1044 @return: True if the Gui log is paused 1045 """ 1046 1047 return self.log_is_paused 1043 1048 1044 1049 def main(self): … … 1058 1063 """ 1059 1064 1060 if self. preferencesComboformat.get_active_text() == 'PNG':1061 self. preferencesHBox6.set_sensitive(False)1062 else: 1063 self. preferencesHBox6.set_sensitive(True)1065 if self.combo_preferences_format.get_active_text() == 'PNG': 1066 self.hbox_preferences_6.set_sensitive(False) 1067 else: 1068 self.hbox_preferences_6.set_sensitive(True) 1064 1069 1065 1070 def _preferences_authentication_toggled(self, widget): … … 1071 1076 """ 1072 1077 1073 if self.check widget(widget):1074 self. preferencesEntryuser.set_sensitive(True)1075 self. preferencesEntrypass.set_sensitive(True)1076 self.itaka Logo.set_from_file(os.path.join(self.itakaglobals.image_dir, "itaka-secure.png"))1077 self.status Icon.set_from_pixbuf(gtk.gdk.pixbuf_new_from_file(os.path.join(self.itakaglobals.image_dir, "itaka-secure.png")))1078 else: 1079 self. preferencesEntryuser.set_sensitive(False)1080 self. preferencesEntrypass.set_sensitive(False)1081 self.itaka Logo.set_from_file(os.path.join(self.itakaglobals.image_dir, "itaka.png"))1082 self.status Icon.set_from_pixbuf(self.icon_pixbuf)1083 1084 1085 def check widget(self, widget):1078 if self.check_widget(widget): 1079 self.entry_preferences_user.set_sensitive(True) 1080 self.entry_preferences_pass.set_sensitive(True) 1081 self.itaka_logo.set_from_file(os.path.join(self.itaka_globals.image_dir, "itaka-secure.png")) 1082 self.status_icon.set_from_pixbuf(gtk.gdk.pixbuf_new_from_file(os.path.join(self.itaka_globals.image_dir, "itaka-secure.png"))) 1083 else: 1084 self.entry_preferences_user.set_sensitive(False) 1085 self.entry_preferences_pass.set_sensitive(False) 1086 self.itaka_logo.set_from_file(os.path.join(self.itaka_globals.image_dir, "itaka.png")) 1087 self.status_icon.set_from_pixbuf(self.icon_pixbuf) 1088 1089 1090 def check_widget(self, widget): 1086 1091 """ 1087 1092 Checks if a gtk.Widget is active … … 1103 1108 @param widget: gtk.Widget 1104 1109 """ 1105 if self.check widget(widget):1110 if self.check_widget(widget): 1106 1111 self.start_server() 1107 1112 else: … … 1116 1121 1117 1122 @type foreign: bool 1118 @param foreign: Whether the caller of this method is not self.button Startstop1123 @param foreign: Whether the caller of this method is not self.button_start_stop 1119 1124 1120 1125 """ … … 1126 1131 except error.ItakaServerErrorCannotListen, e: 1127 1132 self.log.failure(('Gui', 'start_server'), (_('Failed to start server'), _('Failed to start server: %s') % (e)), 'ERROR') 1128 self.button Startstop.set_active(False)1133 self.button_start_stop.set_active(False) 1129 1134 return 1130 1135 … … 1145 1150 # Change buttons 1146 1151 if foreign: 1147 self.button Startstop.set_active(True)1148 self.button Startstop.set_label(_('Stop'))1149 self.start stopimage.set_from_stock(gtk.STOCK_STOP, gtk.ICON_SIZE_BUTTON)1150 self.button Startstop.set_image(self.startstopimage)1151 1152 self.status Icon.set_tooltip(_('Itaka - Server running'))1153 self.menu itemstart.set_sensitive(False)1154 self.menu itemstop.set_sensitive(True)1152 self.button_start_stop.set_active(True) 1153 self.button_start_stop.set_label(_('Stop')) 1154 self.start_stop_image.set_from_stock(gtk.STOCK_STOP, gtk.ICON_SIZE_BUTTON) 1155 self.button_start_stop.set_image(self.start_stop_image) 1156 1157 self.status_icon.set_tooltip(_('Itaka - Server running')) 1158 self.menu_item_start.set_sensitive(False) 1159 self.menu_item_stop.set_sensitive(True) 1155 1160 1156 1161 if not self.expander.get_property("sensitive"): … … 1165 1170 1166 1171 @type foreign: bool 1167 @param foreign: Whether the caller of this method is not self.button Startstop1172 @param foreign: Whether the caller of this method is not self.button_start_stop 1168 1173 """ 1169 1174 … … 1180 1185 # Change GUI elements 1181 1186 if (foreign): 1182 self.button Startstop.set_active(False)1183 1184 self.status Icon.set_tooltip('Itaka')1185 self.start stopimage.set_from_stock(gtk.STOCK_EXECUTE, gtk.ICON_SIZE_BUTTON)1186 self.button Startstop.set_image(self.startstopimage)1187 self.button Startstop.set_label(_('Start'))1188 self.label Lastip.set_text('')1189 self.label Time.set_text('')1190 self.label Served.set_text('')1191 self.menu itemstart.set_sensitive(True)1192 self.menu itemstop.set_sensitive(False)1187 self.button_start_stop.set_active(False) 1188 1189 self.status_icon.set_tooltip('Itaka') 1190 self.start_stop_image.set_from_stock(gtk.STOCK_EXECUTE, gtk.ICON_SIZE_BUTTON) 1191 self.button_start_stop.set_image(self.start_stop_image) 1192 self.button_start_stop.set_label(_('Start')) 1193 self.label_last_ip.set_text('') 1194 self.label_time.set_text('') 1195 self.label_served.set_text('') 1196 self.menu_item_start.set_sensitive(True) 1197 self.menu_item_stop.set_sensitive(False) 1193 1198 1194 1199 def restart_server(self): … … 1221 1226 1222 1227 # Windows fix 1223 del self.status Icon1228 del self.status_icon 1224 1229 1225 1230 gtk.main_quit() … … 1251 1256 self.pieces.append(self.plural(self.minutes, _('minute'))) 1252 1257 1253 self.label Time.set_text(_('<b>When</b>: ') + ', '.join(self.pieces) + _(' ago'))1254 self.label Time.set_use_markup(True)1258 self.label_time.set_text(_('<b>When</b>: ') + ', '.join(self.pieces) + _(' ago')) 1259 self.label_time.set_use_markup(True) 1255 1260 1256 1261 # Need this so it runs more than once … … 1278 1283 1279 1284 if self.configuration['server']['authentication']: 1280 self.itaka Logo.set_from_file(os.path.join(self.itakaglobals.image_dir, "itaka-secure.png"))1281 else: 1282 self.itaka Logo.set_from_file(os.path.join(self.itakaglobals.image_dir, "itaka.png"))1283 1284 self.status Icon.set_from_pixbuf(self.icon_pixbuf)1285 self.itaka_logo.set_from_file(os.path.join(self.itaka_globals.image_dir, "itaka-secure.png")) 1286 else: 1287 self.itaka_logo.set_from_file(os.path.join(self.itaka_globals.image_dir, "itaka.png")) 1288 1289 self.status_icon.set_from_pixbuf(self.icon_pixbuf) 1285 1290 # Only run this event once 1286 1291 return False … … 1305 1310 self.time = time 1306 1311 1307 self.log.detailed_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"))])1308 1309 self.label Served.set_text(_('<b>Served</b>: %d') % (self.counter))1310 self.label Served.set_use_markup(True)1311 self.label Lastip.set_text(_('<b>Client</b>: %s') % (self.ip))1312 self.label Lastip.set_use_markup(True)1313 self.status Icon.set_tooltip(_('Itaka - %s served') % (self.plural(self.counter, _('screenshot'))))1312 self.log.detailed_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"))]) 1313 1314 self.label_served.set_text(_('<b>Served</b>: %d') % (self.counter)) 1315 self.label_served.set_use_markup(True) 1316 self.label_last_ip.set_text(_('<b>Client</b>: %s') % (self.ip)) 1317 self.label_last_ip.set_use_markup(True) 1318 self.status_icon.set_tooltip(_('Itaka - %s served') % (self.plural(self.counter, _('screenshot')))) 1314 1319 1315 1320 # Show the camera image on tray and interface for 1.5 seconds 1316 1321 if self.configuration['server']['authentication']: 1317 self.itaka Logo.set_from_file(os.path.join(self.itakaglobals.image_dir, 'itaka-secure-take.png'))1318 else: 1319 self.itaka Logo.set_from_file(os.path.join(self.itakaglobals.image_dir, 'itaka-take.png'))1320 self.status Icon.set_from_file(os.path.join(self.itakaglobals.image_dir, 'itaka-take.png'))1322 self.itaka_logo.set_from_file(os.path.join(self.itaka_globals.image_dir, 'itaka-secure-take.png')) 1323 else: 1324 self.itaka_logo.set_from_file(os.path.join(self.itaka_globals.image_dir, 'itaka-take.png')) 1325 self.status_icon.set_from_file(os.path.join(self.itaka_globals.image_dir, 'itaka-take.png')) 1321 1326 gobject.timeout_add(1500, self.set_standard_images) 1322 1327
Note: See TracChangeset
for help on using the changeset viewer.

