Esempio n. 1
0
 def on_menu_reset(self, event):
     yes = utils.make_yesno_dlg(_(u'Are you sure you want to reset?'),
                                _(u'Are you sure?'))
     if yes:
         configs.load(self, app.get_real_path('default.cfg'))
         self.picker.view.path.SetValue(u'')
         self.picker.clear_all()
Esempio n. 2
0
    def __rename_item_list(self, event):
        """After pre-renaming checks are completed, rename the list of items."""
        # calculate refresh settings
        count = len(main.toRename)
        count = count / 25 + 1
        if count > int(app.prefs.get('renRefreshMin')):
            count = int(app.prefs.get('renRefreshMin'))

        # define here for faster processing
        def exists(item):
            return os.path.exists(item)

        def join(a, b, c):
            return unicode(os.path.join(a, b, c))

        warn = False
        if event != u'undo':
            path = main.picker.params.root

        # renaming operation:
        i = 0
        for original, renamed in main.toRename:
            if warn != 'duplicate_name' and self.__compare(renamed, original) and\
                exists(renamed[0]):
                # set item as bad
                main.toRename[i][1][1] = None
                self._set_display(i)
                main.set_status_msg(_(u"Duplicate name"), u'warn')
                msg = _(u"This name already exists:\n%s") % renamed[0]\
                    + _(u"\n\nI can make a sub-folder called 't_e_m_p' and do the renaming operation there.\nYou can then move everything back.\n\nGo ahead and do this?")
                title = _(u"Duplicate name")
                if utils.make_yesno_dlg(msg, title):
                    warn = 'duplicate_name'
                else:
                    error = True
                    break
            # set correct path if in dupe error mode
            if warn == 'duplicate_name':
                if not path.endswith(os.sep):
                    path = path + os.sep
                renamed[0] = renamed[0].replace(path, u'')
                renamed[0] = join(path, u't_e_m_p', renamed[0])

            # the actual renaimg op
            error = self._rename_item(i, original, renamed, count)

            if error:
                break
            i += 1
            app.debug_print("%s\n%s\n" % (original[0], renamed[0]))

        main.set_status_msg(_(u"Writing undo files, please wait ..."), u'wait')
        # write out undo files
        backup = main.toRename[:i]
        if app.recursiveFolderOn:
            backup.reverse()
        for original, renamed in backup:
            self.originalFile.write(original[0] + u'\n')
            self.renamedFile.write(renamed[0] + u'\n')
        return error, i
Esempio n. 3
0
    def __rename_item_list(self, event):
        """After pre-renaming checks are completed, rename the list of items."""
        # calculate refresh settings
        count = len(main.toRename)
        count = count / 25 + 1
        if count > int(app.prefs.get('renRefreshMin')):
            count = int(app.prefs.get('renRefreshMin'))

        # define here for faster processing
        def exists(item):
            return os.path.exists(item)
        def join(a, b, c):
            return unicode(os.path.join(a, b, c))

        warn = False
        if event != u'undo':
            path = main.picker.params.root

        # renaming operation:
        i = 0
        for original, renamed in main.toRename:
            if warn != 'duplicate_name' and self.__compare(renamed, original) and\
                exists(renamed[0]):
                    # set item as bad
                    main.toRename[i][1][1] = None
                    self._set_display(i)
                    main.set_status_msg(_(u"Duplicate name"), u'warn')
                    msg = _(u"This name already exists:\n%s") % renamed[0]\
                        + _(u"\n\nI can make a sub-folder called 't_e_m_p' and do the renaming operation there.\nYou can then move everything back.\n\nGo ahead and do this?")
                    title = _(u"Duplicate name")
                    if utils.make_yesno_dlg(msg, title):
                        warn = 'duplicate_name'
                    else:
                        error = True
                        break
            # set correct path if in dupe error mode
            if warn == 'duplicate_name':
                if not path.endswith(os.sep):
                    path = path + os.sep
                renamed[0] = renamed[0].replace(path, u'')
                renamed[0] = join(path, u't_e_m_p', renamed[0])

            # the actual renaimg op
            error = self._rename_item(i, original, renamed, count)

            if error:
                break
            i += 1
            app.debug_print("%s\n%s\n" % (original[0], renamed[0]))

        main.set_status_msg(_(u"Writing undo files, please wait ..."), u'wait')
        # write out undo files
        backup = main.toRename[:i]
        if app.recursiveFolderOn:
            backup.reverse()
        for original, renamed in backup:
            self.originalFile.write(original[0] + u'\n')
            self.renamedFile.write(renamed[0] + u'\n')
        return error, i
Esempio n. 4
0
 def __destroy_all_gui_operations(self, event):
     """Destroy all operations from GUI."""
     if self.Core.operations:
         msg = _("Really delete all operations?\nThis cannot be undone.")
         title = _("Are You Sure?")
         if utils.make_yesno_dlg(msg, title):
             self.destroy_all_operations()
             main.show_preview(event)
Esempio n. 5
0
 def __destroy_all_gui_operations(self, event):
     """Destroy all operations from GUI."""
     if self.Core.operations:
         msg = _("Really delete all operations?\nThis cannot be undone.")
         title = _("Are You Sure?")
         if utils.make_yesno_dlg(msg, title):
             self.destroy_all_operations()
             main.show_preview(event)
Esempio n. 6
0
    def rename(self, event):
        """
        Write undo files first (safety first !), then attemp to perform
        the renaming operation.
        """
        itemsRenamed = 0
        error = False
        main.currentItem = None
        main.bottomWindow.display.mode = 'rename'
        utils.set_busy(True)
        main.picker.view.path.SetEditable(False)

        # adjust and sort items when recursively renaming folders
        if app.recursiveFolderOn and event != u'undo':
            main.set_status_msg(
                _(u"Adjusting %s recursive paths, please wait ...") %
                len(main.toRename), u'wait')

            progressDialog = classes.ProgressDialog(
                main, app.prefs, main.items,
                _(u"Adjusting %%% recursive paths, please wait ..."))

            if app.showTimes:
                t = time.time()

            def sort_test(n):
                return -n[1][0].count(os.sep)

            main.toRename.sort(key=sort_test)

            progressDialog.destroy()

            if app.showTimes:
                print("%s items recursive adjust : %s" % (len(main.toRename),
                                                          (time.time() - t)))

        if not error:
            main.set_status_msg(_(u"Renaming in progress, please wait ..."),
                                u'wait')

            # open undo files for writing
            try:
                self.originalFile = codecs.open(
                    utils.get_user_path(u'undo/original.bak'), 'w', "utf-8")
                self.renamedFile = codecs.open(
                    utils.get_user_path(u'undo/renamed.bak'), 'w', "utf-8")
            except IOError as (n, strerror):
                msg = strerror + _(
                    u"\nMake sure 'undo' directory exists and is read/write\n\nYou will not be able to undo!!\nDo you want to continue??"
                )
                title = _(u"Problem with undo!")
                if not utils.make_yesno_dlg(msg, title):
                    error = 'cancelled'
                dlg.Destroy()
Esempio n. 7
0
    def rename(self, event):
        """
        Write undo files first (safety first !), then attemp to perform
        the renaming operation.
        """
        itemsRenamed = 0
        error = False
        main.currentItem = None
        main.bottomWindow.display.mode = 'rename'
        utils.set_busy(True)
        main.picker.view.path.SetEditable(False)

        # adjust and sort items when recursively renaming folders
        if app.recursiveFolderOn and event != u'undo':
            main.set_status_msg(_(u"Adjusting %s recursive paths, please wait ...") % len(main.toRename), u'wait')

            progressDialog = classes.ProgressDialog(main, app.prefs, main.items,
                                                    _(u"Adjusting %%% recursive paths, please wait ..."))

            if app.showTimes:
                t = time.time()

            def sort_test(n):
                return -n[1][0].count(os.sep)

            main.toRename.sort(key=sort_test)

            progressDialog.destroy()

            if app.showTimes:
                print("%s items recursive adjust : %s" % (len(main.toRename), (time.time() - t)))

        if not error:
            main.set_status_msg(_(u"Renaming in progress, please wait ..."), u'wait')

            # open undo files for writing
            try:
                self.originalFile = codecs.open(utils.get_user_path(u'undo/original.bak'), 'w', "utf-8")
                self.renamedFile = codecs.open(utils.get_user_path(u'undo/renamed.bak'), 'w', "utf-8")
            except IOError as (n, strerror):
                msg = strerror + _(u"\nMake sure 'undo' directory exists and is read/write\n\nYou will not be able to undo!!\nDo you want to continue??")
                title = _(u"Problem with undo!")
                if not utils.make_yesno_dlg(msg, title):
                    error = 'cancelled'
                dlg.Destroy()
Esempio n. 8
0
 def on_menu_reset(self, event):
     yes = utils.make_yesno_dlg(_(u'Are you sure you want to reset?'), _(u'Are you sure?'))
     if yes:
         configs.load(self, app.get_real_path('default.cfg'))
         self.picker.view.path.SetValue(u'')
         self.picker.clear_all()
Esempio n. 9
0
        """Write given language to 'language.ini' file."""
        try:
            langFile = codecs.open(utils.get_user_path(u'language.ini'), 'w', 'utf-8')
        except IOError, error:
            utils.make_err_msg(unicode(error), u"Error")
            pass
        else:
            langFile.write(language)
            langFile.close()
        if event:
            msg = _(u"\n\nYou will need to restart Metamorphose to change the language.")
            msg += _(u"\n\nClose out of Metamorphose now?")
            msg = language + msg
            title = _(u"Change the Language")
            # Restart app automatically if not in windows
            if utils.make_yesno_dlg(msg, title):
                if platform.system() != 'Windows':
                    if wx.Process.Open(app.get_real_path(sys.argv[0])):
                        self.Close()
                else:
                    self.Close()

    def set_status_msg(self, msg, img):
        """Set status bar text and image."""
        self.statusImage.SetBitmap(self.statusImages[img])
        self.SetStatusText(self.make_space(msg))
        app.debug_print(u"status message: '%s'" % msg)

#
#--- MENU ACTIONS: -----------------------------------------------------------#
#
Esempio n. 10
0
        """Write given language to 'language.ini' file."""
        try:
            langFile = codecs.open(utils.get_user_path(u'language.ini'), 'w', 'utf-8')
        except IOError, error:
            utils.make_err_msg(unicode(error), u"Error")
            pass
        else:
            langFile.write(language)
            langFile.close()
        if event:
            msg = _(u"\n\nYou will need to restart Metamorphose to change the language.")
            msg += _(u"\n\nClose out of Metamorphose now?")
            msg = language + msg
            title = _(u"Change the Language")
            # Restart app automatically if not in windows
            if utils.make_yesno_dlg(msg, title):
                if platform.system() != 'Windows':
                    if wx.Process.Open(app.get_real_path(sys.argv[0])):
                        self.Close()
                else:
                    self.Close()

    def set_status_msg(self, msg, img):
        """Set status bar text and image."""
        self.statusImage.SetBitmap(self.statusImages[img])
        self.SetStatusText(self.make_space(msg))
        app.debug_print(u"status message: '%s'" % msg)

#
#--- MENU ACTIONS: -----------------------------------------------------------#
#