From c4f5b3ac5960e50cf2f7b26eb93ec63310a34f1d Mon Sep 17 00:00:00 2001 From: Paul Goins Date: Sat, 29 Jan 2011 18:13:49 +0900 Subject: [PATCH] More cleanups in the kanji list editor dialog. Also removed some debug prints. --- .../jben/interface/gtk/dialog/kanjilisteditor.py | 39 ++++++++++++---------- python/jben/interface/gtk/window/main.py | 20 +++-------- 2 files changed, 26 insertions(+), 33 deletions(-) diff --git a/python/jben/interface/gtk/dialog/kanjilisteditor.py b/python/jben/interface/gtk/dialog/kanjilisteditor.py index 573ace3..d314f5d 100644 --- a/python/jben/interface/gtk/dialog/kanjilisteditor.py +++ b/python/jben/interface/gtk/dialog/kanjilisteditor.py @@ -20,16 +20,22 @@ class EditBox(gtk.TextView): self.set_accepts_tab(False) self.set_wrap_mode(gtk.WRAP_WORD_CHAR) + self.modified = False + + self.get_buffer().connect("changed", self.on_text_changed) + + def on_text_changed(self, widget): + print "EditBox.on_text_changed" + self.modified = True + class EditWindow(gtk.ScrolledWindow): - def __init__(self): + def __init__(self, edit_box): gtk.ScrolledWindow.__init__(self) self.set_shadow_type(gtk.SHADOW_IN) self.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) - - self.edit_box = EditBox() - self.add(self.edit_box) + self.add(edit_box) class ShadowedFrame(gtk.Frame): @@ -41,7 +47,7 @@ class ShadowedFrame(gtk.Frame): class AddFrame(ShadowedFrame): - def __init__(self): + def __init__(self, edit_box): ShadowedFrame.__init__(self, _("Add Kanji")) add_from_file = gtk.Button(_("From File")) @@ -58,7 +64,7 @@ class AddFrame(ShadowedFrame): class SortFrame(ShadowedFrame): - def __init__(self): + def __init__(self, edit_box): ShadowedFrame.__init__(self, _("Sort Kanji")) sort_by_jouyou = gtk.Button(_("By Jouyou Grade")) @@ -74,11 +80,11 @@ class SortFrame(ShadowedFrame): class SideButtons(gtk.VBox): - def __init__(self): + def __init__(self, edit_box): gtk.VBox.__init__(self, spacing=5) - add_frame = AddFrame() - sort_frame = SortFrame() + add_frame = AddFrame(edit_box) + sort_frame = SortFrame(edit_box) for frame in (add_frame, sort_frame): self.pack_start(frame, expand=False) @@ -94,10 +100,10 @@ class DialogKanjiListEditor(StoredSizeDialog): StoredSizeDialog.__init__(self, "gui.kanjilisteditor.size", -1, -1, _("Kanji List Editor"), parent) - edit_window = EditWindow() - side_buttons = SideButtons() + self.edit_box = EditBox() - #edit_window.edit_box.get_buffer().connect("changed", self.on_text_changed) + edit_window = EditWindow(self.edit_box) + side_buttons = SideButtons(self.edit_box) main_box = gtk.HBox(spacing=5) main_box.pack_start(side_buttons, expand=False) @@ -121,16 +127,15 @@ class DialogKanjiListEditor(StoredSizeDialog): self.set_has_separator(False) - def on_text_changed(self, widget): - print "DialogKanjiListEditor.on_text_changed" + def apply(self): + print "apply()ing changes" def on_cancel_clicked(self, widget): - print "DialogKanjiListEditor.on_cancel_clicked" self.response(gtk.RESPONSE_CANCEL) def on_apply_clicked(self, widget): - print "DialogKanjiListEditor.on_apply_clicked" + self.apply() def on_ok_clicked(self, widget): - print "DialogKanjiListEditor.on_ok_clicked" + self.apply() self.response(gtk.RESPONSE_OK) diff --git a/python/jben/interface/gtk/window/main.py b/python/jben/interface/gtk/window/main.py index 8509b7d..d40b37b 100644 --- a/python/jben/interface/gtk/window/main.py +++ b/python/jben/interface/gtk/window/main.py @@ -78,42 +78,31 @@ class Main(StoredSizeWindow): self.destroy() def on_menu_edit_vocab(self, widget): - print "on_menu_edit_vocab" - dialog = DialogVocabListEditor(self) result = dialog.run() dialog.destroy() if result == gtk.RESPONSE_OK: - print "OK was clicked." # If OK was pressed, update the WordDict GUI's current/max index. - else: - print "Cancel was clicked; dialog input discarded." + pass def on_menu_edit_kanji(self, widget): - print "on_menu_edit_kanji" - dialog = DialogKanjiListEditor(self) result = dialog.run() dialog.destroy() if result == gtk.RESPONSE_OK: - print "OK was clicked." # If OK was pressed, update the KanjiDict GUI's current/max index. - else: - print "Cancel was clicked; dialog input discarded." + pass def on_menu_edit_prefs(self, widget): - print "on_menu_edit_prefs" - dialog = DialogPreferences(self) result = dialog.run() dialog.destroy() if result == gtk.RESPONSE_OK: - print "OK was clicked." - else: - print "Cancel was clicked; dialog input discarded." + # If OK was pressed, refresh the UI. + pass def on_menu_practice_kanji(self, widget): print "on_menu_practice_kanji" @@ -126,7 +115,6 @@ class Main(StoredSizeWindow): _("Sorry, this has not yet been re-implemented.")) def on_menu_tools_hand(self, widget): - print "on_menu_tools_hand" # Show kanji handwriting pad... no real reason to make it modal; allow # the user to open multiple ones if they desire. hwpad = WindowKanjiHWSearch() -- 2.11.4.GIT