OpenWrt packages
Sign in or create your account | Project List | Help
OpenWrt packages Git Source Tree
Root/
1 | add CONFIG_NANONOTE support |
2 | |
3 | From: Xiangfu Liu <xiangfu@sharism.cc> |
4 | |
5 | |
6 | --- |
7 | |
8 | configure.in | 36 +++++++++++++++++--------- |
9 | src/Makefile.am | 6 ++++ |
10 | src/class_factory.cpp | 6 ++++ |
11 | src/conf.cpp | 4 +++ |
12 | src/desktop.cpp | 2 + |
13 | src/mainwin.cpp | 8 +++++- |
14 | src/stardict.cpp | 67 ++++++++++++++++++++++++++++++++++++------------- |
15 | 7 files changed, 94 insertions(+), 35 deletions(-) |
16 | |
17 | |
18 | diff --git a/configure.in b/configure.in |
19 | index 83d3d95..4b15e43 100644 |
20 | --- a/configure.in |
21 | +++ b/configure.in |
22 | @@ -296,14 +296,18 @@ dnl ================================================================ |
23 | AC_ARG_ENABLE(gnome-support, AC_HELP_STRING([--disable-gnome-support], [Disable gnome support])) |
24 | AC_ARG_ENABLE(gpe-support, AC_HELP_STRING([--enable-gpe-support], [Enable gpe support])) |
25 | AC_ARG_ENABLE(maemo-support, AC_HELP_STRING([--enable-maemo-support], [Enable maemo support])) |
26 | +AC_ARG_ENABLE(nanonote-support, AC_HELP_STRING([--enable-nanonote-support], [Enable Qi Hardware NanoNote support])) |
27 | AM_CONDITIONAL(GNOME_SUPPORT, test "x${enable_gpe_support}" != "xyes" && test "x${enable_maemo_support}" != "xyes" && test "x${enable_gnome_support}" != "xno") |
28 | AM_CONDITIONAL(GPE_SUPPORT, test "x${enable_gpe_support}" = "xyes") |
29 | AM_CONDITIONAL(MAEMO_SUPPORT, test "x${enable_maemo_support}" = "xyes") |
30 | +AM_CONDITIONAL(NANONOTE_SUPPORT, test "x${enable_nanonote_support}" = "xyes") |
31 | |
32 | if test "x${enable_gpe_support}" = "xyes" ; then |
33 | DEP_MODULES="gtk+-2.0 >= 2.12 glib-2.0 >= 2.14 gthread-2.0 libgpewidget >= 0.109" |
34 | elif test "x${enable_maemo_support}" = "xyes" ; then |
35 | DEP_MODULES="gtk+-2.0 >= 2.12 gthread-2.0 gconf-2.0 >= 2.6 hildon-libs >= 0.12" |
36 | +elif test "x${enable_nanonote_support}" = "xyes" ; then |
37 | + DEP_MODULES="gtk+-2.0 >= 2.12 gthread-2.0 gconf-2.0 >= 2.6" |
38 | elif test "x${enable_gnome_support}" = "xno" ; then |
39 | DEP_MODULES="gtk+-2.0 >= 2.12 gthread-2.0" |
40 | else |
41 | @@ -329,6 +333,11 @@ elif test "x${enable_maemo_support}" = "xyes" ; then |
42 | fi |
43 | AM_GCONF_SOURCE_2 |
44 | AM_CONDITIONAL(SCHEMAS_INSTALL, test x$schemas_install = xtrue) |
45 | +elif test "x${enable_nanonote_support}" = "xyes" ; then |
46 | + echo "Enable Qi Hardware NanoNote suppport"; |
47 | + AC_DEFINE([CONFIG_NANONOTE],[], [Compile with nanonote support]) |
48 | + AM_CONDITIONAL(SCHEMAS_INSTALL, test "x${enable_nanonote_support}" != "xyes") |
49 | + AM_CONDITIONAL(GCONF_SCHEMAS_INSTALL, test "x${enable_nanonote_support}" != "xyes") |
50 | elif test "x${enable_gnome_support}" = "xno" ; then |
51 | echo "Disable gnome support"; |
52 | AC_DEFINE([CONFIG_GTK],[], [Compile without gnome support]) |
53 | @@ -414,21 +423,21 @@ dnl ========================================================================== |
54 | |
55 | # Checks for header files. need by Solaris. |
56 | AC_PATH_XTRA |
57 | -if test -n "$X_CFLAGS"; then |
58 | -CPPFLAGS="$CPPFLAGS $X_CFLAGS" |
59 | -fi |
60 | -if test -n "$X_LIBS"; then |
61 | -LDFLAGS="$LDFLAGS $X_LIBS" |
62 | -fi |
63 | -if test -n "$X_PRE_LIBS"; then |
64 | -LDFLAGS="$LDFLAGS $X_PRE_LIBS" |
65 | -fi |
66 | -if test -n "$X_EXTRA_LIBS"; then |
67 | -LDFLAGS="$LDFLAGS $X_EXTRA_LIBS" |
68 | -fi |
69 | +#if test -n "$X_CFLAGS"; then |
70 | +#CPPFLAGS="$CPPFLAGS $X_CFLAGS" |
71 | +#fi |
72 | +#if test -n "$X_LIBS"; then |
73 | +#LDFLAGS="$LDFLAGS $X_LIBS" |
74 | +#fi |
75 | +#if test -n "$X_PRE_LIBS"; then |
76 | +#LDFLAGS="$LDFLAGS $X_PRE_LIBS" |
77 | +#fi |
78 | +#if test -n "$X_EXTRA_LIBS"; then |
79 | +#LDFLAGS="$LDFLAGS $X_EXTRA_LIBS" |
80 | +#fi |
81 | |
82 | # Checks for libraries. |
83 | -AC_CHECK_LIB([X11], [main], , [AC_MSG_ERROR([X11 lib not found])]) |
84 | +#AC_CHECK_LIB([X11], [main], , [AC_MSG_ERROR([X11 lib not found])]) |
85 | |
86 | AC_SUBST(STARDICT_LIBS) |
87 | AC_SUBST(STARDICT_CFLAGS) |
88 | @@ -494,3 +503,4 @@ echo " |
89 | Type \"make\" to compile StarDict. |
90 | |
91 | " |
92 | + |
93 | diff --git a/src/Makefile.am b/src/Makefile.am |
94 | index bca4861..1499775 100644 |
95 | --- a/src/Makefile.am |
96 | +++ b/src/Makefile.am |
97 | @@ -34,9 +34,13 @@ CONFIG_FILE_MODULE = gconf_file.cpp gconf_file.hpp |
98 | else |
99 | CONFIG_FILE_MODULE = inifile.cpp inifile.hpp |
100 | endif |
101 | +if NANONOTE_SUPPORT |
102 | +X11_ISKEYSPRESSED_FILE_MODULE = |
103 | +endif |
104 | else |
105 | CONFIG_FILE_MODULE = gconf_file.cpp gconf_file.hpp |
106 | IDL_FILE = GNOME_Stardict.idl |
107 | +X11_ISKEYSPRESSED_FILE_MODULE = x11_iskeyspressed.cpp x11_iskeyspressed.hpp |
108 | |
109 | IDL_SOURCES = \ |
110 | GNOME_Stardict-stubs.c \ |
111 | @@ -73,7 +77,7 @@ stardict_SOURCES = \ |
112 | class_factory.cpp class_factory.hpp \ |
113 | config_file.hpp \ |
114 | $(CONFIG_FILE_MODULE) \ |
115 | - x11_iskeyspressed.cpp x11_iskeyspressed.hpp \ |
116 | + $(X11_ISKEYSPRESSED_FILE_MODULE) \ |
117 | gtk_iskeyspressed.cpp gtk_iskeyspressed.hpp \ |
118 | progresswin.cpp progresswin.hpp \ |
119 | tray.cpp tray.hpp \ |
120 | diff --git a/src/class_factory.cpp b/src/class_factory.cpp |
121 | index 8bff538..653111e 100644 |
122 | --- a/src/class_factory.cpp |
123 | +++ b/src/class_factory.cpp |
124 | @@ -34,7 +34,9 @@ |
125 | # include "win32/win32_iskeyspressed.h" |
126 | # include "win32/systray.h" |
127 | #else |
128 | +#ifndef CONFIG_NANONOTE |
129 | # include "x11_iskeyspressed.hpp" |
130 | +#endif |
131 | # include "docklet.h" |
132 | #endif |
133 | |
134 | @@ -51,8 +53,10 @@ void *PlatformFactory::create_class_by_name(const std::string& name, void *param |
135 | return new inifile(get_user_config_dir()+ G_DIR_SEPARATOR_S "stardict.cfg"); |
136 | #endif |
137 | } else if (name=="hotkeys") { |
138 | -#ifdef _WIN32 |
139 | +#if defined(_WIN32) |
140 | return new win32_hotkeys(); |
141 | +#elif defined(CONFIG_NANONOTE) |
142 | + return NULL; |
143 | #else |
144 | return new x11_hotkeys(GTK_WINDOW(param)); |
145 | #endif |
146 | diff --git a/src/conf.cpp b/src/conf.cpp |
147 | index 2d0f89d..9f5e308 100644 |
148 | --- a/src/conf.cpp |
149 | +++ b/src/conf.cpp |
150 | @@ -33,6 +33,10 @@ |
151 | const int DEFAULT_WINDOW_WIDTH=238; |
152 | const int DEFAULT_WINDOW_HEIGHT=279; |
153 | const int DEFAULT_HPANED_POS=79; |
154 | +#elif defined(CONFIG_NANONOTE) |
155 | +const int DEFAULT_WINDOW_WIDTH=320; |
156 | +const int DEFAULT_WINDOW_HEIGHT=240; |
157 | +const int DEFAULT_HPANED_POS=79; |
158 | #else |
159 | const int DEFAULT_WINDOW_WIDTH=463; |
160 | const int DEFAULT_WINDOW_HEIGHT=321; |
161 | diff --git a/src/desktop.cpp b/src/desktop.cpp |
162 | index 9d08caf..4f95bcb 100644 |
163 | --- a/src/desktop.cpp |
164 | +++ b/src/desktop.cpp |
165 | @@ -37,7 +37,7 @@ |
166 | |
167 | #include "desktop.hpp" |
168 | |
169 | -#if defined(CONFIG_GTK) || defined(CONFIG_GPE) || defined(CONFIG_MAEMO) |
170 | +#if defined(CONFIG_GTK) || defined(CONFIG_GPE) || defined(CONFIG_MAEMO) || defined(CONFIG_NANONOTE) |
171 | static void spawn_command(const gchar *exe, const gchar *arg) |
172 | { |
173 | gchar *qarg = g_shell_quote(arg); |
174 | diff --git a/src/mainwin.cpp b/src/mainwin.cpp |
175 | index 7005f7b..f7dac0b 100644 |
176 | --- a/src/mainwin.cpp |
177 | +++ b/src/mainwin.cpp |
178 | @@ -129,10 +129,12 @@ void TopWin::Create(GtkWidget *vbox) |
179 | gtk_box_pack_start(GTK_BOX(hbox),button,false,false,0); |
180 | gtk_widget_set_tooltip_text(button,_("Go Back - Right button: history (Alt+Left)")); |
181 | |
182 | +#ifndef CONFIG_NANONOTE |
183 | GtkWidget *label; |
184 | label = gtk_label_new("\t"); |
185 | gtk_widget_show(label); |
186 | gtk_box_pack_start(GTK_BOX(hbox),label,false,false,0); |
187 | +#endif |
188 | |
189 | button=gtk_button_new(); |
190 | gtk_container_add(GTK_CONTAINER(button),gtk_image_new_from_stock(GTK_STOCK_HOME,GTK_ICON_SIZE_BUTTON)); |
191 | @@ -1807,7 +1809,10 @@ void TextWin::ShowTips() |
192 | query_result = TEXT_WIN_TIPS; |
193 | view->set_text( |
194 | _(" Welcome to StarDict!\n\n" |
195 | - " Press Ctrl+Q to quit. Press Alt+Z to iconify the window or Alt+X to hide the window.\n" |
196 | + " Press Ctrl+Q to quit. \n" |
197 | +#ifndef CONFIG_NANONOTE |
198 | + " Press Alt+Z to iconify the window or Alt+X to hide the window.\n" |
199 | +#endif |
200 | " Press Alt+C or ESC to clear the input entry's text.\n" |
201 | " Press Space key to move focus to the input entry.\n" |
202 | " If the query word was not found, you can press Tab key to select the first word in the word list.\n" |
203 | @@ -2665,6 +2670,7 @@ void MidWin::Create(GtkWidget *vbox) |
204 | |
205 | notebook = gtk_notebook_new(); |
206 | gtk_widget_show(notebook); |
207 | + gtk_widget_set_size_request(GTK_WIDGET(notebook), 50, 20); |
208 | gtk_notebook_set_show_tabs(GTK_NOTEBOOK(notebook), false); |
209 | gtk_notebook_set_show_border(GTK_NOTEBOOK(notebook),false); |
210 | |
211 | diff --git a/src/stardict.cpp b/src/stardict.cpp |
212 | index 326ca4a..2d4acb8 100644 |
213 | --- a/src/stardict.cpp |
214 | +++ b/src/stardict.cpp |
215 | @@ -214,7 +214,9 @@ void AppCore::do_send_http_request(const char* shost, const char* sfile, get_htt |
216 | |
217 | void AppCore::set_news(const char *news, const char *links) |
218 | { |
219 | +#ifndef CONFIG_NANONOTE |
220 | gpAppFrame->oBottomWin.set_news(news, links); |
221 | +#endif |
222 | } |
223 | |
224 | void AppCore::show_netdict_resp(NetDictResponse *resp, bool ismainwin) |
225 | @@ -350,12 +352,13 @@ void AppCore::Create(gchar *queryword) |
226 | gtk_container_add(GTK_CONTAINER(window),vbox); |
227 | oTopWin.Create(vbox); |
228 | oMidWin.Create(vbox); |
229 | + oFloatWin.Create(); |
230 | + bool scan=conf->get_bool_at("dictionary/scan_selection"); |
231 | +#ifndef CONFIG_NANONOTE |
232 | oBottomWin.Create(vbox); |
233 | unlock_keys.reset(static_cast<hotkeys *>(PlatformFactory::create_class_by_name("hotkeys", |
234 | GTK_WINDOW(window)))); |
235 | unlock_keys->set_comb(combnum2str(conf->get_int_at("dictionary/scan_modifier_key"))); |
236 | - oFloatWin.Create(); |
237 | - bool scan=conf->get_bool_at("dictionary/scan_selection"); |
238 | oDockLet.reset(PlatformFactory::create_tray_icon(window, scan, |
239 | oAppSkin)); |
240 | oDockLet->on_quit_.connect(sigc::mem_fun(this, &AppCore::Quit)); |
241 | @@ -365,6 +368,7 @@ void AppCore::Create(gchar *queryword) |
242 | sigc::mem_fun(this, &AppCore::on_maximize)); |
243 | oDockLet->on_middle_btn_click_.connect( |
244 | sigc::mem_fun(this, &AppCore::on_middle_button_click)); |
245 | +#endif // CONFIG_NANONOTE |
246 | oSelection.Init(); |
247 | #ifdef _WIN32 |
248 | oClipboard.Init(); |
249 | @@ -393,7 +397,9 @@ void AppCore::Create(gchar *queryword) |
250 | //NOTICE: when docklet embedded failed,it should always show the window,but,how to detect the failure? |
251 | // As stardict is FOR GNOME,so i don't want to consider the case that haven't the Notification area applet. |
252 | if (!hide_option && (queryword || !hide)) { |
253 | +#ifndef CONFIG_NANONOTE |
254 | oDockLet->hide_state(); |
255 | +#endif |
256 | gtk_widget_show(window); |
257 | } else { |
258 | // This may be needed, so gtk_window_get_screen() in gtk_iskeyspressed.cpp can always work. |
259 | @@ -423,8 +429,12 @@ void AppCore::Create(gchar *queryword) |
260 | |
261 | gboolean AppCore::on_delete_event(GtkWidget * window, GdkEvent *event , AppCore *app) |
262 | { |
263 | +#ifndef CONFIG_NANONOTE |
264 | app->oDockLet->minimize_to_tray(); |
265 | - return TRUE; |
266 | +#endif |
267 | + g_print("Quitting..\n"); |
268 | + gtk_main_quit(); |
269 | + return FALSE; |
270 | } |
271 | |
272 | gboolean AppCore::on_window_state_event(GtkWidget *window, |
273 | @@ -432,12 +442,16 @@ gboolean AppCore::on_window_state_event(GtkWidget *window, |
274 | { |
275 | switch (event->changed_mask) { |
276 | case GDK_WINDOW_STATE_WITHDRAWN: |
277 | +#ifndef CONFIG_NANONOTE |
278 | if (conf->get_bool_at("dictionary/scan_selection")) |
279 | app->oDockLet->set_scan_mode(true); |
280 | else |
281 | app->oDockLet->set_scan_mode(false); |
282 | +#endif |
283 | if (!(event->new_window_state & GDK_WINDOW_STATE_WITHDRAWN)) { |
284 | +#ifndef CONFIG_NANONOTE |
285 | app->oDockLet->hide_state(); |
286 | +#endif |
287 | if (app->oTopWin.get_text()[0]) |
288 | gtk_widget_grab_focus(app->oMidWin.oTextWin.view->widget()); |
289 | } |
290 | @@ -475,7 +489,9 @@ gboolean AppCore::vKeyPressReleaseCallback(GtkWidget * window, GdkEventKey *even |
291 | } |
292 | else if ((event->keyval==GDK_x || event->keyval==GDK_X) && only_mod1_pressed) { |
293 | if (event->type==GDK_KEY_PRESS) { |
294 | +#ifndef CONFIG_NANONOTE |
295 | oAppCore->oDockLet->minimize_to_tray(); |
296 | +#endif |
297 | } |
298 | } |
299 | else if ((event->keyval==GDK_z || event->keyval==GDK_Z) && only_mod1_pressed) { |
300 | @@ -2005,10 +2021,20 @@ private: |
301 | |
302 | void AppCore::PopupPrefsDlg() |
303 | { |
304 | + static std::list<std::string> posb_combs; |
305 | + |
306 | + if (posb_combs.empty()) { |
307 | + posb_combs.push_back("Win"); |
308 | + posb_combs.push_back("Shift"); |
309 | + posb_combs.push_back("Alt"); |
310 | + posb_combs.push_back("Ctrl"); |
311 | + posb_combs.push_back("Ctrl+Alt"); |
312 | + } |
313 | + |
314 | if (!prefs_dlg) { |
315 | prefs_dlg = new PrefsDlg(GTK_WINDOW(window), |
316 | - get_impl(oAppSkin.icon), |
317 | - unlock_keys->possible_combs()); |
318 | + get_impl(oAppSkin.icon), |
319 | + posb_combs); |
320 | bool enbcol = |
321 | conf->get_bool_at("dictionary/enable_collation"); |
322 | int colf = |
323 | @@ -2105,16 +2131,16 @@ void AppCore::End() |
324 | #endif |
325 | oFloatWin.End(); |
326 | |
327 | - oDockLet.reset(0); |
328 | - |
329 | if (dict_manage_dlg) |
330 | dict_manage_dlg->Close(); |
331 | if (prefs_dlg) |
332 | prefs_dlg->Close(); // After user open the preferences dialog, then choose quit in the notification icon, this dialog can be closed. |
333 | oTopWin.Destroy(); |
334 | oMidWin.oIndexWin.oListWin.Destroy(); |
335 | +#ifndef CONFIG_NANONOTE |
336 | + oDockLet.reset(0); |
337 | oBottomWin.Destroy(); |
338 | - |
339 | +#endif |
340 | gtk_widget_destroy(window); |
341 | } |
342 | |
343 | @@ -2153,17 +2179,17 @@ void AppCore::Quit() |
344 | if (!conf->get_bool_at("main_window/maximized")) { |
345 | gint width, height; |
346 | gtk_window_get_size(GTK_WINDOW(window), &width, &height); |
347 | - conf->set_int_at("main_window/window_width", width); |
348 | - conf->set_int_at("main_window/window_height", height); |
349 | + conf->set_int_at("main_window/window_width", width); |
350 | + conf->set_int_at("main_window/window_height", height); |
351 | } |
352 | gint pos = gtk_paned_get_position(GTK_PANED(oMidWin.hpaned)); |
353 | - conf->set_int_at("main_window/hpaned_pos", pos); |
354 | + conf->set_int_at("main_window/hpaned_pos", pos); |
355 | |
356 | if (conf->get_bool_at("floating_window/lock")) { |
357 | gint x, y; |
358 | gtk_window_get_position(GTK_WINDOW(oFloatWin.FloatWindow), &x, &y); |
359 | - conf->set_int_at("floating_window/lock_x", x); |
360 | - conf->set_int_at("floating_window/lock_y", y); |
361 | + conf->set_int_at("floating_window/lock_x", x); |
362 | + conf->set_int_at("floating_window/lock_y", y); |
363 | } |
364 | |
365 | End(); |
366 | @@ -2171,9 +2197,11 @@ void AppCore::Quit() |
367 | #ifdef CONFIG_GNOME |
368 | bonobo_object_unref (stardict_app_server); |
369 | #endif |
370 | - unlock_keys.reset(0); |
371 | - conf.reset(0); |
372 | - gtk_main_quit(); |
373 | +#ifndef CONFIG_NANONOTE |
374 | + unlock_keys.reset(0); |
375 | +#endif |
376 | + conf.reset(0); |
377 | + gtk_main_quit(); |
378 | } |
379 | |
380 | void AppCore::on_main_win_hide_list_changed(const baseconfval* hideval) |
381 | @@ -2198,12 +2226,13 @@ void AppCore::on_dict_scan_select_changed(const baseconfval* scanval) |
382 | bool scan = static_cast<const confval<bool> *>(scanval)->val_; |
383 | |
384 | gtk_widget_set_sensitive(oFloatWin.StopButton, scan); |
385 | +#ifndef CONFIG_NANONOTE |
386 | if (scan != gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(oBottomWin.ScanSelectionCheckButton))) |
387 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(oBottomWin.ScanSelectionCheckButton), scan); |
388 | - |
389 | oDockLet->set_scan_mode(scan); |
390 | if (GTK_WIDGET_VISIBLE(window)) |
391 | oDockLet->hide_state(); |
392 | +#endif |
393 | if (scan) { |
394 | bool lock=conf->get_bool_at("floating_window/lock"); |
395 | if (lock && !oFloatWin.QueryingWord.empty()) |
396 | @@ -2263,8 +2292,10 @@ void AppCore::on_floatwin_lock_y_changed(const baseconfval* lock_y_val) |
397 | |
398 | void AppCore::on_scan_modifier_key_changed(const baseconfval* keyval) |
399 | { |
400 | +#ifndef CONFIG_NANONOTE |
401 | int key = static_cast<const confval<int> *>(keyval)->val_; |
402 | unlock_keys->set_comb(combnum2str(key)); |
403 | +#endif |
404 | } |
405 | |
406 | gchar* GetPureEnglishAlpha(gchar *str) |
407 | @@ -2439,7 +2470,7 @@ int main(int argc,char **argv) |
408 | g_warning("Cannot create directory %s.", userdir.c_str()); |
409 | } |
410 | g_thread_init (NULL); |
411 | -#if defined(_WIN32) || defined(CONFIG_GTK) || defined(CONFIG_MAEMO) |
412 | +#if defined(_WIN32) || defined(CONFIG_GTK) || defined(CONFIG_MAEMO) || defined(CONFIG_NANONOTE) |
413 | gtk_set_locale(); |
414 | gtk_init(&argc, &argv); |
415 | #endif |
416 |