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.TYPE_PYOBJECT, (GObject.TYPE_PYOBJECT,)),
|
||||||
GObject.signal_new("list-font-changed", self, GObject.SIGNAL_RUN_LAST,
|
GObject.signal_new("list-font-changed", self, GObject.SIGNAL_RUN_LAST,
|
||||||
GObject.TYPE_PYOBJECT, (GObject.TYPE_PYOBJECT,))
|
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)
|
builder = get_builder(UI_RESOURCES_PATH + "main.glade", handlers)
|
||||||
self._main_window = builder.get_object("main_window")
|
self._main_window = builder.get_object("main_window")
|
||||||
@@ -393,7 +395,9 @@ class Application(Gtk.Application):
|
|||||||
self._clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)
|
self._clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)
|
||||||
ref_item = builder.get_object("fav_assign_ref_popup_item")
|
ref_item = builder.get_object("fav_assign_ref_popup_item")
|
||||||
self.bind_property("is_enigma", ref_item, "visible")
|
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
|
# Wait dialog
|
||||||
self._wait_dialog = WaitDialog(self._main_window)
|
self._wait_dialog = WaitDialog(self._main_window)
|
||||||
# Filter
|
# Filter
|
||||||
@@ -1166,7 +1170,7 @@ class Application(Gtk.Application):
|
|||||||
|
|
||||||
def on_reference_copy(self, view):
|
def on_reference_copy(self, view):
|
||||||
""" Copying picon id to clipboard. """
|
""" 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):
|
def on_fav_cut(self, view):
|
||||||
self.on_cut(view, ViewTarget.FAV)
|
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.assign_reference(model, p, ref) for p in iptv_paths]
|
||||||
self._clipboard.clear()
|
self._clipboard.clear()
|
||||||
|
|
||||||
|
self.emit("clipboard-changed", self._clipboard.wait_is_text_available())
|
||||||
|
|
||||||
def assign_reference(self, model, path, ref):
|
def assign_reference(self, model, path, ref):
|
||||||
ref_data = ref.split("_")
|
ref_data = ref.split("_")
|
||||||
row = model[path]
|
row = model[path]
|
||||||
|
|||||||
@@ -618,25 +618,30 @@ def get_bouquets_names(model):
|
|||||||
|
|
||||||
# ***************** Others ********************* #
|
# ***************** Others ********************* #
|
||||||
|
|
||||||
def copy_reference(target, view, services, clipboard, transient):
|
def copy_reference(view, app):
|
||||||
""" Copying picon id to clipboard """
|
""" Copying picon id to clipboard. """
|
||||||
model, paths = view.get_selection().get_selected_rows()
|
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
|
return
|
||||||
|
|
||||||
|
target = app.get_target_view(view)
|
||||||
|
clipboard = app._clipboard
|
||||||
|
|
||||||
if target is ViewTarget.SERVICES:
|
if target is ViewTarget.SERVICES:
|
||||||
picon_id = model.get_value(model.get_iter(paths), Column.SRV_PICON_ID)
|
picon_id = model.get_value(model.get_iter(paths), Column.SRV_PICON_ID)
|
||||||
if picon_id:
|
if picon_id:
|
||||||
clipboard.set_text(picon_id.rstrip(".png"), -1)
|
clipboard.set_text(picon_id.rstrip(".png"), -1)
|
||||||
else:
|
else:
|
||||||
show_dialog(DialogType.ERROR, transient, "No reference is present!")
|
app.show_error_message("No reference is present!")
|
||||||
elif target is ViewTarget.FAV:
|
elif target is ViewTarget.FAV:
|
||||||
fav_id = model.get_value(model.get_iter(paths), Column.FAV_ID)
|
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:
|
if srv and srv.picon_id:
|
||||||
clipboard.set_text(srv.picon_id.rstrip(".png"), -1)
|
clipboard.set_text(srv.picon_id.rstrip(".png"), -1)
|
||||||
else:
|
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):
|
def update_entry_data(entry, dialog, settings):
|
||||||
|
|||||||
Reference in New Issue
Block a user