From a908845b4efd047d0e5df335c2045bf315315178 Mon Sep 17 00:00:00 2001 From: DYefremov Date: Fri, 25 Mar 2022 21:25:30 +0300 Subject: [PATCH] filtering support for recordings tab --- app/ui/control.glade | 555 ++++++++++++++++++++++++++++++++----------- app/ui/control.py | 45 +++- app/ui/main.py | 2 +- 3 files changed, 451 insertions(+), 151 deletions(-) diff --git a/app/ui/control.glade b/app/ui/control.glade index d9bde410..931b614c 100644 --- a/app/ui/control.glade +++ b/app/ui/control.glade @@ -1131,6 +1131,18 @@ Author: Dmitriy Yefremov + + + + + + + + + + + + @@ -1161,6 +1173,12 @@ Author: Dmitriy Yefremov + + recordings_model + + + recordings_filter_model + True False @@ -1182,7 +1200,7 @@ Author: Dmitriy Yefremov False 5 5 - 5 + 2 vertical @@ -1193,6 +1211,28 @@ Author: Dmitriy Yefremov 5 5 5 + + + True + True + False + True + Filter + + + + True + False + edit-find-replace-symbolic + + + + + False + True + 0 + + True @@ -1208,6 +1248,37 @@ Author: Dmitriy Yefremov user-trash-symbolic + + + + False + True + 1 + + + + + False + True + 0 + + + + + True + False + 5 + 5 + 5 + 10 + + + True + edit-find-replace-symbolic + False + False + + False @@ -1216,13 +1287,78 @@ Author: Dmitriy Yefremov - + + False + center + + + True + True + edit-find-symbolic + False + False + + + False + True + 0 + + + + + True + False + True + True + + + True + False + down + + + + + False + False + 1 + + + + + True + False + True + True + + + True + False + up + + + + + False + False + 2 + + + + + + False + False + 1 + False True - 0 + 1 @@ -1234,7 +1370,7 @@ Author: Dmitriy Yefremov True True - recordings_model + recordings_sort_model both 5 @@ -1245,9 +1381,11 @@ Author: Dmitriy Yefremov + True 100 Service 0.5 + 0 0.49000000953674316 @@ -1260,10 +1398,12 @@ Author: Dmitriy Yefremov - autosize + True 150 Title + True 0.5 + 1 5 @@ -1280,6 +1420,7 @@ Author: Dmitriy Yefremov 100 Time 0.5 + 2 5 @@ -1295,6 +1436,7 @@ Author: Dmitriy Yefremov 100 Length 0.5 + 3 0.49000000953674316 @@ -1312,6 +1454,7 @@ Author: Dmitriy Yefremov File True 0.5 + 4 end @@ -1328,6 +1471,7 @@ Author: Dmitriy Yefremov Description True 0.5 + 5 end @@ -1344,7 +1488,7 @@ Author: Dmitriy Yefremov True True - 1 + 2 @@ -1386,7 +1530,7 @@ Author: Dmitriy Yefremov False True - 2 + 3 @@ -1469,7 +1613,7 @@ Author: Dmitriy Yefremov - + True False Paths @@ -2297,59 +2441,163 @@ Author: Dmitriy Yefremov True False + 2 vertical 10 - + True False - center - center - 25 - 25 + 20 + 20 5 5 + 15 - - 70 - True + + gtk-network + 100 True True - Standby - app.on_standby - - - True - False - 16 - system-log-out - 1 - - + center + True + True + False True - 1 + 0 - - - 70 + + True - True - True - Wake Up - app.on_wake_up + False + center + center - + + 70 True - False - 16 - document-revert - 1 + True + True + Standby + app.on_standby + + + True + False + 16 + system-log-out + 1 + + + + False + True + 1 + + + + 70 + True + True + True + Wake Up + app.on_wake_up + + + True + False + 16 + document-revert + 1 + + + + + False + True + 2 + + + + + 70 + True + True + True + Reboot + app.on_reboot + + + True + False + 16 + view-refresh + 1 + + + + + False + True + 3 + + + + + 70 + True + True + True + Restart GUI + app.on_restart_gui + + + True + False + 16 + window-new + 1 + + + + + False + True + 4 + + + + + 70 + True + True + True + Shutdown + app.on_shutdown + + + True + False + 16 + application-exit + + + + + False + True + 5 + + + False @@ -2357,80 +2605,6 @@ Author: Dmitriy Yefremov 2 - - - 70 - True - True - True - Reboot - app.on_reboot - - - True - False - 16 - view-refresh - 1 - - - - - False - True - 3 - - - - - 70 - True - True - True - Restart GUI - app.on_restart_gui - - - True - False - 16 - window-new - 1 - - - - - False - True - 4 - - - - - 70 - True - True - True - Shutdown - app.on_shutdown - - - True - False - 16 - application-exit - - - - - False - True - 5 - - - False @@ -2443,11 +2617,108 @@ Author: Dmitriy Yefremov True False 10 + + + 240 + False + 0.5 + in + + + + True + False + 5 + 5 + 5 + 5 + vertical + + + True + True + in + + + True + True + network_model + False + 3 + + + + + + Name + True + 0.5 + + + + 0 + + + + + + + IP + True + 0.5 + + + + 1 + + + + + + + Status + True + 0.5 + + + + 2 + + + + + + + + + True + True + 0 + + + + + + + + + + + + + + + + False + True + 0 + + True False - 0 + 0.5 in @@ -2458,27 +2729,6 @@ Author: Dmitriy Yefremov 5 5 vertical - - - True - False - 5 - 5 - 5 - 5 - - - False - - - - - - True - True - 0 - - True @@ -2628,6 +2878,27 @@ Author: Dmitriy Yefremov 1 + + + True + False + 2 + 2 + 2 + 2 + + + False + + + + + + True + True + 2 + + @@ -2637,7 +2908,7 @@ Author: Dmitriy Yefremov True True - 0 + 1 @@ -2645,7 +2916,7 @@ Author: Dmitriy Yefremov 300 True False - 0 + 0.5 in @@ -2654,8 +2925,8 @@ Author: Dmitriy Yefremov center 25 25 - 25 - 25 + 20 + 20 vertical 5 @@ -3052,7 +3323,7 @@ audio-volume-medium-symbolic True False center - 50 + 15 0.5 none @@ -3137,7 +3408,7 @@ audio-volume-medium-symbolic False True - 1 + 2 diff --git a/app/ui/control.py b/app/ui/control.py index 049e5b94..9a566f18 100644 --- a/app/ui/control.py +++ b/app/ui/control.py @@ -36,6 +36,7 @@ from urllib.parse import quote from gi.repository import GLib from .dialogs import get_builder, show_dialog, DialogType, get_message +from .main_helper import get_base_paths, get_base_model from .uicommons import Gtk, Gdk, UI_RESOURCES_PATH, Page, Column, KeyboardKey, IS_GNOME_SESSION from ..commons import run_task, run_with_delay, log, run_idle from ..connections import HttpAPI, UtfFTP @@ -659,13 +660,20 @@ class RecordingsTool(Gtk.Box): "on_path_activated": self.on_path_activated, "on_recordings_activated": self.on_recordings_activated, "on_recording_remove": self.on_recording_remove, - "on_recordings_model_changed": self.on_recordings_model_changed} + "on_recordings_model_changed": self.on_recordings_model_changed, + "on_recordings_filter_changed": self.on_recordings_filter_changed, + "on_recordings_filter_toggled": self.on_recordings_filter_toggled} builder = get_builder(UI_RESOURCES_PATH + "control.glade", handlers, - objects=("recordings_box", "recordings_model", "rec_paths_model")) + objects=("recordings_box", "recordings_model", "rec_paths_model", + "recordings_sort_model", "recordings_filter_model")) self._rec_view = builder.get_object("recordings_view") self._paths_view = builder.get_object("recordings_paths_view") self._paned = builder.get_object("recordings_paned") + self._model = builder.get_object("recordings_model") + self._filter_model = builder.get_object("recordings_filter_model") + self._filter_model.set_visible_func(self.recordings_filter_function) + self._filter_entry = builder.get_object("recordings_filter_entry") self._recordings_count_label = builder.get_object("recordings_count_label") self.pack_start(builder.get_object("recordings_box"), True, True, 0) if settings.alternate_layout: @@ -675,7 +683,7 @@ class RecordingsTool(Gtk.Box): self.show() def clear_data(self): - self._rec_view.get_model().clear() + self._model.clear() self._paths_view.get_model().clear() def on_layout_changed(self, app, alt_layout): @@ -752,9 +760,8 @@ class RecordingsTool(Gtk.Box): @run_idle def update_recordings_data(self, recordings): - model = self._rec_view.get_model() - model.clear() - list(map(model.append, (self.get_recordings_row(r) for r in recordings.get("recordings", [])))) + self._model.clear() + list(map(self._model.append, (self.get_recordings_row(r) for r in recordings.get("recordings", [])))) def get_recordings_row(self, rec): service = rec.get("e2servicename") @@ -781,6 +788,9 @@ class RecordingsTool(Gtk.Box): return model, paths = self._rec_view.get_selection().get_selected_rows() + paths = get_base_paths(paths, model) + model = get_base_model(model) + if paths and self._ftp: for file, itr in ((model[p][-1].get("e2filename", ""), model.get_iter(p)) for p in paths): resp = self._ftp.delete_file(file) @@ -793,6 +803,17 @@ class RecordingsTool(Gtk.Box): def on_recordings_model_changed(self, model, path, itr=None): self._recordings_count_label.set_text(str(len(model))) + def on_recordings_filter_changed(self, entry): + self._filter_model.refilter() + + def recordings_filter_function(self, model, itr, data): + txt = self._filter_entry.get_text().upper() + return next((s for s in model.get(itr, 0, 1, 2, 3, 4, 5) if s and txt in s.upper()), False) + + def on_recordings_filter_toggled(self, button): + if not button.get_active(): + self._filter_entry.set_text("") + def on_playback(self, box, state): """ Updates state of the UI elements for playback mode. """ if self._settings.play_streams_mode is PlayStreamsMode.BUILT_IN: @@ -820,10 +841,11 @@ class ControlTool(Gtk.Box): self._pix = None handlers = {"on_volume_changed": self.on_volume_changed, - "on_screenshot_draw": self.on_screenshot_draw} + "on_screenshot_draw": self.on_screenshot_draw, + "on_network_toggled": self.on_network_toggled} builder = get_builder(UI_RESOURCES_PATH + "control.glade", handlers, - objects=("control_box", "volume_adjustment")) + objects=("control_box", "volume_adjustment", "network_model")) self.pack_start(builder.get_object("control_box"), True, True, 0) self._remote_box = builder.get_object("remote_box") @@ -839,6 +861,7 @@ class ControlTool(Gtk.Box): self._agc_level_bar = builder.get_object("agc_level_bar") self._volume_button = builder.get_object("volume_button") self.init_actions(app) + if settings.alternate_layout: self.on_layout_changed(app, True) @@ -1006,3 +1029,9 @@ class ControlTool(Gtk.Box): self._snr_level_bar.set_value(int(snr.strip("%N/A") or 0)) self._agc_level_bar.set_value(int(acg.rstrip("%N/A") or 0)) self._ber_level_bar.set_value(int(ber.rstrip("N/A") or 0)) + + # ***************** Network explorer ********************** # + + @run_task + def on_network_toggled(self, button): + pass diff --git a/app/ui/main.py b/app/ui/main.py index 6b05ccae..650a2ef0 100644 --- a/app/ui/main.py +++ b/app/ui/main.py @@ -2671,7 +2671,7 @@ class Application(Gtk.Application): elif key is KeyboardKey.DELETE: self.on_delete(view) elif ctrl and key is KeyboardKey.R or key is KeyboardKey.F2: - if event.state & Gdk.ModifierType.SHIFT_MASK: + if event.state & Gdk.ModifierType.MOD1_MASK: # ALT self.on_rename_for_bouquet() else: self.on_rename(view)