mirror of
https://github.com/DYefremov/DemonEditor.git
synced 2025-12-22 00:19:40 +01:00
assign refs refactoring
This commit is contained in:
@@ -328,6 +328,8 @@ class Application(Gtk.Application):
|
||||
GObject.TYPE_PYOBJECT, (GObject.TYPE_PYOBJECT,)),
|
||||
GObject.signal_new("list-font-changed", self, GObject.SIGNAL_RUN_LAST,
|
||||
GObject.TYPE_PYOBJECT, (GObject.TYPE_PYOBJECT,))
|
||||
GObject.signal_new("clipboard-changed", self, GObject.SIGNAL_RUN_LAST,
|
||||
GObject.TYPE_PYOBJECT, (GObject.TYPE_PYOBJECT,))
|
||||
|
||||
builder = get_builder(UI_RESOURCES_PATH + "main.glade", handlers)
|
||||
self._main_window = builder.get_object("main_window")
|
||||
@@ -393,7 +395,9 @@ class Application(Gtk.Application):
|
||||
self._clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)
|
||||
ref_item = builder.get_object("fav_assign_ref_popup_item")
|
||||
self.bind_property("is_enigma", ref_item, "visible")
|
||||
self._clipboard.connect("owner-change", lambda c, o: ref_item.set_sensitive(c.wait_is_text_available()))
|
||||
# We use a custom event for observe clipboard state.
|
||||
# "owner-change" -> https://gitlab.gnome.org/GNOME/gtk/-/issues/1757
|
||||
self.connect("clipboard-changed", lambda a, o: ref_item.set_sensitive(o))
|
||||
# Wait dialog
|
||||
self._wait_dialog = WaitDialog(self._main_window)
|
||||
# Filter
|
||||
@@ -1166,7 +1170,7 @@ class Application(Gtk.Application):
|
||||
|
||||
def on_reference_copy(self, view):
|
||||
""" Copying picon id to clipboard. """
|
||||
copy_reference(self.get_target_view(view), view, self._services, self._clipboard, self._main_window)
|
||||
copy_reference(view, self)
|
||||
|
||||
def on_fav_cut(self, view):
|
||||
self.on_cut(view, ViewTarget.FAV)
|
||||
@@ -2993,6 +2997,8 @@ class Application(Gtk.Application):
|
||||
[self.assign_reference(model, p, ref) for p in iptv_paths]
|
||||
self._clipboard.clear()
|
||||
|
||||
self.emit("clipboard-changed", self._clipboard.wait_is_text_available())
|
||||
|
||||
def assign_reference(self, model, path, ref):
|
||||
ref_data = ref.split("_")
|
||||
row = model[path]
|
||||
|
||||
@@ -618,25 +618,30 @@ def get_bouquets_names(model):
|
||||
|
||||
# ***************** Others ********************* #
|
||||
|
||||
def copy_reference(target, view, services, clipboard, transient):
|
||||
""" Copying picon id to clipboard """
|
||||
def copy_reference(view, app):
|
||||
""" Copying picon id to clipboard. """
|
||||
model, paths = view.get_selection().get_selected_rows()
|
||||
if not is_only_one_item_selected(paths, transient):
|
||||
if not is_only_one_item_selected(paths, app.app_window):
|
||||
return
|
||||
|
||||
target = app.get_target_view(view)
|
||||
clipboard = app._clipboard
|
||||
|
||||
if target is ViewTarget.SERVICES:
|
||||
picon_id = model.get_value(model.get_iter(paths), Column.SRV_PICON_ID)
|
||||
if picon_id:
|
||||
clipboard.set_text(picon_id.rstrip(".png"), -1)
|
||||
else:
|
||||
show_dialog(DialogType.ERROR, transient, "No reference is present!")
|
||||
app.show_error_message("No reference is present!")
|
||||
elif target is ViewTarget.FAV:
|
||||
fav_id = model.get_value(model.get_iter(paths), Column.FAV_ID)
|
||||
srv = services.get(fav_id, None)
|
||||
srv = app.current_services.get(fav_id, None)
|
||||
if srv and srv.picon_id:
|
||||
clipboard.set_text(srv.picon_id.rstrip(".png"), -1)
|
||||
else:
|
||||
show_dialog(DialogType.ERROR, transient, "No reference is present!")
|
||||
app.show_error_message("No reference is present!")
|
||||
|
||||
app.emit("clipboard-changed", clipboard.wait_is_text_available())
|
||||
|
||||
|
||||
def update_entry_data(entry, dialog, settings):
|
||||
|
||||
Reference in New Issue
Block a user