Merge branch 'master' of git+ssh://dev.laptop.org/git/sugar

This commit is contained in:
Pootle User 2008-01-11 14:18:06 +00:00
commit b59a81b885
6 changed files with 35 additions and 8 deletions

View File

@ -20,6 +20,10 @@ import os
from ConfigParser import ConfigParser from ConfigParser import ConfigParser
import gettext import gettext
# HACK we need to import numpy before gtk otherwise we traceback in
# some locales. See http://dev.laptop.org/ticket/5559.
import numpy
import pygtk import pygtk
pygtk.require('2.0') pygtk.require('2.0')
import gtk import gtk

View File

@ -838,12 +838,24 @@ class Activity(Window, gtk.Container):
if response_id == gtk.RESPONSE_OK: if response_id == gtk.RESPONSE_OK:
self.close(skip_save=True) self.close(skip_save=True)
def close(self, skip_save=False): def can_close(self):
"""Activities should override this function if they want to perform
extra checks before actually closing."""
return True
def close(self, force=False, 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 write_file() to Activities should not override this method, but should implement write_file() to
do any state saving instead. do any state saving instead. If the application wants to control wether it can
close, it should override can_close().
""" """
if not force:
if not self.can_close():
return
try: try:
if not skip_save: if not skip_save:
self.save() self.save()

View File

@ -18,11 +18,16 @@
import gtk import gtk
from sugar.graphics.icon import Icon from sugar.graphics.icon import Icon
import pango
class MenuItem(gtk.ImageMenuItem): class MenuItem(gtk.ImageMenuItem):
def __init__(self, text_label=None, icon_name=None): def __init__(self, text_label=None, icon_name=None, text_maxlen=0):
gtk.ImageMenuItem.__init__(self, text_label) gtk.ImageMenuItem.__init__(self, text_label)
if icon_name: if icon_name:
icon = Icon(icon_name=icon_name, icon_size=gtk.ICON_SIZE_MENU) icon = Icon(icon_name=icon_name, icon_size=gtk.ICON_SIZE_MENU)
self.set_image(icon) self.set_image(icon)
icon.show() icon.show()
if text_maxlen > 0:
self.child.set_ellipsize(pango.ELLIPSIZE_MIDDLE)
self.child.set_max_width_chars(text_maxlen)

View File

@ -21,6 +21,7 @@ import gtk
import gobject import gobject
import time import time
import hippo import hippo
import pango
from sugar.graphics import palettegroup from sugar.graphics import palettegroup
from sugar.graphics import animator from sugar.graphics import animator
@ -140,7 +141,8 @@ class Palette(gtk.Window):
gobject.TYPE_NONE, ([])) gobject.TYPE_NONE, ([]))
} }
def __init__(self, label, accel_path=None, menu_after_content=False): def __init__(self, label, accel_path=None, menu_after_content=False,
text_maxlen=0):
gtk.Window.__init__(self) gtk.Window.__init__(self)
self.set_decorated(False) self.set_decorated(False)
@ -178,6 +180,11 @@ class Palette(gtk.Window):
- 2*self.get_border_width()) - 2*self.get_border_width())
self._label.set_alignment(0, 0.5) self._label.set_alignment(0, 0.5)
self._label.set_padding(style.DEFAULT_SPACING, 0) self._label.set_padding(style.DEFAULT_SPACING, 0)
if text_maxlen > 0:
self._label.set_max_width_chars(text_maxlen)
self._label.set_ellipsize(pango.ELLIPSIZE_MIDDLE)
vbox.pack_start(self._label, False) vbox.pack_start(self._label, False)
self._secondary_box = gtk.VBox() self._secondary_box = gtk.VBox()

View File

@ -404,10 +404,9 @@ def set_timezone(timezone):
# Write info to the /etc/sysconfig/clock file # Write info to the /etc/sysconfig/clock file
fd = open(_TIMEZONE_CONFIG, "w") fd = open(_TIMEZONE_CONFIG, "w")
fd.write('# The ZONE parameter is only evaluated by sugarcontrol.\n') fd.write('# use sugar-control-panel to change this\n')
fd.write('# The timezone of the system ' +
'is defined by the contents of /etc/localtime.\n')
fd.write('ZONE="%s"\n' % timezone) fd.write('ZONE="%s"\n' % timezone)
fd.write('UTC=true\n')
fd.close() fd.close()
else: else:
print (_("Error timezone does not exist.")) print (_("Error timezone does not exist."))

View File

@ -37,7 +37,7 @@ class BuddyMenu(Palette):
self._buddy.connect('nick-changed', self._buddy_nick_changed_cb) self._buddy.connect('nick-changed', self._buddy_nick_changed_cb)
owner = self._get_shell_model().get_owner() owner = self._get_shell_model().get_owner()
if buddy.get_nick() != owner.get_nick(): if not buddy.is_owner():
self._add_items() self._add_items()
def _get_shell_model(self): def _get_shell_model(self):