From ac7d219bb14fdb27e05e3cc98abb548f5ca87e7b Mon Sep 17 00:00:00 2001 From: luxick Date: Wed, 28 Feb 2018 09:51:58 +0100 Subject: [PATCH] Make cells in 'manage base data' dialogs editable. --- dsst/dsst_gtk3/dialogs.py | 15 +- dsst/dsst_gtk3/handlers/base_data_handlers.py | 30 +- dsst/dsst_gtk3/handlers/dialog_handlers.py | 2 +- dsst/dsst_gtk3/handlers/season_handlers.py | 6 +- dsst/dsst_gtk3/resources/glade/window.glade | 689 +++++++++--------- 5 files changed, 381 insertions(+), 361 deletions(-) diff --git a/dsst/dsst_gtk3/dialogs.py b/dsst/dsst_gtk3/dialogs.py index d150bb9..a57aa26 100644 --- a/dsst/dsst_gtk3/dialogs.py +++ b/dsst/dsst_gtk3/dialogs.py @@ -88,31 +88,22 @@ def show_manage_players_dialog(builder: Gtk.Builder, title: str): """ dialog = builder.get_object("manage_players_dialog") # type: Gtk.Dialog dialog.set_transient_for(builder.get_object("main_window")) - dialog.set_title(title) - - result = dialog.run() + dialog.run() dialog.hide() - if result == Gtk.ResponseType.OK: - pass - def show_manage_enemies_dialog(builder: Gtk.Builder, season_id: int): dialog = builder.get_object("manage_enemies_dialog") # type: Gtk.Dialog dialog.set_transient_for(builder.get_object("main_window")) - - result = dialog.run() + dialog.run() dialog.hide() - return result - def show_manage_drinks_dialog(builder: Gtk.Builder): dialog = builder.get_object("manage_drinks_dialog") # type: Gtk.Dialog dialog.set_transient_for(builder.get_object("main_window")) - result = dialog.run() + dialog.run() dialog.hide() - return result def show_edit_death_dialog(builder: Gtk.Builder, episode_id: int, death: sql.Death=None): diff --git a/dsst/dsst_gtk3/handlers/base_data_handlers.py b/dsst/dsst_gtk3/handlers/base_data_handlers.py index 5ec083c..c4324f6 100644 --- a/dsst/dsst_gtk3/handlers/base_data_handlers.py +++ b/dsst/dsst_gtk3/handlers/base_data_handlers.py @@ -17,4 +17,32 @@ class BaseDataHandlers: self.app.reload_base_data() def do_manage_enemies(self, *_): - result = dialogs.show_manage_enemies_dialog(self.app.ui, self.app.get_selected_season_id()) \ No newline at end of file + result = dialogs.show_manage_enemies_dialog(self.app.ui, self.app.get_selected_season_id()) + + def on_player_name_edited(self, _, index, value): + row = self.app.ui.get_object('all_players_store')[index] + sql.Player.update(name=value)\ + .where(sql.Player.id == row[0])\ + .execute() + self.app.reload_base_data() + + def on_player_hex_edited(self, _, index, value): + row = self.app.ui.get_object('all_players_store')[index] + sql.Player.update(hex_id=value)\ + .where(sql.Player.id == row[0])\ + .execute() + self.app.reload_base_data() + + def on_drink_name_edited(self, _, index, value): + row = self.app.ui.get_object('drink_store')[index] + sql.Drink.update(name=value)\ + .where(sql.Drink.id == row[0])\ + .execute() + self.app.reload_base_data() + + def on_drink_vol_edited(self, _, index, value): + row = self.app.ui.get_object('drink_store')[index] + sql.Drink.update(vol=value) \ + .where(sql.Drink.id == row[0]) \ + .execute() + self.app.reload_base_data() \ No newline at end of file diff --git a/dsst/dsst_gtk3/handlers/dialog_handlers.py b/dsst/dsst_gtk3/handlers/dialog_handlers.py index 952fbe5..60dbcd5 100644 --- a/dsst/dsst_gtk3/handlers/dialog_handlers.py +++ b/dsst/dsst_gtk3/handlers/dialog_handlers.py @@ -34,4 +34,4 @@ class DialogHandlers: store = self.app.ui.get_object('drink_store') drink = sql.Drink.create(name=entry.get_text(), vol='0') store.append([drink.id, drink.name, drink.vol]) - entry.set_text('') \ No newline at end of file + entry.set_text('') diff --git a/dsst/dsst_gtk3/handlers/season_handlers.py b/dsst/dsst_gtk3/handlers/season_handlers.py index a9a71a8..472301a 100644 --- a/dsst/dsst_gtk3/handlers/season_handlers.py +++ b/dsst/dsst_gtk3/handlers/season_handlers.py @@ -24,4 +24,8 @@ class SeasonHandlers: self.app.reload_for_season() def on_selected_episode_changed(self, *_): - self.app.reload_for_episode() \ No newline at end of file + self.app.reload_for_episode() + + def on_episode_double_click(self, *_): + self.app.reload_for_episode() + self.app.ui.get_object('stats_notebook').set_current_page(1) diff --git a/dsst/dsst_gtk3/resources/glade/window.glade b/dsst/dsst_gtk3/resources/glade/window.glade index d205f74..27e8874 100644 --- a/dsst/dsst_gtk3/resources/glade/window.glade +++ b/dsst/dsst_gtk3/resources/glade/window.glade @@ -12,171 +12,6 @@ - - False - False - True - dialog - False - - - False - vertical - 4 - - - False - end - - - gtk-ok - True - True - True - True - - - True - True - 0 - - - - - gtk-cancel - True - True - True - True - - - True - True - 1 - - - - - False - False - 0 - - - - - True - False - vertical - 5 - - - True - False - 5 - - - True - False - 5 - 5 - Add Player - - - False - True - 0 - - - - - True - True - - - - False - True - 1 - - - - - False - True - 0 - - - - - True - False - 5 - 5 - All Players - 0 - - - False - True - 1 - - - - - True - True - True - all_players_store - 0 - - - - - - Name - - - - 1 - - - - - - - Hex ID - - - - 2 - - - - - - - False - True - 2 - - - - - True - True - 1 - - - - - - okButtonRename2 - cancelButtonRename2 - - - - - @@ -187,171 +22,6 @@ - - False - False - True - dialog - False - - - False - vertical - 4 - - - False - end - - - gtk-ok - True - True - True - True - - - True - True - 0 - - - - - gtk-cancel - True - True - True - True - - - True - True - 1 - - - - - False - False - 0 - - - - - True - False - vertical - 5 - - - True - False - 5 - - - True - False - 5 - 5 - Add Drink - - - False - True - 0 - - - - - True - True - - - - False - True - 1 - - - - - False - True - 0 - - - - - True - False - 5 - 5 - All Drinks - 0 - - - False - True - 1 - - - - - True - True - True - drink_store - 0 - - - - - - Name - - - - 1 - - - - - - - Vol. - - - - 2 - - - - - - - False - True - 2 - - - - - True - True - 1 - - - - - - okButtonRename3 - cancelButtonRename3 - - - - - @@ -369,6 +39,7 @@ Manage Enemies For This Season False True + 300 dialog False @@ -381,22 +52,11 @@ False end - - gtk-ok - True - True - True - True - - - True - True - 0 - + - - gtk-cancel + + gtk-ok True True True @@ -513,7 +173,6 @@ okButtonRename1 - cancelButtonRename1 @@ -821,6 +480,342 @@ + + False + Manage Drinks + False + True + 300 + dialog + False + + + False + vertical + 4 + + + False + end + + + + + + gtk-ok + True + True + True + True + + + True + True + 1 + + + + + False + False + 0 + + + + + True + False + vertical + 5 + + + True + False + 5 + + + True + False + 5 + 5 + Add Drink + + + False + True + 0 + + + + + True + True + + + + False + True + 1 + + + + + False + True + 0 + + + + + True + False + 5 + 5 + All Drinks + 0 + + + False + True + 1 + + + + + True + True + in + + + True + True + True + drink_store + 0 + + + + + + Name + + + True + + + + 1 + + + + + + + Vol. + + + True + + + + 2 + + + + + + + + + True + True + 2 + + + + + True + True + 1 + + + + + + okButtonRename3 + + + + + + + False + Manage Players + False + True + 300 + dialog + False + + + False + vertical + 4 + + + False + end + + + + + + gtk-ok + True + True + True + True + + + True + True + 1 + + + + + False + False + 0 + + + + + True + False + vertical + 5 + + + True + False + 5 + + + True + False + 5 + 5 + Add Player + + + False + True + 0 + + + + + True + True + + + + False + True + 1 + + + + + False + True + 0 + + + + + True + False + 5 + 5 + All Players + 0 + + + False + True + 1 + + + + + True + True + in + + + True + True + True + all_players_store + 0 + + + + + + Name + + + True + + + + 1 + + + + + + + Hex ID + + + True + + + + 2 + + + + + + + + + True + True + 2 + + + + + True + True + 1 + + + + + + okButtonRename2 + + + + + @@ -1271,6 +1266,7 @@ True False + True Debug True @@ -1441,6 +1437,7 @@ True episodes_store 0 + @@ -1486,7 +1483,7 @@ True True - + True True True