Added pre-template for Time, added sort for list
This commit is contained in:
parent
e84f1b0253
commit
e714edcbb7
|
@ -1,5 +1,5 @@
|
|||
# Python imports
|
||||
import builtins, os
|
||||
import builtins, os, re
|
||||
from os import path
|
||||
|
||||
# Lib imports
|
||||
|
@ -46,6 +46,7 @@ class Builtins:
|
|||
for f in os.listdir(_file):
|
||||
self.from_changes.append(f)
|
||||
|
||||
self.from_changes.sort(key=self._natural_keys)
|
||||
self.to_changes = self.from_changes
|
||||
event_system.push_gui_event(["update-from", None, ()])
|
||||
event_system.push_gui_event(["update-to", None, ()])
|
||||
|
@ -83,6 +84,12 @@ class Builtins:
|
|||
def consume_module_event(self):
|
||||
return self._pop_module_event()
|
||||
|
||||
def _atoi(self, text):
|
||||
return int(text) if text.isdigit() else text
|
||||
|
||||
def _natural_keys(self, text):
|
||||
return [ self._atoi(c) for c in re.split('(\d+)',text) ]
|
||||
|
||||
|
||||
|
||||
# NOTE: Just reminding myself we can add to builtins two different ways...
|
||||
|
|
|
@ -34,7 +34,7 @@ class Controller(Gtk.Box, CommonWidgetGeneratorMixin):
|
|||
file_choser.add_filter(file_filter)
|
||||
|
||||
label = Gtk.Label(label="Bulk Action Type: ")
|
||||
data = ["Insert", "Replace", "Remove", "Remove From / To", "Case"]
|
||||
data = ["Insert", "Replace", "Remove", "Remove From / To", "Case", "Time"]
|
||||
self.store, self.combo_box = self._create_combobox_widget(data)
|
||||
|
||||
add_button = Gtk.Button(label="Add Action")
|
||||
|
|
|
@ -0,0 +1,63 @@
|
|||
# Python imports
|
||||
import pathlib
|
||||
|
||||
# Lib imports
|
||||
import gi
|
||||
gi.require_version('Gtk', '3.0')
|
||||
from gi.repository import Gtk
|
||||
|
||||
# Application imports
|
||||
from mixins import CommonActionsMixin
|
||||
|
||||
|
||||
class Time(Gtk.Box, CommonActionsMixin):
|
||||
def __init__(self):
|
||||
super(Time, self).__init__()
|
||||
|
||||
label = Gtk.Label(label="Time: ")
|
||||
self.insert_entry = Gtk.Entry()
|
||||
self.insert_entry.set_hexpand(True)
|
||||
self.insert_entry.set_placeholder_text("HH:MM:SS...")
|
||||
|
||||
data = ["Start", "End", "Position"]
|
||||
self.store, self.combo_box = self._create_combobox_widget(data)
|
||||
|
||||
self.spin_button = self._create_spinbutton_widget()
|
||||
|
||||
self.add_widgets([label, self.insert_entry, self.combo_box, self.spin_button])
|
||||
self.set_spacing(20)
|
||||
self.show_all()
|
||||
|
||||
|
||||
def run(self):
|
||||
new_collection = []
|
||||
insert_str = self.insert_entry.get_text()
|
||||
itr = self.combo_box.get_active_iter()
|
||||
type = self.store.get(itr, 0)[0]
|
||||
|
||||
print(f"Inserting...")
|
||||
if type == "Start":
|
||||
for name in event_system.to_changes:
|
||||
new_collection.append(f"{insert_str}{name}")
|
||||
if type == "End":
|
||||
for name in event_system.to_changes:
|
||||
base, file_extension = self.get_file_parts()
|
||||
new_collection.append(f"{base}{insert_str}{file_extension}")
|
||||
if type == "Position":
|
||||
position = self.spin_button.get_value_as_int()
|
||||
for name in event_system.to_changes:
|
||||
name = f"{name[:position]}{insert_str}{name[position:]}"
|
||||
new_collection.append(f"{name}")
|
||||
|
||||
event_system.to_changes = new_collection
|
||||
event_system.push_gui_event(["update-to", self, ()])
|
||||
|
||||
|
||||
def _combo_box_changed(self, widget, eve=None):
|
||||
itr = widget.get_active_iter()
|
||||
type = self.store.get(itr, 0)[0]
|
||||
|
||||
if type == "Position":
|
||||
self.spin_button.set_sensitive(True)
|
||||
else:
|
||||
self.spin_button.set_sensitive(False)
|
Loading…
Reference in New Issue