def __init__(self, file_name, document_path, activity_name, title, bundle=False): RadioToolButton.__init__(self) self._document_path = document_path self._title = title self._jobject = None self._activity_name = activity_name self.props.tooltip = _('Instance Source') settings = Gio.Settings('org.sugarlabs.user') self._color = settings.get_string('color') icon = Icon(file=file_name, pixel_size=style.STANDARD_ICON_SIZE, xo_color=XoColor(self._color)) self.set_icon_widget(icon) icon.show() box = PaletteMenuBox() self.props.palette.set_content(box) box.show() if bundle: menu_item = PaletteMenuItem(_('Duplicate'), 'edit-duplicate', xo_color=XoColor(self._color)) menu_item.connect('activate', self.__show_duplicate_alert) else: menu_item = PaletteMenuItem(_('Keep'), 'document-save', xo_color=XoColor(self._color)) menu_item.connect('activate', self.__keep_in_journal_cb) box.append_item(menu_item) menu_item.show()
def _add_row(self, sender, message, icon_name, icon_color): self._store.append((get_icon_file_name(icon_name), XoColor(icon_color), sender, message, get_icon_file_name('list-remove'), XoColor('#FFFFFF,#000000')))
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.IconSize.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.IconSize.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.IconSize.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()
def __init__(self, activity_info): self._activity_info = activity_info client = GConf.Client.get_default() color = XoColor(client.get_string('/desktop/sugar/user/color')) activity_icon = Icon(file=activity_info.get_icon(), xo_color=color, icon_size=Gtk.IconSize.LARGE_TOOLBAR) name = activity_info.get_name() Palette.__init__(self, primary_text=glib.markup_escape_text(name), icon=activity_icon) xo_color = XoColor( '%s,%s' % (style.COLOR_WHITE.get_svg(), style.COLOR_TRANSPARENT.get_svg())) self.menu_box = PaletteMenuBox() menu_item = PaletteMenuItem(text_label=_('Start new'), file_name=activity_info.get_icon(), xo_color=xo_color) menu_item.connect('activate', self.__start_activate_cb) self.menu_box.pack_end(menu_item, True, True, 0) menu_item.show() self.set_content(self.menu_box) self.menu_box.show_all()
def __init__(self, channel): EventPulsingIcon.__init__(self, icon_name=self._ICON_NAME + str(channel), pixel_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) 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_invoker.props.toggle_palette = True self._palette = self._create_palette() self.set_palette(self._palette) self._palette_icon.props.xo_color = self._state_color
def get_color(): if 'org.sugarlabs.user' in Gio.Settings.list_schemas(): settings = Gio.Settings('org.sugarlabs.user') color = settings.get_string('color') return XoColor(color) else: return XoColor()
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') settings = Gio.Settings('org.sugarlabs.user') self._color = settings.get_string('color') icon = Icon(file=file_name, pixel_size=style.STANDARD_ICON_SIZE, xo_color=XoColor(self._color)) self.set_icon_widget(icon) icon.show() if bundle: menu_item = MenuItem(_('Duplicate')) icon = Icon(icon_name='edit-duplicate', pixel_size=style.SMALL_ICON_SIZE, 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', pixel_size=style.SMALL_ICON_SIZE, 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()
def _update_info(self): name = _ICON_NAME current_level = self._model.props.level xo_color = self._color badge_name = None if not self._model.props.present: status = _STATUS_NOT_PRESENT badge_name = None xo_color = XoColor( '%s,%s' % (style.COLOR_WHITE.get_svg(), style.COLOR_WHITE.get_svg())) elif self._model.props.charging: status = _STATUS_CHARGING name += '-charging' xo_color = XoColor( '%s,%s' % (style.COLOR_WHITE.get_svg(), style.COLOR_WHITE.get_svg())) elif self._model.props.discharging: status = _STATUS_DISCHARGING if current_level <= _WARN_MIN_PERCENTAGE: badge_name = 'emblem-warning' else: status = _STATUS_FULLY_CHARGED self.icon.props.icon_name = get_icon_state(name, current_level, step=-5) self.icon.props.xo_color = xo_color self.icon.props.badge_name = badge_name self.palette.set_info(current_level, self._model.props.time_remaining, status)
def __init__(self): Gtk.Grid.__init__(self) self.set_row_spacing(style.DEFAULT_SPACING) self.set_column_spacing(style.DEFAULT_SPACING) self._gender = load_gender() self._buttons = [] self._nocolor = XoColor('#010101,#ffffff') self._color = XoColor() for i, gender in enumerate(GENDERS): self._buttons.append( EventIcon(pixel_size=style.XLARGE_ICON_SIZE, icon_name='%s-6' % (gender))) self._buttons[-1].connect('button-press-event', self._button_press_cb, i) self.attach(self._buttons[-1], i * 2, 0, 1, 1) self._buttons[-1].show() self.reset_button = EventIcon(pixel_size=style.SMALL_ICON_SIZE, icon_name='entry-cancel') self.reset_button.connect('button-press-event', self._reset_button_press_cb) self.attach(self.reset_button, 1, 0, 1, 1) self.reset_button.xo_color = XoColor('#010101,#a0a0a0') self.reset_button.show()
def __init__(self, gender, page=None): Gtk.Grid.__init__(self) self.set_row_spacing(style.DEFAULT_SPACING) self.set_column_spacing(style.DEFAULT_SPACING) self._group_labels = get_group_labels() self._page = page self._gender = gender self._age = self.get_age() self._pickers = [] self._nocolor = XoColor('#010101,#ffffff') self._color = XoColor() if self._gender not in GENDERS: self._gender = 'male' gender_index = GENDERS.index(self._gender) age_index = age_to_index(self._age) width = Gdk.Screen.width() num_ages = len(self._group_labels.AGES) for i in range(num_ages): self._pickers.append( Picker(self._group_labels.ICONS[i][gender_index], _(self._group_labels.LABELS[i]))) self._pickers[i].connect(self._button_activate_cb, i) self._fixed = Gtk.Fixed() fixed_size = width - 4 * style.GRID_CELL_SIZE self._fixed.set_size_request(fixed_size, -1) self.attach(self._fixed, 0, 0, 1, 1) self._fixed.show() self._age_adj = Gtk.Adjustment(value=age_index, lower=0, upper=num_ages - 1, step_incr=1, page_incr=3, page_size=0) self._age_adj.connect('value-changed', self.__age_adj_changed_cb) self._age_slider = Gtk.HScale() self._age_slider.set_draw_value(False) self._age_slider.set_adjustment(self._age_adj) self.attach(self._age_slider, 0, 1, 1, 1) for i in range(num_ages): self._fixed.put(self._pickers[i], 0, 0) self._configure(width) Gdk.Screen.get_default().connect('size-changed', self._configure_cb)
def _update_favorite_item(self): if self._favorite: self._favorite_item.set_label(_('Remove favorite')) xo_color = XoColor('%s,%s' % (style.COLOR_WHITE.get_svg(), style.COLOR_TRANSPARENT.get_svg())) else: self._favorite_item.set_label(_('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
def set_widget_icon(self, icon_name=None, file_name=None): if file_name is not None: icon = Icon(file=file_name, pixel_size=style.SMALL_ICON_SIZE, xo_color=XoColor('white')) else: icon = Icon(icon_name=icon_name, pixel_size=style.SMALL_ICON_SIZE, xo_color=XoColor('white')) self.set_icon_widget(icon) icon.show()
def _create_activity_icon(metadata): if metadata.get('icon-color', ''): color = XoColor(metadata['icon-color']) else: color = XoColor() from sugar3.activity.activity import get_bundle_path bundle = ActivityBundle(get_bundle_path()) icon = Icon(file=bundle.get_icon(), xo_color=color) return icon
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 sugar3.activity.activity import get_bundle_path bundle = ActivityBundle(get_bundle_path()) icon = Icon(file=bundle.get_icon(), xo_color=color) return icon
def set_color(self, color): if self._picker == _PREVIOUS_FILL_COLOR: self._color = XoColor(_get_previous_fill_color(color)) elif self._picker == _PREVIOUS_STROKE_COLOR: self._color = XoColor(_get_previous_stroke_color(color)) elif self._picker == _NEXT_FILL_COLOR: self._color = XoColor(_get_next_fill_color(color)) elif self._picker == _NEXT_STROKE_COLOR: self._color = XoColor(_get_next_stroke_color(color)) else: self._color = color self.props.xo_color = self._color
def __download_running_cb(self): progress = downloadmanager.overall_downloads_progress() self._download_icon.update(progress) if downloadmanager.num_downloads() > 0: self._download_icon.props.tooltip = \ _('{}% Downloaded').format(int(progress*100)) self._download_icon.props.xo_color = XoColor(None) return True else: GLib.source_remove(self._download_running_hid) self._download_running_hid = None self._download_icon.props.tooltip = _('No Downloads Running') self._download_icon.props.xo_color = XoColor('insensitive') return False
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 = NotificationPulsingIcon() 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: # Let's see if the X11 window can give us an icon. window = home_activity.get_window() if not window.get_icon_is_fallback(): pixbuf = window.get_icon() self._icon.pixbuf = pixbuf 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()
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) logging.debug("Generating user keypair") 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) logging.debug("User keypair generated")
def __init__(self, **kwargs): Gtk.EventBox.__init__(self) BaseExpandedEntry.__init__(self) self.project_metadata = None self._service = None self._activity_id = None self._project = None self.modify_bg(Gtk.StateType.NORMAL, style.COLOR_WHITE.get_gdk_color()) self._vbox = Gtk.VBox() self.add(self._vbox) back_bar = BackBar() back_bar.connect('button-release-event', self.__back_bar_release_event_cb) self._vbox.pack_start(back_bar, False, True, 0) header = self.create_header() self._vbox.pack_start(header, False, False, style.DEFAULT_SPACING * 2) header.show() description_box, self._description = self._create_description() self._vbox.pack_start(description_box, False, True, style.DEFAULT_SPACING / 3) self._title.connect('focus-out-event', self._title_focus_out_event_cb) settings = Gio.Settings.new('org.sugarlabs.user') icon_color = settings.get_string('color') self._icon = Icon(icon_name='project-box', pixel_size=style.MEDIUM_ICON_SIZE) self._icon.xo_color = XoColor(icon_color) self._icon_box.pack_start(self._icon, False, False, 0)
def create_icon_widgets(box, sensitive=True): icon = Icon(icon_name='go-previous') icon.props.pixel_size = style.STANDARD_ICON_SIZE box.pack_start(icon, True, True, 0) icon.set_sensitive(sensitive) icon.show() icon = Icon(icon_name='computer-xo', pixel_size=style.STANDARD_ICON_SIZE, xo_color=XoColor()) box.pack_start(icon, True, True, 0) icon.set_sensitive(sensitive) icon.show() icon = Icon(icon_name='battery-000', pixel_size=style.STANDARD_ICON_SIZE, badge_name='emblem-busy') box.pack_start(icon, True, True, 0) icon.set_sensitive(sensitive) icon.show() icon = Icon(icon_name='gtk-new', pixel_size=style.STANDARD_ICON_SIZE, badge_name='gtk-cancel') box.pack_start(icon, True, True, 0) icon.set_sensitive(sensitive) icon.show()
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 # arrives unicode but we connect with byte_arrays=True - SL #4157 activity.props.color = XoColor(str(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)
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: # arrives unicode but we connect with byte_arrays=True - SL #4157 buddy.props.color = XoColor(str(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)
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)
def create_icon_widgets(box, sensitive=True): icon = Icon(icon_name='go-previous') icon.props.icon_size = Gtk.IconSize.LARGE_TOOLBAR box.pack_start(icon, True, True, 0) icon.set_sensitive(sensitive) icon.show() icon = Icon(icon_name='computer-xo', icon_size=Gtk.IconSize.LARGE_TOOLBAR, xo_color=XoColor()) box.pack_start(icon, True, True, 0) icon.set_sensitive(sensitive) icon.show() icon = Icon(icon_name='battery-000', icon_size=Gtk.IconSize.LARGE_TOOLBAR, badge_name='emblem-busy') box.pack_start(icon, True, True, 0) icon.set_sensitive(sensitive) icon.show() icon = Icon(icon_name='gtk-new', icon_size=Gtk.IconSize.LARGE_TOOLBAR, badge_name='gtk-cancel') box.pack_start(icon, True, True, 0) icon.set_sensitive(sensitive) icon.show()
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_WHITE.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, pixel_size=style.STANDARD_ICON_SIZE) 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 = PaletteMenuItem(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 = PaletteMenuItemSeparator() menu_items.append(separator) separator.show() for i in range(0, len(menu_items)): self.menu_box.pack_start(menu_items[i], True, True, 0)
def __init__(self, activity_info): self._activity_info = activity_info color = profile.get_color() activity_icon = Icon(file=activity_info.get_icon(), xo_color=color, pixel_size=style.STANDARD_ICON_SIZE) name = activity_info.get_name() Palette.__init__(self, primary_text=GLib.markup_escape_text(name), icon=activity_icon) xo_color = XoColor( '%s,%s' % (style.COLOR_WHITE.get_svg(), style.COLOR_TRANSPARENT.get_svg())) self.menu_box = PaletteMenuBox() menu_item = PaletteMenuItem(text_label=_('Start new'), file_name=activity_info.get_icon(), xo_color=xo_color) menu_item.connect('activate', self.__start_activate_cb) self.menu_box.pack_end(menu_item, True, True, 0) menu_item.show() self.set_content(self.menu_box) self.menu_box.show_all()
def __init__(self, **kwargs): self._icon_name = None self._pixel_size = style.GRID_CELL_SIZE self._xo_color = None self._title = 'No Title' Gtk.EventBox.__init__(self, **kwargs) self._vbox = Gtk.VBox() self._icon = Icon(icon_name=self._icon_name, pixel_size=self._pixel_size, xo_color=XoColor('#000000,#000000')) self._vbox.pack_start(self._icon, expand=False, fill=False, padding=0) self._label = Gtk.Label(label=self._title) self._vbox.pack_start(self._label, expand=False, fill=False, padding=0) self._vbox.set_spacing(style.DEFAULT_SPACING) self.set_visible_window(False) self.set_app_paintable(True) self.set_events(Gdk.EventMask.BUTTON_PRESS_MASK) self.add(self._vbox) self._vbox.show() self._label.show() self._icon.show()
def __init__(self, cb_object, group): RadioToolButton.__init__(self, group=group) self.props.palette_invoker = FrameWidgetInvoker(self) self.palette_invoker.props.toggle_palette = True 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)
def launch(bundle, activity_id=None, object_id=None, uri=None, color=None, invited=False): if activity_id is None or not activity_id: activity_id = activityfactory.create_activity_id() logging.debug('launch bundle_id=%s activity_id=%s object_id=%s uri=%s', bundle.get_bundle_id(), activity_id, object_id, uri) shell_model = shell.get_model() activity = shell_model.get_activity_by_id(activity_id) if activity is not None: logging.debug('re-launch %r', activity.get_window()) activity.get_window().activate(Gtk.get_current_event_time()) return if color is None: client = GConf.Client.get_default() color = XoColor(client.get_string('/desktop/sugar/user/color')) launcher.add_launcher(activity_id, bundle.get_icon(), color) activity_handle = ActivityHandle(activity_id=activity_id, object_id=object_id, uri=uri, invited=invited) activityfactory.create(bundle, activity_handle)
def __init__(self, cb_object): Palette.__init__(self, text_maxlen=100) self._cb_object = cb_object self.set_group_id('frame') cb_service = clipboard.get_instance() cb_service.connect('object-state-changed', self._object_state_changed_cb) self._remove_item = MenuItem(pgettext('Clipboard', 'Remove'), 'list-remove') self._remove_item.connect('activate', self._remove_item_activate_cb) self.menu.append(self._remove_item) self._remove_item.show() self._open_item = MenuItem(_('Open'), 'zoom-activity') self._open_item.connect('activate', self._open_item_activate_cb) self.menu.append(self._open_item) self._open_item.show() self._journal_item = MenuItem(_('Keep')) client = GConf.Client.get_default() color = XoColor(client.get_string('/desktop/sugar/user/color')) icon = Icon(icon_name='document-save', icon_size=Gtk.IconSize.MENU, xo_color=color) self._journal_item.set_image(icon) self._journal_item.connect('activate', self._journal_item_activate_cb) self.menu.append(self._journal_item) self._journal_item.show() self._update()