示例#1
0
def processArguments():
    '''init process arguments '''
    parser = OptionParser(usage="Usage: deepin-screenshot [options] [arg]", version="deepin-screenshot v2.1")
    parser.add_option("-f", "--full", action="store_true", dest="fullscreen", help=_("Take a screenshot of full screen"))
    parser.add_option("-w", "--window", action="store_true", dest="window", help=_("Take a screenshot of the window"))
    parser.add_option("-d", "--delay", dest="delay", type="int", help=_("Take a screenshot after NUM seconds"), metavar="NUM")
    parser.add_option("-s", "--save", dest="save_file", help=_("save screenshot to FILE"), metavar="FILE")
    parser.add_option("--sub", action="store_true", dest="sub", help=_("run as a subprocess"))
    parser.add_option("-n", "--new", action="store_true", dest="new", help=_("run a new process"))
    parser.add_option("-I", "--icon", action="store_true", dest="icon")
    #parser.add_option("-a", "--area", help="Grab an area of the screen instead of the entire screen", action="store_true")
    #parser.add_option("-e", "--border-effect", action="store_true", dest="border_effect", help="Effect to add to the border")
    #parser.add_option("-i", "--interactive", action="store_true", help="Interactively set options")
    #parser.add_option("-b", "--include-border", action="store_true", help="Include the window border with the screenshot")
    #parser.add_option("-B", "--remove-border", action="store_true", help="Remove the window border from the screenshot")
    #parser.add_option("-c", "--clipboard", help="Send the grab directly to the clipboard", action="store_true")
    parser.get_option('-h').help = _("show this help message and exit")
    parser.get_option('--version').help = _("show program's version number and exit")
    
    import sys
    if '-h' in sys.argv or '--help' in sys.argv:
        parser.remove_option("-I")
    (options, args) = parser.parse_args()

    if not options.new and IS_EXISTS:
        print "deepint-screenshot has run"
        exit(1)
    if options.fullscreen and options.window:
        parser.error("options -f and -w are mutually exclusive")
    config.OPTION_ICON = options.icon
    config.OPTION_FULLSCREEN = options.fullscreen
    config.OPTION_WINDOWN = options.window
    config.OPTION_NEW = options.new
    config.OPTION_FILE = options.save_file
    config.OPTION_SUB = options.sub
    if options.delay:
        notify("Deepin Screenshot", 0, summary=_("DScreenshot"),
               body=_("Deepin Screenshot will start in %d seconds.") % options.delay, timeout=(options.delay-0.5)*1000)
        loop = gobject.MainLoop()
        gobject.timeout_add_seconds(options.delay, loop.quit)
        loop.run()
    if options.save_file:
        parserFile = parser_path(str(options.save_file))
        if options.fullscreen:
            pixbuf = get_screenshot_pixbuf(True)
            pixbuf.save(parserFile[0], parserFile[1])
        elif options.window:
            pixbuf = get_screenshot_pixbuf(False)
            pixbuf.save(parserFile[0], parserFile[1])
        else:    
            main()
    elif options.fullscreen:
        open_file_dialog()
    elif options.window:
        open_file_dialog(False)
    else:
        main()
示例#2
0
def processArguments():
    '''init process arguments '''
    parser = OptionParser(usage="Usage: deepin-screenshot [options] [arg]",
                          version="deepin-screenshot v2.1")
    parser.add_option("-f",
                      "--full",
                      action="store_true",
                      dest="fullscreen",
                      help="Taking the fullscreen shot")
    parser.add_option("-w",
                      "--window",
                      action="store_true",
                      dest="window",
                      help="Taking the currently focused window")
    parser.add_option("-d",
                      "--delay",
                      dest="delay",
                      type="int",
                      help="wait NUM seconds before taking a shot",
                      metavar="NUM")
    parser.add_option("-s",
                      "--save",
                      dest="save_file",
                      help="save screenshot to FILE",
                      metavar="FILE")
    #parser.add_option("-a", "--area", help="Grab an area of the screen instead of the entire screen", action="store_true")
    #parser.add_option("-e", "--border-effect", action="store_true", dest="border_effect", help="Effect to add to the border")
    #parser.add_option("-i", "--interactive", action="store_true", help="Interactively set options")
    #parser.add_option("-b", "--include-border", action="store_true", help="Include the window border with the screenshot")
    #parser.add_option("-B", "--remove-border", action="store_true", help="Remove the window border from the screenshot")
    #parser.add_option("-c", "--clipboard", help="Send the grab directly to the clipboard", action="store_true")

    (options, args) = parser.parse_args()

    if options.fullscreen and options.window:
        parser.error("options -f and -w are mutually exclusive")
    if options.delay:
        CountdownWindow(options.delay)
    if options.save_file:
        parserFile = parser_path(str(options.save_file))
        if options.fullscreen:
            pixbuf = get_screenshot_pixbuf(True)
            pixbuf.save(parserFile[0], parserFile[1])
        elif options.window:
            pixbuf = get_screenshot_pixbuf(False)
            pixbuf.save(parserFile[0], parserFile[1])
        else:
            main(options.save_file)
    elif options.fullscreen:
        open_file_dialog()
    elif options.window:
        open_file_dialog(False)
    else:
        main()
示例#3
0
def open_file_dialog(fullscreen=True, filetype='png'):
    '''
    Save file to file.
    @param fullscreen: if get the fullscreen snapshot.
    @parser filetype: the filetype to save
    '''
    pixbuf = get_screenshot_pixbuf(fullscreen)
    dialog = gtk.FileChooserDialog("Save..", None,
                                   gtk.FILE_CHOOSER_ACTION_SAVE,
                                   (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT,
                                    gtk.STOCK_SAVE, gtk.RESPONSE_ACCEPT))
    dialog.set_default_response(gtk.RESPONSE_ACCEPT)
    dialog.set_position(gtk.WIN_POS_CENTER)
    dialog.set_local_only(True)
    dialog.set_current_folder(get_pictures_dir())
    dialog.set_current_name("%s%s.%s" %
                            (_(DEFAULT_FILENAME), get_format_time(), "png"))

    response = dialog.run()
    if response == gtk.RESPONSE_ACCEPT:
        filename = dialog.get_filename()
        pixbuf.save(filename, save_filetype)
        print "Save snapshot to %s" % (filename)
    elif response == gtk.RESPONSE_REJECT:
        print 'Closed, no files selected'
    dialog.destroy()
示例#4
0
def open_file_dialog(fullscreen=True, filetype='png'):
    '''
    Save file to file.
    @param fullscreen: if get the fullscreen snapshot.
    @parser filetype: the filetype to save
    '''
    pixbuf = get_screenshot_pixbuf(fullscreen)
    dialog = gtk.FileChooserDialog(
        "Save..",
        None,
        gtk.FILE_CHOOSER_ACTION_SAVE,
        (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT,
        gtk.STOCK_SAVE, gtk.RESPONSE_ACCEPT))
    dialog.set_default_response(gtk.RESPONSE_ACCEPT)
    dialog.set_position(gtk.WIN_POS_CENTER)
    dialog.set_local_only(True)
    dialog.set_current_folder(get_pictures_dir())
    dialog.set_current_name("%s%s.%s" % (_(DEFAULT_FILENAME), get_format_time(), "png"))

    response = dialog.run()
    if response == gtk.RESPONSE_ACCEPT:
        filename = dialog.get_filename()
        pixbuf.save(filename, save_filetype)
        print "Save snapshot to %s" % (filename)
    elif response == gtk.RESPONSE_REJECT:
        print 'Closed, no files selected'
    dialog.destroy()
示例#5
0
def processArguments():
    '''init process arguments '''
    parser = OptionParser(usage="Usage: deepin-screenshot [options] [arg]", version="deepin-screenshot v2.1")
    parser.add_option("-f", "--full", action="store_true", dest="fullscreen", help="Taking the fullscreen shot")
    parser.add_option("-w", "--window", action="store_true", dest="window", help="Taking the currently focused window")
    parser.add_option("-d", "--delay", dest="delay", type="int", help="wait NUM seconds before taking a shot", metavar="NUM")
    parser.add_option("-s", "--save", dest="save_file", help="save screenshot to FILE", metavar="FILE")
    #parser.add_option("-a", "--area", help="Grab an area of the screen instead of the entire screen", action="store_true")
    #parser.add_option("-e", "--border-effect", action="store_true", dest="border_effect", help="Effect to add to the border")
    #parser.add_option("-i", "--interactive", action="store_true", help="Interactively set options")
    #parser.add_option("-b", "--include-border", action="store_true", help="Include the window border with the screenshot")
    #parser.add_option("-B", "--remove-border", action="store_true", help="Remove the window border from the screenshot")
    #parser.add_option("-c", "--clipboard", help="Send the grab directly to the clipboard", action="store_true")
    
    (options, args) = parser.parse_args()

    if options.fullscreen and options.window:
        parser.error("options -f and -w are mutually exclusive")
    if options.delay:
        CountdownWindow(options.delay)
    if options.save_file:
        parserFile = parser_path(str(options.save_file))
        if options.fullscreen:
            pixbuf = get_screenshot_pixbuf(True)
            pixbuf.save(parserFile[0], parserFile[1])
        elif options.window:
            pixbuf = get_screenshot_pixbuf(False)
            pixbuf.save(parserFile[0], parserFile[1])
        else:    
            main(options.save_file)
    elif options.fullscreen:
        open_file_dialog()
    elif options.window:
        open_file_dialog(False)
    else:
        main()
示例#6
0
def open_file_dialog(fullscreen=True, filetype='png'):
    '''
    Save file to file.
    @param fullscreen: if get the fullscreen snapshot.
    @parser filetype: the filetype to save
    '''
    from constant import SAVE_OP_AUTO, SAVE_OP_AUTO_AND_CLIP, SAVE_OP_AS
    from _share.config import OperateConfig
    config = OperateConfig()
    save_op = config.get("save", "save_op")
    if save_op:
        save_op_index = int(save_op)
    else:
        save_op_index = SAVE_OP_AS
    pixbuf = get_screenshot_pixbuf(fullscreen)
    if save_op_index == SAVE_OP_AUTO or save_op_index == SAVE_OP_AUTO_AND_CLIP:
        filename = "%s/%s%s.%s" % (get_pictures_dir(), _(DEFAULT_FILENAME),
                                   get_format_time(), "png")
        pixbuf.save(filename, save_filetype)
        msg = "%s '%s'" % (_("Picture has been saved to file"), filename)
        SCROT_BUS.emit_finish(1, filename)
        notify("Deepin Screenshot", 0, summary=_("DScreenshot"), body=msg)
    else:
        dialog = gtk.FileChooserDialog(
            "Save..",
            None,
            gtk.FILE_CHOOSER_ACTION_SAVE,
            (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT,
            gtk.STOCK_SAVE, gtk.RESPONSE_ACCEPT))
        dialog.set_default_response(gtk.RESPONSE_ACCEPT)
        dialog.set_position(gtk.WIN_POS_CENTER)
        dialog.set_local_only(True)
        dialog.set_current_folder(get_pictures_dir())
        dialog.set_current_name("%s%s.%s" % (_(DEFAULT_FILENAME), get_format_time(), "png"))

        response = dialog.run()
        if response == gtk.RESPONSE_ACCEPT:
            filename = dialog.get_filename()
            pixbuf.save(filename, save_filetype)
            msg = "%s '%s'" % (_("Picture has been saved to file"), filename)
            SCROT_BUS.emit_finish(1, filename)
            notify("Deepin Screenshot", 0, summary=_("DScreenshot"), body=msg)
        elif response == gtk.RESPONSE_REJECT:
            print 'Closed, no files selected'
        dialog.destroy()
示例#7
0
def open_file_dialog(fullscreen=True, filetype='png'):
    '''
    Save file to file.
    @param fullscreen: if get the fullscreen snapshot.
    @parser filetype: the filetype to save
    '''
    from constant import SAVE_OP_AUTO, SAVE_OP_AUTO_AND_CLIP, SAVE_OP_AS
    from _share.config import OperateConfig
    config = OperateConfig()
    save_op = config.get("save", "save_op")
    if save_op:
        save_op_index = int(save_op)
    else:
        save_op_index = SAVE_OP_AS
    pixbuf = get_screenshot_pixbuf(fullscreen)
    if save_op_index == SAVE_OP_AUTO or save_op_index == SAVE_OP_AUTO_AND_CLIP:
        filename = "%s/%s%s.%s" % (get_pictures_dir(), _(DEFAULT_FILENAME),
                                   get_format_time(), "png")
        pixbuf.save(filename, save_filetype)
        msg = "%s '%s'" % (_("Picture has been saved to file"), filename)
        SCROT_BUS.emit_finish(1, filename)
        notify("Deepin Screenshot", 0, summary=_("DScreenshot"), body=msg)
    else:
        dialog = gtk.FileChooserDialog("Save..", None,
                                       gtk.FILE_CHOOSER_ACTION_SAVE,
                                       (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT,
                                        gtk.STOCK_SAVE, gtk.RESPONSE_ACCEPT))
        dialog.set_default_response(gtk.RESPONSE_ACCEPT)
        dialog.set_position(gtk.WIN_POS_CENTER)
        dialog.set_local_only(True)
        dialog.set_current_folder(get_pictures_dir())
        dialog.set_current_name(
            "%s%s.%s" % (_(DEFAULT_FILENAME), get_format_time(), "png"))

        response = dialog.run()
        if response == gtk.RESPONSE_ACCEPT:
            filename = dialog.get_filename()
            pixbuf.save(filename, save_filetype)
            msg = "%s '%s'" % (_("Picture has been saved to file"), filename)
            SCROT_BUS.emit_finish(1, filename)
            notify("Deepin Screenshot", 0, summary=_("DScreenshot"), body=msg)
        elif response == gtk.RESPONSE_REJECT:
            print 'Closed, no files selected'
        dialog.destroy()
示例#8
0
def processArguments():
    '''init process arguments '''
    parser = OptionParser(usage="Usage: deepin-screenshot [options] [arg]",
                          version="deepin-screenshot v2.1")
    parser.add_option("-f",
                      "--full",
                      action="store_true",
                      dest="fullscreen",
                      help=_("Take a screenshot of full screen"))
    parser.add_option("-w",
                      "--window",
                      action="store_true",
                      dest="window",
                      help=_("Take a screenshot of the window"))
    parser.add_option("-d",
                      "--delay",
                      dest="delay",
                      type="int",
                      help=_("Take a screenshot after NUM seconds"),
                      metavar="NUM")
    parser.add_option("-s",
                      "--save",
                      dest="save_file",
                      help=_("save screenshot to FILE"),
                      metavar="FILE")
    parser.add_option("--sub",
                      action="store_true",
                      dest="sub",
                      help=_("run as a subprocess"))
    parser.add_option("-n",
                      "--new",
                      action="store_true",
                      dest="new",
                      help=_("run a new process"))
    parser.add_option("-I", "--icon", action="store_true", dest="icon")
    #parser.add_option("-a", "--area", help="Grab an area of the screen instead of the entire screen", action="store_true")
    #parser.add_option("-e", "--border-effect", action="store_true", dest="border_effect", help="Effect to add to the border")
    #parser.add_option("-i", "--interactive", action="store_true", help="Interactively set options")
    #parser.add_option("-b", "--include-border", action="store_true", help="Include the window border with the screenshot")
    #parser.add_option("-B", "--remove-border", action="store_true", help="Remove the window border from the screenshot")
    #parser.add_option("-c", "--clipboard", help="Send the grab directly to the clipboard", action="store_true")
    parser.get_option('-h').help = _("show this help message and exit")
    parser.get_option('--version').help = _(
        "show program's version number and exit")

    import sys
    if '-h' in sys.argv or '--help' in sys.argv:
        parser.remove_option("-I")
    (options, args) = parser.parse_args()

    if not options.new and IS_EXISTS:
        print "deepint-screenshot has run"
        exit(1)
    if options.fullscreen and options.window:
        parser.error("options -f and -w are mutually exclusive")
    config.OPTION_ICON = options.icon
    config.OPTION_FULLSCREEN = options.fullscreen
    config.OPTION_WINDOWN = options.window
    config.OPTION_NEW = options.new
    config.OPTION_FILE = options.save_file
    config.OPTION_SUB = options.sub
    if options.delay:
        notify("Deepin Screenshot",
               0,
               summary=_("DScreenshot"),
               body=_("Deepin Screenshot will start in %d seconds.") %
               options.delay,
               timeout=(options.delay - 0.5) * 1000)
        loop = gobject.MainLoop()
        gobject.timeout_add_seconds(options.delay, loop.quit)
        loop.run()
    if options.save_file:
        parserFile = parser_path(str(options.save_file))
        if options.fullscreen:
            pixbuf = get_screenshot_pixbuf(True)
            pixbuf.save(parserFile[0], parserFile[1])
        elif options.window:
            pixbuf = get_screenshot_pixbuf(False)
            pixbuf.save(parserFile[0], parserFile[1])
        else:
            main()
    elif options.fullscreen:
        open_file_dialog()
    elif options.window:
        open_file_dialog(False)
    else:
        main()