Example #1
0
    def RemoveTag(self, event):
        tag_id = tagging.tag_name_to_id(self.edit_tag)

        event = TagListUpdateEvent(
            self.GetId(),
            checked=self.GetCheckedStrings()
        )

        output.delete_tag(tag_id)
        tagging.delete_tag(tag_id)

        wx.PostEvent(self, event)
Example #2
0
    def OnNewName(self, event):

        tag_id = tagging.tag_name_to_id(self.edit_tag)
        text = event.GetEventObject()
        new_name = text.GetValue()

        for tag_name in tagging.get_all_tags():
            if tagging.tag_name_to_id(tag_name) == tag_id:
                continue

            if tag_name.lower() == new_name.lower():
                wx.MessageBox(
                    ("Tag name already in use! Two tags can't have the same "
                     "name, regardless of case."),
                    "Error",
                    wx.OK,
                )
                return

        if not re.match('^' + expression.REG_TAG_NAME + '$', new_name):
            wx.MessageBox(
                ("Invalid input! Tag names can only contain letters, "
                 "numbers and underscores (which will be displayed "
                 "as a sapce). They must start with a letter."),
                "Error",
                wx.OK,
            )
            return

        output.rename_tag(tag_id, new_name)

        if self.edit_tag in self.checked:
            self.checked.append(new_name)

        event = TagListUpdateEvent(
            self.GetId(),
            checked=self.checked
        )
        wx.PostEvent(self, event)
Example #3
0
    def SaveSettings(self):

        # Register folders
        # Get gallery connection
        gallery_conn = database.get_current_gallery("connection")
        cursor = gallery_conn.cursor()

        location = self.tc_directory.GetValue()
        name = self.tc_name.GetValue()
        if self.cb_automatic.GetValue():
            add_new_tag = 1
        else:
            add_new_tag = 0

        if self.rb_softlinks.GetValue():
            use_softlink = 1
        else:
            use_softlink = 0

        if not os.path.isdir(location):
            wx.MessageBox("Location does not exist!", "Error")
            return

        if name == "":
            wx.MessageBox("Must define a name.", "Error")
            return

        if os.path.isdir(os.path.join(location, name)):
            wx.MessageBox(
                ("Target folder already exists, "
                 "remove it first."),
                "Error",
            )
            return

        checked_tags = self.lb.GetCheckedStrings()
        tags = []
        for tag in checked_tags:
            tags.append(tagging.tag_name_to_id(tag.replace(" ", "_")))

        cursor.execute(
            (
                "INSERT INTO gallery_folder "
                "(name, location, add_new_tag, use_softlink) "
                "VALUES (:name, :location, :add_new_tag, :use_softlink)"
            ),
            {
                "name": name,
                "location": location,
                "add_new_tag": add_new_tag,
                "use_softlink": use_softlink
            }
        )
        gallery_conn.commit()

        cursor.execute(
            (
                "SELECT pk_id FROM gallery_folder "
                "WHERE name = :name "
                "AND location = :location "
            ),
            {
                "name": name,
                "location": location,
            }
        )
        folder_id = cursor.fetchone()[0]

        output.create_gallery(folder_id)
        for tag in tags:
            output.change_gallery(folder_id, tag, True)
Example #4
0
    def SaveSettings(self):
        # FIXME: Change name not working (under windows)?

        # Register folders
        # Get gallery connection
        gallery_conn = database.get_current_gallery("connection")
        cursor = gallery_conn.cursor()

        location = self.tc_directory.GetValue()
        name = self.tc_name.GetValue()
        if self.cb_automatic.GetValue():
            add_new_tag = 1
        else:
            add_new_tag = 0

        if self.rb_softlinks.GetValue():
            use_softlink = True
        else:
            use_softlink = False

        if not os.path.isdir(location):
            wx.MessageBox("Location does not exist!", "Error")
            return

        if name == "":
            wx.MessageBox("Must define a name.", "Error")
            return

        output.change_link_type(self.folder_id, False, use_softlink)

        new_checked_tags = self.lb.GetCheckedStrings()
        for tag in new_checked_tags:
            if tag not in self.checked_tags:
                tag_id = tagging.tag_name_to_id(tag.replace(" ", "_"))
                output.change_gallery(self.folder_id, tag_id, True)

        for tag in self.checked_tags:
            if tag not in new_checked_tags:
                tag_id = tagging.tag_name_to_id(tag.replace(" ", "_"))
                output.change_gallery(self.folder_id, tag_id, False)

        if name != self.name or location != self.location:
            if os.path.isdir(os.path.join(location, name)):
                print "koko made NI"
                wx.MessageBox(
                    ("Location or target folder already exists, "
                     "remove it first."),
                    "Error",
                )
                return

        if name != self.name:
            output.rename(self.folder_id, False, name)

        if location != self.location:
            output.move(self.folder_id, False, location)

        query_save = ("UPDATE gallery_folder SET "
                      "add_new_tag = %d "
                      "WHERE pk_id = %d" % (add_new_tag, self.folder_id))
        cursor.execute(query_save)
        gallery_conn.commit()

        self.Close()
    def SaveSettings(self):
        # FIXME: Change name not working (under windows)?

        # Register folders
        # Get gallery connection
        gallery_conn = database.get_current_gallery("connection")
        cursor = gallery_conn.cursor()

        location = self.tc_directory.GetValue()
        name = self.tc_name.GetValue()
        if self.cb_automatic.GetValue():
            add_new_tag = 1
        else:
            add_new_tag = 0

        if self.rb_softlinks.GetValue():
            use_softlink = True
        else:
            use_softlink = False

        if not os.path.isdir(location):
            wx.MessageBox("Location does not exist!", "Error")
            return

        if name == "":
            wx.MessageBox("Must define a name.", "Error")
            return

        output.change_link_type(self.folder_id, False, use_softlink)

        new_checked_tags = self.lb.GetCheckedStrings()
        for tag in new_checked_tags:
            if tag not in self.checked_tags:
                tag_id = tagging.tag_name_to_id(tag.replace(" ", "_"))
                output.change_gallery(self.folder_id, tag_id, True)

        for tag in self.checked_tags:
            if tag not in new_checked_tags:
                tag_id = tagging.tag_name_to_id(tag.replace(" ", "_"))
                output.change_gallery(self.folder_id, tag_id, False)

        if name != self.name or location != self.location:
            if os.path.isdir(os.path.join(location, name)):
                print "koko made NI"
                wx.MessageBox(
                    ("Location or target folder already exists, "
                     "remove it first."),
                    "Error",
                )
                return

        if name != self.name:
            output.rename(self.folder_id, False, name)

        if location != self.location:
            output.move(self.folder_id, False, location)

        query_save = (
            "UPDATE gallery_folder SET "
            "add_new_tag = %d "
            "WHERE pk_id = %d" %
            (add_new_tag, self.folder_id)
        )
        cursor.execute(query_save)
        gallery_conn.commit()

        self.Close()