1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
|
add CONFIG_NANONOTE support
From: Xiangfu Liu <xiangfu@sharism.cc>
---
configure.in | 36 +++++++++++++++++---------
src/Makefile.am | 6 ++++
src/class_factory.cpp | 6 ++++
src/conf.cpp | 4 +++
src/desktop.cpp | 2 +
src/mainwin.cpp | 8 +++++-
src/stardict.cpp | 67 ++++++++++++++++++++++++++++++++++++-------------
7 files changed, 94 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..f7dac0b 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));
@@ -1807,7 +1809,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 +2670,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<hotkeys *>(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<std::string> 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<const confval<bool> *>(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<const confval<int> *>(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
|