mirror of
https://github.com/DYefremov/DemonEditor.git
synced 2026-05-06 07:26:48 +02:00
added bouquets import via dnd
This commit is contained in:
@@ -12,7 +12,7 @@ from app.ui.main_helper import on_popup_menu
|
||||
from .uicommons import Gtk, UI_RESOURCES_PATH, KeyboardKey, Column
|
||||
|
||||
|
||||
def import_bouquet(transient, model, path, settings, services, appender):
|
||||
def import_bouquet(transient, model, path, settings, services, appender, file_path=None):
|
||||
""" Import of single bouquet """
|
||||
itr = model.get_iter(path)
|
||||
bq_type = BqType(model.get(itr, Column.BQ_TYPE)[0])
|
||||
@@ -30,7 +30,7 @@ def import_bouquet(transient, model, path, settings, services, appender):
|
||||
elif bq_type is BqType.WEBTV:
|
||||
f_pattern = "webtv.xml"
|
||||
|
||||
file_path = get_chooser_dialog(transient, settings, "bouquet files", (f_pattern,))
|
||||
file_path = file_path or get_chooser_dialog(transient, settings, "bouquet files", (f_pattern,))
|
||||
if file_path == Gtk.ResponseType.CANCEL:
|
||||
return
|
||||
|
||||
|
||||
@@ -988,6 +988,12 @@ class Application(Gtk.Application):
|
||||
data = data.get_text()
|
||||
if not data:
|
||||
return
|
||||
|
||||
if data.startswith("file://"):
|
||||
from urllib.parse import unquote, urlparse
|
||||
self.on_import_bouquet(None, file_path=urlparse(unquote(data)).path.strip())
|
||||
return
|
||||
|
||||
itr_str, sep, source = data.partition("::::")
|
||||
if source != self.BQ_MODEL_NAME:
|
||||
return
|
||||
@@ -1907,14 +1913,14 @@ class Application(Gtk.Application):
|
||||
else:
|
||||
show_dialog(DialogType.INFO, self._main_window, "Done!")
|
||||
|
||||
def on_import_bouquet(self, action, value=None):
|
||||
def on_import_bouquet(self, action, value=None, file_path=None):
|
||||
model, paths = self._bouquets_view.get_selection().get_selected_rows()
|
||||
if not paths:
|
||||
self.show_error_dialog("No selected item!")
|
||||
return
|
||||
|
||||
appender = self.append_bouquet if self._s_type is SettingsType.ENIGMA_2 else self.append_bouquets
|
||||
import_bouquet(self._main_window, model, paths[0], self._settings, self._services, appender)
|
||||
import_bouquet(self._main_window, model, paths[0], self._settings, self._services, appender, file_path)
|
||||
|
||||
def on_import_bouquets(self, action, value=None):
|
||||
response = show_dialog(DialogType.CHOOSER, self._main_window, settings=self._settings)
|
||||
|
||||
Reference in New Issue
Block a user