Merge branch 'master' of ssh+git://dev.laptop.org/git/sugar
This commit is contained in:
commit
2a48021a78
1
NEWS
1
NEWS
@ -1,3 +1,4 @@
|
|||||||
|
* #4892: Use the engine to make sugar icons insensitive (benzea)
|
||||||
* #4941: Add menu entry with dialog to show About this XO (erikos)
|
* #4941: Add menu entry with dialog to show About this XO (erikos)
|
||||||
* #5089: show frame shortly when adding object to clipboard (erikos)
|
* #5089: show frame shortly when adding object to clipboard (erikos)
|
||||||
* #5097: Fix pasting text between activities through the clipboard. (tomeu)
|
* #5097: Fix pasting text between activities through the clipboard. (tomeu)
|
||||||
|
@ -94,6 +94,17 @@ if len(args) == 0:
|
|||||||
bundle_path = os.environ['SUGAR_BUNDLE_PATH']
|
bundle_path = os.environ['SUGAR_BUNDLE_PATH']
|
||||||
sys.path.append(bundle_path)
|
sys.path.append(bundle_path)
|
||||||
|
|
||||||
|
bundle = ActivityBundle(bundle_path)
|
||||||
|
|
||||||
|
os.environ['SUGAR_BUNDLE_ID'] = bundle.get_bundle_id()
|
||||||
|
os.environ['SUGAR_BUNDLE_NAME'] = bundle.get_name()
|
||||||
|
|
||||||
|
gtk.icon_theme_get_default().append_search_path(bundle.get_icons_path())
|
||||||
|
|
||||||
|
gettext.bindtextdomain(bundle.get_bundle_id(),
|
||||||
|
bundle.get_locale_path())
|
||||||
|
gettext.textdomain(bundle.get_bundle_id())
|
||||||
|
|
||||||
splitted_module = args[0].rsplit('.', 1)
|
splitted_module = args[0].rsplit('.', 1)
|
||||||
module_name = splitted_module[0]
|
module_name = splitted_module[0]
|
||||||
class_name = splitted_module[1]
|
class_name = splitted_module[1]
|
||||||
@ -133,17 +144,6 @@ if options.single_process is True:
|
|||||||
if hasattr(module, 'start'):
|
if hasattr(module, 'start'):
|
||||||
module.start()
|
module.start()
|
||||||
|
|
||||||
bundle = ActivityBundle(bundle_path)
|
|
||||||
|
|
||||||
os.environ['SUGAR_BUNDLE_ID'] = bundle.get_bundle_id()
|
|
||||||
os.environ['SUGAR_BUNDLE_NAME'] = bundle.get_name()
|
|
||||||
|
|
||||||
gettext.bindtextdomain(bundle.get_bundle_id(),
|
|
||||||
bundle.get_locale_path())
|
|
||||||
gettext.textdomain(bundle.get_bundle_id())
|
|
||||||
|
|
||||||
gtk.icon_theme_get_default().append_search_path(bundle.get_icons_path())
|
|
||||||
|
|
||||||
create_activity_instance(constructor, handle)
|
create_activity_instance(constructor, handle)
|
||||||
|
|
||||||
gtk.main()
|
gtk.main()
|
||||||
|
@ -76,6 +76,10 @@ SCOPE_PRIVATE = "private"
|
|||||||
SCOPE_INVITE_ONLY = "invite" # shouldn't be shown in UI, it's implicit when you invite somebody
|
SCOPE_INVITE_ONLY = "invite" # shouldn't be shown in UI, it's implicit when you invite somebody
|
||||||
SCOPE_NEIGHBORHOOD = "public"
|
SCOPE_NEIGHBORHOOD = "public"
|
||||||
|
|
||||||
|
J_DBUS_SERVICE = 'org.laptop.Journal'
|
||||||
|
J_DBUS_PATH = '/org/laptop/Journal'
|
||||||
|
J_DBUS_INTERFACE = 'org.laptop.Journal'
|
||||||
|
|
||||||
class ActivityToolbar(gtk.Toolbar):
|
class ActivityToolbar(gtk.Toolbar):
|
||||||
"""The Activity toolbar with the Journal entry title, sharing, Keep and Stop buttons
|
"""The Activity toolbar with the Journal entry title, sharing, Keep and Stop buttons
|
||||||
|
|
||||||
@ -905,3 +909,9 @@ def get_activity_root():
|
|||||||
return os.environ['SUGAR_ACTIVITY_ROOT']
|
return os.environ['SUGAR_ACTIVITY_ROOT']
|
||||||
else:
|
else:
|
||||||
raise RuntimeError("No SUGAR_ACTIVITY_ROOT set.")
|
raise RuntimeError("No SUGAR_ACTIVITY_ROOT set.")
|
||||||
|
|
||||||
|
def show_object_in_journal(object_id):
|
||||||
|
bus = dbus.SessionBus()
|
||||||
|
obj = bus.get_object(J_DBUS_SERVICE, J_DBUS_PATH)
|
||||||
|
journal = dbus.Interface(obj, J_DBUS_INTERFACE)
|
||||||
|
journal.ShowObject(object_id)
|
||||||
|
@ -270,7 +270,7 @@ class ActivityCreationHandler(gobject.GObject):
|
|||||||
def _activate_error_handler(self, err):
|
def _activate_error_handler(self, err):
|
||||||
logging.error("Activity activation request failed %s" % err)
|
logging.error("Activity activation request failed %s" % err)
|
||||||
|
|
||||||
def _create_reply_handler(self, xid):
|
def _create_reply_handler(self):
|
||||||
logging.debug("Activity created %s (%s)." %
|
logging.debug("Activity created %s (%s)." %
|
||||||
(self._handle.activity_id, self._service_name))
|
(self._handle.activity_id, self._service_name))
|
||||||
|
|
||||||
|
@ -29,15 +29,17 @@ def _activity_info_from_dict(info_dict):
|
|||||||
if not info_dict:
|
if not info_dict:
|
||||||
return None
|
return None
|
||||||
return ActivityInfo(info_dict['name'], info_dict['icon'],
|
return ActivityInfo(info_dict['name'], info_dict['icon'],
|
||||||
info_dict['bundle_id'], info_dict['path'],
|
info_dict['bundle_id'], info_dict['version'],
|
||||||
info_dict['show_launcher'], info_dict['command'])
|
info_dict['path'], info_dict['show_launcher'],
|
||||||
|
info_dict['command'])
|
||||||
|
|
||||||
class ActivityInfo(object):
|
class ActivityInfo(object):
|
||||||
def __init__(self, name, icon, bundle_id,
|
def __init__(self, name, icon, bundle_id, version,
|
||||||
path, show_launcher, command):
|
path, show_launcher, command):
|
||||||
self.name = name
|
self.name = name
|
||||||
self.icon = icon
|
self.icon = icon
|
||||||
self.bundle_id = bundle_id
|
self.bundle_id = bundle_id
|
||||||
|
self.version = version
|
||||||
self.path = path
|
self.path = path
|
||||||
self.command = command
|
self.command = command
|
||||||
self.show_launcher = show_launcher
|
self.show_launcher = show_launcher
|
||||||
@ -146,6 +148,8 @@ class ActivityRegistry(gobject.GObject):
|
|||||||
self._mime_type_to_activities.clear()
|
self._mime_type_to_activities.clear()
|
||||||
|
|
||||||
def remove_bundle(self, bundle_path):
|
def remove_bundle(self, bundle_path):
|
||||||
|
self._service_name_to_activity_info.clear()
|
||||||
|
self._mime_type_to_activities.clear()
|
||||||
return self._registry.RemoveBundle(bundle_path)
|
return self._registry.RemoveBundle(bundle_path)
|
||||||
|
|
||||||
def _activity_removed_cb(self, info_dict):
|
def _activity_removed_cb(self, info_dict):
|
||||||
|
@ -22,10 +22,15 @@ import locale
|
|||||||
import os
|
import os
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
from sugar.bundle.bundle import Bundle, MalformedBundleException
|
from sugar.bundle.bundle import Bundle, MalformedBundleException, \
|
||||||
|
AlreadyInstalledException, RegistrationException, \
|
||||||
|
NotInstalledException
|
||||||
|
|
||||||
from sugar import activity
|
from sugar import activity
|
||||||
from sugar import env
|
from sugar import env
|
||||||
|
|
||||||
|
import logging
|
||||||
|
|
||||||
class ActivityBundle(Bundle):
|
class ActivityBundle(Bundle):
|
||||||
"""A Sugar activity bundle
|
"""A Sugar activity bundle
|
||||||
|
|
||||||
@ -204,8 +209,16 @@ class ActivityBundle(Bundle):
|
|||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def need_upgrade(self):
|
||||||
|
act = activity.get_registry().get_activity(self._bundle_id)
|
||||||
|
if act is None or act.version != self._activity_version:
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
def install(self):
|
def install(self):
|
||||||
if self.is_installed():
|
act = activity.get_registry().get_activity(self._bundle_id)
|
||||||
|
if act is not None and act.path.startswith(env.get_user_activities_path()):
|
||||||
raise AlreadyInstalledException
|
raise AlreadyInstalledException
|
||||||
|
|
||||||
install_dir = env.get_user_activities_path()
|
install_dir = env.get_user_activities_path()
|
||||||
@ -250,12 +263,21 @@ class ActivityBundle(Bundle):
|
|||||||
if not activity.get_registry().add_bundle(install_path):
|
if not activity.get_registry().add_bundle(install_path):
|
||||||
raise RegistrationException
|
raise RegistrationException
|
||||||
|
|
||||||
def uninstall(self):
|
def uninstall(self, force=False):
|
||||||
if self._unpacked:
|
if self._unpacked:
|
||||||
install_path = self._path
|
install_path = self._path
|
||||||
else:
|
else:
|
||||||
if not self.is_installed():
|
if not self.is_installed():
|
||||||
raise NotInstalledException
|
raise NotInstalledException
|
||||||
|
|
||||||
|
act = activity.get_registry().get_activity(self._bundle_id)
|
||||||
|
if not force and act.version != self._activity_version:
|
||||||
|
logging.warning('Not uninstalling because different bundle present')
|
||||||
|
return
|
||||||
|
elif not act.path.startswith(env.get_user_activities_path()):
|
||||||
|
logging.warning('Not uninstalling system activity')
|
||||||
|
return
|
||||||
|
|
||||||
install_path = os.path.join(env.get_user_activities_path(),
|
install_path = os.path.join(env.get_user_activities_path(),
|
||||||
self._zip_root_dir)
|
self._zip_root_dir)
|
||||||
|
|
||||||
@ -283,3 +305,17 @@ class ActivityBundle(Bundle):
|
|||||||
if not activity.get_registry().remove_bundle(install_path):
|
if not activity.get_registry().remove_bundle(install_path):
|
||||||
raise RegistrationException
|
raise RegistrationException
|
||||||
|
|
||||||
|
def upgrade(self):
|
||||||
|
act = activity.get_registry().get_activity(self._bundle_id)
|
||||||
|
if act is None:
|
||||||
|
logging.warning('Activity not installed')
|
||||||
|
elif act.path.startswith(env.get_user_activities_path()):
|
||||||
|
try:
|
||||||
|
self.uninstall(force=True)
|
||||||
|
except Exception, e:
|
||||||
|
logging.warning('Uninstall failed (%s), still trying to install newer bundle', e)
|
||||||
|
else:
|
||||||
|
logging.warning('Unable to uninstall system activity, installing upgraded version in user activities')
|
||||||
|
|
||||||
|
self.install()
|
||||||
|
|
||||||
|
@ -160,10 +160,16 @@ class DSObject(object):
|
|||||||
if bundle_id is not None:
|
if bundle_id is not None:
|
||||||
raise ValueError('Object is a bundle, cannot be resumed as an activity.')
|
raise ValueError('Object is a bundle, cannot be resumed as an activity.')
|
||||||
|
|
||||||
|
logging.debug('Creating activity bundle')
|
||||||
bundle = ActivityBundle(self.file_path)
|
bundle = ActivityBundle(self.file_path)
|
||||||
if not bundle.is_installed():
|
if not bundle.is_installed():
|
||||||
|
logging.debug('Installing activity bundle')
|
||||||
bundle.install()
|
bundle.install()
|
||||||
|
elif bundle.need_upgrade():
|
||||||
|
logging.debug('Upgrading activity bundle')
|
||||||
|
bundle.upgrade()
|
||||||
|
|
||||||
|
logging.debug('activityfactory.creating bundle with id %r', bundle.get_bundle_id())
|
||||||
activityfactory.create(bundle.get_bundle_id())
|
activityfactory.create(bundle.get_bundle_id())
|
||||||
else:
|
else:
|
||||||
if not self.get_activities() and bundle_id is None:
|
if not self.get_activities() and bundle_id is None:
|
||||||
|
@ -88,9 +88,10 @@ class _IconBuffer(object):
|
|||||||
self.cache = False
|
self.cache = False
|
||||||
self.scale = 1.0
|
self.scale = 1.0
|
||||||
|
|
||||||
def _get_cache_key(self):
|
def _get_cache_key(self, sensitive):
|
||||||
return (self.icon_name, self.file_name, self.fill_color,
|
return (self.icon_name, self.file_name, self.fill_color,
|
||||||
self.stroke_color, self.badge_name, self.width, self.height)
|
self.stroke_color, self.badge_name, self.width, self.height,
|
||||||
|
sensitive)
|
||||||
|
|
||||||
def _load_svg(self, file_name):
|
def _load_svg(self, file_name):
|
||||||
entities = {}
|
entities = {}
|
||||||
@ -139,16 +140,19 @@ class _IconBuffer(object):
|
|||||||
|
|
||||||
return icon_info
|
return icon_info
|
||||||
|
|
||||||
def _draw_badge(self, context, size):
|
def _draw_badge(self, context, size, sensitive, widget):
|
||||||
theme = gtk.icon_theme_get_default()
|
theme = gtk.icon_theme_get_default()
|
||||||
badge_info = theme.lookup_icon(self.badge_name, size, 0)
|
badge_info = theme.lookup_icon(self.badge_name, size, 0)
|
||||||
if badge_info:
|
if badge_info:
|
||||||
badge_file_name = badge_info.get_filename()
|
badge_file_name = badge_info.get_filename()
|
||||||
if badge_file_name.endswith('.svg'):
|
if badge_file_name.endswith('.svg'):
|
||||||
handle = self._loader.load(badge_file_name, {}, self.cache)
|
handle = self._loader.load(badge_file_name, {}, self.cache)
|
||||||
handle.render_cairo(context)
|
pixbuf = handle.get_pixbuf()
|
||||||
else:
|
else:
|
||||||
pixbuf = gtk.gdk.pixbuf_new_from_file(badge_file_name)
|
pixbuf = gtk.gdk.pixbuf_new_from_file(badge_file_name)
|
||||||
|
|
||||||
|
if not sensitive:
|
||||||
|
pixbuf = self._get_insensitive_pixbuf(pixbuf, widget)
|
||||||
surface = hippo.cairo_surface_from_gdk_pixbuf(pixbuf)
|
surface = hippo.cairo_surface_from_gdk_pixbuf(pixbuf)
|
||||||
context.set_source_surface(surface, 0, 0)
|
context.set_source_surface(surface, 0, 0)
|
||||||
context.paint()
|
context.paint()
|
||||||
@ -196,8 +200,30 @@ class _IconBuffer(object):
|
|||||||
self.stroke_color = None
|
self.stroke_color = None
|
||||||
self.fill_color = None
|
self.fill_color = None
|
||||||
|
|
||||||
def get_surface(self):
|
def _get_insensitive_pixbuf (self, pixbuf, widget):
|
||||||
cache_key = self._get_cache_key()
|
if not (widget and widget.style):
|
||||||
|
return pixbuf
|
||||||
|
|
||||||
|
icon_source = gtk.IconSource()
|
||||||
|
# Special size meaning "don't touch"
|
||||||
|
icon_source.set_size(-1)
|
||||||
|
icon_source.set_pixbuf(pixbuf)
|
||||||
|
icon_source.set_state(gtk.STATE_INSENSITIVE)
|
||||||
|
icon_source.set_direction_wildcarded(False)
|
||||||
|
icon_source.set_size_wildcarded(False)
|
||||||
|
|
||||||
|
# Please note that the pixbuf returned by this function is leaked
|
||||||
|
# with current stable versions of pygtk. The relevant bug is
|
||||||
|
# http://bugzilla.gnome.org/show_bug.cgi?id=502871
|
||||||
|
# -- 2007-12-14 Benjamin Berg
|
||||||
|
pixbuf = widget.style.render_icon(icon_source, widget.get_direction(),
|
||||||
|
gtk.STATE_INSENSITIVE, -1, widget,
|
||||||
|
"sugar-icon")
|
||||||
|
|
||||||
|
return pixbuf
|
||||||
|
|
||||||
|
def get_surface(self, sensitive=True, widget=None):
|
||||||
|
cache_key = self._get_cache_key(sensitive)
|
||||||
if cache_key in self._surface_cache:
|
if cache_key in self._surface_cache:
|
||||||
return self._surface_cache[cache_key]
|
return self._surface_cache[cache_key]
|
||||||
|
|
||||||
@ -230,8 +256,18 @@ class _IconBuffer(object):
|
|||||||
|
|
||||||
context.translate(padding, padding)
|
context.translate(padding, padding)
|
||||||
if is_svg:
|
if is_svg:
|
||||||
|
if sensitive:
|
||||||
handle.render_cairo(context)
|
handle.render_cairo(context)
|
||||||
else:
|
else:
|
||||||
|
pixbuf = handle.get_pixbuf()
|
||||||
|
pixbuf = self._get_insensitive_pixbuf(pixbuf, widget)
|
||||||
|
|
||||||
|
pixbuf_surface = hippo.cairo_surface_from_gdk_pixbuf(pixbuf)
|
||||||
|
context.set_source_surface(pixbuf_surface, 0, 0)
|
||||||
|
context.paint()
|
||||||
|
else:
|
||||||
|
if not sensitive:
|
||||||
|
pixbuf = self._get_insensitive_pixbuf(pixbuf, widget)
|
||||||
pixbuf_surface = hippo.cairo_surface_from_gdk_pixbuf(pixbuf)
|
pixbuf_surface = hippo.cairo_surface_from_gdk_pixbuf(pixbuf)
|
||||||
context.set_source_surface(pixbuf_surface, 0, 0)
|
context.set_source_surface(pixbuf_surface, 0, 0)
|
||||||
context.paint()
|
context.paint()
|
||||||
@ -239,7 +275,7 @@ class _IconBuffer(object):
|
|||||||
if self.badge_name:
|
if self.badge_name:
|
||||||
context.restore()
|
context.restore()
|
||||||
context.translate(badge_info.attach_x, badge_info.attach_y)
|
context.translate(badge_info.attach_x, badge_info.attach_y)
|
||||||
self._draw_badge(context, badge_info.size)
|
self._draw_badge(context, badge_info.size, sensitive, widget)
|
||||||
|
|
||||||
self._surface_cache[cache_key] = surface
|
self._surface_cache[cache_key] = surface
|
||||||
|
|
||||||
@ -307,7 +343,8 @@ class Icon(gtk.Image):
|
|||||||
|
|
||||||
def do_expose_event(self, event):
|
def do_expose_event(self, event):
|
||||||
self._sync_image_properties()
|
self._sync_image_properties()
|
||||||
surface = self._buffer.get_surface()
|
sensitive = (self.state != gtk.STATE_INSENSITIVE)
|
||||||
|
surface = self._buffer.get_surface(sensitive, self)
|
||||||
if surface is None:
|
if surface is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -113,6 +113,7 @@ class ActivityRegistry(dbus.service.Object):
|
|||||||
return {'name': bundle.get_name(),
|
return {'name': bundle.get_name(),
|
||||||
'icon': bundle.get_icon(),
|
'icon': bundle.get_icon(),
|
||||||
'bundle_id': bundle.get_bundle_id(),
|
'bundle_id': bundle.get_bundle_id(),
|
||||||
|
'version': bundle.get_activity_version(),
|
||||||
'path': bundle.get_path(),
|
'path': bundle.get_path(),
|
||||||
'command': bundle.get_command(),
|
'command': bundle.get_command(),
|
||||||
'show_launcher': bundle.get_show_launcher()}
|
'show_launcher': bundle.get_show_launcher()}
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
|
import dbus
|
||||||
import os
|
import os
|
||||||
from ConfigParser import ConfigParser
|
from ConfigParser import ConfigParser
|
||||||
|
|
||||||
@ -86,3 +87,28 @@ class Friends(gobject.GObject):
|
|||||||
fileobject = open(self._path, 'w')
|
fileobject = open(self._path, 'w')
|
||||||
cp.write(fileobject)
|
cp.write(fileobject)
|
||||||
fileobject.close()
|
fileobject.close()
|
||||||
|
|
||||||
|
self._sync_friends()
|
||||||
|
|
||||||
|
def _sync_friends(self):
|
||||||
|
# XXX: temporary hack
|
||||||
|
# remove this when the shell service has a D-Bus API for buddies
|
||||||
|
|
||||||
|
def friends_synced():
|
||||||
|
pass
|
||||||
|
|
||||||
|
def friends_synced_error(e):
|
||||||
|
logging.error("Error asking presence service to sync friends: %s"
|
||||||
|
% e)
|
||||||
|
|
||||||
|
keys = []
|
||||||
|
for friend in self:
|
||||||
|
keys.append(friend.get_key())
|
||||||
|
|
||||||
|
bus = dbus.SessionBus()
|
||||||
|
ps = bus.get_object('org.laptop.Sugar.Presence',
|
||||||
|
'/org/laptop/Sugar/Presence')
|
||||||
|
psi = dbus.Interface(ps, 'org.laptop.Sugar.Presence')
|
||||||
|
psi.SyncFriends(keys,
|
||||||
|
reply_handler=friends_synced,
|
||||||
|
error_handler=friends_synced_error)
|
||||||
|
@ -20,6 +20,7 @@ import logging
|
|||||||
import tempfile
|
import tempfile
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
|
import shutil
|
||||||
|
|
||||||
import gobject
|
import gobject
|
||||||
import gtk
|
import gtk
|
||||||
@ -80,8 +81,16 @@ class Shell(gobject.GObject):
|
|||||||
|
|
||||||
def _start_journal_idle(self):
|
def _start_journal_idle(self):
|
||||||
# Mount the datastore in internal flash
|
# Mount the datastore in internal flash
|
||||||
datastore.mount(env.get_profile_path('datastore'), [],
|
ds_path = env.get_profile_path('datastore')
|
||||||
timeout=120 * DBUS_PYTHON_TIMEOUT_UNITS_PER_SECOND)
|
try:
|
||||||
|
datastore.mount(ds_path, [], timeout=120 * \
|
||||||
|
DBUS_PYTHON_TIMEOUT_UNITS_PER_SECOND)
|
||||||
|
except:
|
||||||
|
# Don't explode if there's corruption; move the data out of the way
|
||||||
|
# and attempt to create a store from scratch.
|
||||||
|
shutil.move(ds_path, os.path.abspath(ds_path) + str(time.time()))
|
||||||
|
datastore.mount(ds_path, [], timeout=120 * \
|
||||||
|
DBUS_PYTHON_TIMEOUT_UNITS_PER_SECOND)
|
||||||
|
|
||||||
# Checking for the bundle existence will also ensure
|
# Checking for the bundle existence will also ensure
|
||||||
# that the shell service is started up.
|
# that the shell service is started up.
|
||||||
|
@ -129,7 +129,7 @@ class ActivitiesTray(hippo.CanvasBox):
|
|||||||
|
|
||||||
def _activity_removed_cb(self, activity_registry, activity_info):
|
def _activity_removed_cb(self, activity_registry, activity_info):
|
||||||
for item in self._tray.get_children():
|
for item in self._tray.get_children():
|
||||||
if item.get_bundle_id() == activity_info.service_name:
|
if item.get_bundle_id() == activity_info.bundle_id:
|
||||||
self._tray.remove_item(item)
|
self._tray.remove_item(item)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ class AccessPointView(PulsingIcon):
|
|||||||
# Update badge
|
# Update badge
|
||||||
caps = model.props.capabilities
|
caps = model.props.capabilities
|
||||||
if model.get_nm_network().is_favorite():
|
if model.get_nm_network().is_favorite():
|
||||||
self.props.badge_name = "emblem-star"
|
self.props.badge_name = "emblem-favorite"
|
||||||
elif (caps & NM_802_11_CAP_PROTO_WEP) or (caps & NM_802_11_CAP_PROTO_WPA) or (caps & NM_802_11_CAP_PROTO_WPA2):
|
elif (caps & NM_802_11_CAP_PROTO_WEP) or (caps & NM_802_11_CAP_PROTO_WPA) or (caps & NM_802_11_CAP_PROTO_WPA2):
|
||||||
self.props.badge_name = "emblem-locked"
|
self.props.badge_name = "emblem-locked"
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ def html_to_rgb(html_color):
|
|||||||
return (r, g, b)
|
return (r, g, b)
|
||||||
|
|
||||||
class ActivityIcon(CanvasIcon):
|
class ActivityIcon(CanvasIcon):
|
||||||
_INTERVAL = 100
|
_INTERVAL = 200
|
||||||
|
|
||||||
__gsignals__ = {
|
__gsignals__ = {
|
||||||
'resume': (gobject.SIGNAL_RUN_FIRST,
|
'resume': (gobject.SIGNAL_RUN_FIRST,
|
||||||
|
@ -28,24 +28,60 @@ import common
|
|||||||
|
|
||||||
test = common.Test()
|
test = common.Test()
|
||||||
|
|
||||||
icon = Icon(icon_name='go-previous')
|
hbox = gtk.HBox()
|
||||||
icon.props.icon_size = gtk.ICON_SIZE_LARGE_TOOLBAR
|
test.pack_start(hbox)
|
||||||
test.pack_start(icon)
|
sensitive_box = gtk.VBox()
|
||||||
icon.show()
|
insensitive_box = gtk.VBox()
|
||||||
|
|
||||||
icon = Icon(icon_name='computer-xo',
|
hbox.pack_start(sensitive_box)
|
||||||
|
hbox.pack_start(insensitive_box)
|
||||||
|
hbox.show_all()
|
||||||
|
|
||||||
|
|
||||||
|
def create_icon_widgets(box, sensitive=True):
|
||||||
|
icon = Icon(icon_name='go-previous')
|
||||||
|
icon.props.icon_size = gtk.ICON_SIZE_LARGE_TOOLBAR
|
||||||
|
box.pack_start(icon)
|
||||||
|
icon.set_sensitive(sensitive)
|
||||||
|
icon.show()
|
||||||
|
|
||||||
|
icon = Icon(icon_name='computer-xo',
|
||||||
icon_size=gtk.ICON_SIZE_LARGE_TOOLBAR,
|
icon_size=gtk.ICON_SIZE_LARGE_TOOLBAR,
|
||||||
xo_color=XoColor())
|
xo_color=XoColor())
|
||||||
test.pack_start(icon)
|
box.pack_start(icon)
|
||||||
icon.show()
|
icon.set_sensitive(sensitive)
|
||||||
|
icon.show()
|
||||||
|
|
||||||
icon = Icon(icon_name='battery-000',
|
icon = Icon(icon_name='battery-000',
|
||||||
icon_size=gtk.ICON_SIZE_LARGE_TOOLBAR,
|
icon_size=gtk.ICON_SIZE_LARGE_TOOLBAR,
|
||||||
badge_name='badge-busy')
|
badge_name='emblem-busy')
|
||||||
test.pack_start(icon)
|
box.pack_start(icon)
|
||||||
icon.show()
|
icon.set_sensitive(sensitive)
|
||||||
|
icon.show()
|
||||||
|
|
||||||
|
icon = Icon(icon_name='gtk-new',
|
||||||
|
icon_size=gtk.ICON_SIZE_LARGE_TOOLBAR,
|
||||||
|
badge_name='gtk-cancel')
|
||||||
|
box.pack_start(icon)
|
||||||
|
icon.set_sensitive(sensitive)
|
||||||
|
icon.show()
|
||||||
|
|
||||||
|
|
||||||
|
create_icon_widgets(sensitive_box, True)
|
||||||
|
create_icon_widgets(insensitive_box, False)
|
||||||
|
|
||||||
test.show()
|
test.show()
|
||||||
|
|
||||||
|
# This can be used to test for leaks by setting the LRU cache size
|
||||||
|
# in icon.py to 1.
|
||||||
|
#def idle_cb():
|
||||||
|
# import gc
|
||||||
|
# gc.collect()
|
||||||
|
# test.queue_draw()
|
||||||
|
# return True
|
||||||
|
#
|
||||||
|
#import gobject
|
||||||
|
#gobject.idle_add(idle_cb)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
common.main(test)
|
common.main(test)
|
||||||
|
@ -20,28 +20,28 @@
|
|||||||
import sys
|
import sys
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from sugar import objects
|
from sugar import mime
|
||||||
|
|
||||||
class TestMime(unittest.TestCase):
|
class TestMime(unittest.TestCase):
|
||||||
def test_from_file_name(self):
|
def test_from_file_name(self):
|
||||||
self.assertEqual(objects.mime.get_from_file_name('test.pdf'),
|
self.assertEqual(mime.get_from_file_name('test.pdf'),
|
||||||
'application/pdf')
|
'application/pdf')
|
||||||
|
|
||||||
def test_choose_most_significant(self):
|
def test_choose_most_significant(self):
|
||||||
# Mozilla's text in dnd
|
# Mozilla's text in dnd
|
||||||
mime_type = objects.mime.choose_most_significant(
|
mime_type = mime.choose_most_significant(
|
||||||
['text/plain', 'text/_moz_htmlcontext', 'text/unicode',
|
['text/plain', 'text/_moz_htmlcontext', 'text/unicode',
|
||||||
'text/html', 'text/_moz_htmlinfo'])
|
'text/html', 'text/_moz_htmlinfo'])
|
||||||
self.assertEqual(mime_type, 'text/html')
|
self.assertEqual(mime_type, 'text/html')
|
||||||
|
|
||||||
# Mozilla's text in c&v
|
# Mozilla's text in c&v
|
||||||
mime_type = objects.mime.choose_most_significant(
|
mime_type = mime.choose_most_significant(
|
||||||
['text/_moz_htmlcontext', 'STRING', 'text/html', 'text/_moz_htmlinfo',
|
['text/_moz_htmlcontext', 'STRING', 'text/html', 'text/_moz_htmlinfo',
|
||||||
'text/x-moz-url-priv', 'UTF8_STRING', 'COMPOUND_TEXT'])
|
'text/x-moz-url-priv', 'UTF8_STRING', 'COMPOUND_TEXT'])
|
||||||
self.assertEqual(mime_type, 'text/html')
|
self.assertEqual(mime_type, 'text/html')
|
||||||
|
|
||||||
# Mozilla gif in dnd
|
# Mozilla gif in dnd
|
||||||
mime_type = objects.mime.choose_most_significant(
|
mime_type = mime.choose_most_significant(
|
||||||
['application/x-moz-file-promise-url',
|
['application/x-moz-file-promise-url',
|
||||||
'application/x-moz-file-promise-dest-filename', 'text/_moz_htmlinfo',
|
'application/x-moz-file-promise-dest-filename', 'text/_moz_htmlinfo',
|
||||||
'text/x-moz-url-desc', 'text/_moz_htmlcontext', 'text/x-moz-url-data',
|
'text/x-moz-url-desc', 'text/_moz_htmlcontext', 'text/x-moz-url-data',
|
||||||
@ -49,24 +49,33 @@ class TestMime(unittest.TestCase):
|
|||||||
self.assertEqual(mime_type, 'text/uri-list')
|
self.assertEqual(mime_type, 'text/uri-list')
|
||||||
|
|
||||||
# Mozilla url in dnd
|
# Mozilla url in dnd
|
||||||
mime_type = objects.mime.choose_most_significant(
|
mime_type = mime.choose_most_significant(
|
||||||
['text/_moz_htmlcontext', 'text/html', 'text/_moz_htmlinfo',
|
['text/_moz_htmlcontext', 'text/html', 'text/_moz_htmlinfo',
|
||||||
'_NETSCAPE_URL', 'text/x-moz-url', 'text/x-moz-url-desc',
|
'_NETSCAPE_URL', 'text/x-moz-url', 'text/x-moz-url-desc',
|
||||||
'text/x-moz-url-data', 'text/plain', 'text/unicode'])
|
'text/x-moz-url-data', 'text/plain', 'text/unicode'])
|
||||||
self.assertEqual(mime_type, 'text/x-moz-url')
|
self.assertEqual(mime_type, 'text/x-moz-url')
|
||||||
|
|
||||||
# Abiword text in dnd
|
# Abiword text in dnd
|
||||||
mime_type = objects.mime.choose_most_significant(
|
mime_type = mime.choose_most_significant(
|
||||||
['text/rtf', 'text/uri-list'])
|
['text/rtf', 'text/uri-list'])
|
||||||
self.assertEqual(mime_type, 'text/uri-list')
|
self.assertEqual(mime_type, 'text/uri-list')
|
||||||
|
|
||||||
# Abiword text in c&v
|
# Abiword text in c&v
|
||||||
mime_type = objects.mime.choose_most_significant(
|
mime_type = mime.choose_most_significant(
|
||||||
['UTF8_STRING', 'STRING', 'text/html', 'TEXT', 'text/rtf',
|
['UTF8_STRING', 'STRING', 'text/html', 'TEXT', 'text/rtf',
|
||||||
'COMPOUND_TEXT', 'application/rtf', 'text/plain',
|
'COMPOUND_TEXT', 'application/rtf', 'text/plain',
|
||||||
'application/xhtml+xml'])
|
'application/xhtml+xml'])
|
||||||
self.assertEqual(mime_type, 'application/rtf')
|
self.assertEqual(mime_type, 'application/rtf')
|
||||||
|
|
||||||
|
# Abiword text in c&v
|
||||||
|
mime_type = mime.choose_most_significant(
|
||||||
|
['GTK_TEXT_BUFFER_CONTENTS',
|
||||||
|
'application/x-gtk-text-buffer-rich-text',
|
||||||
|
'UTF8_STRING', 'COMPOUND_TEXT', 'TEXT', 'STRING',
|
||||||
|
'text/plain;charset=utf-8', 'text/plain;charset=UTF-8',
|
||||||
|
'text/plain'])
|
||||||
|
self.assertEqual(mime_type, 'text/plain')
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user