Example #1
0
 def save_operate(self, widget=None):
     '''do save operate'''
     screenshot = self.screenshot
     if screenshot.is_subprocess:
         screenshot.save_to_tmp_file()
     else:
         # auto save
         if screenshot.save_op_index == SAVE_OP_AUTO:
             folder = utils.get_pictures_dir()
             filename = "%s%s.%s" % (_(DEFAULT_FILENAME),
                                     utils.get_format_time(), "png")
             screenshot.save_snapshot("%s/%s" % (folder, filename))
         # save as
         elif screenshot.save_op_index == SAVE_OP_AS:
             self.save_to_file()
         # copy to clip
         elif screenshot.save_op_index == SAVE_OP_CLIP:
             screenshot.save_snapshot()
         # auto save and copy to clip
         else:
             folder = utils.get_pictures_dir()
             filename = "%s%s.%s" % (_(DEFAULT_FILENAME),
                                     utils.get_format_time(), "png")
             screenshot.save_snapshot("%s/%s" % (folder, filename),
                                      clip_flag=True)
Example #2
0
 def save_to_file(self):
     ''' save to file '''
     self.win.hide_colorbar()
     self.win.hide_toolbar()
     #dialog = SaveFileDialog('', self.screenshot.window.window,
         #ok_callback=self._save_to_file_cb, cancel_callback=self._save_to_file_cancel)
     dialog = gtk.FileChooserDialog(
         "Save..",
         self.win.window,
         gtk.FILE_CHOOSER_ACTION_SAVE,
         (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT,
          gtk.STOCK_SAVE, gtk.RESPONSE_ACCEPT))
     dialog.set_action(gtk.FILE_CHOOSER_ACTION_SAVE)
     dialog.set_default_response(gtk.RESPONSE_ACCEPT)
     dialog.set_position(gtk.WIN_POS_MOUSE)
     dialog.set_local_only(True)
     last_folder = self.__config.get("save", "folder")
     if last_folder:
         dialog.set_current_folder(last_folder)
     else:
         dialog.set_current_folder(utils.get_pictures_dir())
     if config.OPTION_FILE:
         dialog.set_current_name(config.OPTION_FILE)
     else:
         dialog.set_current_name("%s%s.%s" % (_(DEFAULT_FILENAME), utils.get_format_time(), "png"))
     response = dialog.run()
     filename = dialog.get_filename()
     if response == gtk.RESPONSE_ACCEPT:
         self.__config.set("save", folder=dialog.get_current_folder())
         self._save_to_file_cb(filename)
     else:
         self._save_to_file_cancel(filename)
     dialog.destroy()
Example #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()
Example #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()
Example #5
0
 def save_to_file(self):
     ''' save to file '''
     self.win.hide_colorbar()
     self.win.hide_toolbar()
     #dialog = SaveFileDialog('', self.screenshot.window.window,
     #ok_callback=self._save_to_file_cb, cancel_callback=self._save_to_file_cancel)
     dialog = gtk.FileChooserDialog("Save..", self.win.window,
                                    gtk.FILE_CHOOSER_ACTION_SAVE,
                                    (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT,
                                     gtk.STOCK_SAVE, gtk.RESPONSE_ACCEPT))
     dialog.set_action(gtk.FILE_CHOOSER_ACTION_SAVE)
     dialog.set_default_response(gtk.RESPONSE_ACCEPT)
     dialog.set_position(gtk.WIN_POS_MOUSE)
     dialog.set_local_only(True)
     last_folder = self.__config.get("save", "folder")
     if last_folder:
         dialog.set_current_folder(last_folder)
     else:
         dialog.set_current_folder(utils.get_pictures_dir())
     dialog.set_current_name(
         "%s%s.%s" % (_(DEFAULT_FILENAME), utils.get_format_time(), "png"))
     response = dialog.run()
     filename = dialog.get_filename()
     if response == gtk.RESPONSE_ACCEPT:
         self.__config.set("save", folder=dialog.get_current_folder())
         self._save_to_file_cb(filename)
     else:
         self._save_to_file_cancel(filename)
     dialog.destroy()
Example #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()
Example #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()
Example #8
0
 def save_operate(self, widget=None):
     '''do save operate'''
     screenshot = self.screenshot
     #print "operate:", screenshot.save_op_index
     # auto save
     if screenshot.save_op_index == SAVE_OP_AUTO:
         folder = utils.get_pictures_dir()
         filename = "%s%s.%s" % (_(DEFAULT_FILENAME), utils.get_format_time(), "png")
         screenshot.save_snapshot("%s/%s" % (folder, filename))
     # save as
     elif screenshot.save_op_index == SAVE_OP_AS:
         self.save_to_file()
     # copy to clip
     elif screenshot.save_op_index == SAVE_OP_CLIP:
         screenshot.save_snapshot()
     # auto save and copy to clip
     else:
         folder = utils.get_pictures_dir()
         filename = "%s%s.%s" % (_(DEFAULT_FILENAME), utils.get_format_time(), "png")
         screenshot.save_snapshot("%s/%s" % (folder, filename), clip_flag=True)