stardict/patches/020-add-nanonote-support.patch |
5 | 5 | |
6 | 6 | --- |
7 | 7 | |
8 | | configure.in | 36 +++++++++++++++++++++++------------- |
9 | | src/Makefile.am | 6 +++++- |
10 | | src/class_factory.cpp | 4 ++++ |
11 | | src/conf.cpp | 4 ++++ |
12 | | src/desktop.cpp | 2 +- |
13 | | src/mainwin.cpp | 7 +++++++ |
14 | | src/stardict.cpp | 38 ++++++++++++++++++++++++-------------- |
15 | | 7 files changed, 68 insertions(+), 29 deletions(-) |
| 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 | 10 +++++++ |
| 14 | src/stardict.cpp | 67 ++++++++++++++++++++++++++++++++++++------------- |
| 15 | 7 files changed, 96 insertions(+), 35 deletions(-) |
16 | 16 | |
17 | 17 | |
18 | 18 | diff --git a/configure.in b/configure.in |
... | ... | |
118 | 118 | progresswin.cpp progresswin.hpp \ |
119 | 119 | tray.cpp tray.hpp \ |
120 | 120 | diff --git a/src/class_factory.cpp b/src/class_factory.cpp |
121 | | index 8bff538..9285428 100644 |
| 121 | index 8bff538..653111e 100644 |
122 | 122 | --- a/src/class_factory.cpp |
123 | 123 | +++ b/src/class_factory.cpp |
124 | 124 | @@ -34,7 +34,9 @@ |
... | ... | |
131 | 131 | # include "docklet.h" |
132 | 132 | #endif |
133 | 133 | |
134 | | @@ -53,6 +55,8 @@ void *PlatformFactory::create_class_by_name(const std::string& name, void *param |
| 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 |
135 | 137 | } else if (name=="hotkeys") { |
136 | | #ifdef _WIN32 |
| 138 | -#ifdef _WIN32 |
| 139 | +#if defined(_WIN32) |
137 | 140 | return new win32_hotkeys(); |
138 | 141 | +#elif defined(CONFIG_NANONOTE) |
139 | 142 | + return NULL; |
... | ... | |
169 | 172 | { |
170 | 173 | gchar *qarg = g_shell_quote(arg); |
171 | 174 | diff --git a/src/mainwin.cpp b/src/mainwin.cpp |
172 | | index 7005f7b..15e6543 100644 |
| 175 | index 7005f7b..0b77b0c 100644 |
173 | 176 | --- a/src/mainwin.cpp |
174 | 177 | +++ b/src/mainwin.cpp |
175 | 178 | @@ -129,10 +129,12 @@ void TopWin::Create(GtkWidget *vbox) |
... | ... | |
201 | 204 | } |
202 | 205 | |
203 | 206 | void LeftWin::on_wazard_button_toggled(GtkToggleButton *button, LeftWin *oLeftWin) |
204 | | @@ -2665,6 +2669,7 @@ void MidWin::Create(GtkWidget *vbox) |
| 207 | @@ -1807,7 +1811,10 @@ void TextWin::ShowTips() |
| 208 | query_result = TEXT_WIN_TIPS; |
| 209 | view->set_text( |
| 210 | _(" Welcome to StarDict!\n\n" |
| 211 | - " Press Ctrl+Q to quit. Press Alt+Z to iconify the window or Alt+X to hide the window.\n" |
| 212 | + " Press Ctrl+Q to quit. \n" |
| 213 | +#ifndef CONFIG_NANONOTE |
| 214 | + " Press Alt+Z to iconify the window or Alt+X to hide the window.\n" |
| 215 | +#endif |
| 216 | " Press Alt+C or ESC to clear the input entry's text.\n" |
| 217 | " Press Space key to move focus to the input entry.\n" |
| 218 | " If the query word was not found, you can press Tab key to select the first word in the word list.\n" |
| 219 | @@ -2665,6 +2672,7 @@ void MidWin::Create(GtkWidget *vbox) |
205 | 220 | |
206 | 221 | notebook = gtk_notebook_new(); |
207 | 222 | gtk_widget_show(notebook); |
... | ... | |
209 | 224 | gtk_notebook_set_show_tabs(GTK_NOTEBOOK(notebook), false); |
210 | 225 | gtk_notebook_set_show_border(GTK_NOTEBOOK(notebook),false); |
211 | 226 | |
212 | | @@ -2711,6 +2716,7 @@ void BottomWin::Destroy() |
| 227 | diff --git a/src/stardict.cpp b/src/stardict.cpp |
| 228 | index 326ca4a..2d4acb8 100644 |
| 229 | --- a/src/stardict.cpp |
| 230 | @@ -214,7 +214,9 @@ void AppCore::do_send_http_request(const char* shost, const char* sfile, get_htt |
213 | 231 | |
214 | | void BottomWin::Create(GtkWidget *vbox) |
| 232 | void AppCore::set_news(const char *news, const char *links) |
215 | 233 | { |
216 | 234 | +#ifndef CONFIG_NANONOTE |
217 | | GtkWidget *hbox = gtk_hbox_new(FALSE, 0); |
218 | | gtk_widget_show(hbox); |
219 | | #ifdef CONFIG_GPE |
220 | | @@ -2827,6 +2833,7 @@ void BottomWin::Create(GtkWidget *vbox) |
221 | | g_signal_connect(G_OBJECT(button),"enter_notify_event", G_CALLBACK(stardict_on_enter_notify), NULL); |
222 | | gtk_box_pack_end(GTK_BOX(hbox),button,false,false,0); |
223 | | gtk_widget_set_tooltip_text(button,_("Search an Internet dictionary - Right button: website list")); |
| 235 | gpAppFrame->oBottomWin.set_news(news, links); |
224 | 236 | +#endif |
225 | 237 | } |
226 | 238 | |
227 | | void BottomWin::on_link_eventbox_clicked(GtkWidget *widget, GdkEventButton *event, BottomWin *oBottomWin) |
228 | | diff --git a/src/stardict.cpp b/src/stardict.cpp |
229 | | index 326ca4a..8b8b8cf 100644 |
230 | | +++ b/src/stardict.cpp |
231 | | @@ -351,9 +351,9 @@ void AppCore::Create(gchar *queryword) |
| 239 | void AppCore::show_netdict_resp(NetDictResponse *resp, bool ismainwin) |
| 240 | @@ -350,12 +352,13 @@ void AppCore::Create(gchar *queryword) |
| 241 | gtk_container_add(GTK_CONTAINER(window),vbox); |
232 | 242 | oTopWin.Create(vbox); |
233 | 243 | oMidWin.Create(vbox); |
| 244 | + oFloatWin.Create(); |
| 245 | + bool scan=conf->get_bool_at("dictionary/scan_selection"); |
| 246 | +#ifndef CONFIG_NANONOTE |
234 | 247 | oBottomWin.Create(vbox); |
235 | | - unlock_keys.reset(static_cast<hotkeys *>(PlatformFactory::create_class_by_name("hotkeys", |
236 | | - GTK_WINDOW(window)))); |
237 | | - unlock_keys->set_comb(combnum2str(conf->get_int_at("dictionary/scan_modifier_key"))); |
238 | | + //unlock_keys.reset(static_cast<hotkeys *>(PlatformFactory::create_class_by_name("hotkeys", |
239 | | + // GTK_WINDOW(window)))); |
240 | | + //unlock_keys->set_comb(combnum2str(conf->get_int_at("dictionary/scan_modifier_key"))); |
241 | | oFloatWin.Create(); |
242 | | bool scan=conf->get_bool_at("dictionary/scan_selection"); |
| 248 | unlock_keys.reset(static_cast<hotkeys *>(PlatformFactory::create_class_by_name("hotkeys", |
| 249 | GTK_WINDOW(window)))); |
| 250 | unlock_keys->set_comb(combnum2str(conf->get_int_at("dictionary/scan_modifier_key"))); |
| 251 | - oFloatWin.Create(); |
| 252 | - bool scan=conf->get_bool_at("dictionary/scan_selection"); |
243 | 253 | oDockLet.reset(PlatformFactory::create_tray_icon(window, scan, |
244 | | @@ -2005,10 +2005,20 @@ private: |
| 254 | oAppSkin)); |
| 255 | oDockLet->on_quit_.connect(sigc::mem_fun(this, &AppCore::Quit)); |
| 256 | @@ -365,6 +368,7 @@ void AppCore::Create(gchar *queryword) |
| 257 | sigc::mem_fun(this, &AppCore::on_maximize)); |
| 258 | oDockLet->on_middle_btn_click_.connect( |
| 259 | sigc::mem_fun(this, &AppCore::on_middle_button_click)); |
| 260 | +#endif // CONFIG_NANONOTE |
| 261 | oSelection.Init(); |
| 262 | #ifdef _WIN32 |
| 263 | oClipboard.Init(); |
| 264 | @@ -393,7 +397,9 @@ void AppCore::Create(gchar *queryword) |
| 265 | //NOTICE: when docklet embedded failed,it should always show the window,but,how to detect the failure? |
| 266 | // As stardict is FOR GNOME,so i don't want to consider the case that haven't the Notification area applet. |
| 267 | if (!hide_option && (queryword || !hide)) { |
| 268 | +#ifndef CONFIG_NANONOTE |
| 269 | oDockLet->hide_state(); |
| 270 | +#endif |
| 271 | gtk_widget_show(window); |
| 272 | } else { |
| 273 | // This may be needed, so gtk_window_get_screen() in gtk_iskeyspressed.cpp can always work. |
| 274 | @@ -423,8 +429,12 @@ void AppCore::Create(gchar *queryword) |
| 275 | |
| 276 | gboolean AppCore::on_delete_event(GtkWidget * window, GdkEvent *event , AppCore *app) |
| 277 | { |
| 278 | +#ifndef CONFIG_NANONOTE |
| 279 | app->oDockLet->minimize_to_tray(); |
| 280 | - return TRUE; |
| 281 | +#endif |
| 282 | + g_print("Quitting..\n"); |
| 283 | + gtk_main_quit(); |
| 284 | + return FALSE; |
| 285 | } |
| 286 | |
| 287 | gboolean AppCore::on_window_state_event(GtkWidget *window, |
| 288 | @@ -432,12 +442,16 @@ gboolean AppCore::on_window_state_event(GtkWidget *window, |
| 289 | { |
| 290 | switch (event->changed_mask) { |
| 291 | case GDK_WINDOW_STATE_WITHDRAWN: |
| 292 | +#ifndef CONFIG_NANONOTE |
| 293 | if (conf->get_bool_at("dictionary/scan_selection")) |
| 294 | app->oDockLet->set_scan_mode(true); |
| 295 | else |
| 296 | app->oDockLet->set_scan_mode(false); |
| 297 | +#endif |
| 298 | if (!(event->new_window_state & GDK_WINDOW_STATE_WITHDRAWN)) { |
| 299 | +#ifndef CONFIG_NANONOTE |
| 300 | app->oDockLet->hide_state(); |
| 301 | +#endif |
| 302 | if (app->oTopWin.get_text()[0]) |
| 303 | gtk_widget_grab_focus(app->oMidWin.oTextWin.view->widget()); |
| 304 | } |
| 305 | @@ -475,7 +489,9 @@ gboolean AppCore::vKeyPressReleaseCallback(GtkWidget * window, GdkEventKey *even |
| 306 | } |
| 307 | else if ((event->keyval==GDK_x || event->keyval==GDK_X) && only_mod1_pressed) { |
| 308 | if (event->type==GDK_KEY_PRESS) { |
| 309 | +#ifndef CONFIG_NANONOTE |
| 310 | oAppCore->oDockLet->minimize_to_tray(); |
| 311 | +#endif |
| 312 | } |
| 313 | } |
| 314 | else if ((event->keyval==GDK_z || event->keyval==GDK_Z) && only_mod1_pressed) { |
| 315 | @@ -2005,10 +2021,20 @@ private: |
245 | 316 | |
246 | 317 | void AppCore::PopupPrefsDlg() |
247 | 318 | { |
... | ... | |
265 | 336 | bool enbcol = |
266 | 337 | conf->get_bool_at("dictionary/enable_collation"); |
267 | 338 | int colf = |
268 | | @@ -2153,17 +2163,17 @@ void AppCore::Quit() |
| 339 | @@ -2105,16 +2131,16 @@ void AppCore::End() |
| 340 | #endif |
| 341 | oFloatWin.End(); |
| 342 | |
| 343 | - oDockLet.reset(0); |
| 344 | - |
| 345 | if (dict_manage_dlg) |
| 346 | dict_manage_dlg->Close(); |
| 347 | if (prefs_dlg) |
| 348 | prefs_dlg->Close(); // After user open the preferences dialog, then choose quit in the notification icon, this dialog can be closed. |
| 349 | oTopWin.Destroy(); |
| 350 | oMidWin.oIndexWin.oListWin.Destroy(); |
| 351 | +#ifndef CONFIG_NANONOTE |
| 352 | + oDockLet.reset(0); |
| 353 | oBottomWin.Destroy(); |
| 354 | - |
| 355 | +#endif |
| 356 | gtk_widget_destroy(window); |
| 357 | } |
| 358 | |
| 359 | @@ -2153,17 +2179,17 @@ void AppCore::Quit() |
269 | 360 | if (!conf->get_bool_at("main_window/maximized")) { |
270 | 361 | gint width, height; |
271 | 362 | gtk_window_get_size(GTK_WINDOW(window), &width, &height); |
... | ... | |
288 | 379 | } |
289 | 380 | |
290 | 381 | End(); |
291 | | @@ -2171,9 +2181,9 @@ void AppCore::Quit() |
| 382 | @@ -2171,9 +2197,11 @@ void AppCore::Quit() |
292 | 383 | #ifdef CONFIG_GNOME |
293 | 384 | bonobo_object_unref (stardict_app_server); |
294 | 385 | #endif |
295 | 386 | - unlock_keys.reset(0); |
296 | 387 | - conf.reset(0); |
297 | 388 | - gtk_main_quit(); |
| 389 | +#ifndef CONFIG_NANONOTE |
298 | 390 | + unlock_keys.reset(0); |
| 391 | +#endif |
299 | 392 | + conf.reset(0); |
300 | 393 | + gtk_main_quit(); |
301 | 394 | } |
302 | 395 | |
303 | 396 | void AppCore::on_main_win_hide_list_changed(const baseconfval* hideval) |
304 | | @@ -2439,7 +2449,7 @@ int main(int argc,char **argv) |
| 397 | @@ -2198,12 +2226,13 @@ void AppCore::on_dict_scan_select_changed(const baseconfval* scanval) |
| 398 | bool scan = static_cast<const confval<bool> *>(scanval)->val_; |
| 399 | |
| 400 | gtk_widget_set_sensitive(oFloatWin.StopButton, scan); |
| 401 | +#ifndef CONFIG_NANONOTE |
| 402 | if (scan != gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(oBottomWin.ScanSelectionCheckButton))) |
| 403 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(oBottomWin.ScanSelectionCheckButton), scan); |
| 404 | - |
| 405 | oDockLet->set_scan_mode(scan); |
| 406 | if (GTK_WIDGET_VISIBLE(window)) |
| 407 | oDockLet->hide_state(); |
| 408 | +#endif |
| 409 | if (scan) { |
| 410 | bool lock=conf->get_bool_at("floating_window/lock"); |
| 411 | if (lock && !oFloatWin.QueryingWord.empty()) |
| 412 | @@ -2263,8 +2292,10 @@ void AppCore::on_floatwin_lock_y_changed(const baseconfval* lock_y_val) |
| 413 | |
| 414 | void AppCore::on_scan_modifier_key_changed(const baseconfval* keyval) |
| 415 | { |
| 416 | +#ifndef CONFIG_NANONOTE |
| 417 | int key = static_cast<const confval<int> *>(keyval)->val_; |
| 418 | unlock_keys->set_comb(combnum2str(key)); |
| 419 | +#endif |
| 420 | } |
| 421 | |
| 422 | gchar* GetPureEnglishAlpha(gchar *str) |
| 423 | @@ -2439,7 +2470,7 @@ int main(int argc,char **argv) |
305 | 424 | g_warning("Cannot create directory %s.", userdir.c_str()); |
306 | 425 | } |
307 | 426 | g_thread_init (NULL); |