mirror of
https://github.com/aclist/dztui.git
synced 2026-08-26 17:57:06 +02:00
fix: pass correct number of records
This commit is contained in:
parent
1b1cb33a6e
commit
672c8f9e9e
@ -473,7 +473,7 @@ def query_by_ip(addr: str) -> Optional[dict]:
|
||||
try:
|
||||
record = addr.split(":")
|
||||
# TODO: create a Record object
|
||||
ip, qport = record[0], record[2]
|
||||
ip, qport = record[0], record[1]
|
||||
res = query_direct(ip, int(qport))
|
||||
except Exception as e:
|
||||
logger.critical(e)
|
||||
|
||||
@ -197,19 +197,19 @@ class ServerModelManager:
|
||||
@call_on_thread(dialog.querying)
|
||||
def add_by_ip(self, addr: str) -> None:
|
||||
res = Servers.query_by_ip(addr)
|
||||
self.parse_single_record(res)
|
||||
self._parse_single_record(res)
|
||||
|
||||
def parse_single_record(self, record: dict) -> None:
|
||||
if res is None:
|
||||
def _parse_single_record(self, response: dict) -> None:
|
||||
if response is None:
|
||||
self.thread_man.set_cleanup_func(StoredFunc(self._cleanup_on_failure))
|
||||
return
|
||||
|
||||
record = Servers.parse_json([res])
|
||||
record = Servers.parse_json([response])
|
||||
|
||||
proxy_man = self._get_proxy_man()
|
||||
raw_model = proxy_man.get_control()
|
||||
|
||||
fqip = Servers.response_to_fq_ip(res)
|
||||
fqip = Servers.response_to_fq_ip(response)
|
||||
config_man = self.controller.get_config_man()
|
||||
config_man.add_saved_server(fqip)
|
||||
|
||||
@ -324,6 +324,7 @@ class ServerModelManager:
|
||||
manager.filter(FilterMode.INITIAL)
|
||||
self.to_insert = manager.get_proxy_model()
|
||||
|
||||
# TODO: abstract for all methods
|
||||
u_maps = set([row[1] for row in data])
|
||||
self._set_new_maps(sorted(u_maps))
|
||||
|
||||
|
||||
@ -217,6 +217,7 @@ class AddPanel(Gtk.Frame):
|
||||
ServerModelManager(self.controller, tree).add_by_ip(addr)
|
||||
|
||||
def _on_activate(self, entry: Gtk.Entry) -> None:
|
||||
# NOTE: default action is to add a record, not connect
|
||||
if not self.add_server.is_sensitive():
|
||||
return
|
||||
self._submit_query()
|
||||
|
||||
@ -50,15 +50,22 @@ class LogTreeView(ContextMixin, TreeView):
|
||||
|
||||
def _on_log_buttonpress(self, widget: Gtk.Widget, event: Gdk.EventButton) -> None:
|
||||
if event.button == Gdk.BUTTON_SECONDARY:
|
||||
path, col, x, y = self.get_path_at_pos(int(event.x), int(event.y))
|
||||
if path:
|
||||
selection = self.get_selection()
|
||||
model, selected_paths = selection.get_selected_rows()
|
||||
if path not in selected_paths:
|
||||
selection.select_path(path)
|
||||
self.present_menu(widget, event)
|
||||
return True
|
||||
return False
|
||||
#selection = self.get_selection()
|
||||
#model, selected_paths = selection.get_selected_rows()
|
||||
#if len(selected_paths) > 1:
|
||||
# for path in selected_paths:
|
||||
# selection.select_path(path)
|
||||
# path, col, x, y = self.get_path_at_pos(int(event.x), int(event.y))
|
||||
# if path:
|
||||
# selection = self.get_selection()
|
||||
# model, selected_paths = selection.get_selected_rows()
|
||||
# if path not in selected_paths:
|
||||
# selection.select_path(path)
|
||||
# self.present_menu(widget, event)
|
||||
# return True
|
||||
#return False
|
||||
|
||||
def _on_log_keypress(self, widget: Gtk.Widget, event: Gdk.EventKey) -> None:
|
||||
self.present_menu(widget, event)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user