예제 #1
0
    def do_response_ok(self):
        tmpfile = TmpFile('insert-screenshot.png')
        selection_mode = False
        delay = 0
        if ScreenshotPicker.has_select_cmd(
                self.screenshot_command) and self.select_radio.get_active():
            selection_mode = True

        if ScreenshotPicker.has_delay_cmd(self.screenshot_command):
            delay = self.time_spin.get_value_as_int()

        options = ScreenshotPicker.get_cmd_options(self.screenshot_command,
                                                   selection_mode, str(delay))
        helper = Application((self.screenshot_command, ) + options)

        def callback(status, tmpfile):
            if status == helper.STATUS_OK:
                name = time.strftime('screenshot_%Y-%m-%d-%H%M%S.png')
                imgdir = self.notebook.get_attachments_dir(self.page)
                imgfile = imgdir.new_file(name)
                tmpfile.rename(imgfile)
                pageview = self.app_window.pageview
                pageview.insert_image(imgfile, interactive=False, force=True)
            else:
                ErrorDialog(
                    self.ui,
                    _('Some error occurred while running "%s"') %
                    self.screenshot_command).run()
                # T: Error message in "insert screenshot" dialog, %s will be replaced by application name

        tmpfile.dir.touch()
        helper.spawn((tmpfile, ), callback, tmpfile)
        return True
예제 #2
0
파일: screenshot.py 프로젝트: gdw2/zim
	def do_response_ok(self):
		tmpfile = TmpFile('insert-screenshot.png')
		options = ()

		if COMMAND == 'scrot':
			if self.select_radio.get_active():
				options += ('--select', '--border')
				# Interactively select a window or rectangle with the mouse.
				# When selecting a window, grab wm border too
			else:
				options += ('--multidisp',)
				# For multiple heads, grab shot from each and join them together.

		delay = self.time_spin.get_value_as_int()
		if delay > 0:
			options += ('-d', str(delay))
			# Wait NUM seconds before taking a shot.

		helper = Application((COMMAND,) + options)

		def callback(status, tmpfile):
			if status == helper.STATUS_OK:
				name = time.strftime('screenshot_%Y-%m-%d-%H%M%S.png')
				dir = self.notebook.get_attachments_dir(self.page)
				file = dir.new_file(name)
				tmpfile.rename(file)
				self.ui.pageview.insert_image(file, interactive=False) # XXX ui == window
			else:
				ErrorDialog(self.ui,
					_('Some error occurred while running "%s"') % COMMAND).run()
					# T: Error message in "insert screenshot" dialog, %s will be replaced by application name

		tmpfile.dir.touch()
		helper.spawn((tmpfile,), callback, tmpfile)
		return True
예제 #3
0
    def make_screenshot(self, selection_mode, delay):
        tmpfile = TmpFile('insert-screenshot.png')
        options = ScreenshotPicker.get_cmd_options(self.screenshot_command,
                                                   selection_mode, str(delay))
        cmd = (self.screenshot_command, ) + options
        helper = Application(cmd)

        def callback(status, tmpfile):
            if status == helper.STATUS_OK:
                name = time.strftime('screenshot_%Y-%m-%d-%H%M%S.png')
                imgdir = self.notebook.get_attachments_dir(self.page)
                imgfile = imgdir.new_file(name)
                tmpfile.rename(imgfile)
                pageview = self.pageview
                pageview.insert_image(imgfile)
            else:
                ErrorDialog(
                    self.ui,
                    _('Some error occurred while running "%s"') %
                    self.screenshot_command).run()
                # T: Error message in "insert screenshot" dialog, %s will be replaced by application name

        tmpfile.dir.touch()
        helper.spawn((tmpfile, ), callback, tmpfile)
        return True

        def callback(status, tmpfile):
            if status == helper.STATUS_OK:
                name = time.strftime('screenshot_%Y-%m-%d-%H%M%S.png')
                imgdir = self.notebook.get_attachments_dir(self.page)
                imgfile = imgdir.new_file(name)
                tmpfile.rename(imgfile)
                pageview = self.pageview
                pageview.insert_image(imgfile)
            else:
                ErrorDialog(
                    self.ui,
                    _('Some error occurred while running "%s"') %
                    self.screenshot_command).run()
                # T: Error message in "insert screenshot" dialog, %s will be replaced by application name

        tmpfile.dir.touch()
        helper.spawn((tmpfile, ), callback, tmpfile)
        return True
예제 #4
0
	def insert_screenshot2(self):
		self.notebook = self.window.ui.notebook  # XXX
		self.page = self.window.ui.page  # XXX
		self.ui = self.window.ui  # XXX
		tmpfile = TmpFile('insert-screenshot.png')
		delay = 0
		selection_mode = True

		helper = Application((self.screenshot_command,))

		def callback(status, tmpfile):
			name = time.strftime('screenshot_%Y-%m-%d-%H%M%S.png')
			imgdir = self.notebook.get_attachments_dir(self.page)
			imgfile = imgdir.new_file(name)
			tmpfile.rename(imgfile)
			pageview = self.ui.mainwindow.pageview
			pageview.insert_image(imgfile, interactive=False, force=True)

		tmpfile.dir.touch()
		helper.spawn((tmpfile,), callback, tmpfile)
예제 #5
0
    def do_response_ok(self):
        tmpfile = TmpFile('insert-screenshot.png')
        options = ()

        if COMMAND == 'scrot':
            if self.select_radio.get_active():
                options += ('--select', '--border')
                # Interactively select a window or rectangle with the mouse.
                # When selecting a window, grab wm border too
            else:
                options += ('--multidisp', )
                # For multiple heads, grab shot from each and join them together.

        delay = self.time_spin.get_value_as_int()
        if delay > 0:
            options += ('-d', str(delay))
            # Wait NUM seconds before taking a shot.

        helper = Application((COMMAND, ) + options)

        def callback(status, tmpfile):
            if status == helper.STATUS_OK:
                name = time.strftime('screenshot_%Y-%m-%d-%H%M%S.png')
                dir = self.notebook.get_attachments_dir(self.page)
                file = dir.new_file(name)
                tmpfile.rename(file)
                self.ui.pageview.insert_image(
                    file, interactive=False)  # XXX ui == window
            else:
                ErrorDialog(
                    self.ui,
                    _('Some error occurred while running "%s"') %
                    COMMAND).run()
                # T: Error message in "insert screenshot" dialog, %s will be replaced by application name

        tmpfile.dir.touch()
        helper.spawn((tmpfile, ), callback, tmpfile)
        return True
예제 #6
0
	def spawn(self, *args):
		'''Spawn a new instance of zim'''
		# TODO: after implementing the daemon, put this in that module
		from zim.applications import Application
		zim = Application((ZIM_EXECUTABLE,) + args)
		zim.spawn()