def _create_palette(self): self._palette_icon = Icon( \ icon_name=self._ICON_NAME + str(self._channel), icon_size=style.STANDARD_ICON_SIZE) text = _('Ad-hoc Network %d') % (self._channel, ) palette_ = palette.Palette(glib.markup_escape_text(text), icon=self._palette_icon) self._connect_item = MenuItem(_('Connect'), 'dialog-ok') self._connect_item.connect('activate', self.__connect_activate_cb) palette_.menu.append(self._connect_item) self._disconnect_item = MenuItem(_('Disconnect'), 'media-eject') self._disconnect_item.connect('activate', self.__disconnect_activate_cb) palette_.menu.append(self._disconnect_item) return palette_
def __init__(self, parent, name, icon_name='', callback=None, tooltip=None, group=None): RadioToolButton.__init__(self) if icon_name == '': icon_name = 'computer-xo' icon = Icon(icon_name=icon_name, icon_size=gtk.ICON_SIZE_LARGE_TOOLBAR) self.set_icon_widget(icon) icon.show() if tooltip is not None: self.set_tooltip(tooltip) self.props.sensitive = True self.connect('clicked', callback) self.set_group(group) self.show() parent.button_dict[name] = self parent.callback_dict[name] = callback
def _create_palette(self): icon_name = get_icon_state(_AP_ICON_NAME, self._strength) self._palette_icon = Icon(icon_name=icon_name, icon_size=style.STANDARD_ICON_SIZE, badge_name=self.props.badge_name) label = glib.markup_escape_text(self._display_name) p = palette.Palette(primary_text=label, icon=self._palette_icon) self._connect_item = MenuItem(_('Connect'), 'dialog-ok') self._connect_item.connect('activate', self.__connect_activate_cb) p.menu.append(self._connect_item) self._disconnect_item = MenuItem(_('Disconnect'), 'media-eject') self._disconnect_item.connect('activate', self._disconnect_activate_cb) p.menu.append(self._disconnect_item) return p
def add_section(help_box, section_text, icon=None): ''' Add a section to the help palette. From helpbutton.py by Gonzalo Odiard ''' max_text_width = int(gtk.gdk.screen_width() / 3) - 20 hbox = gtk.HBox() label = gtk.Label() label.set_use_markup(True) label.set_markup('<b>%s</b>' % section_text) label.set_line_wrap(True) label.set_size_request(max_text_width, -1) hbox.add(label) if icon is not None: _icon = Icon(icon_name=icon) hbox.add(_icon) label.set_size_request(max_text_width - 20, -1) else: label.set_size_request(max_text_width, -1) hbox.show_all() help_box.pack_start(hbox, False, False, padding=5)
def add_paragraph(help_box, text, icon=None): ''' Add an entry to the help palette. From helpbutton.py by Gonzalo Odiard ''' max_text_width = int(gtk.gdk.screen_width() / 3) - 20 hbox = gtk.HBox() label = gtk.Label(text) label.set_justify(gtk.JUSTIFY_LEFT) label.set_line_wrap(True) hbox.add(label) if icon is not None: _icon = Icon(icon_name=icon) hbox.add(_icon) label.set_size_request(max_text_width - 20, -1) else: label.set_size_request(max_text_width, -1) hbox.show_all() help_box.pack_start(hbox, False, False, padding=5) return hbox
def _update_invite_menu(self, activity): buddy_activity = self._buddy.props.current_activity if buddy_activity is not None: buddy_activity_id = buddy_activity.activity_id else: buddy_activity_id = None if activity is None or activity.is_journal() or \ activity.get_activity_id() == buddy_activity_id: self._invite_menu.hide() else: title = activity.get_title() label = self._invite_menu.get_children()[0] label.set_text(_('Invite to %s') % title) icon = Icon(file=activity.get_icon_path()) icon.props.xo_color = activity.get_icon_color() self._invite_menu.set_image(icon) icon.show() self._invite_menu.show()
def __init__(self, buddy): self._buddy = buddy buddy_icon = Icon(icon_name='computer-xo', xo_color=buddy.get_color(), icon_size=gtk.ICON_SIZE_LARGE_TOOLBAR) nick = buddy.get_nick() Palette.__init__(self, None, primary_text=glib.markup_escape_text(nick), icon=buddy_icon) self._invite_menu = None self._active_activity_changed_hid = None self.connect('destroy', self.__destroy_cb) self._buddy.connect('notify::nick', self.__buddy_notify_nick_cb) if buddy.is_owner(): self._add_my_items() else: self._add_buddy_items()
def __init__(self, invite): ToolButton.__init__(self) self._invite = invite self.connect('clicked', self.__clicked_cb) self.connect('destroy', self.__destroy_cb) bundle_registry = bundleregistry.get_registry() bundle = bundle_registry.get_bundle(invite.get_bundle_id()) self._icon = Icon() self._icon.props.xo_color = invite.get_color() if bundle is not None: self._icon.props.file = bundle.get_icon() else: self._icon.props.icon_name = 'image-missing' self.set_icon_widget(self._icon) self._icon.show() palette = InvitePalette(invite) palette.props.invoker = FrameWidgetInvoker(self) palette.set_group_id('frame') palette.connect('remove-invite', self.__remove_invite_cb) self.set_palette(palette) self._notif_icon = NotificationIcon() self._notif_icon.connect('button-release-event', self.__button_release_event_cb) self._notif_icon.props.xo_color = invite.get_color() if bundle is not None: self._notif_icon.props.icon_filename = bundle.get_icon() else: self._notif_icon.props.icon_name = 'image-missing' frame = jarabe.frame.get_view() frame.add_notification(self._notif_icon, gtk.CORNER_TOP_LEFT)
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.ICON_SIZE_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())) menu_item = MenuItem(text_label=_('Start new'), file_name=activity_info.get_icon(), xo_color=xo_color) menu_item.connect('activate', self.__start_activate_cb) self.menu.append(menu_item) menu_item.show()
def __init__(self): gtk.Toolbar.__init__(self) client = gconf.client_get_default() color = XoColor(client.get_string('/desktop/sugar/user/color')) icon = Icon() icon.set_from_icon_name('activity-journal', gtk.ICON_SIZE_LARGE_TOOLBAR) icon.props.xo_color = color self._add_widget(icon) self._add_separator() self._title = gtk.Label(_('Describe your activity')) self._add_widget(self._title) self._add_separator(True) self._keep_button = ToolButton('dialog-ok', tooltip=_('Keep')) self._keep_button.props.accelerator = '<Ctrl>s' self._keep_button.connect('clicked', self.__keep_button_clicked_cb) self.insert(self._keep_button, -1) self._keep_button.show()
def __init__(self, metadata): gobject.GObject.__init__(self) self._metadata = metadata for activity_info in misc.get_activities(metadata): menu_item = MenuItem(activity_info.get_name()) menu_item.set_image(Icon(file=activity_info.get_icon(), icon_size=gtk.ICON_SIZE_MENU)) menu_item.connect('activate', self.__item_activate_cb, activity_info.get_bundle_id()) self.append(menu_item) menu_item.show() if not self.get_children(): if metadata.get('activity_id', ''): resume_label = _('No activity to resume entry') else: resume_label = _('No activity to start entry') menu_item = MenuItem(resume_label) menu_item.set_sensitive(False) self.append(menu_item) menu_item.show()
def _refresh_resume_palette(self): if self._metadata.get('activity_id', ''): # TRANS: Action label for resuming an activity. self._resume.set_tooltip(_('Resume')) else: # TRANS: Action label for starting an entry. self._resume.set_tooltip(_('Start')) palette = self._resume.get_palette() for menu_item in palette.menu.get_children(): palette.menu.remove(menu_item) menu_item.destroy() for activity_info in misc.get_activities(self._metadata): menu_item = MenuItem(activity_info.get_name()) menu_item.set_image( Icon(file=activity_info.get_icon(), icon_size=gtk.ICON_SIZE_MENU)) menu_item.connect('activate', self._resume_menu_item_activate_cb, activity_info.get_bundle_id()) palette.menu.append(menu_item) menu_item.show()
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._progress_bar = None 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.ICON_SIZE_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()
def _build_mainbox(self): self.vbox = gtk.VBox() if len(get_wireless_interfaces()) > 0: self.graph = Graph() self.vbox.pack_start(self.graph) else: icon = Icon(pixel_size=style.XLARGE_ICON_SIZE, icon_name='icon-missing', xo_color=xocolor.XoColor( "%s,%s" % (style.COLOR_BUTTON_GREY.get_svg(), style.COLOR_TRANSPARENT.get_svg()))) text = gtk.Label() text.set_markup('<span size="xx-large">' 'No wireless devices found</span>') text.set_line_wrap(True) text.set_alignment(0.5, 0) text.set_justify(gtk.JUSTIFY_CENTER) self.vbox.pack_start(icon) self.vbox.pack_start(text) self.vbox.show_all() self.set_canvas(self.vbox) self.vbox.show_all()
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: title = journal_entries[0]['title'] self.props.secondary_text = glib.markup_escape_text(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)
def _alert(self, message): bg = gtk.EventBox() bg.modify_bg(gtk.STATE_NORMAL, style.COLOR_WHITE.get_gdk_color()) canvas = gtk.VBox() canvas.set_border_width(style.GRID_CELL_SIZE) canvas.props.spacing = style.DEFAULT_SPACING bg.add(canvas) box = gtk.HBox() box.props.spacing = style.DEFAULT_SPACING canvas.pack_start(box) icon = Icon(pixel_size=style.LARGE_ICON_SIZE) icon.set_from_icon_name('emblem-warning', gtk.ICON_SIZE_LARGE_TOOLBAR) box.pack_start(icon, False) label = gtk.Label() label.props.use_markup = True label.props.label = '<b>Error</b>\n%s' % message box.pack_start(label, False) bg.show_all() return bg
from sugar.graphics.palette import Palette from sugar.graphics.icon import Icon import common test = common.TestPalette() palette = Palette('Test radio and toggle') test.set_palette(palette) box = gtk.HBox() toggle = gtk.ToggleButton() icon = Icon(icon_name='go-previous', icon_size=gtk.ICON_SIZE_LARGE_TOOLBAR) toggle.set_image(icon) box.pack_start(toggle, False) toggle.show() radio = gtk.RadioButton() icon = Icon(icon_name='go-next', icon_size=gtk.ICON_SIZE_LARGE_TOOLBAR) radio.set_image(icon) radio.set_mode(False) box.pack_start(radio, False) radio.show() palette.set_content(box)
['battery-090', '#D1A3FF,#00A0FF'], ['battery-100', '#AC32FF,#FF2B34']] 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]) for d in data: icon = Icon(icon_name=d[0], icon_size=gtk.ICON_SIZE_LARGE_TOOLBAR, xo_color=XoColor(d[1])) test.pack_start(icon) icon.show() button = gtk.Button('mec mac') test.pack_start(button) button.connect('activate', _button_activated_cb) button.show() test.show() if __name__ == '__main__': common.main(test)
def __init__(self, handle): activity.Activity.__init__(self, handle) self.client = gconf.client_get_default() self.current_nick = self.client.get_string("/desktop/sugar/user/nick") self.current_colour = self.client.get_string( "/desktop/sugar/user/color") self.current_colours = _parse_string(self.current_colour) self.toolbox = activity.ActivityToolbox(self) activity_toolbar = self.toolbox.get_activity_toolbar() activity_toolbar.share.props.visible = False activity_toolbar.keep.props.visible = False self.ok_button = ToolButton(icon) self.ok_button.props.tooltip = "Aplicar" self.ok_button.connect("clicked", self.apply) self.ok_button.show() activity_toolbar.insert(self.ok_button, 2) self.set_toolbox(self.toolbox) self.toolbox.show() self.canvas = gtk.VBox() name_box = gtk.HBox() self.canvas.pack_start(name_box, True, True, 5) name_label = gtk.Label("Nombre:") self.name_entry = gtk.Entry() self.name_entry.set_text(self.current_nick) name_label.show() self.name_entry.show() name_box.pack_start(name_label, False, True, 0) name_box.pack_start(self.name_entry, True, True, 0) name_box.show() self.colour_picker = gtk.HBox() selectors = gtk.VBox() self.out_colour_selector = gtk.ColorSelection() self.out_colour_selector.set_current_color( gtk.gdk.color_parse(self.current_colours[0])) self.out_colour_selector.connect("color-changed", self.colour_changed_callback, "out") self.out_colour_selector.show() selectors.pack_start(self.out_colour_selector, True, True, 0) self.in_colour_selector = gtk.ColorSelection() self.in_colour_selector.set_current_color( gtk.gdk.color_parse(self.current_colours[1])) self.in_colour_selector.connect("color-changed", self.colour_changed_callback, "in") self.in_colour_selector.show() selectors.pack_start(self.in_colour_selector, True, True, 0) selectors.show() self.colour_picker.pack_start(selectors, True, True, 0) self.xo_icon = gtk.EventBox() self.icon = Icon(pixel_size=style.XLARGE_ICON_SIZE) self.icon.props.xo_color = XoColor(self.current_colour) self.icon.props.icon_name = 'computer-xo' self.icon.props.pixel_size = style.XLARGE_ICON_SIZE self.icon.show() self.xo_icon.add(self.icon) self.xo_icon.show() self.colour_picker.pack_start(self.xo_icon) self.canvas.pack_start(self.colour_picker, True, True, 5) self.colour_picker.show() self.canvas.show() self.set_canvas(self.canvas) self.show()
def set_named_icon(self, named_icon): icon = Icon(icon_name=named_icon, xo_color=self._xo_color, icon_size=gtk.ICON_SIZE_LARGE_TOOLBAR) self.set_icon_widget(icon) icon.show()
self._alert = None def __register_activate_cb(self, icon): alert = Alert() try: schoolserver.register_laptop() except RegisterError, e: alert.props.title = _('Registration Failed') alert.props.msg = '%s' % e else: alert.props.title = _('Registration Successful') alert.props.msg = _('You are now registered ' \ 'with your school server.') self._my_icon.set_registered() ok_icon = Icon(icon_name='dialog-ok') alert.add_button(gtk.RESPONSE_OK, _('Ok'), ok_icon) self.add_alert(alert) alert.connect('response', self.__register_alert_response_cb) def __register_alert_response_cb(self, alert, response_id): self.remove_alert() def set_resume_mode(self, resume_mode): self._resume_mode = resume_mode for icon in self._box.get_children(): if hasattr(icon, 'set_resume_mode'): icon.set_resume_mode(self._resume_mode)
def set_icon(self, icon_name): icon = Icon(icon_name=icon_name) self.set_icon_widget(icon) icon.show()
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)
def __init__(self, activity): gtk.Toolbar.__init__(self) self._activity = activity self._updating_share = False """ activity.connect('shared', self.__activity_shared_cb) activity.connect('joined', self.__activity_shared_cb) activity.connect('notify::max_participants', self.__max_participants_changed_cb) """ #if activity.metadata: if True: self.label = gtk.Label(display.menu_journal_label) self.label.show() self._add_widget(self.label) self.title = gtk.Entry() self.title.set_size_request(int(gtk.gdk.screen_width() / 6), -1) if activity.metadata: self.title.set_text(activity.metadata['title']) #activity.metadata.connect('updated', self.__jobject_updated_cb) self.title.connect('changed', self.__title_changed_cb) self.title.connect('activate', self.__update_title_cb) self._add_widget(self.title) fn = os.path.join(os.getcwd(), 'assets', 'stack_new.png') button = ImageButton() tooltip = _("Add Album Stack") button.set_image(fn, tip=tooltip) self.add_album = button self.add_album.show() self.add_album.connect('clicked', self.__add_album_clicked_cb) self.insert(self.add_album, -1) fn = os.path.join(os.getcwd(), 'assets', 'stack_del.png') button = ImageButton() tooltip = _("Delete Album Stack") button.set_image(fn, tip=tooltip) button.connect('clicked', self.__delete_album_clicked_cb) self.insert(button, -1) fn = os.path.join(os.getcwd(), 'assets', 'trash_del.png') button = ImageButton() tooltip = _("Remove Trash Images from XO") button.set_image(fn, tip=tooltip) self.empty_journal_button = button self.empty_journal_button.hide() self.empty_journal_button.connect('clicked', self.__empty_trash_clicked_cb) self.insert(self.empty_journal_button, -1) """ separator = gtk.SeparatorToolItem() separator.props.draw = False separator.set_expand(True) self.insert(separator, -1) separator.show() self.share = ToolComboBox(label_text=_('Traceback:')) self.share.combo.connect('changed', self.__traceback_changed_cb) self.share.combo.append_item("traceback_plain", _('Plain')) self.share.combo.append_item('traceback_context', _('Context')) self.share.combo.append_item('traceback_verbose', _('Verbose')) self.insert(self.share, -1) self.share.show() self._update_share() """ separator = gtk.SeparatorToolItem() separator.props.draw = False separator.set_expand(True) self.insert(separator, -1) separator.show() self.keep = ToolButton() self.keep.set_tooltip(_('Save and Start New')) #client = gconf.client_get_default() #color = XoColor(client.get_string('/desktop/sugar/user/color')) #keep_icon = Icon(icon_name='document-save', xo_color=color) keep_icon = Icon(icon_name='document-save') keep_icon.show() self.keep.set_icon_widget(keep_icon) #self.keep.props.accelerator = '<Ctrl>S' self.keep.connect('clicked', self.__keep_clicked_cb) self.insert(self.keep, -1) self.keep.show() self.stop = ToolButton('activity-stop') self.stop.set_tooltip(_('Stop')) #self.stop.props.accelerator = '<Ctrl>Q' self.stop.connect('clicked', self.__stop_clicked_cb) self.insert(self.stop, -1) self.stop.show() self._update_title_sid = None
def __init__(self, handle): activity.Activity.__init__(self, handle, True) self.max_participants = 1 # CHART_OPTIONS self.x_label = "" self.y_label = "" self.chart_color = utils.get_user_fill_color('str') self.chart_line_color = utils.get_user_stroke_color('str') self.current_chart = None self.charts_area = None self.chart_data = [] # TOOLBARS toolbarbox = ToolbarBox() activity_button = ActivityToolbarButton(self) activity_btn_toolbar = activity_button.page activity_btn_toolbar.title.connect('changed', self._set_chart_title) save_as_image = ToolButton("save-as-image") save_as_image.connect("clicked", self._save_as_image) save_as_image.set_tooltip(_("Save as image")) activity_btn_toolbar.insert(save_as_image, -1) save_as_image.show() import_stopwatch = ToolButton("import-stopwatch") import_stopwatch.connect("clicked", self.__import_stopwatch_cb) import_stopwatch.set_tooltip(_("Read StopWatch data")) activity_btn_toolbar.insert(import_stopwatch, -1) import_stopwatch.show() import_measure = ToolButton("import-measure") import_measure.set_tooltip(_("Read Measure data")) if utils.get_channels() == 1: import_measure.connect("clicked", self.__import_measure_cb, 1) else: import_measure.connect("clicked", self._measure_btn_clicked) self._create_measure_palette(import_measure) activity_btn_toolbar.insert(import_measure, -1) import_measure.show() activity_btn_toolbar.keep.hide() toolbarbox.toolbar.insert(activity_button, 0) add_v = ToolButton("row-insert") add_v.connect("clicked", self._add_value) add_v.set_tooltip(_("Add a value")) toolbarbox.toolbar.insert(add_v, -1) remove_v = ToolButton("row-remove") remove_v.connect("clicked", self._remove_value) remove_v.set_tooltip(_("Remove the selected value")) toolbarbox.toolbar.insert(remove_v, -1) separator = gtk.SeparatorToolItem() separator.set_draw(True) separator.set_expand(False) toolbarbox.toolbar.insert(separator, -1) add_vbar_chart = RadioToolButton() add_vbar_chart.connect("clicked", self._add_chart_cb, "vbar") add_vbar_chart.set_tooltip(_("Vertical Bar Chart")) add_vbar_chart.props.icon_name = "vbar" charts_group = add_vbar_chart toolbarbox.toolbar.insert(add_vbar_chart, -1) add_hbar_chart = RadioToolButton() add_hbar_chart.connect("clicked", self._add_chart_cb, "hbar") add_hbar_chart.set_tooltip(_("Horizontal Bar Chart")) add_hbar_chart.props.icon_name = "hbar" add_hbar_chart.props.group = charts_group toolbarbox.toolbar.insert(add_hbar_chart, -1) add_line_chart = RadioToolButton() add_line_chart.connect("clicked", self._add_chart_cb, "line") add_line_chart.set_tooltip(_("Line Chart")) add_line_chart.props.icon_name = "line" add_line_chart.props.group = charts_group toolbarbox.toolbar.insert(add_line_chart, -1) add_pie_chart = RadioToolButton() add_pie_chart.connect("clicked", self._add_chart_cb, "pie") add_pie_chart.set_tooltip(_("Pie Chart")) add_pie_chart.props.icon_name = "pie" add_pie_chart.props.group = charts_group add_pie_chart.set_active(True) toolbarbox.toolbar.insert(add_pie_chart, -1) self.chart_type_buttons = [ add_vbar_chart, add_hbar_chart, add_line_chart, add_pie_chart ] separator = gtk.SeparatorToolItem() separator.set_draw(True) separator.set_expand(False) toolbarbox.toolbar.insert(separator, -1) options_button = ToolbarButton(icon_name='preferences-system') options_toolbar = gtk.Toolbar() self.chart_color_btn = ColorToolButton() self.chart_color_btn.set_color(_COLOR1) self.chart_color_btn.set_title(_("Chart Color")) self.chart_color_btn.connect('notify::color', self._set_chart_color) options_toolbar.insert(self.chart_color_btn, -1) self.line_color_btn = ColorToolButton() self.line_color_btn.set_color(_COLOR2) self.line_color_btn.set_title(_("Line Color")) self.line_color_btn.connect('notify::color', self._set_chart_line_color) options_toolbar.insert(self.line_color_btn, -1) separator = gtk.SeparatorToolItem() separator.set_draw(True) separator.set_expand(False) options_toolbar.insert(separator, -1) h_label_icon = Icon(icon_name="hlabel") h_label_tool_item = gtk.ToolItem() h_label_tool_item.add(h_label_icon) options_toolbar.insert(h_label_tool_item, -1) self.h_label = Entry(_("Horizontal label...")) self.h_label.entry.connect("changed", self._set_h_label) options_toolbar.insert(self.h_label, -1) separator = gtk.SeparatorToolItem() separator.set_draw(False) separator.set_expand(False) options_toolbar.insert(separator, -1) v_label_icon = Icon(icon_name="vlabel") v_label_tool_item = gtk.ToolItem() v_label_tool_item.add(v_label_icon) options_toolbar.insert(v_label_tool_item, -1) self.v_label = Entry(_("Vertical label...")) self.v_label.entry.connect("changed", self._set_v_label) options_toolbar.insert(self.v_label, -1) options_button.props.page = options_toolbar options_toolbar.show_all() toolbarbox.toolbar.insert(options_button, -1) separator = gtk.SeparatorToolItem() separator.set_draw(True) separator.set_expand(False) toolbarbox.toolbar.insert(separator, -1) fullscreen_btn = ToolButton('view-fullscreen') fullscreen_btn.set_tooltip(_('Fullscreen')) fullscreen_btn.connect("clicked", self.__fullscreen_cb) toolbarbox.toolbar.insert(fullscreen_btn, -1) separator = gtk.SeparatorToolItem() separator.set_draw(False) separator.set_expand(True) toolbarbox.toolbar.insert(separator, -1) simplegraphhelp.create_help(toolbarbox.toolbar) stopbtn = StopButton(self) toolbarbox.toolbar.insert(stopbtn, -1) self.set_toolbar_box(toolbarbox) # CANVAS paned = gtk.HPaned() box = gtk.VBox() self.box = box # Set the info box width to 1/3 of the screen: def size_allocate_cb(widget, allocation): paned.disconnect(self._setup_handle) box_width = allocation.width / 3 box.set_size_request(box_width, -1) self._setup_handle = paned.connect('size_allocate', size_allocate_cb) scroll = gtk.ScrolledWindow() scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self.labels_and_values = ChartData(self) scroll.add(self.labels_and_values) self.labels_and_values.connect("label-changed", self._label_changed) self.labels_and_values.connect("value-changed", self._value_changed) box.pack_start(scroll, True, True, 0) paned.add1(box) # CHARTS AREA eventbox = gtk.EventBox() self.charts_area = ChartArea(self) self.charts_area.connect('size_allocate', self._chart_size_allocate) eventbox.modify_bg(gtk.STATE_NORMAL, _WHITE) eventbox.add(self.charts_area) paned.add2(eventbox) self.set_canvas(paned) self.show_all()
def __init__(self, metadata, detail=False): self._metadata = metadata activity_icon = Icon(icon_size=gtk.ICON_SIZE_LARGE_TOOLBAR) activity_icon.props.file = misc.get_icon_name(metadata) color = misc.get_icon_color(metadata) activity_icon.props.xo_color = color if 'title' in metadata: title = gobject.markup_escape_text(metadata['title']) else: title = glib.markup_escape_text(_('Untitled')) Palette.__init__(self, primary_text=title, icon=activity_icon) if misc.get_activities(metadata) or misc.is_bundle(metadata): if metadata.get('activity_id', ''): resume_label = _('Resume') resume_with_label = _('Resume with') else: resume_label = _('Start') resume_with_label = _('Start with') menu_item = MenuItem(resume_label, 'activity-start') menu_item.connect('activate', self.__start_activate_cb) self.menu.append(menu_item) menu_item.show() menu_item = MenuItem(resume_with_label, 'activity-start') self.menu.append(menu_item) menu_item.show() start_with_menu = StartWithMenu(self._metadata) menu_item.set_submenu(start_with_menu) else: menu_item = MenuItem(_('No activity to start entry')) menu_item.set_sensitive(False) self.menu.append(menu_item) menu_item.show() menu_item = MenuItem(_('Copy to')) icon = Icon(icon_name='edit-copy', xo_color=color, icon_size=gtk.ICON_SIZE_MENU) menu_item.set_image(icon) self.menu.append(menu_item) menu_item.show() copy_menu = CopyMenu(metadata) copy_menu.connect('volume-error', self.__volume_error_cb) menu_item.set_submenu(copy_menu) if self._metadata['mountpoint'] == '/': menu_item = MenuItem(_('Duplicate')) icon = Icon(icon_name='edit-duplicate', xo_color=color, icon_size=gtk.ICON_SIZE_MENU) menu_item.set_image(icon) menu_item.connect('activate', self.__duplicate_activate_cb) self.menu.append(menu_item) menu_item.show() menu_item = MenuItem(_('Send to'), 'document-send') self.menu.append(menu_item) menu_item.show() friends_menu = FriendsMenu() friends_menu.connect('friend-selected', self.__friend_selected_cb) menu_item.set_submenu(friends_menu) if detail == True: menu_item = MenuItem(_('View Details'), 'go-right') menu_item.connect('activate', self.__detail_activate_cb) self.menu.append(menu_item) menu_item.show() menu_item = MenuItem(_('Erase'), 'list-remove') menu_item.connect('activate', self.__erase_activate_cb) self.menu.append(menu_item) menu_item.show()
def __init__(self, title, bundle_path, document_path, sugar_toolkit_path): gtk.Toolbar.__init__(self) document_button = None self.bundle_path = bundle_path self.sugar_toolkit_path = sugar_toolkit_path self._add_separator() activity_bundle = ActivityBundle(bundle_path) file_name = activity_bundle.get_icon() if document_path is not None and os.path.exists(document_path): document_button = DocumentButton(file_name, document_path, title) document_button.connect('toggled', self.__button_toggled_cb, document_path) self.insert(document_button, -1) document_button.show() self._add_separator() if bundle_path is not None and os.path.exists(bundle_path): activity_button = DocumentButton(file_name, bundle_path, title, bundle=True) icon = Icon(file=file_name, icon_size=gtk.ICON_SIZE_LARGE_TOOLBAR, fill_color=style.COLOR_TRANSPARENT.get_svg(), stroke_color=style.COLOR_WHITE.get_svg()) activity_button.set_icon_widget(icon) icon.show() if document_button is not None: activity_button.props.group = document_button activity_button.props.tooltip = _('Activity Bundle Source') activity_button.connect('toggled', self.__button_toggled_cb, bundle_path) self.insert(activity_button, -1) activity_button.show() self._add_separator() if sugar_toolkit_path is not None: sugar_button = RadioToolButton() icon = Icon(icon_name='computer-xo', icon_size=gtk.ICON_SIZE_LARGE_TOOLBAR, fill_color=style.COLOR_TRANSPARENT.get_svg(), stroke_color=style.COLOR_WHITE.get_svg()) sugar_button.set_icon_widget(icon) icon.show() if document_button is not None: sugar_button.props.group = document_button else: sugar_button.props.group = activity_button sugar_button.props.tooltip = _('Sugar Toolkit Source') sugar_button.connect('toggled', self.__button_toggled_cb, sugar_toolkit_path) self.insert(sugar_button, -1) sugar_button.show() self._add_separator() self.activity_title_text = _('View source: %s') % title self.sugar_toolkit_title_text = _('View source: %r') % 'Sugar Toolkit' self.label = gtk.Label() self.label.set_markup('<b>%s</b>' % self.activity_title_text) self.label.set_alignment(0, 0.5) self._add_widget(self.label) self._add_separator(True) stop = ToolButton(icon_name='dialog-cancel') stop.set_tooltip(_('Close')) stop.connect('clicked', self.__stop_clicked_cb) self.insert(stop, -1) stop.show()
def __init__(self, client, event): gtk.Window.__init__(self) self._client = client self._event = event self.set_decorated(False) self.set_position(gtk.WIN_POS_CENTER_ALWAYS) self.set_border_width(style.LINE_WIDTH) window = gtk.VBox() self.add(window) toolbar = gtk.Toolbar() window.pack_start(toolbar, False) icon = Icon() icon.set_from_icon_name('emblem-warning', gtk.ICON_SIZE_LARGE_TOOLBAR) icon.props.xo_color = profile.get_color() tool_item = gtk.ToolItem() tool_item.add(icon) toolbar.insert(tool_item, -1) separator = gtk.SeparatorToolItem() separator.props.draw = False separator.set_size_request(style.DEFAULT_SPACING, -1) toolbar.insert(separator, -1) title = gtk.Label(_('Submit failure report')) tool_item = gtk.ToolItem() tool_item.add(title) toolbar.insert(tool_item, -1) separator = gtk.SeparatorToolItem() separator.props.draw = False separator.set_expand(True) toolbar.insert(separator, -1) submit = ToolButton('dialog-ok', tooltip=_('Submit')) submit.connect('clicked', lambda button: self._submit()) toolbar.insert(submit, -1) cancel = ToolButton('dialog-cancel', tooltip=_('Cancel')) cancel.connect('clicked', lambda button: self.destroy()) toolbar.insert(cancel, -1) bg = gtk.EventBox() bg.modify_bg(gtk.STATE_NORMAL, style.COLOR_WHITE.get_gdk_color()) window.pack_start(bg) canvas = gtk.VBox() canvas.set_border_width(style.DEFAULT_SPACING) canvas.props.spacing = style.DEFAULT_SPACING bg.add(canvas) box = gtk.HBox() box.props.spacing = style.DEFAULT_SPACING canvas.pack_start(box, False) if 'icon' in event: icon = Icon(file=event['icon'], pixel_size=style.XLARGE_ICON_SIZE) else: icon = Icon() icon.set_from_icon_name('emblem-warning', gtk.ICON_SIZE_LARGE_TOOLBAR) box.pack_start(icon, False) label = gtk.Label() label.props.use_markup = True if 'solution' in event: activity_name = '%(name)s-%(version)s' % event['solution'][0] else: activity_name = event['context'] label.props.label = '<b>%s</b>\n%s' % (activity_name, event['error']) label.props.wrap = True box.pack_start(label, False) frame = gtk.Frame( _('Optionally, describe the problem in common sentences')) canvas.pack_start(frame) self._message = gtk.TextView() scrolled = gtk.ScrolledWindow() scrolled.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC) scrolled.set_border_width(style.DEFAULT_PADDING) scrolled.add(self._message) frame.add(scrolled) frame = gtk.Frame(_('Log')) canvas.pack_start(frame) text = gtk.TextView() text.props.editable = False if 'trace' in event: text.props.buffer.props.text = '\n'.join(event['trace']) scrolled = gtk.ScrolledWindow() scrolled.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) scrolled.set_border_width(style.DEFAULT_PADDING) scrolled.add(text) frame.add(scrolled) self.show_all() self.set_focus(self._message) self.connect('realize', self.__realize_cb) gap = style.GRID_CELL_SIZE width = gtk.gdk.screen_width() - gap * 2 height = gtk.gdk.screen_height() - gap * 2 self.set_size_request(width, height) self.move(gap, gap)
def __init__(self, **kwargs): Alert.__init__(self, **kwargs) icon = Icon(icon_name='dialog-ok') self.add_button(gtk.RESPONSE_OK, _('Ok'), icon) icon.show()
def __init__(self, metadata, icon, edit_menu=True): self._metadata = metadata self._temp_file_path = None activity_icon = gtk.Image() activity_icon.props.pixbuf = icon title = metadata.get('title') or _('Untitled') Palette.__init__(self, primary_text=title, icon=activity_icon) bundles = port.shell.get_bundles_by_metadata(self._metadata) if bundles: start_bundle = None if metadata.get('activity'): resume_label = _('Resume') start_bundle = port.shell.get_bundle(metadata.get('activity')) else: resume_label = _('Start') bundle_id = model.this['viewers'].get( metadata.get('mime_type')) if bundle_id: start_bundle = port.shell.get_bundle(bundle_id) if start_bundle: menu_icon = Icon(file=start_bundle.get_icon(), icon_size=gtk.ICON_SIZE_MENU) else: menu_icon = Icon(icon_name='activity-start', icon_size=gtk.ICON_SIZE_MENU) menu_item = MenuItem(resume_label) menu_item.set_image(menu_icon) menu_item.connect('activate', self._resume_cb) self.menu.append(menu_item) menu_item.show() self.resum_bundle_id = start_bundle and start_bundle.get_bundle_id( ) self.resum_item = menu_item menu_item = gtk.SeparatorMenuItem() self.menu.append(menu_item) menu_item.show() for i in bundles: menu_item = MenuItem(i.get_name()) menu_item.set_image( Icon(file=i.get_icon(), icon_size=gtk.ICON_SIZE_MENU)) menu_item.connect('activate', self._start_cb, metadata.get('mime_type'), i) self.menu.append(menu_item) menu_item.show() if edit_menu: menu_item = gtk.SeparatorMenuItem() self.menu.append(menu_item) menu_item.show() if edit_menu: menu_item = MenuItem(_('View Details'), 'go-right') menu_item.connect('activate', self._detail_cb) self.menu.append(menu_item) menu_item.show()