def __init__(self, handle): activity.Activity.__init__(self, handle) # abiword uses the current directory for all its file dialogs os.chdir(os.path.expanduser('~')) # create our main abiword canvas self.abiword_canvas = DocumentView() self._new_instance = True toolbar_box = ToolbarBox() self.activity_button = ActivityToolbarButton(self) toolbar_box.toolbar.insert(self.activity_button, -1) separator = Gtk.SeparatorToolItem() separator.show() self.activity_button.props.page.insert(separator, 2) ExportButtonFactory(self, self.abiword_canvas) self.activity_button.show() edit_toolbar = ToolbarButton() edit_toolbar.props.page = EditToolbar(self, toolbar_box) edit_toolbar.props.icon_name = 'toolbar-edit' edit_toolbar.props.label = _('Edit') toolbar_box.toolbar.insert(edit_toolbar, -1) view_toolbar = ToolbarButton() view_toolbar.props.page = ViewToolbar(self.abiword_canvas) view_toolbar.props.icon_name = 'toolbar-view' view_toolbar.props.label = _('View') toolbar_box.toolbar.insert(view_toolbar, -1) # due to http://bugzilla.abisource.com/show_bug.cgi?id=13585 if self.abiword_canvas.get_version() != '3.0': self.speech_toolbar_button = ToolbarButton(icon_name='speak') toolbar_box.toolbar.insert(self.speech_toolbar_button, -1) self._init_speech() separator = Gtk.SeparatorToolItem() toolbar_box.toolbar.insert(separator, -1) text_toolbar = ToolbarButton() text_toolbar.props.page = TextToolbar(self.abiword_canvas) text_toolbar.props.icon_name = 'format-text' text_toolbar.props.label = _('Text') toolbar_box.toolbar.insert(text_toolbar, -1) para_toolbar = ToolbarButton() para_toolbar.props.page = ParagraphToolbar(self.abiword_canvas) para_toolbar.props.icon_name = 'paragraph-bar' para_toolbar.props.label = _('Paragraph') toolbar_box.toolbar.insert(para_toolbar, -1) insert_toolbar = ToolbarButton() insert_toolbar.props.page = InsertToolbar(self.abiword_canvas) insert_toolbar.props.icon_name = 'insert-table' insert_toolbar.props.label = _('Table') toolbar_box.toolbar.insert(insert_toolbar, -1) image = ToolButton('insert-picture') image.set_tooltip(_('Insert Image')) self._image_id = image.connect('clicked', self.__image_cb) toolbar_box.toolbar.insert(image, -1) palette = image.get_palette() box = PaletteMenuBox() palette.set_content(box) box.show() menu_item = PaletteMenuItem(_('Floating')) menu_item.connect('activate', self.__image_cb, True) box.append_item(menu_item) menu_item.show() separator = Gtk.SeparatorToolItem() separator.props.draw = False separator.set_size_request(0, -1) separator.set_expand(True) separator.show() toolbar_box.toolbar.insert(separator, -1) stop = StopButton(self) toolbar_box.toolbar.insert(stop, -1) toolbar_box.show_all() self.set_toolbar_box(toolbar_box) # add a overlay to be able to show a icon while joining a shared doc overlay = Gtk.Overlay() overlay.add(self.abiword_canvas) overlay.show() self._connecting_box = ConnectingBox() overlay.add_overlay(self._connecting_box) self.set_canvas(overlay) # we want a nice border so we can select paragraphs easily self.abiword_canvas.set_show_margin(True) # Set default font face and size self._default_font_face = 'Sans' self._default_font_size = 12 # activity sharing self.participants = {} self.joined = False self.connect('shared', self._shared_cb) if self.shared_activity: # we are joining the activity logger.debug('We are joining an activity') # display a icon while joining self._connecting_box.show() # disable the abi widget self.abiword_canvas.set_sensitive(False) self._new_instance = False self.connect('joined', self._joined_cb) self.shared_activity.connect('buddy-joined', self._buddy_joined_cb) self.shared_activity.connect('buddy-left', self._buddy_left_cb) if self.get_shared(): self._joined_cb(self) else: # we are creating the activity logger.debug("We are creating an activity") self.abiword_canvas.zoom_width() self.abiword_canvas.show() self.connect_after('map-event', self.__map_activity_event_cb) self.abiword_canvas.connect('size-allocate', self.size_allocate_cb)
def __init__(self, handle): activity.Activity.__init__(self, handle) self.set_title('FotoToon') self._max_participants = 1 self.page = None toolbar_box = ToolbarBox() activity_button = ActivityToolbarButton(self) activity_toolbar = activity_button.page toolbar_box.toolbar.insert(activity_button, 0) edit_toolbar_btn = ToolbarButton() edit_toolbar = Gtk.Toolbar() edit_toolbar_btn.props.page = edit_toolbar edit_toolbar_btn.props.icon_name = 'toolbar-edit' edit_toolbar_btn.label = _('Edit') toolbar_box.toolbar.insert(edit_toolbar_btn, -1) view_toolbar_btn = ToolbarButton() view_toolbar = Gtk.Toolbar() view_toolbar_btn.props.page = view_toolbar view_toolbar_btn.props.icon_name = 'toolbar-view' view_toolbar_btn.label = _('View') toolbar_box.toolbar.insert(view_toolbar_btn, -1) slideview_btn = ToggleToolButton('slideshow') slideview_btn.set_tooltip(_('Slideshow')) slideview_btn.set_active(False) slideview_btn.connect('clicked', self._switch_view_mode, False) view_toolbar.insert(slideview_btn, -1) slideview_btn.show() slideview_timings_btn = ToggleToolButton('slideshow-stopwatch') slideview_timings_btn.set_tooltip(_('Slideshow with Timings')) slideview_timings_btn.set_active(False) slideview_timings_btn.connect('clicked', self._switch_view_mode, True) view_toolbar.insert(slideview_timings_btn, -1) slideview_timings_btn.show() time_button = ToolButton('stopwatch') time_button.set_tooltip(_('Set Image Duration in Slideshow (Seconds)')) view_toolbar.insert(time_button, -1) time_button.show() self._time_spin = Gtk.SpinButton.new_with_range(MIN_TIME, MAX_TIME, 1) self._time_spin.connect('value-changed', self.__time_spin_changed_cb) self._time_spin.props.value = DEFAULT_TIME self._time_spin.props.update_policy = \ Gtk.SpinButtonUpdatePolicy.IF_VALID palette = time_button.get_palette() palette.connect('popup', self.__time_button_popup_cb) time_button.connect( 'clicked', lambda *args: palette.popup(immediate=True, state=Palette.SECONDARY)) alignment = Gtk.Alignment() alignment.set_padding(style.DEFAULT_PADDING, style.DEFAULT_PADDING, style.DEFAULT_PADDING, style.DEFAULT_PADDING) alignment.add(self._time_spin) self._time_spin.show() palette.set_content(alignment) alignment.show() fullscreen_btn = ToolButton('view-fullscreen') fullscreen_btn.set_tooltip(_('Fullscreen')) fullscreen_btn.props.accelerator = '<Alt>Return' fullscreen_btn.connect('clicked', lambda w: self.fullscreen()) view_toolbar.insert(fullscreen_btn, -1) fullscreen_btn.show() self.set_toolbar_box(toolbar_box) toolbar = toolbar_box.toolbar self.page = Page() self.globes_manager = GlobesManager(toolbar, edit_toolbar, self) # fonts self._text_button = ToolbarButton() self._text_button.props.page = TextToolbar(self.page) self._text_button.props.icon_name = 'format-text-size' self._text_button.props.label = _('Text') self._toolbar_box.toolbar.insert(self._text_button, -1) reorder_img_btn = ToolButton('thumbs-view') reorder_img_btn.set_icon_name('thumbs-view') reorder_img_btn.set_tooltip(_('Change image order')) reorder_img_btn.connect('clicked', self.__image_order_cb) edit_toolbar.insert(reorder_img_btn, -1) reorder_img_btn.show() bgchange = ToolButton(icon_name='contract-coordinates') bgchange.set_tooltip(_('Edit background image')) bgchange.connect('clicked', self.__bgchange_clicked_cb) edit_toolbar.insert(bgchange, -1) bgchange.show() separator = Gtk.SeparatorToolItem() separator.props.draw = False separator.set_expand(True) toolbar_box.toolbar.insert(separator, -1) stop = StopButton(self) toolbar_box.toolbar.insert(stop, -1) toolbar_box.show_all() # add export button separator_2 = Gtk.SeparatorToolItem() separator_2.show() activity_toolbar.insert(separator_2, -1) self.bt_save_as_image = ToolButton() self.bt_save_as_image.props.icon_name = 'save-as-image' self.bt_save_as_image.connect('clicked', self.write_image) self.bt_save_as_image.set_tooltip(_('Save as Image')) activity_toolbar.insert(self.bt_save_as_image, -1) self.bt_save_as_image.show() save_as_pdf = ToolButton() save_as_pdf.props.icon_name = 'save-as-pdf' save_as_pdf.connect('clicked', self._save_as_pdf) save_as_pdf.set_tooltip(_('Save as a Book (PDF)')) activity_toolbar.insert(save_as_pdf, -1) save_as_pdf.show() save_as_ogg = ToolButton() save_as_ogg.props.icon_name = 'save-as-ogg' save_as_ogg.connect('clicked', self.__save_as_ogg_cb) save_as_ogg.set_tooltip(_('Save as a Movie (OGG)')) activity_toolbar.insert(save_as_ogg, -1) Gst.init(None) if Gst.version_string() != 'GStreamer 1.0.10': save_as_ogg.show() activity_button.page.title.connect("focus-in-event", self.on_title) scrolled = Gtk.ScrolledWindow() # scrolled.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.ALWAYS) scrolled.add_with_viewport(self.page) scrolled.set_kinetic_scrolling(False) scrolled.show_all() self._slideview = SlideView(self) self._slideview.show_all() self._notebook = Gtk.Notebook() self._notebook.set_show_tabs(False) self._notebook.append_page(scrolled, None) self._notebook.append_page(self._slideview, None) self._notebook.show_all() if self._jobject.file_path is None or self._jobject.file_path == '': empty_widget = EmptyWidget() empty_widget.connect('choose-image', self.__add_image) self.set_canvas(empty_widget) else: self.set_canvas(self._notebook) self.show() self.metadata['mime_type'] = 'application/x-fototoon-activity' self.page.empty_page = handle.object_id is None self._key_press_signal_id = None
def __init__ (self, handle): if os.path.exists('/tmp/1'): os.remove('/tmp/1') activity.Activity.__init__ (self, handle) # abiword uses the current directory for all its file dialogs os.chdir(os.path.expanduser('~')) # create our main abiword canvas self.abiword_canvas = Canvas() self.set_canvas(self.abiword_canvas) self.abiword_canvas.connect_after('map-event', self.__map_event_cb) self.abiword_canvas.show() if os.path.exists('/tmp/2'): os.remove('/tmp/2') toolbar_box = ToolbarBox() activity_button = ActivityToolbarButton(self) separator = gtk.SeparatorToolItem() separator.show() activity_button.props.page.insert(separator, 2) export_button = ExportButton(self, self.abiword_canvas) export_button.show() activity_button.props.page.insert(export_button, 2) toolbar_box.toolbar.insert(activity_button, 0) edit_toolbar = ToolbarButton() edit_toolbar.props.page = EditToolbar(self, toolbar_box) edit_toolbar.props.icon_name = 'toolbar-edit' edit_toolbar.props.label = _('Edit') toolbar_box.toolbar.insert(edit_toolbar, -1) view_toolbar = ToolbarButton() view_toolbar.props.page = ViewToolbar(self.abiword_canvas) view_toolbar.props.icon_name = 'toolbar-view' view_toolbar.props.label = _('View') toolbar_box.toolbar.insert(view_toolbar, -1) separator = gtk.SeparatorToolItem() toolbar_box.toolbar.insert(separator, -1) toolbar_box.show_all() self.set_toolbar_box(toolbar_box) if os.path.exists('/tmp/3'): os.remove('/tmp/3') text_toolbar = ToolbarButton() text_toolbar.props.page = TextToolbar(self.abiword_canvas) text_toolbar.props.icon_name = 'format-text' text_toolbar.props.label = _('Text') toolbar_box.toolbar.insert(text_toolbar, -1) para_toolbar = ToolbarButton() para_toolbar.props.page = ParagraphToolbar(self.abiword_canvas) para_toolbar.props.icon_name = 'paragraph-bar' para_toolbar.props.label = _('Paragraph') toolbar_box.toolbar.insert(para_toolbar, -1) list_toolbar = ToolbarButton() list_toolbar.props.page = ListToolbar(self.abiword_canvas) list_toolbar.props.icon_name = 'toolbar-bulletlist' list_toolbar.props.label = _('Bullet List') toolbar_box.toolbar.insert(list_toolbar, -1) insert_toolbar = ToolbarButton() insert_toolbar.props.page = InsertToolbar(self.abiword_canvas) insert_toolbar.props.icon_name = 'insert-table' insert_toolbar.props.label = _('Table') toolbar_box.toolbar.insert(insert_toolbar, -1) separator = gtk.SeparatorToolItem() toolbar_box.toolbar.insert(separator, -1) bold = ToggleToolButton('format-text-bold') bold.set_tooltip(_('Bold')) bold_id = bold.connect('clicked', lambda sender: self.abiword_canvas.toggle_bold()) self.abiword_canvas.connect('bold', lambda abi, b: self._setToggleButtonState(bold, b, bold_id)) toolbar_box.toolbar.insert(bold, -1) italic = ToggleToolButton('format-text-italic') italic.set_tooltip(_('Italic')) italic_id = italic.connect('clicked', lambda sender: self.abiword_canvas.toggle_italic()) self.abiword_canvas.connect('italic', lambda abi, b: self._setToggleButtonState(italic, b, italic_id)) toolbar_box.toolbar.insert(italic, -1) underline = ToggleToolButton('format-text-underline') underline.set_tooltip(_('Underline')) underline_id = underline.connect('clicked', lambda sender: self.abiword_canvas.toggle_underline()) self.abiword_canvas.connect('underline', lambda abi, b: self._setToggleButtonState(underline, b, underline_id)) toolbar_box.toolbar.insert(underline, -1) separator = gtk.SeparatorToolItem() toolbar_box.toolbar.insert(separator, -1) color = ColorToolButton() color.connect('color-set', self._text_color_cb, self.abiword_canvas) tool_item = gtk.ToolItem() tool_item.add(color) toolbar_box.toolbar.insert(tool_item, -1) self.abiword_canvas.connect('color', lambda abi, r, g, b: color.set_color(gtk.gdk.Color(r * 256, g * 256, b * 256))) separator = gtk.SeparatorToolItem() separator.props.draw = False separator.set_expand(True) separator.show() toolbar_box.toolbar.insert(separator, -1) stop = StopButton(self) toolbar_box.toolbar.insert(stop, -1) toolbar_box.show_all() self.set_toolbar_box(toolbar_box) self._zoom_handler = self.abiword_canvas.connect("zoom", self.__zoom_cb)