From 401541af716ba2781fd546faea667054bd9a05d0 Mon Sep 17 00:00:00 2001 From: Karel Matas Date: Fri, 5 Jul 2013 16:21:40 +0200 Subject: [PATCH] show kanji in dicview context menu --- CHANGELOG | 1 + src/aoi.cxx | 2 +- src/gui.cxx | 8 +++++++- src/gui.hxx | 17 +++++++++++++---- 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 558ef40..a73283f 100755 --- a/CHANGELOG +++ b/CHANGELOG @@ -5,6 +5,7 @@ alpha.03 (temporary replacement of EditWord) - example sentences from Tatoeba project (initial version) - downloading the pre-built database from internet +- show kanji in dicview context menu alpha.02 - JLPT and Grade are now separate fields, not flags. diff --git a/src/aoi.cxx b/src/aoi.cxx index 9b37f5c..cccf5eb 100755 --- a/src/aoi.cxx +++ b/src/aoi.cxx @@ -69,7 +69,7 @@ App::App () #ifdef DEBUG // ui_->progress(90, "DEBUG query..." ); -// parse_dic_input("ana*"); + parse_dic_input("ana*"); // cb_kanji_search(); // ui_->cb_toggle_group(nullptr); #endif diff --git a/src/gui.cxx b/src/gui.cxx index 0bebd52..b3e6d45 100755 --- a/src/gui.cxx +++ b/src/gui.cxx @@ -300,7 +300,7 @@ void GUI::dicview_menu ( int did, const vector &v, bool notes, bool exam menu.textsize( 1.5*font_base_size_ ); for ( string s: v ){ menu.add( (s+"/Copy").c_str(), 0, scb_copy, (void*)s.c_str()); - menu.add( (s+"/Show").c_str() ); + menu.add( (s+"/Show").c_str(), 0, scb_menu_show_kanji, (void*)this ); } menu.add("Notes",0,0,0, notes ? 0:FL_MENU_INACTIVE); menu.add("Examples",0, App::scb_examples,(void*)parent_, @@ -350,6 +350,12 @@ void GUI::popup_kanji ( const Kanji &k ) } +void GUI::popup_kanji ( const string &k ) +{ + popup_kanji(parent_->db_get_kanji(k)); +} + + void GUI::cb_knj_clear () { main_window_->e_strokes->value(""); diff --git a/src/gui.hxx b/src/gui.hxx index 128d026..ad5d8c2 100755 --- a/src/gui.hxx +++ b/src/gui.hxx @@ -372,6 +372,10 @@ class GUI //! Popups KanjiPopupWindow in KanjiView. void popup_kanji ( const Kanji &k ); + /*! + * Tells App to find kanji k and call popup_kanji( const Kanji &k ). + */ + void popup_kanji ( const string &k ); // interface for App (controller) inline void help_file ( const string &s ) { help_file_ = s; }; @@ -432,15 +436,20 @@ class GUI }; void cb_jis208_toggle (); - //! See popup_kanji() + inline static void scb_menu_show_kanji ( Fl_Widget *w, void *p ){ + char name[64]; // the last picked menu item + if ( ((Fl_Menu_*)w)->item_pathname(name, sizeof(name)-1) == 0 ) + // menu item is in the form: "Kanji/Show" + ((GUI*)p)->popup_kanji( strtok( name, "/" ) ); + } inline static void scb_knj_clear ( Fl_Widget *w, void *f ) {((GUI *)f)->cb_knj_clear(); } inline static void scb_toggle_group(Fl_Widget *w, void *f) - {((GUI *)f)->cb_toggle_group();}; + {((GUI *)f)->cb_toggle_group();} inline static void scb_show_help(Fl_Widget *w, void *f) - {((GUI *)f)->cb_show_help();}; + {((GUI *)f)->cb_show_help();} inline static void scb_jis208_toggle(Fl_Widget *w, void *f) - {((GUI *)f)->cb_jis208_toggle();}; + {((GUI *)f)->cb_jis208_toggle();} inline static void scb_test_romanization ( Fl_Widget *w, void *p ) {((GUI*)p)->show_romanization_test(); } inline static void scb_test_fonts ( Fl_Widget *w, void *p ) -- 2.11.4.GIT