コード例 #1
0
	def testOpenFolderCreate(self):
		from zim.gui.applications import open_folder_prompt_create
		from zim.fs import adapt_from_newfs

		widget = tests.MockObject()
		folder = self.setUpFolder(mock=tests.MOCK_ALWAYS_REAL)
		myfolder = folder.folder('test')
		entry = ApplicationManager().get_fallback_filebrowser()

		def answer_yes(dialog):
			dialog.answer_yes()

		def answer_no(dialog):
			dialog.answer_no()

		with tests.DialogContext(answer_no):
			open_folder_prompt_create(widget, myfolder)

		self.assertFalse(myfolder.exists())
		self.assertEqual(self.calls, [])

		with tests.DialogContext(answer_yes):
			open_folder_prompt_create(widget, myfolder)

		self.assertTrue(myfolder.exists())
		self.assertEqual(self.calls[-1], (widget, entry, adapt_from_newfs(myfolder), None))
コード例 #2
0
 def open_attachments_folder(self):
     '''Menu action to open the attachment folder for the current page'''
     dir = self.notebook.get_attachments_dir(self.page)
     if dir is None:
         error = _('This page does not have an attachments folder')
         # T: Error message
         ErrorDialog(self.widget, error).run()
     else:
         open_folder_prompt_create(self.widget, dir)
コード例 #3
0
 def open_document_root(self):
     '''Menu action to open the document root folder'''
     # TODO: should be insensitive if document_root is not defined
     dir = self.notebook.document_root
     if dir is None:
         error = _('No document root defined for this notebook')
         # T: Error message
         ErrorDialog(self.widget, error).run()
     else:
         open_folder_prompt_create(self.widget, dir)
コード例 #4
0
    def __init__(self, dialog, plugins):
        GObject.GObject.__init__(self)
        self.set_spacing(5)
        self.dialog = dialog
        self.plugins = plugins

        self.hbox = Gtk.HBox(self, spacing=12)
        self.hbox.set_border_width(5)
        self.add(self.hbox)

        #~ logger.debug('Plugins that are loaded: %s' % list(plugins))

        self.treeview = PluginsTreeView(self.plugins)
        self.treeselection = self.treeview.get_selection()
        self.treeselection.connect('changed', self.do_selection_changed)
        swindow = ScrolledWindow(self.treeview, hpolicy=Gtk.PolicyType.NEVER)
        self.hbox.pack_start(swindow, False, True, 0)

        vbox = Gtk.VBox()
        self.hbox.add(vbox)

        # Textview with scrollbars to show plugins info. Required by small screen devices
        swindow, textview = ScrolledTextView()
        textview.set_cursor_visible(False)
        self.textbuffer = textview.get_buffer()
        self.textbuffer.create_tag('bold', weight=Pango.Weight.BOLD)
        self.textbuffer.create_tag('red', foreground='#FF0000')
        vbox.pack_start(swindow, True, True, 0)

        hbox = Gtk.HBox(spacing=5)
        vbox.pack_end(hbox, False, True, 0)

        self.plugin_help_button = \
         Gtk.Button.new_with_mnemonic(_('_More')) # T: Button in plugin tab
        self.plugin_help_button.connect('clicked', self.on_help_button_clicked)
        hbox.pack_start(self.plugin_help_button, False, True, 0)

        self.configure_button = \
         Gtk.Button.new_with_mnemonic(_('C_onfigure')) # T: Button in plugin tab
        self.configure_button.connect('clicked',
                                      self.on_configure_button_clicked)
        hbox.pack_start(self.configure_button, False, True, 0)

        try:
            self.treeselection.select_path(0)
        except:
            pass  # maybe loading plugins failed

        ## Add buttons to get and install new plugins
        hbox = Gtk.HButtonBox()
        hbox.set_border_width(5)
        hbox.set_layout(Gtk.ButtonBoxStyle.START)
        self.pack_start(hbox, False, True, 0)

        open_button = Gtk.Button.new_with_mnemonic(_('Open plugins folder'))
        open_button.connect(
            'clicked', lambda o: open_folder_prompt_create(o, PLUGIN_FOLDER))
        hbox.pack_start(open_button, False, True, 0)

        url_button = Gtk.LinkButton(
            'http://zim-wiki.org/more_plugins.html',
            _('Get more plugins online')  # T: label for button with URL
        )
        hbox.pack_start(url_button, False, True, 0)
コード例 #5
0
 def on_browse(self, *a):
     dir = XDG_DATA_HOME.subdir(('zim', 'templates'))
     open_folder_prompt_create(self, dir)
コード例 #6
0
 def on_open_folder(self, o):
     # Callback for the "open folder" button
     open_folder_prompt_create(self, self.iconview.folder)
     self.iconview.refresh()