trim EOL (end-of-line) spaces on source files

This commit is contained in:
Sascha Silbe 2009-08-25 19:55:48 +02:00
parent 6c3fd0346c
commit ecdaf6b795
53 changed files with 446 additions and 446 deletions

View File

@ -74,7 +74,7 @@ _sugarext.c: _sugarext.defs _sugarext.override
--prefix py$* $*.defs) > gen-$*.c \ --prefix py$* $*.defs) > gen-$*.c \
&& cp gen-$*.c $*.c \ && cp gen-$*.c $*.c \
&& rm -f gen-$*.c && rm -f gen-$*.c
sugar-marshal.c: sugar-marshal.list sugar-marshal.c: sugar-marshal.list
$(GLIB_GENMARSHAL) --prefix=sugar_marshal \ $(GLIB_GENMARSHAL) --prefix=sugar_marshal \
$(srcdir)/sugar-marshal.list --header --body > sugar-marshal.c $(srcdir)/sugar-marshal.list --header --body > sugar-marshal.c

View File

@ -18,12 +18,12 @@
"""Activity implementation code for Sugar-based activities """Activity implementation code for Sugar-based activities
Each activity within the OLPC environment must provide two 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 sugar.activity.activityfactory.ActivityFactory
class is responsible for providing a "create" method which class is responsible for providing a "create" method which
takes a small dictionary with values corresponding to a takes a small dictionary with values corresponding to a
sugar.activity.activityhandle.ActivityHandle sugar.activity.activityhandle.ActivityHandle
@ -33,23 +33,23 @@ Each activity so registered is described by a
sugar.activity.bundle.Bundle sugar.activity.bundle.Bundle
instance, which parses a specially formatted activity.info instance, which parses a specially formatted activity.info
file (stored in the activity directory's ./activity file (stored in the activity directory's ./activity
subdirectory). The subdirectory). The
sugar.activity.bundlebuilder sugar.activity.bundlebuilder
module provides facilities for the standard setup.py module module provides facilities for the standard setup.py module
which produces and registers bundles from activity source which produces and registers bundles from activity source
directories. directories.
Once instantiated by the ActivityFactory's create method, 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 after the
sugar.activity.activityservice.ActivityService 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 window, requesting sharing across the network, and basic
"what type of application are you" queries. "what type of application are you" queries.
""" """

View File

@ -1,6 +1,6 @@
"""Base class for activities written in Python """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. activity must do to participate in the Sugar desktop.
A Basic Activity 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 the activity.info file associated with your activity will tell the sugar-shell
which class to start. which class to start.
For example the most minimal Activity: For example the most minimal Activity:
from sugar.activity import activity from sugar.activity import activity
class ReadActivity(activity.Activity): class ReadActivity(activity.Activity):
pass pass
@ -61,7 +61,7 @@ import dbus
import dbus.service import dbus.service
import cjson import cjson
from sugar import util from sugar import util
from sugar.presence import presenceservice from sugar.presence import presenceservice
from sugar.activity.activityservice import ActivityService from sugar.activity.activityservice import ActivityService
from sugar.activity.namingalert import NamingAlert from sugar.activity.namingalert import NamingAlert
@ -136,67 +136,67 @@ class _ActivitySession(gobject.GObject):
class Activity(Window, gtk.Container): class Activity(Window, gtk.Container):
"""This is the base Activity class that all other Activities derive from. """This is the base Activity class that all other Activities derive from.
This is where your activity starts. This is where your activity starts.
To get a working Activity: To get a working Activity:
0. Derive your Activity from this class: 0. Derive your Activity from this class:
class MyActivity(activity.Activity): class MyActivity(activity.Activity):
... ...
1. implement an __init__() method for your Activity class. 1. implement an __init__() method for your Activity class.
Use your init method to create your own ActivityToolbar which will Use your init method to create your own ActivityToolbar which will
contain some standard buttons: contain some standard buttons:
toolbox = activity.ActivityToolbox(self) toolbox = activity.ActivityToolbox(self)
Add extra Toolbars to your toolbox. Add extra Toolbars to your toolbox.
You should setup Activity sharing here too. You should setup Activity sharing here too.
Finaly, your Activity may need some resources which you can claim Finaly, your Activity may need some resources which you can claim
here too. here too.
The __init__() method is also used to make the distinction between 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() 2. Implement read_file() and write_file()
Most activities revolve around creating and storing Journal entries. Most activities revolve around creating and storing Journal entries.
For example, Write: You create a document, it is saved to the Journal For example, Write: You create a document, it is saved to the Journal
and then later you resume working on the document. and then later you resume working on the document.
read_file() and write_file() will be called by sugar to tell your 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 Activity that it should load or save the document the user is working
on. on.
3. Implement our Activity Toolbars. 3. Implement our Activity Toolbars.
The Toolbars are added to your Activity in step 1 (the toolbox), but The Toolbars are added to your Activity in step 1 (the toolbox), but
you need to implement them somewhere. Now is a good time. you need to implement them somewhere. Now is a good time.
There are a number of standard Toolbars. The most basic one, the one There are a number of standard Toolbars. The most basic one, the one
your almost absolutely MUST have is the ActivityToolbar. Without your almost absolutely MUST have is the ActivityToolbar. Without
this, you're not really making a proper Sugar Activity (which may be 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 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 Usually, you will also need the standard EditToolbar. This is the one
which has the standard copy and paste buttons. You need to derive which has the standard copy and paste buttons. You need to derive
your own EditToolbar class from sugar.EditToolbar: your own EditToolbar class from sugar.EditToolbar:
class EditToolbar(activity.EditToolbar): class EditToolbar(activity.EditToolbar):
... ...
See EditToolbar for the methods you should implement in your class. See EditToolbar for the methods you should implement in your class.
Finaly, your Activity will very likely need some activity specific Finaly, your Activity will very likely need some activity specific
buttons and options you can create your own toolbars by deriving a buttons and options you can create your own toolbars by deriving a
class from gtk.Toolbar: class from gtk.Toolbar:
class MySpecialToolbar(gtk.Toolbar): class MySpecialToolbar(gtk.Toolbar):
... ...
4. Use your creativity. Make your Activity something special and share 4. Use your creativity. Make your Activity something special and share
it with your friends! it with your friends!
Read through the methods of the Activity class below, to learn more about 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 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. 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): def __init__(self, handle, create_jobject=True):
"""Initialise the Activity """Initialise the Activity
handle -- sugar.activity.activityhandle.ActivityHandle handle -- sugar.activity.activityhandle.ActivityHandle
instance providing the activity id and access to the instance providing the activity id and access to the
presence service which *may* provide sharing for this presence service which *may* provide sharing for this
application application
create_jobject -- boolean create_jobject -- boolean
define if it should create a journal object if we are define if it should create a journal object if we are
not resuming not resuming
Side effects: Side effects:
Sets the gdk screen DPI setting (resolution) to the Sets the gdk screen DPI setting (resolution) to the
Sugar screen resolution. Sugar screen resolution.
Connects our "destroy" message to our _destroy_cb Connects our "destroy" message to our _destroy_cb
method. method.
Creates a base gtk.Window within this window. Creates a base gtk.Window within this window.
Creates an ActivityService (self._bus) servicing Creates an ActivityService (self._bus) servicing
this application. this application.
Usage: Usage:
If your Activity implements __init__(), it should call If your Activity implements __init__(), it should call
the base class __init()__ before doing Activity specific things. the base class __init()__ before doing Activity specific things.
""" """
Window.__init__(self) Window.__init__(self)
@ -280,9 +280,9 @@ class Activity(Window, gtk.Container):
share_scope = SCOPE_PRIVATE share_scope = SCOPE_PRIVATE
if handle.object_id: 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']) self.set_title(self._jobject.metadata['title'])
if self._jobject.metadata.has_key('share-scope'): if self._jobject.metadata.has_key('share-scope'):
share_scope = self._jobject.metadata['share-scope'] share_scope = self._jobject.metadata['share-scope']
@ -364,7 +364,7 @@ class Activity(Window, gtk.Container):
def get_id(self): def get_id(self):
"""Returns the activity id of the current instance of your activity. """Returns the activity id of the current instance of your activity.
The activity id is sort-of-like the unix process id (PID). However, The activity id is sort-of-like the unix process id (PID). However,
unlike PIDs it is only different for each new instance (with unlike PIDs it is only different for each new instance (with
create_jobject = True set) and stays the same everytime a user 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): def set_canvas(self, canvas):
"""Sets the 'work area' of your activity with the canvas of your choice. """Sets the 'work area' of your activity with the canvas of your choice.
One commonly used canvas is gtk.ScrolledWindow One commonly used canvas is gtk.ScrolledWindow
""" """
Window.set_canvas(self, canvas) Window.set_canvas(self, canvas)
@ -412,21 +412,21 @@ class Activity(Window, gtk.Container):
logging.debug('Error creating activity datastore object: %s', err) logging.debug('Error creating activity datastore object: %s', err)
def get_activity_root(self): 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 out of this class to the module itself
Returns a path for saving Activity specific preferences, etc. Returns a path for saving Activity specific preferences, etc.
Returns a path to the location in the filesystem where the activity can Returns a path to the location in the filesystem where the activity can
store activity related data that doesn't pertain to the current store activity related data that doesn't pertain to the current
execution of the activity and thus cannot go into the DataStore. execution of the activity and thus cannot go into the DataStore.
Currently, this will return something like Currently, this will return something like
~/.sugar/default/MyActivityName/ ~/.sugar/default/MyActivityName/
Activities should ONLY save settings, user preferences and other data 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 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 \ if os.environ.has_key('SUGAR_ACTIVITY_ROOT') and \
os.environ['SUGAR_ACTIVITY_ROOT']: os.environ['SUGAR_ACTIVITY_ROOT']:
@ -438,17 +438,17 @@ class Activity(Window, gtk.Container):
""" """
Subclasses implement this method if they support resuming objects from Subclasses implement this method if they support resuming objects from
the journal. 'file_path' is the file to read from. the journal. 'file_path' is the file to read from.
You should immediately open the file from the file_path, because the You should immediately open the file from the file_path, because the
file_name will be deleted immediately after returning from read_file(). 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: 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 After you have opened it, the file will only be really gone when you
close it. close it.
Although not required, this is also a good time to read all meta-data: 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 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 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 raise NotImplementedError
@ -456,17 +456,17 @@ class Activity(Window, gtk.Container):
""" """
Subclasses implement this method if they support saving data to objects Subclasses implement this method if they support saving data to objects
in the journal. 'file_path' is the file to write to. 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 If the user did make changes, you should create the file_path and save
all document data to it. all document data to it.
Additionally, you should also write any metadata needed to resume your Additionally, you should also write any metadata needed to resume your
activity. For example, the Read activity saves the current page and zoom activity. For example, the Read activity saves the current page and zoom
level, so it can display the page. level, so it can display the page.
Note: Currently, the file_path *WILL* be different from the one you 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() 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 raise NotImplementedError
@ -539,11 +539,11 @@ class Activity(Window, gtk.Container):
def save(self): def save(self):
"""Request that the activity is saved to the Journal. """Request that the activity is saved to the Journal.
This method is called by the close() method below. In general, This method is called by the close() method below. In general,
activities should not override this method. This method is part of the 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 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: if self._jobject is None:
@ -590,7 +590,7 @@ class Activity(Window, gtk.Container):
def copy(self): def copy(self):
"""Request that the activity 'Keep in Journal' the current state """Request that the activity 'Keep in Journal' the current state
of the activity. of the activity.
Activities should not override this method. Instead, like save() do any Activities should not override this method. Instead, like save() do any
copy work that needs to be done in write_file() copy work that needs to be done in write_file()
""" """
@ -656,7 +656,7 @@ class Activity(Window, gtk.Container):
def _send_invites(self): def _send_invites(self):
while self._invites_queue: while self._invites_queue:
buddy_key = self._invites_queue.pop() buddy_key = self._invites_queue.pop()
buddy = self._pservice.get_buddy(buddy_key) buddy = self._pservice.get_buddy(buddy_key)
if buddy: if buddy:
self.shared_activity.invite( self.shared_activity.invite(
@ -666,10 +666,10 @@ class Activity(Window, gtk.Container):
def invite(self, buddy_key): def invite(self, buddy_key):
"""Invite a buddy to join this Activity. """Invite a buddy to join this Activity.
Side Effects: Side Effects:
Calls self.share(True) to privately share the activity if it wasn't Calls self.share(True) to privately share the activity if it wasn't
shared before. shared before.
""" """
self._invites_queue.append(buddy_key) self._invites_queue.append(buddy_key)
@ -681,7 +681,7 @@ class Activity(Window, gtk.Container):
def share(self, private=False): def share(self, private=False):
"""Request that the activity be shared on the network. """Request that the activity be shared on the network.
private -- bool: True to share by invitation only, private -- bool: True to share by invitation only,
False to advertise as shared to everyone. False to advertise as shared to everyone.
@ -694,7 +694,7 @@ class Activity(Window, gtk.Container):
verb = private and 'private' or 'public' verb = private and 'private' or 'public'
logging.debug('Requesting %s share of activity %s.', verb, logging.debug('Requesting %s share of activity %s.', verb,
self._activity_id) self._activity_id)
self._share_id = self._pservice.connect("activity-shared", self._share_id = self._pservice.connect("activity-shared",
self.__share_cb) self.__share_cb)
self._pservice.share_activity(self, private=private) self._pservice.share_activity(self, private=private)
@ -752,7 +752,7 @@ class Activity(Window, gtk.Container):
def close(self, skip_save=False): def close(self, skip_save=False):
"""Request that the activity be stopped and saved to the Journal """Request that the activity be stopped and saved to the Journal
Activities should not override this method, but should implement Activities should not override this method, but should implement
write_file() to do any state saving instead. If the application wants write_file() to do any state saving instead. If the application wants
to control wether it can close, it should override can_close(). to control wether it can close, it should override can_close().
@ -783,13 +783,13 @@ class Activity(Window, gtk.Container):
def get_metadata(self): def get_metadata(self):
"""Returns the jobject metadata or None if there is no jobject. """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" self.metadata['MyKey'] = "Something"
and retrieve metadata in read_file() using: and retrieve metadata in read_file() using:
self.metadata.get('MyKey', 'aDefaultValue') self.metadata.get('MyKey', 'aDefaultValue')
Note: Make sure your activity works properly if one or more of the Note: Make sure your activity works properly if one or more of the
metadata items is missing. Never assume they will all be present. metadata items is missing. Never assume they will all be present.
""" """
@ -822,7 +822,7 @@ def _get_session():
def get_bundle_name(): def get_bundle_name():
"""Return the bundle name for the current process' bundle""" """Return the bundle name for the current process' bundle"""
return os.environ['SUGAR_BUNDLE_NAME'] return os.environ['SUGAR_BUNDLE_NAME']
def get_bundle_path(): def get_bundle_path():
"""Return the bundle path for the current process' bundle""" """Return the bundle path for the current process' bundle"""
return os.environ['SUGAR_BUNDLE_PATH'] return os.environ['SUGAR_BUNDLE_PATH']

View File

@ -197,7 +197,7 @@ class ActivityCreationHandler(gobject.GObject):
self._bundle = bundle self._bundle = bundle
self._service_name = bundle.get_bundle_id() self._service_name = bundle.get_bundle_id()
self._handle = handle self._handle = handle
bus = dbus.SessionBus() bus = dbus.SessionBus()
bus_object = bus.get_object(_SHELL_SERVICE, _SHELL_PATH) bus_object = bus.get_object(_SHELL_SERVICE, _SHELL_PATH)
self._shell = dbus.Interface(bus_object, _SHELL_IFACE) self._shell = dbus.Interface(bus_object, _SHELL_IFACE)

View File

@ -25,25 +25,25 @@ class ActivityHandle(object):
self, activity_id=None, object_id=None, uri=None self, activity_id=None, object_id=None, uri=None
): ):
"""Initialise the handle from activity_id """Initialise the handle from activity_id
activity_id -- unique id for the activity to be activity_id -- unique id for the activity to be
created created
object_id -- identity of the journal object object_id -- identity of the journal object
associated with the activity. It was used by associated with the activity. It was used by
the journal prototype implementation, might the journal prototype implementation, might
change when we do the real one. change when we do the real one.
When you resume an activity from the journal When you resume an activity from the journal
the object_id will be passed in. It's optional the object_id will be passed in. It's optional
since new activities does not have an since new activities does not have an
associated object (yet). associated object (yet).
XXX Not clear how this relates to the activity XXX Not clear how this relates to the activity
id yet, i.e. not sure we really need both. TBF id yet, i.e. not sure we really need both. TBF
uri -- URI associated with the activity. Used when uri -- URI associated with the activity. Used when
opening an external file or resource in the opening an external file or resource in the
activity, rather than a journal object activity, rather than a journal object
(downloads stored on the file system for (downloads stored on the file system for
example or web pages) example or web pages)
""" """
self.activity_id = activity_id self.activity_id = activity_id

View File

@ -30,20 +30,20 @@ _ACTIVITY_INTERFACE = "org.laptop.Activity"
class ActivityService(dbus.service.Object): class ActivityService(dbus.service.Object):
"""Base dbus service object that each Activity uses to export dbus methods. """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 The dbus service is separate from the actual Activity object so that we can
tightly control what stuff passes through the dbus python bindings.""" tightly control what stuff passes through the dbus python bindings."""
def __init__(self, activity): def __init__(self, activity):
"""Initialise the service for the given activity """Initialise the service for the given activity
activity -- sugar.activity.activity.Activity instance activity -- sugar.activity.activity.Activity instance
Creates dbus services that use the instance's activity_id Creates dbus services that use the instance's activity_id
as discriminants among all active services as discriminants among all active services
of this type. That is, the services are all available of this type. That is, the services are all available
as names/paths derived from the instance's activity_id. as names/paths derived from the instance's activity_id.
The various methods exposed on dbus are just forwarded The various methods exposed on dbus are just forwarded
to the client Activity object's equally-named methods. to the client Activity object's equally-named methods.
""" """

View File

@ -36,7 +36,7 @@ from sugar.bundle.activitybundle import ActivityBundle
IGNORE_DIRS = ['dist', '.git'] IGNORE_DIRS = ['dist', '.git']
IGNORE_FILES = ['.gitignore', 'MANIFEST', '*.pyc', '*~', '*.bak', 'pseudo.po'] IGNORE_FILES = ['.gitignore', 'MANIFEST', '*.pyc', '*~', '*.bak', 'pseudo.po']
def list_files(base_dir, ignore_dirs=None, ignore_files=None): def list_files(base_dir, ignore_dirs=None, ignore_files=None):
result = [] result = []
@ -46,7 +46,7 @@ def list_files(base_dir, ignore_dirs=None, ignore_files=None):
if ignore_files: if ignore_files:
for pattern in ignore_files: for pattern in ignore_files:
files = [f for f in files if not fnmatch(f, pattern)] files = [f for f in files if not fnmatch(f, pattern)]
rel_path = root[len(base_dir) + 1:] rel_path = root[len(base_dir) + 1:]
for f in files: for f in files:
result.append(os.path.join(rel_path, f)) 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_name = reduce(lambda x, y:x+y, self.activity_name.split())
self.bundle_root_dir = self.bundle_name + '.activity' self.bundle_root_dir = self.bundle_name + '.activity'
self.tar_root_dir = '%s-%d' % (self.bundle_name, self.version) self.tar_root_dir = '%s-%d' % (self.bundle_name, self.version)
if self.dist_name: if self.dist_name:
self.xo_name = self.tar_name = self.dist_name self.xo_name = self.tar_name = self.dist_name
else: else:
@ -103,7 +103,7 @@ class Builder(object):
if not self.config.bundle.is_dir(po_dir): if not self.config.bundle.is_dir(po_dir):
logging.warn("Missing po/ dir, cannot build_locale") logging.warn("Missing po/ dir, cannot build_locale")
return return
locale_dir = os.path.join(self.config.source_dir, 'locale') locale_dir = os.path.join(self.config.source_dir, 'locale')
if os.path.exists(locale_dir): if os.path.exists(locale_dir):
@ -154,15 +154,15 @@ class Builder(object):
missing_files.append(path) missing_files.append(path)
return missing_files return missing_files
def fix_manifest(self): def fix_manifest(self):
self.build() self.build()
manifest = self.config.bundle.manifest manifest = self.config.bundle.manifest
for path in self.check_manifest(): for path in self.check_manifest():
manifest.append(path) manifest.append(path)
f = open(os.path.join(self.config.source_dir, "MANIFEST"), "wb") f = open(os.path.join(self.config.source_dir, "MANIFEST"), "wb")
for line in manifest: for line in manifest:
f.write(line + "\n") f.write(line + "\n")
@ -186,7 +186,7 @@ class XOPackager(Packager):
def package(self): def package(self):
bundle_zip = zipfile.ZipFile(self.package_path, 'w', bundle_zip = zipfile.ZipFile(self.package_path, 'w',
zipfile.ZIP_DEFLATED) zipfile.ZIP_DEFLATED)
missing_files = self.builder.check_manifest() missing_files = self.builder.check_manifest()
if missing_files: if missing_files:
logging.warn('These files are not included in the manifest ' \ logging.warn('These files are not included in the manifest ' \
@ -207,14 +207,14 @@ class SourcePackager(Packager):
self.config.tar_name) self.config.tar_name)
def get_files(self): 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) cwd=self.config.source_dir)
stdout, _ = git_ls.communicate() stdout, _ = git_ls.communicate()
if git_ls.returncode : if git_ls.returncode :
# Fall back to filtered list # Fall back to filtered list
return list_files(self.config.source_dir, return list_files(self.config.source_dir,
IGNORE_DIRS, IGNORE_FILES) IGNORE_DIRS, IGNORE_FILES)
return [path.strip() for path in stdout.strip('\n').split('\n')] return [path.strip() for path in stdout.strip('\n').split('\n')]
def package(self): def package(self):
@ -286,7 +286,7 @@ def cmd_dist_xo(config, args):
if args: if args:
print 'Usage: %prog dist_xo' print 'Usage: %prog dist_xo'
return return
packager = XOPackager(Builder(config)) packager = XOPackager(Builder(config))
packager.package() packager.package()

View File

@ -43,7 +43,7 @@ def get_single_process_path(bundle_id):
class SingleProcess(dbus.service.Object): class SingleProcess(dbus.service.Object):
def __init__(self, name_service, constructor): def __init__(self, name_service, constructor):
self.constructor = constructor self.constructor = constructor
bus = dbus.SessionBus() bus = dbus.SessionBus()
bus_name = dbus.service.BusName(name_service, bus=bus) bus_name = dbus.service.BusName(name_service, bus=bus)
object_path = get_single_process_path(name_service) object_path = get_single_process_path(name_service)
@ -77,7 +77,7 @@ def main():
if len(args) == 0: if len(args) == 0:
print 'A python class must be specified as first argument.' print 'A python class must be specified as first argument.'
sys.exit(1) sys.exit(1)
bundle_path = os.environ['SUGAR_BUNDLE_PATH'] bundle_path = os.environ['SUGAR_BUNDLE_PATH']
sys.path.append(bundle_path) sys.path.append(bundle_path)
@ -102,7 +102,7 @@ def main():
module_name = splitted_module[0] module_name = splitted_module[0]
class_name = splitted_module[1] class_name = splitted_module[1]
module = __import__(module_name) module = __import__(module_name)
for comp in module_name.split('.')[1:]: for comp in module_name.split('.')[1:]:
module = getattr(module, comp) module = getattr(module, comp)

View File

@ -69,7 +69,7 @@ class NamingToolbar(gtk.Toolbar):
client = gconf.client_get_default() client = gconf.client_get_default()
color = XoColor(client.get_string('/desktop/sugar/user/color')) color = XoColor(client.get_string('/desktop/sugar/user/color'))
icon = Icon() icon = Icon()
icon.set_from_icon_name('activity-journal', icon.set_from_icon_name('activity-journal',
gtk.ICON_SIZE_LARGE_TOOLBAR) gtk.ICON_SIZE_LARGE_TOOLBAR)
icon.props.xo_color = color icon.props.xo_color = color
self._add_widget(icon) self._add_widget(icon)
@ -78,7 +78,7 @@ class NamingToolbar(gtk.Toolbar):
self._title = gtk.Label(_('Name this entry')) self._title = gtk.Label(_('Name this entry'))
self._add_widget(self._title) self._add_widget(self._title)
self._add_separator(True) self._add_separator(True)
self._keep_button = ToolButton('dialog-ok', tooltip=_('Keep')) self._keep_button = ToolButton('dialog-ok', tooltip=_('Keep'))
@ -170,7 +170,7 @@ class NamingAlert(gtk.Window):
width = gtk.gdk.screen_width() - offset * 2 width = gtk.gdk.screen_width() - offset * 2
height = gtk.gdk.screen_height() - offset * 2 height = gtk.gdk.screen_height() - offset * 2
self.set_size_request(width, height) 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_decorated(False)
self.set_resizable(False) self.set_resizable(False)
self.set_modal(True) self.set_modal(True)
@ -230,13 +230,13 @@ class NamingAlert(gtk.Window):
self._favorite_icon = self._create_favorite_icon() self._favorite_icon = self._create_favorite_icon()
header.append(self._favorite_icon) header.append(self._favorite_icon)
entry_icon = self._create_entry_icon() entry_icon = self._create_entry_icon()
header.append(entry_icon) header.append(entry_icon)
self._title = self._create_title() self._title = self._create_title()
header.append(self._title, hippo.PACK_EXPAND) header.append(self._title, hippo.PACK_EXPAND)
if gtk.widget_get_default_direction() == gtk.TEXT_DIR_RTL: if gtk.widget_get_default_direction() == gtk.TEXT_DIR_RTL:
header.reverse() header.reverse()
@ -251,7 +251,7 @@ class NamingAlert(gtk.Window):
def _create_favorite_icon(self): def _create_favorite_icon(self):
favorite_icon = FavoriteIcon(False) favorite_icon = FavoriteIcon(False)
return favorite_icon return favorite_icon
def _create_entry_icon(self): def _create_entry_icon(self):
bundle_id = self._activity.metadata.get('activity', '') bundle_id = self._activity.metadata.get('activity', '')
if not bundle_id: if not bundle_id:
@ -259,7 +259,7 @@ class NamingAlert(gtk.Window):
if bundle_id == '': if bundle_id == '':
file_name = _get_icon_name(self._activity.metadata) file_name = _get_icon_name(self._activity.metadata)
else: else:
activity_bundle = ActivityBundle(self._bundle_path) activity_bundle = ActivityBundle(self._bundle_path)
file_name = activity_bundle.get_icon() file_name = activity_bundle.get_icon()
entry_icon = CanvasIcon(file_name=file_name) entry_icon = CanvasIcon(file_name=file_name)
@ -268,7 +268,7 @@ class NamingAlert(gtk.Window):
entry_icon.props.xo_color = XoColor( \ entry_icon.props.xo_color = XoColor( \
self._activity.metadata['icon-color']) self._activity.metadata['icon-color'])
return entry_icon return entry_icon
def _create_title(self): def _create_title(self):
title = CanvasEntry() title = CanvasEntry()
title.set_background(style.COLOR_WHITE.get_html()) title.set_background(style.COLOR_WHITE.get_html())
@ -302,7 +302,7 @@ class NamingAlert(gtk.Window):
def _create_tags(self): def _create_tags(self):
vbox = hippo.CanvasBox() vbox = hippo.CanvasBox()
vbox.props.spacing = style.DEFAULT_SPACING vbox.props.spacing = style.DEFAULT_SPACING
text = hippo.CanvasText(text=_('Tags:'), text = hippo.CanvasText(text=_('Tags:'),
font_desc=style.FONT_NORMAL.get_pango_desc()) font_desc=style.FONT_NORMAL.get_pango_desc())
text.props.color = style.COLOR_BUTTON_GREY.get_int() text.props.color = style.COLOR_BUTTON_GREY.get_int()
@ -313,7 +313,7 @@ class NamingAlert(gtk.Window):
text.props.xalign = hippo.ALIGNMENT_START text.props.xalign = hippo.ALIGNMENT_START
vbox.append(text) vbox.append(text)
tags = self._activity.metadata.get('tags', '') tags = self._activity.metadata.get('tags', '')
text_view = CanvasTextView(tags, box_height=style.GRID_CELL_SIZE * 2) text_view = CanvasTextView(tags, box_height=style.GRID_CELL_SIZE * 2)
vbox.append(text_view, hippo.PACK_EXPAND) vbox.append(text_view, hippo.PACK_EXPAND)

View File

@ -33,7 +33,7 @@ from sugar.bundle.bundle import Bundle, \
class ActivityBundle(Bundle): class ActivityBundle(Bundle):
"""A Sugar activity bundle """A Sugar activity bundle
See http://wiki.laptop.org/go/Activity_bundles for details See http://wiki.laptop.org/go/Activity_bundles for details
""" """
@ -48,7 +48,7 @@ class ActivityBundle(Bundle):
Bundle.__init__(self, path) Bundle.__init__(self, path)
self.activity_class = None self.activity_class = None
self.bundle_exec = None self.bundle_exec = None
self._name = None self._name = None
self._icon = None self._icon = None
self._bundle_id = None self._bundle_id = None
@ -83,16 +83,16 @@ class ActivityBundle(Bundle):
if not f: if not f:
logging.warning("Activity directory lacks a MANIFEST file.") logging.warning("Activity directory lacks a MANIFEST file.")
return [] return []
ret = [line.strip() for line in f.readlines()] ret = [line.strip() for line in f.readlines()]
f.close() f.close()
return ret return ret
def _read_manifest(self): def _read_manifest(self):
"""return a list with the lines in MANIFEST, with invalid lines replaced """return a list with the lines in MANIFEST, with invalid lines replaced
by empty lines. 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 be preserved. For instance, when renaming a file, you should leave
the new name on the same line as the old one. 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', logging.warning('Bundle %s: duplicate entry in MANIFEST: %s',
self._name, line) self._name, line)
continue continue
# Remove MANIFEST # Remove MANIFEST
if line == "MANIFEST": if line == "MANIFEST":
lines[num] = "" lines[num] = ""
logging.warning('Bundle %s: MANIFEST includes itself: %s', logging.warning('Bundle %s: MANIFEST includes itself: %s',
self._name, line) self._name, line)
# Remove invalid files # Remove invalid files
if not self.is_file(line): if not self.is_file(line):
lines[num] = "" lines[num] = ""
@ -127,7 +127,7 @@ class ActivityBundle(Bundle):
self._name, line) self._name, line)
return lines return lines
def get_files(self, manifest = None): def get_files(self, manifest = None):
files = [line for line in (manifest or self.manifest) if line] files = [line for line in (manifest or self.manifest) if line]
@ -135,7 +135,7 @@ class ActivityBundle(Bundle):
files.append('MANIFEST') files.append('MANIFEST')
return files return files
def _parse_info(self, info_file): def _parse_info(self, info_file):
cp = ConfigParser() cp = ConfigParser()
cp.readfp(info_file) cp.readfp(info_file)
@ -260,7 +260,7 @@ class ActivityBundle(Bundle):
return os.path.join(self._path, icon_path) return os.path.join(self._path, icon_path)
else: else:
icon_data = self.get_file(icon_path).read() 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') suffix='.svg')
os.write(temp_file, icon_data) os.write(temp_file, icon_data)
os.close(temp_file) os.close(temp_file)
@ -298,7 +298,7 @@ class ActivityBundle(Bundle):
self._unzip(install_dir) self._unzip(install_dir)
install_path = os.path.join(install_dir, self._zip_root_dir) install_path = os.path.join(install_dir, self._zip_root_dir)
# List installed files # List installed files
manifestfiles = self.get_files(self._raw_manifest()) manifestfiles = self.get_files(self._raw_manifest())
paths = [] paths = []
@ -306,7 +306,7 @@ class ActivityBundle(Bundle):
rel_path = root[len(install_path) + 1:] rel_path = root[len(install_path) + 1:]
for f in files: for f in files:
paths.append(os.path.join(rel_path, f)) paths.append(os.path.join(rel_path, f))
# Check the list against the MANIFEST # Check the list against the MANIFEST
for path in paths: for path in paths:
if path in manifestfiles: if path in manifestfiles:
@ -316,7 +316,7 @@ class ActivityBundle(Bundle):
path) path)
if strict_manifest: if strict_manifest:
os.remove(os.path.join(install_path, path)) os.remove(os.path.join(install_path, path))
# Is anything in MANIFEST left over after accounting for all files? # Is anything in MANIFEST left over after accounting for all files?
if manifestfiles: if manifestfiles:
err = ("Bundle %s: files in MANIFEST not included: %s"% err = ("Bundle %s: files in MANIFEST not included: %s"%

View File

@ -46,7 +46,7 @@ class MalformedBundleException(Exception):
class Bundle(object): class Bundle(object):
"""A Sugar activity, content module, etc. """A Sugar activity, content module, etc.
The bundle itself may be either a zip file or a directory The bundle itself may be either a zip file or a directory
hierarchy, with metadata about the bundle stored various files hierarchy, with metadata about the bundle stored various files
inside it. inside it.
@ -71,7 +71,7 @@ class Bundle(object):
# manifest = self._get_file(self._infodir + '/contents') # manifest = self._get_file(self._infodir + '/contents')
# if manifest is None: # if manifest is None:
# raise MalformedBundleException('No manifest file') # raise MalformedBundleException('No manifest file')
# #
# signature = self._get_file(self._infodir + '/contents.sig') # signature = self._get_file(self._infodir + '/contents.sig')
# if signature is None: # if signature is None:
# raise MalformedBundleException('No signature file') # raise MalformedBundleException('No signature file')
@ -124,7 +124,7 @@ class Bundle(object):
logging.debug('%s not found.', filename) logging.debug('%s not found.', filename)
return f return f
def is_file(self, filename): def is_file(self, filename):
if self._zip_file is None: if self._zip_file is None:
path = os.path.join(self._path, filename) path = os.path.join(self._path, filename)

View File

@ -41,7 +41,7 @@ class DSMetadata(gobject.GObject):
self._props = {} self._props = {}
else: else:
self._props = props self._props = props
default_keys = ['activity', 'activity_id', default_keys = ['activity', 'activity_id',
'mime_type', 'title_set_by_user'] 'mime_type', 'title_set_by_user']
for key in default_keys: for key in default_keys:
@ -61,13 +61,13 @@ class DSMetadata(gobject.GObject):
def __contains__(self, key): def __contains__(self, key):
return self._props.__contains__(key) return self._props.__contains__(key)
def has_key(self, key): def has_key(self, key):
return self._props.has_key(key) return self._props.has_key(key)
def keys(self): def keys(self):
return self._props.keys() return self._props.keys()
def get_dictionary(self): def get_dictionary(self):
return self._props return self._props
@ -93,7 +93,7 @@ class DSObject(object):
metadata = DSMetadata(dbus_helpers.get_properties(self.object_id)) metadata = DSMetadata(dbus_helpers.get_properties(self.object_id))
self._metadata = metadata self._metadata = metadata
return self._metadata return self._metadata
def set_metadata(self, metadata): def set_metadata(self, metadata):
if self._metadata != metadata: if self._metadata != metadata:
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.set_file_path(dbus_helpers.get_filename(self.object_id))
self._owns_file = True self._owns_file = True
return self._file_path return self._file_path
def set_file_path(self, file_path): def set_file_path(self, file_path):
if self._file_path != file_path: if self._file_path != file_path:
if self._file_path and self._owns_file: 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 query['limit'] = limit
if offset: if offset:
query['offset'] = offset query['offset'] = offset
props_list, total_count = dbus_helpers.find(query, properties, props_list, total_count = dbus_helpers.find(query, properties,
reply_handler, error_handler) reply_handler, error_handler)
objects = [] objects = []
for props in props_list: for props in props_list:
object_id = props['uid'] object_id = props['uid']

View File

@ -67,7 +67,7 @@ def update(uid, properties, filename, transfer_ownership=False,
def delete(uid): def delete(uid):
logging.debug('dbus_helpers.delete: %r', uid) logging.debug('dbus_helpers.delete: %r', uid)
_get_data_store().delete(uid) _get_data_store().delete(uid)
def get_properties(uid): def get_properties(uid):
logging.debug('dbus_helpers.get_properties: %s', uid) logging.debug('dbus_helpers.get_properties: %s', uid)
return _get_data_store().get_properties(uid, byte_arrays=True) return _get_data_store().get_properties(uid, byte_arrays=True)

View File

@ -205,7 +205,7 @@ is_keycode (const gchar *string)
* can represent various keyboard keys (numlock, meta, hyper, etc.), * can represent various keyboard keys (numlock, meta, hyper, etc.),
* the virtual modifier represents the keyboard key, the concrete * the virtual modifier represents the keyboard key, the concrete
* modifier the actual Mod2-Mod5 bits in the key press event. * modifier the actual Mod2-Mod5 bits in the key press event.
* *
* Returns: %TRUE on success. * Returns: %TRUE on success.
*/ */
gboolean gboolean
@ -218,7 +218,7 @@ egg_accelerator_parse_virtual (const gchar *accelerator,
GdkModifierType mods; GdkModifierType mods;
gint len; gint len;
gboolean bad_keyval; gboolean bad_keyval;
if (accelerator_key) if (accelerator_key)
*accelerator_key = 0; *accelerator_key = 0;
if (accelerator_mods) if (accelerator_mods)
@ -229,7 +229,7 @@ egg_accelerator_parse_virtual (const gchar *accelerator,
g_return_val_if_fail (accelerator != NULL, FALSE); g_return_val_if_fail (accelerator != NULL, FALSE);
bad_keyval = FALSE; bad_keyval = FALSE;
keyval = 0; keyval = 0;
mods = 0; mods = 0;
len = strlen (accelerator); len = strlen (accelerator);
@ -312,7 +312,7 @@ egg_accelerator_parse_virtual (const gchar *accelerator,
else else
{ {
gchar last_ch; gchar last_ch;
last_ch = *accelerator; last_ch = *accelerator;
while (last_ch && last_ch != '>') while (last_ch && last_ch != '>')
{ {
@ -359,7 +359,7 @@ egg_accelerator_parse_virtual (const gchar *accelerator,
len -= len; len -= len;
} }
} }
if (accelerator_key) if (accelerator_key)
*accelerator_key = gdk_keyval_to_lower (keyval); *accelerator_key = gdk_keyval_to_lower (keyval);
if (accelerator_mods) if (accelerator_mods)
@ -374,7 +374,7 @@ egg_accelerator_parse_virtual (const gchar *accelerator,
* @accelerator_key: accelerator keyval * @accelerator_key: accelerator keyval
* @accelerator_mods: accelerator modifier mask * @accelerator_mods: accelerator modifier mask
* @returns: a newly-allocated accelerator name * @returns: a newly-allocated accelerator name
* *
* Converts an accelerator keyval and modifier mask * Converts an accelerator keyval and modifier mask
* into a string parseable by egg_accelerator_parse_virtual(). * into a string parseable by egg_accelerator_parse_virtual().
* For example, if you pass in #GDK_q and #EGG_VIRTUAL_CONTROL_MASK, * 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); strcpy (accelerator + l, text_super);
l += sizeof (text_super) - 1; l += sizeof (text_super) - 1;
} }
strcpy (accelerator + l, keyval_name); strcpy (accelerator + l, keyval_name);
return accelerator; 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 (GDK_IS_KEYMAP (keymap));
g_return_if_fail (concrete_mods != NULL); g_return_if_fail (concrete_mods != NULL);
modmap = egg_keymap_get_modmap (keymap); modmap = egg_keymap_get_modmap (keymap);
/* Not so sure about this algorithm. */ /* Not so sure about this algorithm. */
concrete = 0; concrete = 0;
i = 0; i = 0;
while (i < EGG_MODMAP_ENTRY_LAST) while (i < EGG_MODMAP_ENTRY_LAST)
@ -542,14 +542,14 @@ egg_keymap_virtualize_modifiers (GdkKeymap *keymap,
GdkModifierType virtual; GdkModifierType virtual;
int i; int i;
const EggModmap *modmap; const EggModmap *modmap;
g_return_if_fail (GDK_IS_KEYMAP (keymap)); g_return_if_fail (GDK_IS_KEYMAP (keymap));
g_return_if_fail (virtual_mods != NULL); g_return_if_fail (virtual_mods != NULL);
modmap = egg_keymap_get_modmap (keymap); modmap = egg_keymap_get_modmap (keymap);
/* Not so sure about this algorithm. */ /* Not so sure about this algorithm. */
virtual = 0; virtual = 0;
i = 0; i = 0;
while (i < EGG_MODMAP_ENTRY_LAST) while (i < EGG_MODMAP_ENTRY_LAST)
@ -557,12 +557,12 @@ egg_keymap_virtualize_modifiers (GdkKeymap *keymap,
if ((1 << i) & concrete_mods) if ((1 << i) & concrete_mods)
{ {
EggVirtualModifierType cleaned; EggVirtualModifierType cleaned;
cleaned = modmap->mapping[i] & ~(EGG_VIRTUAL_MOD2_MASK | cleaned = modmap->mapping[i] & ~(EGG_VIRTUAL_MOD2_MASK |
EGG_VIRTUAL_MOD3_MASK | EGG_VIRTUAL_MOD3_MASK |
EGG_VIRTUAL_MOD4_MASK | EGG_VIRTUAL_MOD4_MASK |
EGG_VIRTUAL_MOD5_MASK); EGG_VIRTUAL_MOD5_MASK);
if (cleaned != 0) if (cleaned != 0)
{ {
virtual |= cleaned; virtual |= cleaned;
@ -575,10 +575,10 @@ egg_keymap_virtualize_modifiers (GdkKeymap *keymap,
virtual |= modmap->mapping[i]; virtual |= modmap->mapping[i];
} }
} }
++i; ++i;
} }
*virtual_mods = virtual; *virtual_mods = virtual;
} }
@ -594,7 +594,7 @@ reload_modmap (GdkKeymap *keymap,
xmodmap = XGetModifierMapping (gdk_x11_get_default_xdisplay ()); xmodmap = XGetModifierMapping (gdk_x11_get_default_xdisplay ());
memset (modmap->mapping, 0, sizeof (modmap->mapping)); memset (modmap->mapping, 0, sizeof (modmap->mapping));
/* there are 8 modifiers, and the first 3 are shift, shift lock, /* there are 8 modifiers, and the first 3 are shift, shift lock,
* and control * and control
*/ */
@ -611,7 +611,7 @@ reload_modmap (GdkKeymap *keymap,
int n_entries; int n_entries;
int j; int j;
EggVirtualModifierType mask; EggVirtualModifierType mask;
keys = NULL; keys = NULL;
keyvals = NULL; keyvals = NULL;
n_entries = 0; n_entries = 0;
@ -619,11 +619,11 @@ reload_modmap (GdkKeymap *keymap,
gdk_keymap_get_entries_for_keycode (keymap, gdk_keymap_get_entries_for_keycode (keymap,
keycode, keycode,
&keys, &keyvals, &n_entries); &keys, &keyvals, &n_entries);
mask = 0; mask = 0;
j = 0; j = 0;
while (j < n_entries) while (j < n_entries)
{ {
if (keyvals[j] == GDK_Num_Lock) if (keyvals[j] == GDK_Num_Lock)
mask |= EGG_VIRTUAL_NUM_LOCK_MASK; mask |= EGG_VIRTUAL_NUM_LOCK_MASK;
else if (keyvals[j] == GDK_Scroll_Lock) else if (keyvals[j] == GDK_Scroll_Lock)
@ -639,19 +639,19 @@ reload_modmap (GdkKeymap *keymap,
mask |= EGG_VIRTUAL_SUPER_MASK; mask |= EGG_VIRTUAL_SUPER_MASK;
else if (keyvals[j] == GDK_Mode_switch) else if (keyvals[j] == GDK_Mode_switch)
mask |= EGG_VIRTUAL_MODE_SWITCH_MASK; mask |= EGG_VIRTUAL_MODE_SWITCH_MASK;
++j; ++j;
} }
/* Mod1Mask is 1 << 3 for example, i.e. the /* Mod1Mask is 1 << 3 for example, i.e. the
* fourth modifier, i / keyspermod is the modifier * fourth modifier, i / keyspermod is the modifier
* index * index
*/ */
modmap->mapping[i/xmodmap->max_keypermod] |= mask; modmap->mapping[i/xmodmap->max_keypermod] |= mask;
g_free (keyvals); g_free (keyvals);
g_free (keys); g_free (keys);
++i; ++i;
} }
@ -664,7 +664,7 @@ reload_modmap (GdkKeymap *keymap,
modmap->mapping[EGG_MODMAP_ENTRY_MOD3] |= EGG_VIRTUAL_MOD3_MASK; 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_MOD4] |= EGG_VIRTUAL_MOD4_MASK;
modmap->mapping[EGG_MODMAP_ENTRY_MOD5] |= EGG_VIRTUAL_MOD5_MASK; modmap->mapping[EGG_MODMAP_ENTRY_MOD5] |= EGG_VIRTUAL_MOD5_MASK;
XFreeModifiermap (xmodmap); XFreeModifiermap (xmodmap);
} }
@ -676,7 +676,7 @@ egg_keymap_get_modmap (GdkKeymap *keymap)
/* This is all a hack, much simpler when we can just /* This is all a hack, much simpler when we can just
* modify GDK directly. * modify GDK directly.
*/ */
modmap = g_object_get_data (G_OBJECT (keymap), modmap = g_object_get_data (G_OBJECT (keymap),
"egg-modmap"); "egg-modmap");
@ -687,9 +687,9 @@ egg_keymap_get_modmap (GdkKeymap *keymap)
/* FIXME modify keymap change events with an event filter /* FIXME modify keymap change events with an event filter
* and force a reload if we get one * and force a reload if we get one
*/ */
reload_modmap (keymap, modmap); reload_modmap (keymap, modmap);
g_object_set_data_full (G_OBJECT (keymap), g_object_set_data_full (G_OBJECT (keymap),
"egg-modmap", "egg-modmap",
modmap, modmap,
@ -697,6 +697,6 @@ egg_keymap_get_modmap (GdkKeymap *keymap)
} }
g_assert (modmap != NULL); g_assert (modmap != NULL);
return modmap; return modmap;
} }

View File

@ -36,7 +36,7 @@ typedef enum
EGG_VIRTUAL_CONTROL_MASK = 1 << 2, EGG_VIRTUAL_CONTROL_MASK = 1 << 2,
EGG_VIRTUAL_ALT_MASK = 1 << 3, /* fixed as Mod1 */ EGG_VIRTUAL_ALT_MASK = 1 << 3, /* fixed as Mod1 */
EGG_VIRTUAL_MOD2_MASK = 1 << 4, EGG_VIRTUAL_MOD2_MASK = 1 << 4,
EGG_VIRTUAL_MOD3_MASK = 1 << 5, EGG_VIRTUAL_MOD3_MASK = 1 << 5,
EGG_VIRTUAL_MOD4_MASK = 1 << 6, EGG_VIRTUAL_MOD4_MASK = 1 << 6,
@ -50,11 +50,11 @@ typedef enum
GDK_BUTTON5_MASK = 1 << 12, GDK_BUTTON5_MASK = 1 << 12,
/* 13, 14 are used by Xkb for the keyboard group */ /* 13, 14 are used by Xkb for the keyboard group */
#endif #endif
EGG_VIRTUAL_META_MASK = 1 << 24, EGG_VIRTUAL_META_MASK = 1 << 24,
EGG_VIRTUAL_SUPER_MASK = 1 << 25, EGG_VIRTUAL_SUPER_MASK = 1 << 25,
EGG_VIRTUAL_HYPER_MASK = 1 << 26, 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_NUM_LOCK_MASK = 1 << 28,
EGG_VIRTUAL_SCROLL_LOCK_MASK = 1 << 29, 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 /* 28-31 24-27 20-23 16-19 12-15 8-11 4-7 0-3
* 7 f 0 0 0 0 f f * 7 f 0 0 0 0 f f
*/ */
EGG_VIRTUAL_MODIFIER_MASK = 0x7f0000ff EGG_VIRTUAL_MODIFIER_MASK = 0x7f0000ff
} EggVirtualModifierType; } EggVirtualModifierType;

View File

@ -155,7 +155,7 @@ egg_desktop_file_new_from_key_file (GKeyFile *key_file,
g_key_file_free (key_file); g_key_file_free (key_file);
return NULL; return NULL;
} }
else else
g_free (version); g_free (version);
} }
@ -1334,7 +1334,7 @@ egg_desktop_file_launch (EggDesktopFile *desktop_file,
EGG_DESKTOP_FILE_ERROR_NOT_LAUNCHABLE, EGG_DESKTOP_FILE_ERROR_NOT_LAUNCHABLE,
_("Can't pass document URIs to a 'Type=Link' desktop entry")); _("Can't pass document URIs to a 'Type=Link' desktop entry"));
return FALSE; return FALSE;
} }
if (!parse_link (desktop_file, &app_desktop_file, &documents, error)) if (!parse_link (desktop_file, &app_desktop_file, &documents, error))
return FALSE; return FALSE;
@ -1418,10 +1418,10 @@ egg_set_desktop_file (const char *desktop_file_path)
/** /**
* egg_get_desktop_file: * egg_get_desktop_file:
* *
* Gets the application's #EggDesktopFile, as set by * Gets the application's #EggDesktopFile, as set by
* egg_set_desktop_file(). * egg_set_desktop_file().
* *
* Return value: the #EggDesktopFile, or %NULL if it hasn't been set. * Return value: the #EggDesktopFile, or %NULL if it hasn't been set.
**/ **/
EggDesktopFile * EggDesktopFile *

View File

@ -281,7 +281,7 @@ sm_client_xsmp_connect (gpointer user_data)
if (xsmp->restart_style == SmRestartIfRunning) 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)) "X-GNOME-AutoRestart", NULL))
xsmp->restart_style = SmRestartImmediately; xsmp->restart_style = SmRestartImmediately;
} }
@ -1120,7 +1120,7 @@ delete_properties (EggSMClientXSMP *xsmp, ...)
* until you're done with the SmProp. * until you're done with the SmProp.
*/ */
static SmProp * static SmProp *
array_prop (const char *name, ...) array_prop (const char *name, ...)
{ {
SmProp *prop; SmProp *prop;
SmPropValue pv; SmPropValue pv;
@ -1338,13 +1338,13 @@ ice_error_handler (IceConn ice_conn,
IcePointer values) IcePointer values)
{ {
/* Do nothing */ /* Do nothing */
} }
static void static void
ice_io_error_handler (IceConn ice_conn) ice_io_error_handler (IceConn ice_conn)
{ {
/* Do nothing */ /* Do nothing */
} }
static void static void
smc_error_handler (SmcConn smc_conn, smc_error_handler (SmcConn smc_conn,

View File

@ -114,7 +114,7 @@ egg_sm_client_class_init (EggSMClientClass *klass)
* handling this signal; if the user has requested that the session * handling this signal; if the user has requested that the session
* be saved when logging out, then ::save_state will be emitted * be saved when logging out, then ::save_state will be emitted
* separately. * separately.
* *
* If the application agrees to quit, it should then wait for either * If the application agrees to quit, it should then wait for either
* the ::quit_cancelled or ::quit signals to be emitted. * the ::quit_cancelled or ::quit signals to be emitted.
**/ **/

View File

@ -50,7 +50,7 @@ import gtk
import gobject import gobject
import hippo import hippo
import math import math
from sugar.graphics import style from sugar.graphics import style
from sugar.graphics.icon import Icon from sugar.graphics.icon import Icon
@ -111,24 +111,24 @@ class Alert(gtk.EventBox):
self._msg_label.set_alignment(0, 0.5) self._msg_label.set_alignment(0, 0.5)
self._msg_box.pack_start(self._msg_label, False) self._msg_box.pack_start(self._msg_label, False)
self._hbox.pack_start(self._msg_box, False) self._hbox.pack_start(self._msg_box, False)
self._buttons_box = gtk.HButtonBox() self._buttons_box = gtk.HButtonBox()
self._buttons_box.set_layout(gtk.BUTTONBOX_END) self._buttons_box.set_layout(gtk.BUTTONBOX_END)
self._buttons_box.set_spacing(style.DEFAULT_SPACING) self._buttons_box.set_spacing(style.DEFAULT_SPACING)
self._hbox.pack_start(self._buttons_box) self._hbox.pack_start(self._buttons_box)
gobject.GObject.__init__(self, **kwargs) gobject.GObject.__init__(self, **kwargs)
self.set_visible_window(True) self.set_visible_window(True)
self.add(self._hbox) self.add(self._hbox)
self._title_label.show() self._title_label.show()
self._msg_label.show() self._msg_label.show()
self._buttons_box.show() self._buttons_box.show()
self._msg_box.show() self._msg_box.show()
self._hbox.show() self._hbox.show()
self.show() self.show()
def do_set_property(self, pspec, value): def do_set_property(self, pspec, value):
""" """
Set alert property Set alert property
@ -299,21 +299,21 @@ class _TimeoutIcon(hippo.CanvasText, hippo.CanvasItem):
def __init__(self, **kwargs): def __init__(self, **kwargs):
hippo.CanvasText.__init__(self, **kwargs) hippo.CanvasText.__init__(self, **kwargs)
self.props.orientation = hippo.ORIENTATION_HORIZONTAL self.props.orientation = hippo.ORIENTATION_HORIZONTAL
self.props.border_left = style.DEFAULT_SPACING self.props.border_left = style.DEFAULT_SPACING
self.props.border_right = style.DEFAULT_SPACING self.props.border_right = style.DEFAULT_SPACING
def do_paint_background(self, cr, damaged_box): def do_paint_background(self, cr, damaged_box):
[width, height] = self.get_allocation() [width, height] = self.get_allocation()
xval = width * 0.5 xval = width * 0.5
yval = height * 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) hippo.cairo_set_source_rgba32(cr, self.props.background_color)
cr.arc(xval, yval, radius, 0, 2*math.pi) cr.arc(xval, yval, radius, 0, 2*math.pi)
cr.fill_preserve() cr.fill_preserve()
class TimeoutAlert(Alert): class TimeoutAlert(Alert):
@ -362,22 +362,22 @@ class TimeoutAlert(Alert):
Alert.__init__(self, **kwargs) Alert.__init__(self, **kwargs)
self._timeout = timeout self._timeout = timeout
icon = Icon(icon_name='dialog-cancel') icon = Icon(icon_name='dialog-cancel')
self.add_button(gtk.RESPONSE_CANCEL, _('Cancel'), icon) self.add_button(gtk.RESPONSE_CANCEL, _('Cancel'), icon)
icon.show() icon.show()
self._timeout_text = _TimeoutIcon( self._timeout_text = _TimeoutIcon(
text=self._timeout, text=self._timeout,
color=style.COLOR_BUTTON_GREY.get_int(), 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 = hippo.Canvas()
canvas.set_root(self._timeout_text) canvas.set_root(self._timeout_text)
canvas.show() canvas.show()
self.add_button(gtk.RESPONSE_OK, _('Continue'), canvas) self.add_button(gtk.RESPONSE_OK, _('Continue'), canvas)
gobject.timeout_add_seconds(1, self.__timeout) gobject.timeout_add_seconds(1, self.__timeout)
def __timeout(self): def __timeout(self):
self._timeout -= 1 self._timeout -= 1
self._timeout_text.props.text = self._timeout self._timeout_text.props.text = self._timeout

View File

@ -31,7 +31,7 @@ class Animator(gobject.GObject):
'completed': (gobject.SIGNAL_RUN_FIRST, 'completed': (gobject.SIGNAL_RUN_FIRST,
gobject.TYPE_NONE, ([])), gobject.TYPE_NONE, ([])),
} }
def __init__(self, duration, fps=20, easing=EASE_OUT_EXPO): def __init__(self, duration, fps=20, easing=EASE_OUT_EXPO):
gobject.GObject.__init__(self) gobject.GObject.__init__(self)
self._animations = [] self._animations = []

View File

@ -29,11 +29,11 @@ class CanvasTextView(hippo.CanvasWidget):
self.text_view_widget.props.right_margin = style.DEFAULT_SPACING self.text_view_widget.props.right_margin = style.DEFAULT_SPACING
self.text_view_widget.props.wrap_mode = gtk.WRAP_WORD self.text_view_widget.props.wrap_mode = gtk.WRAP_WORD
self.text_view_widget.show() self.text_view_widget.show()
# TODO: These fields should expand vertically instead of scrolling # TODO: These fields should expand vertically instead of scrolling
scrolled_window = gtk.ScrolledWindow() scrolled_window = gtk.ScrolledWindow()
scrolled_window.set_shadow_type(gtk.SHADOW_OUT) scrolled_window.set_shadow_type(gtk.SHADOW_OUT)
scrolled_window.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC) scrolled_window.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
scrolled_window.add(self.text_view_widget) scrolled_window.add(self.text_view_widget)
self.props.widget = scrolled_window self.props.widget = scrolled_window

View File

@ -29,7 +29,7 @@ from sugar.graphics.palette import Palette, ToolInvoker, WidgetInvoker
_ = lambda msg: gettext.dgettext('sugar-toolkit', msg) _ = lambda msg: gettext.dgettext('sugar-toolkit', msg)
def get_svg_color_string(color): 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) color.blue / 257)
class _ColorButton(gtk.Button): 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 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. the current color, and the stroke color is set to the font color.
""" """
__gtype_name__ = 'SugarColorButton' __gtype_name__ = 'SugarColorButton'
__gsignals__ = { 'color-set' : (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, __gsignals__ = { 'color-set' : (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
tuple())} tuple())}
def __init__(self, **kwargs): def __init__(self, **kwargs):
self._title = _('Choose a color') self._title = _('Choose a color')
self._color = gtk.gdk.Color(0, 0, 0) self._color = gtk.gdk.Color(0, 0, 0)
@ -92,10 +92,10 @@ class _ColorButton(gtk.Button):
def __palette_color_set_cb(self, palette): def __palette_color_set_cb(self, palette):
self.emit('color-set') self.emit('color-set')
def __palette_color_changed(self, palette, pspec): def __palette_color_changed(self, palette, pspec):
self.color = self._palette.color self.color = self._palette.color
def do_style_set(self, previous_style): def do_style_set(self, previous_style):
self._preview.stroke_color = \ self._preview.stroke_color = \
get_svg_color_string(self.style.fg[gtk.STATE_NORMAL]) get_svg_color_string(self.style.fg[gtk.STATE_NORMAL])
@ -111,12 +111,12 @@ class _ColorButton(gtk.Button):
def set_color(self, color): def set_color(self, color):
assert isinstance(color, gtk.gdk.Color) assert isinstance(color, gtk.gdk.Color)
if self._color.red == color.red and \ if self._color.red == color.red and \
self._color.green == color.green and \ self._color.green == color.green and \
self._color.blue == color.blue: self._color.blue == color.blue:
return return
self._color = gtk.gdk.Color(color.red, color.green, color.blue) self._color = gtk.gdk.Color(color.red, color.green, color.blue)
self._preview.fill_color = get_svg_color_string(self._color) self._preview.fill_color = get_svg_color_string(self._color)
if self._palette: if self._palette:
@ -201,9 +201,9 @@ class _ColorButton(gtk.Button):
red = self._color.red / 257 red = self._color.red / 257
green = self._color.green / 257 green = self._color.green / 257
blue = self._color.blue / 257 blue = self._color.blue / 257
pixbuf.fill(red << 24 + green << 16 + blue << 8 + 0xff) pixbuf.fill(red << 24 + green << 16 + blue << 8 + 0xff)
context.set_icon_pixbuf(pixbuf) context.set_icon_pixbuf(pixbuf)
def __drag_data_get_cb(self, widget, context, selection_data, info, time): 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(self._swatch_tray)
self._picker_hbox.pack_start(gtk.VSeparator(), self._picker_hbox.pack_start(gtk.VSeparator(),
padding=style.DEFAULT_SPACING) padding=style.DEFAULT_SPACING)
self._chooser_table = gtk.Table(3, 2) self._chooser_table = gtk.Table(3, 2)
self._chooser_table.set_col_spacing(0, style.DEFAULT_PADDING) 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._create_color_scale(_('Blue'), self._BLUE, 2))
self._picker_hbox.add(self._chooser_table) self._picker_hbox.add(self._chooser_table)
self._picker_hbox.show_all() self._picker_hbox.show_all()
self._build_swatches() self._build_swatches()
@ -300,7 +300,7 @@ class _ColorPalette(Palette):
return scale return scale
def _build_swatches(self): def _build_swatches(self):
for child in self._swatch_tray.get_children(): for child in self._swatch_tray.get_children():
@ -370,12 +370,12 @@ class _ColorPalette(Palette):
return return
self._color = color.copy() self._color = color.copy()
if self._scales: if self._scales:
self._scales[self._RED].set_value(self._color.red / 65535.0) 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._GREEN].set_value(self._color.green / 65535.0)
self._scales[self._BLUE].set_value(self._color.blue / 65535.0) self._scales[self._BLUE].set_value(self._color.blue / 65535.0)
self.notify('color') self.notify('color')
def get_color(self): def get_color(self):

View File

@ -23,7 +23,7 @@ import gobject
import gtk import gtk
class ComboBox(gtk.ComboBox): class ComboBox(gtk.ComboBox):
__gtype_name__ = 'SugarComboBox' __gtype_name__ = 'SugarComboBox'
def __init__(self): def __init__(self):
gtk.ComboBox.__init__(self) gtk.ComboBox.__init__(self)
@ -129,7 +129,7 @@ class ComboBox(gtk.ComboBox):
None None
""" """
self._model.append([0, None, None, True]) self._model.append([0, None, None, True])
def get_active_item(self): def get_active_item(self):
""" """

View File

@ -337,10 +337,10 @@ class Icon(gtk.Image):
if self._buffer.file_name != self.props.file: if self._buffer.file_name != self.props.file:
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) width, height = gtk.icon_size_lookup(self.props.icon_size)
else: else:
width = height = self.props.pixel_size width = height = self.props.pixel_size
if self._buffer.width != width or self._buffer.height != height: if self._buffer.width != width or self._buffer.height != height:
self._buffer.width = width self._buffer.width = width
self._buffer.height = height self._buffer.height = height
@ -917,7 +917,7 @@ class CanvasIcon(hippo.CanvasBox, hippo.CanvasItem):
def get_palette_invoker(self): def get_palette_invoker(self):
return self._palette_invoker return self._palette_invoker
def set_palette_invoker(self, palette_invoker): def set_palette_invoker(self, palette_invoker):
self._palette_invoker.detach() self._palette_invoker.detach()
self._palette_invoker = palette_invoker self._palette_invoker = palette_invoker
@ -929,7 +929,7 @@ class CanvasIcon(hippo.CanvasBox, hippo.CanvasItem):
from sugar.graphics.palette import Palette from sugar.graphics.palette import Palette
self.set_palette(Palette(text)) self.set_palette(Palette(text))
palette = property(get_palette, set_palette) palette = property(get_palette, set_palette)
class CellRendererIcon(gtk.GenericCellRenderer): class CellRendererIcon(gtk.GenericCellRenderer):
@ -1019,7 +1019,7 @@ class CellRendererIcon(gtk.GenericCellRenderer):
if self._buffer.background_color != value: if self._buffer.background_color != value:
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) setter=set_background_color)
def set_size(self, value): def set_size(self, value):

View File

@ -17,7 +17,7 @@
"""Notebook class """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 a close button in every tab when the 'can-close-tabs' gproperty
is enabled (True) is enabled (True)
@ -38,11 +38,11 @@ class Notebook(gtk.Notebook):
def __init__(self, **kwargs): def __init__(self, **kwargs):
# Initialise the Widget # Initialise the Widget
#
# Side effects: # Side effects:
# Set the 'can-close-tabs' property using **kwargs # Set the 'can-close-tabs' property using **kwargs
# Set True the scrollable notebook property # Set True the scrollable notebook property
gobject.GObject.__init__(self, **kwargs) gobject.GObject.__init__(self, **kwargs)
self._can_close_tabs = None self._can_close_tabs = None
@ -108,7 +108,7 @@ class Notebook(gtk.Notebook):
tab_box.show_all() tab_box.show_all()
event_box.add(tab_box) event_box.add(tab_box)
return event_box return event_box
def add_page(self, text_label, widget): def add_page(self, text_label, widget):
@ -130,16 +130,16 @@ class Notebook(gtk.Notebook):
# Add a new page to the notebook # Add a new page to the notebook
if self._can_close_tabs: if self._can_close_tabs:
eventbox = self._create_custom_tab(text_label, widget) eventbox = self._create_custom_tab(text_label, widget)
self.append_page(widget, eventbox) self.append_page(widget, eventbox)
else: else:
self.append_page(widget, gtk.Label(text_label)) self.append_page(widget, gtk.Label(text_label))
pages = self.get_n_pages() pages = self.get_n_pages()
# Set the new page # Set the new page
self.set_current_page(pages - 1) self.set_current_page(pages - 1)
self.show_all() self.show_all()
return True return True
def _close_page(self, button, child): def _close_page(self, button, child):

View File

@ -56,7 +56,7 @@ class ObjectChooser(object):
self._chooser_id = None self._chooser_id = None
self._response_code = gtk.RESPONSE_NONE self._response_code = gtk.RESPONSE_NONE
self._what_filter = what_filter self._what_filter = what_filter
def run(self): def run(self):
self._object_id = None self._object_id = None

View File

@ -45,7 +45,7 @@ class Palette(PaletteWindow):
__gtype_name__ = 'SugarPalette' __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 # 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, def __init__(self, label=None, accel_path=None, menu_after_content=False,
text_maxlen=60, **kwargs): text_maxlen=60, **kwargs):
@ -67,9 +67,9 @@ class Palette(PaletteWindow):
primary_box.pack_start(self._icon_box, expand=False) primary_box.pack_start(self._icon_box, expand=False)
labels_box = gtk.VBox() 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) 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) style.DEFAULT_SPACING)
self._label_alignment.add(labels_box) self._label_alignment.add(labels_box)
self._label_alignment.show() self._label_alignment.show()
@ -182,7 +182,7 @@ class Palette(PaletteWindow):
if self._invoker is not None: if self._invoker is not None:
self._update_full_request() self._update_full_request()
PaletteWindow.popup(self, immediate) PaletteWindow.popup(self, immediate)
if state is None: if state is None:
@ -194,7 +194,7 @@ class Palette(PaletteWindow):
def on_enter(self, event): def on_enter(self, event):
PaletteWindow.on_enter(self, event) PaletteWindow.on_enter(self, event)
self._secondary_anim.start() self._secondary_anim.start()
def _add_menu(self): def _add_menu(self):
self._menu_box = gtk.VBox() self._menu_box = gtk.VBox()
self._secondary_box.pack_start(self._menu_box) self._secondary_box.pack_start(self._menu_box)

View File

@ -76,7 +76,7 @@ class Group(gobject.GObject):
def popdown(self): def popdown(self):
for palette in self._palettes: for palette in self._palettes:
if palette.is_up(): if palette.is_up():
palette.popdown(immediate=True) palette.popdown(immediate=True)
def _palette_popup_cb(self, palette): def _palette_popup_cb(self, palette):

View File

@ -47,7 +47,7 @@ def _calculate_gap(a, b):
gap_side = gtk.POS_TOP gap_side = gtk.POS_TOP
else: else:
gap = False gap = False
if gap: if gap:
if gap_side == gtk.POS_BOTTOM or gap_side == gtk.POS_TOP: if gap_side == gtk.POS_BOTTOM or gap_side == gtk.POS_TOP:
gap_start = min(a.width, max(0, b.x - a.x)) gap_start = min(a.width, max(0, b.x - a.x))
@ -181,7 +181,7 @@ class PaletteWindow(gtk.Window):
self.set_group_id(None) self.set_group_id(None)
def set_invoker(self, invoker): def set_invoker(self, invoker):
for hid in self._invoker_hids[:]: for hid in self._invoker_hids[:]:
self._invoker.disconnect(hid) self._invoker.disconnect(hid)
self._invoker_hids.remove(hid) self._invoker_hids.remove(hid)
@ -212,7 +212,7 @@ class PaletteWindow(gtk.Window):
immediate = False immediate = False
if self.is_up(): if self.is_up():
self._popdown_anim.stop() self._popdown_anim.stop()
return return
if self._group_id: if self._group_id:
@ -629,7 +629,7 @@ class Invoker(gobject.GObject):
def get_palette(self): def get_palette(self):
return self._palette return self._palette
def set_palette(self, palette): def set_palette(self, palette):
if self._palette: if self._palette:
self._palette.props.invoker = None self._palette.props.invoker = None
@ -787,7 +787,7 @@ class CanvasInvoker(Invoker):
return gtk.gdk.Rectangle(x, y, width, height) return gtk.gdk.Rectangle(x, y, width, height)
else: else:
return gtk.gdk.Rectangle() return gtk.gdk.Rectangle()
def __motion_notify_event_cb(self, button, event): def __motion_notify_event_cb(self, button, event):
if event.detail == hippo.MOTION_DETAIL_ENTER: if event.detail == hippo.MOTION_DETAIL_ENTER:
self.notify_mouse_enter() self.notify_mouse_enter()

View File

@ -154,7 +154,7 @@ class RadioToolButton(gtk.RadioToolButton):
def get_palette_invoker(self): def get_palette_invoker(self):
return self._palette_invoker return self._palette_invoker
def set_palette_invoker(self, palette_invoker): def set_palette_invoker(self, palette_invoker):
self._palette_invoker.detach() self._palette_invoker.detach()
self._palette_invoker = palette_invoker self._palette_invoker = palette_invoker

View File

@ -35,13 +35,13 @@ class CanvasRoundBox(hippo.CanvasBox, hippo.CanvasItem):
# TODO: we should calculate radius depending on the height of the box. # TODO: we should calculate radius depending on the height of the box.
self._radius = style.zoom(10) self._radius = style.zoom(10)
self.props.orientation = hippo.ORIENTATION_HORIZONTAL self.props.orientation = hippo.ORIENTATION_HORIZONTAL
self.props.border = self._BORDER_DEFAULT self.props.border = self._BORDER_DEFAULT
self.props.border_left = self._radius self.props.border_left = self._radius
self.props.border_right = self._radius self.props.border_right = self._radius
self.props.border_color = style.COLOR_BLACK.get_int() self.props.border_color = style.COLOR_BLACK.get_int()
def do_paint_background(self, cr, damaged_box): def do_paint_background(self, cr, damaged_box):
[width, height] = self.get_allocation() [width, height] = self.get_allocation()

View File

@ -59,7 +59,7 @@ class ToggleToolButton(gtk.ToggleToolButton):
def get_palette_invoker(self): def get_palette_invoker(self):
return self._palette_invoker return self._palette_invoker
def set_palette_invoker(self, palette_invoker): def set_palette_invoker(self, palette_invoker):
self._palette_invoker.detach() self._palette_invoker.detach()
self._palette_invoker = palette_invoker self._palette_invoker = palette_invoker
@ -69,7 +69,7 @@ class ToggleToolButton(gtk.ToggleToolButton):
def set_tooltip(self, text): def set_tooltip(self, text):
self.set_palette(Palette(text)) self.set_palette(Palette(text))
def do_expose_event(self, event): def do_expose_event(self, event):
allocation = self.get_allocation() allocation = self.get_allocation()
child = self.get_child() child = self.get_child()
@ -85,5 +85,5 @@ class ToggleToolButton(gtk.ToggleToolButton):
allocation.width, allocation.height) allocation.width, allocation.height)
gtk.ToggleToolButton.do_expose_event(self, event) gtk.ToggleToolButton.do_expose_event(self, event)
palette = property(get_palette, set_palette) palette = property(get_palette, set_palette)

View File

@ -27,7 +27,7 @@ from sugar.graphics import palettegroup
class ToolbarButton(ToolButton): class ToolbarButton(ToolButton):
def __init__(self, page=None, **kwargs): def __init__(self, page=None, **kwargs):
ToolButton.__init__(self, **kwargs) ToolButton.__init__(self, **kwargs)
self.page_widget = None self.page_widget = None
self.set_page(page) self.set_page(page)

View File

@ -36,7 +36,7 @@ class Toolbox(gtk.VBox):
def __init__(self): def __init__(self):
gtk.VBox.__init__(self) gtk.VBox.__init__(self)
self._notebook = gtk.Notebook() self._notebook = gtk.Notebook()
self._notebook.set_tab_pos(gtk.POS_BOTTOM) self._notebook.set_tab_pos(gtk.POS_BOTTOM)
self._notebook.set_show_border(False) self._notebook.set_show_border(False)
@ -55,12 +55,12 @@ class Toolbox(gtk.VBox):
border_bottom=style.LINE_WIDTH) border_bottom=style.LINE_WIDTH)
self._separator.set_root(box) self._separator.set_root(box)
self.pack_start(self._separator, False) self.pack_start(self._separator, False)
self._notebook.connect('notify::page', self._notify_page_cb) self._notebook.connect('notify::page', self._notify_page_cb)
def _notify_page_cb(self, notebook, pspec): def _notify_page_cb(self, notebook, pspec):
self.emit('current-toolbar-changed', notebook.props.page) self.emit('current-toolbar-changed', notebook.props.page)
def add_toolbar(self, name, toolbar): def add_toolbar(self, name, toolbar):
label = gtk.Label(name) label = gtk.Label(name)
width, height_ = label.size_request() width, height_ = label.size_request()
@ -68,7 +68,7 @@ class Toolbox(gtk.VBox):
label.set_alignment(0.0, 0.5) label.set_alignment(0.0, 0.5)
event_box = gtk.EventBox() event_box = gtk.EventBox()
alignment = gtk.Alignment(0.0, 0.0, 1.0, 1.0) alignment = gtk.Alignment(0.0, 0.0, 1.0, 1.0)
alignment.set_padding(0, 0, style.TOOLBOX_HORIZONTAL_PADDING, alignment.set_padding(0, 0, style.TOOLBOX_HORIZONTAL_PADDING,
style.TOOLBOX_HORIZONTAL_PADDING) style.TOOLBOX_HORIZONTAL_PADDING)
@ -83,7 +83,7 @@ class Toolbox(gtk.VBox):
if self._notebook.get_n_pages() > 1: if self._notebook.get_n_pages() > 1:
self._notebook.set_show_tabs(True) self._notebook.set_show_tabs(True)
self._separator.show() self._separator.show()
def remove_toolbar(self, index): def remove_toolbar(self, index):
self._notebook.remove_page(index) self._notebook.remove_page(index)
@ -96,6 +96,6 @@ class Toolbox(gtk.VBox):
def get_current_toolbar(self): def get_current_toolbar(self):
return self._notebook.get_current_page() return self._notebook.get_current_page()
current_toolbar = property(get_current_toolbar, set_current_toolbar) current_toolbar = property(get_current_toolbar, set_current_toolbar)

View File

@ -128,7 +128,7 @@ class ToolButton(gtk.ToolButton):
def get_palette_invoker(self): def get_palette_invoker(self):
return self._palette_invoker return self._palette_invoker
def set_palette_invoker(self, palette_invoker): def set_palette_invoker(self, palette_invoker):
self._palette_invoker.detach() self._palette_invoker.detach()
self._palette_invoker = palette_invoker self._palette_invoker = palette_invoker

View File

@ -64,7 +64,7 @@ class _TrayViewport(gtk.Viewport):
adj = self.get_vadjustment() adj = self.get_vadjustment()
adj.connect('changed', self._adjustment_changed_cb) adj.connect('changed', self._adjustment_changed_cb)
adj.connect('value-changed', self._adjustment_changed_cb) adj.connect('value-changed', self._adjustment_changed_cb)
def scroll(self, direction): def scroll(self, direction):
if direction == _PREVIOUS_PAGE: if direction == _PREVIOUS_PAGE:
self._scroll_previous() self._scroll_previous()
@ -447,7 +447,7 @@ class TrayIcon(gtk.ToolItem):
def get_palette_invoker(self): def get_palette_invoker(self):
return self._palette_invoker return self._palette_invoker
def set_palette_invoker(self, palette_invoker): def set_palette_invoker(self, palette_invoker):
self._palette_invoker.detach() self._palette_invoker.detach()
self._palette_invoker = palette_invoker self._palette_invoker = palette_invoker

View File

@ -86,12 +86,12 @@ class Window(gtk.Window):
self.connect('realize', self.__window_realize_cb) self.connect('realize', self.__window_realize_cb)
self.connect('window-state-event', self.__window_state_event_cb) self.connect('window-state-event', self.__window_state_event_cb)
self.connect('key-press-event', self.__key_press_cb) self.connect('key-press-event', self.__key_press_cb)
self._toolbar_box = None self._toolbar_box = None
self._alerts = [] self._alerts = []
self._canvas = None self._canvas = None
self.tray = None self.tray = None
self._vbox = gtk.VBox() self._vbox = gtk.VBox()
self._hbox = gtk.HBox() self._hbox = gtk.HBox()
self._vbox.pack_start(self._hbox) self._vbox.pack_start(self._hbox)
@ -100,7 +100,7 @@ class Window(gtk.Window):
self._event_box = gtk.EventBox() self._event_box = gtk.EventBox()
self._hbox.pack_start(self._event_box) self._hbox.pack_start(self._event_box)
self._event_box.show() 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) | gtk.gdk.POINTER_MOTION_MASK)
self._event_box.connect('motion-notify-event', self.__motion_notify_cb) self._event_box.connect('motion-notify-event', self.__motion_notify_cb)
@ -120,7 +120,7 @@ class Window(gtk.Window):
if canvas: if canvas:
self._event_box.add(canvas) self._event_box.add(canvas)
self._canvas = canvas self._canvas = canvas
def get_canvas(self): def get_canvas(self):
@ -144,16 +144,16 @@ class Window(gtk.Window):
def set_tray(self, tray, position): def set_tray(self, tray, position):
if self.tray: if self.tray:
box = self.tray.get_parent() box = self.tray.get_parent()
box.remove(self.tray) box.remove(self.tray)
if position == gtk.POS_LEFT: if position == gtk.POS_LEFT:
self._hbox.pack_start(tray, False) self._hbox.pack_start(tray, False)
elif position == gtk.POS_RIGHT: elif position == gtk.POS_RIGHT:
self._hbox.pack_end(tray, False) self._hbox.pack_end(tray, False)
elif position == gtk.POS_BOTTOM: elif position == gtk.POS_BOTTOM:
self._vbox.pack_end(tray, False) self._vbox.pack_end(tray, False)
self.tray = tray self.tray = tray
def add_alert(self, alert): def add_alert(self, alert):
@ -162,14 +162,14 @@ class Window(gtk.Window):
self._vbox.pack_start(alert, False) self._vbox.pack_start(alert, False)
if self._toolbar_box is not None: if self._toolbar_box is not None:
self._vbox.reorder_child(alert, 1) self._vbox.reorder_child(alert, 1)
else: else:
self._vbox.reorder_child(alert, 0) self._vbox.reorder_child(alert, 0)
def remove_alert(self, alert): def remove_alert(self, alert):
if alert in self._alerts: if alert in self._alerts:
self._alerts.remove(alert) self._alerts.remove(alert)
# if the alert is the visible one on top of the queue # 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) self._vbox.remove(alert)
if len(self._alerts) >= 1: if len(self._alerts) >= 1:
self._vbox.pack_start(self._alerts[0], False) self._vbox.pack_start(self._alerts[0], False)
@ -177,7 +177,7 @@ class Window(gtk.Window):
self._vbox.reorder_child(self._alerts[0], 1) self._vbox.reorder_child(self._alerts[0], 1)
else: else:
self._vbox.reorder_child(self._alert[0], 0) self._vbox.reorder_child(self._alert[0], 0)
def __window_realize_cb(self, window): def __window_realize_cb(self, window):
group = gtk.Window() group = gtk.Window()
group.realize() group.realize()

View File

@ -315,7 +315,7 @@ gsm_app_provides (GsmApp *app, const char *service)
return FALSE; return FALSE;
} }
static void static void
app_exited (GPid pid, gint status, gpointer data) app_exited (GPid pid, gint status, gpointer data)
{ {
if (WIFEXITED (status)) if (WIFEXITED (status))

View File

@ -63,7 +63,7 @@ pid_t gsm_app_launch (GsmApp *app,
void gsm_app_set_client (GsmApp *app, void gsm_app_set_client (GsmApp *app,
GsmClient *client); GsmClient *client);
void gsm_app_registered (GsmApp *app); void gsm_app_registered (GsmApp *app);
G_END_DECLS G_END_DECLS

View File

@ -192,7 +192,7 @@ register_client_callback (SmsConn conn,
GsmClientXSMP *xsmp = manager_data; GsmClientXSMP *xsmp = manager_data;
char *id; char *id;
g_debug ("Client '%s' received RegisterClient(%s)", g_debug ("Client '%s' received RegisterClient(%s)",
xsmp->description, xsmp->description,
previous_id ? previous_id : "NULL"); previous_id ? previous_id : "NULL");
@ -319,8 +319,8 @@ save_yourself_request_callback (SmsConn conn,
if (shutdown && global) if (shutdown && global)
{ {
g_debug (" initiating shutdown"); g_debug (" initiating shutdown");
/* gsm_session_initiate_shutdown (global_session, /* gsm_session_initiate_shutdown (global_session,
!fast, !fast,
GSM_SESSION_LOGOUT_TYPE_LOGOUT); GSM_SESSION_LOGOUT_TYPE_LOGOUT);
*/ */
} }
@ -333,7 +333,7 @@ save_yourself_request_callback (SmsConn conn,
g_debug (" ignoring"); g_debug (" ignoring");
} }
static void static void
xsmp_restart (GsmClient *client, GError **error) xsmp_restart (GsmClient *client, GError **error)
{ {
char *restart_cmd = gsm_client_get_restart_command (client); 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); prop = find_property (client, name, &index);
if (!prop) if (!prop)
return; return;
#if 0 #if 0
/* This is wrong anyway; we can't unconditionally run the current /* This is wrong anyway; we can't unconditionally run the current

View File

@ -66,7 +66,7 @@ struct _GsmClientClass
char * (*get_discard_command) (GsmClient *client); char * (*get_discard_command) (GsmClient *client);
gboolean (*get_autorestart) (GsmClient *client); gboolean (*get_autorestart) (GsmClient *client);
void (*restart) (GsmClient *client, void (*restart) (GsmClient *client,
GError **error); GError **error);
void (*save_yourself) (GsmClient *client, void (*save_yourself) (GsmClient *client,
gboolean save_state); gboolean save_state);

View File

@ -120,8 +120,8 @@ gsm_session_class_init (GsmSessionClass *klass)
/** /**
* gsm_session_set_name: * gsm_session_set_name:
* @session: session instance * @session: session instance
* @name: name of the session * @name: name of the session
* *
* Sets the name of a running session. * Sets the name of a running session.
**/ **/
@ -231,7 +231,7 @@ gsm_session_register_client (GsmSession *session,
const char *id) const char *id)
{ {
GSList *a; GSList *a;
char *client_id = NULL; char *client_id = NULL;
/* If we're shutting down, we don't accept any new session /* If we're shutting down, we don't accept any new session
clients. */ clients. */
@ -252,7 +252,7 @@ gsm_session_register_client (GsmSession *session,
return NULL; return NULL;
} }
} }
client_id = g_strdup (id); client_id = g_strdup (id);
} }
@ -438,7 +438,7 @@ client_save_yourself_done (GsmClient *client, gpointer data)
session->phase2_clients = session->phase2_clients =
g_slist_remove (session->phase2_clients, client); g_slist_remove (session->phase2_clients, client);
if (session->phase == GSM_SESSION_PHASE_SHUTDOWN && if (session->phase == GSM_SESSION_PHASE_SHUTDOWN &&
!session->shutdown_clients) !session->shutdown_clients)
{ {
if (session->phase2_clients) if (session->phase2_clients)
@ -471,7 +471,7 @@ client_disconnected (GsmClient *client, gpointer data)
is_condition_client = TRUE; is_condition_client = TRUE;
} }
if (session->phase != GSM_SESSION_PHASE_SHUTDOWN && if (session->phase != GSM_SESSION_PHASE_SHUTDOWN &&
gsm_client_get_autorestart (client) && gsm_client_get_autorestart (client) &&
!is_condition_client) !is_condition_client)
{ {

View File

@ -39,25 +39,25 @@ extern GsmSession *global_session;
typedef enum { typedef enum {
/* gsm's own startup/initialization phase */ /* gsm's own startup/initialization phase */
GSM_SESSION_PHASE_STARTUP, GSM_SESSION_PHASE_STARTUP,
/* xrandr setup, gnome-settings-daemon, etc */ /* xrandr setup, gnome-settings-daemon, etc */
GSM_SESSION_PHASE_INITIALIZATION, GSM_SESSION_PHASE_INITIALIZATION,
/* window/compositing managers */ /* window/compositing managers */
GSM_SESSION_PHASE_WINDOW_MANAGER, GSM_SESSION_PHASE_WINDOW_MANAGER,
/* apps that will create _NET_WM_WINDOW_TYPE_PANEL windows */ /* apps that will create _NET_WM_WINDOW_TYPE_PANEL windows */
GSM_SESSION_PHASE_PANEL, GSM_SESSION_PHASE_PANEL,
/* apps that will create _NET_WM_WINDOW_TYPE_DESKTOP windows */ /* apps that will create _NET_WM_WINDOW_TYPE_DESKTOP windows */
GSM_SESSION_PHASE_DESKTOP, GSM_SESSION_PHASE_DESKTOP,
/* everything else */ /* everything else */
GSM_SESSION_PHASE_APPLICATION, GSM_SESSION_PHASE_APPLICATION,
/* done launching */ /* done launching */
GSM_SESSION_PHASE_RUNNING, GSM_SESSION_PHASE_RUNNING,
/* shutting down */ /* shutting down */
GSM_SESSION_PHASE_SHUTDOWN GSM_SESSION_PHASE_SHUTDOWN
} GsmSessionPhase; } GsmSessionPhase;

View File

@ -124,7 +124,7 @@ class ChunkedGlibHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
self.wfile.flush() self.wfile.flush()
self.wfile.close() self.wfile.close()
self.rfile.close() self.rfile.close()
def finish(self): def finish(self):
"""Close the sockets when we're done, not before""" """Close the sockets when we're done, not before"""
pass pass

View File

@ -19,6 +19,6 @@
Provides a simplified API for accessing the dbus service Provides a simplified API for accessing the dbus service
which coordinates native network presence and sharing which coordinates native network presence and sharing
information. This includes both "buddies" and "shared information. This includes both "buddies" and "shared
activities". activities".
""" """

View File

@ -30,16 +30,16 @@ _logger = logging.getLogger('sugar.presence.activity')
class Activity(gobject.GObject): class Activity(gobject.GObject):
"""UI interface for an Activity in the presence service """UI interface for an Activity in the presence service
Activities in the presence service represent your and other user's Activities in the presence service represent your and other user's
shared activities. shared activities.
Properties: Properties:
id id
color color
name name
type type
joined joined
""" """
__gsignals__ = { __gsignals__ = {
'buddy-joined': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, 'buddy-joined': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
@ -74,7 +74,7 @@ class Activity(gobject.GObject):
self._ps_del_object = del_obj_cb self._ps_del_object = del_obj_cb
bobj = bus.get_object(self._PRESENCE_SERVICE, object_path) bobj = bus.get_object(self._PRESENCE_SERVICE, object_path)
self._activity = dbus.Interface(bobj, self._ACTIVITY_DBUS_INTERFACE) 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._buddy_handle_joined_cb)
self._activity.connect_to_signal('BuddyLeft', self._activity.connect_to_signal('BuddyLeft',
self._buddy_left_cb) self._buddy_left_cb)
@ -211,7 +211,7 @@ class Activity(gobject.GObject):
def _emit_buddy_left_signal(self, object_path): def _emit_buddy_left_signal(self, object_path):
"""Generate buddy-left GObject signal with presence Buddy object """Generate buddy-left GObject signal with presence Buddy object
XXX note use of _ps_new_object instead of _ps_del_object here XXX note use of _ps_new_object instead of _ps_del_object here
""" """
self.emit('buddy-left', self._ps_new_object(object_path)) 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) self._handle_to_buddy_path.pop(handle, None)
def _emit_new_channel_signal(self, object_path): 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 New telepathy-python communications channel has been opened
""" """
self.emit('new-channel', object_path) self.emit('new-channel', object_path)
@ -255,7 +255,7 @@ class Activity(gobject.GObject):
def get_buddy_by_handle(self, handle): def get_buddy_by_handle(self, handle):
"""Retrieve the Buddy object given a telepathy handle. """Retrieve the Buddy object given a telepathy handle.
buddy object paths are cached in self._handle_to_buddy_path, buddy object paths are cached in self._handle_to_buddy_path,
so we can get the buddy without calling PS. so we can get the buddy without calling PS.
""" """
@ -378,8 +378,8 @@ class Activity(gobject.GObject):
# GetChannels() wrapper # GetChannels() wrapper
def get_channels(self): def get_channels(self):
"""Retrieve communications channel descriptions for the activity """Retrieve communications channel descriptions for the activity
Returns a tuple containing: Returns a tuple containing:
- the D-Bus well-known service name of the connection - the D-Bus well-known service name of the connection
(FIXME: this is redundant; in Telepathy it can be derived (FIXME: this is redundant; in Telepathy it can be derived

View File

@ -26,17 +26,17 @@ import dbus
class Buddy(gobject.GObject): class Buddy(gobject.GObject):
"""UI interface for a Buddy in the presence service """UI interface for a Buddy in the presence service
Each buddy interface tracks a set of activities and properties 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. the presence interface.
Properties Dictionary: Properties Dictionary:
'key': public key, 'key': public key,
'nick': nickname , 'nick': nickname ,
'color': color (XXX what format), 'color': color (XXX what format),
'current-activity': (XXX dbus path?), 'current-activity': (XXX dbus path?),
'owner': (XXX dbus path?), 'owner': (XXX dbus path?),
'icon': (XXX pixel data for an icon?) 'icon': (XXX pixel data for an icon?)
See __gproperties__ See __gproperties__
""" """
@ -67,11 +67,11 @@ class Buddy(gobject.GObject):
def __init__(self, bus, new_obj_cb, del_obj_cb, object_path): def __init__(self, bus, new_obj_cb, del_obj_cb, object_path):
"""Initialise the reference to the buddy """Initialise the reference to the buddy
bus -- dbus bus object bus -- dbus bus object
new_obj_cb -- callback to call when this buddy joins an activity new_obj_cb -- callback to call when this buddy joins an activity
del_obj_cb -- callback to call when this buddy leaves an activity del_obj_cb -- callback to call when this buddy leaves an activity
object_path -- path to the buddy object object_path -- path to the buddy object
""" """
gobject.GObject.__init__(self) gobject.GObject.__init__(self)
self._object_path = object_path self._object_path = object_path
@ -104,7 +104,7 @@ class Buddy(gobject.GObject):
self._joined_activity_signal.remove() self._joined_activity_signal.remove()
self._left_activity_signal.remove() self._left_activity_signal.remove()
self._property_changed_signal.remove() self._property_changed_signal.remove()
def _get_properties_helper(self): def _get_properties_helper(self):
"""Retrieve the Buddy's property dictionary from the service object """Retrieve the Buddy's property dictionary from the service object
""" """
@ -114,8 +114,8 @@ class Buddy(gobject.GObject):
return props return props
def do_get_property(self, pspec): 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 pspec -- XXX some sort of GTK specifier object with attributes
including 'name', 'active' and 'icon-name' including 'name', 'active' and 'icon-name'
""" """
@ -170,7 +170,7 @@ class Buddy(gobject.GObject):
def _joined_activity_cb(self, object_path): def _joined_activity_cb(self, object_path):
"""Handle dbus signal by emitting a GObject signal """Handle dbus signal by emitting a GObject signal
Stores the activity in activities dictionary as well Stores the activity in activities dictionary as well
""" """
if not self._activities.has_key(object_path): if not self._activities.has_key(object_path):
@ -179,7 +179,7 @@ class Buddy(gobject.GObject):
def _emit_left_activity_signal(self, object_path): def _emit_left_activity_signal(self, object_path):
"""Emit activity left signal with Activity object """Emit activity left signal with Activity object
XXX this calls self._ps_new_object instead of self._ps_del_object, XXX this calls self._ps_new_object instead of self._ps_del_object,
which would seem to be the incorrect callback? which would seem to be the incorrect callback?
""" """
@ -188,7 +188,7 @@ class Buddy(gobject.GObject):
def _left_activity_cb(self, object_path): def _left_activity_cb(self, object_path):
"""Handle dbus signal by emitting a GObject signal """Handle dbus signal by emitting a GObject signal
Also removes from the activities dictionary Also removes from the activities dictionary
""" """
if self._activities.has_key(object_path): 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) gobject.idle_add(self._emit_left_activity_signal, object_path)
def _handle_property_changed_signal(self, prop_list): def _handle_property_changed_signal(self, prop_list):
"""Emit property-changed signal with property dictionary """Emit property-changed signal with property dictionary
Generates a property-changed signal with the results of Generates a property-changed signal with the results of
_get_properties_helper() _get_properties_helper()
""" """
self._properties = self._get_properties_helper() self._properties = self._get_properties_helper()
@ -212,7 +212,7 @@ class Buddy(gobject.GObject):
def get_icon_pixbuf(self): def get_icon_pixbuf(self):
"""Retrieve Buddy's icon as a GTK pixel buffer """Retrieve Buddy's icon as a GTK pixel buffer
XXX Why aren't the icons coming in as SVG? XXX Why aren't the icons coming in as SVG?
""" """
if self.props.icon and len(self.props.icon): if self.props.icon and len(self.props.icon):
@ -224,12 +224,12 @@ class Buddy(gobject.GObject):
return None return None
def get_joined_activities(self): def get_joined_activities(self):
"""Retrieve the set of all activities which this buddy has joined """Retrieve the set of all activities which this buddy has joined
Uses the GetJoinedActivities method on the service Uses the GetJoinedActivities method on the service
object to produce object paths, wraps each in an object to produce object paths, wraps each in an
Activity object. Activity object.
returns list of presence Activity objects returns list of presence Activity objects
""" """
try: try:

View File

@ -40,8 +40,8 @@ _logger = logging.getLogger('sugar.presence.presenceservice')
class PresenceService(gobject.GObject): 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 This class provides UI programmers with simplified access
to the dbus service of the same name. It allows for observing to the dbus service of the same name. It allows for observing
various events from the presence service as GObject events, various events from the presence service as GObject events,
@ -68,7 +68,7 @@ class PresenceService(gobject.GObject):
_PS_BUDDY_OP = DBUS_PATH + "/Buddies/" _PS_BUDDY_OP = DBUS_PATH + "/Buddies/"
_PS_ACTIVITY_OP = DBUS_PATH + "/Activities/" _PS_ACTIVITY_OP = DBUS_PATH + "/Activities/"
def __init__(self, allow_offline_iface=True): def __init__(self, allow_offline_iface=True):
"""Initialise the service and attempt to connect to events """Initialise the service and attempt to connect to events
@ -99,30 +99,30 @@ class PresenceService(gobject.GObject):
_ps_ = None _ps_ = None
def _get_ps(self): def _get_ps(self):
"""Retrieve dbus interface to PresenceService """Retrieve dbus interface to PresenceService
Also registers for updates from various dbus events on the Also registers for updates from various dbus events on the
interface. interface.
If unable to retrieve the interface, we will temporarily If unable to retrieve the interface, we will temporarily
return an _OfflineInterface object to allow the calling return an _OfflineInterface object to allow the calling
code to continue functioning as though it had accessed a code to continue functioning as though it had accessed a
real presence service. 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 for use by other methods and returns that interface
""" """
if not self._ps_: if not self._ps_:
try: try:
# NOTE: We need to follow_name_owner_changes here # 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 # we follow the changes or we start the service
# before we connect. Starting the service here # before we connect. Starting the service here
# causes a major bottleneck during startup # causes a major bottleneck during startup
ps = dbus.Interface( ps = dbus.Interface(
self._bus.get_object(DBUS_SERVICE, self._bus.get_object(DBUS_SERVICE,
DBUS_PATH, DBUS_PATH,
follow_name_owner_changes=True), follow_name_owner_changes=True),
DBUS_INTERFACE DBUS_INTERFACE
) )
except dbus.exceptions.DBusException, err: except dbus.exceptions.DBusException, err:
@ -135,7 +135,7 @@ class PresenceService(gobject.GObject):
return _OfflineInterface() return _OfflineInterface()
raise RuntimeError("Failed to connect to the presence service.") raise RuntimeError("Failed to connect to the presence service.")
else: else:
self._ps_ = ps self._ps_ = ps
ps.connect_to_signal('BuddyAppeared', ps.connect_to_signal('BuddyAppeared',
self._buddy_appeared_cb) self._buddy_appeared_cb)
ps.connect_to_signal('BuddyDisappeared', ps.connect_to_signal('BuddyDisappeared',
@ -149,7 +149,7 @@ class PresenceService(gobject.GObject):
ps.connect_to_signal('PrivateInvitation', ps.connect_to_signal('PrivateInvitation',
self._private_invitation_cb) self._private_invitation_cb)
return self._ps_ return self._ps_
_ps = property( _ps = property(
_get_ps, None, None, _get_ps, None, None,
"""DBUS interface to the PresenceService """DBUS interface to the PresenceService
@ -158,16 +158,16 @@ class PresenceService(gobject.GObject):
def _new_object(self, object_path): def _new_object(self, object_path):
"""Turn new object path into (cached) Buddy/Activity instance """Turn new object path into (cached) Buddy/Activity instance
object_path -- full dbus path of the new object, must be object_path -- full dbus path of the new object, must be
prefixed with either of _PS_BUDDY_OP or _PS_ACTIVITY_OP prefixed with either of _PS_BUDDY_OP or _PS_ACTIVITY_OP
Note that this method is called throughout the class whenever 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 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, _one_ Python object for any D-Bus object represented by an object path,
effectively wrapping the D-Bus object in a single Python GObject. effectively wrapping the D-Bus object in a single Python GObject.
returns presence Buddy or Activity representation returns presence Buddy or Activity representation
""" """
obj = None obj = None
@ -225,7 +225,7 @@ class PresenceService(gobject.GObject):
# we could use a LRU cache limited to some value. # we could use a LRU cache limited to some value.
del self._objcache[object_path] del self._objcache[object_path]
obj.destroy() obj.destroy()
return False return False
def _buddy_disappeared_cb(self, object_path): def _buddy_disappeared_cb(self, object_path):
@ -282,7 +282,7 @@ class PresenceService(gobject.GObject):
def get_activities(self): def get_activities(self):
"""Retrieve set of all activities from service """Retrieve set of all activities from service
returns list of Activity objects for all object paths returns list of Activity objects for all object paths
the service reports exist (using GetActivities) 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): 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: if not reply_handler:
logging.error('Function get_activities_async called without' \ logging.error('Function get_activities_async called without' \
'a reply handler. Can not run.') 'a reply handler. Can not run.')
return return
self._ps.GetActivities( self._ps.GetActivities(
@ -351,7 +351,7 @@ class PresenceService(gobject.GObject):
def get_buddies(self): def get_buddies(self):
"""Retrieve set of all buddies from service """Retrieve set of all buddies from service
returns list of Buddy objects for all object paths returns list of Buddy objects for all object paths
the service reports exist (using GetBuddies) 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): 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: if not reply_handler:
logging.error('Function get_buddies_async called without' \ logging.error('Function get_buddies_async called without' \
'a reply handler. Can not run.') 'a reply handler. Can not run.')
return return
self._ps.GetBuddies( self._ps.GetBuddies(
@ -402,11 +402,11 @@ class PresenceService(gobject.GObject):
def get_buddy(self, key): def get_buddy(self, key):
"""Retrieve single Buddy object for the given public key """Retrieve single Buddy object for the given public key
key -- buddy's public encryption key key -- buddy's public encryption key
returns single Buddy object or None if the activity returns single Buddy object or None if the activity
is not found using GetBuddyByPublicKey on the is not found using GetBuddyByPublicKey on the
service service
""" """
try: try:
@ -479,15 +479,15 @@ class PresenceService(gobject.GObject):
def share_activity(self, activity, properties=None, private=True): def share_activity(self, activity, properties=None, private=True):
"""Ask presence service to ask the activity to share itself publicly. """Ask presence service to ask the activity to share itself publicly.
Uses the AdvertiseActivity method on the service to ask for the Uses the AdvertiseActivity method on the service to ask for the
sharing of the given activity. Arranges to emit activity-shared sharing of the given activity. Arranges to emit activity-shared
event with: event with:
(success, Activity, err) (success, Activity, err)
on success/failure. on success/failure.
returns None returns None
""" """
actid = activity.get_id() actid = activity.get_id()
@ -528,16 +528,16 @@ class PresenceService(gobject.GObject):
class _OfflineInterface( object ): class _OfflineInterface( object ):
"""Offline-presence-service interface """Offline-presence-service interface
Used to mimic the behaviour of a real PresenceService sufficiently Used to mimic the behaviour of a real PresenceService sufficiently
to avoid crashing client code that expects the given interface. 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? easily, but would it be worth it?
""" """
def raiseException( self, *args, **named ): def raiseException( self, *args, **named ):
"""Raise dbus.exceptions.DBusException""" """Raise dbus.exceptions.DBusException"""
raise dbus.exceptions.DBusException( raise dbus.exceptions.DBusException(
"""PresenceService Interface not available""" """PresenceService Interface not available"""
) )
GetActivities = raiseException GetActivities = raiseException
@ -546,7 +546,7 @@ class _OfflineInterface( object ):
GetBuddyByPublicKey = raiseException GetBuddyByPublicKey = raiseException
GetOwner = raiseException GetOwner = raiseException
GetPreferredConnection = raiseException GetPreferredConnection = raiseException
def ShareActivity( def ShareActivity(
self, actid, atype, name, properties, self, actid, atype, name, properties,
reply_handler, error_handler, reply_handler, error_handler,
): ):
@ -559,7 +559,7 @@ class _OfflineInterface( object ):
class _MockPresenceService(gobject.GObject): class _MockPresenceService(gobject.GObject):
"""Test fixture allowing testing of items that use PresenceService """Test fixture allowing testing of items that use PresenceService
See PresenceService for usage and purpose See PresenceService for usage and purpose
""" """
__gsignals__ = { __gsignals__ = {

View File

@ -33,18 +33,18 @@ _profile = None
class Profile(object): class Profile(object):
"""Local user's current options/profile information """Local user's current options/profile information
User settings were previously stored in an INI-style User settings were previously stored in an INI-style
configuration file. We moved to gconf now. The deprected configuration file. We moved to gconf now. The deprected
API is kept around to not break activities still using it. API is kept around to not break activities still using it.
The profile is also responsible for loading the user's The profile is also responsible for loading the user's
public and private ssh keys from disk. public and private ssh keys from disk.
Attributes: Attributes:
pubkey -- public ssh key 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): def __init__(self, path):
self._pubkey = None self._pubkey = None
@ -138,7 +138,7 @@ class Profile(object):
client.set_string("/desktop/sugar/user/color", color) client.set_string("/desktop/sugar/user/color", color)
if cp.has_option('Jabber', 'Server'): if cp.has_option('Jabber', 'Server'):
server = cp.get('Jabber', 'Server') server = cp.get('Jabber', 'Server')
client.set_string("/desktop/sugar/collaboration/jabber_server", client.set_string("/desktop/sugar/collaboration/jabber_server",
server) server)
if cp.has_option('Date', 'Timezone'): if cp.has_option('Date', 'Timezone'):
timezone = cp.get('Date', 'Timezone') timezone = cp.get('Date', 'Timezone')
@ -165,7 +165,7 @@ class Profile(object):
client.set_bool("/desktop/sugar/power/extreme", True) client.set_bool("/desktop/sugar/power/extreme", True)
if cp.has_option('Shell', 'FavoritesLayout'): if cp.has_option('Shell', 'FavoritesLayout'):
layout = cp.get('Shell', 'FavoritesLayout') layout = cp.get('Shell', 'FavoritesLayout')
client.set_string("/desktop/sugar/desktop/favorites_layout", client.set_string("/desktop/sugar/desktop/favorites_layout",
layout) layout)
del cp del cp
try: try:
@ -191,7 +191,7 @@ class Profile(object):
'#export SUGAR_LOGGER_LEVEL=debug\n\n' \ '#export SUGAR_LOGGER_LEVEL=debug\n\n' \
'# Uncomment the following line to enable core dumps\n' \ '# Uncomment the following line to enable core dumps\n' \
'#ulimit -c unlimited\n' '#ulimit -c unlimited\n'
fd.write(text) fd.write(text)
fd.close() fd.close()
def get_profile(): def get_profile():
@ -205,11 +205,11 @@ def get_profile():
def get_nick_name(): def get_nick_name():
client = gconf.client_get_default() client = gconf.client_get_default()
return client.get_string("/desktop/sugar/user/nick") return client.get_string("/desktop/sugar/user/nick")
def get_color(): def get_color():
client = gconf.client_get_default() client = gconf.client_get_default()
color = client.get_string("/desktop/sugar/user/color") color = client.get_string("/desktop/sugar/user/color")
return XoColor(color) return XoColor(color)
def get_pubkey(): def get_pubkey():

View File

@ -87,14 +87,14 @@ gtk_entry_get_pixel_ranges (GtkEntry *entry,
if (ranges) if (ranges)
{ {
gint *r = *ranges; gint *r = *ranges;
for (i = 0; i < real_n_ranges; ++i) for (i = 0; i < real_n_ranges; ++i)
{ {
r[2 * i + 1] = (r[2 * i + 1] - r[2 * i]) / PANGO_SCALE; r[2 * i + 1] = (r[2 * i + 1] - r[2 * i]) / PANGO_SCALE;
r[2 * i] = r[2 * i] / PANGO_SCALE; r[2 * i] = r[2 * i] / PANGO_SCALE;
} }
} }
if (n_ranges) if (n_ranges)
*n_ranges = real_n_ranges; *n_ranges = real_n_ranges;
} }
@ -117,7 +117,7 @@ gtk_entry_get_cursor_locations (GtkEntry *entry,
{ {
if (strong_x) if (strong_x)
*strong_x = 0; *strong_x = 0;
if (weak_x) if (weak_x)
*weak_x = 0; *weak_x = 0;
} }
@ -128,7 +128,7 @@ gtk_entry_get_cursor_locations (GtkEntry *entry,
const gchar *text = pango_layout_get_text (layout); const gchar *text = pango_layout_get_text (layout);
PangoRectangle strong_pos, weak_pos; PangoRectangle strong_pos, weak_pos;
gint index; gint index;
if (type == CURSOR_STANDARD) if (type == CURSOR_STANDARD)
{ {
index = g_utf8_offset_to_pointer (text, entry->current_pos + entry->preedit_cursor) - text; 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); pango_layout_get_cursor_pos (layout, index, &strong_pos, &weak_pos);
if (strong_x) if (strong_x)
*strong_x = strong_pos.x / PANGO_SCALE; *strong_x = strong_pos.x / PANGO_SCALE;
if (weak_x) if (weak_x)
*weak_x = weak_pos.x / PANGO_SCALE; *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))); GdkKeymap *keymap = gdk_keymap_get_for_display (gtk_widget_get_display (GTK_WIDGET (entry)));
PangoDirection keymap_direction = gdk_keymap_get_direction (keymap); PangoDirection keymap_direction = gdk_keymap_get_direction (keymap);
if (GTK_WIDGET_DRAWABLE (entry)) if (GTK_WIDGET_DRAWABLE (entry))
{ {
GtkWidget *widget = GTK_WIDGET (entry); GtkWidget *widget = GTK_WIDGET (entry);
@ -186,7 +186,7 @@ gtk_entry_draw_cursor (GtkEntry *entry,
xoffset = inner_border.left - entry->scroll_offset; xoffset = inner_border.left - entry->scroll_offset;
gdk_drawable_get_size (entry->text_area, NULL, &text_area_height); gdk_drawable_get_size (entry->text_area, NULL, &text_area_height);
gtk_entry_get_cursor_locations (entry, type, &strong_x, &weak_x); gtk_entry_get_cursor_locations (entry, type, &strong_x, &weak_x);
g_object_get (gtk_widget_get_settings (widget), g_object_get (gtk_widget_get_settings (widget),
@ -194,7 +194,7 @@ gtk_entry_draw_cursor (GtkEntry *entry,
NULL); NULL);
dir1 = entry->resolved_dir; dir1 = entry->resolved_dir;
if (split_cursor) if (split_cursor)
{ {
x1 = strong_x; x1 = strong_x;
@ -221,7 +221,7 @@ gtk_entry_draw_cursor (GtkEntry *entry,
draw_insertion_cursor (entry, draw_insertion_cursor (entry,
&cursor_location, TRUE, dir1, &cursor_location, TRUE, dir1,
dir2 != PANGO_DIRECTION_NEUTRAL); dir2 != PANGO_DIRECTION_NEUTRAL);
if (dir2 != PANGO_DIRECTION_NEUTRAL) if (dir2 != PANGO_DIRECTION_NEUTRAL)
{ {
cursor_location.x = xoffset + x2; cursor_location.x = xoffset + x2;
@ -243,7 +243,7 @@ get_layout_position (GtkEntry *entry,
GtkBorder inner_border; GtkBorder inner_border;
gint y_pos; gint y_pos;
PangoLayoutLine *line; PangoLayoutLine *line;
// layout = gtk_entry_ensure_layout (entry, TRUE); // layout = gtk_entry_ensure_layout (entry, TRUE);
layout = gtk_entry_get_layout(entry); layout = gtk_entry_get_layout(entry);
@ -254,11 +254,11 @@ get_layout_position (GtkEntry *entry,
line = pango_layout_get_lines (layout)->data; line = pango_layout_get_lines (layout)->data;
pango_layout_line_get_extents (line, NULL, &logical_rect); pango_layout_line_get_extents (line, NULL, &logical_rect);
/* Align primarily for locale's ascent/descent */ /* 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); entry->ascent + logical_rect.y);
/* Now see if we need to adjust to fit in actual drawn string */ /* Now see if we need to adjust to fit in actual drawn string */
if (logical_rect.height > area_height) if (logical_rect.height > area_height)
y_pos = (area_height - logical_rect.height) / 2; y_pos = (area_height - logical_rect.height) / 2;
@ -266,7 +266,7 @@ get_layout_position (GtkEntry *entry,
y_pos = 0; y_pos = 0;
else if (y_pos + logical_rect.height > area_height) else if (y_pos + logical_rect.height > area_height)
y_pos = area_height - logical_rect.height; y_pos = area_height - logical_rect.height;
y_pos = inner_border.top + y_pos / PANGO_SCALE; y_pos = inner_border.top + y_pos / PANGO_SCALE;
if (x) if (x)
@ -306,10 +306,10 @@ static void
gtk_entry_draw_text (GtkEntry *entry) gtk_entry_draw_text (GtkEntry *entry)
{ {
GtkWidget *widget; GtkWidget *widget;
if (!entry->visible && entry->invisible_char == 0) if (!entry->visible && entry->invisible_char == 0)
return; return;
if (GTK_WIDGET_DRAWABLE (entry)) if (GTK_WIDGET_DRAWABLE (entry))
{ {
//PangoLayout *layout = gtk_entry_ensure_layout (entry, TRUE); //PangoLayout *layout = gtk_entry_ensure_layout (entry, TRUE);
@ -317,9 +317,9 @@ gtk_entry_draw_text (GtkEntry *entry)
cairo_t *cr; cairo_t *cr;
gint x, y; gint x, y;
gint start_pos, end_pos; gint start_pos, end_pos;
widget = GTK_WIDGET (entry); widget = GTK_WIDGET (entry);
get_layout_position (entry, &x, &y); get_layout_position (entry, &x, &y);
cr = gdk_cairo_create (entry->text_area); cr = gdk_cairo_create (entry->text_area);
@ -360,14 +360,14 @@ gtk_entry_draw_text (GtkEntry *entry)
logical_rect.height); logical_rect.height);
cairo_clip (cr); cairo_clip (cr);
gdk_cairo_set_source_color (cr, selection_color); gdk_cairo_set_source_color (cr, selection_color);
cairo_paint (cr); cairo_paint (cr);
cairo_move_to (cr, x, y); cairo_move_to (cr, x, y);
gdk_cairo_set_source_color (cr, text_color); gdk_cairo_set_source_color (cr, text_color);
pango_cairo_show_layout (cr, layout); pango_cairo_show_layout (cr, layout);
g_free (ranges); g_free (ranges);
} }
@ -427,7 +427,7 @@ get_text_area_size (GtkEntry *entry,
if (y) if (y)
*y = yborder; *y = yborder;
if (width) if (width)
*width = GTK_WIDGET (entry)->allocation.width - xborder * 2; *width = GTK_WIDGET (entry)->allocation.width - xborder * 2;
@ -471,7 +471,7 @@ sugar_address_entry_expose(GtkWidget *widget,
cairo_fill(cr); cairo_fill(cr);
cairo_destroy (cr); cairo_destroy (cr);
} }
if ((entry->visible || entry->invisible_char != 0) && if ((entry->visible || entry->invisible_char != 0) &&
GTK_WIDGET_HAS_FOCUS (widget) && GTK_WIDGET_HAS_FOCUS (widget) &&

View File

@ -153,7 +153,7 @@ sugar_key_grabber_init(SugarKeyGrabber *grabber)
gdk_window_add_filter(grabber->root, filter_events, 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 * 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) { while (*cur != NULL) {
key = *cur; key = *cur;
cur += 1; cur += 1;
keyinfo = g_new0 (Key, 1); keyinfo = g_new0 (Key, 1);
keyinfo->key = g_strdup(key); keyinfo->key = g_strdup(key);
@ -279,9 +279,9 @@ sugar_key_grabber_is_modifier(SugarKeyGrabber *grabber, guint keycode, guint mas
break; break;
} }
} }
XFreeModifiermap (modmap); XFreeModifiermap (modmap);
return is_modifier; return is_modifier;
} }

View File

@ -48,16 +48,16 @@ def sha_data(data):
def unique_id(data = ''): def unique_id(data = ''):
"""Generate a likely-unique ID for whatever purpose """Generate a likely-unique ID for whatever purpose
data -- suffix appended to working data before hashing data -- suffix appended to working data before hashing
Returns a 40-character string with hexidecimal digits 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. within a constrained range and the data passed.
Note: these are *not* crypotographically secure or Note: these are *not* crypotographically secure or
globally unique identifiers. While they are likely globally unique identifiers. While they are likely
to be unique-enough, no attempt is made to make to be unique-enough, no attempt is made to make
perfectly unique values. perfectly unique values.
""" """
data_string = "%s%s%s" % (time.time(), random.randint(10000, 100000), data) data_string = "%s%s%s" % (time.time(), random.randint(10000, 100000), data)
@ -72,7 +72,7 @@ def is_hex(s):
except ValueError: except ValueError:
return False return False
return True return True
def validate_activity_id(actid): def validate_activity_id(actid):
"""Validate an activity ID.""" """Validate an activity ID."""
@ -90,7 +90,7 @@ def set_proc_title(title):
and only the first 15 characters will be shown. and only the first 15 characters will be shown.
title -- the title you wish to change the process title -- the title you wish to change the process
title to title to
Returns True on success. We don't raise exceptions Returns True on success. We don't raise exceptions
because if something goes wrong here it is not a big because if something goes wrong here it is not a big
@ -284,7 +284,7 @@ class TempFilePath(str):
def __del__(self): def __del__(self):
if _tracked_paths[self] == 1: if _tracked_paths[self] == 1:
del _tracked_paths[self] del _tracked_paths[self]
if os.path.exists(self): if os.path.exists(self):
os.unlink(self) os.unlink(self)
logging.debug('TempFilePath deleted %r', self) logging.debug('TempFilePath deleted %r', self)

View File

@ -16,7 +16,7 @@
# Boston, MA 02111-1307, USA. # Boston, MA 02111-1307, USA.
""" """
UNSTABLE. Used only internally by Activity and jarabe. UNSTABLE. Used only internally by Activity and jarabe.
""" """
import gtk import gtk