Ejemplo n.º 1
0
    def update_treeview(self):
        """Clears and redraws all the import presets in the treeview."""

        app = App.get_running_app()
        presets = self.ids['presets']

        #Clear old presets
        presets.clear_widgets()

        #Check if screenDatabase folders are set, cant import without somewhere to import to.
        database_folders = app.config.get('Database Directories', 'paths')
        database_folders = local_path(database_folders)
        if database_folders.strip(' '):
            databases = database_folders.split(';')
        else:
            databases = []
        new_preset_button = self.ids['newPresetButton']
        if databases:
            new_preset_button.disabled = False
            for index, import_preset in enumerate(app.imports):
                preset = ImportPreset(index=index,
                                      text=import_preset['title'],
                                      owner=self,
                                      import_to=import_preset['import_to'])
                preset.data = import_preset
                if index == self.selected_import:
                    preset.expanded = True
                presets.add_widget(preset)
        else:
            new_preset_button.disabled = True
            presets.add_widget(
                NormalLabel(
                    text="You Must Set Up A Database Before Importing Photos"))
Ejemplo n.º 2
0
    def import_preset(self):
        """Activates the import process using the selected import preset."""

        app = App.get_running_app()
        preset = app.imports[self.selected_import]
        if not preset['import_from']:
            app.message("Please Set An Import Directory.")
            return
        good_paths = []
        for path in preset['import_from']:
            if os.path.exists(path):
                good_paths.append(path)
        if not good_paths:
            app.message("Directories to import photo from do not exist.")
            return
        if not os.path.exists(preset['import_to']):
            app.message(
                "Directory to import photo to do not exist or is not accessible."
            )
            return
        database_folders = app.config.get('Database Directories', 'paths')
        database_folders = local_path(database_folders)
        if database_folders.strip(' '):
            databases = database_folders.split(';')
        else:
            databases = []
        if preset['import_to'] not in databases:
            app.message("Please Set A Database To Import To.")
            return
        app.importing_screen.import_to = preset['import_to']
        app.importing_screen.naming_method = preset['naming_method']
        app.importing_screen.delete_originals = preset['delete_originals']
        app.importing_screen.import_from = preset['import_from']
        app.importing_screen.single_folder = preset['single_folder']
        app.show_importing()
Ejemplo n.º 3
0
 def __init__(self, **kwargs):
     super(ImportPresetArea, self).__init__(**kwargs)
     Clock.schedule_once(self.update_import_from)
     app = App.get_running_app()
     self.imports_dropdown = NormalDropDown()
     self.imports_dropdown.basic_animation = True
     database_folders = app.config.get('Database Directories', 'paths')
     database_folders = local_path(database_folders)
     if database_folders.strip(' '):
         databases = database_folders.split(';')
     else:
         databases = []
     for database in databases:
         menu_button = MenuButton(text=database)
         menu_button.bind(on_release=self.change_import_to)
         self.imports_dropdown.add_widget(menu_button)
Ejemplo n.º 4
0
  def album_load_all(self):
    """Scans the album directory, and tries to load all album .ini files into the app.albums variable."""

    self.albums = []
    album_directory = self.album_directory
    if not os.path.exists(album_directory):
      os.makedirs(album_directory)
    album_directory_contents = os.listdir(album_directory)
    for item in album_directory_contents:
      if os.path.splitext(item)[1] == '.ini':
        try:
          configfile = ConfigParser(interpolation=None)
          configfile.read(os.path.join(album_directory, item))
          info = dict(configfile.items('info'))
          album_name = info['name']
          album_description = info['description']
          elements = configfile.items('photos')
          photos = []
          for element in elements:
            photo_path = local_path(element[1])
            if self.Photo.exist(photo_path):
              photos.append(photo_path)
          self.albums.append({'name': album_name, 'description': album_description, 'file': item, 'photos': photos})
        except:
          pass

    def add_album(self, instance=None, answer="yes"):
      """Adds the current input album to the app albums."""

      if answer == 'yes':
        if instance is not None:
          album = instance.ids['input'].text.strip(' ')
          if not album:
            self.dismiss_popup()
            return
        else:
          album_input = self.ids['newAlbum']
          album = album_input.text
          album_input.text = ''
        app = App.get_running_app()
        app.album_make(album, '')
        self.create_treeview()
      self.dismiss_popup()
Ejemplo n.º 5
0
    def drop_widget(self, fullpath, position, dropped_type, aspect=1):
        """Called when a widget is dropped after being dragged.
        Determines what to do with the widget based on where it is dropped.
        Arguments:
            fullpath: String, file location of the object being dragged.
            position: List of X,Y window coordinates that the widget is dropped on.
            dropped_type: String, describes the object's screenDatabase origin directory
        """

        app = App.get_running_app()
        transfer_from = dropped_type
        left_database_holder = self.ids['leftDatabaseHolder']
        left_database_area = self.ids['leftDatabaseArea']
        right_database_holder = self.ids['rightDatabaseHolder']
        right_database_area = self.ids['rightDatabaseArea']
        transfer_to = None
        folders = []
        if left_database_holder.collide_point(position[0], position[1]):
            if transfer_from != self.left_database:
                selects = right_database_area.selects
                for select in selects:
                    folders.append(local_path(select['fullpath']))
                transfer_to = self.left_database
        elif right_database_holder.collide_point(position[0], position[1]):
            if transfer_from != self.right_database:
                selects = left_database_area.selects
                for select in selects:
                    folders.append(local_path(select['fullpath']))
                transfer_to = self.right_database
        if transfer_to:
            if fullpath not in folders:
                folders.append(fullpath)
            #remove subfolders
            removes = []
            for folder in folders:
                for fold in folders:
                    if folder.startswith(fold + os.path.sep):
                        removes.append(folder)
                        break
            reduced_folders = []
            for folder in folders:
                if folder not in removes:
                    reduced_folders.append(folder)

            content = ConfirmPopup(text='Move These Folders From "' +
                                   transfer_from + '" to "' + transfer_to +
                                   '"?',
                                   yes_text='Move',
                                   no_text="Don't Move",
                                   warn_yes=True)
            content.bind(on_answer=self.move_folders)
            self.transfer_to = transfer_to
            self.transfer_from = transfer_from
            self.folders = reduced_folders
            self.popup = MoveConfirmPopup(title='Confirm Move',
                                          content=content,
                                          size_hint=(None, None),
                                          size=(app.popup_x,
                                                app.button_scale * 4),
                                          auto_dismiss=False)
            self.popup.open()