def _load_toolbar(self): toolbar = gtk.Toolbar() # Remove Feed Palette remove_button = ToolButton(icon_name='list-remove') vbox = gtk.VBox() label = gtk.Label(_('Really delete feed?')) vbox.pack_start(label) hbox = gtk.HBox() expander_label = gtk.Label(' ') hbox.pack_start(expander_label) #b = gtk.Button(icon_name='stock-remove') b = ToolButton(icon_name='list-remove') #b.set_use_stock(True) b.connect('clicked', self._on_remove_feed_activate) hbox.pack_start(b, False) vbox.pack_start(hbox) palette = Palette(_('Remove Feed?')) palette.set_content(vbox) vbox.show_all() remove_button.set_palette(palette) toolbar.insert(remove_button, -1) remove_button.show() # Add Feed Palette button = ToolButton(icon_name='list-add') toolbar.insert(button, -1) button.show() self._add_feed_dialog = AddFeedDialog.AddFeedDialog( gtk.glade.XML(os.path.join(self.glade_prefix, 'penguintv.glade'), "window_add_feed", 'penguintv'), self) #MAGIC content = self._add_feed_dialog.extract_content() content.show_all() #button.connect('clicked', self._add_feed_dialog.show) palette = Palette(_('Subscribe to Feed')) palette.set_content(content) button.set_palette(palette) self._feedlist = gtk.ListStore(int, str, str) self._combo = gtk.ComboBox(self._feedlist) cell = gtk.CellRendererText() self._combo.pack_start(cell, True) self._combo.add_attribute(cell, 'text', 1) self._combo.connect("changed", self._on_combo_select) toolcombo = ToolComboBox(self._combo) toolbar.insert(toolcombo, -1) toolcombo.show_all() toolbar.show() return toolbar
def _load_toolbar(self): toolbar = gtk.Toolbar() # Remove Feed Palette remove_button = ToolButton(icon_name='list-remove') vbox = gtk.VBox() label = gtk.Label(_('Really delete feed?')) vbox.pack_start(label) hbox = gtk.HBox() expander_label = gtk.Label(' ') hbox.pack_start(expander_label) #b = gtk.Button(icon_name='stock-remove') b = ToolButton(icon_name='list-remove') #b.set_use_stock(True) b.connect('clicked', self._on_remove_feed_activate) hbox.pack_start(b, False) vbox.pack_start(hbox) palette = Palette(_('Remove Feed?')) palette.set_content(vbox) vbox.show_all() remove_button.set_palette(palette) toolbar.insert(remove_button, -1) remove_button.show() # Add Feed Palette button = ToolButton(icon_name='list-add') toolbar.insert(button, -1) button.show() self._add_feed_dialog = AddFeedDialog.AddFeedDialog(gtk.glade.XML(os.path.join(self.glade_prefix, 'penguintv.glade'), "window_add_feed",'penguintv'), self) #MAGIC content = self._add_feed_dialog.extract_content() content.show_all() #button.connect('clicked', self._add_feed_dialog.show) palette = Palette(_('Subscribe to Feed')) palette.set_content(content) button.set_palette(palette) self._feedlist = gtk.ListStore(int, str, str) self._combo = gtk.ComboBox(self._feedlist) cell = gtk.CellRendererText() self._combo.pack_start(cell, True) self._combo.add_attribute(cell, 'text', 1) self._combo.connect("changed", self._on_combo_select) toolcombo = ToolComboBox(self._combo) toolbar.insert(toolcombo, -1) toolcombo.show_all() toolbar.show() return toolbar
class TestPalette(Test): def __init__(self): Test.__init__(self) toolbar = gtk.Toolbar() self._invoker = ToolButton('go-previous') toolbar.insert(self._invoker, -1) self._invoker.show() self.pack_start(toolbar, False) toolbar.show() def set_palette(self, palette): self._invoker.set_palette(palette)
class XoScopeActivity(activity.Activity): """XoScopeActivity class as specified in activity.info""" def __init__(self, handle): """Set up the XoScope activity.""" activity.Activity.__init__(self, handle) self._instance_directory = os.path.join(self.get_activity_root(),\ 'instance') # we do not have collaboration features # make the share option insensitive self.max_participants = 1 self._capturing = False self._mode = 'live' # 0, 2 or 5 second delay before capturing the image self._delay = 0 # Zoom 1x, 2x, 4x self._zoom = 1 # Exposure bracketing self._bracketing = '0' # Preview mode stuff self._num_pics = 0 # Index of pic to be displayed in preview mode self._pic_index = 0 # This holds the image titles and name information. Saved # across activity instances self._images = [] # Flag to store whether image preview element needs to resize # the pixbuf self._needs_resize = False if OLD_TOOLBAR: self.toolbox = ActivityToolbox(self) self.set_toolbox(self.toolbox) self.toolbox.show() activity_toolbar = self.toolbox.get_activity_toolbar() activity_toolbar = gtk.Toolbar() self.toolbox.add_toolbar(_('Control'), activity_toolbar) self.toolbox.set_current_toolbar(1) self._controls_toolbar = activity_toolbar advanced_toolbar = self.toolbox.get_activity_toolbar() advanced_toolbar = gtk.Toolbar() #self.toolbox.add_toolbar(_('Advanced controls'), advanced_toolbar) else: toolbar_box = ToolbarBox() self.activity_button = ActivityToolbarButton(self) toolbar_box.toolbar.insert(self.activity_button, 0) self.activity_button.show() self.set_toolbar_box(toolbar_box) toolbar_box.show() activity_toolbar = self.activity_button.page self._controls_toolbar = self.get_toolbar_box().toolbar self._controls_toolbar.show() advanced_toolbar = gtk.Toolbar() #advanced_toolbar.show_all() advanced_button = ToolbarButton() advanced_button.props.page = advanced_toolbar advanced_button.props.label = _('Advanced controls') advanced_button.props.icon_name = 'advanced' #advanced_button.show() #toolbar_box.toolbar.insert(advanced_button, -1) self._live_toolitem = gtk.ToolItem() self._live_toolbar_container = gtk.HBox() self._preview_toolitem = gtk.ToolItem() self._preview_toolbar_container = gtk.HBox() separator = gtk.SeparatorToolItem() if not OLD_TOOLBAR: separator.props.draw = True else: separator.props.draw = False separator.set_expand(False) self._controls_toolbar.insert(separator, -1) separator.show() self._photo_button = ToolButton('photo') self._photo_button.props.label = _('Capture photo') self._photo_button.connect('clicked', self.__capture_image_cb) self._live_toolbar_container.add(self._photo_button) self._photo_button.show() self._delay_button = ToolButton('delay_%d' % self._delay) self._delay_button.props.label = _('Capture delay') self._delay_button.connect('clicked', self.__change_capture_delay_cb) self._live_toolbar_container.add(self._delay_button) self._delay_button.show() self._zoom_button = ToolButton('zoom_%d' % self._zoom) self._zoom_button.props.label = _('Image Zoom') self._zoom_button.connect('clicked', self.__change_image_zoom_cb) self._live_toolbar_container.add(self._zoom_button) self._zoom_button.show() #if self._check_available_control(v4l2.V4L2_CID_EXPOSURE): # self._bracketing_button = ToolButton('bracketing_%s' % self._bracketing) # self._bracketing_button.props.label = _('bracketing mode') # self._bracketing_button.connect('clicked', # self.__change_capture_bracketing_cb) # self._live_toolbar_container.add(self._bracketing_button) # self._bracketing_button.show() separator = gtk.SeparatorToolItem() separator.props.draw = True separator.set_expand(False) self._live_toolbar_container.add(separator) separator.show() # Camera control settings follow if self._check_available_control(v4l2.V4L2_CID_EXPOSURE): self._exposure_button = ToolButton('exposure') self._exposure_button.set_palette(ScalePalette('Exposure',\ v4l2.V4L2_CID_EXPOSURE)) self._exposure_button.connect('clicked', self.__button_clicked_cb) self._live_toolbar_container.add(self._exposure_button) self._exposure_button.show() if self._check_available_control(v4l2.V4L2_CID_GAIN): self._gain_button = ToolButton('gain') self._gain_button.set_palette(ScalePalette('Gain',\ v4l2.V4L2_CID_GAIN, self._check_available_control(v4l2.V4L2_CID_AUTOGAIN))) self._gain_button.connect('clicked', self.__button_clicked_cb) advanced_toolbar.insert(self._gain_button, -1) self._gain_button.show() if self._check_available_control(v4l2.V4L2_CID_BRIGHTNESS): self._brightness_button = ToolButton('brightness') self._brightness_button.set_palette(ScalePalette('Brightness',\ v4l2.V4L2_CID_BRIGHTNESS, self._check_available_control( v4l2.V4L2_CID_AUTOBRIGHTNESS))) self._brightness_button.connect('clicked', self.__button_clicked_cb) self._live_toolbar_container.add(self._brightness_button) self._brightness_button.show() if self._check_available_control(v4l2.V4L2_CID_CONTRAST): self._contrast_button = ToolButton('contrast') self._contrast_button.set_palette(ScalePalette('Contrast',\ v4l2.V4L2_CID_CONTRAST)) self._contrast_button.connect('clicked', self.__button_clicked_cb) self._live_toolbar_container.add(self._contrast_button) self._contrast_button.show() if self._check_available_control(v4l2.V4L2_CID_SATURATION): self._saturation_button = ToolButton('saturation') self._saturation_button.set_palette(ScalePalette('Saturation',\ v4l2.V4L2_CID_SATURATION)) self._saturation_button.connect('clicked', self.__button_clicked_cb) advanced_toolbar.insert(self._saturation_button, -1) self._saturation_button.show() if self._check_available_control( v4l2.V4L2_CID_WHITE_BALANCE_TEMPERATURE): self._white_balance_button = ToolButton('white_balance') self._white_balance_button.set_palette(ScalePalette('White' ' balance', v4l2.V4L2_CID_WHITE_BALANCE_TEMPERATURE, self._check_available_control( v4l2.V4L2_CID_AUTO_WHITE_BALANCE))) self._white_balance_button.connect('clicked', self.__button_clicked_cb) advanced_toolbar.insert(self._white_balance_button, -1) self._white_balance_button.show() if self._check_available_control(v4l2.V4L2_CID_HUE): self._color_tone_button = ToolButton('color_tone') self._color_tone_button.set_palette(ScalePalette('Color' ' tone', v4l2.V4L2_CID_HUE, self._check_available_control( v4l2.V4L2_CID_HUE_AUTO))) self._color_tone_button.connect('clicked', self.__button_clicked_cb) advanced_toolbar.insert(self._color_tone_button, -1) self._color_tone_button.show() #if self._check_available_control(v4l2.V4L2_CID_NIGHT_MODE): # self._night_mode_button = ToolButton('night_mode') # self._night_mode_button.set_palette(ScalePalette('Night mode',\ # v4l2.V4L2_CID_NIGHT_MODE)) # self._night_mode_button.connect('clicked', # self.__button_clicked_cb) # self._live_toolbar_container.add(self._night_mode_button) # self._night_mode_button.show() self._previous_image = ToolButton('go-previous-paired') self._previous_image.label = _('Previous image') self._previous_image.connect('clicked', self.__previous_image_clicked_cb) self._preview_toolbar_container.add(self._previous_image) self._previous_image.show() self._next_image = ToolButton('go-next-paired') self._next_image.label = _('Next image') self._next_image.connect('clicked', self.__next_image_clicked_cb) self._preview_toolbar_container.add(self._next_image) self._next_image.show() self._image_name_entry = gtk.Entry() self._image_name_entry.set_text('') self._image_name_entry.set_size_request(400, -1) self._image_name_entry.connect('activate', self.__image_name_entry_activated_cb) self._preview_toolbar_container.add(self._image_name_entry) self._image_name_entry.show() self._save_to_journal = ToolButton('save_to_journal') self._save_to_journal.label = _('Save to journal') self._save_to_journal.connect('clicked', self.__save_to_journal_clicked_cb) self._preview_toolbar_container.add(self._save_to_journal) self._save_to_journal.show() self._trash = ToolButton('trash') self._trash.label = _('Delete') self._trash.connect('clicked', self.__trash_clicked_cb) self._preview_toolbar_container.add(self._trash) self._trash.show() separator = gtk.SeparatorToolItem() separator.props.draw = False separator.set_expand(True) self._controls_toolbar.insert(separator, -1) separator.show() self._mode_button = ToolButton('%s_mode' % self._mode) self._mode_button.props.label = _('Mode') self._mode_button.connect('clicked', self.__switch_modes_cb) self._controls_toolbar.insert(self._mode_button, -1) self._mode_button.show() if not OLD_TOOLBAR: separator = gtk.SeparatorToolItem() separator.props.draw = True separator.set_expand(False) self._controls_toolbar.insert(separator, -1) separator.show() activity_stop = StopButton(self) toolbar_box.toolbar.insert(activity_stop, -1) activity_stop.show() self._preview_toolitem.add(self._preview_toolbar_container) self._live_toolitem.add(self._live_toolbar_container) self._preview_toolbar_container.show() self._live_toolbar_container.show() if self._mode == 'preview': self._controls_toolbar.insert(self._preview_toolitem, 1) self._preview_toolitem.show() else: self._controls_toolbar.insert(self._live_toolitem, 1) self._live_toolitem.show() self._mode = 'live' self._controls_toolbar.show() activity_toolbar.show() self._main_view = gtk.HBox() self._movie_window = gtk.DrawingArea() self._movie_window.connect('realize', self.__movie_window_realize_cb) self._movie_window.unset_flags(gtk.DOUBLE_BUFFERED) self._movie_window.set_flags(gtk.APP_PAINTABLE) self._main_view.add(self._movie_window) self._preview_frame = gtk.AspectFrame(None, 0.5, 0.5, 1, True) self._preview_window = gtk.Image() self._preview_frame.add(self._preview_window) self._preview_window.connect('size_allocate', self.__preview_window_size_allocate_cb) self.xoscope = gst.Pipeline('xoscope_pipe') camsrc = gst.element_factory_make('v4l2src', 'camsrc') caps = gst.Caps('video/x-raw-yuv') filt = gst.element_factory_make('capsfilter', 'filter') filt.set_property('caps', caps) ffmpegcolorspace = gst.element_factory_make('ffmpegcolorspace', 'ffmpegcolorspace') self._disp_sink = gst.element_factory_make('xvimagesink', 'disp_sink') # http://thread.gmane.org/gmane.comp.video.gstreamer.devel/29644 self._disp_sink.set_property('sync', False) self.image_sink = gst.element_factory_make('fakesink', 'image_sink') self.image_sink.set_property('silent', True) tee = gst.element_factory_make('tee', 'tee') queue = gst.element_factory_make('queue', 'dispqueue') queue.set_property('leaky', True) queue.set_property('max-size-buffers', 20) queue2 = gst.element_factory_make('queue', 'imagequeue') queue2.set_property('leaky', True) queue2.set_property('max-size-buffers', 20) self._zoom_element = gst.element_factory_make('videobox', 'zoombox') jpeg = gst.element_factory_make('jpegenc', 'pbjpeg') jpeg.set_property('quality', 100) self.xoscope.add(camsrc, filt, ffmpegcolorspace,\ self._zoom_element, self._disp_sink, tee, queue, queue2,\ self.image_sink, jpeg) gst.element_link_many(camsrc, filt, self._zoom_element,\ ffmpegcolorspace, tee, queue, self._disp_sink) gst.element_link_many(tee, queue2, jpeg, self.image_sink) bus = self.xoscope.get_bus() bus.add_signal_watch() bus.enable_sync_message_emission() bus.connect('message', self.__on_message_cb) bus.connect('sync-message::element', self.__on_sync_message_cb) self._main_view.show() self._movie_window.show() self.set_canvas(self._main_view) # If we start playing without a delay, the live view window # doesn't get attached to the main canvas properly (This is # a problem on slow computers like xo1). gobject.timeout_add(2000, self.__start_live_view) def __preview_window_size_allocate_cb(self, gobject, allocation): # Make sure we don't get stuck in an infinite loop if self._needs_resize: pixbuf = self._preview_window.get_pixbuf() new_pixbuf = pixbuf.scale_simple(allocation.width,\ allocation.height, gtk.gdk.INTERP_BILINEAR) self._preview_window.set_from_pixbuf(new_pixbuf) self._preview_window.show() self._needs_resize = False else: return def read_file(self, path): logging.debug('read_file %s' % path) try: dom = minidom.parse(path) except Exception, e: logging.error('read_file: %s' % e) return logging.debug('read file, now filling hash') self._fill_info_hash(dom) self._update_zoom_element_and_button() self._delay_button.set_icon('delay_%d' % self._delay)