def __init__(self, picker): CanvasIcon.__init__(self, icon_name='computer-xo', pixel_size=style.XLARGE_ICON_SIZE) self._picker = picker self._color = None self.connect('button_press_event', self.__pressed_cb, picker)
def __init__(self, model, file_name, xo_color, size=style.STANDARD_ICON_SIZE): CanvasIcon.__init__(self, file_name=file_name, xo_color=xo_color, pixel_size=size) self._model = model self.palette_invoker.props.toggle_palette = True
def __init__(self, model, file_name, xo_color, size=style.STANDARD_ICON_SIZE): CanvasIcon.__init__(self, file_name=file_name, xo_color=xo_color, pixel_size=size) self._model = model self.connect('button-release-event', self.__button_release_event_cb)
def __init__(self, interval=_INTERVAL, **kwargs): self._pulser = Pulser(self, interval) self._base_color = None self._pulse_color = None self._paused = False self._pulsing = False CanvasIcon.__init__(self, **kwargs) self.connect('destroy', self.__destroy_cb)
def __init__(self, buddies): Gtk.Alignment.__init__(self, 0, 0, 0, 0) hbox = Gtk.HBox() for buddy in buddies: nick_, color = buddy icon = CanvasIcon(icon_name='computer-xo', xo_color=XoColor(color), pixel_size=style.STANDARD_ICON_SIZE) icon.set_palette(BuddyPalette(buddy)) hbox.pack_start(icon, True, True, 0) self.add(hbox)
def __init__(self, buddy, pixel_size=style.STANDARD_ICON_SIZE): CanvasIcon.__init__(self, icon_name='computer-xo', pixel_size=pixel_size) self._filtered = False self._buddy = buddy self._buddy.connect('notify::present', self.__buddy_notify_present_cb) self._buddy.connect('notify::color', self.__buddy_notify_color_cb) self.palette_invoker.props.toggle_palette = True self.palette_invoker.cache_palette = False self._update_color()
def __init__(self): CanvasIcon.__init__(self, icon_name='activity-journal', pixel_size=style.STANDARD_ICON_SIZE, cache=True) self._home_model = shell.get_model() self._home_activity = self._home_model.get_active_activity() if self._home_activity is not None: self._update() self._home_model.connect('active-activity-changed', self.__active_activity_changed_cb) self.connect_after('activate', self.__activate_cb)
def _create_icon(self): icon = CanvasIcon(file_name=misc.get_icon_name(self._metadata)) icon.connect_after('activate', self.__icon_activate_cb) if misc.is_activity_bundle(self._metadata): xo_color = XoColor('%s,%s' % (style.COLOR_BUTTON_GREY.get_svg(), style.COLOR_TRANSPARENT.get_svg())) else: xo_color = misc.get_icon_color(self._metadata) icon.props.xo_color = xo_color icon.set_palette(ObjectPalette(self._journalactivity, self._metadata)) return icon
def __init__(self, model, alerts): SectionView.__init__(self) self._model = model self.restart_alerts = alerts services = get_webaccount_services() if len(services) == 0: label = Gtk.Label() label.set_markup( '<span size="x-large" weight="bold">' + glib.markup_escape_text( _('No web services are installed.\n' 'Please visit %s for more details.' % 'http://wiki.sugarlabs.org/go/WebServices')) + '</span>') label.show() self.add(label) return vbox = Gtk.VBox() hbox = Gtk.HBox(style.DEFAULT_SPACING) self._service_config_box = Gtk.VBox() for service in services: icon = CanvasIcon(icon_name=service.get_icon_name()) icon.connect('button_press_event', service.config_service_cb, self._service_config_box) icon.show() hbox.pack_start(icon, False, False, 0) hbox.show() vbox.pack_start(hbox, False, False, 0) scrolled = Gtk.ScrolledWindow() vbox.pack_start(scrolled, True, True, 0) self.add(vbox) scrolled.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC) scrolled.show() workspace = Gtk.VBox() scrolled.add_with_viewport(workspace) workspace.show() workspace.add(self._service_config_box) workspace.show_all() vbox.show()
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._resume_mode = True self.connect_after('activate', self.__button_activate_cb) datastore.updated.connect(self.__datastore_listener_updated_cb) datastore.deleted.connect(self.__datastore_listener_deleted_cb) self._refresh() self._update()
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._resume_mode = Gio.Settings( 'org.sugarlabs.user').get_boolean('resume-activity') self.connect_after('activate', self.__button_activate_cb) datastore.updated.connect(self.__datastore_listener_updated_cb) datastore.deleted.connect(self.__datastore_listener_deleted_cb) self._refresh() self._update()
def __init__(self, buddy, **kwargs): Gtk.VBox.__init__(self) # round icon sizes to an even number so that it can be accurately # centered in a larger bounding box also of even dimensions size = style.LARGE_ICON_SIZE & ~1 self._buddy = buddy self._buddy_icon = BuddyIcon(buddy) self._buddy_icon.props.pixel_size = size self.add(self._buddy_icon) self._buddy_icon.show() self._activity_icon = CanvasIcon(pixel_size=size) self._update_activity() self._buddy.connect('notify::current-activity', self.__buddy_notify_current_activity_cb) self._buddy.connect('notify::present', self.__buddy_notify_present_cb) self._buddy.connect('notify::color', self.__buddy_notify_color_cb)
def _create_icon(self, color, name='computer-xo'): return CanvasIcon(icon_name=name, xo_color=XoColor(color), pixel_size=style.STANDARD_ICON_SIZE)
class FriendView(Gtk.VBox): def __init__(self, buddy, **kwargs): Gtk.VBox.__init__(self) # round icon sizes to an even number so that it can be accurately # centered in a larger bounding box also of even dimensions size = style.LARGE_ICON_SIZE & ~1 self._buddy = buddy self._buddy_icon = BuddyIcon(buddy) self._buddy_icon.props.pixel_size = size self.add(self._buddy_icon) self._buddy_icon.show() self._activity_icon = CanvasIcon(pixel_size=size) self._update_activity() self._buddy.connect('notify::current-activity', self.__buddy_notify_current_activity_cb) self._buddy.connect('notify::present', self.__buddy_notify_present_cb) self._buddy.connect('notify::color', self.__buddy_notify_color_cb) def _get_new_icon_name(self, ps_activity): registry = bundleregistry.get_registry() activity_info = registry.get_bundle(ps_activity.props.type) if activity_info: return activity_info.get_icon() return None def _remove_activity_icon(self): if self._activity_icon.get_visible(): self._activity_icon.hide() self.remove(self._activity_icon) def __buddy_notify_current_activity_cb(self, buddy, pspec): self._update_activity() def _update_activity(self): if not self._buddy.props.present or \ not self._buddy.props.current_activity: self._remove_activity_icon() return # FIXME: use some sort of "unknown activity" icon rather # than hiding the icon? name = self._get_new_icon_name(self._buddy.current_activity) if name: self._activity_icon.props.file_name = name self._activity_icon.props.xo_color = self._buddy.props.color if not self._activity_icon.get_visible(): self.add(self._activity_icon) self._activity_icon.show() else: self._remove_activity_icon() def __buddy_notify_present_cb(self, buddy, pspec): self._update_activity() def __buddy_notify_color_cb(self, buddy, pspec): # TODO: shouldn't this change self._buddy_icon instead? self._activity_icon.props.xo_color = buddy.props.color
def do_get_preferred_height(self): height = CanvasIcon.do_get_preferred_height(self)[0] height += ActivityIcon._BORDER_WIDTH * 2 return (height, height)
def __init__(self, model, alerts): SectionView.__init__(self) self._model = model self.restart_alerts = alerts services = get_webaccount_services() grid = Gtk.Grid() if len(services) == 0: grid.set_row_spacing(style.DEFAULT_SPACING) icon = Icon(pixel_size=style.LARGE_ICON_SIZE, icon_name='module-webaccount', stroke_color=style.COLOR_BUTTON_GREY.get_svg(), fill_color=style.COLOR_TRANSPARENT.get_svg()) grid.attach(icon, 0, 0, 1, 1) icon.show() label = Gtk.Label() label.set_justify(Gtk.Justification.CENTER) label.set_markup( '<span foreground="%s" size="large">%s</span>' % (style.COLOR_BUTTON_GREY.get_html(), GLib.markup_escape_text( _('No web services are installed.\n' 'Please visit %s for more details.' % 'http://wiki.sugarlabs.org/go/WebServices')))) label.show() grid.attach(label, 0, 1, 1, 1) alignment = Gtk.Alignment.new(0.5, 0.5, 0.1, 0.1) alignment.add(grid) grid.show() self.add(alignment) alignment.show() return grid.set_row_spacing(style.DEFAULT_SPACING * 4) grid.set_column_spacing(style.DEFAULT_SPACING * 4) grid.set_border_width(style.DEFAULT_SPACING * 2) grid.set_column_homogeneous(True) width = Gdk.Screen.width() - 2 * style.GRID_CELL_SIZE nx = int(width / (style.GRID_CELL_SIZE + style.DEFAULT_SPACING * 4)) self._service_config_box = Gtk.VBox() x = 0 y = 0 for service in services: service_grid = Gtk.Grid() icon = CanvasIcon(icon_name=service.get_icon_name()) icon.show() service_grid.attach(icon, x, y, 1, 1) icon.connect('activate', service.config_service_cb, None, self._service_config_box) label = Gtk.Label() label.set_justify(Gtk.Justification.CENTER) name = get_service_name(service) label.set_markup(name) service_grid.attach(label, x, y + 1, 1, 1) label.show() grid.attach(service_grid, x, y, 1, 1) service_grid.show() x += 1 if x == nx: x = 0 y += 1 alignment = Gtk.Alignment.new(0.5, 0, 0, 0) alignment.add(grid) grid.show() vbox = Gtk.VBox() vbox.pack_start(alignment, False, False, 0) alignment.show() scrolled = Gtk.ScrolledWindow() vbox.pack_start(scrolled, True, True, 0) self.add(vbox) scrolled.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC) scrolled.show() workspace = Gtk.VBox() scrolled.add_with_viewport(workspace) workspace.show() workspace.add(self._service_config_box) workspace.show_all() vbox.show()
def do_get_preferred_width(self): width = CanvasIcon.do_get_preferred_width(self)[0] width += ActivityIcon._BORDER_WIDTH * 2 return (width, width)