mirror of
https://github.com/DYefremov/DemonEditor.git
synced 2025-12-24 01:19:40 +01:00
bouquet name gen refactoring
This commit is contained in:
@@ -1543,14 +1543,7 @@ class Application(Gtk.Application):
|
|||||||
return
|
return
|
||||||
|
|
||||||
bq_type = model.get_value(itr, Column.BQ_TYPE)
|
bq_type = model.get_value(itr, Column.BQ_TYPE)
|
||||||
bq_name = "bouquet"
|
bq_name = gen_bouquet_name(self._bouquets, "bouquet", bq_type)
|
||||||
count = 0
|
|
||||||
key = f"{bq_name}:{bq_type}"
|
|
||||||
# Generating name of new bouquet.
|
|
||||||
while key in self._bouquets:
|
|
||||||
count += 1
|
|
||||||
bq_name = f"bouquet{count}"
|
|
||||||
key = f"{bq_name}:{bq_type}"
|
|
||||||
|
|
||||||
response = show_dialog(DialogType.INPUT, self._main_window, bq_name)
|
response = show_dialog(DialogType.INPUT, self._main_window, bq_name)
|
||||||
if response == Gtk.ResponseType.CANCEL:
|
if response == Gtk.ResponseType.CANCEL:
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ __all__ = ("insert_marker", "move_items", "rename", "ViewTarget", "set_flags", "
|
|||||||
"get_model_data", "remove_all_unused_picons", "get_picon_pixbuf", "get_base_itrs", "get_iptv_url",
|
"get_model_data", "remove_all_unused_picons", "get_picon_pixbuf", "get_base_itrs", "get_iptv_url",
|
||||||
"get_iptv_data", "update_entry_data", "append_text_to_tview", "on_popup_menu", "get_picon_file_name",
|
"get_iptv_data", "update_entry_data", "append_text_to_tview", "on_popup_menu", "get_picon_file_name",
|
||||||
"update_toggle_model", "update_popup_filter_model", "update_filter_sat_positions", "get_pos_num",
|
"update_toggle_model", "update_popup_filter_model", "update_filter_sat_positions", "get_pos_num",
|
||||||
"show_info_bar_message")
|
"show_info_bar_message", "gen_bouquet_name")
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
@@ -686,6 +686,19 @@ def get_bouquets_names(model):
|
|||||||
return bouquets_names
|
return bouquets_names
|
||||||
|
|
||||||
|
|
||||||
|
def gen_bouquet_name(bouquets, base_name, bq_type):
|
||||||
|
""" Generates a name for new bouquets. """
|
||||||
|
count = 0
|
||||||
|
key = f"{base_name}:{bq_type}"
|
||||||
|
bq_name = base_name
|
||||||
|
while key in bouquets:
|
||||||
|
count += 1
|
||||||
|
bq_name = f"{base_name}{count}"
|
||||||
|
key = f"{bq_name}:{bq_type}"
|
||||||
|
|
||||||
|
return bq_name
|
||||||
|
|
||||||
|
|
||||||
def get_services_type_groups(services):
|
def get_services_type_groups(services):
|
||||||
""" Returns services grouped by main types [TV, Radio, Data]. -> dict """
|
""" Returns services grouped by main types [TV, Radio, Data]. -> dict """
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user