def _setup_toolbars(self, have_toolbox): """ Setup the toolbars. """ self.max_participants = MAX_HANDS if have_toolbox: toolbox = ToolbarBox() # Activity toolbar activity_button = ActivityToolbarButton(self) toolbox.toolbar.insert(activity_button, 0) activity_button.show() self.set_toolbar_box(toolbox) toolbox.show() self.toolbar = toolbox.toolbar else: # Use pre-0.86 toolbar design games_toolbar = gtk.Toolbar() toolbox = activity.ActivityToolbox(self) self.set_toolbox(toolbox) toolbox.add_toolbar(_('Game'), games_toolbar) toolbox.show() toolbox.set_current_toolbar(1) self.toolbar = games_toolbar self._new_game_button = _button_factory( 'new-game', _('Start a new game.'), self._new_game_cb, self.toolbar) self.robot_button = _button_factory( 'robot-off', _('Play with the robot.'), self._robot_cb, self.toolbar) self.player = _image_factory( svg_str_to_pixbuf(generate_xo(scale=0.8, colors=['#303030', '#303030'])), self.toolbar, tooltip=self.nick) self.dialog_button = _button_factory('go-next', _('Turn complete'), self._dialog_cb, self.toolbar) self.status = _label_factory('', self.toolbar) self.hint_button = _button_factory('help-toolbar', _('Help'), self._hint_cb, self.toolbar) self.score = _label_factory(_('Score: ') + '0', self.toolbar) if _have_toolbox: _separator_factory(toolbox.toolbar, False, True) stop_button = StopButton(self) stop_button.props.accelerator = '<Ctrl>q' toolbox.toolbar.insert(stop_button, -1) stop_button.show()
def __init__(self, handle): activity.Activity.__init__(self, handle) self._name = handle self.num = mynum.Numbers() if NEW_TOOLBARS: toolbar_box = ToolbarBox() separator = gtk.SeparatorToolItem() separator.props.draw = False separator.set_expand(True) toolbar_box.toolbar.insert(separator, -1) separator.show() stop_button = StopButton(self) stop_button.props.accelerator = '<Ctrl><Shift>Q' toolbar_box.toolbar.insert(stop_button, -1) stop_button.show() self.set_toolbar_box(toolbar_box) toolbar_box.show() else: toolbox = ActivityToolbox(self) self.set_toolbox(toolbox) toolbox.show() if self.num.widget.parent: self.num.widget.parent.remove(self.num.widget) self.num.widget.show() self.set_canvas(self.num.widget) self.show_all() self.num.setActivity(self)
def build_toolbar(self): self.max_participants = 1 toolbar_box = ToolbarBox() self.set_toolbar_box(toolbar_box) toolbar_box.show() activity_button = ActivityToolbarButton(self) toolbar_box.toolbar.insert(activity_button, -1) activity_button.show() separator = gtk.SeparatorToolItem() separator.props.draw = False separator.set_expand(True) toolbar_box.toolbar.insert(separator, -1) separator.show() self.create_help(toolbar_box.toolbar) stop_button = StopButton(self) toolbar_box.toolbar.insert(stop_button, -1) stop_button.show() self.show_all()
def build_toolbar(self): toolbar_box = ToolbarBox() self.set_toolbar_box(toolbar_box) toolbar_box.show() activity_button = ActivityToolbarButton(self) toolbar_box.toolbar.insert(activity_button, -1) activity_button.show() separator = gtk.SeparatorToolItem() separator.props.draw = False separator.set_expand(False) toolbar_box.toolbar.insert(separator, -1) separator.show() button = ToolButton('speaker-muted-100') button.set_tooltip(_('Sound')) button.connect('clicked', self.sound_control) toolbar_box.toolbar.insert(button, -1) separator = gtk.SeparatorToolItem() separator.props.draw = False separator.set_expand(True) toolbar_box.toolbar.insert(separator, -1) separator.show() stop_button = StopButton(self) toolbar_box.toolbar.insert(stop_button, -1) stop_button.show() self.show_all()
def __init__(self, handle): """Set up the HelloWorld activity.""" activity.Activity.__init__(self, handle) # toolbar with the new toolbar redesign toolbar_box = ToolbarBox() activity_button = ActivityButton(self) toolbar_box.toolbar.insert(activity_button, 0) activity_button.show() title_entry = TitleEntry(self) toolbar_box.toolbar.insert(title_entry, -1) title_entry.show() separator = gtk.SeparatorToolItem() separator.props.draw = False separator.set_expand(True) toolbar_box.toolbar.insert(separator, -1) separator.show() stop_button = StopButton(self) toolbar_box.toolbar.insert(stop_button, -1) stop_button.show() self.set_toolbar_box(toolbar_box) toolbar_box.show() self.load_data() self.cargar_ui()
def _setup_toolbars(self, have_toolbox): """ Setup the toolbars. """ self.max_participants = MAX_HANDS if have_toolbox: toolbox = ToolbarBox() # Activity toolbar activity_button = ActivityToolbarButton(self) toolbox.toolbar.insert(activity_button, 0) activity_button.show() self.set_toolbar_box(toolbox) toolbox.show() self.toolbar = toolbox.toolbar else: # Use pre-0.86 toolbar design games_toolbar = gtk.Toolbar() toolbox = activity.ActivityToolbox(self) self.set_toolbox(toolbox) toolbox.add_toolbar(_('Game'), games_toolbar) toolbox.show() toolbox.set_current_toolbar(1) self.toolbar = games_toolbar self._new_game_button = button_factory( 'new-game', self.toolbar, self._new_game_cb, tooltip=_('Start a new game.')) self.robot_button = button_factory( 'robot-off', self.toolbar, self._robot_cb, tooltip= _('Play with the robot.')) self.player = image_factory( svg_str_to_pixbuf(generate_xo(scale=0.8, colors=['#303030', '#303030'])), self.toolbar, tooltip=self.nick) self.dialog_button = button_factory( 'go-next', self.toolbar, self._dialog_cb, tooltip=_('Turn complete')) self.status = label_factory(self.toolbar, '') self.hint_button = button_factory( 'help-toolbar', self.toolbar, self._hint_cb, tooltip=_('Help')) self.score = label_factory(self.toolbar, _('Score: ') + '0') if _have_toolbox: separator_factory(toolbox.toolbar, True, False) stop_button = StopButton(self) stop_button.props.accelerator = '<Ctrl>q' toolbox.toolbar.insert(stop_button, -1) stop_button.show()
def build_toolbar(self): toolbox = ToolbarBox() activity_button = ActivityToolbarButton(self) toolbox.toolbar.insert(activity_button, -1) activity_button.show() self.build_calibrate_toolbar(toolbox) self.build_options_toolbar(toolbox) self.build_resolution_toolbar(toolbox) self.build_colors_toolbar(toolbox) separador13 = gtk.SeparatorToolItem() separador13.props.draw = False separador13.set_expand(True) toolbox.toolbar.insert(separador13, -1) stop_button = StopButton(self) stop_button.props.accelerator = _('<Ctrl>Q') toolbox.toolbar.insert(stop_button, -1) stop_button.show() self.set_toolbox(toolbox) toolbox.show() self.show_all()
def setup_toolbar(self): '''Setup the top toolbar. Groupthink needs some work here.''' toolbar_box = ToolbarBox() activity_button = ActivityToolbarButton(self) toolbar_box.toolbar.insert(activity_button, 0) activity_button.show() self.edit_toolbar = EditToolbar() edit_toolbar_button = ToolbarButton(page=self.edit_toolbar, icon_name='toolbar-edit') self.edit_toolbar.show() toolbar_box.toolbar.insert(edit_toolbar_button, -1) edit_toolbar_button.show() self.edit_toolbar.undo.connect('clicked', self.undobutton_cb) self.edit_toolbar.redo.connect('clicked', self.redobutton_cb) self.edit_toolbar.copy.connect('clicked', self.copybutton_cb) self.edit_toolbar.paste.connect('clicked', self.pastebutton_cb) separator = gtk.SeparatorToolItem() separator.props.draw = False separator.set_expand(True) toolbar_box.toolbar.insert(separator, -1) separator.show() stop_button = StopButton(self) stop_button.props.accelerator = '<Ctrl><Shift>Q' toolbar_box.toolbar.insert(stop_button, -1) stop_button.show() self.set_toolbar_box(toolbar_box) toolbar_box.show()
def build_toolbar(self): toolbar_box = ToolbarBox() self.set_toolbar_box(toolbar_box) toolbar_box.show() activity_button = ActivityToolbarButton(self) toolbar_box.toolbar.insert(activity_button, -1) activity_button.show() # Pause/Play button: stop_play = ToolButton('media-playback-stop') stop_play.set_tooltip(_("Stop")) stop_play.set_accelerator(_('<ctrl>space')) stop_play.connect('clicked', self._stop_play_cb) stop_play.show() toolbar_box.toolbar.insert(stop_play, -1) # Blank space (separator) and Stop button at the end: separator = gtk.SeparatorToolItem() separator.props.draw = False separator.set_expand(True) toolbar_box.toolbar.insert(separator, -1) separator.show() stop_button = StopButton(self) toolbar_box.toolbar.insert(stop_button, -1) stop_button.show()
def _configure_toolbars(self): if _USE_OLD_TOOLBARS: toolbox = ActivityToolbox(self) toolbar = gtk.Toolbar() else: toolbar_box = ToolbarBox() toolbar = toolbar_box.toolbar activity_button = ActivityToolbarButton(self) toolbar_box.toolbar.insert(activity_button, 0) activity_button.show() self._add_expander(toolbar_box.toolbar) toolbar.add(gtk.SeparatorToolItem()) if _USE_OLD_TOOLBARS: self.set_toolbox(toolbox) toolbox.show() else: stop_button = StopButton(self) stop_button.props.accelerator = '<Ctrl><Shift>Q' toolbar_box.toolbar.insert(stop_button, -1) stop_button.show() self.set_toolbar_box(toolbar_box) toolbar_box.show()
def build_toolbar(self): toolbar_box = ToolbarBox() self.set_toolbar_box(toolbar_box) toolbar_box.show() activity_button = ActivityToolbarButton(self) toolbar_box.toolbar.insert(activity_button, -1) activity_button.show() self.blocklist = [] self.radioList = {} for c in tools.allTools: button = ToolButton(c.icon) button.set_tooltip(_(c.toolTip)) button.connect('clicked',self.radioClicked) toolbar_box.toolbar.insert(button, -1) button.show() self.radioList[button] = c.name separator = gtk.SeparatorToolItem() separator.props.draw = False separator.set_expand(True) toolbar_box.toolbar.insert(separator, -1) separator.show() stop_button = StopButton(self) toolbar_box.toolbar.insert(stop_button, -1) stop_button.show() self.show_all()
def build_toolbar(self): toolbar_box = ToolbarBox() self.set_toolbar_box(toolbar_box) toolbar_box.show() activity_button = ActivityToolbarButton(self) toolbar_box.toolbar.insert(activity_button, -1) activity_button.show() separator1 = gtk.SeparatorToolItem() separator1.props.draw = True separator1.set_expand(False) toolbar_box.toolbar.insert(separator1, -1) separator1.show() item1 = gtk.ToolItem() label1 = gtk.Label() label1.set_text(_('Levels') + ' ') item1.add(label1) toolbar_box.toolbar.insert(item1, -1) item2 = gtk.ToolItem() levels = (_('Cross'), _('Cross 2'), #TRANS:'chimney' - the place where you make fire _('Hearth'), _('Arrow'), _('Pyramid'), _('Diamond'), _('Solitaire')) combo = Combo(levels) item2.add(combo) combo.connect('changed', self.change_combo) toolbar_box.toolbar.insert(item2, -1) separator2 = gtk.SeparatorToolItem() separator2.props.draw = True separator2.set_expand(False) toolbar_box.toolbar.insert(separator2, -1) separator2.show() sound_button = ToolButton('speaker-muted-100') sound_button.set_tooltip(_('Sound')) sound_button.connect('clicked', self.sound_control) toolbar_box.toolbar.insert(sound_button, -1) separator3 = gtk.SeparatorToolItem() separator3.props.draw = False separator3.set_expand(True) toolbar_box.toolbar.insert(separator3, -1) separator3.show() stop_button = StopButton(self) toolbar_box.toolbar.insert(stop_button, -1) stop_button.show() self.show_all()
def build_toolbar(self): toolbar_box = ToolbarBox() self.set_toolbar_box(toolbar_box) toolbar_box.show() activity_button = ActivityToolbarButton(self) toolbar_box.toolbar.insert(activity_button, -1) activity_button.show() separator1 = gtk.SeparatorToolItem() separator1.props.draw = True separator1.set_expand(False) toolbar_box.toolbar.insert(separator1, -1) separator1.show() item1 = gtk.ToolItem() label1 = gtk.Label() label1.set_text(_('Levels') + ' ') item1.add(label1) toolbar_box.toolbar.insert(item1, -1) item2 = gtk.ToolItem() levels = ( _('Cross'), _('Cross 2'), #TRANS:'chimney' - the place where you make fire _('Hearth'), _('Arrow'), _('Pyramid'), _('Diamond'), _('Solitaire')) combo = Combo(levels) item2.add(combo) combo.connect('changed', self.change_combo) toolbar_box.toolbar.insert(item2, -1) separator2 = gtk.SeparatorToolItem() separator2.props.draw = True separator2.set_expand(False) toolbar_box.toolbar.insert(separator2, -1) separator2.show() sound_button = ToolButton('speaker-muted-100') sound_button.set_tooltip(_('Sound')) sound_button.connect('clicked', self.sound_control) toolbar_box.toolbar.insert(sound_button, -1) separator3 = gtk.SeparatorToolItem() separator3.props.draw = False separator3.set_expand(True) toolbar_box.toolbar.insert(separator3, -1) separator3.show() stop_button = StopButton(self) toolbar_box.toolbar.insert(stop_button, -1) stop_button.show() self.show_all()
def _setup_toolbars(self, have_toolbox): """ Setup the toolbars.. """ if have_toolbox: toolbox = ToolbarBox() # Activity toolbar activity_button = ActivityToolbarButton(self) toolbox.toolbar.insert(activity_button, 0) activity_button.show() self.set_toolbar_box(toolbox) toolbox.show() toolbar = toolbox.toolbar else: # Use pre-0.86 toolbar design games_toolbar = gtk.Toolbar() toolbox = activity.ActivityToolbox(self) self.set_toolbox(toolbox) toolbox.add_toolbar(_('Game'), games_toolbar) toolbox.show() toolbox.set_current_toolbar(1) toolbar = games_toolbar # Add the buttons and labels to the toolbars self.level_button = button_factory( LEVEL_ICONS[self._play_level], toolbar, self.change_play_level_cb, tooltip=_('Set difficulty level.')) mode = self._play_mode mode += 1 if mode == len(GAME_ICONS): mode = 0 self.game_buttons = [] for i in range(len(GAME_ICONS)): if i==0: self.game_buttons.append(radio_factory( GAME_ICONS[0], toolbar, self.change_play_mode_cb, cb_arg=0, tooltip=_('Select game.'), group=None)) else: self.game_buttons.append(radio_factory( GAME_ICONS[i], toolbar, self.change_play_mode_cb, cb_arg=i, tooltip=_('Select game.'), group=self.game_buttons[0])) self.game_buttons[mode].set_active(True) separator_factory(toolbar, False, True) self.status_label = label_factory(toolbar, _("drag to swap")) if _have_toolbox: separator_factory(toolbox.toolbar, True, False) stop_button = StopButton(self) stop_button.props.accelerator = '<Ctrl>q' toolbox.toolbar.insert(stop_button, -1) stop_button.show()
def __init__(self, handle): activity.Activity.__init__(self, handle) toolbar_box = ToolbarBox() activity_button = ActivityToolbarButton(self) toolbar_box.toolbar.insert(activity_button, 0) activity_button.show() separator = gtk.SeparatorToolItem() separator.props.draw = False separator.set_expand(True) toolbar_box.toolbar.insert(separator, -1) separator.show() change_color_button = ToolButton('toolbar-colors') change_color_button.set_tooltip(_('Click here to change the background color')) change_color_button.connect('clicked', self.on_change_color_clicked) toolbar_box.toolbar.insert(change_color_button, -1) change_color_button.show() separator = gtk.SeparatorToolItem() separator.props.draw = False separator.set_expand(True) toolbar_box.toolbar.insert(separator, -1) separator.show() stop_button = StopButton(self) stop_button.props.accelerator = '<Ctrl><Shift>Q' toolbar_box.toolbar.insert(stop_button, -1) stop_button.show() button = gtk.Button("Click here to change the background color") button.connect('clicked', self.on_change_color_clicked) button.set_flags(gtk.CAN_DEFAULT) button.grab_default() toolbar_box.add(button) button.show() self.set_toolbar_box(toolbar_box) toolbar_box.show() canvas = gtk.HBox(False, 0) color = gtk.gdk.color_parse("skyblue") self.d_area = gtk.DrawingArea() self.d_area.connect("expose-event", self.expose) self.d_area.modify_bg(gtk.STATE_NORMAL, color) canvas.add(self.d_area) self.set_canvas(canvas) self.show_all()
def build_toolbar(self): """Build our Activity toolbar for the Sugar system This is a customisation point for those games which want to provide custom toolbars when running under Sugar. """ try: from sugar.graphics.toolbarbox import ToolbarBox, ToolbarButton from sugar.activity.widgets import ActivityToolbarButton, StopButton, \ ShareButton, KeepButton from mybutton import MyActivityToolbarButton toolbar_box = ToolbarBox() activity_button = MyActivityToolbarButton(self) toolbar_box.toolbar.insert(activity_button, 0) activity_button.show() separator = gtk.SeparatorToolItem() separator.props.draw = False separator.set_expand(True) toolbar_box.toolbar.insert(separator, -1) separator.show() share_button = ShareButton(self) toolbar_box.toolbar.insert(share_button, -1) share_button.show() keep_button = KeepButton(self) toolbar_box.toolbar.insert(keep_button, -1) keep_button.show() stop_button = StopButton(self) stop_button.props.accelerator = '<Ctrl><Shift>Q' toolbar_box.toolbar.insert(stop_button, -1) stop_button.show() self.set_toolbar_box(toolbar_box) toolbar_box.show() toolbar = toolbar_box.toolbar except ImportError: toolbar = activity.ActivityToolbar(self) toolbar.show() self.set_toolbox(toolbar) toolbar.title.unset_flags(gtk.CAN_FOCUS) def shared_cb(*args, **kwargs): log.info('shared: %s, %s', args, kwargs) try: mesh.activity_shared(self) except Exception, err: log.error( """Failure signaling activity sharing to mesh module: %s""", util.get_traceback(err)) else:
def __init__(self, handle): """Set up the HelloWorld activity.""" activity.Activity.__init__(self, handle) # we do not have collaboration features # make the share option insensitive self.max_participants = 1 # toolbar with the new toolbar redesign toolbar_box = ToolbarBox() activity_button = ActivityButton(self) toolbar_box.toolbar.insert(activity_button, 0) activity_button.show() title_entry = TitleEntry(self) toolbar_box.toolbar.insert(title_entry, -1) title_entry.show() share_button = ShareButton(self) toolbar_box.toolbar.insert(share_button, -1) share_button.show() separator = gtk.SeparatorToolItem() separator.props.draw = False separator.set_expand(True) toolbar_box.toolbar.insert(separator, -1) separator.show() stop_button = StopButton(self) toolbar_box.toolbar.insert(stop_button, -1) stop_button.show() self.set_toolbar_box(toolbar_box) toolbar_box.show() # advanced example widgets vbox = gtk.VBox() self.label = gtk.Label() self.entry = gtk.Entry() self.text = gtk.TextView() vbox.add(self.label) vbox.add(self.entry) vbox.add(self.text) self.set_canvas(vbox) vbox.show_all() self._logging_example() self._i18n_example()
def __init__(self, handle): activity.Activity.__init__(self, handle) self.max_participants = 1 toolbar_box = ToolbarBox() activity_button = ActivityToolbarButton(self) toolbar_box.toolbar.insert(activity_button, 0) activity_button.show() jugarc_button = ToolButton('chico') jugarc_button.set_tooltip(('Jugar el juego en pantalla chica')) jugarc_button.connect('clicked', self._jugar_chico) toolbar_box.toolbar.insert(jugarc_button, -1) jugarc_button.show jugarm_button = ToolButton('mediano') jugarm_button.set_tooltip(('Jugar el juego en pantalla mediana')) jugarm_button.connect('clicked', self._jugar_mediano) toolbar_box.toolbar.insert(jugarm_button, -1) jugarm_button.show jugarg_button = ToolButton('grande') jugarg_button.set_tooltip(('Jugar el juego en pantalla grande')) jugarg_button.connect('clicked', self._jugar_grande) toolbar_box.toolbar.insert(jugarg_button, -1) jugarg_button.show separator = gtk.SeparatorToolItem() separator.props.draw = False separator.set_expand(True) toolbar_box.toolbar.insert(separator, -1) separator.show() self.create_help(toolbar_box.toolbar) self.set_toolbar_box(toolbar_box) toolbar_box.show() self._update_accelerators(toolbar_box) self._filechooser = gtk.FileChooserWidget(\ action=gtk.FILE_CHOOSER_ACTION_OPEN,backend=None) self._filechooser.set_current_folder("/") self.botonJugar = gtk.Button("Jugar rom") self.botonJugar.connect('clicked', self._jugar_mediano) self.botonJugar.show() self._filechooser.set_extra_widget(self.botonJugar) self.set_canvas(self._filechooser) self.show_all()
def build_toolbar(self): toolbox = ToolbarBox() activity_button = ActivityToolbarButton(self) toolbox.toolbar.insert(activity_button, -1) activity_button.show() separator = gtk.SeparatorToolItem() separator.props.draw = False separator.set_expand(True) toolbox.toolbar.insert(separator, -1) separator.show() stop_button = StopButton(self) toolbox.toolbar.insert(stop_button, -1) stop_button.show() self.set_toolbox(toolbox) toolbox.show()
def __init__(self, handle): activity.Activity.__init__(self, handle) self.max_participants = 10 # toolbar with the new toolbar redesign toolbar_box = ToolbarBox() activity_button = ActivityButton(self) toolbar_box.toolbar.insert(activity_button, 0) activity_button.show() title_entry = TitleEntry(self) toolbar_box.toolbar.insert(title_entry, -1) title_entry.show() share_button = ShareButton(self) toolbar_box.toolbar.insert(share_button, -1) share_button.show() stop_button = StopButton(self) toolbar_box.toolbar.insert(stop_button, -1) stop_button.show() self.back_button = BackButton() self.back_button.connect('clicked', self.show_options1) toolbar_box.toolbar.insert(self.back_button, 0) self.back_button.show() self.set_toolbar_box(toolbar_box) toolbar_box.show() self.show_options() self._logger = logging.getLogger('hellomesh-activity') self.hellotube = None # Shared session self.initiating = False # get the Presence Service self.pservice = presenceservice.get_instance() # Buddy object for you owner = self.pservice.get_owner() self.owner = owner self.connect('shared', self._shared_cb) self.connect('joined', self._joined_cb)
def __init__(self, handle): activity.Activity.__init__(self, handle) self.max_participants = 10 # toolbar with the new toolbar redesign toolbar_box = ToolbarBox() activity_button = ActivityButton(self) toolbar_box.toolbar.insert(activity_button, 0) activity_button.show() title_entry = TitleEntry(self) toolbar_box.toolbar.insert(title_entry, -1) title_entry.show() share_button = ShareButton(self) toolbar_box.toolbar.insert(share_button, -1) share_button.show() stop_button = StopButton(self) toolbar_box.toolbar.insert(stop_button, -1) stop_button.show() self.back_button = BackButton() self.back_button.connect("clicked", self.show_options1) toolbar_box.toolbar.insert(self.back_button, 0) self.back_button.show() self.set_toolbar_box(toolbar_box) toolbar_box.show() self.show_options() self._logger = logging.getLogger("hellomesh-activity") self.hellotube = None # Shared session self.initiating = False # get the Presence Service self.pservice = presenceservice.get_instance() # Buddy object for you owner = self.pservice.get_owner() self.owner = owner self.connect("shared", self._shared_cb) self.connect("joined", self._joined_cb)
def __init__(self, handle): """Set up the Pilas activity.""" activity.Activity.__init__(self, handle) # we do not have collaboration features, # make the share option insensitive self.max_participants = 1 # toolbar with the new toolbar redesign toolbar_box = ToolbarBox() activity_button = ActivityButton(self) toolbar_box.toolbar.insert(activity_button, 0) activity_button.show() title_entry = TitleEntry(self) toolbar_box.toolbar.insert(title_entry, -1) title_entry.show() share_button = ShareButton(self) toolbar_box.toolbar.insert(share_button, -1) share_button.show() separator = gtk.SeparatorToolItem() separator.props.draw = False separator.set_expand(True) toolbar_box.toolbar.insert(separator, -1) separator.show() stop_button = StopButton(self) toolbar_box.toolbar.insert(stop_button, -1) stop_button.show() self.set_toolbar_box(toolbar_box) toolbar_box.show() socket = gtk.Socket() socket.connect("plug-added", self._on_plugged_event) socket.set_flags(gtk.CAN_FOCUS) self.set_canvas(socket) self.set_focus(socket) socket.show() screen_width = gtk.gdk.screen_width() screen_height = gtk.gdk.screen_height() Popen(["python", "pilas_plug.py", str(socket.get_id()), str(screen_width), str(screen_height)], env=new_env)
def build_toolbar(self): self.max_participants = 1 toolbar_box = ToolbarBox() self.set_toolbar_box(toolbar_box) toolbar_box.show() activity_button = ActivityToolbarButton(self) toolbar_box.toolbar.insert(activity_button, -1) activity_button.show() # toolbars self.build_size_toolbar(toolbar_box) self.build_colors_toolbar(toolbar_box) separator = gtk.SeparatorToolItem() toolbar_box.toolbar.insert(separator, -1) separator.show() #current item = gtk.ToolItem() label = gtk.Label() label.set_text(' %s ' % _('Current player:')) item.add(label) toolbar_box.toolbar.insert(item, -1) #player item = gtk.ToolItem() self.current_label = gtk.Label() self.current_label.set_text(' %s ' % _('Player 1')) item.add(self.current_label) toolbar_box.toolbar.insert(item, -1) # end separator separator = gtk.SeparatorToolItem() separator.props.draw = False separator.set_expand(True) toolbar_box.toolbar.insert(separator, -1) separator.show() stop_button = StopButton(self) toolbar_box.toolbar.insert(stop_button, -1) stop_button.show() self.show_all()
def build_toolbar(self): try: # Use new >= 0.86 toolbar self.max_participants = 1 toolbar_box = ToolbarBox() activity_button = ActivityToolbarButton(self) toolbar_box.toolbar.insert(activity_button, 0) activity_button.show() separator = gtk.SeparatorToolItem() toolbar_box.toolbar.insert(separator, -1) separator.show() self._insert_create_tools(toolbar_box.toolbar) separator = gtk.SeparatorToolItem() separator.props.draw = False separator.set_size_request(0, -1) separator.set_expand(True) toolbar_box.toolbar.insert(separator, -1) separator.show() stop_button = StopButton(self) toolbar_box.toolbar.insert(stop_button, -1) stop_button.show() self.set_toolbar_box(toolbar_box) toolbar_box.show() return toolbar_box except NameError: # Use old <= 0.84 toolbar design toolbox = activity.ActivityToolbox(self) activity_toolbar = toolbox.get_activity_toolbar() activity_toolbar.share.props.visible = False create_toolbar = gtk.Toolbar() self._insert_create_tools(create_toolbar) toolbox.add_toolbar(_("Create"), create_toolbar) create_toolbar.show() toolbox.set_current_toolbar(1) toolbox.show() self.set_toolbox(toolbox) return activity_toolbar
def __init__(self, handle): """Set up the Expresar activity.""" activity.Activity.__init__(self, handle) # toolbar with the new toolbar redesign toolbar_box = ToolbarBox() activity_button = ActivityButton(self) toolbar_box.toolbar.insert(activity_button, 0) activity_button.show() title_entry = TitleEntry(self) toolbar_box.toolbar.insert(title_entry, -1) title_entry.show() separator = gtk.SeparatorToolItem() separator.props.draw = False separator.set_expand(True) toolbar_box.toolbar.insert(separator, -1) separator.show() stop_button = StopButton(self) toolbar_box.toolbar.insert(stop_button, -1) stop_button.show() self.set_toolbar_box(toolbar_box) toolbar_box.show() self._pressButton_counter = 0 self.listaSecciones = [] parsear(self.listaSecciones) self.lenghtSecciones = int(math.sqrt(len(self.listaSecciones))) self.hbox = gtk.HBox() self.table = gtk.Table(LENGHT, LENGHT, True) self.indiceSecciones = 0 self.create_interior(self.table, self.listaSecciones) self.set_canvas(self.hbox) self.hbox.show() self._button_index = 0 self._button_index_2 = 0 self._indice = 0 self._button_list = [] gobject.timeout_add(DELAY, self.__timeout_cb, self.table)
def build_toolbar(self): self.max_participants = 1 toolbar_box = ToolbarBox() self.set_toolbar_box(toolbar_box) toolbar_box.show() activity_button = ActivityToolbarButton(self) toolbar_box.toolbar.insert(activity_button, -1) activity_button.show() # new pic button new_pic = ToolButton('new-pic') new_pic.connect('clicked', self._new_picture) new_pic.set_tooltip(_('New picture')) toolbar_box.toolbar.insert(new_pic, -1) # add / remove point buttons add_point = ToolButton("row-insert") add_point.connect("clicked", self._add_point) add_point.set_tooltip(_("Add a point")) toolbar_box.toolbar.insert(add_point, -1) rem_point = ToolButton("row-remove") rem_point.connect("clicked", self._remove_point) rem_point.set_tooltip(_("Remove the selected point")) toolbar_box.toolbar.insert(rem_point, -1) # save list button save = ToolButton('filesave') save.connect('clicked', self._save) save.set_tooltip(_('Save data')) toolbar_box.toolbar.insert(save, -1) # separator and stop button separator = gtk.SeparatorToolItem() separator.props.draw = False separator.set_expand(True) toolbar_box.toolbar.insert(separator, -1) separator.show() stop_button = StopButton(self) toolbar_box.toolbar.insert(stop_button, -1) stop_button.show()
def __init__(self, handle): """Set up the HelloWorld activity.""" activity.Activity.__init__(self, handle) # we do not have collaboration features # make the share option insensitive self.max_participants = 1 # toolbar with the new toolbar redesign toolbar_box = ToolbarBox() activity_button = ActivityButton(self) toolbar_box.toolbar.insert(activity_button, 0) activity_button.show() title_entry = TitleEntry(self) toolbar_box.toolbar.insert(title_entry, -1) title_entry.show() share_button = ShareButton(self) toolbar_box.toolbar.insert(share_button, -1) share_button.show() separator = gtk.SeparatorToolItem() separator.props.draw = False separator.set_expand(True) toolbar_box.toolbar.insert(separator, -1) separator.show() stop_button = StopButton(self) toolbar_box.toolbar.insert(stop_button, -1) stop_button.show() self.set_toolbar_box(toolbar_box) toolbar_box.show() # label with the text, make the string translatable self.ser = serial.Serial('/dev/ttyACM0', 9600) hbox = gtk.HBox()
def build_toolbar(self): toolbar_box = ToolbarBox() toolbar_box.show() activity_button = ActivityToolbarButton(self) toolbar_box.toolbar.insert(activity_button, -1) activity_button.show() separator = gtk.SeparatorToolItem() separator.props.draw = False separator.set_expand(True) toolbar_box.toolbar.insert(separator, -1) stop_button = StopButton(self) toolbar_box.toolbar.insert(stop_button, -1) stop_button.show() self.set_toolbar_box(toolbar_box) toolbar_box.show_all()
def __init__(self, handle): """Set up the HelloWorld activity.""" activity.Activity.__init__(self, handle) # we do not have collaboration features # make the share option insensitive self.max_participants = 1 # toolbar with the new toolbar redesign toolbar_box = ToolbarBox() activity_button = ActivityButton(self) toolbar_box.toolbar.insert(activity_button, 0) activity_button.show() title_entry = TitleEntry(self) toolbar_box.toolbar.insert(title_entry, -1) title_entry.show() share_button = ShareButton(self) toolbar_box.toolbar.insert(share_button, -1) share_button.show() separator = gtk.SeparatorToolItem() separator.props.draw = False separator.set_expand(True) toolbar_box.toolbar.insert(separator, -1) separator.show() stop_button = StopButton(self) toolbar_box.toolbar.insert(stop_button, -1) stop_button.show() self.set_toolbar_box(toolbar_box) toolbar_box.show() # label with the text, make the string translatable #label = gtk.Label(_("Hello World!")) main = Main() self.set_canvas(main) main.show()
def __init__(self, handle): """Set up the ActivityTemplate activity.""" activity.Activity.__init__(self, handle) # we do not have collaboration features # make the share option insensitive self.max_participants = 1 # toolbar with the new toolbar redesign toolbar_box = ToolbarBox() activity_button = ActivityButton(self) toolbar_box.toolbar.insert(activity_button, 0) activity_button.show() title_entry = TitleEntry(self) toolbar_box.toolbar.insert(title_entry, -1) title_entry.show() share_button = ShareButton(self) toolbar_box.toolbar.insert(share_button, -1) share_button.show() separator = gtk.SeparatorToolItem() separator.props.draw = False separator.set_expand(True) toolbar_box.toolbar.insert(separator, -1) separator.show() stop_button = StopButton(self) toolbar_box.toolbar.insert(stop_button, -1) stop_button.show() self.set_toolbar_box(toolbar_box) toolbar_box.show() # Code changes made by glucosa team, the three lines # makes the game graphic area. self.game = Game() self.set_canvas(self.game.canvas) self.game.canvas.show()
def add_line2(self): self.line = gtk.HBox() self.label = gtk.Label(_("sugar.activity.widgets.ActivityButton()")) self.line.add(self.label) self.label.show() toolbar_box1 = ToolbarBox() self.line.add(toolbar_box1) toolbar_box1.show() activity_button1 = ActivityButton(self) toolbar_box1.toolbar.insert(activity_button1, 0) activity_button1.show() self.label1 = gtk.Label(_("Some Description")) self.line.add(self.label1) self.label1.show() self.container.add(self.line) self.line.show()
def add_line8(self): self.line = gtk.HBox() self.label = gtk.Label(_("sugar.activity.widgets.PasteButton()")) self.line.add(self.label) self.label.show() toolbar_box1 = ToolbarBox() self.line.add(toolbar_box1) toolbar_box1.show() title_entry1 = PasteButton() toolbar_box1.toolbar.insert(title_entry1, 0) title_entry1.show() self.label1 = gtk.Label(_("Some Description")) self.line.add(self.label1) self.label1.show() self.container.add(self.line) self.line.show()
def __init__(self, handle): """Set up the LiveDemo activity.""" activity.Activity.__init__(self, handle) # we do not have collaboration features # make the share option insensitive self.max_participants = 1 # toolbar with the new toolbar redesign toolbar_box = ToolbarBox() activity_button = ActivityButton(self) toolbar_box.toolbar.insert(activity_button, 0) activity_button.show() separator = gtk.SeparatorToolItem() separator.props.draw = False separator.set_expand(True) toolbar_box.toolbar.insert(separator, -1) separator.show() stop_button = StopButton(self) toolbar_box.toolbar.insert(stop_button, -1) stop_button.show() # box principal main_box = gtk.VBox() self.init_gui(main_box) self.set_canvas(main_box) self.set_toolbar_box(toolbar_box) self.set_canvas(main_box) self.set_toolbar_box(toolbar_box) toolbar_box.show() main_box.show_all() self.__path = os.path.dirname(os.path.abspath(__file__)) self.__recognizer = helper.RecognitionHelper(self.__path) self.__recognizer.listen(self.final_result) self.__recognizer.start_listening()
def __init__(self, handle): """Set up the HelloWorld activity.""" activity.Activity.__init__(self, handle) # Change the following number to change max participants self.max_participants = 1 toolbar_box = ToolbarBox() activity_button = ActivityButton(self) toolbar_box.toolbar.insert(activity_button, 0) activity_button.show() title_entry = TitleEntry(self) toolbar_box.toolbar.insert(title_entry, -1) title_entry.show() share_button = ShareButton(self) toolbar_box.toolbar.insert(share_button, -1) share_button.show() separator = gtk.SeparatorToolItem() separator.props.draw = False separator.set_expand(True) toolbar_box.toolbar.insert(separator, -1) separator.show() stop_button = StopButton(self) toolbar_box.toolbar.insert(stop_button, -1) stop_button.show() self.set_toolbar_box(toolbar_box) toolbar_box.show() # Change the following text to change the message (Default: 'Hello World!' label = gtk.Label(_("Hello World!")) self.set_canvas(label) label.show()
def _setup_toolbars(self): ''' Add buttons to toolbars ''' custom_toolbar = gtk.Toolbar() if HAS_TOOLBARBOX: toolbox = ToolbarBox() self.toolbar = toolbox.toolbar activity_button = ActivityToolbarButton(self) self.toolbar.insert(activity_button, 0) activity_button.show() custom_toolbar_button = ToolbarButton( label=_('Custom'), page=custom_toolbar, icon_name='view-source') custom_toolbar.show() self.toolbar.insert(custom_toolbar_button, -1) custom_toolbar_button.show() self._load_standard_buttons(self.toolbar) separator_factory(self.toolbar, expand=True, visible=False) stop_button = StopButton(self) stop_button.props.accelerator = _('<Ctrl>Q') self.toolbar.insert(stop_button, -1) stop_button.show() self.set_toolbox(toolbox) toolbox.show() else: toolbox = activity.ActivityToolbox(self) self.set_toolbox(toolbox) self.toolbar = gtk.Toolbar() toolbox.add_toolbar(_('Project'), self.toolbar) toolbox.add_toolbar(_('Custom'), custom_toolbar) self._load_standard_buttons(self.toolbar) self._load_custom_buttons(custom_toolbar)
def __init__(self, handle): """Set up the PiensaEscribe activity.""" activity.Activity.__init__(self, handle) # we do not have collaboration features # make the share option insensitive self.max_participants = 1 # toolbar with the new toolbar redesign toolbar_box = ToolbarBox() activity_button = ActivityButton(self) toolbar_box.toolbar.insert(activity_button, 0) activity_button.show() title_entry = TitleEntry(self) toolbar_box.toolbar.insert(title_entry, -1) title_entry.show() share_button = ShareButton(self) toolbar_box.toolbar.insert(share_button, -1) share_button.show() separator = gtk.SeparatorToolItem() separator.props.draw = False separator.set_expand(True) toolbar_box.toolbar.insert(separator, -1) separator.show() stop_button = StopButton(self) toolbar_box.toolbar.insert(stop_button, -1) stop_button.show() self.set_toolbar_box(toolbar_box) toolbar_box.show() self.createGUI()
def build_toolbar(self): # Creates the Toolbox. It contains the Activity Toolbar, which is the # bar that appears on every Sugar window and contains essential # functionalities, such as the 'Collaborate' and 'Close' buttons. toolbox = ToolbarBox() activity_button = ActivityToolbarButton(self) toolbox.toolbar.insert(activity_button, -1) activity_button.show() # Blank space (separator) and Stop button at the end: separator = gtk.SeparatorToolItem() separator.props.draw = False separator.set_expand(True) toolbox.toolbar.insert(separator, -1) separator.show() # Activity stop button stop_button = StopButton(self) toolbox.toolbar.insert(stop_button, -1) stop_button.show() self.set_toolbox(toolbox) toolbox.show()
class TamTamSynthLab(activity.Activity): def __init__(self, handle): activity.Activity.__init__(self, handle) color = gtk.gdk.color_parse(Config.WS_BCK_COLOR) self.modify_bg(gtk.STATE_NORMAL, color) self.set_title('TamTam SynthLab') self.set_resizable(False) self.trackpad = Trackpad(self) self.preloadTimeout = None self.connect('notify::active', self.onActive) self.connect('destroy', self.onDestroy) #load the sugar toolbar if Config.HAVE_TOOLBOX: # no sharing self.max_participants = 1 self.toolbox = ToolbarBox() self.toolbox.toolbar.insert(widgets.ActivityToolbarButton(self), 0) self.toolbox.toolbar.insert(gtk.SeparatorToolItem(), -1) else: self.toolbox = activity.ActivityToolbox(self) self.set_toolbox(self.toolbox) # no sharing self.activity_toolbar = self.toolbox.get_activity_toolbar() self.activity_toolbar.share.hide() self.activity_toolbar.keep.hide() self.toolbox.show() self.trackpad.setContext('synthLab') self.synthLab = SynthLabMain(self) self.connect('key-press-event', self.synthLab .onKeyPress) self.connect('key-release-event', self.synthLab .onKeyRelease) self.connect("key-press-event", self.synthLab.onKeyPress) self.connect("key-release-event", self.synthLab.onKeyRelease) self.set_canvas(self.synthLab) self.synthLab.onActivate(arg=None) if Config.HAVE_TOOLBOX: separator = gtk.SeparatorToolItem() separator.props.draw = False separator.set_expand(True) self.toolbox.toolbar.insert(separator, -1) self.toolbox.toolbar.insert(widgets.StopButton(self), -1) self.toolbox.toolbar.show_all() self.show() def onPreloadTimeout(self): if Config.DEBUG > 4: print "TamTam::onPreloadTimeout", self.preloadList t = time.time() if self.preloadList[0].load(t + 0.100): # finished preloading this object self.preloadList.pop(0) if not len(self.preloadList): if Config.DEBUG > 1: print "TamTam::finished preloading", time.time() - t self.preloadTimeout = False return False # finished preloading everything if Config.DEBUG > 4: print "TamTam::preload returned after", time.time() - t return True def onActive(self, widget=None, event=None): if widget.props.active == False: logging.debug('TamTamSynthLab.onActivate disconnecting csound') csnd = new_csound_client() csnd.connect(False) else: logging.debug('TamTamSynthLab.onActivate connecting csound') csnd = new_csound_client() csnd.connect(True) def onKeyPress(self, widget, event): pass def onKeyRelease(self, widget, event): pass def onDestroy(self, arg2): if Config.DEBUG: print 'DEBUG: TamTam::onDestroy()' self.synthLab.onDestroy() csnd = new_csound_client() csnd.connect(False) csnd.destroy() gtk.main_quit() # No more dir created by TamTam def ensure_dir(self, dir, perms=0777, rw=os.R_OK | os.W_OK):
class TamTamEdit(activity.Activity): def __init__(self, handle): activity.Activity.__init__(self, handle) # for snd in ['mic1','mic2','mic3','mic4','lab1','lab2','lab3','lab4', 'lab5', 'lab6']: # if not os.path.isfile(os.path.join(Config.DATA_DIR, snd)): # shutil.copyfile(Config.SOUNDS_DIR + '/' + snd , Config.DATA_DIR + '/' + snd) # os.system('chmod 0777 ' + Config.DATA_DIR + '/' + snd + ' &') color = gtk.gdk.color_parse(Config.WS_BCK_COLOR) self.modify_bg(gtk.STATE_NORMAL, color) self.trackpad = Trackpad(self) self.preloadTimeout = None self.connect('notify::active', self.onActive) self.connect('destroy', self.onDestroy) #load the sugar toolbar if Config.HAVE_TOOLBOX: # no sharing self.max_participants = 1 self.toolbox = ToolbarBox() self.toolbox.toolbar.insert(widgets.ActivityToolbarButton(self), -1) else: self.toolbox = activity.ActivityToolbox(self) self.set_toolbox(self.toolbox) self.activity_toolbar = self.toolbox.get_activity_toolbar() self.toolbox.show() self.trackpad.setContext('edit') self.edit = MainWindow(self) self.connect('key-press-event', self.edit.onKeyPress) self.connect('key-release-event', self.edit.onKeyRelease) #self.modeList[mode].regenerate() self.set_canvas(self.edit) self.edit.onActivate(arg=None) if Config.HAVE_TOOLBOX: separator = gtk.SeparatorToolItem() separator.props.draw = False separator.set_expand(True) self.toolbox.toolbar.insert(separator, -1) self.toolbox.toolbar.insert(widgets.StopButton(self), -1) self.toolbox.toolbar.show_all() else: self.activity_toolbar.share.hide() self.show() def onPreloadTimeout(self): if Config.DEBUG > 4: print "TamTam::onPreloadTimeout", self.preloadList t = time.time() if self.preloadList[0].load(t + 0.100): # finished preloading this object self.preloadList.pop(0) if not len(self.preloadList): if Config.DEBUG > 1: print "TamTam::finished preloading", time.time() - t self.preloadTimeout = False return False # finished preloading everything if Config.DEBUG > 4: print "TamTam::preload returned after", time.time() - t return True def onActive(self, widget=None, event=None): if widget.props.active == False: csnd = new_csound_client() csnd.connect(False) else: csnd = new_csound_client() csnd.connect(True) def onKeyPress(self, widget, event): pass def onKeyRelease(self, widget, event): pass def onDestroy(self, arg2): if Config.DEBUG: print 'DEBUG: TamTam::onDestroy()' self.edit.onDestroy() csnd = new_csound_client() csnd.connect(False) csnd.destroy() gtk.main_quit() # No more dir created by TamTam def ensure_dir(self, dir, perms=0777, rw=os.R_OK | os.W_OK):
def build_toolbar(self): toolbar_box = ToolbarBox() self.set_toolbar_box(toolbar_box) toolbar_box.show() activity_button = ActivityToolbarButton(self) toolbar_box.toolbar.insert(activity_button, -1) activity_button.show() tool_group = None self.game_button = RadioToolButton() self.game_button.props.icon_name = 'gamecanvas' self.game_button.set_tooltip(_('Juego')) self.game_button.accelerator = "<Ctrl>1" self.game_button.props.group = tool_group self.game_button.connect('clicked', self.show_game) toolbar_box.toolbar.insert(self.game_button, -1) self.game_button.show() tool_group = self.game_button button = RadioToolButton() button.props.icon_name = 'view-source' button.set_tooltip(_('Editor')) button.accelerator = "<Ctrl>2" button.props.group = tool_group button.connect('clicked', self.show_editor) toolbar_box.toolbar.insert(button, -1) button.show() self.save_button = ToolButton('dialog-ok') self.save_button.set_tooltip(_('Guardar')) self.save_button.accelerator = "<Ctrl>s" self.save_button.connect('clicked', self.save_file) self.save_button.set_sensitive(False) toolbar_box.toolbar.insert(self.save_button, -1) self.save_button.show() separator = gtk.SeparatorToolItem() toolbar_box.toolbar.insert(separator, -1) separator.show() button = ToolButton('system-restart') button.set_tooltip(_('Reiniciar juego')) button.accelerator = "<Alt><Shift>r" button.connect('clicked', self.restart_game) toolbar_box.toolbar.insert(button, -1) button.show() self.editor_button = ToolButton('sources') self.editor_button.set_tooltip(_('Consola')) self.editor_button.accelerator = "<Ctrl>grave" self.editor_button.connect('clicked', self.toggle_console) toolbar_box.toolbar.insert(self.editor_button, -1) self.editor_button.show() separator = gtk.SeparatorToolItem() toolbar_box.toolbar.insert(separator, -1) separator.show() button = helpbutton.HelpButton(self) toolbar_box.toolbar.insert(button, -1) button.show() button = ToolButton() button.props.icon_name = 'activity-about' button.set_tooltip(_('Acerca de')) button.accelerator = "<Ctrl>i" button.connect('clicked', self.run_credits) toolbar_box.toolbar.insert(button, -1) button.show() # Blank space (separator) and Stop button at the end: separator = gtk.SeparatorToolItem() separator.props.draw = False separator.set_expand(True) toolbar_box.toolbar.insert(separator, -1) separator.show() stop_button = StopButton(self) toolbar_box.toolbar.insert(stop_button, -1) stop_button.show()
class UI: log = logging.getLogger('cuadraditos-ui') def __init__(self, pca): self.ca = pca # listen for ctrl+c & escape key self.ca.connect('key-press-event', self._key_press_event_cb) self.ACTIVE = False self.LAUNCHING = True self.ca.add_events(gtk.gdk.VISIBILITY_NOTIFY_MASK) self.ca.connect("visibility-notify-event", self._visible_notify_cb) self.control_bar_ht = 60 # True when we're showing live video feed in the primary screen self.CAPTUREMODE = True #self.inset = self.__class__.dim_INSET #init self.mapped = False self.setup = False self.tbars = {Constants.MODE_VIDEO: 1, Constants.MODE_HELP: 2} # Use 0.86 toolbar design self.toolbox = ToolbarBox() # Buttons added to the Activity toolbar activity_button = ActivityToolbarButton(self.ca) self.toolbox.toolbar.insert(activity_button, 0) activity_button.show() separator = gtk.SeparatorToolItem() separator.props.draw = False separator.set_expand(True) separator.show() self.toolbox.toolbar.insert(separator, -1) # The ever-present Stop Button stop_button = StopButton(self) stop_button.props.accelerator = '<Ctrl>Q' self.toolbox.toolbar.insert(stop_button, -1) stop_button.show() self.ca.set_toolbar_box(self.toolbox) self.toolbox.show() self.toolbox_ht = self.toolbox.size_request()[1] self.vh = gtk.gdk.screen_height() - \ (self.toolbox_ht + self.control_bar_ht) self.vw = int(self.vh / .75) main_box = gtk.VBox() self.ca.set_canvas(main_box) main_box.get_parent().modify_bg(gtk.STATE_NORMAL, Constants.color_black.gColor) main_box.show() self._play_button = PlayButton() self._play_button.connect('clicked', self._button_play_click) main_box.pack_start(self._play_button, expand=True) self._play_button.show() self.setup_windows() def _mapEventCb(self, widget, event): #when your parent window is ready, turn on the feed of live video self.capture_window.disconnect(self.MAP_EVENT_ID) self.mapped = True self.set_up() def set_up(self): if (self.mapped and not self.setup): self.setup = True gobject.idle_add(self.final_setup) def final_setup(self): self.LAUNCHING = False self.ACTIVE = self.ca.get_property("visible") self.update_video_components() if (self.ACTIVE): self.ca.capture.play() def setup_windows(self): self.window_stack = [] self.capture_window = LiveCaptureWindow(Constants.color_black.gColor) self.add_to_window_stack(self.capture_window, self.ca) self.capture_window.set_capture(self.ca.capture) self.capture_window.set_events(gtk.gdk.BUTTON_RELEASE_MASK) self.capture_window.connect("button_release_event", self._live_button_release_cb) self.capture_window.add_events(gtk.gdk.VISIBILITY_NOTIFY_MASK) self.capture_window.connect("visibility-notify-event", self._visible_notify_cb) self.capture_window.connect('key-press-event', self._key_press_event_cb) self.hide_all_windows() self.MAP_EVENT_ID = self.capture_window.connect_after("map-event", self._mapEventCb) for i in range(0, len(self.window_stack)): self.window_stack[i].show_all() def _visible_notify_cb(self, widget, event): if (self.LAUNCHING): return temp_ACTIVE = True if (event.state == gtk.gdk.VISIBILITY_FULLY_OBSCURED): if (widget == self.ca): temp_ACTIVE = False if (temp_ACTIVE != self.ACTIVE): self.ACTIVE = temp_ACTIVE if not self.ACTIVE: self.ca.stop_pipes() self.capture_window.hide() self._play_button.show() def add_to_window_stack(self, win, parent): self.window_stack.append(win) win.set_transient_for(parent) win.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG) win.set_decorated(False) win.set_focus_on_map(False) win.set_property("accept-focus", False) win.props.destroy_with_parent = True def _key_press_event_cb(self, widget, event): #todo: trac #4144 #we listen here for CTRL+C events and game keys, and pass on events to #gtk.Entry fields keyname = gtk.gdk.keyval_name(event.keyval) if (keyname == 'c' and event.state == gtk.gdk.CONTROL_MASK): self.ca.close() elif (keyname == 'Escape'): self.ca.close() return False def close(self): self.ca.stop_pipes() self.hide_all_windows() self.ca.close() def hide_all_windows(self): for i in range(0, len(self.window_stack)): self.window_stack[i].hide_all() def _button_play_click(self, widget): self.ca.capture.play() self.update_video_components() def _live_button_release_cb(self, widget, event): self.ca.capture.play() self.CAPTUREMODE = True self.update_video_components() def start_live_video(self, force): # We need to know which window and which pipe here # if returning from another activity, active won't be false and needs # to be to get started if (self.ca.capture.window == self.capture_window and self.ca.props.active and not force): self.ca.m.set_updating(True) return self.ca.m.set_updating(True) self.capture_window.set_capture(self.ca.capture) self.ca.capture.play() self.ca.m.set_updating(False) def set_capture_loc_dim(self, win): self.smart_resize(win, gtk.gdk.screen_width(), gtk.gdk.screen_height() - self.toolbox_ht) backg_loc = self.get_background_wloc() self.smart_move(win, backg_loc[0], backg_loc[1]) def smart_resize(self, win, w, h): win_size = win.get_size() if ((win_size[0] != w) or (win_size[1] != h)): win.resize(w, h) return True else: return False def smart_move(self, win, x, y): win_loc = win.get_position() if ((win_loc[0] != x) or (win_loc[1] != y)): win.move(x, y) return True else: return False def get_background_wloc(self): return [gtk.gdk.screen_width(), self.toolbox_ht] def update_video_components(self): pos = [] pos.append({"position": "capture", "window": self.capture_window}) self.hide_all_windows() # Update positions self.set_capture_loc_dim(self.capture_window) for i in range(0, len(self.window_stack)): self.window_stack[i].show_all() def debug_windows(self): for i in range(0, len(self.window_stack)): self.__class__.log.error('%s %s %s' % (self.window_stack[i], self.window_stack[i].get_size(), self.window_stack[i].get_position()))
def __init__(self, handle): self.client = gconf.client_get_default() """Set up the MouseCam activity.""" activity.Activity.__init__(self, handle) # we do not have collaboration features # make the share option insensitive self.max_participants = 1 self.has_toolbarbox = HAS_TOOLBARBOX #register destroy callback self.connect("destroy", self.cb_cleanup) if(self.has_toolbarbox): # toolbar with the new toolbar redesign toolbar_box = ToolbarBox() activity_button = ActivityButton(self) toolbar_box.toolbar.insert(activity_button, 0) activity_button.show() title_entry = TitleEntry(self) toolbar_box.toolbar.insert(title_entry, -1) title_entry.show() share_button = ShareButton(self) toolbar_box.toolbar.insert(share_button, -1) share_button.show() separator = gtk.SeparatorToolItem() separator.props.draw = False separator.set_expand(True) toolbar_box.toolbar.insert(separator, -1) separator.show() stop_button = StopButton(self) toolbar_box.toolbar.insert(stop_button, -1) stop_button.show() self.set_toolbar_box(toolbar_box) else: # toolbar with the old toolbar design toolbar_box = activity.ActivityToolbox(self) self.set_toolbox(toolbar_box) toolbar_box.show() # Set default values for keypad and returnkey events self.client.set_bool('/apps/mousecam/keypad_events', False) self.client.set_bool('/apps/mousecam/return_key_instead_click', False) # And, one last HScale widget for adjusting the mouse speed box1 = gtk.VBox(False, 0) box1.set_border_width(10) self.set_canvas(box1) box1.show() # value, lower, upper, step_increment, page_increment, page_size # Note that the page_size value only makes a difference for # scrollbar widgets, and the highest value you'll get is actually # (upper - page_size). gconf_persist_value = self.client.get_float('/apps/mousecam/adj') if(gconf_persist_value == NOT_DEFINED): slide_vel_start_value = 50.0 self.client.set_float('/apps/mousecam/adj', slide_vel_start_value) else: slide_vel_start_value = gconf_persist_value adj1 = gtk.Adjustment(slide_vel_start_value, 1.0, 101.0, 0.1, 1.0, 1.0) adj1.connect("value_changed", self.cb_change_event) box1_1 = gtk.VBox(False, 10) box1.pack_start(box1_1, True, True, 0) box1_1.show() gconf_persist_value = self.client.get_int('/apps/mousecam/threshold') if(gconf_persist_value == NOT_DEFINED): slide_threshold_start_value = 100 self.client.set_int('/apps/mousecam/threshold', slide_threshold_start_value) else: slide_threshold_start_value = gconf_persist_value adj2 = gtk.Adjustment(slide_threshold_start_value, 0, 256, 1.0, 1.0, 1.0) adj2.connect("value_changed", self.cb_threshold_change_event) box1_2 = gtk.VBox(False, 10) box1.pack_start(box1_2, True, True, 0) box1_2.show() # Reuse the same adjustment self.hscale = gtk.HScale(adj1) self.hscale.set_size_request(600, 90) ###scale_set_default_values(self.hscale) box1_1.pack_start(self.hscale, True, True, 0) self.hscale.show() self.hscale2 = gtk.HScale(adj2) self.hscale2.set_digits(0) self.hscale2.set_size_request(600, 90) box1_2.pack_start(self.hscale2, True, True, 0) self.hscale2.show() # An option menu to change the position of the value #label = gtk.Label(_('Deslice la barra para enlentecer el mouse:')) label = gtk.Label(_('Slide the bar to slow the mouse speed:')) box1_1.pack_start(label, False, False, 0) label.show() label = gtk.Label(_('Slide the bar to decrease the threshold:')) box1_2.pack_start(label, False, False, 0) label.show() # Check button for mouse / keypad event switch button_keypad = gtk.CheckButton(_('Enable keypad events')) button_keypad.connect("toggled", self.cb_keypad_events) button_keypad.show() # Check button for click / return key event switch button_returnkey = gtk.CheckButton(_('Enable the return key in place of the mouse click')) button_returnkey.connect("toggled", self.cb_keypad_events) button_returnkey.show() box1_3 = gtk.VBox(False, 10) box1_3.show() box1_3.pack_start(button_keypad, False, False, 2) box1_3.pack_start(button_returnkey, False, False, 2) box1.pack_start(box1_3, True, True, 0) menu = gtk.Menu() self.window.show() os.system("bin/execute.sh &")
def create_new_toolbar(self): toolbar_box = ToolbarBox() activity_button = MyActivityToolbarButton(self) toolbar_box.toolbar.insert(activity_button, 0) activity_button.show() self.connect('go-fullscreen', \ self.__view_toolbar_go_fullscreen_cb) self.back = ToolButton('go-previous') self.back.set_tooltip(_('Back')) self.back.props.sensitive = False palette = self.back.get_palette() self.menu_prev_page = MenuItem(text_label= _("Previous page")) palette.menu.append(self.menu_prev_page) self.menu_prev_page.show_all() self.back.connect('clicked', self.go_back_cb) self.menu_prev_page.connect('activate', self.go_back_cb) toolbar_box.toolbar.insert(self.back, -1) self.back.show() self.forward = ToolButton('go-next') self.forward.set_tooltip(_('Forward')) self.forward.props.sensitive = False palette = self.forward.get_palette() self.menu_next_page = MenuItem(text_label= _("Next page")) palette.menu.append(self.menu_next_page) self.menu_next_page.show_all() self.forward.connect('clicked', self.go_forward_cb) self.menu_next_page.connect('activate', self.go_forward_cb) toolbar_box.toolbar.insert(self.forward, -1) self.forward.show() num_page_item = gtk.ToolItem() self.num_page_entry = gtk.Entry() self.num_page_entry.set_text('0') self.num_page_entry.set_alignment(1) self.num_page_entry.connect('insert-text', self.__new_num_page_entry_insert_text_cb) self.num_page_entry.connect('activate', self.__new_num_page_entry_activate_cb) self.num_page_entry.set_width_chars(4) num_page_item.add(self.num_page_entry) self.num_page_entry.show() toolbar_box.toolbar.insert(num_page_item, -1) num_page_item.show() total_page_item = gtk.ToolItem() self.total_page_label = gtk.Label() label_attributes = pango.AttrList() label_attributes.insert(pango.AttrSize(14000, 0, -1)) label_attributes.insert(pango.AttrForeground(65535, 65535, 65535, 0, -1)) self.total_page_label.set_attributes(label_attributes) self.total_page_label.set_text(' / 0') total_page_item.add(self.total_page_label) self.total_page_label.show() toolbar_box.toolbar.insert(total_page_item, -1) total_page_item.show() spacer = gtk.SeparatorToolItem() toolbar_box.toolbar.insert(spacer, -1) spacer.show() self._zoom_out = ToolButton('zoom-out') self._zoom_out.set_tooltip(_('Zoom out')) self._zoom_out.connect('clicked', self._zoom_out_cb) toolbar_box.toolbar.insert(self._zoom_out, -1) self._zoom_out.props.sensitive = False self._zoom_out.show() self._zoom_in = ToolButton('zoom-in') self._zoom_in.set_tooltip(_('Zoom in')) self._zoom_in.connect('clicked', self._zoom_in_cb) toolbar_box.toolbar.insert(self._zoom_in, -1) self._zoom_in.props.sensitive = True self._zoom_in.show() self._fullscreen = ToolButton('view-fullscreen') self._fullscreen.set_tooltip(_('Fullscreen')) self._fullscreen.connect('clicked', self._fullscreen_cb) toolbar_box.toolbar.insert(self._fullscreen, -1) self._fullscreen.show() separator = gtk.SeparatorToolItem() separator.props.draw = False separator.set_expand(True) toolbar_box.toolbar.insert(separator, -1) separator.show() stop_button = StopButton(self) stop_button.props.accelerator = '<Ctrl><Shift>Q' toolbar_box.toolbar.insert(stop_button, -1) stop_button.show() self.set_toolbar_box(toolbar_box) toolbar_box.show()
def _setup_toolbars(self): ''' Setup the toolbars. ''' self.max_participants = 6 if HAVE_TOOLBOX: toolbox = ToolbarBox() # Activity toolbar activity_button_toolbar = ActivityToolbarButton(self) toolbox.toolbar.insert(activity_button_toolbar, 0) activity_button_toolbar.show() self.set_toolbar_box(toolbox) toolbox.show() self.toolbar = toolbox.toolbar self.record_toolbar = gtk.Toolbar() record_toolbar_button = ToolbarButton( label=_('Record a sound'), page=self.record_toolbar, icon_name='media-audio') self.record_toolbar.show_all() record_toolbar_button.show() toolbox.toolbar.insert(record_toolbar_button, -1) else: # Use pre-0.86 toolbar design primary_toolbar = gtk.Toolbar() toolbox = activity.ActivityToolbox(self) self.set_toolbox(toolbox) toolbox.add_toolbar(_('Page'), primary_toolbar) self.record_toolbar = gtk.Toolbar() toolbox.add_toolbar(_('Record'), self.record_toolbar) toolbox.show() toolbox.set_current_toolbar(1) self.toolbar = primary_toolbar self._prev_button = button_factory( 'go-previous-inactive', self.toolbar, self._prev_cb, tooltip=_('Prev slide'), accelerator='<Ctrl>P') self._next_button = button_factory( 'go-next', self.toolbar, self._next_cb, tooltip=_('Next slide'), accelerator='<Ctrl>N') separator_factory(self.toolbar) slide_button = radio_factory('slide-view', self.toolbar, self._slides_cb, group=None, tooltip=_('Slide view')) radio_factory('thumbs-view', self.toolbar, self._thumbs_cb, tooltip=_('Thumbnail view'), group=slide_button) button_factory('view-fullscreen', self.toolbar, self.do_fullscreen_cb, tooltip=_('Fullscreen'), accelerator='<Alt>Return') separator_factory(self.toolbar) journal_button = button_factory( 'write-journal', self.toolbar, self._do_journal_cb, tooltip=_('Update description')) self._palette = journal_button.get_palette() msg_box = gtk.HBox() sw = gtk.ScrolledWindow() sw.set_size_request(int(gtk.gdk.screen_width() / 2), 2 * style.GRID_CELL_SIZE) sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self._text_view = gtk.TextView() self._text_view.set_left_margin(style.DEFAULT_PADDING) self._text_view.set_right_margin(style.DEFAULT_PADDING) self._text_view.set_wrap_mode(gtk.WRAP_WORD_CHAR) self._text_view.connect('focus-out-event', self._text_view_focus_out_event_cb) sw.add(self._text_view) sw.show() msg_box.pack_start(sw, expand=False) msg_box.show_all() self._palette.set_content(msg_box) label_factory(self.record_toolbar, _('Record a sound') + ':') self._record_button = button_factory( 'media-record', self.record_toolbar, self._record_cb, tooltip=_('Start recording')) separator_factory(self.record_toolbar) # Look to see if we have audio previously recorded obj_id = self._get_audio_obj_id() dsobject = self._search_for_audio_note(obj_id) if dsobject is not None: _logger.debug('Found previously recorded audio') self._add_playback_button(profile.get_nick_name(), self.colors, dsobject.file_path) if HAVE_TOOLBOX: button_factory('system-restart', activity_button_toolbar, self._resend_cb, tooltip=_('Refresh')) separator_factory(activity_button_toolbar) self._save_pdf = button_factory( 'save-as-pdf', activity_button_toolbar, self._save_as_pdf_cb, tooltip=_('Save as PDF')) else: separator_factory(self.toolbar) self._save_pdf = button_factory( 'save-as-pdf', self.toolbar, self._save_as_pdf_cb, tooltip=_('Save as PDF')) if HAVE_TOOLBOX: separator_factory(toolbox.toolbar, True, False) stop_button = StopButton(self) stop_button.props.accelerator = '<Ctrl>q' toolbox.toolbar.insert(stop_button, -1) stop_button.show()
class Record(activity.Activity): def __init__(self, handle): super(Record, self).__init__(handle) self.props.enable_fullscreen_mode = False Instance(self) self.add_events(gtk.gdk.VISIBILITY_NOTIFY_MASK) self.connect("visibility-notify-event", self._visibility_changed) # the main classes self.model = Model(self) self.ui_init() # CSCL self.connect("shared", self._shared_cb) if self.get_shared_activity(): # have you joined or shared this activity yourself? if self.get_shared(): self._joined_cb(self) else: self.connect("joined", self._joined_cb) # Realize the video view widget so that it knows its own window XID self._media_view.realize_video() # Changing to the first toolbar kicks off the rest of the setup if self.model.get_has_camera(): self.model.change_mode(constants.MODE_PHOTO) else: self.model.change_mode(constants.MODE_AUDIO) # Restore critical hidden mixer controls to default model = hw.get_xo_version() if model == 1.75 or model == 4: args = ["amixer", "set", "Analog Mic Boost", "100%"] try: subprocess.check_output(args) except: pass def read_file(self, path): self.model.read_file(path) def write_file(self, path): self.model.write_file(path) def close(self): self.model.gplay.stop() self.model.glive.stop() super(Record, self).close() def _visibility_changed(self, widget, event): self.model.set_visible(event.state != gtk.gdk.VISIBILITY_FULLY_OBSCURED) def _shared_cb(self, activity): self.model.collab.set_activity_shared() def _joined_cb(self, activity): self.model.collab.joined() def ui_init(self): self._fullscreen = False self._showing_info = False # FIXME: if _thumb_tray becomes some kind of button group, we wouldn't # have to track which recd is active self._active_recd = None self.connect_after("key-press-event", self._key_pressed) self._active_toolbar_idx = 0 self._toolbar_box = ToolbarBox() activity_button = ActivityToolbarButton(self) self._toolbar_box.toolbar.insert(activity_button, 0) self.set_toolbar_box(self._toolbar_box) self._toolbar = self.get_toolbar_box().toolbar tool_group = None if self.model.get_has_camera(): self._photo_button = RadioToolButton() self._photo_button.props.group = tool_group tool_group = self._photo_button self._photo_button.props.icon_name = "camera-external" self._photo_button.props.label = _("Photo") self._photo_button.mode = constants.MODE_PHOTO self._photo_button.connect("clicked", self._mode_button_clicked) self._toolbar.insert(self._photo_button, -1) self._video_button = RadioToolButton() self._video_button.props.group = tool_group self._video_button.props.icon_name = "media-video" self._video_button.props.label = _("Video") self._video_button.mode = constants.MODE_VIDEO self._video_button.connect("clicked", self._mode_button_clicked) self._toolbar.insert(self._video_button, -1) else: self._photo_button = None self._video_button = None self._audio_button = RadioToolButton() self._audio_button.props.group = tool_group self._audio_button.props.icon_name = "media-audio" self._audio_button.props.label = _("Audio") self._audio_button.mode = constants.MODE_AUDIO self._audio_button.connect("clicked", self._mode_button_clicked) self._toolbar.insert(self._audio_button, -1) self._toolbar.insert(gtk.SeparatorToolItem(), -1) self._toolbar_controls = RecordControl(self._toolbar) separator = gtk.SeparatorToolItem() separator.props.draw = False separator.set_expand(True) self._toolbar.insert(separator, -1) self._toolbar.insert(StopButton(self), -1) self.get_toolbar_box().show_all() main_box = gtk.VBox() self.set_canvas(main_box) main_box.get_parent().modify_bg(gtk.STATE_NORMAL, COLOR_BLACK) main_box.show() self._media_view = MediaView() self._media_view.connect("media-clicked", self._media_view_media_clicked) self._media_view.connect("pip-clicked", self._media_view_pip_clicked) self._media_view.connect("info-clicked", self._media_view_info_clicked) self._media_view.connect("full-clicked", self._media_view_full_clicked) self._media_view.connect("tags-changed", self._media_view_tags_changed) self._media_view.show() self._controls_hbox = gtk.HBox() self._controls_hbox.show() self._shutter_button = ShutterButton() self._shutter_button.connect("clicked", self._shutter_clicked) self._controls_hbox.pack_start(self._shutter_button, expand=True, fill=False) self._countdown_image = CountdownImage() self._controls_hbox.pack_start(self._countdown_image, expand=True, fill=False) self._play_button = PlayButton() self._play_button.connect("clicked", self._play_pause_clicked) self._controls_hbox.pack_start(self._play_button, expand=False) self._playback_scale = PlaybackScale(self.model) self._controls_hbox.pack_start(self._playback_scale, expand=True, fill=True) self._progress = ProgressInfo() self._controls_hbox.pack_start(self._progress, expand=True, fill=True) self._title_label = gtk.Label() self._title_label.set_markup("<b><span foreground='white'>" + _("Title:") + "</span></b>") self._controls_hbox.pack_start(self._title_label, expand=False) self._title_entry = gtk.Entry() self._title_entry.modify_bg(gtk.STATE_INSENSITIVE, COLOR_BLACK) self._title_entry.connect("changed", self._title_changed) self._controls_hbox.pack_start(self._title_entry, expand=True, fill=True, padding=10) self._record_container = RecordContainer(self._media_view, self._controls_hbox) main_box.pack_start(self._record_container, expand=True, fill=True, padding=6) self._record_container.show() self._thumb_tray = HTray() self._thumb_tray.set_size_request(-1, 150) main_box.pack_end(self._thumb_tray, expand=False) self._thumb_tray.show_all() def serialize(self): data = {} data["timer"] = self._toolbar_controls.get_timer_idx() data["duration"] = self._toolbar_controls.get_duration_idx() data["quality"] = self._toolbar_controls.get_quality() return data def deserialize(self, data): self._toolbar_controls.set_timer_idx(data.get("timer", 0)) self._toolbar_controls.set_duration_idx(data.get("duration", 0)) self._toolbar_controls.set_quality(data.get("quality", 0)) def _key_pressed(self, widget, event): key = event.keyval if key == gtk.keysyms.KP_Page_Up: # game key O if self._shutter_button.props.visible: if self._shutter_button.props.sensitive: self._shutter_button.clicked() else: # return to live mode self.model.set_state(constants.STATE_READY) if self.model.ui_frozen(): return False if key == gtk.keysyms.c and event.state == gdk.CONTROL_MASK: self._copy_to_clipboard(self._active_recd) elif key == gtk.keysyms.i: self._toggle_info() elif key == gtk.keysyms.Escape: if self._fullscreen: self._toggle_fullscreen() return False def _play_pause_clicked(self, widget): self.model.play_pause() def set_mode(self, mode): self._toolbar_controls.set_mode(mode) # can be called from gstreamer thread, so must not do any GTK+ stuff def set_glive_sink(self, sink): return self._media_view.set_video_sink(sink) # can be called from gstreamer thread, so must not do any GTK+ stuff def set_gplay_sink(self, sink): return self._media_view.set_video2_sink(sink) def get_selected_quality(self): return self._toolbar_controls.get_quality() def get_selected_timer(self): return self._toolbar_controls.get_timer() def get_selected_duration(self): return self._toolbar_controls.get_duration() * 60 # convert to secs def set_progress(self, value, text): self._progress.set_progress(value) self._progress.set_text(text) def set_countdown(self, value): if value == 0: self._shutter_button.show() self._countdown_image.hide() self._countdown_image.clear() return self._shutter_button.hide() self._countdown_image.show() self._countdown_image.set_value(value) def _title_changed(self, widget): self._active_recd.setTitle(self._title_entry.get_text()) def _media_view_media_clicked(self, widget): if self._play_button.props.visible and self._play_button.props.sensitive: self._play_button.clicked() def _media_view_pip_clicked(self, widget): # clicking on the PIP always returns to live mode self.model.set_state(constants.STATE_READY) def _media_view_info_clicked(self, widget): self._toggle_info() def _toggle_info(self): recd = self._active_recd if not recd: return if self._showing_info: self._show_recd(recd, play=False) return self._showing_info = True if self.model.get_mode() in (constants.MODE_PHOTO, constants.MODE_AUDIO): func = self._media_view.show_info_photo else: func = self._media_view.show_info_video self._play_button.hide() self._progress.hide() self._playback_scale.hide() self._title_entry.set_text(recd.title) self._title_entry.show() self._title_label.show() self._record_container.set_title_visible(True) func(recd.recorderName, recd.colorStroke, recd.colorFill, utils.getDateString(recd.time), recd.tags) def _media_view_full_clicked(self, widget): self._toggle_fullscreen() def _media_view_tags_changed(self, widget, tbuffer): text = tbuffer.get_text(tbuffer.get_start_iter(), tbuffer.get_end_iter()) self._active_recd.setTags(text) def _toggle_fullscreen(self): if not self._fullscreen: self._toolbar_box.hide() self._thumb_tray.hide() else: self._toolbar_box.show() self._thumb_tray.show() self._fullscreen = not self._fullscreen self._media_view.set_fullscreen(self._fullscreen) def _mode_button_clicked(self, button): self.model.change_mode(button.mode) def _shutter_clicked(self, arg): self.model.do_shutter() def set_shutter_sensitive(self, value): self._shutter_button.set_sensitive(value) def set_state(self, state): radio_state = state == constants.STATE_READY for item in (self._photo_button, self._audio_button, self._video_button): if item: item.set_sensitive(radio_state) self._showing_info = False if state == constants.STATE_READY: self._set_cursor_default() self._active_recd = None self._title_entry.hide() self._title_label.hide() self._record_container.set_title_visible(False) self._play_button.hide() self._playback_scale.hide() self._progress.hide() self._controls_hbox.set_child_packing( self._shutter_button, expand=True, fill=False, padding=0, pack_type=gtk.PACK_START ) self._shutter_button.set_normal() self._shutter_button.set_sensitive(True) self._shutter_button.show() self._media_view.show_live() elif state == constants.STATE_RECORDING: self._shutter_button.set_recording() self._controls_hbox.set_child_packing( self._shutter_button, expand=False, fill=False, padding=0, pack_type=gtk.PACK_START ) self._progress.show() elif state == constants.STATE_PROCESSING: self._set_cursor_busy() self._shutter_button.hide() self._progress.show() elif state == constants.STATE_DOWNLOADING: self._shutter_button.hide() self._progress.show() def set_paused(self, value): if value: self._play_button.set_play() else: self._play_button.set_pause() def _thumbnail_clicked(self, button, recd): if self.model.ui_frozen(): return self._active_recd = recd self._show_recd(recd) def add_thumbnail(self, recd, scroll_to_end): button = RecdButton(recd) clicked_handler = button.connect("clicked", self._thumbnail_clicked, recd) remove_handler = button.connect("remove-requested", self._remove_recd) clipboard_handler = button.connect("copy-clipboard-requested", self._thumbnail_copy_clipboard) button.set_data("handler-ids", (clicked_handler, remove_handler, clipboard_handler)) self._thumb_tray.add_item(button) button.show() if scroll_to_end: self._thumb_tray.scroll_to_end() def _copy_to_clipboard(self, recd): if recd == None: return if not recd.isClipboardCopyable(): return media_path = recd.getMediaFilepath() tmp_path = utils.getUniqueFilepath(media_path, 0) shutil.copyfile(media_path, tmp_path) gtk.Clipboard().set_with_data([("text/uri-list", 0, 0)], self._clipboard_get, self._clipboard_clear, tmp_path) def _clipboard_get(self, clipboard, selection_data, info, path): selection_data.set("text/uri-list", 8, "file://" + path) def _clipboard_clear(self, clipboard, path): if os.path.exists(path): os.unlink(path) def _thumbnail_copy_clipboard(self, recdbutton): self._copy_to_clipboard(recdbutton.get_recd()) def _remove_recd(self, recdbutton): recd = recdbutton.get_recd() self.model.delete_recd(recd) if self._active_recd == recd: self.model.set_state(constants.STATE_READY) self._remove_thumbnail(recdbutton) def _remove_thumbnail(self, recdbutton): handlers = recdbutton.get_data("handler-ids") for handler in handlers: recdbutton.disconnect(handler) self._thumb_tray.remove_item(recdbutton) recdbutton.cleanup() def remove_all_thumbnails(self): for child in self._thumb_tray.get_children(): self._remove_thumbnail(child) def show_still(self, pixbuf): self._media_view.show_still(pixbuf) def _show_photo(self, recd): path = self._get_photo_path(recd) self._media_view.show_photo(path) self._title_entry.set_text(recd.title) self._title_entry.show() self._title_label.show() self._record_container.set_title_visible(True) self._shutter_button.hide() self._progress.hide() def _show_audio(self, recd, play): self._progress.hide() self._shutter_button.hide() self._title_entry.hide() self._title_label.hide() self._record_container.set_title_visible(False) self._play_button.show() self._playback_scale.show() path = recd.getAudioImageFilepath() self._media_view.show_photo(path) if play: self.model.play_audio(recd) def _show_video(self, recd, play): self._progress.hide() self._shutter_button.hide() self._title_entry.hide() self._title_label.hide() self._record_container.set_title_visible(False) self._play_button.show() self._playback_scale.show() self._media_view.show_video() if play: self.model.play_video(recd) def set_playback_scale(self, value): self._playback_scale.set_value(value) def _get_photo_path(self, recd): # FIXME should live (partially) in recd? # downloading = self.ca.requestMeshDownload(recd) # self.MESHING = downloading if True: # not downloading: # self.progressWindow.updateProgress(0, "") return recd.getMediaFilepath() # maybe it is not downloaded from the mesh yet... # but we can show the low res thumb in the interim return recd.getThumbFilepath() def _show_recd(self, recd, play=True): self._showing_info = False if recd.buddy and not recd.downloadedFromBuddy: self.model.request_download(recd) elif recd.type == constants.TYPE_PHOTO: self._show_photo(recd) elif recd.type == constants.TYPE_AUDIO: self._show_audio(recd, play) elif recd.type == constants.TYPE_VIDEO: self._show_video(recd, play) def remote_recd_available(self, recd): if recd == self._active_recd: self._show_recd(recd) def update_download_progress(self, recd): if recd != self._active_recd: return if not recd.meshDownloading: msg = _("Download failed.") elif recd.meshDownloadingProgress: msg = _("Downloading...") else: msg = _("Requesting...") self.set_progress(recd.meshDownlodingPercent, msg) def _set_cursor_busy(self): self.window.set_cursor(gdk.Cursor(gdk.WATCH)) def _set_cursor_default(self): self.window.set_cursor(None)
def __init__(self, handle): super(PeterActivity, self).__init__(handle) # Get user's Sugar colors sugarcolors = profile.get_color().to_string().split(',') colors = [[int(sugarcolors[0][1:3], 16), int(sugarcolors[0][3:5], 16), int(sugarcolors[0][5:7], 16)], [int(sugarcolors[1][1:3], 16), int(sugarcolors[1][3:5], 16), int(sugarcolors[1][5:7], 16)]] # No sharing self.max_participants = 1 # Build the activity toolbar. toolbox = ToolbarBox() activity_button = ActivityToolbarButton(self) toolbox.toolbar.insert(activity_button, 0) activity_button.show() self._add_level_slider(toolbox.toolbar) green = ToolButton('green') toolbox.toolbar.insert(green, -1) green.set_tooltip(_('Run')) green.connect('clicked', self._button_cb, 'green') green.show() separator = gtk.SeparatorToolItem() separator.props.draw = True toolbox.toolbar.insert(separator, -1) separator.show() label = gtk.Label('') label.set_use_markup(True) label.show() labelitem = gtk.ToolItem() labelitem.add(label) toolbox.toolbar.insert(labelitem, -1) labelitem.show() separator = gtk.SeparatorToolItem() separator.props.draw = False separator.set_expand(True) toolbox.toolbar.insert(separator, -1) separator.show() stop = ToolButton('activity-stop') toolbox.toolbar.insert(stop, -1) stop.props.tooltip = _('Stop') stop.props.accelerator = '<Ctrl>Q' stop.connect('clicked', self.__stop_button_clicked_cb, activity) stop.show() toolbox.show() self.set_toolbox(toolbox) # Create the game instance. self.game = Numbers.Numbers(colors, sugar=True) # Build the Pygame canvas. self._pygamecanvas = sugargame.canvas.PygameCanvas(self) # Note that set_canvas implicitly calls # read_file when resuming from the Journal. self.set_canvas(self._pygamecanvas) self.game.canvas = self._pygamecanvas self.game.set_buttons(green) self.game.set_label(label) gtk.gdk.screen_get_default().connect('size-changed', self.__configure_cb) # Start the game running. self._pygamecanvas.run_pygame(self.game.run)
def __init__(self, handle): super(PeterActivity, self).__init__(handle) # Get user's Sugar colors sugarcolors = profile.get_color().to_string().split(",") colors = [ [int(sugarcolors[0][1:3], 16), int(sugarcolors[0][3:5], 16), int(sugarcolors[0][5:7], 16)], [int(sugarcolors[1][1:3], 16), int(sugarcolors[1][3:5], 16), int(sugarcolors[1][5:7], 16)], ] # No sharing self.max_participants = 1 self.datapath = os.path.join(activity.get_activity_root(), "instance") # Build the activity toolbar. toolbox = ToolbarBox() activity_button = ActivityToolbarButton(self) toolbox.toolbar.insert(activity_button, 0) activity_button.show() self._add_speed_slider(toolbox.toolbar) cyan = ToolButton("cyan") toolbox.toolbar.insert(cyan, -1) cyan.set_tooltip(_("Next pattern")) cyan.connect("clicked", self._button_cb, "cyan") cyan.set_sensitive(False) cyan.show() green = ToolButton("green") toolbox.toolbar.insert(green, -1) green.set_tooltip(_("Draw")) green.connect("clicked", self._button_cb, "green") green.show() red = ToolButton("red") toolbox.toolbar.insert(red, -1) red.set_tooltip(_("Stop")) red.connect("clicked", self._button_cb, "red") red.show() separator = gtk.SeparatorToolItem() separator.props.draw = True toolbox.toolbar.insert(separator, -1) separator.show() label = gtk.Label("") label.set_use_markup(True) label.show() labelitem = gtk.ToolItem() labelitem.add(label) toolbox.toolbar.insert(labelitem, -1) labelitem.show() export = ToolButton("export-turtleblocks") toolbox.toolbar.insert(export, -1) export.set_tooltip(_("Export to TurtleBlocks")) export.connect("clicked", self._export_turtleblocks_cb) export.show() separator = gtk.SeparatorToolItem() separator.props.draw = False separator.set_expand(True) toolbox.toolbar.insert(separator, -1) separator.show() stop_button = StopButton(self) stop_button.props.accelerator = _("<Ctrl>Q") toolbox.toolbar.insert(stop_button, -1) stop_button.show() toolbox.show() self.set_toolbox(toolbox) # Create the game instance. self.game = Spirolaterals.Spirolaterals(colors) # Build the Pygame canvas. self._pygamecanvas = sugargame.canvas.PygameCanvas(self) # Note that set_canvas implicitly calls # read_file when resuming from the Journal. self.set_canvas(self._pygamecanvas) self.game.canvas = self._pygamecanvas gtk.gdk.screen_get_default().connect("size-changed", self.__configure_cb) # Start the game running. self.game.set_cyan_button(cyan) self.game.set_label(label) self._speed_range.set_value(200) self._pygamecanvas.run_pygame(self.game.run)
def __init__(self, handle): """Set up the HelloWorld activity.""" activity.Activity.__init__(self, handle) self._logger = logging.getLogger('home-work-viewer') self._logger.setLevel(logging.DEBUG) self._logger.debug("Inside to __init__ of HomeWorkViewer") ts = time.time() self._logger.debug(ts) #self._logger.debug( datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d %H:%M:%S')) '''Obtenemos el JSON de la Actividad''' json_data=open('json.txt') self.activity = json.load(json_data, object_hook=lambda d: namedtuple('Activity', d.keys())(*d.values())) json_data.close() # we do not have collaboration features # make the share option insensitive self.max_participants = 1 # toolbar with the new toolbar redesign toolbar_box = ToolbarBox() activity_button = ActivityButton(self) toolbar_box.toolbar.insert(activity_button, 0) activity_button.show() title_entry = TitleEntry(self) toolbar_box.toolbar.insert(title_entry, 1) title_entry.show() separator = gtk.SeparatorToolItem() separator.props.draw = False separator.set_expand(True) toolbar_box.toolbar.insert(separator, -1) separator.show() self.buttonBefore = ToolButton('go-previous') self.buttonBefore.set_tooltip(_('Back')) self.buttonBefore.connect("clicked", self.backButtonCallBack) toolbar_box.toolbar.insert(self.buttonBefore, 2) self.buttonBefore.show() self.buttonNext = ToolButton('go-next') self.buttonNext.set_tooltip(_('Next')) self.buttonNext.connect("clicked", self.nextButtonCallBack) toolbar_box.toolbar.insert(self.buttonNext, 3) self.buttonNext.show() stop_button = StopButton(self) toolbar_box.toolbar.insert(stop_button, -1) stop_button.show() self.set_toolbar_box(toolbar_box) toolbar_box.show() self.vBoxMain = gtk.VBox(True, 2) self.vBoxMain.show() self.set_canvas(self.vBoxMain) self.jsonState = None self.createWindowExercises() """Leave this line always in the last"""
def build_toolbar(self): toolbar_box = ToolbarBox() self.set_toolbar_box(toolbar_box) toolbar_box.show() activity_button = ActivityToolbarButton(self) toolbar_box.toolbar.insert(activity_button, -1) activity_button.show() separator = gtk.SeparatorToolItem() toolbar_box.toolbar.insert(separator, -1) separator.show() self.build_colors_toolbar(toolbar_box) separator = gtk.SeparatorToolItem() toolbar_box.toolbar.insert(separator, -1) separator.show() # new game button new_game = ToolButton('new-game') new_game.connect('clicked', self._new_game) new_game.set_tooltip(_('New game')) toolbar_box.toolbar.insert(new_game, -1) separator = gtk.SeparatorToolItem() toolbar_box.toolbar.insert(separator, -1) separator.show() #current item = gtk.ToolItem() label = gtk.Label() label.set_text(' %s ' % _('Current player:')) item.add(label) toolbar_box.toolbar.insert(item, -1) #player item = gtk.ToolItem() self.current_label = gtk.Label() self.current_label.set_text(' %s' % 1) item.add(self.current_label) toolbar_box.toolbar.insert(item, -1) separator = gtk.SeparatorToolItem() toolbar_box.toolbar.insert(separator, -1) separator.show() sound_button = ToolButton('speaker-muted-100') sound_button.set_tooltip(_('Sound')) sound_button.connect('clicked', self.sound_control) toolbar_box.toolbar.insert(sound_button, -1) # separator and stop separator = gtk.SeparatorToolItem() separator.props.draw = False separator.set_expand(True) toolbar_box.toolbar.insert(separator, -1) separator.show() stop_button = StopButton(self) toolbar_box.toolbar.insert(stop_button, -1) stop_button.show() self.show_all()
def __init__(self, handle): """Set up the activity.""" activity.Activity.__init__(self, handle) """Create the user interface.""" self.stack = gtk.VBox() self.add(self.stack) self.hpaned = gtk.HPaned() self.stack.pack_end(self.hpaned) self.vpaned = gtk.VPaned() self.hpaned.pack2(self.vpaned, shrink=False) self.hpaned.set_position(200) self.plugins = window.PluginTabs() self.hpaned.pack1(self.plugins.widget, shrink=False) self.model = Abominade(self) self.plugins.add_main(self.model.buffers) self.plugins.add_tab(self.model.files) self.plugins.add_tab(self.model.bookmarks) self.plugins.add_tab(self.model.terminals) self.vpaned.pack1(self.model.vim.widget, resize=True, shrink=False) self.vpaned.pack2(self.model.terminals.book, resize=False, shrink=False) # make sure buffers list isn't zero-height if self.plugins.stack.get_position() < 200: self.plugins.stack.set_position(200) self.stack.show_all() self.set_canvas(self.stack) self.init_interpreter() label = gtk.Label("Consola") self.model.terminals.book.prepend_page(self.interpreter, tab_label=label) # we do not have collaboration features # make the share option insensitive self.max_participants = 1 # toolbar with the new toolbar redesign toolbar_box = ToolbarBox() activity_button = ActivityButton(self) toolbar_box.toolbar.insert(activity_button, 0) activity_button.show() title_entry = TitleEntry(self) toolbar_box.toolbar.insert(title_entry, -1) title_entry.show() self.sidebar_button = ToggleToolButton('folder') self.sidebar_button.set_active(True) self.sidebar_button.set_tooltip('Consola') self.sidebar_button.accelerator = "<Ctrl>grave" self.sidebar_button.connect('clicked', self.toggle_sidebar) toolbar_box.toolbar.insert(self.sidebar_button, -1) self.sidebar_button.show() self.bottom_button = ToggleToolButton('tray-show') self.bottom_button.set_active(True) self.bottom_button.set_tooltip('Consola') self.bottom_button.accelerator = "<Ctrl>grave" self.bottom_button.connect('clicked', self.toggle_bottom) toolbar_box.toolbar.insert(self.bottom_button, -1) self.bottom_button.show() share_button = ShareButton(self) toolbar_box.toolbar.insert(share_button, -1) share_button.show() separator = gtk.SeparatorToolItem() separator.props.draw = False separator.set_expand(True) toolbar_box.toolbar.insert(separator, -1) separator.show() stop_button = StopButton(self) toolbar_box.toolbar.insert(stop_button, -1) stop_button.show() self.set_toolbar_box(toolbar_box) toolbar_box.show() self.model.start()
class TamTamMini(activity.Activity): __gtype_name__ = 'TamTamMiniWindow' def __init__(self, handle): self.mini = None activity.Activity.__init__(self, handle) color = gtk.gdk.color_parse(Config.WS_BCK_COLOR) self.modify_bg(gtk.STATE_NORMAL, color) self.set_title('TamTam Mini') self.connect('notify::active', self.onActive) self.connect('destroy', self.onDestroy) if Config.HAVE_TOOLBOX: from sugar.graphics.toolbarbox import ToolbarBox from sugar.activity import widgets self.toolbox = ToolbarBox() self.toolbox.toolbar.insert(widgets.ActivityButton(self), -1) self.toolbox.toolbar.insert(widgets.TitleEntry(self), -1) try: from sugar.activity.widgets import DescriptionItem except ImportError: pass else: description_item = DescriptionItem(self) self.toolbox.toolbar.insert(description_item, -1) description_item.show() self.toolbox.toolbar.insert(widgets.ShareButton(self), -1) else: self.toolbox = activity.ActivityToolbox(self) self.set_toolbox(self.toolbox) self.toolbox.show() self.mini = miniTamTamMain(self) self.mini.onActivate(arg=None) self.mini.updateInstrumentPanel() self.set_canvas(self.mini) if Config.HAVE_TOOLBOX: separator = gtk.SeparatorToolItem() separator.props.draw = False separator.set_expand(True) self.toolbox.toolbar.insert(separator, -1) self.toolbox.toolbar.insert(widgets.StopButton(self), -1) self.toolbox.toolbar.show_all() self.show() def do_size_allocate(self, allocation): activity.Activity.do_size_allocate(self, allocation) if self.mini is not None: self.mini.updateInstrumentPanel() def onActive(self, widget=None, event=None): if widget.props.active == False: csnd = new_csound_client() csnd.connect(False) else: csnd = new_csound_client() csnd.connect(True) def onDestroy(self, arg2): if Config.DEBUG: print 'DEBUG: TamTam::onDestroy()' self.mini.onDestroy() csnd = new_csound_client() csnd.connect(False) csnd.destroy() gtk.main_quit() # no more dir created by TamTam def ensure_dir(self, dir, perms=0777, rw=os.R_OK | os.W_OK):