예제 #1
0
 def get_depiction(self):
     if self.pixbuf == None:
         file_name = os.path.join(self.activity_root, 'data',
                                  self.get_metadata('hasDepiction')[0])
         self.pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(
             file_name, style.zoom(160), style.zoom(120))
     return self.pixbuf
예제 #2
0
    def set_image(self, buf, fill='#0000ff', stroke='#4d4c4f'):
        img = gtk.Image()                    
        loader = gtk.gdk.PixbufLoader()
        loader.write(buf)
        loader.close()
        pixbuf = loader.get_pixbuf()
        del loader            

        xo_buddy = os.path.join(os.path.dirname(__file__), "icons/link.svg")
        pixbuf_bg = self._read_link_background(xo_buddy, fill, stroke)
        pixbuf_bg = pixbuf_bg.scale_simple(style.zoom(120),
                                           style.zoom(110),
                                           gtk.gdk.INTERP_BILINEAR)        
        dest_x = style.zoom(10) 
        dest_y = style.zoom(20) 
        w = pixbuf.get_width()
        h = pixbuf.get_height() 
        scale_x = 1
        scale_y = 1
        
        pixbuf.composite(pixbuf_bg, dest_x, dest_y, w, h, dest_x, dest_y,
                         scale_x, scale_y, gtk.gdk.INTERP_BILINEAR, 255)
        img.set_from_pixbuf(pixbuf_bg)
        self.set_icon_widget(img)
        img.show()
        del pixbuf
        del pixbuf_bg
        gc.collect()
예제 #3
0
    def get_preview(self):
        """Returns an image representing the state of the activity. Generally
        this is what the user is seeing in this moment.

        Activities can override this method, which should return a str with the
        binary content of a png image with a width of 300 and a height of 225
        pixels.
        """
        if self.canvas is None or not hasattr(self.canvas, 'get_snapshot'):
            return None
        pixmap = self.canvas.get_snapshot((-1, -1, 0, 0))

        width, height = pixmap.get_size()
        pixbuf = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, 0, 8, width, height)
        pixbuf = pixbuf.get_from_drawable(pixmap, pixmap.get_colormap(), 0, 0,
                                          0, 0, width, height)
        pixbuf = pixbuf.scale_simple(style.zoom(300), style.zoom(225),
                                     gtk.gdk.INTERP_BILINEAR)

        preview_data = []

        def save_func(buf, data):
            data.append(buf)

        pixbuf.save_to_callback(save_func, 'png', user_data=preview_data)
        preview_data = ''.join(preview_data)

        return preview_data
예제 #4
0
    def get_preview(self):
        """Returns an image representing the state of the activity. Generally
        this is what the user is seeing in this moment.

        Activities can override this method, which should return a str with the
        binary content of a png image with a width of 300 and a height of 225
        pixels.
        """
        if self.canvas is None or not hasattr(self.canvas, 'get_snapshot'):
            return None
        pixmap = self.canvas.get_snapshot((-1, -1, 0, 0))

        width, height = pixmap.get_size()
        pixbuf = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, 0, 8, width, height)
        pixbuf = pixbuf.get_from_drawable(pixmap, pixmap.get_colormap(),
                                          0, 0, 0, 0, width, height)
        pixbuf = pixbuf.scale_simple(style.zoom(300), style.zoom(225),
                                     gtk.gdk.INTERP_BILINEAR)

        preview_data = []
        def save_func(buf, data):
            data.append(buf)

        pixbuf.save_to_callback(save_func, 'png', user_data=preview_data)
        preview_data = ''.join(preview_data)

        return preview_data
예제 #5
0
def _get_preview_data(screenshot):
    preview = screenshot.scale_simple(style.zoom(300), style.zoom(225),
                                      gtk.gdk.INTERP_BILINEAR)
    preview_data = []

    def save_func(buf, data):
        data.append(buf)

    preview.save_to_callback(save_func, 'png', user_data=preview_data)

    return dbus.ByteArray(''.join(preview_data))
예제 #6
0
    def __init__(self, parent):
        gtk.TreeView.__init__(self)
        self._model = gtk.ListStore(str, str, str, str)
        self.set_model(self._model)
        self._activity = parent
        self.set_rules_hint(True)

        self.icon = CellRendererIcon(self)
        self.icon._buffer.width = style.zoom(100)
        self.icon._buffer.height = style.zoom(100)
        self.icon._xo_color = color
        self._name = gtk.CellRendererText()
        self.description = gtk.CellRendererText()
        self.status = gtk.CellRendererText()
        self.description.props.wrap_mode = True

        self.icon_column = gtk.TreeViewColumn(_("Icon"))
        self._name_column = gtk.TreeViewColumn(_("Activity"))
        self.description_column = gtk.TreeViewColumn(_("Description"))
        self.status_column = gtk.TreeViewColumn(_("Status"))

        self.icon_column.pack_start(self.icon, False)
        self._name_column.pack_start(self._name, True)
        self.description_column.pack_start(self.description, True)
        self.status_column.pack_start(self.status, False)

        self.icon_column.add_attribute(self.icon, 'icon_name', 0)
        self._name_column.add_attribute(self._name, "markup", 1)
        self.description_column.add_attribute(self.description, "markup", 2)
        self.status_column.add_attribute(self.status, "text", 3)

        self.current = 0

        self.append_column(self.icon_column)
        self.append_column(self._name_column)
        self.append_column(self.description_column)
        self.append_column(self.status_column)

        self.download_list = DownloadList()
        self.connect("row-activated", self._download)

        self._parent = parent
        self.thread = None
        self.words = ''
        self._list = utils.get_store_list()
        self.can_search = True
        self.stopped = False

        self.show_all()
예제 #7
0
    def __init__(self, handle):
        "The entry point to the Activity"
        global page
        activity.Activity.__init__(self, handle)

        toolbox = activity.ActivityToolbox(self)
        activity_toolbar = toolbox.get_activity_toolbar()
        activity_toolbar.keep.props.visible = False
        activity_toolbar.share.props.visible = False
        self.set_toolbox(toolbox)

        toolbox.show()
        self.scrolled_window = gtk.ScrolledWindow()
        self.scrolled_window.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
        self.scrolled_window.props.shadow_type = gtk.SHADOW_NONE

        self.textview = gtk.TextView()
        self.textview.set_editable(False)
        self.textview.set_cursor_visible(False)
        self.textview.set_left_margin(50)
        self.textview.connect("key_press_event", self.keypress_cb)

        self.scrolled_window.add(self.textview)
        self.set_canvas(self.scrolled_window)
        self.textview.show()
        self.scrolled_window.show()
        page = 0
        self.textview.grab_focus()
        self.font_desc = pango.FontDescription("sans %d" % style.zoom(10))
        self.textview.modify_font(self.font_desc)
    def get_preview(self):
        if not hasattr(self.abiword_canvas, 'render_page_to_image'):
            return activity.Activity.get_preview(self)

        pixbuf = self.abiword_canvas.render_page_to_image(1)
        pixbuf = pixbuf.scale_simple(style.zoom(300), style.zoom(225),
                                     gtk.gdk.INTERP_BILINEAR)

        preview_data = []
        def save_func(buf, data):
            data.append(buf)

        pixbuf.save_to_callback(save_func, 'png', user_data=preview_data)
        preview_data = ''.join(preview_data)

        return preview_data
예제 #9
0
    def _get_screenshot(self):
        window = self._browser.window
        width, height = window.get_size()

        screenshot = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, has_alpha=False,
                                    bits_per_sample=8, width=width,
                                    height=height)
        screenshot.get_from_drawable(window, window.get_colormap(), 0, 0, 0, 0,
                                     width, height)

        screenshot = screenshot.scale_simple(style.zoom(100),
                                                 style.zoom(80),
                                                 gtk.gdk.INTERP_BILINEAR)

        buf = self.get_buffer(screenshot)
        return buf
예제 #10
0
    def _create_preview(self):
        width = style.zoom(320)
        height = style.zoom(240)
        box = hippo.CanvasBox()

        if len(self._metadata.get('preview', '')) > 4:
            if self._metadata['preview'][1:4] == 'PNG':
                preview_data = self._metadata['preview']
            else:
                # TODO: We are close to be able to drop this.
                import base64
                preview_data = base64.b64decode(self._metadata['preview'])

            png_file = StringIO.StringIO(preview_data)
            try:
                surface = cairo.ImageSurface.create_from_png(png_file)
                has_preview = True
            except Exception:
                logging.exception('Error while loading the preview')
                has_preview = False
        else:
            has_preview = False

        if has_preview:
            preview_box = hippo.CanvasImage(
                image=surface,
                border=style.LINE_WIDTH,
                border_color=style.COLOR_BUTTON_GREY.get_int(),
                xalign=hippo.ALIGNMENT_CENTER,
                yalign=hippo.ALIGNMENT_CENTER,
                scale_width=width,
                scale_height=height)
        else:
            preview_box = hippo.CanvasText(
                text=_('No preview'),
                font_desc=style.FONT_NORMAL.get_pango_desc(),
                xalign=hippo.ALIGNMENT_CENTER,
                yalign=hippo.ALIGNMENT_CENTER,
                border=style.LINE_WIDTH,
                border_color=style.COLOR_BUTTON_GREY.get_int(),
                color=style.COLOR_BUTTON_GREY.get_int(),
                box_width=width,
                box_height=height)
        preview_box.connect_after('button-release-event',
                                  self._preview_box_button_release_event_cb)
        box.append(preview_box)
        return box
예제 #11
0
    def _create_preview(self):
        width = style.zoom(320)
        height = style.zoom(240)
        box = hippo.CanvasBox()

        if len(self._metadata.get('preview', '')) > 4:
            if self._metadata['preview'][1:4] == 'PNG':
                preview_data = self._metadata['preview']
            else:
                # TODO: We are close to be able to drop this.
                import base64
                preview_data = base64.b64decode(
                        self._metadata['preview'])

            png_file = StringIO.StringIO(preview_data)
            try:
                surface = cairo.ImageSurface.create_from_png(png_file)
                has_preview = True
            except Exception:
                logging.exception('Error while loading the preview')
                has_preview = False
        else:
            has_preview = False

        if has_preview:
            preview_box = hippo.CanvasImage(image=surface,
                    border=style.LINE_WIDTH,
                    border_color=style.COLOR_BUTTON_GREY.get_int(),
                    xalign=hippo.ALIGNMENT_CENTER,
                    yalign=hippo.ALIGNMENT_CENTER,
                    scale_width=width,
                    scale_height=height)
        else:
            preview_box = hippo.CanvasText(text=_('No preview'),
                    font_desc=style.FONT_NORMAL.get_pango_desc(),
                    xalign=hippo.ALIGNMENT_CENTER,
                    yalign=hippo.ALIGNMENT_CENTER,
                    border=style.LINE_WIDTH,
                    border_color=style.COLOR_BUTTON_GREY.get_int(),
                    color=style.COLOR_BUTTON_GREY.get_int(),
                    box_width=width,
                    box_height=height)
        preview_box.connect_after('button-release-event',
                                  self._preview_box_button_release_event_cb)
        box.append(preview_box)
        return box
예제 #12
0
 def update_preview_cb(self, file_chooser, preview):
     filename = file_chooser.get_preview_filename()
     try:
         file_mimetype = mime.get_for_file(filename)
         if file_mimetype == 'application/x-cbz' or file_mimetype == 'application/zip':
             fname = self.extract_image(filename)
             pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(
                 fname, style.zoom(320), style.zoom(240))
             preview.set_from_pixbuf(pixbuf)
             have_preview = True
             os.remove(fname)
         else:
             have_preview = False
     except:
         have_preview = False
     file_chooser.set_preview_widget_active(have_preview)
     return
예제 #13
0
 def update_preview_cb(self, file_chooser, preview):
     filename = file_chooser.get_preview_filename()
     try:
         file_mimetype = mime.get_for_file(filename)
         if file_mimetype  == 'application/x-cbz' or file_mimetype == 'application/zip':
             fname = self.extract_image(filename)
             pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(fname, 
                 style.zoom(320), style.zoom(240))
             preview.set_from_pixbuf(pixbuf)
             have_preview = True
             os.remove(fname)
         else:
             have_preview = False
     except:
         have_preview = False
     file_chooser.set_preview_widget_active(have_preview)
     return
    def create_preview_metadata(self,  filename):

        file_mimetype = mime.get_for_file(filename)
        if not file_mimetype.startswith('image/'):
            return ''
            
        scaled_pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(filename,
                                                              style.zoom(320), style.zoom(240))
        preview_data = []

        def save_func(buf, data):
            data.append(buf)

        scaled_pixbuf.save_to_callback(save_func, 'png', 
                                       user_data=preview_data)
        preview_data = ''.join(preview_data)

        return preview_data
예제 #15
0
파일: style.py 프로젝트: AlanJAS/Butia
def font_zoom(size):
    """ 21 Returns the proper font size for current Sugar environment
    NOTE: Use this function only if you are targeting activity for XO with 
    0.82 Sugar and want non-default font sizes, otherwise just
    do not mention font sizes in your code
    """

    if hasattr(style, '_XO_DPI'):
        return style.zoom(size)
    else:
        return size
예제 #16
0
    def __init__(self, **kwargs):
        hippo.CanvasBox.__init__(self, **kwargs)

        # TODO: we should calculate radius depending on the height of the box.
        self._radius = style.zoom(10)

        self.props.orientation = hippo.ORIENTATION_HORIZONTAL
        self.props.border = self._BORDER_DEFAULT
        self.props.border_left = self._radius
        self.props.border_right = self._radius
        self.props.border_color = style.COLOR_BLACK.get_int()
예제 #17
0
    def __init__(self, **kwargs):
        gtk.HBox.__init__(self, **kwargs)

        self._x = None
        self._y = None
        self._width = None
        self._height = None
        self._radius = style.zoom(10)
        self.border = self._BORDER_DEFAULT
        self.border_color = style.COLOR_BLACK
        self.background_color = None
        self.set_reallocate_redraws(True)
        self.set_resize_mode(gtk.RESIZE_PARENT)
        self.connect("expose_event", self.__expose_cb)
        self.connect("add", self.__add_cb)
예제 #18
0
    def __init__(self, **kwargs):
        gtk.HBox.__init__(self, **kwargs)

        self._x = None
        self._y = None
        self._width = None
        self._height = None
        self._radius = style.zoom(10)
        self.border = self._BORDER_DEFAULT
        self.border_color = style.COLOR_BLACK
        self.background_color = None
        self.set_reallocate_redraws(True)
        self.set_resize_mode(gtk.RESIZE_PARENT)
        self.connect("expose_event", self.__expose_cb)
        self.connect("add", self.__add_cb)
예제 #19
0
    def __init__(self, intro):
        _Page.__init__(self)
        self._intro = intro

        alignment = gtk.Alignment(0.5, 0.5, 0, 0)
        self.pack_start(alignment, expand=True, fill=True)

        hbox = gtk.HBox(spacing=style.DEFAULT_SPACING)
        alignment.add(hbox)

        label = gtk.Label(_('Name:'))
        hbox.pack_start(label, expand=False)

        self._entry = gtk.Entry()
        self._entry.connect('notify::text', self._text_changed_cb)
        self._entry.set_size_request(style.zoom(300), -1)
        self._entry.set_max_length(45)
        hbox.pack_start(self._entry, expand=False)
예제 #20
0
    def __init__(self, intro):
        _Page.__init__(self)
        self._intro = intro

        alignment = gtk.Alignment(0.5, 0.5, 0, 0)
        self.pack_start(alignment, expand=True, fill=True)

        hbox = gtk.HBox(spacing=style.DEFAULT_SPACING)
        alignment.add(hbox)

        label = gtk.Label(_('Name:'))
        hbox.pack_start(label, expand=False)

        self._entry = gtk.Entry()
        self._entry.connect('notify::text', self._text_changed_cb)
        self._entry.set_size_request(style.zoom(300), -1)
        self._entry.set_max_length(45)
        hbox.pack_start(self._entry, expand=False)
예제 #21
0
    def __init__(self, primary_text):
        Palette.__init__(self, primary_text)
        self._level = 0
        self._time = 0
        self._status = _STATUS_NOT_PRESENT
        self._progress_bar = gtk.ProgressBar()
        self._progress_bar.set_size_request(
            style.zoom(style.GRID_CELL_SIZE * 4), -1)
        self._progress_bar.show()
        self._status_label = gtk.Label()
        self._status_label.show()

        vbox = gtk.VBox()
        vbox.pack_start(self._progress_bar)
        vbox.pack_start(self._status_label)
        vbox.show()

        self._progress_widget = vbox
        self.set_content(self._progress_widget)
예제 #22
0
    def setup(self, activity):
        self._activity = activity
        activity._scrolled = gtk.ScrolledWindow()
        activity._scrolled.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
        activity._scrolled.props.shadow_type = gtk.SHADOW_NONE

        self._scrolled = activity._scrolled

        self.textview = gtk.TextView()
        self.textview.set_editable(False)
        self.textview.set_cursor_visible(False)
        self.textview.set_left_margin(50)
        self.textview.set_right_margin(50)
        self.textview.set_wrap_mode(gtk.WRAP_WORD)
        self.textview.connect('button-release-event', \
                self._view_buttonrelease_event_cb)
        self.connect('selection-changed', activity._view_selection_changed_cb)

        activity._scrolled.add(self.textview)
        self.textview.show()
        activity._scrolled.show()
        activity._hbox.pack_start(activity._scrolled, expand=True, fill=True)

        self._font_size = style.zoom(10)
        self.font_desc = pango.FontDescription("sans %d" % self._font_size)
        self.textview.modify_font(self.font_desc)
        self._zoom = 100
        self.font_zoom_relation = self._zoom / self._font_size
        self._current_page = 0

        self.highlight_tag = self.textview.get_buffer().create_tag()
        self.highlight_tag.set_property('underline', 'single')
        self.highlight_tag.set_property('foreground', 'black')
        self.highlight_tag.set_property('background', 'yellow')

        # text to speech initialization
        self.current_word = 0
        self.word_tuples = []
        self.spoken_word_tag = self.textview.get_buffer().create_tag()
        self.spoken_word_tag.set_property('weight', pango.WEIGHT_BOLD)
        self.normal_tag = self.textview.get_buffer().create_tag()
        self.normal_tag.set_property('weight', pango.WEIGHT_NORMAL)
예제 #23
0
    def _create_color_scale(self, text, color, row):
        label = gtk.Label(text)
        label.props.xalign = 1.0
        scale = gtk.HScale()
        scale.set_size_request(style.zoom(250), -1)
        scale.set_draw_value(False)
        scale.set_range(0, 1.0)
        scale.set_increments(0.1, 0.2)

        if color == self._RED:
            scale.set_value(self._color.red / 65535.0)
        elif color == self._GREEN:
            scale.set_value(self._color.green / 65535.0)
        elif color == self._BLUE:
            scale.set_value(self._color.blue / 65535.0)

        scale.connect('value-changed', self.__scale_value_changed_cb, color)
        self._chooser_table.attach(label, 0, 1, row, row + 1)
        self._chooser_table.attach(scale, 1, 2, row, row + 1)

        return scale
예제 #24
0
    def __init__(self):
        gtk.VBox.__init__(self)
        self.set_border_width(style.zoom(30))

        self._page = self.PAGE_NAME
        self._name_page = _NamePage(self)
        self._color_page = _ColorPage()
        self._current_page = None
        self._next_button = None

        client = gconf.client_get_default()
        default_nick = client.get_string('/desktop/sugar/user/default_nick')
        if default_nick != 'disabled':
            self._page = self.PAGE_COLOR
            if default_nick == 'system':
                pwd_entry = pwd.getpwuid(os.getuid())
                default_nick = (pwd_entry.pw_gecos.split(',')[0]
                                or pwd_entry.pw_name)
            self._name_page.set_name(default_nick)

        self._setup_page()
예제 #25
0
    def __init__(self):
        gtk.VBox.__init__(self)
        self.set_border_width(style.zoom(30))

        self._page = self.PAGE_NAME
        self._name_page = _NamePage(self)
        self._color_page = _ColorPage()
        self._current_page = None
        self._next_button = None

        client = gconf.client_get_default()
        default_nick = client.get_string('/desktop/sugar/user/default_nick')
        if default_nick != 'disabled':
            self._page = self.PAGE_COLOR
            if default_nick == 'system':
                pwd_entry = pwd.getpwuid(os.getuid())
                default_nick = (pwd_entry.pw_gecos.split(',')[0] or
                                pwd_entry.pw_name)
            self._name_page.set_name(default_nick)

        self._setup_page()
    def __init__(self, handle):
        activity.Activity.__init__(self, handle)
        logger.debug("test")

        # Configure the toolbox
        toolbox = activity.ActivityToolbox(self)
        activity_toolbar = toolbox.get_activity_toolbar()
        activity_toolbar.keep.props.visible = False
        activity_toolbar.share.props.visible = False
        self.set_toolbox(toolbox)
        toolbox.show()

        # Create a data store and the app
        datastore = Datastore("127.0.0.1:8080")
        backend = BackEnd(datastore, self.get_activity_root())
        main = SortingPanel(datastore, backend)
        widget = main.get_widget()

        # pack
        self.set_canvas(widget)
        widget.grab_focus()
        widget.modify_font(pango.FontDescription("sans %d" % style.zoom(10)))
 def __init__(self, handle):
     activity.Activity.__init__(self, handle)
     logger.debug("test")
     
     # Configure the toolbox
     toolbox = activity.ActivityToolbox(self)
     activity_toolbar = toolbox.get_activity_toolbar()
     activity_toolbar.keep.props.visible = False
     activity_toolbar.share.props.visible = False
     self.set_toolbox(toolbox)
     toolbox.show()
     
     # Create a data store and the app
     datastore = Datastore("127.0.0.1:8080")
     backend = BackEnd(datastore, self.get_activity_root())
     main = SortingPanel(datastore, backend)
     widget = main.get_widget()
     
     # pack
     self.set_canvas(widget)
     widget.grab_focus()
     widget.modify_font(pango.FontDescription("sans %d" % style.zoom(10)))
예제 #28
0
    def _create_color_scale(self, text, color, row):
        label = gtk.Label(text)
        label.props.xalign = 1.0
        scale = gtk.HScale()
        scale.set_size_request(style.zoom(250), -1)
        scale.set_draw_value(False)
        scale.set_range(0, 1.0)
        scale.set_increments(0.1, 0.2)

        if color == self._RED:
            scale.set_value(self._color.red / 65535.0)
        elif color == self._GREEN:
            scale.set_value(self._color.green / 65535.0)
        elif color == self._BLUE:
            scale.set_value(self._color.blue / 65535.0)

        scale.connect('value-changed',
                      self.__scale_value_changed_cb,
                      color)
        self._chooser_table.attach(label, 0, 1, row, row + 1)
        self._chooser_table.attach(scale, 1, 2, row, row + 1)

        return scale
예제 #29
0
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.

import gtk
import gobject

from sugar.graphics import style
from sugar.graphics.toolbutton import ToolButton
from sugar.graphics import palettegroup

from toolkit.internals.palettewindow import PaletteWindow
from toolkit.internals.palettewindow import ToolInvoker

_ARROW_SIZE = style.zoom(24)
_LINE_WIDTH = 2


class ToolbarButton(ToolButton):
    def __init__(self, page=None, **kwargs):
        ToolButton.__init__(self, **kwargs)

        self.page_widget = None

        self.set_page(page)

        self.connect('clicked',
                     lambda widget: self.set_expanded(not self.is_expanded()))
        self.connect('size-allocate', self.__size_allocate_cb)
예제 #30
0
파일: chatbox.py 프로젝트: Akirato/speak
    def add_text(self, buddy, text, status_message=False):
        '''Display text on screen, with name and colors.
        buddy -- buddy object or dict {nick: string, color: string}
        (The dict is for loading the chat log from the journal,
        when we don't have the buddy object any more.)
        text -- string, what the buddy said
        status_message -- boolean
        False: show what buddy said
        True: show what buddy did

        .----- rb ------------.
        |  +----align-------+ |
        |  | +--message---+ | |
        |  | | nick:      | | |
        |  | | text 1     | | |
        |  | | text 2     | | |
        |  | +------------+ | |
        |  +----------------+ |
        `----------------- +--'
                          \|

        The color scheme for owner messages is:
        nick in darker of stroke and fill colors
        background in lighter of stroke and fill colors
        text in black

        The color scheme for buddy messages is:
        nick in darker of stroke and fill colors
        background in light gray
        text in black

        rb has a tail on the right for owner messages and the left for
        buddy messages.
        '''
        if not buddy:
            buddy = self._owner

        if type(buddy) is dict:
            # dict required for loading chat log from journal
            nick = buddy['nick']
            color = buddy['color']
        elif buddy is None:
            nick = 'unknown'
            color = '#000000,#808080'
        else:
            nick = buddy.props.nick
            color = buddy.props.color
        try:
            color_stroke_html, color_fill_html = color.split(',')
        except ValueError:
            color_stroke_html, color_fill_html = ('#000000', '#888888')

        lighter = lighter_color(color.split(','))
        darker = 1 - lighter

        if len(text) > 3 and text[0:4] == '/me ':
            me_message = True
        else:
            me_message = False

        if status_message or me_message:
            text_color = style.COLOR_WHITE
            nick_color = style.COLOR_WHITE
            color_fill = style.Color('#808080')
            highlight_fill = style.COLOR_WHITE
            tail = None
        else:
            highlight_fill = style.COLOR_BUTTON_GREY
            text_color = style.COLOR_BLACK
            if darker == 1:
                color_fill = style.Color(color_stroke_html)
                if is_low_contrast(color.split(',')):
                    nick_color = text_color
                else:
                    nick_color = style.Color(color_fill_html)
            else:
                color_fill = style.Color(color_fill_html)
                if is_low_contrast(color.split(',')):
                    nick_color = text_color
                else:
                    nick_color = style.Color(color_stroke_html)
            if nick == profile.get_nick_name():
                tail = 'right'
            else:
                tail = 'left'

        color_stroke = None

        self._add_log(nick, color, text, status_message)

        # Check for Right-To-Left languages:
        if pango.find_base_dir(nick, -1) == pango.DIRECTION_RTL:
            lang_rtl = True
        else:
            lang_rtl = False

        # Check if new message box or add text to previous:
        new_msg = True
        if self._last_msg_sender and buddy == self._last_msg_sender:
            # Add text to previous message
            if not (me_message or status_message):
                new_msg = False

        if not new_msg:
            message = self._last_msg
            message.add_text(text)
        else:
            rb = RoundBox()
            rb.background_color = color_fill
            rb.border_color = color_stroke
            rb.tail = tail
            self._rb_list.append(rb)

            grid_internal = gtk.VBox()
            grid_internal.set_size_request(
                gtk.gdk.screen_width() - style.GRID_CELL_SIZE,
                style.GRID_CELL_SIZE)  # -1)
            self._grid_list.append(grid_internal)

            row = 0

            if status_message:
                nick = None
            elif me_message:
                text = text[4:]

            message = TextBox(self, nick_color, text_color, color_fill,
                              highlight_fill, lang_rtl, nick, text)
            self._message_list.append(message)

            self._last_msg_sender = buddy
            self._last_msg = message

            grid_internal.pack_start(message, expand=False, padding=0)
            row += 1

            align = gtk.Alignment(0.0, 0.0, 1.0, 1.0)
            if rb.tail is None:
                bottom_padding = style.zoom(7)
            else:
                bottom_padding = style.zoom(40)
            align.set_padding(style.zoom(7), bottom_padding, style.zoom(30),
                              style.zoom(30))

            align.add(grid_internal)
            grid_internal.show()

            rb.pack_start(align, True, True, 0)
            align.show()

            self._conversation.pack_start(rb, expand=False,
                                          padding=style.DEFAULT_PADDING)
            rb.show()
            self._row_counter += 1
            message.show()

        if status_message:
            self._last_msg_sender = None
예제 #31
0
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

import math

import gobject
import hippo

from sugar.graphics import style


_BASE_DISTANCE = style.zoom(25)
_CHILDREN_FACTOR = style.zoom(3)


class SnowflakeLayout(gobject.GObject, hippo.CanvasLayout):
    __gtype_name__ = 'SugarSnowflakeLayout'

    def __init__(self):
        gobject.GObject.__init__(self)
        self._nflakes = 0
        self._box = None

    def add(self, child, center=False):
        if not center:
            self._nflakes += 1
    def __init__(self, update_activity, bundle_pane):
        gtk.ScrolledWindow.__init__(self)
        self.update_activity = update_activity
        self.bundle_pane = bundle_pane

        # create TreeView using a filtered treestore
        self.ftreestore = self.update_activity.bundle_list.filter_new()
        if not _DEBUG_VIEW_ALL:
            self.ftreestore.set_visible_column(model.UPDATE_EXISTS)
        self.treeview = gtk.TreeView(self.ftreestore)

        # toggle cell renderers #
        crbool = gtk.CellRendererToggle()
        crbool.set_property('activatable', True)
        crbool.set_property('xpad', style.DEFAULT_PADDING)
        crbool.set_property('indicator_size', style.zoom(26))
        crbool.connect('toggled', self.toggled_cb)

        # icon cell renderers #
        cricon = gtk.CellRendererPixbuf()
        cricon.set_property('width', style.STANDARD_ICON_SIZE)
        cricon.set_property('height', style.STANDARD_ICON_SIZE)

        # text cell renderers #
        crtext = gtk.CellRendererText()
        crtext.set_property('xpad', style.DEFAULT_PADDING)
        crtext.set_property('ypad', style.DEFAULT_PADDING)

        #create the TreeViewColumn to display the data
        def view_func_maker(propname):
            def view_func(cell_layout, renderer, m, it):
                renderer.set_property(propname,
                                      not m.get_value(it, model.IS_HEADER))

            return view_func

        hide_func = view_func_maker('visible')
        insens_func = view_func_maker('sensitive')
        self.column_install = gtk.TreeViewColumn('Install', crbool)
        self.column_install.add_attribute(crbool, 'active',
                                          model.UPDATE_SELECTED)
        self.column_install.set_cell_data_func(crbool, hide_func)
        self.column = gtk.TreeViewColumn('Name')
        self.column.pack_start(cricon, expand=False)
        self.column.pack_start(crtext, expand=True)
        self.column.add_attribute(cricon, 'pixbuf', model.ICON)
        self.column.set_resizable(True)
        self.column.set_cell_data_func(cricon, hide_func)

        def markup_func(cell_layout, renderer, m, it):
            s = '<b>%s</b>' % _e(m.get_value(it, model.NAME))
            if m.get_value(it, model.IS_HEADER):
                s = '<big>%s</big>' % s
            desc = m.get_value(it, model.DESCRIPTION)
            if desc is not None and desc != '':
                s += '\n<small>%s</small>' % _e(desc)
            renderer.set_property('markup', s)
            insens_func(cell_layout, renderer, m, it)

        self.column.set_cell_data_func(crtext, markup_func)

        # add tvcolumn to treeview
        self.treeview.append_column(self.column_install)
        self.treeview.append_column(self.column)

        self.treeview.set_reorderable(False)
        self.treeview.set_enable_search(False)
        self.treeview.set_headers_visible(False)
        self.treeview.set_rules_hint(True)
        self.treeview.connect('button-press-event', self.show_context_menu)

        def is_valid_cb(activity_list, __):
            self.treeview.set_sensitive(
                self.update_activity.bundle_list.is_valid())

        self.update_activity.bundle_list.connect('notify::is-valid',
                                                 is_valid_cb)
        is_valid_cb(self.update_activity.bundle_list, None)

        self.add_with_viewport(self.treeview)
        self.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
예제 #33
0
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

import math

import gobject
import hippo

from sugar.graphics import style

_BASE_DISTANCE = style.zoom(25)
_CHILDREN_FACTOR = style.zoom(3)


class SnowflakeLayout(gobject.GObject, hippo.CanvasLayout):
    __gtype_name__ = 'SugarSnowflakeLayout'

    def __init__(self):
        gobject.GObject.__init__(self)
        self._nflakes = 0
        self._box = None

    def add(self, child, center=False):
        if not center:
            self._nflakes += 1
예제 #34
0
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

import gtk
import gobject
import pango
import gconf

from sugar.graphics import style

WHITE = gtk.gdk.Color('#FFFFFF')
BLACK = gtk.gdk.Color('#000000')

NOTE_WIDTH = style.zoom(279)
NOTE_HEIGHT = style.zoom(279)
MARGIN = style.zoom(21)
LAYOUT_WIDTH = NOTE_WIDTH - (MARGIN * 2)
BOX_SPACE = style.zoom(29)

SPACE_DEFAULT = int(gtk.gdk.screen_width() / (NOTE_WIDTH + BOX_SPACE))

ESC_KEY = 65307
TAB_KEY = 65289
SHIFT_TAB_KEY = 65056


def get_colors():
    client = gconf.client_get_default()
    colors = client.get_string('/desktop/sugar/user/color')
예제 #35
0
    def __init__(self, handle):
        """Set up the Textdungeon activity."""
        activity.Activity.__init__(self, handle)

        # we do not have collaboration features
        # make the share option insensitive
        self.max_participants = 1

        if _NEW_TOOLBAR_SUPPORT:
            # toolbar with the new toolbar redesign >= Sugar 0.88?
            toolbar_box = ToolbarBox()

            activity_button = ActivityButton(self)
            toolbar_box.toolbar.insert(activity_button, 0)
            activity_button.show()

            title_entry = TitleEntry(self)
            toolbar_box.toolbar.insert(title_entry, -1)
            title_entry.show()

            share_button = ShareButton(self)
            toolbar_box.toolbar.insert(share_button, -1)
            share_button.show()

            keep_button = KeepButton(self)
            toolbar_box.toolbar.insert(keep_button, -1)
            keep_button.show()
        
            separator = gtk.SeparatorToolItem()
            separator.props.draw = False
            separator.set_expand(True)
            toolbar_box.toolbar.insert(separator, -1)
            separator.show()

            stop_button = StopButton(self)
            toolbar_box.toolbar.insert(stop_button, -1)
            stop_button.show()

            self.set_toolbar_box(toolbar_box)
            toolbar_box.show()

        else:
            toolbox = activity.ActivityToolbox(self)
            self.set_toolbox(toolbox)
            toolbox.show()

        self.scrolled_window = gtk.ScrolledWindow()
        self.scrolled_window.set_policy(gtk.POLICY_NEVER,
            gtk.POLICY_AUTOMATIC)
        self.scrolled_window.props.shadow_type = \
            gtk.SHADOW_NONE
        self.textview = gtk.TextView()
        self.textview.set_editable(True)
        self.textview.set_cursor_visible(True)
        self.textview.set_wrap_mode(True)
        self.textview.connect("key_press_event",
            self.keypress_cb)

        self.scrolled_window.add(self.textview)
        self.set_canvas(self.scrolled_window)
        self.textview.show()
        self.scrolled_window.show()
        self.textview.grab_focus()
        self.font_desc = pango.FontDescription("sans %d" %
            style.zoom(8))
        self.textview.modify_font(self.font_desc)
#        self.stringthing=""

        self.loc =[0, 0]
        self.direction =0
        self.roomdata  =[]
        self.items=[]
        self.doors=[]
        self.inventory=[]
        self.keyboardentrystring=''
        self.filecontents=''
        self.printtobuf( 'Press h for help')
        self.printtobuf( 'Use a text editor such as the Write Activity to edit this dungeon, create new ones or reset a dungeon\n')
        self.printtobuf( 'You are in a dimly lit cavern ' + 'facing '+ compass(self.direction))
        if handle.object_id==None:
            readroomfile(self)                  #load the default room 
예제 #36
0
    def define_buttons(self):
        """ See comment in Exercies.define_buttons. """    
        self.toggle_plus = gtk.ToggleButton("+")
        self.toggle_label = self.toggle_plus.get_child()
        self.toggle_label.modify_font(pango.FontDescription("sans %d" % style.zoom(12)))
        self.toggle_plus.connect("toggled", self.toggle_plus_callback)
        self._display.settings_table.attach(self.toggle_plus, 1, 2, 10, 11 )
        self.toggle_plus.show()
        
        self.toggle_minus = gtk.ToggleButton("-")
        self.toggle_label = self.toggle_minus.get_child()
        self.toggle_label.modify_font(pango.FontDescription("sans %d" % style.zoom(12)))
        self.toggle_minus.connect("toggled", self.toggle_minus_callback)
        self._display.settings_table.attach(self.toggle_minus, 1, 2, 9, 10 )
        self.toggle_minus.show()
        
        self.label0 = gtk.Label("3")
        self.label0.modify_font(pango.FontDescription("sans 12"))
        self._display.settings_table.attach(self.label0, 2, 3, 10, 11 ) 
        self.label0.show()
        
        self.label1 = gtk.Label("=")
        self.label1.modify_font(pango.FontDescription("sans 12"))
        self._display.settings_table.attach(self.label1, 3, 4, 10, 11 ) 
        self.label1.show()
        
        self.label2 = gtk.Label("12")
        self.label2.modify_font(pango.FontDescription("sans 12"))
        self._display.settings_table.attach(self.label2, 4, 5, 10, 11 ) 
        self.label2.show()
        
        self.label3 = gtk.Label("1 + 2")
        self.label3.modify_font(pango.FontDescription("sans 12"))
        self._display.settings_table.attach(self.label3, 2, 3, 11, 12 ) 
        self.label3.show()
                
        self.label6 = gtk.Label(self._display._sett['MAX'])
        self.label6.modify_font(pango.FontDescription("sans 12"))
        self._display.settings_table.attach(self.label6, 5, 6, 1, 2 ) 
        self.label6.show()
        
        #self.label7 = gtk.Label(self._display._sess._gen.count((self._display._key, self._display._sett)))
        #self.label7.modify_font(pango.FontDescription("sans 12"))
        #self._display.settings_table.attach(self.label7, 5, 6, 2, 3 ) 
        #self.label7.show()
        
        self.toggle_newline = gtk.ToggleButton("<")
        self.toggle_label = self.toggle_newline.get_child()
        self.toggle_label.modify_font(pango.FontDescription("sans %d" % style.zoom(12)))
        self.toggle_newline.connect("toggled", self.toggle_newline_callback)
        self._display.settings_table.attach(self.toggle_newline, 5, 6, 11, 12)
        self.toggle_newline.show()
        
        self.toggle_shuffle_all = gtk.ToggleButton("@")
        self.toggle_shuffle_all_label = self.toggle_shuffle_all.get_child()
        self.toggle_shuffle_all_label.modify_font(pango.FontDescription("sans %d" % style.zoom(12)))
        self.toggle_shuffle_all.connect("toggled", self.toggle_shuffle_all_callback)
        self._display.settings_table.attach(self.toggle_shuffle_all, 0, 1, 13, 14 )
        self.toggle_shuffle_all.show()
        
        self.toggle_shuffle_inner = gtk.ToggleButton("@")
        self.toggle_shuffle_inner_label = self.toggle_shuffle_inner.get_child()
        self.toggle_shuffle_inner_label.modify_font(pango.FontDescription("sans %d" % style.zoom(12)))
        self.toggle_shuffle_inner.connect("toggled", self.toggle_shuffle_inner_callback)
        self._display.settings_table.attach(self.toggle_shuffle_inner, 2, 3, 13, 14 )
        self.toggle_shuffle_inner.show()
        
        self.toggle_pos3 = gtk.ToggleButton("--")
        self.toggle_label = self.toggle_pos3.get_child()
        self.toggle_label.modify_font(pango.FontDescription("sans %d" % style.zoom(12)))
        self.toggle_pos3.connect("toggled", self.toggle_pos3_callback)
        self._display.settings_table.attach(self.toggle_pos3, 2, 3, 12, 13 )
        self.toggle_pos3.show()
        
        self.toggle_pos5 = gtk.ToggleButton("--")
        self.toggle_label = self.toggle_pos5.get_child()
        self.toggle_label.modify_font(pango.FontDescription("sans %d" % style.zoom(12)))
        self.toggle_pos5.connect("toggled", self.toggle_pos5_callback)
        self._display.settings_table.attach(self.toggle_pos5, 4, 5, 12, 13 )
        self.toggle_pos5.show()
        
        self.number_butts = []

        for i in range(1,9+1):
            self.toggle = gtk.ToggleButton(str(i))
            self.toggle_label = self.toggle.get_child()
            self.toggle_label.modify_font(pango.FontDescription("sans %d" % style.zoom(12)))            
            self.toggle.connect("toggled", self.toggle_number_callback, i) 
            self._display.settings_table.attach(self.toggle, 0, 1, 1+i, 2+i)
            self.toggle.show()
            self.number_butts.append(self.toggle)
예제 #37
0
class ActivityIcon(CanvasIcon):
    __gtype_name__ = 'SugarFavoriteActivityIcon'

    _BORDER_WIDTH = style.zoom(3)
    _MAX_RESUME_ENTRIES = 5

    def __init__(self, activity_info):
        CanvasIcon.__init__(self, cache=True,
                            file_name=activity_info.get_icon())

        self._activity_info = activity_info
        self._journal_entries = []
        self._hovering = False
        self._resume_mode = True

        self.connect('hovering-changed', self.__hovering_changed_event_cb)
        self.connect('button-release-event', self.__button_release_event_cb)

        datastore.updated.connect(self.__datastore_listener_updated_cb)
        datastore.deleted.connect(self.__datastore_listener_deleted_cb)

        self._refresh()
        self._update()

    def _refresh(self):
        bundle_id = self._activity_info.get_bundle_id()
        properties = ['uid', 'title', 'icon-color', 'activity', 'activity_id',
                      'mime_type', 'mountpoint']
        self._get_last_activity_async(bundle_id, properties)

    def __datastore_listener_updated_cb(self, **kwargs):
        bundle_id = self._activity_info.get_bundle_id()
        if kwargs['metadata'].get('activity', '') == bundle_id:
            self._refresh()

    def __datastore_listener_deleted_cb(self, **kwargs):
        for entry in self._journal_entries:
            if entry['uid'] == kwargs['object_id']:
                self._refresh()
                break

    def _get_last_activity_async(self, bundle_id, properties):
        query = {'activity': bundle_id}
        datastore.find(query, sorting=['+timestamp'],
                       limit=self._MAX_RESUME_ENTRIES,
                       properties=properties,
                       reply_handler=self.__get_last_activity_reply_handler_cb,
                       error_handler=self.__get_last_activity_error_handler_cb)

    def __get_last_activity_reply_handler_cb(self, entries, total_count):
        # If there's a problem with the DS index, we may get entries not
        # related to this activity.
        checked_entries = []
        for entry in entries:
            if entry['activity'] == self.bundle_id:
                checked_entries.append(entry)

        self._journal_entries = checked_entries
        self._update()

    def __get_last_activity_error_handler_cb(self, error):
        logging.error('Error retrieving most recent activities: %r', error)

    def _update(self):
        self.palette = None
        if not self._resume_mode or not self._journal_entries:
            xo_color = XoColor('%s,%s' % (style.COLOR_BUTTON_GREY.get_svg(),
                                          style.COLOR_TRANSPARENT.get_svg()))
        else:
            xo_color = misc.get_icon_color(self._journal_entries[0])
        self.props.xo_color = xo_color

    def create_palette(self):
        palette = FavoritePalette(self._activity_info, self._journal_entries)
        palette.connect('activate', self.__palette_activate_cb)
        palette.connect('entry-activate', self.__palette_entry_activate_cb)
        return palette

    def __palette_activate_cb(self, palette):
        self._activate()

    def __palette_entry_activate_cb(self, palette, metadata):
        self._resume(metadata)

    def __hovering_changed_event_cb(self, icon, hovering):
        self._hovering = hovering
        self.emit_paint_needed(0, 0, -1, -1)

    def do_paint_above_children(self, cr, damaged_box):
        if not self._hovering:
            return

        width, height = self.get_allocation()

        x = ActivityIcon._BORDER_WIDTH / 2.0
        y = ActivityIcon._BORDER_WIDTH / 2.0
        width -= ActivityIcon._BORDER_WIDTH
        height -= ActivityIcon._BORDER_WIDTH
        radius = width / 10.0

        cr.move_to(x + radius, y)
        cr.arc(x + width - radius, y + radius, radius, math.pi * 1.5,
               math.pi * 2.0)
        cr.arc(x + width - radius, x + height - radius, radius, 0,
               math.pi * 0.5)
        cr.arc(x + radius, y + height - radius, radius, math.pi * 0.5, math.pi)
        cr.arc(x + radius, y + radius, radius, math.pi, math.pi * 1.5)

        color = style.COLOR_SELECTION_GREY.get_int()
        hippo.cairo_set_source_rgba32(cr, color)
        cr.set_line_width(ActivityIcon._BORDER_WIDTH)
        cr.stroke()

    def do_get_content_height_request(self, for_width):
        height, height = CanvasIcon.do_get_content_height_request(self,
                                                                  for_width)
        height += ActivityIcon._BORDER_WIDTH * 2
        return height, height

    def do_get_content_width_request(self):
        width, width = CanvasIcon.do_get_content_width_request(self)
        width += ActivityIcon._BORDER_WIDTH * 2
        return width, width

    def __button_release_event_cb(self, icon, event):
        self._activate()

    def _resume(self, journal_entry):
        if not journal_entry['activity_id']:
            journal_entry['activity_id'] = activityfactory.create_activity_id()
        misc.resume(journal_entry, self._activity_info.get_bundle_id())

    def _activate(self):
        if self.palette is not None:
            self.palette.popdown(immediate=True)

        if self._resume_mode and self._journal_entries:
            self._resume(self._journal_entries[0])
        else:
            misc.launch(self._activity_info)

    def get_bundle_id(self):
        return self._activity_info.get_bundle_id()
    bundle_id = property(get_bundle_id, None)

    def get_version(self):
        return self._activity_info.get_activity_version()
    version = property(get_version, None)

    def get_activity_name(self):
        return self._activity_info.get_name()

    def _get_installation_time(self):
        return self._activity_info.get_installation_time()
    installation_time = property(_get_installation_time, None)

    def _get_fixed_position(self):
        registry = bundleregistry.get_registry()
        return registry.get_bundle_position(self.bundle_id, self.version)
    fixed_position = property(_get_fixed_position, None)

    def set_resume_mode(self, resume_mode):
        self._resume_mode = resume_mode
        self._update()
예제 #38
0
 def __add_cb(self, child, params):
     child.set_border_width(style.zoom(5))
예제 #39
0
파일: theme.py 프로젝트: Daksh/joke-machine
COLOR_LIST_BORDER     = COLOR_TOOLBAR_GREY
COLOR_LIST_ROW        = COLOR_TEXT_FIELD_GREY
COLOR_LIST_ROW_ALT    = COLOR_GRAY
COLOR_TEXTBOX         = COLOR_PAGE
COLOR_LINK            = COLOR_BLUE
COLOR_TAB_ACTIVE      = COLOR_DARK_GREEN
COLOR_TAB_INACTIVE    = COLOR_LIGHT_GREEN
COLOR_TAB_SEPERATOR   = COLOR_LIGHT_GRAY
COLOR_TAB_TEXT        = COLOR_WHITE


# constants ####################################################################

zoom = style.zoom

PADDING_TAB = style.zoom(6)
DEFAULT_PADDING = style.zoom(6)
DEFAULT_SPACING = style.zoom(8)
BORDER_WIDTH = style.zoom(6) 
BORDER_WIDTH_CONTROL = style.zoom(12) 
BORDER_WIDTH_IMAGE = style.zoom(1)
SPACER_VERTICAL = style.zoom(20)
SPACER_HORIZONTAL = style.zoom(20)

# images #######################################################################

IMAGE_CHOOSE = 'resources/image.png'
AUDIO_CHOOSE = 'resources/audio.png'


# helpers ######################################################################
예제 #40
0
    def __init__(self, start_window=True):
        super(gtk.VBox, self).__init__()
        self.using_powerd = self._verify_powerd_directory()
        self._inhibit_suspend()

        self.image = gtk.Image()
        self.pack_start(self.image, True, True, padding=0)

        # images management
        images_path = \
                os.path.expanduser('~/Activities/Welcome.activity/images/')

        self.anim_order = 0
        self.image_order = 0
        self.auto_change_anim = True
        self.animation_list = []
        for fname in sorted(os.listdir(images_path)):
            if os.path.isdir(images_path + fname):
                anim_path = images_path + fname
                logging.debug('Animation dir file: %s', anim_path)
                animation_images_list = []
                for imagefname in sorted(os.listdir(anim_path)):
                    image_path = os.path.join(anim_path, imagefname)
                    animation_images_list.append(image_path)
                    logging.debug('Image file: %s', image_path)
                self.animation_list.append(animation_images_list)
            else:
                self.animation_list.append([images_path + fname])

        if self.animation_list:
            self._update_image()

        if start_window:
            # Create bottom controls
            bottom_toolbar = gtk.HBox()
            self.pack_start(bottom_toolbar, False, padding=style.zoom(30))

            left_box = gtk.HBox()
            bottom_toolbar.pack_start(left_box, False, padding=0)

            center_align = gtk.Alignment(0.5, 0, 0, 0)
            center_box = gtk.HBox()
            center_align.add(center_box)
            bottom_toolbar.pack_start(center_align, True, True, padding=0)

            right_box = gtk.HBox()
            bottom_toolbar.pack_start(right_box, False, padding=0)

            # init gettext
            locale_path = \
                    os.path.expanduser('~/Activities/Welcome.activity/locale/')
            gettext.bindtextdomain('org.laptop.WelcomeActivity', locale_path)
            gettext.textdomain('org.laptop.WelcomeActivity')
            _ = gettext.gettext

            _next_button = gtk.Button()
            _next_button.set_label(_('Next'))
            next_image = Icon(icon_name='go-right')
            _next_button.set_image(next_image)
            _next_button.connect('clicked', self.__next_clicked_cb)

            self.sequence_view = SequenceView(len(self.animation_list))

            right_box.pack_end(_next_button, False, False,
                    padding=style.zoom(30))
            bt_width, bt_height = _next_button.size_request()

            prev_bt = CustomButton('go-previous-paired-grey', bt_height)
            center_box.pack_start(prev_bt, False, False, 5)
            prev_bt.connect('button-press-event', self.prev_anim_clicked_cb)

            center_box.pack_start(self.sequence_view, False, False, padding=5)

            next_bt = CustomButton('go-next-paired-grey', bt_height)
            center_box.pack_start(next_bt, False, False, 5)
            next_bt.connect('button-press-event', self.next_anim_clicked_cb)

            # do the right_box and left_box have the same size
            width = int(gtk.gdk.screen_width() / 4)
            right_box.set_size_request(width, -1)
            left_box.set_size_request(width, -1)

        else:
            center_align = gtk.Alignment(0.5, 0, 0, 0)
            self.pack_start(center_align, False, padding=2)
            self.sequence_view = SequenceView(len(self.animation_list))
            center_align.add(self.sequence_view)

        self.show_all()

        # calculate space available for images
        #   (only to tell to the designers)
        height_av = gtk.gdk.screen_height() - style.GRID_CELL_SIZE * 2
        width_av = gtk.gdk.screen_width()
        print 'Size available for image: %d x %d' % (width_av, height_av)
예제 #41
0
    def define_buttons(self):
        self.toggle_shuffle = gtk.ToggleButton("@")
        self.toggle_label = self.toggle_shuffle.get_child()
        self.toggle_label.modify_font(pango.FontDescription("sans %d" % style.zoom(12)))
        self.toggle_shuffle.connect("toggled", self.toggle_shuffle_callback)
        self._display.settings_table.attach(self.toggle_shuffle, 5, 6, 13, 14 )
        self.toggle_shuffle.show()

        self.toggle_equal_fixed_right = gtk.ToggleButton("<<")
        self.toggle_label = self.toggle_equal_fixed_right.get_child()
        self.toggle_label.modify_font(pango.FontDescription("sans %d" % style.zoom(12)))
        self.toggle_equal_fixed_right.connect("toggled", self.toggle_equal_fixed_right_callback)
        self._display.settings_table.attach(self.toggle_equal_fixed_right, 5, 6, 10, 11 )
        self.toggle_equal_fixed_right.show()

        self.toggle_equal_fixed_left = gtk.ToggleButton("<<")
        self.toggle_label = self.toggle_equal_fixed_left.get_child()
        self.toggle_label.modify_font(pango.FontDescription("sans %d" % style.zoom(12)))
        self.toggle_equal_fixed_left.connect("toggled", self.toggle_equal_fixed_left_callback)
        self._display.settings_table.attach(self.toggle_equal_fixed_left, 5, 6, 12, 13 )
        self.toggle_equal_fixed_left.show()

        self.toggle_pos1 = gtk.ToggleButton("--")
        self.toggle_label = self.toggle_pos1.get_child()
        self.toggle_label.modify_font(pango.FontDescription("sans %d" % style.zoom(12)))
        self.toggle_pos1.connect("toggled", self.toggle_pos1_callback)
        self._display.settings_table.attach(self.toggle_pos1, 0, 1, 11, 12 )
        self.toggle_pos1.show()

        self.toggle_pos3 = gtk.ToggleButton("--")
        self.toggle_label = self.toggle_pos3.get_child()
        self.toggle_label.modify_font(pango.FontDescription("sans %d" % style.zoom(12)))
        self.toggle_pos3.connect("toggled", self.toggle_pos3_callback)
        self._display.settings_table.attach(self.toggle_pos3, 2, 3, 11, 12 )
        self.toggle_pos3.show()

        self.toggle_pos5 = gtk.ToggleButton("--")
        self.toggle_label = self.toggle_pos5.get_child()
        self.toggle_label.modify_font(pango.FontDescription("sans %d" % style.zoom(12)))
        self.toggle_pos5.connect("toggled", self.toggle_pos5_callback)
        self._display.settings_table.attach(self.toggle_pos5, 4, 5, 11, 12 )
        self.toggle_pos5.show()

        self.toggle_pos1_lower = gtk.ToggleButton("--")
        self.toggle_label = self.toggle_pos1_lower.get_child()
        self.toggle_label.modify_font(pango.FontDescription("sans %d" % style.zoom(12)))
        self.toggle_pos1_lower.connect("toggled", self.toggle_pos1_lower_callback)
        self._display.settings_table.attach(self.toggle_pos1_lower, 0, 1, 13, 14 )
        self.toggle_pos1_lower.show()

        self.toggle_pos3_lower = gtk.ToggleButton("--")
        self.toggle_label = self.toggle_pos3_lower.get_child()
        self.toggle_label.modify_font(pango.FontDescription("sans %d" % style.zoom(12)))
        self.toggle_pos3_lower.connect("toggled", self.toggle_pos3_lower_callback)
        self._display.settings_table.attach(self.toggle_pos3_lower, 2, 3, 13, 14 )
        self.toggle_pos3_lower.show()

        self.toggle_pos5_lower = gtk.ToggleButton("--")
        self.toggle_label = self.toggle_pos5_lower.get_child()
        self.toggle_label.modify_font(pango.FontDescription("sans %d" % style.zoom(12)))
        self.toggle_pos5_lower.connect("toggled", self.toggle_pos5_lower_callback)
        self._display.settings_table.attach(self.toggle_pos5_lower, 4, 5, 13, 14 )
        self.toggle_pos5_lower.show()

        self.label0 = gtk.Label("0")
        self.label0.modify_font(pango.FontDescription("sans 12"))
        self._display.settings_table.attach(self.label0, 0, 1, 10, 11 )
        self.label0.show()

        self.toggle_plus = gtk.ToggleButton("+")
        self.toggle_label = self.toggle_plus.get_child()
        self.toggle_label.modify_font(pango.FontDescription("sans %d" % style.zoom(12)))
        self.toggle_plus.connect("toggled", self.toggle_plus_callback)
        self._display.settings_table.attach(self.toggle_plus, 1, 2, 10, 11 )
        self.toggle_plus.show()

        self.toggle_minus = gtk.ToggleButton("-")
        self.toggle_label = self.toggle_minus.get_child()
        self.toggle_label.modify_font(pango.FontDescription("sans %d" % style.zoom(12)))
        self.toggle_minus.connect("toggled", self.toggle_minus_callback)
        self._display.settings_table.attach(self.toggle_minus, 1, 2, 9, 10 )
        self.toggle_minus.show()

        self.label02 = gtk.Label("0")
        self.label02.modify_font(pango.FontDescription("sans 12"))
        self._display.settings_table.attach(self.label02, 2, 3, 10, 11 )
        self.label02.show()

        self.label_equal = gtk.Label("=")
        self.label_equal.modify_font(pango.FontDescription("sans 12"))
        self._display.settings_table.attach(self.label_equal, 3, 4, 10, 11 )
        self.label_equal.show()

        self.label0_lower = gtk.Label("0")
        self.label0_lower.modify_font(pango.FontDescription("sans 12"))
        self._display.settings_table.attach(self.label0_lower, 0, 1, 12, 13 )
        self.label0_lower.show()

        self.label_equal_lower = gtk.Label("=")
        self.label_equal_lower.modify_font(pango.FontDescription("sans 12"))
        self._display.settings_table.attach(self.label_equal_lower, 1, 2, 12, 13 )
        self.label_equal_lower.show()

        self.label02_lower = gtk.Label("0")
        self.label02_lower.modify_font(pango.FontDescription("sans 12"))
        self._display.settings_table.attach(self.label02_lower, 2, 3, 12, 13 )
        self.label02_lower.show()

        self.label_plus_minus_lower = gtk.Label("+")
        self.label_plus_minus_lower.modify_font(pango.FontDescription("sans 12"))
        self._display.settings_table.attach(self.label_plus_minus_lower, 3, 4, 12, 13 )
        self.label_plus_minus_lower.show()

        self.label03_lower = gtk.Label("0")
        self.label03_lower.modify_font(pango.FontDescription("sans 12"))
        self._display.settings_table.attach(self.label03_lower, 4, 5, 12, 13 )
        self.label03_lower.show()

        # Buttons 9 .. 0
        self.number_butts = []
        for i in range(0,9+1):
            self.toggle = gtk.ToggleButton(str(i))
            self.toggle_label = self.toggle.get_child()
            self.toggle_label.modify_font(pango.FontDescription("sans %d" % style.zoom(12)))
            self.toggle.connect("toggled", self.toggle_number_callback, i)
            self._display.settings_table.attach(self.toggle, 4, 5, 10-i, 11-i)
            self.toggle.show()
            self.number_butts.append(self.toggle)
예제 #42
0
 def __init__(self, radius=style.zoom(10), **kwargs):
     hippo.CanvasBox.__init__(self, **kwargs)
     self.set_radius(radius)
예제 #43
0
 def __add_cb(self, child, params):
     child.set_border_width(style.zoom(5))
예제 #44
0
 def get_depiction(self):
     if self.pixbuf == None:
         file_name = os.path.join(self.activity_root, 'data', self.get_metadata('hasDepiction')[0])
         self.pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(file_name, style.zoom(160), style.zoom(120))
     return self.pixbuf
    def __init__(self, handle):
        "The entry point to the Activity"
        global page
        activity.Activity.__init__(self, handle)
        
        toolbox = activity.ActivityToolbox(self)
        activity_toolbar = toolbox.get_activity_toolbar()
        activity_toolbar.keep.props.visible = False
        activity_toolbar.share.props.visible = False

        self.edit_toolbar = activity.EditToolbar()
        self.edit_toolbar.undo.props.visible = False
        self.edit_toolbar.redo.props.visible = False
        self.edit_toolbar.separator.props.visible = False
        self.edit_toolbar.copy.set_sensitive(False)
        self.edit_toolbar.copy.connect('clicked', self.edit_toolbar_copy_cb)
        self.edit_toolbar.paste.props.visible = False
        toolbox.add_toolbar(_('Edit'), self.edit_toolbar)
        self.edit_toolbar.show()
        
        self.read_toolbar = ReadToolbar()
        toolbox.add_toolbar(_('Read'), self.read_toolbar)
        self.read_toolbar.back.connect('clicked', self.go_back_cb)
        self.read_toolbar.forward.connect('clicked', self.go_forward_cb)
        self.read_toolbar.num_page_entry.connect('activate',
                                     self.num_page_entry_activate_cb)
        self.read_toolbar.show()

        self.view_toolbar = ViewToolbar()
        toolbox.add_toolbar(_('View'), self.view_toolbar)
        self.view_toolbar.connect('go-fullscreen',
                self.view_toolbar_go_fullscreen_cb)
        self.view_toolbar.zoom_in.connect('clicked', self.zoom_in_cb)
        self.view_toolbar.zoom_out.connect('clicked', self.zoom_out_cb)
        self.view_toolbar.show()

        self.set_toolbox(toolbox)
        toolbox.show()
        self.scrolled_window = gtk.ScrolledWindow()
        self.scrolled_window.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
        self.scrolled_window.props.shadow_type = gtk.SHADOW_NONE

        self.textview = gtk.TextView()
        self.textview.set_editable(False)
        self.textview.set_cursor_visible(False)
        self.textview.set_left_margin(50)
        self.textview.connect("key_press_event", self.keypress_cb)

        self.scrolled_window.add(self.textview)
        self.set_canvas(self.scrolled_window)
        self.textview.show()
        self.scrolled_window.show()
        page = 0
        self.clipboard = gtk.Clipboard(display=gtk.gdk.display_get_default(), \
                                       selection="CLIPBOARD")
        self.textview.grab_focus()
        self.font_desc = pango.FontDescription("sans %d" % style.zoom(10))
        self.textview.modify_font(self.font_desc)

        buffer = self.textview.get_buffer()
        self.markset_id = buffer.connect("mark-set", self.mark_set_cb)
        self.toolbox.set_current_toolbar(TOOLBAR_READ)
예제 #46
0
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

import gtk
import gobject
import pango
import gconf

from sugar.graphics import style

WHITE = gtk.gdk.Color('#FFFFFF')
BLACK = gtk.gdk.Color('#000000')

NOTE_WIDTH = style.zoom(279)
NOTE_HEIGHT = style.zoom(279)
MARGIN = style.zoom(21)
LAYOUT_WIDTH = NOTE_WIDTH - (MARGIN * 2)
BOX_SPACE = style.zoom(29)

SPACE_DEFAULT = int(gtk.gdk.screen_width() / (NOTE_WIDTH + BOX_SPACE))

ESC_KEY = 65307
TAB_KEY = 65289
SHIFT_TAB_KEY = 65056


def get_colors():
    client = gconf.client_get_default()
    colors = client.get_string('/desktop/sugar/user/color')
 def show_image(self, filename):
     "display a resized image in a preview"
     scaled_buf = gtk.gdk.pixbuf_new_from_file_at_size(filename, 
                                                       style.zoom(300), style.zoom(225))
     self.image.set_from_pixbuf(scaled_buf)
     self.image.show()
예제 #48
0
파일: activity.py 프로젝트: cemeiq/Primero
    def __init__(self, start_window=True):
        super(gtk.VBox, self).__init__()
        self.using_powerd = self._verify_powerd_directory()
        self._inhibit_suspend()

        self.image = gtk.Image()
        self.pack_start(self.image, True, True, padding=0)

        # images management
        images_path = \
                os.path.expanduser('~/Activities/Welcome.activity/images/')

        self.anim_order = 0
        self.image_order = 0
        self.auto_change_anim = True
        self.animation_list = []
        for fname in sorted(os.listdir(images_path)):
            if os.path.isdir(images_path + fname):
                anim_path = images_path + fname
                logging.debug('Animation dir file: %s', anim_path)
                animation_images_list = []
                for imagefname in sorted(os.listdir(anim_path)):
                    image_path = os.path.join(anim_path, imagefname)
                    animation_images_list.append(image_path)
                    logging.debug('Image file: %s', image_path)
                self.animation_list.append(animation_images_list)
            else:
                self.animation_list.append([images_path + fname])

        if self.animation_list:
            self._update_image()

        if start_window:
            # Create bottom controls
            bottom_toolbar = gtk.HBox()
            self.pack_start(bottom_toolbar, False, padding=style.zoom(30))

            left_box = gtk.HBox()
            bottom_toolbar.pack_start(left_box, False, padding=0)

            center_align = gtk.Alignment(0.5, 0, 0, 0)
            center_box = gtk.HBox()
            center_align.add(center_box)
            bottom_toolbar.pack_start(center_align, True, True, padding=0)

            right_box = gtk.HBox()
            bottom_toolbar.pack_start(right_box, False, padding=0)

            # init gettext
            locale_path = \
                    os.path.expanduser('~/Activities/Welcome.activity/locale/')
            gettext.bindtextdomain('org.laptop.WelcomeActivity', locale_path)
            gettext.textdomain('org.laptop.WelcomeActivity')
            _ = gettext.gettext

            _next_button = gtk.Button()
            _next_button.set_label(_('Next'))
            next_image = Icon(icon_name='go-right')
            _next_button.set_image(next_image)
            _next_button.connect('clicked', self.__next_clicked_cb)

            self.sequence_view = SequenceView(len(self.animation_list))

            right_box.pack_end(_next_button,
                               False,
                               False,
                               padding=style.zoom(30))
            bt_width, bt_height = _next_button.size_request()

            prev_bt = CustomButton('go-previous-paired-grey', bt_height)
            center_box.pack_start(prev_bt, False, False, 5)
            prev_bt.connect('button-press-event', self.prev_anim_clicked_cb)

            center_box.pack_start(self.sequence_view, False, False, padding=5)

            next_bt = CustomButton('go-next-paired-grey', bt_height)
            center_box.pack_start(next_bt, False, False, 5)
            next_bt.connect('button-press-event', self.next_anim_clicked_cb)

            # do the right_box and left_box have the same size
            width = int(gtk.gdk.screen_width() / 4)
            right_box.set_size_request(width, -1)
            left_box.set_size_request(width, -1)

        else:
            center_align = gtk.Alignment(0.5, 0, 0, 0)
            self.pack_start(center_align, False, padding=2)
            self.sequence_view = SequenceView(len(self.animation_list))
            center_align.add(self.sequence_view)

        self.show_all()

        # calculate space available for images
        #   (only to tell to the designers)
        height_av = gtk.gdk.screen_height() - style.GRID_CELL_SIZE * 2
        width_av = gtk.gdk.screen_width()
        print 'Size available for image: %d x %d' % (width_av, height_av)
예제 #49
0
    def define_buttons(self):
        """buttons for this setting, which is specific for TimesDiv"""
        self.label = gtk.Label("2")
        self.label.modify_font(pango.FontDescription("sans 12"))
        self._display.settings_table.attach(self.label, 0, 1, 13, 14 ) 
        self.label.show()
        
        self.label = gtk.Label("in")
        self.label.modify_font(pango.FontDescription("sans 12"))
        self._display.settings_table.attach(self.label, 1, 2, 13, 14 ) 
        self.label.show()
        
        self.label = gtk.Label("2")
        self.label.modify_font(pango.FontDescription("sans 12"))
        self._display.settings_table.attach(self.label, 2, 3, 13, 14 ) 
        self.label.show()
        
        self.label = gtk.Label("=")
        self.label.modify_font(pango.FontDescription("sans 12"))
        self._display.settings_table.attach(self.label, 3, 4, 13, 14 ) 
        self.label.show()
        
        self.label = gtk.Label("1")
        self.label.modify_font(pango.FontDescription("sans 12"))
        self._display.settings_table.attach(self.label, 4, 5, 13, 14 ) 
        self.label.show()
        
        self.label = gtk.Label("|")
        self.label.modify_font(pango.FontDescription("sans 12"))
        self._display.settings_table.attach(self.label, 5, 6, 13, 14 ) 
        self.label.show()
        
        self._display.settings_table.resize(15, 8)
        
        self.label = gtk.Label("0")
        self.label.modify_font(pango.FontDescription("sans 12"))
        self._display.settings_table.attach(self.label, 6, 7, 13, 14 ) 
        self.label.show()
        
        self.label = gtk.Label("2")
        self.label.modify_font(pango.FontDescription("sans 12"))
        self._display.settings_table.attach(self.label, 0, 1, 12, 13 ) 
        self.label.show()
        
        self.label = gtk.Label(":")
        self.label.modify_font(pango.FontDescription("sans 12"))
        self._display.settings_table.attach(self.label, 1, 2, 12, 13 ) 
        self.label.show()
        
        self.label = gtk.Label("2")
        self.label.modify_font(pango.FontDescription("sans 12"))
        self._display.settings_table.attach(self.label, 2, 3, 12, 13 ) 
        self.label.show()
        
        self.label = gtk.Label("=")
        self.label.modify_font(pango.FontDescription("sans 12"))
        self._display.settings_table.attach(self.label, 3, 4, 12, 13 ) 
        self.label.show()
        
        self.label = gtk.Label("1")
        self.label.modify_font(pango.FontDescription("sans 12"))
        self._display.settings_table.attach(self.label, 4, 5, 12, 13 ) 
        self.label.show()
        
        self.label = gtk.Label("|")
        self.label.modify_font(pango.FontDescription("sans 12"))
        self._display.settings_table.attach(self.label, 5, 6, 12, 13 ) 
        self.label.show()
        
        self.label = gtk.Label("0")
        self.label.modify_font(pango.FontDescription("sans 12"))
        self._display.settings_table.attach(self.label, 6, 7, 12, 13 ) 
        self.label.show()
        
        self.label = gtk.Label("1")
        self.label.modify_font(pango.FontDescription("sans 12"))
        self._display.settings_table.attach(self.label, 0, 1, 9, 10 ) 
        self.label.show()
        
        self.label = gtk.Label("*")
        self.label.modify_font(pango.FontDescription("sans 12"))
        self._display.settings_table.attach(self.label, 1, 2, 9, 10 ) 
        self.label.show()
        
        self.label = gtk.Label("=")
        self.label.modify_font(pango.FontDescription("sans 12"))
        self._display.settings_table.attach(self.label, 3, 4, 9, 10 ) 
        self.label.show()
        
        self.label = gtk.Label("2")
        self.label.modify_font(pango.FontDescription("sans 12"))
        self._display.settings_table.attach(self.label, 4, 5, 9, 10 ) 
        self.label.show()
        
        self.toggle_shuffle_all = gtk.ToggleButton("@")
        self.toggle_shuffle_all_label = self.toggle_shuffle_all.get_child()
        self.toggle_shuffle_all_label.modify_font(pango.FontDescription("sans %d" % style.zoom(12)))
        self.toggle_shuffle_all.connect("toggled", self.toggle_shuffle_all_callback)
        self._display.settings_table.attach(self.toggle_shuffle_all, 2, 3, 11, 12 )
        self.toggle_shuffle_all.show()
        
        self.toggle_shuffle_inner = gtk.ToggleButton("@")
        self.toggle_shuffle_inner_label = self.toggle_shuffle_inner.get_child()
        self.toggle_shuffle_inner_label.modify_font(pango.FontDescription("sans %d" % style.zoom(12)))
        self.toggle_shuffle_inner.connect("toggled", self.toggle_shuffle_inner_callback)
        self._display.settings_table.attach(self.toggle_shuffle_inner, 0, 1, 11, 12 )
        self.toggle_shuffle_inner.show()
        
        self.toggle_remainder = gtk.ToggleButton("V")
        self.toggle_remainder_label = self.toggle_remainder.get_child()
        self.toggle_remainder_label.modify_font(pango.FontDescription("sans %d" % style.zoom(12)))
        self.toggle_remainder.connect("toggled", self.toggle_remainder_callback)
        self._display.settings_table.attach(self.toggle_remainder, 5, 7, 11, 12 )
        self.toggle_remainder.show()
        
        self.label = gtk.Label("< - >")
        self.label.modify_font(pango.FontDescription("sans 12"))
        self._display.settings_table.attach(self.label, 0, 3, 10, 11) 
        self.label.show()
        
        self.toggle_times = gtk.ToggleButton("<")
        self.toggle_times_label = self.toggle_times.get_child()
        self.toggle_times_label.modify_font(pango.FontDescription("sans %d" % style.zoom(12)))
        self.toggle_times.connect("toggled", self.toggle_times_callback)
        self._display.settings_table.attach(self.toggle_times, 7, 8, 9, 10 )
        self.toggle_times.show()
                
        self.toggle_commute = gtk.ToggleButton("<")
        self.toggle_commute_label = self.toggle_commute.get_child()
        self.toggle_commute_label.modify_font(pango.FontDescription("sans %d" % style.zoom(12)))
        self.toggle_commute.connect("toggled", self.toggle_commute_callback)
        self._display.settings_table.attach(self.toggle_commute, 7, 8, 10, 11 )
        self.toggle_commute.show()
        
        self.toggle_div = gtk.ToggleButton("<")
        self.toggle_div_label = self.toggle_div.get_child()
        self.toggle_div_label.modify_font(pango.FontDescription("sans %d" % style.zoom(12)))
        self.toggle_div.connect("toggled", self.toggle_div_callback)
        self._display.settings_table.attach(self.toggle_div, 7, 8, 12, 13 )
        self.toggle_div.show()
        
        self.toggle_in = gtk.ToggleButton("<")
        self.toggle_in_label = self.toggle_in.get_child()
        self.toggle_in_label.modify_font(pango.FontDescription("sans %d" % style.zoom(12)))
        self.toggle_in.connect("toggled", self.toggle_in_callback)
        self._display.settings_table.attach(self.toggle_in, 7, 8, 13, 14 )
        self.toggle_in.show()
        
        self.number_butts = []

        for i in range(2 ,9 + 1):
            self.toggle = gtk.ToggleButton(str(i))
            self.toggle_label = self.toggle.get_child()
            self.toggle_label.modify_font(pango.FontDescription("sans %d" % style.zoom(12)))          
            self.toggle.connect("toggled", self.toggle_number_callback, i) 
            self._display.settings_table.attach(self.toggle, 2, 3, 11-i, 12-i)
            self.toggle.show()
            self.number_butts.append(self.toggle)