Example #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()
Example #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()
Example #3
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()
Example #4
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()