mirror of
https://github.com/DYefremov/DemonEditor.git
synced 2025-12-21 16:09:41 +01:00
sub-bouquets creation support
This commit is contained in:
@@ -337,122 +337,6 @@ Author: Dmitriy Yefremov
|
||||
<property name="can_focus">False</property>
|
||||
<property name="stock">gtk-file</property>
|
||||
</object>
|
||||
<object class="GtkMenu" id="bouquets_popup_menu">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<object class="GtkImageMenuItem" id="bouquets_new_popup_item">
|
||||
<property name="label">gtk-new</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="sensitive">False</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="use_stock">True</property>
|
||||
<signal name="activate" handler="on_new_bouquet" object="bouquets_tree_view" swapped="no"/>
|
||||
<accelerator key="Insert" signal="activate" modifiers="Primary"/>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkImageMenuItem" id="bouquet_import_popup_item">
|
||||
<property name="label" translatable="yes">Import</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="sensitive">False</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="image">import_bouquet_image</property>
|
||||
<property name="use_stock">False</property>
|
||||
<signal name="activate" handler="on_import_bouquet" swapped="no"/>
|
||||
<accelerator key="i" signal="activate" modifiers="Primary"/>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkImageMenuItem" id="bouquet_export_popup_item">
|
||||
<property name="label">gtk-save-as</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="use_stock">True</property>
|
||||
<signal name="activate" handler="on_bouquet_export" swapped="no"/>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkSeparatorMenuItem" id="bouquets_popup_separator">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkImageMenuItem" id="bouquets_cut_popup_item">
|
||||
<property name="label">gtk-cut</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="sensitive">False</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="use_stock">True</property>
|
||||
<signal name="activate" handler="on_bouquets_cut" object="bouquets_tree_view" swapped="no"/>
|
||||
<accelerator key="x" signal="activate" modifiers="Primary"/>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkImageMenuItem" id="bouquets_copy_popup_item">
|
||||
<property name="label">gtk-copy</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="sensitive">False</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="use_stock">True</property>
|
||||
<signal name="activate" handler="on_bouquets_copy" object="bouquets_tree_view" swapped="no"/>
|
||||
<accelerator key="c" signal="activate" modifiers="Primary"/>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkImageMenuItem" id="bouquets_paste_popup_item">
|
||||
<property name="label">gtk-paste</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="sensitive">False</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="use_stock">True</property>
|
||||
<signal name="activate" handler="on_bouquets_paste" object="bouquets_tree_view" swapped="no"/>
|
||||
<accelerator key="v" signal="activate" modifiers="Primary"/>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkSeparatorMenuItem" id="bouquets_popup_separator_2">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkImageMenuItem" id="bouquets_edit_popup_item">
|
||||
<property name="label">gtk-edit</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="sensitive">False</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="use_stock">True</property>
|
||||
<signal name="activate" handler="on_edit" swapped="no"/>
|
||||
<accelerator key="e" signal="activate" modifiers="Primary"/>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkSeparatorMenuItem" id="bouquets_popup_separator_3">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkImageMenuItem" id="bouquets_remove_popup_item">
|
||||
<property name="label">gtk-remove</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="sensitive">False</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="use_stock">True</property>
|
||||
<signal name="activate" handler="on_delete" object="bouquets_tree_view" swapped="no"/>
|
||||
<accelerator key="Delete" signal="activate"/>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<object class="GtkImage" id="insert_image">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
@@ -847,6 +731,136 @@ Author: Dmitriy Yefremov
|
||||
<property name="can_focus">False</property>
|
||||
<property name="stock">gtk-new</property>
|
||||
</object>
|
||||
<object class="GtkImage" id="new_sub_bouquet_image">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="icon_name">document-new</property>
|
||||
</object>
|
||||
<object class="GtkMenu" id="bouquets_popup_menu">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<object class="GtkImageMenuItem" id="bouquets_new_popup_item">
|
||||
<property name="label">gtk-new</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="sensitive">False</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="use_stock">True</property>
|
||||
<signal name="activate" handler="on_new_bouquet" object="bouquets_tree_view" swapped="no"/>
|
||||
<accelerator key="Insert" signal="activate" modifiers="Primary"/>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkImageMenuItem" id="bouquets_new_sub_popup_item">
|
||||
<property name="label" translatable="yes">New sub-bouquet</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="image">new_sub_bouquet_image</property>
|
||||
<property name="use_stock">False</property>
|
||||
<signal name="activate" handler="on_new_sub_bouquet" swapped="no"/>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkImageMenuItem" id="bouquet_import_popup_item">
|
||||
<property name="label" translatable="yes">Import</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="sensitive">False</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="image">import_bouquet_image</property>
|
||||
<property name="use_stock">False</property>
|
||||
<signal name="activate" handler="on_import_bouquet" swapped="no"/>
|
||||
<accelerator key="i" signal="activate" modifiers="Primary"/>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkImageMenuItem" id="bouquet_export_popup_item">
|
||||
<property name="label">gtk-save-as</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="use_stock">True</property>
|
||||
<signal name="activate" handler="on_bouquet_export" swapped="no"/>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkSeparatorMenuItem" id="bouquets_popup_separator">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkImageMenuItem" id="bouquets_cut_popup_item">
|
||||
<property name="label">gtk-cut</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="sensitive">False</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="use_stock">True</property>
|
||||
<signal name="activate" handler="on_bouquets_cut" object="bouquets_tree_view" swapped="no"/>
|
||||
<accelerator key="x" signal="activate" modifiers="Primary"/>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkImageMenuItem" id="bouquets_copy_popup_item">
|
||||
<property name="label">gtk-copy</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="sensitive">False</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="use_stock">True</property>
|
||||
<signal name="activate" handler="on_bouquets_copy" object="bouquets_tree_view" swapped="no"/>
|
||||
<accelerator key="c" signal="activate" modifiers="Primary"/>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkImageMenuItem" id="bouquets_paste_popup_item">
|
||||
<property name="label">gtk-paste</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="sensitive">False</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="use_stock">True</property>
|
||||
<signal name="activate" handler="on_bouquets_paste" object="bouquets_tree_view" swapped="no"/>
|
||||
<accelerator key="v" signal="activate" modifiers="Primary"/>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkSeparatorMenuItem" id="bouquets_popup_separator_2">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkImageMenuItem" id="bouquets_edit_popup_item">
|
||||
<property name="label">gtk-edit</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="sensitive">False</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="use_stock">True</property>
|
||||
<signal name="activate" handler="on_edit" swapped="no"/>
|
||||
<accelerator key="e" signal="activate" modifiers="Primary"/>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkSeparatorMenuItem" id="bouquets_popup_separator_3">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkImageMenuItem" id="bouquets_remove_popup_item">
|
||||
<property name="label">gtk-remove</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="sensitive">False</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="use_stock">True</property>
|
||||
<signal name="activate" handler="on_delete" object="bouquets_tree_view" swapped="no"/>
|
||||
<accelerator key="Delete" signal="activate"/>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<object class="GtkImage" id="open_image">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
|
||||
@@ -181,6 +181,7 @@ class Application(Gtk.Application):
|
||||
"on_record": self.on_record,
|
||||
"on_remove_all_unavailable": self.on_remove_all_unavailable,
|
||||
"on_new_bouquet": self.on_new_bouquet,
|
||||
"on_new_sub_bouquet": self.on_new_sub_bouquet,
|
||||
"on_create_bouquet_for_current_satellite": self.on_create_bouquet_for_current_satellite,
|
||||
"on_create_bouquet_for_each_satellite": self.on_create_bouquet_for_each_satellite,
|
||||
"on_create_bouquet_for_current_package": self.on_create_bouquet_for_current_package,
|
||||
@@ -376,6 +377,8 @@ class Application(Gtk.Application):
|
||||
# Lock, Hide.
|
||||
self.bind_property("is-enigma", self._tool_elements.get(self._LOCK_HIDE_ELEMENTS[0]), "visible")
|
||||
self.bind_property("is-enigma", self._tool_elements.get(self._LOCK_HIDE_ELEMENTS[1]), "visible", 4)
|
||||
# Sub-bouquets menu item.
|
||||
self.bind_property("is_enigma", builder.get_object("bouquets_new_sub_popup_item"), "visible")
|
||||
# Stack page widgets.
|
||||
self._stack_services_frame = builder.get_object("services_frame")
|
||||
self._stack_satellite_box = builder.get_object("satellite_box")
|
||||
@@ -1046,17 +1049,21 @@ class Application(Gtk.Application):
|
||||
*bouquet.split(":"))
|
||||
return bouquet_file_name
|
||||
|
||||
def on_new_bouquet(self, view):
|
||||
def on_new_bouquet(self, view, sub=False):
|
||||
""" Creates a new item in the bouquets tree """
|
||||
model, paths = view.get_selection().get_selected_rows()
|
||||
|
||||
if paths:
|
||||
itr = model.get_iter(paths[0])
|
||||
bq_type = model.get_value(itr, 3)
|
||||
if not model.iter_parent(itr) and sub:
|
||||
self.show_error_message("Not allowed in this context!")
|
||||
return
|
||||
|
||||
bq_type = model.get_value(itr, Column.BQ_TYPE)
|
||||
bq_name = "bouquet"
|
||||
count = 0
|
||||
key = f"{bq_name}:{bq_type}"
|
||||
# Generating name of new bouquet
|
||||
# Generating name of new bouquet.
|
||||
while key in self._bouquets:
|
||||
count += 1
|
||||
bq_name = f"bouquet{count}"
|
||||
@@ -1080,15 +1087,29 @@ class Application(Gtk.Application):
|
||||
|
||||
self._current_bq_name = response
|
||||
|
||||
if model.iter_n_children(itr): # parent
|
||||
ch_itr = model.insert(itr, 0, bq)
|
||||
scroll_to(model.get_path(ch_itr), view, paths)
|
||||
if not model.iter_parent(itr): # root parent
|
||||
scroll_to(model.get_path(model.insert(itr, Column.BQ_NAME, bq)), view, paths)
|
||||
else:
|
||||
p_itr = model.iter_parent(itr)
|
||||
if sub:
|
||||
if model.iter_parent(p_itr):
|
||||
self.show_error_message("Not allowed in this context!")
|
||||
return
|
||||
else:
|
||||
if len(self._fav_model):
|
||||
msg = "This bouquet already contains data.\n\nThey may be lost when saved!"
|
||||
if show_dialog(DialogType.QUESTION, self._main_window, msg) != Gtk.ResponseType.OK:
|
||||
return
|
||||
|
||||
scroll_to(model.get_path(model.append(itr, bq)), view, paths)
|
||||
else:
|
||||
it = model.insert(p_itr, int(model.get_path(itr)[1]) + 1, bq) if p_itr else model.append(itr, bq)
|
||||
scroll_to(model.get_path(it), view, paths)
|
||||
self._bouquets[key] = []
|
||||
|
||||
def on_new_sub_bouquet(self, item=None):
|
||||
self.on_new_bouquet(self._bouquets_view, True)
|
||||
|
||||
def on_edit(self, *args):
|
||||
""" Edit header bar button """
|
||||
if self._services_view.is_focus():
|
||||
@@ -1852,7 +1873,7 @@ class Application(Gtk.Application):
|
||||
self._services[fav_id] = srv
|
||||
elif s_type is BqServiceType.BOUQUET:
|
||||
# Sub bouquets!
|
||||
msg = "Detected sub-bouquets. This feature is not fully supported yet!"
|
||||
msg = "Detected sub-bouquets. This feature is still experimental!"
|
||||
self.show_info_message(msg, Gtk.MessageType.WARNING)
|
||||
self.append_bouquet(srv.data, bouquet)
|
||||
elif srv.name:
|
||||
|
||||
Reference in New Issue
Block a user