def __init__(self, data, extension, group, activity): Gtk.VBox.__init__(self) self.activity = activity self.md5sum = data[extension][1] self.progressbar = Gtk.ProgressBar() size = Gdk.Screen.width() / 10 tmp_dir = os.path.join(self.activity.get_activity_root(), 'tmp') fd, self.file_path = tempfile.mkstemp(dir=tmp_dir) os.close(fd) xo_color = get_user_color() icon = CanvasIcon(icon_name=extension, xo_color=xo_color, pixel_size=size) icon.connect('button-press-event', self.download, data[extension][0]) title = Gtk.Label(extension) font = Pango.FontDescription("%d" % (size / 4)) title.modify_font(font) hbox = Gtk.HBox() hbox.pack_start(icon, False, False, 5) hbox.pack_start(title, False, False, 15) hbox.pack_end(self.progressbar, False, False, 5) hbox.set_size_request(Gdk.Screen.width(), -1) group.add_widget(self.progressbar) self.pack_start(hbox, True, True, 0) self.pack_end(Gtk.HSeparator(), False, False, 5) self.show_all()
def build_extension(self, icon_name, service_path, cp_path, service_title): size = Gdk.Screen.width() / 10 xo_color = get_user_color() label = Gtk.Label(service_title) icono = Icon(icon_name=icon_name, pixel_size=size, xo_color=xo_color) font = Pango.FontDescription("%d" % (size / 4)) label.modify_font(font) remove = CanvasIcon(icon_name='remove-extension', xo_color=xo_color) hbox = Gtk.HBox() hbox.pack_start(icono, False, False, 5) hbox.pack_start(label, False, False, 5) hbox.pack_end(remove, False, False, 5) hbox.set_size_request(size * 10, -1) vbox = Gtk.VBox() vbox.pack_start(hbox, False, False, 0) vbox.pack_end(Gtk.HSeparator(), False, False, 3) remove.connect('button-press-event', self.remove_extension, service_path, cp_path, vbox, service_title) return vbox
def _show_bundle_icon(self, icon_path): if self._icon in self._vbox: self._vbox.remove(self._icon) self._icon = CanvasIcon(file_name=icon_path, xo_color=XoColor('#000000,#FFFFFF'), pixel_size=style.LARGE_ICON_SIZE) self._vbox.pack_end(self._icon, True, True, 0) self._icon.show()
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 _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, 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 build_zone(self, icon_name, text, zones=2): xo_color = get_user_color() width = Gdk.Screen.width() / zones icon = CanvasIcon(icon_name=icon_name, xo_color=xo_color, pixel_size=width) label = Gtk.Label() label.set_markup("%s" % text) label.modify_font(Pango.FontDescription('15')) label.set_justify(2) label.modify_fg(Gtk.StateType.NORMAL, Gdk.color_parse(get_fill_color())) vbox = Gtk.VBox() vbox.pack_start(icon, True, True, 0) vbox.pack_end(label, False, False, 5) box = Gtk.EventBox() box.add(vbox) #box.modify_bg(Gtk.StateType.NORMAL, Gdk.color_parse('white')) icon.connect('button-press-event', lambda x, y: self.emit('action', icon_name)) return box
def _create_icon(self, color, name='computer-xo'): return CanvasIcon(icon_name=name, xo_color=XoColor(color), pixel_size=style.STANDARD_ICON_SIZE)
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()