예제 #1
0
    def __init__(self, file_name, document_path, title, bundle=False):
        RadioToolButton.__init__(self)

        self._document_path = document_path
        self._title = title
        self._jobject = None

        self.props.tooltip = _('Instance Source')

        client = gconf.client_get_default()
        self._color = client.get_string('/desktop/sugar/user/color')
        icon = Icon(file=file_name,
                    icon_size=gtk.ICON_SIZE_LARGE_TOOLBAR,
                    xo_color=XoColor(self._color))
        self.set_icon_widget(icon)
        icon.show()

        if bundle:
            menu_item = MenuItem(_('Duplicate'))
            icon = Icon(icon_name='edit-duplicate',
                        icon_size=gtk.ICON_SIZE_MENU,
                        xo_color=XoColor(self._color))
            menu_item.connect('activate', self.__copy_to_home_cb)
        else:
            menu_item = MenuItem(_('Keep'))
            icon = Icon(icon_name='document-save',
                        icon_size=gtk.ICON_SIZE_MENU,
                        xo_color=XoColor(self._color))
            menu_item.connect('activate', self.__keep_in_journal_cb)

        menu_item.set_image(icon)

        self.props.palette.menu.append(menu_item)
        menu_item.show()
예제 #2
0
    def __init__(self, channel):
        CanvasPulsingIcon.__init__(self,
                                   icon_name=self._ICON_NAME + str(channel),
                                   size=style.STANDARD_ICON_SIZE, cache=True)
        self._bus = dbus.SystemBus()
        self._channel = channel
        self._disconnect_item = None
        self._connect_item = None
        self._palette_icon = None
        self._filtered = False

        get_adhoc_manager_instance().connect('members-changed',
                                             self.__members_changed_cb)
        get_adhoc_manager_instance().connect('state-changed',
                                             self.__state_changed_cb)

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

        pulse_color = XoColor('%s,%s' % (style.COLOR_BUTTON_GREY.get_svg(),
                                         style.COLOR_TRANSPARENT.get_svg()))
        self.props.pulse_color = pulse_color
        self._state_color = XoColor('%s,%s' % \
                                       (profile.get_color().get_stroke_color(),
                                        style.COLOR_TRANSPARENT.get_svg()))
        self.props.base_color = self._state_color
        self._palette = self._create_palette()
        self.set_palette(self._palette)
        self._palette_icon.props.xo_color = self._state_color
예제 #3
0
def create_profile(name, color=None):
    if not color:
        color = XoColor()

    client = gconf.client_get_default()
    client.set_string('/desktop/sugar/user/nick', name)
    client.set_string('/desktop/sugar/user/color', color.to_string())
    client.suggest_sync()

    if profile.get_pubkey() and profile.get_profile().privkey_hash:
        logging.info('Valid key pair found, skipping generation.')
        return

    # Generate keypair
    import commands
    keypath = os.path.join(env.get_profile_path(), 'owner.key')
    if os.path.exists(keypath):
        os.rename(keypath, keypath + '.broken')
        logging.warning('Existing private key %s moved to %s.broken', keypath,
                        keypath)

    if os.path.exists(keypath + '.pub'):
        os.rename(keypath + '.pub', keypath + '.pub.broken')
        logging.warning('Existing public key %s.pub moved to %s.pub.broken',
                        keypath, keypath)

    cmd = "ssh-keygen -q -t dsa -f %s -C '' -N ''" % (keypath, )
    (s, o) = commands.getstatusoutput(cmd)
    if s != 0:
        logging.error('Could not generate key pair: %d %s', s, o)
예제 #4
0
def create_profile(name, color=None):
    if not color:
        color = XoColor()

    client = gconf.client_get_default()
    client.set_string('/desktop/sugar/user/nick', name)
    client.set_string('/desktop/sugar/user/color', color.to_string())
    client.suggest_sync()

    if profile.get_pubkey() and profile.get_profile().privkey_hash:
        logging.info('Valid key pair found, skipping generation.')
        return

    # Generate keypair
    import commands
    keypath = os.path.join(env.get_profile_path(), 'owner.key')
    if os.path.exists(keypath):
        os.rename(keypath, keypath + '.broken')
        logging.warning('Existing private key %s moved to %s.broken',
                        keypath, keypath)

    if os.path.exists(keypath + '.pub'):
        os.rename(keypath + '.pub', keypath + '.pub.broken')
        logging.warning('Existing public key %s.pub moved to %s.pub.broken',
                        keypath, keypath)

    cmd = "ssh-keygen -q -t dsa -f %s -C '' -N ''" % (keypath, )
    (s, o) = commands.getstatusoutput(cmd)
    if s != 0:
        logging.error('Could not generate key pair: %d %s', s, o)
예제 #5
0
    def __init__(self, data):
        self.id = data[0]
        self.md5 = data[1]
        self.page = data[2]
        self.title = data[3]
        self.content = data[4]
        self.bodyurl = data[5]
        self.texttitle = data[6]
        self.textcreator = data[7]
        self.created = data[8]
        self.modified = data[9]
        self.creator = data[10]
        self.annotates = data[11]

        if isinstance(data[12], str) or isinstance(data[12], unicode):
            self.color = XoColor(data[12])
        elif isinstance(data[12], XoColor):
            self.color = data[12]
        else:
            self.color = XoColor(" ")

        self.local = data[13]
        self.mimetype = data[14]
        self.uuid = data[15]
        self.annotationurl = data[16]
        if ((self.uuid == None) or (len(self.uuid) == 0)):
            self.make_new_uuid()
        _logger.debug('annobookmark annotates is %s' % self.annotates)

        if (self.annotationurl == None):
            self.annotationurl = ''
예제 #6
0
 def __motion_notify_event_cb(self, icon, event):
     if not self._keep:
         if event.detail == hippo.MOTION_DETAIL_ENTER:
             client = gconf.client_get_default()
             prelit_color = XoColor(client.get_string("/desktop/sugar/user/color"))
             icon.props.stroke_color = prelit_color.get_stroke_color()
             icon.props.fill_color = prelit_color.get_fill_color()
         elif event.detail == hippo.MOTION_DETAIL_LEAVE:
             icon.props.stroke_color = style.COLOR_BUTTON_GREY.get_svg()
             icon.props.fill_color = style.COLOR_TRANSPARENT.get_svg()
예제 #7
0
def _create_activity_icon(metadata):
    if metadata.get('icon-color', ''):
        color = XoColor(metadata['icon-color'])
    else:
        color = XoColor()

    from sugar.activity.activity import get_bundle_path
    bundle = ActivityBundle(get_bundle_path())
    icon = Icon(file=bundle.get_icon(), xo_color=color)

    return icon
예제 #8
0
 def __motion_notify_event_cb(self, icon, event):
     if not self._keep:
         if event.detail == hippo.MOTION_DETAIL_ENTER:
             client = gconf.client_get_default()
             prelit_color = XoColor(
                 client.get_string('/desktop/sugar/user/color'))
             icon.props.stroke_color = prelit_color.get_stroke_color()
             icon.props.fill_color = prelit_color.get_fill_color()
         elif event.detail == hippo.MOTION_DETAIL_LEAVE:
             icon.props.stroke_color = style.COLOR_BUTTON_GREY.get_svg()
             icon.props.fill_color = style.COLOR_TRANSPARENT.get_svg()
예제 #9
0
    def __init__(self, tree_view):
        CellRendererIcon.__init__(self, tree_view)

        self.props.width = style.GRID_CELL_SIZE
        self.props.height = style.GRID_CELL_SIZE
        self.props.size = style.SMALL_ICON_SIZE
        self.props.icon_name = 'emblem-favorite'
        self.props.mode = gtk.CELL_RENDERER_MODE_ACTIVATABLE
        client = gconf.client_get_default()
        prelit_color = XoColor(client.get_string('/desktop/sugar/user/color'))
        self.props.prelit_stroke_color = prelit_color.get_stroke_color()
        self.props.prelit_fill_color = prelit_color.get_fill_color()
예제 #10
0
    def _update_favorite_item(self):
        label = self._favorite_item.child
        if self._favorite:
            label.set_text(_('Remove favorite'))
            xo_color = XoColor('%s,%s' % (style.COLOR_WHITE.get_svg(),
                                          style.COLOR_TRANSPARENT.get_svg()))
        else:
            label.set_text(_('Make favorite'))
            client = gconf.client_get_default()
            xo_color = XoColor(client.get_string('/desktop/sugar/user/color'))

        self._favorite_icon.props.xo_color = xo_color
예제 #11
0
    def __init__(self, tree_view):
        CellRendererIcon.__init__(self, tree_view)

        self.props.width = style.GRID_CELL_SIZE
        self.props.height = style.GRID_CELL_SIZE
        self.props.size = style.SMALL_ICON_SIZE
        self.props.icon_name = 'emblem-favorite'
        self.props.mode = gtk.CELL_RENDERER_MODE_ACTIVATABLE
        client = gconf.client_get_default()
        prelit_color = XoColor(client.get_string('/desktop/sugar/user/color'))
        self.props.prelit_stroke_color = prelit_color.get_stroke_color()
        self.props.prelit_fill_color = prelit_color.get_fill_color()
예제 #12
0
def _create_activity_icon(metadata):
    if metadata.get('icon-color', ''):
        color = XoColor(metadata['icon-color'])
    else:
        client = gconf.client_get_default()
        color = XoColor(client.get_string('/desktop/sugar/user/color'))

    from sugar.activity.activity import get_bundle_path
    bundle = ActivityBundle(get_bundle_path())
    icon = Icon(file=bundle.get_icon(), xo_color=color)

    return icon
예제 #13
0
    def __init__(self):
        logging.debug('STARTUP: Loading the group view')

        gobject.GObject.__init__(self)

        self._box = hippo.CanvasBox()
        self._box.props.background_color = style.COLOR_WHITE.get_int()
        self.set_root(self._box)

        self._friends = {}

        self._layout = SpreadLayout()
        self._box.set_layout(self._layout)

        client = gconf.client_get_default()
        color = XoColor(client.get_string('/desktop/sugar/user/color'))

        self._owner_icon = CanvasIcon(icon_name='computer-xo', cache=True,
                                      xo_color=color)
        self._owner_icon.props.size = style.LARGE_ICON_SIZE

        self._owner_icon.set_palette(BuddyMenu(get_owner_instance()))
        self._layout.add(self._owner_icon)

        friends_model = friends.get_model()

        for friend in friends_model:
            self.add_friend(friend)

        friends_model.connect('friend-added', self._friend_added_cb)
        friends_model.connect('friend-removed', self._friend_removed_cb)
예제 #14
0
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,
                xo_color=XoColor())
    box.pack_start(icon)
    icon.set_sensitive(sensitive)
    icon.show()

    icon = Icon(icon_name='battery-000',
                icon_size=gtk.ICON_SIZE_LARGE_TOOLBAR,
                badge_name='emblem-busy')
    box.pack_start(icon)
    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()
예제 #15
0
    def __init__(self, activity_info, journal_entries):
        ActivityPalette.__init__(self, activity_info)

        if not 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(journal_entries[0])

        self.props.icon = Icon(file=activity_info.get_icon(),
                               xo_color=xo_color,
                               icon_size=gtk.ICON_SIZE_LARGE_TOOLBAR)

        if journal_entries:
            self.props.secondary_text = journal_entries[0]['title']

            menu_items = []
            for entry in journal_entries:
                icon_file_name = misc.get_icon_name(entry)
                color = misc.get_icon_color(entry)

                menu_item = MenuItem(text_label=entry['title'],
                                     file_name=icon_file_name,
                                     xo_color=color)
                menu_item.connect('activate', self.__resume_entry_cb, entry)
                menu_items.append(menu_item)
                menu_item.show()

            if journal_entries:
                separator = gtk.SeparatorMenuItem()
                menu_items.append(separator)
                separator.show()

            for i in range(0, len(menu_items)):
                self.menu.insert(menu_items[i], i)
예제 #16
0
    def __init__(self, tree_view):
        CellRendererIcon.__init__(self, tree_view)

        self.props.width = style.GRID_CELL_SIZE
        self.props.height = style.GRID_CELL_SIZE
        self.props.size = style.STANDARD_ICON_SIZE
        self.props.stroke_color = style.COLOR_BUTTON_GREY.get_svg()
        self.props.fill_color = style.COLOR_TRANSPARENT.get_svg()
        self.props.mode = gtk.CELL_RENDERER_MODE_ACTIVATABLE

        client = gconf.client_get_default()
        prelit_color = XoColor(client.get_string('/desktop/sugar/user/color'))
        self.props.prelit_stroke_color = prelit_color.get_stroke_color()
        self.props.prelit_fill_color = prelit_color.get_fill_color()

        self._tree_view = tree_view
예제 #17
0
    def __init__(self):
        BaseBuddyModel.__init__(self)

        client = gconf.client_get_default()
        self.props.nick = client.get_string('/desktop/sugar/user/nick')
        color = client.get_string('/desktop/sugar/user/color')
        self.props.color = XoColor(color)

        self.props.key = get_profile().pubkey

        self.connect('notify::nick', self.__property_changed_cb)
        self.connect('notify::color', self.__property_changed_cb)

        bus = dbus.SessionBus()
        bus.add_signal_receiver(
                self.__name_owner_changed_cb,
                signal_name='NameOwnerChanged',
                dbus_interface='org.freedesktop.DBus')

        bus_object = bus.get_object(dbus.BUS_DAEMON_NAME, dbus.BUS_DAEMON_PATH)
        for service in bus_object.ListNames(
                dbus_interface=dbus.BUS_DAEMON_IFACE):
            if service.startswith(CONNECTION + '.'):
                path = '/%s' % service.replace('.', '/')
                Connection(service, path, bus,
                           ready_handler=self.__connection_ready_cb)
예제 #18
0
    def __init__(self, cb_object, group):
        RadioToolButton.__init__(self, group=group)

        self.props.palette_invoker = FrameWidgetInvoker(self)

        self._cb_object = cb_object
        self.owns_clipboard = False
        self.props.sensitive = False
        self.props.active = False
        self._notif_icon = None
        self._current_percent = None

        self._icon = Icon()
        client = gconf.client_get_default()
        color = XoColor(client.get_string('/desktop/sugar/user/color'))
        self._icon.props.xo_color = color
        self.set_icon_widget(self._icon)
        self._icon.show()

        cb_service = clipboard.get_instance()
        cb_service.connect('object-state-changed',
                           self._object_state_changed_cb)
        cb_service.connect('object-selected', self._object_selected_cb)

        child = self.get_child()
        child.connect('drag_data_get', self._drag_data_get_cb)
        self.connect('notify::active', self._notify_active_cb)
예제 #19
0
    def __activity_updated_cb(self, account, activity_id, properties):
        logging.debug('__activity_updated_cb %r %r', activity_id, properties)
        if activity_id not in self._activities:
            logging.debug(
                '__activity_updated_cb Unknown activity with '
                'activity_id %r', activity_id)
            return

        registry = bundleregistry.get_registry()
        bundle = registry.get_bundle(properties['type'])
        if not bundle:
            logging.warning('Ignoring shared activity we don' 't have')
            return

        activity = self._activities[activity_id]

        is_new = activity.props.bundle is None

        activity.props.color = XoColor(properties['color'])
        activity.props.bundle = bundle
        activity.props.name = properties['name']
        activity.props.private = properties['private']

        if is_new:
            self._shell_model.add_shared_activity(activity_id,
                                                  activity.props.color)
            self.emit('activity-added', activity)
예제 #20
0
    def __init__(self, home_activity, group):
        RadioToolButton.__init__(self, group=group)

        self.set_palette_invoker(FrameWidgetInvoker(self))
        self.palette_invoker.cache_palette = False

        self._home_activity = home_activity
        self._notify_launch_hid = None

        self._icon = PulsingIcon()
        self._icon.props.base_color = home_activity.get_icon_color()
        self._icon.props.pulse_color = \
                XoColor('%s,%s' % (style.COLOR_BUTTON_GREY.get_svg(),
                                   style.COLOR_TOOLBAR_GREY.get_svg()))
        if home_activity.get_icon_path():
            self._icon.props.file = home_activity.get_icon_path()
        else:
            self._icon.props.icon_name = 'image-missing'
        self.set_icon_widget(self._icon)
        self._icon.show()

        if home_activity.props.launch_status == shell.Activity.LAUNCHING:
            self._icon.props.pulsing = True
            self._notify_launch_hid = home_activity.connect( \
                    'notify::launch-status', self.__notify_launch_status_cb)
        elif home_activity.props.launch_status == shell.Activity.LAUNCH_FAILED:
            self._on_failed_launch()
예제 #21
0
    def __buddy_updated_cb(self, account, contact_id, properties):
        logging.debug('__buddy_updated_cb %r', contact_id)
        if contact_id is None:
            # Don't know the contact-id yet, will get the full state later
            return

        if contact_id not in self._buddies:
            logging.debug(
                '__buddy_updated_cb Unknown buddy with contact_id'
                ' %r', contact_id)
            return

        buddy = self._buddies[contact_id]

        is_new = buddy.props.key is None and 'key' in properties

        if 'color' in properties:
            buddy.props.color = XoColor(properties['color'])

        if 'key' in properties:
            buddy.props.key = properties['key']

        nick_key = CONNECTION_INTERFACE_ALIASING + '/alias'
        if nick_key in properties:
            buddy.props.nick = properties[nick_key]

        if is_new:
            self.emit('buddy-added', buddy)
예제 #22
0
    def __init__(self, tree_view):
        CellRendererIcon.__init__(self, tree_view)

        self.props.width = style.GRID_CELL_SIZE
        self.props.height = style.GRID_CELL_SIZE
        self.props.size = style.STANDARD_ICON_SIZE
        self.props.stroke_color = style.COLOR_BUTTON_GREY.get_svg()
        self.props.fill_color = style.COLOR_TRANSPARENT.get_svg()
        self.props.mode = gtk.CELL_RENDERER_MODE_ACTIVATABLE

        client = gconf.client_get_default()
        prelit_color = XoColor(client.get_string('/desktop/sugar/user/color'))
        self.props.prelit_stroke_color = prelit_color.get_stroke_color()
        self.props.prelit_fill_color = prelit_color.get_fill_color()

        self._tree_view = tree_view
예제 #23
0
    def __init__(self):
        gtk.Window.__init__(self)

        self.set_border_width(style.LINE_WIDTH)
        offset = style.GRID_CELL_SIZE
        width = gtk.gdk.screen_width() - offset * 2
        height = gtk.gdk.screen_height() - offset * 2
        self.set_size_request(width, height)
        self.set_position(gtk.WIN_POS_CENTER_ALWAYS)
        self.set_decorated(False)
        self.set_resizable(False)
        self.set_modal(True)

        self._main_view = gtk.EventBox()
        self._vbox = gtk.VBox()
        self._vbox.set_spacing(style.DEFAULT_SPACING)
        self._vbox.set_border_width(style.GRID_CELL_SIZE * 2)
        self._main_view.modify_bg(gtk.STATE_NORMAL,
                                  style.COLOR_BLACK.get_gdk_color())
        self._main_view.add(self._vbox)
        self._vbox.show()

        client = gconf.client_get_default()
        color = XoColor(client.get_string('/desktop/sugar/user/color'))

        icon = Icon(icon_name='activity-journal',
                    pixel_size=style.XLARGE_ICON_SIZE,
                    xo_color=color)
        self._vbox.pack_start(icon, False)
        icon.show()

        self._title = gtk.Label()
        self._title.modify_fg(gtk.STATE_NORMAL,
                              style.COLOR_WHITE.get_gdk_color())
        self._title.set_markup('<b>%s</b>' % _('Your Journal is full'))
        self._vbox.pack_start(self._title, False)
        self._title.show()

        self._message = gtk.Label(_('Please delete some old Journal'
                                    ' entries to make space for new ones.'))
        self._message.modify_fg(gtk.STATE_NORMAL,
                              style.COLOR_WHITE.get_gdk_color())
        self._vbox.pack_start(self._message, False)
        self._message.show()

        alignment = gtk.Alignment(xalign=0.5, yalign=0.5)
        self._vbox.pack_start(alignment, expand=False)
        alignment.show()

        self._show_journal = gtk.Button()
        self._show_journal.set_label(_('Show Journal'))
        alignment.add(self._show_journal)
        self._show_journal.show()
        self._show_journal.connect('clicked', self.__show_journal_cb)

        self.add(self._main_view)
        self._main_view.show()

        self.connect('realize', self.__realize_cb)
예제 #24
0
 def __favorite_set_data_cb(self, column, cell, model, tree_iter):
     favorite = model[tree_iter][ListModel.COLUMN_FAVORITE]
     if favorite:
         client = gconf.client_get_default()
         color = XoColor(client.get_string('/desktop/sugar/user/color'))
         cell.props.xo_color = color
     else:
         cell.props.xo_color = None
예제 #25
0
    def __init__(self):
        BaseButton.__init__(self, mount_point='/')

        self.props.named_icon = 'activity-journal'

        client = gconf.client_get_default()
        color = XoColor(client.get_string('/desktop/sugar/user/color'))
        self.props.xo_color = color
예제 #26
0
    def __init__(self, documents_path):
        BaseButton.__init__(self, mount_point=documents_path)

        self.props.named_icon = 'user-documents'

        client = gconf.client_get_default()
        color = XoColor(client.get_string('/desktop/sugar/user/color'))
        self.props.xo_color = color
예제 #27
0
 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
예제 #28
0
 def show_notification(self):
     self._notif_icon = NotificationIcon()
     self._notif_icon.props.icon_name = self._icon.props.icon_name
     self._notif_icon.props.xo_color = \
             XoColor('%s,%s' % (self._icon.props.stroke_color,
                                self._icon.props.fill_color))
     frame = jarabe.frame.get_view()
     frame.add_notification(self._notif_icon, gtk.CORNER_BOTTOM_LEFT)
예제 #29
0
class Equation:
    def __init__(self,
                 label=None,
                 eqn=None,
                 res=None,
                 col=None,
                 owner=None,
                 eqnstr=None,
                 ml=None):

        if eqnstr is not None:
            self.parse(eqnstr)
        elif eqn is not None:
            self.set(label, eqn, res, col, owner)

        self.ml = ml

    def set(self, label, eqn, res, col, owner):
        """Set equation properties."""

        self.label = label
        self.equation = eqn
        self.result = res
        self.color = col
        self.owner = owner

    def __str__(self):
        if isinstance(self.result, SVGImage):
            svg_data = "<svg>" + base64.b64encode(self.result.get_svg_data())
            return "%s;%s;%s;%s;%s\n" % \
                (self.label, self.equation, svg_data,
                 self.color.to_string(), self.owner)
        else:
            return "%s;%s;%s;%s;%s\n" % \
                (self.label, self.equation, self.result,
                 self.color.to_string(), self.owner)

    def parse(self, str):
        """Parse equation object string representation."""

        str = str.rstrip("\r\n")
        l = str.split(';')
        if len(l) != 5:
            _logger.error(_('Equation.parse() string invalid (%s)'), str)
            return False

        if l[2].startswith("<svg>"):
            l[2] = SVGImage(data=base64.b64decode(l[2][5:]))


# Should figure out how to use MathLib directly in a non-hacky way
        else:
            try:
                l[2] = Decimal(l[2])
            except Exception, inst:
                pass

        self.set(l[0], l[1], l[2], XoColor(color_string=l[3]), l[4])
예제 #30
0
    def on_calc_value(self, row, column):
        if column == FIELD_ICON:
            return port.pixbuf.sugar_icon(
                file_name=port.shell.get_icon_filename(
                    activity=row[FIELD_ACTIVITY] or row[FIELD_BUNDLE_ID],
                    mime_type=row[FIELD_MIME_TYPE]),
                width=model.ICON_SIZE,
                height=model.ICON_SIZE,
                color=XoColor(row[FIELD_ICON_COLOR]))

        elif column == FIELD_MODIFY_TIME:
            if row[FIELD_TIMESTAMP]:
                timestamp = float(row[FIELD_TIMESTAMP])
                return util.timestamp_to_elapsed_string(timestamp)
            elif row[FIELD_MTIME]:
                ti = time.strptime(row[FIELD_MTIME], '%Y-%m-%dT%H:%M:%S')
                return util.timestamp_to_elapsed_string(time.mktime(ti))
            else:
                return _('No date')

        elif column >= FIELD_BUDDY_FIRST \
                and column < FIELD_BUDDY_FIRST + VISIBLE_BUDDIES_COUNT:
            buddies = row[FIELD_BUDDIES] or []
            if not buddies:
                return None
            buddy_num = column - FIELD_BUDDY_FIRST
            if buddy_num >= len(buddies):
                return None
            return port.pixbuf.sugar_icon(icon_name='computer-xo',
                                          width=model.ICON_SIZE,
                                          height=model.ICON_SIZE,
                                          color=XoColor(buddies[buddy_num][2]))

        elif column == FIELD_THUMB:
            self.fetch_metadata(row)
            return model.THUMB_STUB

        elif column == FIELD_PREVIEW:
            self.fetch_metadata(row)
            return model.PREVIEW_STUB

        elif column == FIELD_BUDDY_MENU:
            return ObjectMenu(row, row[FIELD_ICON])

        return None
예제 #31
0
def _button_activated_cb(button):
    import random

    global data
    random.shuffle(data)

    for i in range(0, len(test.get_children()) - 1):
        test.get_children()[i].props.icon_name = data[i][0]
        test.get_children()[i].props.xo_color = XoColor(data[i][1])
예제 #32
0
 def __init__(self, series_name=None, series_color=None):
     gobject.GObject.__init__(self)
     self.series_name = series_name \
         if series_name is not None else profile.get_nick_name()
     self.data_length = 40
     self.shrink_by = 1
     self.data_moments = (0, 1, 2, 3)
     self.data = []
     self.moments = [[] for m in self.data_moments]
     self.set_color(series_color if series_color is not None else XoColor())
예제 #33
0
    def __init__(self, buddy):
        self._buddy = buddy

        nick, colors = buddy
        buddy_icon = Icon(icon_name='computer-xo',
                          icon_size=style.STANDARD_ICON_SIZE,
                          xo_color=XoColor(colors))

        Palette.__init__(self, primary_text=glib.markup_escape_text(nick),
                         icon=buddy_icon)
예제 #34
0
    def set_keep(self, keep):
        if keep == self._keep:
            return

        self._keep = keep
        if keep:
            client = gconf.client_get_default()
            color = XoColor(client.get_string('/desktop/sugar/user/color'))
            self.props.xo_color = color
        else:
            self.props.stroke_color = style.COLOR_BUTTON_GREY.get_svg()
            self.props.fill_color = style.COLOR_TRANSPARENT.get_svg()