def select(self): if Sound.current != self: Sound.current = self Sound.player.set_state(gst.STATE_NULL) Sound.player.set_property('uri', 'file://' + theme.path(self._soundfile)) if Sound.playing: Sound.player.set_state(gst.STATE_PLAYING) return self
def __init__(self, name, thumbfile, dir): self.name = name self.frames = [] if dir: for i in sorted(glob.glob(theme.path(dir, '*'))): self.frames.append(PreinstalledFrame( os.path.join(dir, os.path.basename(i)))) self._thumb = theme.pixbuf(thumbfile, theme.THUMB_SIZE) self._custom = False else: for i in range(0, theme.FRAME_ROWS * theme.FRAME_COLS): self.frames.append(CustomFrame()) self._thumb = theme.CUSTOM_FRAME_THUMB self._custom = True
def __init__(self): GObject.GObject.__init__(self) self._screen = Screen() self._play_tape_num = 0 self._playing = None self._delay = 3 * 150 self._tape_selected = -1 self._tape = [] self._char = None self._frames = [] self._prev_combo_selected = {} self._emission = True self._screen_size_id = None # frames table self.table = Gtk.Table( # theme.FRAME_ROWS, columns=theme.FRAME_COLS, homogeneous=False) for i in range(theme.FRAME_ROWS * theme.FRAME_COLS): self._add_frame(i) # frames box table_scroll = VScrolledBox() table_scroll.set_viewport(self.table) table_scroll.modify_bg(Gtk.StateType.NORMAL, Gdk.color_parse(BUTTON_BACKGROUND)) yellow_frames = Gtk.EventBox() yellow_frames.modify_bg(Gtk.StateType.NORMAL, Gdk.color_parse(YELLOW)) table_frames = Gtk.EventBox() table_frames.modify_bg(Gtk.StateType.NORMAL, Gdk.color_parse(BACKGROUND)) table_frames.set_border_width(5) table_frames.add(table_scroll) yellow_frames.add(table_frames) yelow_arrow = Gtk.Image() yelow_arrow.set_from_file(theme.path('icons', 'yellow_arrow.png')) frames_box = Gtk.VBox() frames_box.pack_start(yellow_frames, True, True, 0) frames_box.pack_start(yelow_arrow, False, False, 0) frames_box.props.border_width = theme.BORDER_WIDTH # screen screen_pink = Gtk.EventBox() screen_pink.modify_bg(Gtk.StateType.NORMAL, Gdk.color_parse(PINK)) screen_box = Gtk.EventBox() screen_box.set_border_width(5) screen_box.add(self._screen) screen_pink.add(screen_box) screen_pink.props.border_width = theme.BORDER_WIDTH # tape tape = Gtk.HBox() for i in range(TAPE_COUNT): frame_box = Gtk.VBox() filmstrip_pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale( theme.path('icons', 'filmstrip.png'), THUMB_SIZE, -1, False) filmstrip = Gtk.Image() filmstrip.set_from_pixbuf(filmstrip_pixbuf) frame_box.pack_start(filmstrip, False, False, 0) frame = Gtk.EventBox() frame.set_events(Gdk.EventMask.BUTTON_PRESS_MASK) frame.connect('button_press_event', self._tape_cb, i) frame.modify_bg(Gtk.StateType.NORMAL, Gdk.color_parse(BLACK)) frame.modify_bg(Gtk.StateType.PRELIGHT, Gdk.color_parse(BLACK)) frame.props.border_width = 2 frame.set_size_request(theme.THUMB_SIZE, theme.THUMB_SIZE) frame_box.pack_start(frame, True, True, 0) self._tape.append(frame) frame_image = Gtk.Image() frame_image.set_from_pixbuf(theme.EMPTY_THUMB) frame.add(frame_image) filmstrip = Gtk.Image() filmstrip.set_from_pixbuf(filmstrip_pixbuf) frame_box.pack_start(filmstrip, False, False, 0) tape.pack_start(frame_box, False, False, 0) # left control box self.controlbox = Gtk.VBox() self.controlbox.props.border_width = theme.BORDER_WIDTH self.controlbox.props.spacing = theme.BORDER_WIDTH leftbox = Gtk.VBox() logo = Gtk.Image() logo.set_from_file(theme.path('icons', 'logo.png')) leftbox.set_size_request(logo.props.pixbuf.get_width(), -1) leftbox.pack_start(logo, False, False, 0) leftbox.pack_start(self.controlbox, True, True, 0) # screen box screen_alignment = Gtk.Alignment.new(0.5, 0.5, 0, 0) screen_alignment.add(screen_pink) box = Gtk.EventBox() box.modify_bg(Gtk.StateType.NORMAL, Gdk.color_parse(BACKGROUND)) box.connect('size-allocate', self._screen_size_cb, screen_pink) box.add(screen_alignment) cetralbox = Gtk.HBox() cetralbox.pack_start(box, expand=True, fill=True, padding=0) cetralbox.pack_start(frames_box, expand=False, fill=True, padding=0) hdesktop = Gtk.HBox() hdesktop.pack_start(leftbox, False, True, 0) hdesktop.pack_start(cetralbox, True, True, 0) # tape box arrow = Gtk.Image() arrow.set_from_file(theme.path('icons', 'pink_arrow.png')) tape_pink = Gtk.EventBox() tape_pink.modify_bg(Gtk.StateType.NORMAL, Gdk.color_parse(PINK)) tape_bg = Gtk.EventBox() tape_bg.modify_bg(Gtk.StateType.NORMAL, Gdk.color_parse(BACKGROUND)) tape_bg.set_border_width(5) tape_bg.add(tape) tape_pink.add(tape_bg) tape_hbox = Gtk.HBox() tape_hbox.pack_start(tape_pink, True, False, 0) tape_box = Gtk.VBox() tape_box.props.border_width = theme.BORDER_WIDTH tape_box.pack_start(arrow, False, False, 0) tape_box.pack_start(tape_hbox, True, True, 0) desktop = Gtk.VBox() desktop.pack_start(hdesktop, True, True, 0) desktop.pack_start(tape_box, False, False, 0) greenbox = Gtk.EventBox() greenbox.modify_bg(Gtk.StateType.NORMAL, Gdk.color_parse(BACKGROUND)) greenbox.set_border_width(5) greenbox.add(desktop) self.modify_bg(Gtk.StateType.NORMAL, Gdk.color_parse(YELLOW)) self.add(greenbox) self.show_all()
view_box = gtk.EventBox() view_box.add(view) view_box.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse(theme.WHITE)) view_box.props.border_width = 10 border_box = gtk.EventBox() border_box.add(view_box) border_box.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse(theme.WHITE)) scrolled_window = gtk.ScrolledWindow() scrolled_window.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC) scrolled_window.add_with_viewport(border_box) View.notebook.append_page(scrolled_window) self.show_all() _locale = locale.getdefaultlocale()[0] _lang = _locale and _locale.split('_')[0] or 'en' if not os.path.isdir(theme.path('lessons', _lang)): logging.info('Cannot find lessons for language %s, thus use en' % _lang) _lang = 'en' for i, filename in enumerate(sorted(glob(theme.path('lessons', _lang, '*')))): THEMES.append(Lesson(i, filename))