add CONFIG_NANONOTE support From: Xiangfu Liu --- configure.in | 36 +++++++++++++++++--------- src/Makefile.am | 6 ++++ src/class_factory.cpp | 6 ++++ src/conf.cpp | 4 +++ src/desktop.cpp | 2 + src/mainwin.cpp | 10 +++++++ src/stardict.cpp | 67 ++++++++++++++++++++++++++++++++++++------------- 7 files changed, 96 insertions(+), 35 deletions(-) diff --git a/configure.in b/configure.in index 83d3d95..4b15e43 100644 --- a/configure.in +++ b/configure.in @@ -296,14 +296,18 @@ dnl ================================================================ AC_ARG_ENABLE(gnome-support, AC_HELP_STRING([--disable-gnome-support], [Disable gnome support])) AC_ARG_ENABLE(gpe-support, AC_HELP_STRING([--enable-gpe-support], [Enable gpe support])) AC_ARG_ENABLE(maemo-support, AC_HELP_STRING([--enable-maemo-support], [Enable maemo support])) +AC_ARG_ENABLE(nanonote-support, AC_HELP_STRING([--enable-nanonote-support], [Enable Qi Hardware NanoNote support])) AM_CONDITIONAL(GNOME_SUPPORT, test "x${enable_gpe_support}" != "xyes" && test "x${enable_maemo_support}" != "xyes" && test "x${enable_gnome_support}" != "xno") AM_CONDITIONAL(GPE_SUPPORT, test "x${enable_gpe_support}" = "xyes") AM_CONDITIONAL(MAEMO_SUPPORT, test "x${enable_maemo_support}" = "xyes") +AM_CONDITIONAL(NANONOTE_SUPPORT, test "x${enable_nanonote_support}" = "xyes") if test "x${enable_gpe_support}" = "xyes" ; then DEP_MODULES="gtk+-2.0 >= 2.12 glib-2.0 >= 2.14 gthread-2.0 libgpewidget >= 0.109" elif test "x${enable_maemo_support}" = "xyes" ; then DEP_MODULES="gtk+-2.0 >= 2.12 gthread-2.0 gconf-2.0 >= 2.6 hildon-libs >= 0.12" +elif test "x${enable_nanonote_support}" = "xyes" ; then + DEP_MODULES="gtk+-2.0 >= 2.12 gthread-2.0 gconf-2.0 >= 2.6" elif test "x${enable_gnome_support}" = "xno" ; then DEP_MODULES="gtk+-2.0 >= 2.12 gthread-2.0" else @@ -329,6 +333,11 @@ elif test "x${enable_maemo_support}" = "xyes" ; then fi AM_GCONF_SOURCE_2 AM_CONDITIONAL(SCHEMAS_INSTALL, test x$schemas_install = xtrue) +elif test "x${enable_nanonote_support}" = "xyes" ; then + echo "Enable Qi Hardware NanoNote suppport"; + AC_DEFINE([CONFIG_NANONOTE],[], [Compile with nanonote support]) + AM_CONDITIONAL(SCHEMAS_INSTALL, test "x${enable_nanonote_support}" != "xyes") + AM_CONDITIONAL(GCONF_SCHEMAS_INSTALL, test "x${enable_nanonote_support}" != "xyes") elif test "x${enable_gnome_support}" = "xno" ; then echo "Disable gnome support"; AC_DEFINE([CONFIG_GTK],[], [Compile without gnome support]) @@ -414,21 +423,21 @@ dnl ========================================================================== # Checks for header files. need by Solaris. AC_PATH_XTRA -if test -n "$X_CFLAGS"; then -CPPFLAGS="$CPPFLAGS $X_CFLAGS" -fi -if test -n "$X_LIBS"; then -LDFLAGS="$LDFLAGS $X_LIBS" -fi -if test -n "$X_PRE_LIBS"; then -LDFLAGS="$LDFLAGS $X_PRE_LIBS" -fi -if test -n "$X_EXTRA_LIBS"; then -LDFLAGS="$LDFLAGS $X_EXTRA_LIBS" -fi +#if test -n "$X_CFLAGS"; then +#CPPFLAGS="$CPPFLAGS $X_CFLAGS" +#fi +#if test -n "$X_LIBS"; then +#LDFLAGS="$LDFLAGS $X_LIBS" +#fi +#if test -n "$X_PRE_LIBS"; then +#LDFLAGS="$LDFLAGS $X_PRE_LIBS" +#fi +#if test -n "$X_EXTRA_LIBS"; then +#LDFLAGS="$LDFLAGS $X_EXTRA_LIBS" +#fi # Checks for libraries. -AC_CHECK_LIB([X11], [main], , [AC_MSG_ERROR([X11 lib not found])]) +#AC_CHECK_LIB([X11], [main], , [AC_MSG_ERROR([X11 lib not found])]) AC_SUBST(STARDICT_LIBS) AC_SUBST(STARDICT_CFLAGS) @@ -494,3 +503,4 @@ echo " Type \"make\" to compile StarDict. " + diff --git a/src/Makefile.am b/src/Makefile.am index bca4861..1499775 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -34,9 +34,13 @@ CONFIG_FILE_MODULE = gconf_file.cpp gconf_file.hpp else CONFIG_FILE_MODULE = inifile.cpp inifile.hpp endif +if NANONOTE_SUPPORT +X11_ISKEYSPRESSED_FILE_MODULE = +endif else CONFIG_FILE_MODULE = gconf_file.cpp gconf_file.hpp IDL_FILE = GNOME_Stardict.idl +X11_ISKEYSPRESSED_FILE_MODULE = x11_iskeyspressed.cpp x11_iskeyspressed.hpp IDL_SOURCES = \ GNOME_Stardict-stubs.c \ @@ -73,7 +77,7 @@ stardict_SOURCES = \ class_factory.cpp class_factory.hpp \ config_file.hpp \ $(CONFIG_FILE_MODULE) \ - x11_iskeyspressed.cpp x11_iskeyspressed.hpp \ + $(X11_ISKEYSPRESSED_FILE_MODULE) \ gtk_iskeyspressed.cpp gtk_iskeyspressed.hpp \ progresswin.cpp progresswin.hpp \ tray.cpp tray.hpp \ diff --git a/src/class_factory.cpp b/src/class_factory.cpp index 8bff538..653111e 100644 --- a/src/class_factory.cpp +++ b/src/class_factory.cpp @@ -34,7 +34,9 @@ # include "win32/win32_iskeyspressed.h" # include "win32/systray.h" #else +#ifndef CONFIG_NANONOTE # include "x11_iskeyspressed.hpp" +#endif # include "docklet.h" #endif @@ -51,8 +53,10 @@ void *PlatformFactory::create_class_by_name(const std::string& name, void *param return new inifile(get_user_config_dir()+ G_DIR_SEPARATOR_S "stardict.cfg"); #endif } else if (name=="hotkeys") { -#ifdef _WIN32 +#if defined(_WIN32) return new win32_hotkeys(); +#elif defined(CONFIG_NANONOTE) + return NULL; #else return new x11_hotkeys(GTK_WINDOW(param)); #endif diff --git a/src/conf.cpp b/src/conf.cpp index 2d0f89d..9f5e308 100644 --- a/src/conf.cpp +++ b/src/conf.cpp @@ -33,6 +33,10 @@ const int DEFAULT_WINDOW_WIDTH=238; const int DEFAULT_WINDOW_HEIGHT=279; const int DEFAULT_HPANED_POS=79; +#elif defined(CONFIG_NANONOTE) +const int DEFAULT_WINDOW_WIDTH=320; +const int DEFAULT_WINDOW_HEIGHT=240; +const int DEFAULT_HPANED_POS=79; #else const int DEFAULT_WINDOW_WIDTH=463; const int DEFAULT_WINDOW_HEIGHT=321; diff --git a/src/desktop.cpp b/src/desktop.cpp index 9d08caf..4f95bcb 100644 --- a/src/desktop.cpp +++ b/src/desktop.cpp @@ -37,7 +37,7 @@ #include "desktop.hpp" -#if defined(CONFIG_GTK) || defined(CONFIG_GPE) || defined(CONFIG_MAEMO) +#if defined(CONFIG_GTK) || defined(CONFIG_GPE) || defined(CONFIG_MAEMO) || defined(CONFIG_NANONOTE) static void spawn_command(const gchar *exe, const gchar *arg) { gchar *qarg = g_shell_quote(arg); diff --git a/src/mainwin.cpp b/src/mainwin.cpp index 7005f7b..0b77b0c 100644 --- a/src/mainwin.cpp +++ b/src/mainwin.cpp @@ -129,10 +129,12 @@ void TopWin::Create(GtkWidget *vbox) gtk_box_pack_start(GTK_BOX(hbox),button,false,false,0); gtk_widget_set_tooltip_text(button,_("Go Back - Right button: history (Alt+Left)")); +#ifndef CONFIG_NANONOTE GtkWidget *label; label = gtk_label_new("\t"); gtk_widget_show(label); gtk_box_pack_start(GTK_BOX(hbox),label,false,false,0); +#endif button=gtk_button_new(); gtk_container_add(GTK_CONTAINER(button),gtk_image_new_from_stock(GTK_STOCK_HOME,GTK_ICON_SIZE_BUTTON)); @@ -1249,6 +1251,7 @@ void LeftWin::Create(GtkWidget *hbox, bool has_treedict) gtk_widget_show(vbox); gtk_box_pack_start(GTK_BOX(hbox),vbox, false, false, 0); +#ifndef CONFIG_NANONOTE GtkWidget *wazard_button = gtk_radio_button_new(NULL); GTK_WIDGET_UNSET_FLAGS (wazard_button, GTK_CAN_FOCUS); gtk_toggle_button_set_mode(GTK_TOGGLE_BUTTON(wazard_button), false); @@ -1323,6 +1326,7 @@ void LeftWin::Create(GtkWidget *hbox, bool has_treedict) g_signal_connect(G_OBJECT(button),"enter_notify_event", G_CALLBACK(stardict_on_enter_notify), NULL); gtk_box_pack_end(GTK_BOX(vbox),button,false,false,0); gtk_widget_set_tooltip_text(button,_("Previous word (Alt+Up)")); +#endif } void LeftWin::on_wazard_button_toggled(GtkToggleButton *button, LeftWin *oLeftWin) @@ -1807,7 +1811,10 @@ void TextWin::ShowTips() query_result = TEXT_WIN_TIPS; view->set_text( _(" Welcome to StarDict!\n\n" - " Press Ctrl+Q to quit. Press Alt+Z to iconify the window or Alt+X to hide the window.\n" + " Press Ctrl+Q to quit. \n" +#ifndef CONFIG_NANONOTE + " Press Alt+Z to iconify the window or Alt+X to hide the window.\n" +#endif " Press Alt+C or ESC to clear the input entry's text.\n" " Press Space key to move focus to the input entry.\n" " If the query word was not found, you can press Tab key to select the first word in the word list.\n" @@ -2665,6 +2672,7 @@ void MidWin::Create(GtkWidget *vbox) notebook = gtk_notebook_new(); gtk_widget_show(notebook); + gtk_widget_set_size_request(GTK_WIDGET(notebook), 50, 20); gtk_notebook_set_show_tabs(GTK_NOTEBOOK(notebook), false); gtk_notebook_set_show_border(GTK_NOTEBOOK(notebook),false); diff --git a/src/stardict.cpp b/src/stardict.cpp index 326ca4a..2d4acb8 100644 --- a/src/stardict.cpp +++ b/src/stardict.cpp @@ -214,7 +214,9 @@ void AppCore::do_send_http_request(const char* shost, const char* sfile, get_htt void AppCore::set_news(const char *news, const char *links) { +#ifndef CONFIG_NANONOTE gpAppFrame->oBottomWin.set_news(news, links); +#endif } void AppCore::show_netdict_resp(NetDictResponse *resp, bool ismainwin) @@ -350,12 +352,13 @@ void AppCore::Create(gchar *queryword) gtk_container_add(GTK_CONTAINER(window),vbox); oTopWin.Create(vbox); oMidWin.Create(vbox); + oFloatWin.Create(); + bool scan=conf->get_bool_at("dictionary/scan_selection"); +#ifndef CONFIG_NANONOTE oBottomWin.Create(vbox); unlock_keys.reset(static_cast(PlatformFactory::create_class_by_name("hotkeys", GTK_WINDOW(window)))); unlock_keys->set_comb(combnum2str(conf->get_int_at("dictionary/scan_modifier_key"))); - oFloatWin.Create(); - bool scan=conf->get_bool_at("dictionary/scan_selection"); oDockLet.reset(PlatformFactory::create_tray_icon(window, scan, oAppSkin)); oDockLet->on_quit_.connect(sigc::mem_fun(this, &AppCore::Quit)); @@ -365,6 +368,7 @@ void AppCore::Create(gchar *queryword) sigc::mem_fun(this, &AppCore::on_maximize)); oDockLet->on_middle_btn_click_.connect( sigc::mem_fun(this, &AppCore::on_middle_button_click)); +#endif // CONFIG_NANONOTE oSelection.Init(); #ifdef _WIN32 oClipboard.Init(); @@ -393,7 +397,9 @@ void AppCore::Create(gchar *queryword) //NOTICE: when docklet embedded failed,it should always show the window,but,how to detect the failure? // As stardict is FOR GNOME,so i don't want to consider the case that haven't the Notification area applet. if (!hide_option && (queryword || !hide)) { +#ifndef CONFIG_NANONOTE oDockLet->hide_state(); +#endif gtk_widget_show(window); } else { // This may be needed, so gtk_window_get_screen() in gtk_iskeyspressed.cpp can always work. @@ -423,8 +429,12 @@ void AppCore::Create(gchar *queryword) gboolean AppCore::on_delete_event(GtkWidget * window, GdkEvent *event , AppCore *app) { +#ifndef CONFIG_NANONOTE app->oDockLet->minimize_to_tray(); - return TRUE; +#endif + g_print("Quitting..\n"); + gtk_main_quit(); + return FALSE; } gboolean AppCore::on_window_state_event(GtkWidget *window, @@ -432,12 +442,16 @@ gboolean AppCore::on_window_state_event(GtkWidget *window, { switch (event->changed_mask) { case GDK_WINDOW_STATE_WITHDRAWN: +#ifndef CONFIG_NANONOTE if (conf->get_bool_at("dictionary/scan_selection")) app->oDockLet->set_scan_mode(true); else app->oDockLet->set_scan_mode(false); +#endif if (!(event->new_window_state & GDK_WINDOW_STATE_WITHDRAWN)) { +#ifndef CONFIG_NANONOTE app->oDockLet->hide_state(); +#endif if (app->oTopWin.get_text()[0]) gtk_widget_grab_focus(app->oMidWin.oTextWin.view->widget()); } @@ -475,7 +489,9 @@ gboolean AppCore::vKeyPressReleaseCallback(GtkWidget * window, GdkEventKey *even } else if ((event->keyval==GDK_x || event->keyval==GDK_X) && only_mod1_pressed) { if (event->type==GDK_KEY_PRESS) { +#ifndef CONFIG_NANONOTE oAppCore->oDockLet->minimize_to_tray(); +#endif } } else if ((event->keyval==GDK_z || event->keyval==GDK_Z) && only_mod1_pressed) { @@ -2005,10 +2021,20 @@ private: void AppCore::PopupPrefsDlg() { + static std::list posb_combs; + + if (posb_combs.empty()) { + posb_combs.push_back("Win"); + posb_combs.push_back("Shift"); + posb_combs.push_back("Alt"); + posb_combs.push_back("Ctrl"); + posb_combs.push_back("Ctrl+Alt"); + } + if (!prefs_dlg) { prefs_dlg = new PrefsDlg(GTK_WINDOW(window), - get_impl(oAppSkin.icon), - unlock_keys->possible_combs()); + get_impl(oAppSkin.icon), + posb_combs); bool enbcol = conf->get_bool_at("dictionary/enable_collation"); int colf = @@ -2105,16 +2131,16 @@ void AppCore::End() #endif oFloatWin.End(); - oDockLet.reset(0); - if (dict_manage_dlg) dict_manage_dlg->Close(); if (prefs_dlg) prefs_dlg->Close(); // After user open the preferences dialog, then choose quit in the notification icon, this dialog can be closed. oTopWin.Destroy(); oMidWin.oIndexWin.oListWin.Destroy(); +#ifndef CONFIG_NANONOTE + oDockLet.reset(0); oBottomWin.Destroy(); - +#endif gtk_widget_destroy(window); } @@ -2153,17 +2179,17 @@ void AppCore::Quit() if (!conf->get_bool_at("main_window/maximized")) { gint width, height; gtk_window_get_size(GTK_WINDOW(window), &width, &height); - conf->set_int_at("main_window/window_width", width); - conf->set_int_at("main_window/window_height", height); + conf->set_int_at("main_window/window_width", width); + conf->set_int_at("main_window/window_height", height); } gint pos = gtk_paned_get_position(GTK_PANED(oMidWin.hpaned)); - conf->set_int_at("main_window/hpaned_pos", pos); + conf->set_int_at("main_window/hpaned_pos", pos); if (conf->get_bool_at("floating_window/lock")) { gint x, y; gtk_window_get_position(GTK_WINDOW(oFloatWin.FloatWindow), &x, &y); - conf->set_int_at("floating_window/lock_x", x); - conf->set_int_at("floating_window/lock_y", y); + conf->set_int_at("floating_window/lock_x", x); + conf->set_int_at("floating_window/lock_y", y); } End(); @@ -2171,9 +2197,11 @@ void AppCore::Quit() #ifdef CONFIG_GNOME bonobo_object_unref (stardict_app_server); #endif - unlock_keys.reset(0); - conf.reset(0); - gtk_main_quit(); +#ifndef CONFIG_NANONOTE + unlock_keys.reset(0); +#endif + conf.reset(0); + gtk_main_quit(); } void AppCore::on_main_win_hide_list_changed(const baseconfval* hideval) @@ -2198,12 +2226,13 @@ void AppCore::on_dict_scan_select_changed(const baseconfval* scanval) bool scan = static_cast *>(scanval)->val_; gtk_widget_set_sensitive(oFloatWin.StopButton, scan); +#ifndef CONFIG_NANONOTE if (scan != gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(oBottomWin.ScanSelectionCheckButton))) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(oBottomWin.ScanSelectionCheckButton), scan); - oDockLet->set_scan_mode(scan); if (GTK_WIDGET_VISIBLE(window)) oDockLet->hide_state(); +#endif if (scan) { bool lock=conf->get_bool_at("floating_window/lock"); if (lock && !oFloatWin.QueryingWord.empty()) @@ -2263,8 +2292,10 @@ void AppCore::on_floatwin_lock_y_changed(const baseconfval* lock_y_val) void AppCore::on_scan_modifier_key_changed(const baseconfval* keyval) { +#ifndef CONFIG_NANONOTE int key = static_cast *>(keyval)->val_; unlock_keys->set_comb(combnum2str(key)); +#endif } gchar* GetPureEnglishAlpha(gchar *str) @@ -2439,7 +2470,7 @@ int main(int argc,char **argv) g_warning("Cannot create directory %s.", userdir.c_str()); } g_thread_init (NULL); -#if defined(_WIN32) || defined(CONFIG_GTK) || defined(CONFIG_MAEMO) +#if defined(_WIN32) || defined(CONFIG_GTK) || defined(CONFIG_MAEMO) || defined(CONFIG_NANONOTE) gtk_set_locale(); gtk_init(&argc, &argv); #endif