2022-02-06 19:34:48 +00:00
|
|
|
# Python imports
|
|
|
|
|
|
|
|
# Lib imports
|
|
|
|
import gi
|
|
|
|
gi.require_version('Gtk', '3.0')
|
|
|
|
from gi.repository import Gtk
|
|
|
|
|
|
|
|
# Application imports
|
2022-02-07 06:29:25 +00:00
|
|
|
from mixins import CommonWidgetGeneratorMixin, CommonActionsMixin
|
2022-02-06 19:34:48 +00:00
|
|
|
|
|
|
|
|
2022-02-07 06:29:25 +00:00
|
|
|
class Remove(Gtk.Box, CommonWidgetGeneratorMixin, CommonActionsMixin):
|
2022-02-06 19:34:48 +00:00
|
|
|
def __init__(self):
|
|
|
|
super(Remove, self).__init__()
|
|
|
|
|
|
|
|
self.entry_from = Gtk.Entry()
|
|
|
|
|
|
|
|
data = ["All", "Word Start", "Word End", "First Instance", "Last Instance", "RegEx"]
|
|
|
|
self.store, self.combo_box = self._create_combobox_widget(data)
|
|
|
|
|
|
|
|
self.entry_from.set_hexpand(True)
|
|
|
|
self.entry_from.set_placeholder_text("Remove...")
|
|
|
|
|
2022-02-07 06:29:25 +00:00
|
|
|
self.add_widgets([self.entry_from, self.combo_box])
|
2022-02-06 19:34:48 +00:00
|
|
|
self.set_spacing(20)
|
|
|
|
self.show_all()
|
|
|
|
|
|
|
|
|
|
|
|
def run(self):
|
|
|
|
from_str = self.entry_from.get_text()
|
|
|
|
if from_str:
|
|
|
|
new_collection = []
|
|
|
|
itr = self.combo_box.get_active_iter()
|
|
|
|
type = self.store.get(itr, 0)[0]
|
|
|
|
print(f"To Remove: {from_str}")
|
|
|
|
|
|
|
|
if type == "All":
|
|
|
|
for name in event_system.to_changes:
|
|
|
|
new_collection.append(name.replace(from_str, ''))
|
|
|
|
if type == "Word Start":
|
|
|
|
print("Stub...")
|
|
|
|
if type == "Word End":
|
|
|
|
print("Stub...")
|
|
|
|
if type == "First Instance":
|
|
|
|
for name in event_system.to_changes:
|
|
|
|
new_collection.append( name.replace(from_str, "", 1) )
|
|
|
|
if type == "Last Instance":
|
|
|
|
for name in event_system.to_changes:
|
|
|
|
new_collection.append( self._replace_last(name, from_str, "") )
|
|
|
|
if type == "RegEx":
|
|
|
|
print("Stub...")
|
|
|
|
|
|
|
|
event_system.to_changes = new_collection
|
|
|
|
event_system.push_gui_event(["update-to", self, ()])
|