diff --git a/app/ui/satellites_dialog.glade b/app/ui/satellites_dialog.glade index e90e90e8..e507cce4 100644 --- a/app/ui/satellites_dialog.glade +++ b/app/ui/satellites_dialog.glade @@ -135,44 +135,145 @@ Author: Dmitriy Yefremov - - True + False + - - gtk-open + True False - True - True - - - - - - gtk-save - True - False - True - True - - - - - - True - False - - - - - gtk-quit - True - False - True - True - + 5 + 5 + 0 + in + + + True + False + center + 5 + 5 + 5 + 5 + vertical + 2 + + + gtk-open + True + True + True + none + True + True + + + + False + True + 0 + + + + + gtk-save + True + True + True + none + True + True + + + + False + True + 1 + + + + + gtk-save-as + True + True + True + none + True + True + + + + False + True + 2 + + + + + True + False + + + False + True + 3 + + + + + gtk-refresh + True + True + True + none + True + True + + + + False + True + 4 + + + + + True + False + + + False + True + 2 + 5 + + + + + gtk-quit + True + True + True + none + True + True + + + + False + True + 6 + + + + + + + + + main + @@ -383,7 +484,7 @@ Author: Dmitriy Yefremov True True True - left_header_menu + left_header_menu True diff --git a/app/ui/satellites_dialog.py b/app/ui/satellites_dialog.py index 4be69111..4ef180f9 100644 --- a/app/ui/satellites_dialog.py +++ b/app/ui/satellites_dialog.py @@ -26,6 +26,7 @@ class SatellitesDialog: handlers = {"on_open": self.on_open, "on_remove": self.on_remove, "on_save": self.on_save, + "on_save_as": self.on_save_as, "on_update": self.on_update, "on_up": self.on_up, "on_down": self.on_down, @@ -34,6 +35,7 @@ class SatellitesDialog: "on_transponder_add": self.on_transponder_add, "on_edit": self.on_edit, "on_key_release": self.on_key_release, + "on_popover_release": self.on_popover_release, "on_row_activated": self.on_row_activated, "on_resize": self.on_resize, "on_quit": self.on_quit} @@ -70,18 +72,13 @@ class SatellitesDialog: if self._options: self._options["sat_editor_window_size"] = window.get_size() + @run_idle def on_quit(self, *args): self._dialog.destroy() + @run_idle def on_open(self, model): - file_filter = Gtk.FileFilter() - file_filter.add_pattern("satellites.xml") - file_filter.set_name("satellites.xml") - response = show_dialog(dialog_type=DialogType.CHOOSER, - transient=self._dialog, - options=self._options, - action_type=Gtk.FileChooserAction.OPEN, - file_filter=file_filter) + response = self.get_file_dialog_response(Gtk.FileChooserAction.OPEN) if response == Gtk.ResponseType.CANCEL: return @@ -91,6 +88,17 @@ class SatellitesDialog: self._data_path = response self.on_satellites_list_load(model) + def get_file_dialog_response(self, action: Gtk.FileChooserAction): + file_filter = Gtk.FileFilter() + file_filter.add_pattern("satellites.xml") + file_filter.set_name("satellites.xml") + response = show_dialog(dialog_type=DialogType.CHOOSER, + transient=self._dialog, + options=self._options, + action_type=action, + file_filter=file_filter) + return response + @staticmethod def on_row_activated(view, path, column): if view.row_expanded(path): @@ -126,6 +134,9 @@ class SatellitesDialog: elif key == Gdk.KEY_Left or key == Gdk.KEY_Right: view.do_unselect_all(view) + def on_popover_release(self, menu, event): + menu.popdown() + @run_idle def on_satellites_list_load(self, model): """ Load satellites data into model """ @@ -261,6 +272,7 @@ class SatellitesDialog: for itr in [model.get_iter(path) for path in paths]: model.remove(itr) + @run_idle def on_save(self, view): if show_dialog(DialogType.QUESTION, self._dialog) == Gtk.ResponseType.CANCEL: return @@ -270,6 +282,13 @@ class SatellitesDialog: model.foreach(self.parse_data, satellites) write_satellites(satellites, self._data_path) + def on_save_as(self, item): + response = self.get_file_dialog_response(Gtk.FileChooserAction.SAVE) + if response == Gtk.ResponseType.CANCEL: + return + show_dialog(DialogType.ERROR, transient=self._dialog, text="Not implemented yet!") + + @run_idle def on_update(self, item): dialog = SatellitesUpdateDialog(self._dialog, self._sat_view.get_model()) dialog.run()