diff --git a/honoka/src/honoka_imengine_setup.cpp b/honoka/src/honoka_imengine_setup.cpp index a5b3de3..1049c5c 100644 --- a/honoka/src/honoka_imengine_setup.cpp +++ b/honoka/src/honoka_imengine_setup.cpp @@ -124,46 +124,55 @@ static GtkWidget * create_setup_window () { - setup = new HonokaSetupGtk("setup","",""); - HonokaSetupGtkPage *page; + setup = new HonokaSetup("setup","",""); + HonokaSetupPage *page; vector l; - HonokaSetupGtk * keys = new HonokaSetupGtk(_("key setting"),"",""); - page = new HonokaSetupGtkPage(_("general setting"),"",""); - page->append(new HonokaSetupGtkIntItem( + + page = new HonokaSetupPage(_("general setting"),"",""); + page->append(new HonokaSetupIntItem( _("_Auto candidates popup: "), HONOKA_CONFIG_ALP, _("set the count of conversion until displaying the list of lookup result automatically."), HONOKA_DEFAULT_ALP, -1,10 )); + page->append(new HonokaSetupBoolItem( + _("_NumKey selection: "), + HONOKA_CONFIG_NUMKEY_SELECT, + _("If you use the candidate selection by numkey, check this."), + HONOKA_DEFAULT_NUMKEY_SELECT + )); + setup->append(page); - page = new HonokaSetupGtkPage(_("Common keys"),"",""); - page->append(new HonokaSetupGtkKeyItem( + HonokaSetup * keys = new HonokaSetup(_("key setting"),"",""); + + page = new HonokaSetupPage(_("Common keys"),"",""); + page->append(new HonokaSetupKeyItem( _("Commit keys:"), HONOKA_CONFIG_KEY_COMMIT, _("The key events to commit the preedit string. "), HONOKA_DEFAULT_KEY_COMMIT )); - page->append(new HonokaSetupGtkKeyItem( + page->append(new HonokaSetupKeyItem( _("Convert keys:"), HONOKA_CONFIG_KEY_CONVERSION_START, _("The key events to convert the preedit string to kanji. "), HONOKA_DEFAULT_KEY_CONVERSION_START )); - page->append(new HonokaSetupGtkKeyItem( + page->append(new HonokaSetupKeyItem( _("Cancel keys:"), HONOKA_CONFIG_KEY_CANCEL, _("The key events to cancel preediting or converting. "), HONOKA_DEFAULT_KEY_CANCEL )); - page->append(new HonokaSetupGtkKeyItem( + page->append(new HonokaSetupKeyItem( _("Backspace keys:"), HONOKA_CONFIG_KEY_BACKSPACE, _("The key events to delete a character before caret. "), HONOKA_DEFAULT_KEY_BACKSPACE )); - page->append(new HonokaSetupGtkKeyItem( + page->append(new HonokaSetupKeyItem( _("Delete keys:"), HONOKA_CONFIG_KEY_DELETE, _("The key events to delete a character after caret. "), @@ -171,14 +180,14 @@ )); keys->append(page); - page = new HonokaSetupGtkPage(_("Preedit keys"),"",""); - page->append(new HonokaSetupGtkKeyItem( + page = new HonokaSetupPage(_("Preedit keys"),"",""); + page->append(new HonokaSetupKeyItem( _("Move forward keys:"), HONOKA_CONFIG_KEY_FORWARD, _("The key events to move the caret to forward. "), HONOKA_DEFAULT_KEY_FORWARD )); - page->append(new HonokaSetupGtkKeyItem( + page->append(new HonokaSetupKeyItem( _("Move backward keys:"), HONOKA_CONFIG_KEY_BACKWARD, _("The key events to move the caret to backward. "), @@ -186,26 +195,26 @@ )); keys->append(page); - page = new HonokaSetupGtkPage(_("Candidates keys"),"",""); - page->append(new HonokaSetupGtkKeyItem( + page = new HonokaSetupPage(_("Candidates keys"),"",""); + page->append(new HonokaSetupKeyItem( _("Next segment keys:"), HONOKA_CONFIG_KEY_CONVERSION_FORWARD, _("The key events to select next segment. "), HONOKA_DEFAULT_KEY_CONVERSION_FORWARD )); - page->append(new HonokaSetupGtkKeyItem( + page->append(new HonokaSetupKeyItem( _("Previous segment keys:"), HONOKA_CONFIG_KEY_CONVERSION_BACKWARD, _("The key events to select previous segment. "), HONOKA_DEFAULT_KEY_CONVERSION_BACKWARD )); - page->append(new HonokaSetupGtkKeyItem( + page->append(new HonokaSetupKeyItem( _("Shrink segment keys:"), HONOKA_CONFIG_KEY_CONVERSION_SHRINK, _("The key events to shrink the selected segment. "), HONOKA_DEFAULT_KEY_CONVERSION_SHRINK )); - page->append(new HonokaSetupGtkKeyItem( + page->append(new HonokaSetupKeyItem( _("Expand segment keys:"), HONOKA_CONFIG_KEY_CONVERSION_EXPAND, _("The key events to expand the selected segment. "), @@ -213,32 +222,32 @@ )); keys->append(page); - page = new HonokaSetupGtkPage(_("Candidates keys"),"",""); - page->append(new HonokaSetupGtkKeyItem( + page = new HonokaSetupPage(_("Candidates keys"),"",""); + page->append(new HonokaSetupKeyItem( _("Next keys:"), HONOKA_CONFIG_KEY_CONVERSION_NEXT, _("The key events to select next candidate. "), HONOKA_DEFAULT_KEY_CONVERSION_NEXT )); - page->append(new HonokaSetupGtkKeyItem( + page->append(new HonokaSetupKeyItem( _("Previous keys:"), HONOKA_CONFIG_KEY_CONVERSION_PREV, _("The key events to select previous candidate. "), HONOKA_DEFAULT_KEY_CONVERSION_PREV )); - page->append(new HonokaSetupGtkKeyItem( + page->append(new HonokaSetupKeyItem( _("candidates list keys:"), HONOKA_CONFIG_KEY_LOOKUPPOPUP, _("The key events to popup candidates list. "), HONOKA_DEFAULT_KEY_LOOKUPPOPUP )); - page->append(new HonokaSetupGtkKeyItem( + page->append(new HonokaSetupKeyItem( _("Page up keys:"), HONOKA_CONFIG_KEY_LOOKUPPAGEUP, _("The key events to select page up candidates. "), HONOKA_DEFAULT_KEY_LOOKUPPAGEUP )); - page->append(new HonokaSetupGtkKeyItem( + page->append(new HonokaSetupKeyItem( _("Page down keys:"), HONOKA_CONFIG_KEY_LOOKUPPAGEDOWN, _("The key events to select page down candidates. "), @@ -248,23 +257,25 @@ setup->append(keys); - page = new HonokaSetupGtkPage(_("Wnn-plugin"),"",""); + HonokaSetup * plugins = new HonokaSetup(_("plugins setting"),"",""); - page->append(new HonokaSetupGtkBoolItem( + page = new HonokaSetupPage(_("Wnn-plugin"),"",""); + + page->append(new HonokaSetupBoolItem( _("_Use this plugin: "), String(HONOKA_CONFIG_PLUGINLOADER_PREFIX) + String("/plugin-wnn"), _("if you use this plugin, check this."), true )); - page->append(new HonokaSetupGtkEntryItem( + page->append(new HonokaSetupEntryItem( _("_Server: "), HONOKA_CONFIG_JSERVER, _("input the server name to connect."), HONOKA_DEFAULT_JSERVER )); // file - page->append(new HonokaSetupGtkFileItem( + page->append(new HonokaSetupFileItem( _("_wnnenvrc: "), HONOKA_CONFIG_WNNENVRC, _("input the path of wnnenvrc."), @@ -275,60 +286,62 @@ l.push_back(String("Wnn6")); l.push_back(String("Wnn7")); l.push_back(String("Wnn8")); - page->append(new HonokaSetupGtkSelectItem( + page->append(new HonokaSetupSelectItem( _("Server_type: "), HONOKA_CONFIG_JSERVERTYPE, _("select the server type from Wnn4 / Wnn6 / Wnn7."), HONOKA_DEFAULT_JSERVERTYPE, l )); - setup->append(page); + plugins->append(page); - page = new HonokaSetupGtkPage(_("Anthy-plugin"),"",""); + page = new HonokaSetupPage(_("Anthy-plugin"),"",""); - page->append(new HonokaSetupGtkBoolItem( + page->append(new HonokaSetupBoolItem( _("_Use this plugin: "), String(HONOKA_CONFIG_PLUGINLOADER_PREFIX) + String("/plugin-anthy"), _("if you use this plugin, check this."), true )); - setup->append(page); + plugins->append(page); - page = new HonokaSetupGtkPage(_("Canna-plugin"),"",""); + page = new HonokaSetupPage(_("Canna-plugin"),"",""); - page->append(new HonokaSetupGtkBoolItem( + page->append(new HonokaSetupBoolItem( _("_Use this plugin: "), String(HONOKA_CONFIG_PLUGINLOADER_PREFIX) + String("/canna-anthy"), _("if you use this plugin, check this."), true )); // file - page->append(new HonokaSetupGtkFileItem( + page->append(new HonokaSetupFileItem( _("_DicHomeDir: "), HONOKA_CONFIG_CANNA_DICHOMEDIRPATH, _("set your DicHomeDir in this entry."), HONOKA_DEFAULT_CANNA_DICHOMEDIRPATH )); - setup->append(page); + plugins->append(page); - page = new HonokaSetupGtkPage(_("SKKDic-plugin"),"",""); + page = new HonokaSetupPage(_("SKKDic-plugin"),"",""); - page->append(new HonokaSetupGtkBoolItem( + page->append(new HonokaSetupBoolItem( _("_Use this plugin: "), String(HONOKA_CONFIG_PLUGINLOADER_PREFIX) + String("/skkdic-anthy"), _("if you use this plugin, check this."), true )); // file - page->append(new HonokaSetupGtkFileItem( + page->append(new HonokaSetupFileItem( _("_SKKDic file: "), HONOKA_CONFIG_SKKDIC_DICFILE, _("set SKKDic file in this entry."), HONOKA_DEFAULT_SKKDIC_DICFILE )); - setup->append(page); + plugins->append(page); + + setup->append(plugins); return setup->getValueWidget(); @@ -339,7 +352,7 @@ { if (!config.null()) { setup->readConfig(config); - HonokaSetupGtk::changed = false; + HonokaSetup::changed = false; } } @@ -348,14 +361,14 @@ { if (!config.null()) { setup->saveConfig(config); - HonokaSetupGtk::changed = false; + HonokaSetup::changed = false; } } static bool query_changed () { - return HonokaSetupGtk::changed; + return HonokaSetup::changed; } diff --git a/honoka/src/honokasetupgtk.cpp b/honoka/src/honokasetupgtk.cpp index 703b419..f40edd1 100644 --- a/honoka/src/honokasetupgtk.cpp +++ b/honoka/src/honokasetupgtk.cpp @@ -153,6 +153,30 @@ }; // +// Container +// + +HonokaSetupGtkContainer::HonokaSetupGtkContainer() +{ + items.clear(); +}; + +HonokaSetupGtkContainer::~HonokaSetupGtkContainer() +{ +}; + + +HonokaSetupGtkItem * HonokaSetupGtkContainer::getLastItem() { + if (!items.size()) return 0; + return items[items.size() - 1]; +}; + +void HonokaSetupGtkContainer::append(HonokaSetupGtkItem *item) +{ + items.push_back(item); +} + +// // KeyItem // @@ -474,7 +498,7 @@ // HonokaSetupGtkPage::HonokaSetupGtkPage(String _label,String _name,String _tip) -: HonokaSetupGtkItem(_label,_name,_tip) +: HonokaSetupGtkItem(_label,_name,_tip),HonokaSetupGtkContainer() { valueWidget = gtk_vbox_new(FALSE, 0); gtk_widget_show(valueWidget); @@ -521,7 +545,7 @@ HonokaSetupGtk::HonokaSetupGtk(String _label,String _name,String _tip) -: HonokaSetupGtkItem(_label,_name,_tip) +: HonokaSetupGtkItem(_label,_name,_tip),HonokaSetupGtkContainer() { valueWidget = gtk_notebook_new(); gtk_widget_show(valueWidget); @@ -536,7 +560,7 @@ void HonokaSetupGtk::append(HonokaSetupGtkItem *page) { - pages.push_back(page); + items.push_back(page); gtk_widget_show(page->getLabelWidget()); gtk_notebook_append_page(GTK_NOTEBOOK(valueWidget),page->getValueWidget(),page->getLabelWidget()); @@ -545,24 +569,18 @@ void HonokaSetupGtk::readConfig(ConfigPointer cfg) { - for(unsigned int i = 0;i < pages.size();i ++) { - pages[i]->readConfig(cfg); + for(unsigned int i = 0;i < items.size();i ++) { + items[i]->readConfig(cfg); } return; } void HonokaSetupGtk::saveConfig(ConfigPointer cfg) { - for(unsigned int i = 0;i < pages.size();i ++) { - pages[i]->saveConfig(cfg); + for(unsigned int i = 0;i < items.size();i ++) { + items[i]->saveConfig(cfg); } return; } -HonokaSetupGtkItem * HonokaSetupGtk::getLastItem() { - if (!pages.size()) return 0; - return pages[pages.size() - 1]; -}; - - diff --git a/honoka/src/honokasetupgtk.h b/honoka/src/honokasetupgtk.h index b9bce16..9514776 100644 --- a/honoka/src/honokasetupgtk.h +++ b/honoka/src/honokasetupgtk.h @@ -38,6 +38,22 @@ /** @author TAM (Teppei Tamra) */ + +// for GTK + +#define HonokaSetupItem HonokaSetupGtkItem +#define HonokaSetupEntryItem HonokaSetupGtkEntryItem +#define HonokaSetupFileItem HonokaSetupGtkFileItem +#define HonokaSetupKeyItem HonokaSetupGtkKeyItem +#define HonokaSetupBoolItem HonokaSetupGtkBoolItem +#define HonokaSetupIntItem HonokaSetupGtkIntItem +#define HonokaSetupSelectItem HonokaSetupGtkSelectItem +#define HonokaSetupPage HonokaSetupGtkPage +#define HonokaSetup HonokaSetupGtk + + + + class HonokaSetupGtkItem { public: GtkWidget *getValueWidget(); @@ -60,6 +76,16 @@ static GtkTooltips *tipWidget; }; +class HonokaSetupGtkContainer { +public: + HonokaSetupGtkItem * getLastItem(); +protected: + HonokaSetupGtkContainer(); + ~HonokaSetupGtkContainer(); + virtual void append(HonokaSetupGtkItem *item); + vector items; +}; + class HonokaSetupGtkEntryItem : public HonokaSetupGtkItem { public: HonokaSetupGtkEntryItem(String _label,String _name,String _tip,String _default); @@ -145,30 +171,26 @@ }; -class HonokaSetupGtkPage: public HonokaSetupGtkItem { +class HonokaSetupGtkPage: public HonokaSetupGtkItem ,public HonokaSetupGtkContainer { public: HonokaSetupGtkPage(String _label,String _name,String _tip); ~HonokaSetupGtkPage(); - void append(HonokaSetupGtkItem *item); + virtual void append(HonokaSetupGtkItem *item); String getLabel(); virtual void readConfig(ConfigPointer cfg); virtual void saveConfig(ConfigPointer cfg); protected: - vector items; GtkWidget *table; }; -class HonokaSetupGtk: public HonokaSetupGtkItem { +class HonokaSetupGtk: public HonokaSetupGtkItem ,public HonokaSetupGtkContainer { public: HonokaSetupGtk(String _label,String _name,String _tip); ~HonokaSetupGtk(); - void append(HonokaSetupGtkItem *page); + virtual void append(HonokaSetupGtkItem *page); virtual void readConfig(ConfigPointer cfg); virtual void saveConfig(ConfigPointer cfg); - HonokaSetupGtkItem * getLastItem(); -protected: - vector pages; }; #endif