From ecdaf6b795550158273ba3a0d582f7ff2bec3187 Mon Sep 17 00:00:00 2001 From: Sascha Silbe Date: Tue, 25 Aug 2009 19:55:48 +0200 Subject: [PATCH] trim EOL (end-of-line) spaces on source files --- src/sugar/Makefile.am | 2 +- src/sugar/activity/__init__.py | 20 ++-- src/sugar/activity/activity.py | 140 ++++++++++++------------- src/sugar/activity/activityfactory.py | 2 +- src/sugar/activity/activityhandle.py | 28 ++--- src/sugar/activity/activityservice.py | 12 +-- src/sugar/activity/bundlebuilder.py | 22 ++-- src/sugar/activity/main.py | 6 +- src/sugar/activity/namingalert.py | 22 ++-- src/sugar/bundle/activitybundle.py | 30 +++--- src/sugar/bundle/bundle.py | 6 +- src/sugar/datastore/datastore.py | 14 +-- src/sugar/datastore/dbus_helpers.py | 2 +- src/sugar/eggaccelerators.c | 62 +++++------ src/sugar/eggaccelerators.h | 8 +- src/sugar/eggdesktopfile.c | 8 +- src/sugar/eggsmclient-xsmp.c | 8 +- src/sugar/eggsmclient.c | 2 +- src/sugar/graphics/alert.py | 38 +++---- src/sugar/graphics/animator.py | 2 +- src/sugar/graphics/canvastextview.py | 4 +- src/sugar/graphics/colorbutton.py | 28 ++--- src/sugar/graphics/combobox.py | 4 +- src/sugar/graphics/icon.py | 10 +- src/sugar/graphics/notebook.py | 16 +-- src/sugar/graphics/objectchooser.py | 2 +- src/sugar/graphics/palette.py | 10 +- src/sugar/graphics/palettegroup.py | 2 +- src/sugar/graphics/palettewindow.py | 10 +- src/sugar/graphics/radiotoolbutton.py | 2 +- src/sugar/graphics/roundbox.py | 4 +- src/sugar/graphics/toggletoolbutton.py | 6 +- src/sugar/graphics/toolbarbox.py | 2 +- src/sugar/graphics/toolbox.py | 12 +-- src/sugar/graphics/toolbutton.py | 2 +- src/sugar/graphics/tray.py | 4 +- src/sugar/graphics/window.py | 22 ++-- src/sugar/gsm-app.c | 2 +- src/sugar/gsm-app.h | 2 +- src/sugar/gsm-client-xsmp.c | 10 +- src/sugar/gsm-client.h | 2 +- src/sugar/gsm-session.c | 12 +-- src/sugar/gsm-session.h | 14 +-- src/sugar/network.py | 2 +- src/sugar/presence/__init__.py | 2 +- src/sugar/presence/activity.py | 28 ++--- src/sugar/presence/buddy.py | 58 +++++----- src/sugar/presence/presenceservice.py | 86 +++++++-------- src/sugar/profile.py | 22 ++-- src/sugar/sugar-address-entry.c | 48 ++++----- src/sugar/sugar-key-grabber.c | 8 +- src/sugar/util.py | 20 ++-- src/sugar/wm.py | 2 +- 53 files changed, 446 insertions(+), 446 deletions(-) diff --git a/src/sugar/Makefile.am b/src/sugar/Makefile.am index fb87bf65..236e337c 100644 --- a/src/sugar/Makefile.am +++ b/src/sugar/Makefile.am @@ -74,7 +74,7 @@ _sugarext.c: _sugarext.defs _sugarext.override --prefix py$* $*.defs) > gen-$*.c \ && cp gen-$*.c $*.c \ && rm -f gen-$*.c - + sugar-marshal.c: sugar-marshal.list $(GLIB_GENMARSHAL) --prefix=sugar_marshal \ $(srcdir)/sugar-marshal.list --header --body > sugar-marshal.c diff --git a/src/sugar/activity/__init__.py b/src/sugar/activity/__init__.py index 8d3ef2bb..b69646c6 100644 --- a/src/sugar/activity/__init__.py +++ b/src/sugar/activity/__init__.py @@ -18,12 +18,12 @@ """Activity implementation code for Sugar-based activities Each activity within the OLPC environment must provide two -dbus services. The first, patterned after the +dbus services. The first, patterned after the sugar.activity.activityfactory.ActivityFactory -class is responsible for providing a "create" method which -takes a small dictionary with values corresponding to a +class is responsible for providing a "create" method which +takes a small dictionary with values corresponding to a sugar.activity.activityhandle.ActivityHandle @@ -33,23 +33,23 @@ Each activity so registered is described by a sugar.activity.bundle.Bundle -instance, which parses a specially formatted activity.info -file (stored in the activity directory's ./activity -subdirectory). The +instance, which parses a specially formatted activity.info +file (stored in the activity directory's ./activity +subdirectory). The sugar.activity.bundlebuilder -module provides facilities for the standard setup.py module -which produces and registers bundles from activity source +module provides facilities for the standard setup.py module +which produces and registers bundles from activity source directories. Once instantiated by the ActivityFactory's create method, -each activity must provide an introspection API patterned +each activity must provide an introspection API patterned after the sugar.activity.activityservice.ActivityService -class. This class allows for querying the ID of the root +class. This class allows for querying the ID of the root window, requesting sharing across the network, and basic "what type of application are you" queries. """ diff --git a/src/sugar/activity/activity.py b/src/sugar/activity/activity.py index 05c5b001..dee7f90f 100644 --- a/src/sugar/activity/activity.py +++ b/src/sugar/activity/activity.py @@ -1,6 +1,6 @@ """Base class for activities written in Python -This is currently the only definitive reference for what an +This is currently the only definitive reference for what an activity must do to participate in the Sugar desktop. A Basic Activity @@ -10,11 +10,11 @@ The convention is to call it ActivitynameActivity, but this is not required as the activity.info file associated with your activity will tell the sugar-shell which class to start. -For example the most minimal Activity: +For example the most minimal Activity: + - from sugar.activity import activity - + class ReadActivity(activity.Activity): pass @@ -61,7 +61,7 @@ import dbus import dbus.service import cjson -from sugar import util +from sugar import util from sugar.presence import presenceservice from sugar.activity.activityservice import ActivityService from sugar.activity.namingalert import NamingAlert @@ -136,67 +136,67 @@ class _ActivitySession(gobject.GObject): class Activity(Window, gtk.Container): """This is the base Activity class that all other Activities derive from. This is where your activity starts. - + To get a working Activity: 0. Derive your Activity from this class: class MyActivity(activity.Activity): ... - + 1. implement an __init__() method for your Activity class. - + Use your init method to create your own ActivityToolbar which will - contain some standard buttons: + contain some standard buttons: toolbox = activity.ActivityToolbox(self) - + Add extra Toolbars to your toolbox. - + You should setup Activity sharing here too. - + Finaly, your Activity may need some resources which you can claim here too. - + The __init__() method is also used to make the distinction between - being resumed from the Journal, or starting with a blank document. - + being resumed from the Journal, or starting with a blank document. + 2. Implement read_file() and write_file() Most activities revolve around creating and storing Journal entries. For example, Write: You create a document, it is saved to the Journal and then later you resume working on the document. - + read_file() and write_file() will be called by sugar to tell your Activity that it should load or save the document the user is working on. - + 3. Implement our Activity Toolbars. The Toolbars are added to your Activity in step 1 (the toolbox), but you need to implement them somewhere. Now is a good time. - + There are a number of standard Toolbars. The most basic one, the one your almost absolutely MUST have is the ActivityToolbar. Without this, you're not really making a proper Sugar Activity (which may be okay, but you should really stop and think about why not!) You do - this with the ActivityToolbox(self) call in step 1. - + this with the ActivityToolbox(self) call in step 1. + Usually, you will also need the standard EditToolbar. This is the one which has the standard copy and paste buttons. You need to derive your own EditToolbar class from sugar.EditToolbar: class EditToolbar(activity.EditToolbar): ... - + See EditToolbar for the methods you should implement in your class. - + Finaly, your Activity will very likely need some activity specific buttons and options you can create your own toolbars by deriving a class from gtk.Toolbar: class MySpecialToolbar(gtk.Toolbar): ... - + 4. Use your creativity. Make your Activity something special and share it with your friends! - + Read through the methods of the Activity class below, to learn more about - how to make an Activity work. - + how to make an Activity work. + Hint: A good and simple Activity to learn from is the Read activity. To create your own activity, you may want to copy it and use it as a template. """ @@ -208,34 +208,34 @@ class Activity(Window, gtk.Container): } def __init__(self, handle, create_jobject=True): - """Initialise the Activity - + """Initialise the Activity + handle -- sugar.activity.activityhandle.ActivityHandle - instance providing the activity id and access to the - presence service which *may* provide sharing for this + instance providing the activity id and access to the + presence service which *may* provide sharing for this application create_jobject -- boolean define if it should create a journal object if we are not resuming - Side effects: - - Sets the gdk screen DPI setting (resolution) to the + Side effects: + + Sets the gdk screen DPI setting (resolution) to the Sugar screen resolution. - + Connects our "destroy" message to our _destroy_cb method. - + Creates a base gtk.Window within this window. - + Creates an ActivityService (self._bus) servicing this application. - - Usage: + + Usage: If your Activity implements __init__(), it should call the base class __init()__ before doing Activity specific things. - + """ Window.__init__(self) @@ -280,9 +280,9 @@ class Activity(Window, gtk.Container): share_scope = SCOPE_PRIVATE if handle.object_id: - self._jobject = datastore.get(handle.object_id) + self._jobject = datastore.get(handle.object_id) self.set_title(self._jobject.metadata['title']) - + if self._jobject.metadata.has_key('share-scope'): share_scope = self._jobject.metadata['share-scope'] @@ -364,7 +364,7 @@ class Activity(Window, gtk.Container): def get_id(self): """Returns the activity id of the current instance of your activity. - + The activity id is sort-of-like the unix process id (PID). However, unlike PIDs it is only different for each new instance (with create_jobject = True set) and stays the same everytime a user @@ -379,7 +379,7 @@ class Activity(Window, gtk.Container): def set_canvas(self, canvas): """Sets the 'work area' of your activity with the canvas of your choice. - + One commonly used canvas is gtk.ScrolledWindow """ Window.set_canvas(self, canvas) @@ -412,21 +412,21 @@ class Activity(Window, gtk.Container): logging.debug('Error creating activity datastore object: %s', err) def get_activity_root(self): - """ FIXME: Deprecated. This part of the API has been moved + """ FIXME: Deprecated. This part of the API has been moved out of this class to the module itself Returns a path for saving Activity specific preferences, etc. - + Returns a path to the location in the filesystem where the activity can store activity related data that doesn't pertain to the current execution of the activity and thus cannot go into the DataStore. - + Currently, this will return something like ~/.sugar/default/MyActivityName/ - + Activities should ONLY save settings, user preferences and other data which isn't specific to a journal item here. If (meta-)data is in anyway - specific to a journal entry, it MUST be stored in the DataStore. + specific to a journal entry, it MUST be stored in the DataStore. """ if os.environ.has_key('SUGAR_ACTIVITY_ROOT') and \ os.environ['SUGAR_ACTIVITY_ROOT']: @@ -438,17 +438,17 @@ class Activity(Window, gtk.Container): """ Subclasses implement this method if they support resuming objects from the journal. 'file_path' is the file to read from. - + You should immediately open the file from the file_path, because the file_name will be deleted immediately after returning from read_file(). Once the file has been opened, you do not have to read it immediately: After you have opened it, the file will only be really gone when you close it. - + Although not required, this is also a good time to read all meta-data: the file itself cannot be changed externally, but the title, description and other metadata['tags'] may change. So if it is important for you to - notice changes, this is the time to record the originals. + notice changes, this is the time to record the originals. """ raise NotImplementedError @@ -456,17 +456,17 @@ class Activity(Window, gtk.Container): """ Subclasses implement this method if they support saving data to objects in the journal. 'file_path' is the file to write to. - + If the user did make changes, you should create the file_path and save all document data to it. - + Additionally, you should also write any metadata needed to resume your activity. For example, the Read activity saves the current page and zoom level, so it can display the page. - + Note: Currently, the file_path *WILL* be different from the one you received in file_read(). Even if you kept the file_path from file_read() - open until now, you must still write the entire file to this file_path. + open until now, you must still write the entire file to this file_path. """ raise NotImplementedError @@ -539,11 +539,11 @@ class Activity(Window, gtk.Container): def save(self): """Request that the activity is saved to the Journal. - + This method is called by the close() method below. In general, activities should not override this method. This method is part of the public API of an Acivity, and should behave in standard ways. Use your - own implementation of write_file() to save your Activity specific data. + own implementation of write_file() to save your Activity specific data. """ if self._jobject is None: @@ -590,7 +590,7 @@ class Activity(Window, gtk.Container): def copy(self): """Request that the activity 'Keep in Journal' the current state of the activity. - + Activities should not override this method. Instead, like save() do any copy work that needs to be done in write_file() """ @@ -656,7 +656,7 @@ class Activity(Window, gtk.Container): def _send_invites(self): while self._invites_queue: - buddy_key = self._invites_queue.pop() + buddy_key = self._invites_queue.pop() buddy = self._pservice.get_buddy(buddy_key) if buddy: self.shared_activity.invite( @@ -666,10 +666,10 @@ class Activity(Window, gtk.Container): def invite(self, buddy_key): """Invite a buddy to join this Activity. - + Side Effects: Calls self.share(True) to privately share the activity if it wasn't - shared before. + shared before. """ self._invites_queue.append(buddy_key) @@ -681,7 +681,7 @@ class Activity(Window, gtk.Container): def share(self, private=False): """Request that the activity be shared on the network. - + private -- bool: True to share by invitation only, False to advertise as shared to everyone. @@ -694,7 +694,7 @@ class Activity(Window, gtk.Container): verb = private and 'private' or 'public' logging.debug('Requesting %s share of activity %s.', verb, self._activity_id) - self._share_id = self._pservice.connect("activity-shared", + self._share_id = self._pservice.connect("activity-shared", self.__share_cb) self._pservice.share_activity(self, private=private) @@ -752,7 +752,7 @@ class Activity(Window, gtk.Container): def close(self, skip_save=False): """Request that the activity be stopped and saved to the Journal - + Activities should not override this method, but should implement write_file() to do any state saving instead. If the application wants to control wether it can close, it should override can_close(). @@ -783,13 +783,13 @@ class Activity(Window, gtk.Container): def get_metadata(self): """Returns the jobject metadata or None if there is no jobject. - - Activities can set metadata in write_file() using: + + Activities can set metadata in write_file() using: self.metadata['MyKey'] = "Something" - - and retrieve metadata in read_file() using: + + and retrieve metadata in read_file() using: self.metadata.get('MyKey', 'aDefaultValue') - + Note: Make sure your activity works properly if one or more of the metadata items is missing. Never assume they will all be present. """ @@ -822,7 +822,7 @@ def _get_session(): def get_bundle_name(): """Return the bundle name for the current process' bundle""" return os.environ['SUGAR_BUNDLE_NAME'] - + def get_bundle_path(): """Return the bundle path for the current process' bundle""" return os.environ['SUGAR_BUNDLE_PATH'] diff --git a/src/sugar/activity/activityfactory.py b/src/sugar/activity/activityfactory.py index 1971cc23..f2ca5ba9 100644 --- a/src/sugar/activity/activityfactory.py +++ b/src/sugar/activity/activityfactory.py @@ -197,7 +197,7 @@ class ActivityCreationHandler(gobject.GObject): self._bundle = bundle self._service_name = bundle.get_bundle_id() self._handle = handle - + bus = dbus.SessionBus() bus_object = bus.get_object(_SHELL_SERVICE, _SHELL_PATH) self._shell = dbus.Interface(bus_object, _SHELL_IFACE) diff --git a/src/sugar/activity/activityhandle.py b/src/sugar/activity/activityhandle.py index f255fd50..7240e3c5 100644 --- a/src/sugar/activity/activityhandle.py +++ b/src/sugar/activity/activityhandle.py @@ -25,25 +25,25 @@ class ActivityHandle(object): self, activity_id=None, object_id=None, uri=None ): """Initialise the handle from activity_id - + activity_id -- unique id for the activity to be created - object_id -- identity of the journal object - associated with the activity. It was used by - the journal prototype implementation, might - change when we do the real one. - - When you resume an activity from the journal - the object_id will be passed in. It's optional - since new activities does not have an + object_id -- identity of the journal object + associated with the activity. It was used by + the journal prototype implementation, might + change when we do the real one. + + When you resume an activity from the journal + the object_id will be passed in. It's optional + since new activities does not have an associated object (yet). - + XXX Not clear how this relates to the activity id yet, i.e. not sure we really need both. TBF - uri -- URI associated with the activity. Used when - opening an external file or resource in the - activity, rather than a journal object - (downloads stored on the file system for + uri -- URI associated with the activity. Used when + opening an external file or resource in the + activity, rather than a journal object + (downloads stored on the file system for example or web pages) """ self.activity_id = activity_id diff --git a/src/sugar/activity/activityservice.py b/src/sugar/activity/activityservice.py index 20cf7fef..1e5d2ea1 100644 --- a/src/sugar/activity/activityservice.py +++ b/src/sugar/activity/activityservice.py @@ -30,20 +30,20 @@ _ACTIVITY_INTERFACE = "org.laptop.Activity" class ActivityService(dbus.service.Object): """Base dbus service object that each Activity uses to export dbus methods. - + The dbus service is separate from the actual Activity object so that we can tightly control what stuff passes through the dbus python bindings.""" def __init__(self, activity): """Initialise the service for the given activity - + activity -- sugar.activity.activity.Activity instance - + Creates dbus services that use the instance's activity_id - as discriminants among all active services - of this type. That is, the services are all available + as discriminants among all active services + of this type. That is, the services are all available as names/paths derived from the instance's activity_id. - + The various methods exposed on dbus are just forwarded to the client Activity object's equally-named methods. """ diff --git a/src/sugar/activity/bundlebuilder.py b/src/sugar/activity/bundlebuilder.py index 555fe981..b11c7d06 100644 --- a/src/sugar/activity/bundlebuilder.py +++ b/src/sugar/activity/bundlebuilder.py @@ -36,7 +36,7 @@ from sugar.bundle.activitybundle import ActivityBundle IGNORE_DIRS = ['dist', '.git'] IGNORE_FILES = ['.gitignore', 'MANIFEST', '*.pyc', '*~', '*.bak', 'pseudo.po'] - + def list_files(base_dir, ignore_dirs=None, ignore_files=None): result = [] @@ -46,7 +46,7 @@ def list_files(base_dir, ignore_dirs=None, ignore_files=None): if ignore_files: for pattern in ignore_files: files = [f for f in files if not fnmatch(f, pattern)] - + rel_path = root[len(base_dir) + 1:] for f in files: result.append(os.path.join(rel_path, f)) @@ -83,7 +83,7 @@ class Config(object): self.bundle_name = reduce(lambda x, y:x+y, self.activity_name.split()) self.bundle_root_dir = self.bundle_name + '.activity' self.tar_root_dir = '%s-%d' % (self.bundle_name, self.version) - + if self.dist_name: self.xo_name = self.tar_name = self.dist_name else: @@ -103,7 +103,7 @@ class Builder(object): if not self.config.bundle.is_dir(po_dir): logging.warn("Missing po/ dir, cannot build_locale") return - + locale_dir = os.path.join(self.config.source_dir, 'locale') if os.path.exists(locale_dir): @@ -154,15 +154,15 @@ class Builder(object): missing_files.append(path) return missing_files - + def fix_manifest(self): self.build() manifest = self.config.bundle.manifest - + for path in self.check_manifest(): manifest.append(path) - + f = open(os.path.join(self.config.source_dir, "MANIFEST"), "wb") for line in manifest: f.write(line + "\n") @@ -186,7 +186,7 @@ class XOPackager(Packager): def package(self): bundle_zip = zipfile.ZipFile(self.package_path, 'w', zipfile.ZIP_DEFLATED) - + missing_files = self.builder.check_manifest() if missing_files: logging.warn('These files are not included in the manifest ' \ @@ -207,14 +207,14 @@ class SourcePackager(Packager): self.config.tar_name) def get_files(self): - git_ls = subprocess.Popen(['git', 'ls-files'], stdout=subprocess.PIPE, + git_ls = subprocess.Popen(['git', 'ls-files'], stdout=subprocess.PIPE, cwd=self.config.source_dir) stdout, _ = git_ls.communicate() if git_ls.returncode : # Fall back to filtered list return list_files(self.config.source_dir, IGNORE_DIRS, IGNORE_FILES) - + return [path.strip() for path in stdout.strip('\n').split('\n')] def package(self): @@ -286,7 +286,7 @@ def cmd_dist_xo(config, args): if args: print 'Usage: %prog dist_xo' return - + packager = XOPackager(Builder(config)) packager.package() diff --git a/src/sugar/activity/main.py b/src/sugar/activity/main.py index 721595cb..168b2f4d 100644 --- a/src/sugar/activity/main.py +++ b/src/sugar/activity/main.py @@ -43,7 +43,7 @@ def get_single_process_path(bundle_id): class SingleProcess(dbus.service.Object): def __init__(self, name_service, constructor): self.constructor = constructor - + bus = dbus.SessionBus() bus_name = dbus.service.BusName(name_service, bus=bus) object_path = get_single_process_path(name_service) @@ -77,7 +77,7 @@ def main(): if len(args) == 0: print 'A python class must be specified as first argument.' - sys.exit(1) + sys.exit(1) bundle_path = os.environ['SUGAR_BUNDLE_PATH'] sys.path.append(bundle_path) @@ -102,7 +102,7 @@ def main(): module_name = splitted_module[0] class_name = splitted_module[1] - module = __import__(module_name) + module = __import__(module_name) for comp in module_name.split('.')[1:]: module = getattr(module, comp) diff --git a/src/sugar/activity/namingalert.py b/src/sugar/activity/namingalert.py index 11b76886..18e84a79 100644 --- a/src/sugar/activity/namingalert.py +++ b/src/sugar/activity/namingalert.py @@ -69,7 +69,7 @@ class NamingToolbar(gtk.Toolbar): client = gconf.client_get_default() color = XoColor(client.get_string('/desktop/sugar/user/color')) icon = Icon() - icon.set_from_icon_name('activity-journal', + icon.set_from_icon_name('activity-journal', gtk.ICON_SIZE_LARGE_TOOLBAR) icon.props.xo_color = color self._add_widget(icon) @@ -78,7 +78,7 @@ class NamingToolbar(gtk.Toolbar): self._title = gtk.Label(_('Name this entry')) self._add_widget(self._title) - + self._add_separator(True) self._keep_button = ToolButton('dialog-ok', tooltip=_('Keep')) @@ -170,7 +170,7 @@ class NamingAlert(gtk.Window): width = gtk.gdk.screen_width() - offset * 2 height = gtk.gdk.screen_height() - offset * 2 self.set_size_request(width, height) - self.set_position(gtk.WIN_POS_CENTER_ALWAYS) + self.set_position(gtk.WIN_POS_CENTER_ALWAYS) self.set_decorated(False) self.set_resizable(False) self.set_modal(True) @@ -230,13 +230,13 @@ class NamingAlert(gtk.Window): self._favorite_icon = self._create_favorite_icon() header.append(self._favorite_icon) - + entry_icon = self._create_entry_icon() header.append(entry_icon) - + self._title = self._create_title() header.append(self._title, hippo.PACK_EXPAND) - + if gtk.widget_get_default_direction() == gtk.TEXT_DIR_RTL: header.reverse() @@ -251,7 +251,7 @@ class NamingAlert(gtk.Window): def _create_favorite_icon(self): favorite_icon = FavoriteIcon(False) return favorite_icon - + def _create_entry_icon(self): bundle_id = self._activity.metadata.get('activity', '') if not bundle_id: @@ -259,7 +259,7 @@ class NamingAlert(gtk.Window): if bundle_id == '': file_name = _get_icon_name(self._activity.metadata) - else: + else: activity_bundle = ActivityBundle(self._bundle_path) file_name = activity_bundle.get_icon() entry_icon = CanvasIcon(file_name=file_name) @@ -268,7 +268,7 @@ class NamingAlert(gtk.Window): entry_icon.props.xo_color = XoColor( \ self._activity.metadata['icon-color']) return entry_icon - + def _create_title(self): title = CanvasEntry() title.set_background(style.COLOR_WHITE.get_html()) @@ -302,7 +302,7 @@ class NamingAlert(gtk.Window): def _create_tags(self): vbox = hippo.CanvasBox() vbox.props.spacing = style.DEFAULT_SPACING - + text = hippo.CanvasText(text=_('Tags:'), font_desc=style.FONT_NORMAL.get_pango_desc()) text.props.color = style.COLOR_BUTTON_GREY.get_int() @@ -313,7 +313,7 @@ class NamingAlert(gtk.Window): text.props.xalign = hippo.ALIGNMENT_START vbox.append(text) - + tags = self._activity.metadata.get('tags', '') text_view = CanvasTextView(tags, box_height=style.GRID_CELL_SIZE * 2) vbox.append(text_view, hippo.PACK_EXPAND) diff --git a/src/sugar/bundle/activitybundle.py b/src/sugar/bundle/activitybundle.py index f38d70cc..7600847c 100644 --- a/src/sugar/bundle/activitybundle.py +++ b/src/sugar/bundle/activitybundle.py @@ -33,7 +33,7 @@ from sugar.bundle.bundle import Bundle, \ class ActivityBundle(Bundle): """A Sugar activity bundle - + See http://wiki.laptop.org/go/Activity_bundles for details """ @@ -48,7 +48,7 @@ class ActivityBundle(Bundle): Bundle.__init__(self, path) self.activity_class = None self.bundle_exec = None - + self._name = None self._icon = None self._bundle_id = None @@ -83,16 +83,16 @@ class ActivityBundle(Bundle): if not f: logging.warning("Activity directory lacks a MANIFEST file.") return [] - - ret = [line.strip() for line in f.readlines()] + + ret = [line.strip() for line in f.readlines()] f.close() return ret - + def _read_manifest(self): """return a list with the lines in MANIFEST, with invalid lines replaced by empty lines. - - Since absolute order carries information on file history, it should + + Since absolute order carries information on file history, it should be preserved. For instance, when renaming a file, you should leave the new name on the same line as the old one. """ @@ -113,13 +113,13 @@ class ActivityBundle(Bundle): logging.warning('Bundle %s: duplicate entry in MANIFEST: %s', self._name, line) continue - + # Remove MANIFEST if line == "MANIFEST": lines[num] = "" logging.warning('Bundle %s: MANIFEST includes itself: %s', self._name, line) - + # Remove invalid files if not self.is_file(line): lines[num] = "" @@ -127,7 +127,7 @@ class ActivityBundle(Bundle): self._name, line) return lines - + def get_files(self, manifest = None): files = [line for line in (manifest or self.manifest) if line] @@ -135,7 +135,7 @@ class ActivityBundle(Bundle): files.append('MANIFEST') return files - + def _parse_info(self, info_file): cp = ConfigParser() cp.readfp(info_file) @@ -260,7 +260,7 @@ class ActivityBundle(Bundle): return os.path.join(self._path, icon_path) else: icon_data = self.get_file(icon_path).read() - temp_file, temp_file_path = tempfile.mkstemp(prefix=self._icon, + temp_file, temp_file_path = tempfile.mkstemp(prefix=self._icon, suffix='.svg') os.write(temp_file, icon_data) os.close(temp_file) @@ -298,7 +298,7 @@ class ActivityBundle(Bundle): self._unzip(install_dir) install_path = os.path.join(install_dir, self._zip_root_dir) - + # List installed files manifestfiles = self.get_files(self._raw_manifest()) paths = [] @@ -306,7 +306,7 @@ class ActivityBundle(Bundle): rel_path = root[len(install_path) + 1:] for f in files: paths.append(os.path.join(rel_path, f)) - + # Check the list against the MANIFEST for path in paths: if path in manifestfiles: @@ -316,7 +316,7 @@ class ActivityBundle(Bundle): path) if strict_manifest: os.remove(os.path.join(install_path, path)) - + # Is anything in MANIFEST left over after accounting for all files? if manifestfiles: err = ("Bundle %s: files in MANIFEST not included: %s"% diff --git a/src/sugar/bundle/bundle.py b/src/sugar/bundle/bundle.py index 5979d5b4..44037e88 100644 --- a/src/sugar/bundle/bundle.py +++ b/src/sugar/bundle/bundle.py @@ -46,7 +46,7 @@ class MalformedBundleException(Exception): class Bundle(object): """A Sugar activity, content module, etc. - + The bundle itself may be either a zip file or a directory hierarchy, with metadata about the bundle stored various files inside it. @@ -71,7 +71,7 @@ class Bundle(object): # manifest = self._get_file(self._infodir + '/contents') # if manifest is None: # raise MalformedBundleException('No manifest file') - # + # # signature = self._get_file(self._infodir + '/contents.sig') # if signature is None: # raise MalformedBundleException('No signature file') @@ -124,7 +124,7 @@ class Bundle(object): logging.debug('%s not found.', filename) return f - + def is_file(self, filename): if self._zip_file is None: path = os.path.join(self._path, filename) diff --git a/src/sugar/datastore/datastore.py b/src/sugar/datastore/datastore.py index 1217c6ae..39dd8a68 100644 --- a/src/sugar/datastore/datastore.py +++ b/src/sugar/datastore/datastore.py @@ -41,7 +41,7 @@ class DSMetadata(gobject.GObject): self._props = {} else: self._props = props - + default_keys = ['activity', 'activity_id', 'mime_type', 'title_set_by_user'] for key in default_keys: @@ -61,13 +61,13 @@ class DSMetadata(gobject.GObject): def __contains__(self, key): return self._props.__contains__(key) - + def has_key(self, key): return self._props.has_key(key) def keys(self): return self._props.keys() - + def get_dictionary(self): return self._props @@ -93,7 +93,7 @@ class DSObject(object): metadata = DSMetadata(dbus_helpers.get_properties(self.object_id)) self._metadata = metadata return self._metadata - + def set_metadata(self, metadata): if self._metadata != metadata: self._metadata = metadata @@ -105,7 +105,7 @@ class DSObject(object): self.set_file_path(dbus_helpers.get_filename(self.object_id)) self._owns_file = True return self._file_path - + def set_file_path(self, file_path): if self._file_path != file_path: if self._file_path and self._owns_file: @@ -203,10 +203,10 @@ def find(query, sorting=None, limit=None, offset=None, properties=None, query['limit'] = limit if offset: query['offset'] = offset - + props_list, total_count = dbus_helpers.find(query, properties, reply_handler, error_handler) - + objects = [] for props in props_list: object_id = props['uid'] diff --git a/src/sugar/datastore/dbus_helpers.py b/src/sugar/datastore/dbus_helpers.py index 94bf68a5..37223fe5 100644 --- a/src/sugar/datastore/dbus_helpers.py +++ b/src/sugar/datastore/dbus_helpers.py @@ -67,7 +67,7 @@ def update(uid, properties, filename, transfer_ownership=False, def delete(uid): logging.debug('dbus_helpers.delete: %r', uid) _get_data_store().delete(uid) - + def get_properties(uid): logging.debug('dbus_helpers.get_properties: %s', uid) return _get_data_store().get_properties(uid, byte_arrays=True) diff --git a/src/sugar/eggaccelerators.c b/src/sugar/eggaccelerators.c index 0a39d519..0487db09 100644 --- a/src/sugar/eggaccelerators.c +++ b/src/sugar/eggaccelerators.c @@ -205,7 +205,7 @@ is_keycode (const gchar *string) * can represent various keyboard keys (numlock, meta, hyper, etc.), * the virtual modifier represents the keyboard key, the concrete * modifier the actual Mod2-Mod5 bits in the key press event. - * + * * Returns: %TRUE on success. */ gboolean @@ -218,7 +218,7 @@ egg_accelerator_parse_virtual (const gchar *accelerator, GdkModifierType mods; gint len; gboolean bad_keyval; - + if (accelerator_key) *accelerator_key = 0; if (accelerator_mods) @@ -229,7 +229,7 @@ egg_accelerator_parse_virtual (const gchar *accelerator, g_return_val_if_fail (accelerator != NULL, FALSE); bad_keyval = FALSE; - + keyval = 0; mods = 0; len = strlen (accelerator); @@ -312,7 +312,7 @@ egg_accelerator_parse_virtual (const gchar *accelerator, else { gchar last_ch; - + last_ch = *accelerator; while (last_ch && last_ch != '>') { @@ -359,7 +359,7 @@ egg_accelerator_parse_virtual (const gchar *accelerator, len -= len; } } - + if (accelerator_key) *accelerator_key = gdk_keyval_to_lower (keyval); if (accelerator_mods) @@ -374,7 +374,7 @@ egg_accelerator_parse_virtual (const gchar *accelerator, * @accelerator_key: accelerator keyval * @accelerator_mods: accelerator modifier mask * @returns: a newly-allocated accelerator name - * + * * Converts an accelerator keyval and modifier mask * into a string parseable by egg_accelerator_parse_virtual(). * For example, if you pass in #GDK_q and #EGG_VIRTUAL_CONTROL_MASK, @@ -499,7 +499,7 @@ egg_virtual_accelerator_name (guint accelerator_key, strcpy (accelerator + l, text_super); l += sizeof (text_super) - 1; } - + strcpy (accelerator + l, keyval_name); return accelerator; @@ -516,11 +516,11 @@ egg_keymap_resolve_virtual_modifiers (GdkKeymap *keymap, g_return_if_fail (GDK_IS_KEYMAP (keymap)); g_return_if_fail (concrete_mods != NULL); - + modmap = egg_keymap_get_modmap (keymap); - + /* Not so sure about this algorithm. */ - + concrete = 0; i = 0; while (i < EGG_MODMAP_ENTRY_LAST) @@ -542,14 +542,14 @@ egg_keymap_virtualize_modifiers (GdkKeymap *keymap, GdkModifierType virtual; int i; const EggModmap *modmap; - + g_return_if_fail (GDK_IS_KEYMAP (keymap)); g_return_if_fail (virtual_mods != NULL); modmap = egg_keymap_get_modmap (keymap); - + /* Not so sure about this algorithm. */ - + virtual = 0; i = 0; while (i < EGG_MODMAP_ENTRY_LAST) @@ -557,12 +557,12 @@ egg_keymap_virtualize_modifiers (GdkKeymap *keymap, if ((1 << i) & concrete_mods) { EggVirtualModifierType cleaned; - + cleaned = modmap->mapping[i] & ~(EGG_VIRTUAL_MOD2_MASK | EGG_VIRTUAL_MOD3_MASK | EGG_VIRTUAL_MOD4_MASK | EGG_VIRTUAL_MOD5_MASK); - + if (cleaned != 0) { virtual |= cleaned; @@ -575,10 +575,10 @@ egg_keymap_virtualize_modifiers (GdkKeymap *keymap, virtual |= modmap->mapping[i]; } } - + ++i; } - + *virtual_mods = virtual; } @@ -594,7 +594,7 @@ reload_modmap (GdkKeymap *keymap, xmodmap = XGetModifierMapping (gdk_x11_get_default_xdisplay ()); memset (modmap->mapping, 0, sizeof (modmap->mapping)); - + /* there are 8 modifiers, and the first 3 are shift, shift lock, * and control */ @@ -611,7 +611,7 @@ reload_modmap (GdkKeymap *keymap, int n_entries; int j; EggVirtualModifierType mask; - + keys = NULL; keyvals = NULL; n_entries = 0; @@ -619,11 +619,11 @@ reload_modmap (GdkKeymap *keymap, gdk_keymap_get_entries_for_keycode (keymap, keycode, &keys, &keyvals, &n_entries); - + mask = 0; j = 0; while (j < n_entries) - { + { if (keyvals[j] == GDK_Num_Lock) mask |= EGG_VIRTUAL_NUM_LOCK_MASK; else if (keyvals[j] == GDK_Scroll_Lock) @@ -639,19 +639,19 @@ reload_modmap (GdkKeymap *keymap, mask |= EGG_VIRTUAL_SUPER_MASK; else if (keyvals[j] == GDK_Mode_switch) mask |= EGG_VIRTUAL_MODE_SWITCH_MASK; - + ++j; } /* Mod1Mask is 1 << 3 for example, i.e. the * fourth modifier, i / keyspermod is the modifier * index - */ + */ modmap->mapping[i/xmodmap->max_keypermod] |= mask; - + g_free (keyvals); - g_free (keys); - + g_free (keys); + ++i; } @@ -664,7 +664,7 @@ reload_modmap (GdkKeymap *keymap, modmap->mapping[EGG_MODMAP_ENTRY_MOD3] |= EGG_VIRTUAL_MOD3_MASK; modmap->mapping[EGG_MODMAP_ENTRY_MOD4] |= EGG_VIRTUAL_MOD4_MASK; modmap->mapping[EGG_MODMAP_ENTRY_MOD5] |= EGG_VIRTUAL_MOD5_MASK; - + XFreeModifiermap (xmodmap); } @@ -676,7 +676,7 @@ egg_keymap_get_modmap (GdkKeymap *keymap) /* This is all a hack, much simpler when we can just * modify GDK directly. */ - + modmap = g_object_get_data (G_OBJECT (keymap), "egg-modmap"); @@ -687,9 +687,9 @@ egg_keymap_get_modmap (GdkKeymap *keymap) /* FIXME modify keymap change events with an event filter * and force a reload if we get one */ - + reload_modmap (keymap, modmap); - + g_object_set_data_full (G_OBJECT (keymap), "egg-modmap", modmap, @@ -697,6 +697,6 @@ egg_keymap_get_modmap (GdkKeymap *keymap) } g_assert (modmap != NULL); - + return modmap; } diff --git a/src/sugar/eggaccelerators.h b/src/sugar/eggaccelerators.h index d2276d2b..96d53903 100644 --- a/src/sugar/eggaccelerators.h +++ b/src/sugar/eggaccelerators.h @@ -36,7 +36,7 @@ typedef enum EGG_VIRTUAL_CONTROL_MASK = 1 << 2, EGG_VIRTUAL_ALT_MASK = 1 << 3, /* fixed as Mod1 */ - + EGG_VIRTUAL_MOD2_MASK = 1 << 4, EGG_VIRTUAL_MOD3_MASK = 1 << 5, EGG_VIRTUAL_MOD4_MASK = 1 << 6, @@ -50,11 +50,11 @@ typedef enum GDK_BUTTON5_MASK = 1 << 12, /* 13, 14 are used by Xkb for the keyboard group */ #endif - + EGG_VIRTUAL_META_MASK = 1 << 24, EGG_VIRTUAL_SUPER_MASK = 1 << 25, EGG_VIRTUAL_HYPER_MASK = 1 << 26, - EGG_VIRTUAL_MODE_SWITCH_MASK = 1 << 27, + EGG_VIRTUAL_MODE_SWITCH_MASK = 1 << 27, EGG_VIRTUAL_NUM_LOCK_MASK = 1 << 28, EGG_VIRTUAL_SCROLL_LOCK_MASK = 1 << 29, @@ -63,7 +63,7 @@ typedef enum /* 28-31 24-27 20-23 16-19 12-15 8-11 4-7 0-3 * 7 f 0 0 0 0 f f - */ + */ EGG_VIRTUAL_MODIFIER_MASK = 0x7f0000ff } EggVirtualModifierType; diff --git a/src/sugar/eggdesktopfile.c b/src/sugar/eggdesktopfile.c index eb28b9d6..d095a2fb 100644 --- a/src/sugar/eggdesktopfile.c +++ b/src/sugar/eggdesktopfile.c @@ -155,7 +155,7 @@ egg_desktop_file_new_from_key_file (GKeyFile *key_file, g_key_file_free (key_file); return NULL; } - else + else g_free (version); } @@ -1334,7 +1334,7 @@ egg_desktop_file_launch (EggDesktopFile *desktop_file, EGG_DESKTOP_FILE_ERROR_NOT_LAUNCHABLE, _("Can't pass document URIs to a 'Type=Link' desktop entry")); return FALSE; - } + } if (!parse_link (desktop_file, &app_desktop_file, &documents, error)) return FALSE; @@ -1418,10 +1418,10 @@ egg_set_desktop_file (const char *desktop_file_path) /** * egg_get_desktop_file: - * + * * Gets the application's #EggDesktopFile, as set by * egg_set_desktop_file(). - * + * * Return value: the #EggDesktopFile, or %NULL if it hasn't been set. **/ EggDesktopFile * diff --git a/src/sugar/eggsmclient-xsmp.c b/src/sugar/eggsmclient-xsmp.c index 13eb5d5b..2a9532af 100644 --- a/src/sugar/eggsmclient-xsmp.c +++ b/src/sugar/eggsmclient-xsmp.c @@ -281,7 +281,7 @@ sm_client_xsmp_connect (gpointer user_data) if (xsmp->restart_style == SmRestartIfRunning) { - if (egg_desktop_file_get_boolean (desktop_file, + if (egg_desktop_file_get_boolean (desktop_file, "X-GNOME-AutoRestart", NULL)) xsmp->restart_style = SmRestartImmediately; } @@ -1120,7 +1120,7 @@ delete_properties (EggSMClientXSMP *xsmp, ...) * until you're done with the SmProp. */ static SmProp * -array_prop (const char *name, ...) +array_prop (const char *name, ...) { SmProp *prop; SmPropValue pv; @@ -1338,13 +1338,13 @@ ice_error_handler (IceConn ice_conn, IcePointer values) { /* Do nothing */ -} +} static void ice_io_error_handler (IceConn ice_conn) { /* Do nothing */ -} +} static void smc_error_handler (SmcConn smc_conn, diff --git a/src/sugar/eggsmclient.c b/src/sugar/eggsmclient.c index 86036f91..a59cea00 100644 --- a/src/sugar/eggsmclient.c +++ b/src/sugar/eggsmclient.c @@ -114,7 +114,7 @@ egg_sm_client_class_init (EggSMClientClass *klass) * handling this signal; if the user has requested that the session * be saved when logging out, then ::save_state will be emitted * separately. - * + * * If the application agrees to quit, it should then wait for either * the ::quit_cancelled or ::quit signals to be emitted. **/ diff --git a/src/sugar/graphics/alert.py b/src/sugar/graphics/alert.py index 2c3c4caf..b108d9dd 100644 --- a/src/sugar/graphics/alert.py +++ b/src/sugar/graphics/alert.py @@ -50,7 +50,7 @@ import gtk import gobject import hippo import math - + from sugar.graphics import style from sugar.graphics.icon import Icon @@ -111,24 +111,24 @@ class Alert(gtk.EventBox): self._msg_label.set_alignment(0, 0.5) self._msg_box.pack_start(self._msg_label, False) self._hbox.pack_start(self._msg_box, False) - + self._buttons_box = gtk.HButtonBox() self._buttons_box.set_layout(gtk.BUTTONBOX_END) self._buttons_box.set_spacing(style.DEFAULT_SPACING) self._hbox.pack_start(self._buttons_box) - + gobject.GObject.__init__(self, **kwargs) - self.set_visible_window(True) - self.add(self._hbox) + self.set_visible_window(True) + self.add(self._hbox) self._title_label.show() self._msg_label.show() self._buttons_box.show() self._msg_box.show() self._hbox.show() self.show() - - def do_set_property(self, pspec, value): + + def do_set_property(self, pspec, value): """ Set alert property @@ -299,21 +299,21 @@ class _TimeoutIcon(hippo.CanvasText, hippo.CanvasItem): def __init__(self, **kwargs): hippo.CanvasText.__init__(self, **kwargs) - + self.props.orientation = hippo.ORIENTATION_HORIZONTAL self.props.border_left = style.DEFAULT_SPACING self.props.border_right = style.DEFAULT_SPACING - + def do_paint_background(self, cr, damaged_box): [width, height] = self.get_allocation() - + xval = width * 0.5 yval = height * 0.5 - radius = min(width * 0.5, height * 0.5) - + radius = min(width * 0.5, height * 0.5) + hippo.cairo_set_source_rgba32(cr, self.props.background_color) - cr.arc(xval, yval, radius, 0, 2*math.pi) - cr.fill_preserve() + cr.arc(xval, yval, radius, 0, 2*math.pi) + cr.fill_preserve() class TimeoutAlert(Alert): @@ -362,22 +362,22 @@ class TimeoutAlert(Alert): Alert.__init__(self, **kwargs) self._timeout = timeout - + icon = Icon(icon_name='dialog-cancel') self.add_button(gtk.RESPONSE_CANCEL, _('Cancel'), icon) icon.show() - + self._timeout_text = _TimeoutIcon( text=self._timeout, color=style.COLOR_BUTTON_GREY.get_int(), - background_color=style.COLOR_WHITE.get_int()) + background_color=style.COLOR_WHITE.get_int()) canvas = hippo.Canvas() canvas.set_root(self._timeout_text) - canvas.show() + canvas.show() self.add_button(gtk.RESPONSE_OK, _('Continue'), canvas) gobject.timeout_add_seconds(1, self.__timeout) - + def __timeout(self): self._timeout -= 1 self._timeout_text.props.text = self._timeout diff --git a/src/sugar/graphics/animator.py b/src/sugar/graphics/animator.py index 5d5b3556..51c8ac34 100644 --- a/src/sugar/graphics/animator.py +++ b/src/sugar/graphics/animator.py @@ -31,7 +31,7 @@ class Animator(gobject.GObject): 'completed': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ([])), } - + def __init__(self, duration, fps=20, easing=EASE_OUT_EXPO): gobject.GObject.__init__(self) self._animations = [] diff --git a/src/sugar/graphics/canvastextview.py b/src/sugar/graphics/canvastextview.py index 481248db..4a2aaa49 100644 --- a/src/sugar/graphics/canvastextview.py +++ b/src/sugar/graphics/canvastextview.py @@ -29,11 +29,11 @@ class CanvasTextView(hippo.CanvasWidget): self.text_view_widget.props.right_margin = style.DEFAULT_SPACING self.text_view_widget.props.wrap_mode = gtk.WRAP_WORD self.text_view_widget.show() - + # TODO: These fields should expand vertically instead of scrolling scrolled_window = gtk.ScrolledWindow() scrolled_window.set_shadow_type(gtk.SHADOW_OUT) scrolled_window.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC) scrolled_window.add(self.text_view_widget) - + self.props.widget = scrolled_window diff --git a/src/sugar/graphics/colorbutton.py b/src/sugar/graphics/colorbutton.py index a5c7f0af..f69691cc 100644 --- a/src/sugar/graphics/colorbutton.py +++ b/src/sugar/graphics/colorbutton.py @@ -29,7 +29,7 @@ from sugar.graphics.palette import Palette, ToolInvoker, WidgetInvoker _ = lambda msg: gettext.dgettext('sugar-toolkit', msg) def get_svg_color_string(color): - return '#%.2X%.2X%.2X' % (color.red / 257, color.green / 257, + return '#%.2X%.2X%.2X' % (color.red / 257, color.green / 257, color.blue / 257) class _ColorButton(gtk.Button): @@ -40,11 +40,11 @@ class _ColorButton(gtk.Button): As a preview an sugar.graphics.Icon is used. The fill color will be set to the current color, and the stroke color is set to the font color. """ - + __gtype_name__ = 'SugarColorButton' __gsignals__ = { 'color-set' : (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, tuple())} - + def __init__(self, **kwargs): self._title = _('Choose a color') self._color = gtk.gdk.Color(0, 0, 0) @@ -92,10 +92,10 @@ class _ColorButton(gtk.Button): def __palette_color_set_cb(self, palette): self.emit('color-set') - + def __palette_color_changed(self, palette, pspec): self.color = self._palette.color - + def do_style_set(self, previous_style): self._preview.stroke_color = \ get_svg_color_string(self.style.fg[gtk.STATE_NORMAL]) @@ -111,12 +111,12 @@ class _ColorButton(gtk.Button): def set_color(self, color): assert isinstance(color, gtk.gdk.Color) - + if self._color.red == color.red and \ self._color.green == color.green and \ self._color.blue == color.blue: return - + self._color = gtk.gdk.Color(color.red, color.green, color.blue) self._preview.fill_color = get_svg_color_string(self._color) if self._palette: @@ -201,9 +201,9 @@ class _ColorButton(gtk.Button): red = self._color.red / 257 green = self._color.green / 257 blue = self._color.blue / 257 - + pixbuf.fill(red << 24 + green << 16 + blue << 8 + 0xff) - + context.set_icon_pixbuf(pixbuf) def __drag_data_get_cb(self, widget, context, selection_data, info, time): @@ -258,7 +258,7 @@ class _ColorPalette(Palette): self._picker_hbox.pack_start(self._swatch_tray) self._picker_hbox.pack_start(gtk.VSeparator(), padding=style.DEFAULT_SPACING) - + self._chooser_table = gtk.Table(3, 2) self._chooser_table.set_col_spacing(0, style.DEFAULT_PADDING) @@ -271,7 +271,7 @@ class _ColorPalette(Palette): self._create_color_scale(_('Blue'), self._BLUE, 2)) self._picker_hbox.add(self._chooser_table) - + self._picker_hbox.show_all() self._build_swatches() @@ -300,7 +300,7 @@ class _ColorPalette(Palette): return scale - + def _build_swatches(self): for child in self._swatch_tray.get_children(): @@ -370,12 +370,12 @@ class _ColorPalette(Palette): return self._color = color.copy() - + if self._scales: self._scales[self._RED].set_value(self._color.red / 65535.0) self._scales[self._GREEN].set_value(self._color.green / 65535.0) self._scales[self._BLUE].set_value(self._color.blue / 65535.0) - + self.notify('color') def get_color(self): diff --git a/src/sugar/graphics/combobox.py b/src/sugar/graphics/combobox.py index 4e094ab4..fe18087b 100644 --- a/src/sugar/graphics/combobox.py +++ b/src/sugar/graphics/combobox.py @@ -23,7 +23,7 @@ import gobject import gtk class ComboBox(gtk.ComboBox): - __gtype_name__ = 'SugarComboBox' + __gtype_name__ = 'SugarComboBox' def __init__(self): gtk.ComboBox.__init__(self) @@ -129,7 +129,7 @@ class ComboBox(gtk.ComboBox): None """ - self._model.append([0, None, None, True]) + self._model.append([0, None, None, True]) def get_active_item(self): """ diff --git a/src/sugar/graphics/icon.py b/src/sugar/graphics/icon.py index 6f5a1678..cc6c8d2f 100644 --- a/src/sugar/graphics/icon.py +++ b/src/sugar/graphics/icon.py @@ -337,10 +337,10 @@ class Icon(gtk.Image): if self._buffer.file_name != self.props.file: self._buffer.file_name = self.props.file - if self.props.pixel_size == -1: + if self.props.pixel_size == -1: width, height = gtk.icon_size_lookup(self.props.icon_size) else: - width = height = self.props.pixel_size + width = height = self.props.pixel_size if self._buffer.width != width or self._buffer.height != height: self._buffer.width = width self._buffer.height = height @@ -917,7 +917,7 @@ class CanvasIcon(hippo.CanvasBox, hippo.CanvasItem): def get_palette_invoker(self): return self._palette_invoker - + def set_palette_invoker(self, palette_invoker): self._palette_invoker.detach() self._palette_invoker = palette_invoker @@ -929,7 +929,7 @@ class CanvasIcon(hippo.CanvasBox, hippo.CanvasItem): from sugar.graphics.palette import Palette self.set_palette(Palette(text)) - + palette = property(get_palette, set_palette) class CellRendererIcon(gtk.GenericCellRenderer): @@ -1019,7 +1019,7 @@ class CellRendererIcon(gtk.GenericCellRenderer): if self._buffer.background_color != value: self._buffer.background_color = value - background_color = gobject.property(type=object, + background_color = gobject.property(type=object, setter=set_background_color) def set_size(self, value): diff --git a/src/sugar/graphics/notebook.py b/src/sugar/graphics/notebook.py index 4965b249..65d35224 100644 --- a/src/sugar/graphics/notebook.py +++ b/src/sugar/graphics/notebook.py @@ -17,7 +17,7 @@ """Notebook class -This class create a gtk.Notebook() widget supporting +This class create a gtk.Notebook() widget supporting a close button in every tab when the 'can-close-tabs' gproperty is enabled (True) @@ -38,11 +38,11 @@ class Notebook(gtk.Notebook): def __init__(self, **kwargs): # Initialise the Widget - # - # Side effects: + + # Side effects: # Set the 'can-close-tabs' property using **kwargs # Set True the scrollable notebook property - + gobject.GObject.__init__(self, **kwargs) self._can_close_tabs = None @@ -108,7 +108,7 @@ class Notebook(gtk.Notebook): tab_box.show_all() event_box.add(tab_box) - + return event_box def add_page(self, text_label, widget): @@ -130,16 +130,16 @@ class Notebook(gtk.Notebook): # Add a new page to the notebook if self._can_close_tabs: eventbox = self._create_custom_tab(text_label, widget) - self.append_page(widget, eventbox) + self.append_page(widget, eventbox) else: self.append_page(widget, gtk.Label(text_label)) - + pages = self.get_n_pages() # Set the new page self.set_current_page(pages - 1) self.show_all() - + return True def _close_page(self, button, child): diff --git a/src/sugar/graphics/objectchooser.py b/src/sugar/graphics/objectchooser.py index aa46738b..582ac62e 100644 --- a/src/sugar/graphics/objectchooser.py +++ b/src/sugar/graphics/objectchooser.py @@ -56,7 +56,7 @@ class ObjectChooser(object): self._chooser_id = None self._response_code = gtk.RESPONSE_NONE self._what_filter = what_filter - + def run(self): self._object_id = None diff --git a/src/sugar/graphics/palette.py b/src/sugar/graphics/palette.py index bb2c6552..f6133060 100644 --- a/src/sugar/graphics/palette.py +++ b/src/sugar/graphics/palette.py @@ -45,7 +45,7 @@ class Palette(PaletteWindow): __gtype_name__ = 'SugarPalette' - # DEPRECATED: label is passed with the primary-text property, accel_path + # DEPRECATED: label is passed with the primary-text property, accel_path # is set via the invoker property, and menu_after_content is not used def __init__(self, label=None, accel_path=None, menu_after_content=False, text_maxlen=60, **kwargs): @@ -67,9 +67,9 @@ class Palette(PaletteWindow): primary_box.pack_start(self._icon_box, expand=False) labels_box = gtk.VBox() - self._label_alignment = gtk.Alignment(xalign=0, yalign=0.5, + self._label_alignment = gtk.Alignment(xalign=0, yalign=0.5, xscale=1, yscale=0.33) - self._label_alignment.set_padding(0, 0, style.DEFAULT_SPACING, + self._label_alignment.set_padding(0, 0, style.DEFAULT_SPACING, style.DEFAULT_SPACING) self._label_alignment.add(labels_box) self._label_alignment.show() @@ -182,7 +182,7 @@ class Palette(PaletteWindow): if self._invoker is not None: self._update_full_request() - + PaletteWindow.popup(self, immediate) if state is None: @@ -194,7 +194,7 @@ class Palette(PaletteWindow): def on_enter(self, event): PaletteWindow.on_enter(self, event) self._secondary_anim.start() - + def _add_menu(self): self._menu_box = gtk.VBox() self._secondary_box.pack_start(self._menu_box) diff --git a/src/sugar/graphics/palettegroup.py b/src/sugar/graphics/palettegroup.py index e95b5aa7..d3bccb5f 100644 --- a/src/sugar/graphics/palettegroup.py +++ b/src/sugar/graphics/palettegroup.py @@ -76,7 +76,7 @@ class Group(gobject.GObject): def popdown(self): for palette in self._palettes: - if palette.is_up(): + if palette.is_up(): palette.popdown(immediate=True) def _palette_popup_cb(self, palette): diff --git a/src/sugar/graphics/palettewindow.py b/src/sugar/graphics/palettewindow.py index 96e4da19..d3fe2cbc 100644 --- a/src/sugar/graphics/palettewindow.py +++ b/src/sugar/graphics/palettewindow.py @@ -47,7 +47,7 @@ def _calculate_gap(a, b): gap_side = gtk.POS_TOP else: gap = False - + if gap: if gap_side == gtk.POS_BOTTOM or gap_side == gtk.POS_TOP: gap_start = min(a.width, max(0, b.x - a.x)) @@ -181,7 +181,7 @@ class PaletteWindow(gtk.Window): self.set_group_id(None) def set_invoker(self, invoker): - for hid in self._invoker_hids[:]: + for hid in self._invoker_hids[:]: self._invoker.disconnect(hid) self._invoker_hids.remove(hid) @@ -212,7 +212,7 @@ class PaletteWindow(gtk.Window): immediate = False if self.is_up(): - self._popdown_anim.stop() + self._popdown_anim.stop() return if self._group_id: @@ -629,7 +629,7 @@ class Invoker(gobject.GObject): def get_palette(self): return self._palette - + def set_palette(self, palette): if self._palette: self._palette.props.invoker = None @@ -787,7 +787,7 @@ class CanvasInvoker(Invoker): return gtk.gdk.Rectangle(x, y, width, height) else: return gtk.gdk.Rectangle() - + def __motion_notify_event_cb(self, button, event): if event.detail == hippo.MOTION_DETAIL_ENTER: self.notify_mouse_enter() diff --git a/src/sugar/graphics/radiotoolbutton.py b/src/sugar/graphics/radiotoolbutton.py index 11f962d8..72642326 100644 --- a/src/sugar/graphics/radiotoolbutton.py +++ b/src/sugar/graphics/radiotoolbutton.py @@ -154,7 +154,7 @@ class RadioToolButton(gtk.RadioToolButton): def get_palette_invoker(self): return self._palette_invoker - + def set_palette_invoker(self, palette_invoker): self._palette_invoker.detach() self._palette_invoker = palette_invoker diff --git a/src/sugar/graphics/roundbox.py b/src/sugar/graphics/roundbox.py index 28644bce..b909c741 100644 --- a/src/sugar/graphics/roundbox.py +++ b/src/sugar/graphics/roundbox.py @@ -35,13 +35,13 @@ class CanvasRoundBox(hippo.CanvasBox, hippo.CanvasItem): # TODO: we should calculate radius depending on the height of the box. self._radius = style.zoom(10) - + self.props.orientation = hippo.ORIENTATION_HORIZONTAL self.props.border = self._BORDER_DEFAULT self.props.border_left = self._radius self.props.border_right = self._radius self.props.border_color = style.COLOR_BLACK.get_int() - + def do_paint_background(self, cr, damaged_box): [width, height] = self.get_allocation() diff --git a/src/sugar/graphics/toggletoolbutton.py b/src/sugar/graphics/toggletoolbutton.py index 9bb2f585..0aeb59ca 100644 --- a/src/sugar/graphics/toggletoolbutton.py +++ b/src/sugar/graphics/toggletoolbutton.py @@ -59,7 +59,7 @@ class ToggleToolButton(gtk.ToggleToolButton): def get_palette_invoker(self): return self._palette_invoker - + def set_palette_invoker(self, palette_invoker): self._palette_invoker.detach() self._palette_invoker = palette_invoker @@ -69,7 +69,7 @@ class ToggleToolButton(gtk.ToggleToolButton): def set_tooltip(self, text): self.set_palette(Palette(text)) - + def do_expose_event(self, event): allocation = self.get_allocation() child = self.get_child() @@ -85,5 +85,5 @@ class ToggleToolButton(gtk.ToggleToolButton): allocation.width, allocation.height) gtk.ToggleToolButton.do_expose_event(self, event) - + palette = property(get_palette, set_palette) diff --git a/src/sugar/graphics/toolbarbox.py b/src/sugar/graphics/toolbarbox.py index fb35bb1b..266e6be4 100644 --- a/src/sugar/graphics/toolbarbox.py +++ b/src/sugar/graphics/toolbarbox.py @@ -27,7 +27,7 @@ from sugar.graphics import palettegroup class ToolbarButton(ToolButton): def __init__(self, page=None, **kwargs): ToolButton.__init__(self, **kwargs) - + self.page_widget = None self.set_page(page) diff --git a/src/sugar/graphics/toolbox.py b/src/sugar/graphics/toolbox.py index 1cfbe933..47a311d0 100644 --- a/src/sugar/graphics/toolbox.py +++ b/src/sugar/graphics/toolbox.py @@ -36,7 +36,7 @@ class Toolbox(gtk.VBox): def __init__(self): gtk.VBox.__init__(self) - + self._notebook = gtk.Notebook() self._notebook.set_tab_pos(gtk.POS_BOTTOM) self._notebook.set_show_border(False) @@ -55,12 +55,12 @@ class Toolbox(gtk.VBox): border_bottom=style.LINE_WIDTH) self._separator.set_root(box) self.pack_start(self._separator, False) - + self._notebook.connect('notify::page', self._notify_page_cb) def _notify_page_cb(self, notebook, pspec): self.emit('current-toolbar-changed', notebook.props.page) - + def add_toolbar(self, name, toolbar): label = gtk.Label(name) width, height_ = label.size_request() @@ -68,7 +68,7 @@ class Toolbox(gtk.VBox): label.set_alignment(0.0, 0.5) event_box = gtk.EventBox() - + alignment = gtk.Alignment(0.0, 0.0, 1.0, 1.0) alignment.set_padding(0, 0, style.TOOLBOX_HORIZONTAL_PADDING, style.TOOLBOX_HORIZONTAL_PADDING) @@ -83,7 +83,7 @@ class Toolbox(gtk.VBox): if self._notebook.get_n_pages() > 1: self._notebook.set_show_tabs(True) self._separator.show() - + def remove_toolbar(self, index): self._notebook.remove_page(index) @@ -96,6 +96,6 @@ class Toolbox(gtk.VBox): def get_current_toolbar(self): return self._notebook.get_current_page() - + current_toolbar = property(get_current_toolbar, set_current_toolbar) diff --git a/src/sugar/graphics/toolbutton.py b/src/sugar/graphics/toolbutton.py index 047df067..7def0ff7 100644 --- a/src/sugar/graphics/toolbutton.py +++ b/src/sugar/graphics/toolbutton.py @@ -128,7 +128,7 @@ class ToolButton(gtk.ToolButton): def get_palette_invoker(self): return self._palette_invoker - + def set_palette_invoker(self, palette_invoker): self._palette_invoker.detach() self._palette_invoker = palette_invoker diff --git a/src/sugar/graphics/tray.py b/src/sugar/graphics/tray.py index 5df71702..8b0abe78 100644 --- a/src/sugar/graphics/tray.py +++ b/src/sugar/graphics/tray.py @@ -64,7 +64,7 @@ class _TrayViewport(gtk.Viewport): adj = self.get_vadjustment() adj.connect('changed', self._adjustment_changed_cb) adj.connect('value-changed', self._adjustment_changed_cb) - + def scroll(self, direction): if direction == _PREVIOUS_PAGE: self._scroll_previous() @@ -447,7 +447,7 @@ class TrayIcon(gtk.ToolItem): def get_palette_invoker(self): return self._palette_invoker - + def set_palette_invoker(self, palette_invoker): self._palette_invoker.detach() self._palette_invoker = palette_invoker diff --git a/src/sugar/graphics/window.py b/src/sugar/graphics/window.py index 4b25bc00..6ab6ee16 100644 --- a/src/sugar/graphics/window.py +++ b/src/sugar/graphics/window.py @@ -86,12 +86,12 @@ class Window(gtk.Window): self.connect('realize', self.__window_realize_cb) self.connect('window-state-event', self.__window_state_event_cb) self.connect('key-press-event', self.__key_press_cb) - + self._toolbar_box = None self._alerts = [] self._canvas = None self.tray = None - + self._vbox = gtk.VBox() self._hbox = gtk.HBox() self._vbox.pack_start(self._hbox) @@ -100,7 +100,7 @@ class Window(gtk.Window): self._event_box = gtk.EventBox() self._hbox.pack_start(self._event_box) self._event_box.show() - self._event_box.add_events(gtk.gdk.POINTER_MOTION_HINT_MASK + self._event_box.add_events(gtk.gdk.POINTER_MOTION_HINT_MASK | gtk.gdk.POINTER_MOTION_MASK) self._event_box.connect('motion-notify-event', self.__motion_notify_cb) @@ -120,7 +120,7 @@ class Window(gtk.Window): if canvas: self._event_box.add(canvas) - + self._canvas = canvas def get_canvas(self): @@ -144,16 +144,16 @@ class Window(gtk.Window): def set_tray(self, tray, position): if self.tray: - box = self.tray.get_parent() + box = self.tray.get_parent() box.remove(self.tray) - + if position == gtk.POS_LEFT: self._hbox.pack_start(tray, False) elif position == gtk.POS_RIGHT: self._hbox.pack_end(tray, False) elif position == gtk.POS_BOTTOM: self._vbox.pack_end(tray, False) - + self.tray = tray def add_alert(self, alert): @@ -162,14 +162,14 @@ class Window(gtk.Window): self._vbox.pack_start(alert, False) if self._toolbar_box is not None: self._vbox.reorder_child(alert, 1) - else: + else: self._vbox.reorder_child(alert, 0) - + def remove_alert(self, alert): if alert in self._alerts: self._alerts.remove(alert) # if the alert is the visible one on top of the queue - if alert.get_parent() is not None: + if alert.get_parent() is not None: self._vbox.remove(alert) if len(self._alerts) >= 1: self._vbox.pack_start(self._alerts[0], False) @@ -177,7 +177,7 @@ class Window(gtk.Window): self._vbox.reorder_child(self._alerts[0], 1) else: self._vbox.reorder_child(self._alert[0], 0) - + def __window_realize_cb(self, window): group = gtk.Window() group.realize() diff --git a/src/sugar/gsm-app.c b/src/sugar/gsm-app.c index 3a63bacf..96b65ce8 100644 --- a/src/sugar/gsm-app.c +++ b/src/sugar/gsm-app.c @@ -315,7 +315,7 @@ gsm_app_provides (GsmApp *app, const char *service) return FALSE; } -static void +static void app_exited (GPid pid, gint status, gpointer data) { if (WIFEXITED (status)) diff --git a/src/sugar/gsm-app.h b/src/sugar/gsm-app.h index 32ee62d5..038caeea 100644 --- a/src/sugar/gsm-app.h +++ b/src/sugar/gsm-app.h @@ -63,7 +63,7 @@ pid_t gsm_app_launch (GsmApp *app, void gsm_app_set_client (GsmApp *app, GsmClient *client); -void gsm_app_registered (GsmApp *app); +void gsm_app_registered (GsmApp *app); G_END_DECLS diff --git a/src/sugar/gsm-client-xsmp.c b/src/sugar/gsm-client-xsmp.c index 04c7de47..632dec9e 100644 --- a/src/sugar/gsm-client-xsmp.c +++ b/src/sugar/gsm-client-xsmp.c @@ -192,7 +192,7 @@ register_client_callback (SmsConn conn, GsmClientXSMP *xsmp = manager_data; char *id; - g_debug ("Client '%s' received RegisterClient(%s)", + g_debug ("Client '%s' received RegisterClient(%s)", xsmp->description, previous_id ? previous_id : "NULL"); @@ -319,8 +319,8 @@ save_yourself_request_callback (SmsConn conn, if (shutdown && global) { g_debug (" initiating shutdown"); -/* gsm_session_initiate_shutdown (global_session, - !fast, +/* gsm_session_initiate_shutdown (global_session, + !fast, GSM_SESSION_LOGOUT_TYPE_LOGOUT); */ } @@ -333,7 +333,7 @@ save_yourself_request_callback (SmsConn conn, g_debug (" ignoring"); } -static void +static void xsmp_restart (GsmClient *client, GError **error) { char *restart_cmd = gsm_client_get_restart_command (client); @@ -555,7 +555,7 @@ delete_property (GsmClientXSMP *client, const char *name) prop = find_property (client, name, &index); if (!prop) - return; + return; #if 0 /* This is wrong anyway; we can't unconditionally run the current diff --git a/src/sugar/gsm-client.h b/src/sugar/gsm-client.h index 3e4e751f..4cfd7ed2 100644 --- a/src/sugar/gsm-client.h +++ b/src/sugar/gsm-client.h @@ -66,7 +66,7 @@ struct _GsmClientClass char * (*get_discard_command) (GsmClient *client); gboolean (*get_autorestart) (GsmClient *client); - void (*restart) (GsmClient *client, + void (*restart) (GsmClient *client, GError **error); void (*save_yourself) (GsmClient *client, gboolean save_state); diff --git a/src/sugar/gsm-session.c b/src/sugar/gsm-session.c index 0fe2fb53..fd3c52f8 100644 --- a/src/sugar/gsm-session.c +++ b/src/sugar/gsm-session.c @@ -120,8 +120,8 @@ gsm_session_class_init (GsmSessionClass *klass) /** * gsm_session_set_name: - * @session: session instance - * @name: name of the session + * @session: session instance + * @name: name of the session * * Sets the name of a running session. **/ @@ -231,7 +231,7 @@ gsm_session_register_client (GsmSession *session, const char *id) { GSList *a; - char *client_id = NULL; + char *client_id = NULL; /* If we're shutting down, we don't accept any new session clients. */ @@ -252,7 +252,7 @@ gsm_session_register_client (GsmSession *session, return NULL; } } - + client_id = g_strdup (id); } @@ -438,7 +438,7 @@ client_save_yourself_done (GsmClient *client, gpointer data) session->phase2_clients = g_slist_remove (session->phase2_clients, client); - if (session->phase == GSM_SESSION_PHASE_SHUTDOWN && + if (session->phase == GSM_SESSION_PHASE_SHUTDOWN && !session->shutdown_clients) { if (session->phase2_clients) @@ -471,7 +471,7 @@ client_disconnected (GsmClient *client, gpointer data) is_condition_client = TRUE; } - if (session->phase != GSM_SESSION_PHASE_SHUTDOWN && + if (session->phase != GSM_SESSION_PHASE_SHUTDOWN && gsm_client_get_autorestart (client) && !is_condition_client) { diff --git a/src/sugar/gsm-session.h b/src/sugar/gsm-session.h index d4880a9b..7b23b00a 100644 --- a/src/sugar/gsm-session.h +++ b/src/sugar/gsm-session.h @@ -39,25 +39,25 @@ extern GsmSession *global_session; typedef enum { /* gsm's own startup/initialization phase */ GSM_SESSION_PHASE_STARTUP, - + /* xrandr setup, gnome-settings-daemon, etc */ GSM_SESSION_PHASE_INITIALIZATION, - + /* window/compositing managers */ GSM_SESSION_PHASE_WINDOW_MANAGER, - + /* apps that will create _NET_WM_WINDOW_TYPE_PANEL windows */ GSM_SESSION_PHASE_PANEL, - + /* apps that will create _NET_WM_WINDOW_TYPE_DESKTOP windows */ GSM_SESSION_PHASE_DESKTOP, - + /* everything else */ GSM_SESSION_PHASE_APPLICATION, - + /* done launching */ GSM_SESSION_PHASE_RUNNING, - + /* shutting down */ GSM_SESSION_PHASE_SHUTDOWN } GsmSessionPhase; diff --git a/src/sugar/network.py b/src/sugar/network.py index 0e25d731..d6599ff9 100644 --- a/src/sugar/network.py +++ b/src/sugar/network.py @@ -124,7 +124,7 @@ class ChunkedGlibHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): self.wfile.flush() self.wfile.close() self.rfile.close() - + def finish(self): """Close the sockets when we're done, not before""" pass diff --git a/src/sugar/presence/__init__.py b/src/sugar/presence/__init__.py index 1136c190..9756612c 100644 --- a/src/sugar/presence/__init__.py +++ b/src/sugar/presence/__init__.py @@ -19,6 +19,6 @@ Provides a simplified API for accessing the dbus service which coordinates native network presence and sharing -information. This includes both "buddies" and "shared +information. This includes both "buddies" and "shared activities". """ diff --git a/src/sugar/presence/activity.py b/src/sugar/presence/activity.py index 13abf5d4..3102388d 100644 --- a/src/sugar/presence/activity.py +++ b/src/sugar/presence/activity.py @@ -30,16 +30,16 @@ _logger = logging.getLogger('sugar.presence.activity') class Activity(gobject.GObject): """UI interface for an Activity in the presence service - + Activities in the presence service represent your and other user's shared activities. - + Properties: - id - color - name - type - joined + id + color + name + type + joined """ __gsignals__ = { 'buddy-joined': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, @@ -74,7 +74,7 @@ class Activity(gobject.GObject): self._ps_del_object = del_obj_cb bobj = bus.get_object(self._PRESENCE_SERVICE, object_path) self._activity = dbus.Interface(bobj, self._ACTIVITY_DBUS_INTERFACE) - self._activity.connect_to_signal('BuddyHandleJoined', + self._activity.connect_to_signal('BuddyHandleJoined', self._buddy_handle_joined_cb) self._activity.connect_to_signal('BuddyLeft', self._buddy_left_cb) @@ -211,7 +211,7 @@ class Activity(gobject.GObject): def _emit_buddy_left_signal(self, object_path): """Generate buddy-left GObject signal with presence Buddy object - + XXX note use of _ps_new_object instead of _ps_del_object here """ self.emit('buddy-left', self._ps_new_object(object_path)) @@ -225,8 +225,8 @@ class Activity(gobject.GObject): self._handle_to_buddy_path.pop(handle, None) def _emit_new_channel_signal(self, object_path): - """Generate new-channel GObject signal with channel object path - + """Generate new-channel GObject signal with channel object path + New telepathy-python communications channel has been opened """ self.emit('new-channel', object_path) @@ -255,7 +255,7 @@ class Activity(gobject.GObject): def get_buddy_by_handle(self, handle): """Retrieve the Buddy object given a telepathy handle. - + buddy object paths are cached in self._handle_to_buddy_path, so we can get the buddy without calling PS. """ @@ -378,8 +378,8 @@ class Activity(gobject.GObject): # GetChannels() wrapper def get_channels(self): - """Retrieve communications channel descriptions for the activity - + """Retrieve communications channel descriptions for the activity + Returns a tuple containing: - the D-Bus well-known service name of the connection (FIXME: this is redundant; in Telepathy it can be derived diff --git a/src/sugar/presence/buddy.py b/src/sugar/presence/buddy.py index 877a798c..f97682ad 100644 --- a/src/sugar/presence/buddy.py +++ b/src/sugar/presence/buddy.py @@ -26,17 +26,17 @@ import dbus class Buddy(gobject.GObject): """UI interface for a Buddy in the presence service - + Each buddy interface tracks a set of activities and properties - that can be queried to provide UI controls for manipulating + that can be queried to provide UI controls for manipulating the presence interface. - + Properties Dictionary: - 'key': public key, - 'nick': nickname , - 'color': color (XXX what format), - 'current-activity': (XXX dbus path?), - 'owner': (XXX dbus path?), + 'key': public key, + 'nick': nickname , + 'color': color (XXX what format), + 'current-activity': (XXX dbus path?), + 'owner': (XXX dbus path?), 'icon': (XXX pixel data for an icon?) See __gproperties__ """ @@ -67,11 +67,11 @@ class Buddy(gobject.GObject): def __init__(self, bus, new_obj_cb, del_obj_cb, object_path): """Initialise the reference to the buddy - - bus -- dbus bus object - new_obj_cb -- callback to call when this buddy joins an activity - del_obj_cb -- callback to call when this buddy leaves an activity - object_path -- path to the buddy object + + bus -- dbus bus object + new_obj_cb -- callback to call when this buddy joins an activity + del_obj_cb -- callback to call when this buddy leaves an activity + object_path -- path to the buddy object """ gobject.GObject.__init__(self) self._object_path = object_path @@ -104,7 +104,7 @@ class Buddy(gobject.GObject): self._joined_activity_signal.remove() self._left_activity_signal.remove() self._property_changed_signal.remove() - + def _get_properties_helper(self): """Retrieve the Buddy's property dictionary from the service object """ @@ -114,8 +114,8 @@ class Buddy(gobject.GObject): return props def do_get_property(self, pspec): - """Retrieve a particular property from our property dictionary - + """Retrieve a particular property from our property dictionary + pspec -- XXX some sort of GTK specifier object with attributes including 'name', 'active' and 'icon-name' """ @@ -170,7 +170,7 @@ class Buddy(gobject.GObject): def _joined_activity_cb(self, object_path): """Handle dbus signal by emitting a GObject signal - + Stores the activity in activities dictionary as well """ if not self._activities.has_key(object_path): @@ -179,7 +179,7 @@ class Buddy(gobject.GObject): def _emit_left_activity_signal(self, object_path): """Emit activity left signal with Activity object - + XXX this calls self._ps_new_object instead of self._ps_del_object, which would seem to be the incorrect callback? """ @@ -188,7 +188,7 @@ class Buddy(gobject.GObject): def _left_activity_cb(self, object_path): """Handle dbus signal by emitting a GObject signal - + Also removes from the activities dictionary """ if self._activities.has_key(object_path): @@ -196,9 +196,9 @@ class Buddy(gobject.GObject): gobject.idle_add(self._emit_left_activity_signal, object_path) def _handle_property_changed_signal(self, prop_list): - """Emit property-changed signal with property dictionary - - Generates a property-changed signal with the results of + """Emit property-changed signal with property dictionary + + Generates a property-changed signal with the results of _get_properties_helper() """ self._properties = self._get_properties_helper() @@ -212,7 +212,7 @@ class Buddy(gobject.GObject): def get_icon_pixbuf(self): """Retrieve Buddy's icon as a GTK pixel buffer - + XXX Why aren't the icons coming in as SVG? """ if self.props.icon and len(self.props.icon): @@ -224,12 +224,12 @@ class Buddy(gobject.GObject): return None def get_joined_activities(self): - """Retrieve the set of all activities which this buddy has joined - - Uses the GetJoinedActivities method on the service - object to produce object paths, wraps each in an - Activity object. - + """Retrieve the set of all activities which this buddy has joined + + Uses the GetJoinedActivities method on the service + object to produce object paths, wraps each in an + Activity object. + returns list of presence Activity objects """ try: diff --git a/src/sugar/presence/presenceservice.py b/src/sugar/presence/presenceservice.py index cc72800e..f6bb8758 100644 --- a/src/sugar/presence/presenceservice.py +++ b/src/sugar/presence/presenceservice.py @@ -40,8 +40,8 @@ _logger = logging.getLogger('sugar.presence.presenceservice') class PresenceService(gobject.GObject): - """UI-side interface to the dbus presence service - + """UI-side interface to the dbus presence service + This class provides UI programmers with simplified access to the dbus service of the same name. It allows for observing various events from the presence service as GObject events, @@ -68,7 +68,7 @@ class PresenceService(gobject.GObject): _PS_BUDDY_OP = DBUS_PATH + "/Buddies/" _PS_ACTIVITY_OP = DBUS_PATH + "/Activities/" - + def __init__(self, allow_offline_iface=True): """Initialise the service and attempt to connect to events @@ -99,30 +99,30 @@ class PresenceService(gobject.GObject): _ps_ = None def _get_ps(self): - """Retrieve dbus interface to PresenceService - - Also registers for updates from various dbus events on the + """Retrieve dbus interface to PresenceService + + Also registers for updates from various dbus events on the interface. - - If unable to retrieve the interface, we will temporarily - return an _OfflineInterface object to allow the calling - code to continue functioning as though it had accessed a + + If unable to retrieve the interface, we will temporarily + return an _OfflineInterface object to allow the calling + code to continue functioning as though it had accessed a real presence service. - - If successful, caches the presence service interface + + If successful, caches the presence service interface for use by other methods and returns that interface """ if not self._ps_: try: # NOTE: We need to follow_name_owner_changes here - # because we can not connect to a signal unless + # because we can not connect to a signal unless # we follow the changes or we start the service # before we connect. Starting the service here # causes a major bottleneck during startup ps = dbus.Interface( self._bus.get_object(DBUS_SERVICE, DBUS_PATH, - follow_name_owner_changes=True), + follow_name_owner_changes=True), DBUS_INTERFACE ) except dbus.exceptions.DBusException, err: @@ -135,7 +135,7 @@ class PresenceService(gobject.GObject): return _OfflineInterface() raise RuntimeError("Failed to connect to the presence service.") else: - self._ps_ = ps + self._ps_ = ps ps.connect_to_signal('BuddyAppeared', self._buddy_appeared_cb) ps.connect_to_signal('BuddyDisappeared', @@ -149,7 +149,7 @@ class PresenceService(gobject.GObject): ps.connect_to_signal('PrivateInvitation', self._private_invitation_cb) return self._ps_ - + _ps = property( _get_ps, None, None, """DBUS interface to the PresenceService @@ -158,16 +158,16 @@ class PresenceService(gobject.GObject): def _new_object(self, object_path): """Turn new object path into (cached) Buddy/Activity instance - + object_path -- full dbus path of the new object, must be prefixed with either of _PS_BUDDY_OP or _PS_ACTIVITY_OP - + Note that this method is called throughout the class whenever - the representation of the object is required, it is not only + the representation of the object is required, it is not only called when the object is first discovered. The point is to only have _one_ Python object for any D-Bus object represented by an object path, effectively wrapping the D-Bus object in a single Python GObject. - + returns presence Buddy or Activity representation """ obj = None @@ -225,7 +225,7 @@ class PresenceService(gobject.GObject): # we could use a LRU cache limited to some value. del self._objcache[object_path] obj.destroy() - + return False def _buddy_disappeared_cb(self, object_path): @@ -282,7 +282,7 @@ class PresenceService(gobject.GObject): def get_activities(self): """Retrieve set of all activities from service - + returns list of Activity objects for all object paths the service reports exist (using GetActivities) """ @@ -317,12 +317,12 @@ class PresenceService(gobject.GObject): ) def get_activities_async(self, reply_handler=None, error_handler=None): - """Retrieve set of all activities from service asyncronously + """Retrieve set of all activities from service asyncronously """ if not reply_handler: logging.error('Function get_activities_async called without' \ - 'a reply handler. Can not run.') + 'a reply handler. Can not run.') return self._ps.GetActivities( @@ -351,7 +351,7 @@ class PresenceService(gobject.GObject): def get_buddies(self): """Retrieve set of all buddies from service - + returns list of Buddy objects for all object paths the service reports exist (using GetBuddies) """ @@ -386,12 +386,12 @@ class PresenceService(gobject.GObject): ) def get_buddies_async(self, reply_handler=None, error_handler=None): - """Retrieve set of all buddies from service asyncronously + """Retrieve set of all buddies from service asyncronously """ if not reply_handler: logging.error('Function get_buddies_async called without' \ - 'a reply handler. Can not run.') + 'a reply handler. Can not run.') return self._ps.GetBuddies( @@ -402,11 +402,11 @@ class PresenceService(gobject.GObject): def get_buddy(self, key): """Retrieve single Buddy object for the given public key - + key -- buddy's public encryption key - - returns single Buddy object or None if the activity - is not found using GetBuddyByPublicKey on the + + returns single Buddy object or None if the activity + is not found using GetBuddyByPublicKey on the service """ try: @@ -479,15 +479,15 @@ class PresenceService(gobject.GObject): def share_activity(self, activity, properties=None, private=True): """Ask presence service to ask the activity to share itself publicly. - - Uses the AdvertiseActivity method on the service to ask for the - sharing of the given activity. Arranges to emit activity-shared + + Uses the AdvertiseActivity method on the service to ask for the + sharing of the given activity. Arranges to emit activity-shared event with: - + (success, Activity, err) - + on success/failure. - + returns None """ actid = activity.get_id() @@ -528,16 +528,16 @@ class PresenceService(gobject.GObject): class _OfflineInterface( object ): """Offline-presence-service interface - + Used to mimic the behaviour of a real PresenceService sufficiently to avoid crashing client code that expects the given interface. - - XXX we could likely return a "MockOwner" object reasonably + + XXX we could likely return a "MockOwner" object reasonably easily, but would it be worth it? """ def raiseException( self, *args, **named ): """Raise dbus.exceptions.DBusException""" - raise dbus.exceptions.DBusException( + raise dbus.exceptions.DBusException( """PresenceService Interface not available""" ) GetActivities = raiseException @@ -546,7 +546,7 @@ class _OfflineInterface( object ): GetBuddyByPublicKey = raiseException GetOwner = raiseException GetPreferredConnection = raiseException - def ShareActivity( + def ShareActivity( self, actid, atype, name, properties, reply_handler, error_handler, ): @@ -559,7 +559,7 @@ class _OfflineInterface( object ): class _MockPresenceService(gobject.GObject): """Test fixture allowing testing of items that use PresenceService - + See PresenceService for usage and purpose """ __gsignals__ = { diff --git a/src/sugar/profile.py b/src/sugar/profile.py index 9d897baa..666c3552 100644 --- a/src/sugar/profile.py +++ b/src/sugar/profile.py @@ -33,18 +33,18 @@ _profile = None class Profile(object): """Local user's current options/profile information - - User settings were previously stored in an INI-style - configuration file. We moved to gconf now. The deprected + + User settings were previously stored in an INI-style + configuration file. We moved to gconf now. The deprected API is kept around to not break activities still using it. The profile is also responsible for loading the user's public and private ssh keys from disk. - + Attributes: - + pubkey -- public ssh key - privkey_hash -- SHA has of the child's public key + privkey_hash -- SHA has of the child's public key """ def __init__(self, path): self._pubkey = None @@ -138,7 +138,7 @@ class Profile(object): client.set_string("/desktop/sugar/user/color", color) if cp.has_option('Jabber', 'Server'): server = cp.get('Jabber', 'Server') - client.set_string("/desktop/sugar/collaboration/jabber_server", + client.set_string("/desktop/sugar/collaboration/jabber_server", server) if cp.has_option('Date', 'Timezone'): timezone = cp.get('Date', 'Timezone') @@ -165,7 +165,7 @@ class Profile(object): client.set_bool("/desktop/sugar/power/extreme", True) if cp.has_option('Shell', 'FavoritesLayout'): layout = cp.get('Shell', 'FavoritesLayout') - client.set_string("/desktop/sugar/desktop/favorites_layout", + client.set_string("/desktop/sugar/desktop/favorites_layout", layout) del cp try: @@ -191,7 +191,7 @@ class Profile(object): '#export SUGAR_LOGGER_LEVEL=debug\n\n' \ '# Uncomment the following line to enable core dumps\n' \ '#ulimit -c unlimited\n' - fd.write(text) + fd.write(text) fd.close() def get_profile(): @@ -205,11 +205,11 @@ def get_profile(): def get_nick_name(): client = gconf.client_get_default() - return client.get_string("/desktop/sugar/user/nick") + return client.get_string("/desktop/sugar/user/nick") def get_color(): client = gconf.client_get_default() - color = client.get_string("/desktop/sugar/user/color") + color = client.get_string("/desktop/sugar/user/color") return XoColor(color) def get_pubkey(): diff --git a/src/sugar/sugar-address-entry.c b/src/sugar/sugar-address-entry.c index c7555e06..0309880c 100644 --- a/src/sugar/sugar-address-entry.c +++ b/src/sugar/sugar-address-entry.c @@ -87,14 +87,14 @@ gtk_entry_get_pixel_ranges (GtkEntry *entry, if (ranges) { gint *r = *ranges; - + for (i = 0; i < real_n_ranges; ++i) { r[2 * i + 1] = (r[2 * i + 1] - r[2 * i]) / PANGO_SCALE; r[2 * i] = r[2 * i] / PANGO_SCALE; } } - + if (n_ranges) *n_ranges = real_n_ranges; } @@ -117,7 +117,7 @@ gtk_entry_get_cursor_locations (GtkEntry *entry, { if (strong_x) *strong_x = 0; - + if (weak_x) *weak_x = 0; } @@ -128,7 +128,7 @@ gtk_entry_get_cursor_locations (GtkEntry *entry, const gchar *text = pango_layout_get_text (layout); PangoRectangle strong_pos, weak_pos; gint index; - + if (type == CURSOR_STANDARD) { index = g_utf8_offset_to_pointer (text, entry->current_pos + entry->preedit_cursor) - text; @@ -148,12 +148,12 @@ gtk_entry_get_cursor_locations (GtkEntry *entry, } } } - + pango_layout_get_cursor_pos (layout, index, &strong_pos, &weak_pos); - + if (strong_x) *strong_x = strong_pos.x / PANGO_SCALE; - + if (weak_x) *weak_x = weak_pos.x / PANGO_SCALE; } @@ -165,7 +165,7 @@ gtk_entry_draw_cursor (GtkEntry *entry, { GdkKeymap *keymap = gdk_keymap_get_for_display (gtk_widget_get_display (GTK_WIDGET (entry))); PangoDirection keymap_direction = gdk_keymap_get_direction (keymap); - + if (GTK_WIDGET_DRAWABLE (entry)) { GtkWidget *widget = GTK_WIDGET (entry); @@ -186,7 +186,7 @@ gtk_entry_draw_cursor (GtkEntry *entry, xoffset = inner_border.left - entry->scroll_offset; gdk_drawable_get_size (entry->text_area, NULL, &text_area_height); - + gtk_entry_get_cursor_locations (entry, type, &strong_x, &weak_x); g_object_get (gtk_widget_get_settings (widget), @@ -194,7 +194,7 @@ gtk_entry_draw_cursor (GtkEntry *entry, NULL); dir1 = entry->resolved_dir; - + if (split_cursor) { x1 = strong_x; @@ -221,7 +221,7 @@ gtk_entry_draw_cursor (GtkEntry *entry, draw_insertion_cursor (entry, &cursor_location, TRUE, dir1, dir2 != PANGO_DIRECTION_NEUTRAL); - + if (dir2 != PANGO_DIRECTION_NEUTRAL) { cursor_location.x = xoffset + x2; @@ -243,7 +243,7 @@ get_layout_position (GtkEntry *entry, GtkBorder inner_border; gint y_pos; PangoLayoutLine *line; - + // layout = gtk_entry_ensure_layout (entry, TRUE); layout = gtk_entry_get_layout(entry); @@ -254,11 +254,11 @@ get_layout_position (GtkEntry *entry, line = pango_layout_get_lines (layout)->data; pango_layout_line_get_extents (line, NULL, &logical_rect); - + /* Align primarily for locale's ascent/descent */ - y_pos = ((area_height - entry->ascent - entry->descent) / 2 + + y_pos = ((area_height - entry->ascent - entry->descent) / 2 + entry->ascent + logical_rect.y); - + /* Now see if we need to adjust to fit in actual drawn string */ if (logical_rect.height > area_height) y_pos = (area_height - logical_rect.height) / 2; @@ -266,7 +266,7 @@ get_layout_position (GtkEntry *entry, y_pos = 0; else if (y_pos + logical_rect.height > area_height) y_pos = area_height - logical_rect.height; - + y_pos = inner_border.top + y_pos / PANGO_SCALE; if (x) @@ -306,10 +306,10 @@ static void gtk_entry_draw_text (GtkEntry *entry) { GtkWidget *widget; - + if (!entry->visible && entry->invisible_char == 0) return; - + if (GTK_WIDGET_DRAWABLE (entry)) { //PangoLayout *layout = gtk_entry_ensure_layout (entry, TRUE); @@ -317,9 +317,9 @@ gtk_entry_draw_text (GtkEntry *entry) cairo_t *cr; gint x, y; gint start_pos, end_pos; - + widget = GTK_WIDGET (entry); - + get_layout_position (entry, &x, &y); cr = gdk_cairo_create (entry->text_area); @@ -360,14 +360,14 @@ gtk_entry_draw_text (GtkEntry *entry) logical_rect.height); cairo_clip (cr); - + gdk_cairo_set_source_color (cr, selection_color); cairo_paint (cr); cairo_move_to (cr, x, y); gdk_cairo_set_source_color (cr, text_color); pango_cairo_show_layout (cr, layout); - + g_free (ranges); } @@ -427,7 +427,7 @@ get_text_area_size (GtkEntry *entry, if (y) *y = yborder; - + if (width) *width = GTK_WIDGET (entry)->allocation.width - xborder * 2; @@ -471,7 +471,7 @@ sugar_address_entry_expose(GtkWidget *widget, cairo_fill(cr); cairo_destroy (cr); } - + if ((entry->visible || entry->invisible_char != 0) && GTK_WIDGET_HAS_FOCUS (widget) && diff --git a/src/sugar/sugar-key-grabber.c b/src/sugar/sugar-key-grabber.c index 8139ce13..8a00a80f 100644 --- a/src/sugar/sugar-key-grabber.c +++ b/src/sugar/sugar-key-grabber.c @@ -153,7 +153,7 @@ sugar_key_grabber_init(SugarKeyGrabber *grabber) gdk_window_add_filter(grabber->root, filter_events, grabber); } -/* grab_key and grab_key_real are from +/* grab_key and grab_key_real are from * gnome-control-center/gnome-settings-daemon/gnome-settings-multimedia-keys.c */ @@ -213,7 +213,7 @@ sugar_key_grabber_grab_keys(SugarKeyGrabber *grabber, const char **keys) while (*cur != NULL) { key = *cur; cur += 1; - + keyinfo = g_new0 (Key, 1); keyinfo->key = g_strdup(key); @@ -279,9 +279,9 @@ sugar_key_grabber_is_modifier(SugarKeyGrabber *grabber, guint keycode, guint mas break; } } - + XFreeModifiermap (modmap); - + return is_modifier; } diff --git a/src/sugar/util.py b/src/sugar/util.py index c35d3664..99092ee5 100644 --- a/src/sugar/util.py +++ b/src/sugar/util.py @@ -48,16 +48,16 @@ def sha_data(data): def unique_id(data = ''): """Generate a likely-unique ID for whatever purpose - + data -- suffix appended to working data before hashing - + Returns a 40-character string with hexidecimal digits - representing an SHA hash of the time, a random digit + representing an SHA hash of the time, a random digit within a constrained range and the data passed. - - Note: these are *not* crypotographically secure or - globally unique identifiers. While they are likely - to be unique-enough, no attempt is made to make + + Note: these are *not* crypotographically secure or + globally unique identifiers. While they are likely + to be unique-enough, no attempt is made to make perfectly unique values. """ data_string = "%s%s%s" % (time.time(), random.randint(10000, 100000), data) @@ -72,7 +72,7 @@ def is_hex(s): except ValueError: return False - return True + return True def validate_activity_id(actid): """Validate an activity ID.""" @@ -90,7 +90,7 @@ def set_proc_title(title): and only the first 15 characters will be shown. title -- the title you wish to change the process - title to + title to Returns True on success. We don't raise exceptions because if something goes wrong here it is not a big @@ -284,7 +284,7 @@ class TempFilePath(str): def __del__(self): if _tracked_paths[self] == 1: del _tracked_paths[self] - + if os.path.exists(self): os.unlink(self) logging.debug('TempFilePath deleted %r', self) diff --git a/src/sugar/wm.py b/src/sugar/wm.py index 4ec9a12b..64505e8c 100644 --- a/src/sugar/wm.py +++ b/src/sugar/wm.py @@ -16,7 +16,7 @@ # Boston, MA 02111-1307, USA. """ -UNSTABLE. Used only internally by Activity and jarabe. +UNSTABLE. Used only internally by Activity and jarabe. """ import gtk