stardict/patches/001-fix-compile-error.patch |
| 1 | fix compile error |
| 2 | |
| 3 | From: Xiangfu Liu <xiangfu@sharism.cc> |
| 4 | |
| 5 | |
| 6 | --- |
| 7 | |
| 8 | src/gconf_file.cpp | 2 ++ |
| 9 | src/inifile.cpp | 1 + |
| 10 | src/lib/common.cpp | 2 ++ |
| 11 | src/lib/data.cpp | 1 + |
| 12 | src/lib/http_client.cpp | 1 + |
| 13 | src/lib/pluginmanager.cpp | 2 +- |
| 14 | src/lib/stardict_client.cpp | 1 + |
| 15 | src/lib/treedict.cpp | 1 + |
| 16 | src/pangoview.cpp | 2 ++ |
| 17 | src/prefsdlg.cpp | 1 + |
| 18 | src/readword.cpp | 1 + |
| 19 | src/sigc++/signal.h | 2 +- |
| 20 | src/utils.cpp | 2 ++ |
| 21 | src/x11_iskeyspressed.hpp | 2 ++ |
| 22 | .../stardict_dictdotcn.cpp | 2 +- |
| 23 | .../stardict-espeak-tts-plugin/stardict_espeak.cpp | 1 + |
| 24 | .../stardict_gucharmap.cpp | 3 ++- |
| 25 | .../stardict_html_parsedata.cpp | 2 ++ |
| 26 | .../stardict-man-plugin/stardict_man.cpp | 2 +- |
| 27 | .../stardict_powerword_parsedata.cpp | 1 + |
| 28 | .../stardict-qqwry-plugin/stardict_qqwry.cpp | 3 ++- |
| 29 | .../stardict-spell-plugin/stardict_spell.cpp | 1 + |
| 30 | .../stardict_wiki2xml.cpp | 1 + |
| 31 | .../stardict_wiki_parsedata.cpp | 1 + |
| 32 | .../stardict-wordnet-plugin/court_widget.cpp | 1 + |
| 33 | .../stardict-wordnet-plugin/stardict_wordnet.cpp | 1 + |
| 34 | .../stardict_wordnet_parsedata.cpp | 1 + |
| 35 | .../stardict_xdxf_parsedata.cpp | 1 + |
| 36 | tests/t_config_file.cpp | 1 + |
| 37 | tests/t_xml.cpp | 1 + |
| 38 | 30 files changed, 38 insertions(+), 6 deletions(-) |
| 39 | |
| 40 | |
| 41 | diff --git a/src/gconf_file.cpp b/src/gconf_file.cpp |
| 42 | index a5b81c6..e1d43aa 100644 |
| 43 | --- a/src/gconf_file.cpp |
| 44 | @@ -22,6 +22,8 @@ |
| 45 | # include "config.h" |
| 46 | #endif |
| 47 | |
| 48 | +#include <memory> |
| 49 | + |
| 50 | #include <glib/gi18n.h> |
| 51 | |
| 52 | #include "gconf_file.hpp" |
| 53 | diff --git a/src/inifile.cpp b/src/inifile.cpp |
| 54 | index 2f73f7b..e652709 100644 |
| 55 | --- a/src/inifile.cpp |
| 56 | @@ -25,6 +25,7 @@ |
| 57 | #include <vector> |
| 58 | #include <cerrno> |
| 59 | #include <cstring> |
| 60 | +#include <cstdlib> |
| 61 | #include <cstdio> |
| 62 | #include <glib/gi18n.h> |
| 63 | #include <glib/gstdio.h> |
| 64 | diff --git a/src/lib/common.cpp b/src/lib/common.cpp |
| 65 | index 6575ad9..29faf9e 100644 |
| 66 | --- a/src/lib/common.cpp |
| 67 | @@ -24,6 +24,8 @@ |
| 68 | # include "config.h" |
| 69 | #endif |
| 70 | |
| 71 | +#include <cstdlib> |
| 72 | +#include <cstring> |
| 73 | #include "common.hpp" |
| 74 | |
| 75 | static void parse_description(const char *p, long len, std::string &description) |
| 76 | diff --git a/src/lib/data.cpp b/src/lib/data.cpp |
| 77 | index 45c7d1a..1b29ec3 100644 |
| 78 | --- a/src/lib/data.cpp |
| 79 | @@ -22,6 +22,7 @@ |
| 80 | # include "config.h" |
| 81 | #endif |
| 82 | |
| 83 | +#include <cstring> |
| 84 | #include "kmp.h" |
| 85 | |
| 86 | #include "data.hpp" |
| 87 | diff --git a/src/lib/http_client.cpp b/src/lib/http_client.cpp |
| 88 | index 802a469..732f205 100644 |
| 89 | --- a/src/lib/http_client.cpp |
| 90 | @@ -2,6 +2,7 @@ |
| 91 | # include "config.h" |
| 92 | #endif |
| 93 | |
| 94 | +#include <cstring> |
| 95 | #include "http_client.h" |
| 96 | #include "sockets.hpp" |
| 97 | |
| 98 | diff --git a/src/lib/pluginmanager.cpp b/src/lib/pluginmanager.cpp |
| 99 | index de3e92d..28a46c4 100644 |
| 100 | --- a/src/lib/pluginmanager.cpp |
| 101 | @@ -1,6 +1,6 @@ |
| 102 | #include "pluginmanager.h" |
| 103 | #include "file.hpp" |
| 104 | -#include <string> |
| 105 | +#include <cstring> |
| 106 | |
| 107 | StarDictPluginBaseObject::StarDictPluginBaseObject(const char *filename, GModule *module_, plugin_configure_func_t configure_func_): |
| 108 | plugin_filename(filename), module(module_), configure_func(configure_func_) |
| 109 | diff --git a/src/lib/stardict_client.cpp b/src/lib/stardict_client.cpp |
| 110 | index dcae5ce..c3d2511 100644 |
| 111 | --- a/src/lib/stardict_client.cpp |
| 112 | @@ -25,6 +25,7 @@ |
| 113 | #include <glib.h> |
| 114 | #include <glib/gi18n.h> |
| 115 | |
| 116 | +#include <cstdlib> |
| 117 | #include "sockets.hpp" |
| 118 | #include "md5.h" |
| 119 | #include "getuint32.h" |
| 120 | diff --git a/src/lib/treedict.cpp b/src/lib/treedict.cpp |
| 121 | index 01fa89a..f0b3322 100644 |
| 122 | --- a/src/lib/treedict.cpp |
| 123 | @@ -25,6 +25,7 @@ |
| 124 | # include "config.h" |
| 125 | #endif |
| 126 | |
| 127 | +#include <cstring> |
| 128 | #include "file.hpp" |
| 129 | #include "getuint32.h" |
| 130 | |
| 131 | diff --git a/src/pangoview.cpp b/src/pangoview.cpp |
| 132 | index eb5d34d..e400ac3 100644 |
| 133 | --- a/src/pangoview.cpp |
| 134 | @@ -22,6 +22,8 @@ |
| 135 | # include "config.h" |
| 136 | #endif |
| 137 | |
| 138 | +#include <cstring> |
| 139 | + |
| 140 | #include "gtktextviewpango.h" |
| 141 | #include "utils.h" |
| 142 | #include "skin.h"//for SkinCursor definition |
| 143 | diff --git a/src/prefsdlg.cpp b/src/prefsdlg.cpp |
| 144 | index 33648ed..14e3f15 100644 |
| 145 | --- a/src/prefsdlg.cpp |
| 146 | @@ -21,6 +21,7 @@ |
| 147 | # include "config.h" |
| 148 | #endif |
| 149 | |
| 150 | +#include <cstdlib> |
| 151 | #include <glib/gi18n.h> |
| 152 | #include <glib/gstdio.h> |
| 153 | |
| 154 | diff --git a/src/readword.cpp b/src/readword.cpp |
| 155 | index 340fbb6..f6efb2c 100644 |
| 156 | --- a/src/readword.cpp |
| 157 | @@ -3,6 +3,7 @@ |
| 158 | #endif |
| 159 | |
| 160 | #include <cstring> |
| 161 | +#include <cstdlib> |
| 162 | #include <string> |
| 163 | |
| 164 | #include <glib/gi18n.h> |
| 165 | diff --git a/src/sigc++/signal.h b/src/sigc++/signal.h |
| 166 | index 282a5b1..b103dbf 100644 |
| 167 | --- a/src/sigc++/signal.h |
| 168 | @@ -18,7 +18,7 @@ |
| 169 | //Compilers, such as older versions of SUN Forte C++, that do not allow this also often |
| 170 | //do not allow a typedef to have the same name as a class in the typedef's definition. |
| 171 | //For Sun Forte CC 5.7 (SUN Workshop 10), comment this out to fix the build. |
| 172 | - #define SIGC_TYPEDEF_REDEFINE_ALLOWED 1 |
| 173 | +// #define SIGC_TYPEDEF_REDEFINE_ALLOWED 1 |
| 174 | #endif |
| 175 | |
| 176 | namespace sigc { |
| 177 | diff --git a/src/utils.cpp b/src/utils.cpp |
| 178 | index 4a09f30..2ce059b 100644 |
| 179 | --- a/src/utils.cpp |
| 180 | @@ -22,6 +22,8 @@ |
| 181 | # include "config.h" |
| 182 | #endif |
| 183 | |
| 184 | +#include <cstring> |
| 185 | + |
| 186 | #include <glib.h> |
| 187 | #include <glib/gi18n.h> |
| 188 | #include <cstdlib> |
| 189 | diff --git a/src/x11_iskeyspressed.hpp b/src/x11_iskeyspressed.hpp |
| 190 | index 9b0d375..f7391ad 100644 |
| 191 | --- a/src/x11_iskeyspressed.hpp |
| 192 | @@ -1,6 +1,8 @@ |
| 193 | #ifndef _X11_ISKEYSPRESSED_HPP_ |
| 194 | #define _X11_ISKEYSPRESSED_HPP_ |
| 195 | |
| 196 | +#include <memory> |
| 197 | + |
| 198 | #include <gdk/gdkx.h> |
| 199 | #include <X11/keysym.h> |
| 200 | #include <gtk/gtk.h> |
| 201 | diff --git a/stardict-plugins/stardict-dictdotcn-plugin/stardict_dictdotcn.cpp b/stardict-plugins/stardict-dictdotcn-plugin/stardict_dictdotcn.cpp |
| 202 | index b779046..f608fb1 100644 |
| 203 | --- a/stardict-plugins/stardict-dictdotcn-plugin/stardict_dictdotcn.cpp |
| 204 | @@ -1,6 +1,6 @@ |
| 205 | #include "stardict_dictdotcn.h" |
| 206 | #include <glib/gi18n.h> |
| 207 | -#include <string> |
| 208 | +#include <cstring> |
| 209 | #include <list> |
| 210 | |
| 211 | #ifdef _WIN32 |
| 212 | diff --git a/stardict-plugins/stardict-espeak-tts-plugin/stardict_espeak.cpp b/stardict-plugins/stardict-espeak-tts-plugin/stardict_espeak.cpp |
| 213 | index 08d6f91..340cf5c 100644 |
| 214 | --- a/stardict-plugins/stardict-espeak-tts-plugin/stardict_espeak.cpp |
| 215 | @@ -1,4 +1,5 @@ |
| 216 | #include "stardict_espeak.h" |
| 217 | +#include <cstring> |
| 218 | #include <espeak/speak_lib.h> |
| 219 | #include <glib/gi18n.h> |
| 220 | |
| 221 | diff --git a/stardict-plugins/stardict-gucharmap-plugin/stardict_gucharmap.cpp b/stardict-plugins/stardict-gucharmap-plugin/stardict_gucharmap.cpp |
| 222 | index f522e07..855c5fd 100644 |
| 223 | --- a/stardict-plugins/stardict-gucharmap-plugin/stardict_gucharmap.cpp |
| 224 | @@ -1,7 +1,8 @@ |
| 225 | #include "stardict_gucharmap.h" |
| 226 | #include <glib/gi18n.h> |
| 227 | #include <gucharmap/gucharmap.h> |
| 228 | -#include <string> |
| 229 | +#include <cstring> |
| 230 | +#include <cstdlib> |
| 231 | |
| 232 | static char *build_dictdata(char type, const char *definition) |
| 233 | { |
| 234 | diff --git a/stardict-plugins/stardict-html-parsedata-plugin/stardict_html_parsedata.cpp b/stardict-plugins/stardict-html-parsedata-plugin/stardict_html_parsedata.cpp |
| 235 | index 8bb78e8..1803299 100644 |
| 236 | --- a/stardict-plugins/stardict-html-parsedata-plugin/stardict_html_parsedata.cpp |
| 237 | @@ -1,4 +1,6 @@ |
| 238 | #include "stardict_html_parsedata.h" |
| 239 | +#include <cstring> |
| 240 | +#include <cstdlib> |
| 241 | #include <glib/gi18n.h> |
| 242 | |
| 243 | #ifdef _WIN32 |
| 244 | diff --git a/stardict-plugins/stardict-man-plugin/stardict_man.cpp b/stardict-plugins/stardict-man-plugin/stardict_man.cpp |
| 245 | index 1587e46..dfd7560 100644 |
| 246 | --- a/stardict-plugins/stardict-man-plugin/stardict_man.cpp |
| 247 | @@ -1,6 +1,6 @@ |
| 248 | #include "stardict_man.h" |
| 249 | #include <glib/gi18n.h> |
| 250 | -#include <string> |
| 251 | +#include <cstring> |
| 252 | |
| 253 | static const StarDictPluginSystemInfo *plugin_info = NULL; |
| 254 | static bool need_prefix; |
| 255 | diff --git a/stardict-plugins/stardict-powerword-parsedata-plugin/stardict_powerword_parsedata.cpp b/stardict-plugins/stardict-powerword-parsedata-plugin/stardict_powerword_parsedata.cpp |
| 256 | index 068ebbe..4da5c81 100644 |
| 257 | --- a/stardict-plugins/stardict-powerword-parsedata-plugin/stardict_powerword_parsedata.cpp |
| 258 | @@ -1,4 +1,5 @@ |
| 259 | #include "stardict_powerword_parsedata.h" |
| 260 | +#include <cstring> |
| 261 | #include <glib/gi18n.h> |
| 262 | |
| 263 | #ifdef _WIN32 |
| 264 | diff --git a/stardict-plugins/stardict-qqwry-plugin/stardict_qqwry.cpp b/stardict-plugins/stardict-qqwry-plugin/stardict_qqwry.cpp |
| 265 | index 65234dc..b5a7046 100644 |
| 266 | --- a/stardict-plugins/stardict-qqwry-plugin/stardict_qqwry.cpp |
| 267 | @@ -1,7 +1,8 @@ |
| 268 | #include "stardict_qqwry.h" |
| 269 | #include <glib/gi18n.h> |
| 270 | #include <glib/gstdio.h> |
| 271 | -#include <string> |
| 272 | +#include <cstring> |
| 273 | +#include <cstdlib> |
| 274 | |
| 275 | #ifdef _WIN32 |
| 276 | #include <windows.h> |
| 277 | diff --git a/stardict-plugins/stardict-spell-plugin/stardict_spell.cpp b/stardict-plugins/stardict-spell-plugin/stardict_spell.cpp |
| 278 | index af3e8ae..d5e66af 100644 |
| 279 | --- a/stardict-plugins/stardict-spell-plugin/stardict_spell.cpp |
| 280 | @@ -1,4 +1,5 @@ |
| 281 | #include "stardict_spell.h" |
| 282 | +#include <cstring> |
| 283 | #include <glib.h> |
| 284 | #include <glib/gi18n.h> |
| 285 | #include <enchant.h> |
| 286 | diff --git a/stardict-plugins/stardict-wiki-parsedata-plugin/stardict_wiki2xml.cpp b/stardict-plugins/stardict-wiki-parsedata-plugin/stardict_wiki2xml.cpp |
| 287 | index 0cfade9..f1a0277 100644 |
| 288 | --- a/stardict-plugins/stardict-wiki-parsedata-plugin/stardict_wiki2xml.cpp |
| 289 | @@ -1,5 +1,6 @@ |
| 290 | #include "stardict_wiki2xml.h" |
| 291 | #include "WIKI2XML.h" |
| 292 | +#include <cstring> |
| 293 | #include <glib.h> |
| 294 | |
| 295 | std::string wiki2xml(std::string &str) |
| 296 | diff --git a/stardict-plugins/stardict-wiki-parsedata-plugin/stardict_wiki_parsedata.cpp b/stardict-plugins/stardict-wiki-parsedata-plugin/stardict_wiki_parsedata.cpp |
| 297 | index fdf5270..8a6f7b0 100644 |
| 298 | --- a/stardict-plugins/stardict-wiki-parsedata-plugin/stardict_wiki_parsedata.cpp |
| 299 | @@ -1,5 +1,6 @@ |
| 300 | #include "stardict_wiki_parsedata.h" |
| 301 | #include "stardict_wiki2xml.h" |
| 302 | +#include <cstring> |
| 303 | #include <glib/gi18n.h> |
| 304 | |
| 305 | #ifdef _WIN32 |
| 306 | diff --git a/stardict-plugins/stardict-wordnet-plugin/court_widget.cpp b/stardict-plugins/stardict-wordnet-plugin/court_widget.cpp |
| 307 | index 37b227e..1e49f90 100644 |
| 308 | --- a/stardict-plugins/stardict-wordnet-plugin/court_widget.cpp |
| 309 | @@ -1,4 +1,5 @@ |
| 310 | #include "court_widget.h" |
| 311 | +#include <cstring> |
| 312 | #include <math.h> |
| 313 | #include <list> |
| 314 | |
| 315 | diff --git a/stardict-plugins/stardict-wordnet-plugin/stardict_wordnet.cpp b/stardict-plugins/stardict-wordnet-plugin/stardict_wordnet.cpp |
| 316 | index 043afaf..bc4c9ff 100644 |
| 317 | --- a/stardict-plugins/stardict-wordnet-plugin/stardict_wordnet.cpp |
| 318 | @@ -1,5 +1,6 @@ |
| 319 | #include "stardict_wordnet.h" |
| 320 | #include "court_widget.h" |
| 321 | +#include <cstring> |
| 322 | #include <glib/gi18n.h> |
| 323 | |
| 324 | #ifdef _WIN32 |
| 325 | diff --git a/stardict-plugins/stardict-wordnet-plugin/stardict_wordnet_parsedata.cpp b/stardict-plugins/stardict-wordnet-plugin/stardict_wordnet_parsedata.cpp |
| 326 | index 9f9ab9f..c5397e1 100644 |
| 327 | --- a/stardict-plugins/stardict-wordnet-plugin/stardict_wordnet_parsedata.cpp |
| 328 | @@ -1,4 +1,5 @@ |
| 329 | #include "stardict_wordnet_parsedata.h" |
| 330 | +#include <cstring> |
| 331 | #include <glib/gi18n.h> |
| 332 | |
| 333 | #ifdef _WIN32 |
| 334 | diff --git a/stardict-plugins/stardict-xdxf-parsedata-plugin/stardict_xdxf_parsedata.cpp b/stardict-plugins/stardict-xdxf-parsedata-plugin/stardict_xdxf_parsedata.cpp |
| 335 | index 905a01d..b143b90 100644 |
| 336 | --- a/stardict-plugins/stardict-xdxf-parsedata-plugin/stardict_xdxf_parsedata.cpp |
| 337 | @@ -1,4 +1,5 @@ |
| 338 | #include "stardict_xdxf_parsedata.h" |
| 339 | +#include <cstring> |
| 340 | #include <glib/gi18n.h> |
| 341 | |
| 342 | #ifdef _WIN32 |
| 343 | diff --git a/tests/t_config_file.cpp b/tests/t_config_file.cpp |
| 344 | index 73e2a52..24715cf 100644 |
| 345 | --- a/tests/t_config_file.cpp |
| 346 | @@ -8,6 +8,7 @@ |
| 347 | #include <cstring> |
| 348 | #include <iterator> |
| 349 | #include <iostream> |
| 350 | +#include <memory> |
| 351 | #include <gtk/gtk.h> |
| 352 | |
| 353 | #include "config_file.hpp" |
| 354 | diff --git a/tests/t_xml.cpp b/tests/t_xml.cpp |
| 355 | index a20422d..29b3d2a 100644 |
| 356 | --- a/tests/t_xml.cpp |
| 357 | @@ -5,6 +5,7 @@ |
| 358 | #include <glib.h> |
| 359 | #include <cstdlib> |
| 360 | #include <string> |
| 361 | +#include <cstring> |
| 362 | |
| 363 | |
| 364 | static void xml_decode(const char *str, std::string& decoded) |
stardict/patches/002-dont-need-hotkey-in-nanonote.patch |
| 1 | don't need hotkey in nanonote |
| 2 | |
| 3 | From: Xiangfu Liu <xiangfu@sharism.cc> |
| 4 | |
| 5 | |
| 6 | --- |
| 7 | |
| 8 | configure.in | 2 |
| 9 | src/class_factory.cpp | 2 |
| 10 | src/conf.cpp | 6 - |
| 11 | src/stardict.cpp | 6 - |
| 12 | src/x11_iskeyspressed.cpp | 351 --------------------------------------------- |
| 13 | src/x11_iskeyspressed.hpp | 65 -------- |
| 14 | 6 files changed, 8 insertions(+), 424 deletions(-) |
| 15 | |
| 16 | |
| 17 | diff --git a/configure.in b/configure.in |
| 18 | index 83d3d95..3676e2c 100644 |
| 19 | --- a/configure.in |
| 20 | @@ -428,7 +428,7 @@ LDFLAGS="$LDFLAGS $X_EXTRA_LIBS" |
| 21 | fi |
| 22 | |
| 23 | # Checks for libraries. |
| 24 | -AC_CHECK_LIB([X11], [main], , [AC_MSG_ERROR([X11 lib not found])]) |
| 25 | +#AC_CHECK_LIB([X11], [main], , [AC_MSG_ERROR([X11 lib not found])]) |
| 26 | |
| 27 | AC_SUBST(STARDICT_LIBS) |
| 28 | AC_SUBST(STARDICT_CFLAGS) |
| 29 | diff --git a/src/class_factory.cpp b/src/class_factory.cpp |
| 30 | index 8bff538..d1dddc2 100644 |
| 31 | --- a/src/class_factory.cpp |
| 32 | @@ -54,7 +54,7 @@ void *PlatformFactory::create_class_by_name(const std::string& name, void *param |
| 33 | #ifdef _WIN32 |
| 34 | return new win32_hotkeys(); |
| 35 | #else |
| 36 | - return new x11_hotkeys(GTK_WINDOW(param)); |
| 37 | + return NULL; //new x11_hotkeys(GTK_WINDOW(param)); |
| 38 | #endif |
| 39 | } |
| 40 | return NULL; |
| 41 | diff --git a/src/conf.cpp b/src/conf.cpp |
| 42 | index 2d0f89d..a35bc5c 100644 |
| 43 | --- a/src/conf.cpp |
| 44 | @@ -34,9 +34,9 @@ const int DEFAULT_WINDOW_WIDTH=238; |
| 45 | const int DEFAULT_WINDOW_HEIGHT=279; |
| 46 | const int DEFAULT_HPANED_POS=79; |
| 47 | #else |
| 48 | -const int DEFAULT_WINDOW_WIDTH=463; |
| 49 | -const int DEFAULT_WINDOW_HEIGHT=321; |
| 50 | -const int DEFAULT_HPANED_POS=127; |
| 51 | +const int DEFAULT_WINDOW_WIDTH=320; |
| 52 | +const int DEFAULT_WINDOW_HEIGHT=240; |
| 53 | +const int DEFAULT_HPANED_POS=79; |
| 54 | #endif |
| 55 | |
| 56 | std::auto_ptr<AppConf> conf; |
| 57 | diff --git a/src/stardict.cpp b/src/stardict.cpp |
| 58 | index 326ca4a..4c51d61 100644 |
| 59 | --- a/src/stardict.cpp |
| 60 | @@ -351,9 +351,9 @@ void AppCore::Create(gchar *queryword) |
| 61 | oTopWin.Create(vbox); |
| 62 | oMidWin.Create(vbox); |
| 63 | oBottomWin.Create(vbox); |
| 64 | - unlock_keys.reset(static_cast<hotkeys *>(PlatformFactory::create_class_by_name("hotkeys", |
| 65 | - GTK_WINDOW(window)))); |
| 66 | - unlock_keys->set_comb(combnum2str(conf->get_int_at("dictionary/scan_modifier_key"))); |
| 67 | + //unlock_keys.reset(static_cast<hotkeys *>(PlatformFactory::create_class_by_name("hotkeys", |
| 68 | + // GTK_WINDOW(window)))); |
| 69 | + //unlock_keys->set_comb(combnum2str(conf->get_int_at("dictionary/scan_modifier_key"))); |
| 70 | oFloatWin.Create(); |
| 71 | bool scan=conf->get_bool_at("dictionary/scan_selection"); |
| 72 | oDockLet.reset(PlatformFactory::create_tray_icon(window, scan, |
| 73 | diff --git a/src/x11_iskeyspressed.cpp b/src/x11_iskeyspressed.cpp |
| 74 | index 15e8fb0..8b13789 100644 |
| 75 | --- a/src/x11_iskeyspressed.cpp |
| 76 | @@ -1,352 +1 @@ |
| 77 | -/* |
| 78 | - * This file part of StarDict - A international dictionary for GNOME. |
| 79 | - * http://stardict.sourceforge.net |
| 80 | - * |
| 81 | - * Copyright (C) 2005 Evgeniy <dushistov@mail.ru> |
| 82 | - * |
| 83 | - * This program is free software; you can redistribute it and/or modify |
| 84 | - * it under the terms of the GNU General Public License as published by |
| 85 | - * the Free Software Foundation; either version 3 of the License, or |
| 86 | - * (at your option) any later version. |
| 87 | - * |
| 88 | - * This program is distributed in the hope that it will be useful, |
| 89 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 90 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 91 | - * GNU Library General Public License for more details. |
| 92 | - * |
| 93 | - * You should have received a copy of the GNU General Public License |
| 94 | - * along with this program; if not, write to the Free Software |
| 95 | - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 96 | - */ |
| 97 | |
| 98 | -/* |
| 99 | - * goal: react on key press even if there are window |
| 100 | - * have no focus in XWindows. This code based on xbindkeys. |
| 101 | - */ |
| 102 | - |
| 103 | -#ifdef HAVE_CONFIG_H |
| 104 | -# include "config.h" |
| 105 | -#endif |
| 106 | - |
| 107 | -#include "gtk_iskeyspressed.hpp" |
| 108 | - |
| 109 | -#include "x11_iskeyspressed.hpp" |
| 110 | - |
| 111 | - |
| 112 | - |
| 113 | -unsigned int x11_hotkeys::numlock_mask, x11_hotkeys::scrolllock_mask, |
| 114 | - x11_hotkeys::capslock_mask; |
| 115 | - |
| 116 | -void x11_hotkeys::get_offending_modifiers(Display * dpy) |
| 117 | -{ |
| 118 | - int i; |
| 119 | - XModifierKeymap *modmap; |
| 120 | - KeyCode nlock, slock; |
| 121 | - static int mask_table[8] = { |
| 122 | - ShiftMask, LockMask, ControlMask, Mod1Mask, |
| 123 | - Mod2Mask, Mod3Mask, Mod4Mask, Mod5Mask |
| 124 | - }; |
| 125 | - |
| 126 | - nlock = XKeysymToKeycode (dpy, XK_Num_Lock); |
| 127 | - slock = XKeysymToKeycode (dpy, XK_Scroll_Lock); |
| 128 | - |
| 129 | - /* |
| 130 | - * Find out the masks for the NumLock and ScrollLock modifiers, |
| 131 | - * so that we can bind the grabs for when they are enabled too. |
| 132 | - */ |
| 133 | - modmap = XGetModifierMapping (dpy); |
| 134 | - |
| 135 | - if (modmap != NULL && modmap->max_keypermod > 0) { |
| 136 | - for (i = 0; i < 8 * modmap->max_keypermod; i++) { |
| 137 | - if (modmap->modifiermap[i] == nlock && nlock != 0) |
| 138 | - numlock_mask = mask_table[i / modmap->max_keypermod]; |
| 139 | - else if (modmap->modifiermap[i] == slock && slock != 0) |
| 140 | - scrolllock_mask = mask_table[i / modmap->max_keypermod]; |
| 141 | - } |
| 142 | - } |
| 143 | - |
| 144 | - capslock_mask = LockMask; |
| 145 | - |
| 146 | - if (modmap) |
| 147 | - XFreeModifiermap (modmap); |
| 148 | -} |
| 149 | - |
| 150 | -void x11_hotkeys::my_grab_key(Display * dpy, KeyCode keycode, |
| 151 | - unsigned int modifier, Window win) |
| 152 | -{ |
| 153 | - modifier &= ~(numlock_mask | capslock_mask | scrolllock_mask); |
| 154 | - |
| 155 | - |
| 156 | - XGrabKey(dpy, keycode, modifier, (win ? win : DefaultRootWindow(dpy)), |
| 157 | - False, GrabModeAsync, GrabModeAsync); |
| 158 | - |
| 159 | - if (modifier == AnyModifier) |
| 160 | - return; |
| 161 | - |
| 162 | - if (numlock_mask) |
| 163 | - XGrabKey (dpy, keycode, modifier | numlock_mask, |
| 164 | - (win ? win : DefaultRootWindow (dpy)), |
| 165 | - False, GrabModeAsync, GrabModeAsync); |
| 166 | - |
| 167 | - if (capslock_mask) |
| 168 | - XGrabKey (dpy, keycode, modifier | capslock_mask, |
| 169 | - (win ? win : DefaultRootWindow (dpy)), |
| 170 | - False, GrabModeAsync, GrabModeAsync); |
| 171 | - |
| 172 | - if (scrolllock_mask) |
| 173 | - XGrabKey (dpy, keycode, modifier | scrolllock_mask, |
| 174 | - (win ? win : DefaultRootWindow (dpy)), |
| 175 | - False, GrabModeAsync, GrabModeAsync); |
| 176 | - |
| 177 | - if (numlock_mask && capslock_mask) |
| 178 | - XGrabKey (dpy, keycode, modifier | numlock_mask | capslock_mask, |
| 179 | - (win ? win : DefaultRootWindow (dpy)), |
| 180 | - False, GrabModeAsync, GrabModeAsync); |
| 181 | - |
| 182 | - if (numlock_mask && scrolllock_mask) |
| 183 | - XGrabKey (dpy, keycode, modifier | numlock_mask | scrolllock_mask, |
| 184 | - (win ? win : DefaultRootWindow (dpy)), |
| 185 | - False, GrabModeAsync, GrabModeAsync); |
| 186 | - |
| 187 | - if (capslock_mask && scrolllock_mask) |
| 188 | - XGrabKey (dpy, keycode, modifier | capslock_mask | scrolllock_mask, |
| 189 | - (win ? win : DefaultRootWindow (dpy)), |
| 190 | - False, GrabModeAsync, GrabModeAsync); |
| 191 | - |
| 192 | - if (numlock_mask && capslock_mask && scrolllock_mask) |
| 193 | - XGrabKey (dpy, keycode, |
| 194 | - modifier | numlock_mask | capslock_mask | scrolllock_mask, |
| 195 | - (win ? win : DefaultRootWindow (dpy)), False, GrabModeAsync, |
| 196 | - GrabModeAsync); |
| 197 | - |
| 198 | -} |
| 199 | - |
| 200 | - |
| 201 | -void x11_hotkeys::my_grab_button(Display * dpy, unsigned int button, |
| 202 | - unsigned int modifier, Window win) |
| 203 | -{ |
| 204 | - modifier &= ~(numlock_mask | capslock_mask | scrolllock_mask); |
| 205 | - |
| 206 | - XGrabButton (dpy, button, modifier, (win ? win : DefaultRootWindow (dpy)), |
| 207 | - False, ButtonPressMask | ButtonReleaseMask, |
| 208 | - GrabModeAsync, GrabModeAsync, None, None); |
| 209 | - |
| 210 | - if (modifier == AnyModifier) |
| 211 | - return; |
| 212 | - |
| 213 | - if (numlock_mask) |
| 214 | - XGrabButton (dpy, button, modifier | numlock_mask, |
| 215 | - (win ? win : DefaultRootWindow (dpy)), |
| 216 | - False, ButtonPressMask | ButtonReleaseMask, |
| 217 | - GrabModeAsync, GrabModeAsync, None, None); |
| 218 | - |
| 219 | - |
| 220 | - if (capslock_mask) |
| 221 | - XGrabButton (dpy, button, modifier | capslock_mask, |
| 222 | - (win ? win : DefaultRootWindow (dpy)), |
| 223 | - False, ButtonPressMask | ButtonReleaseMask, |
| 224 | - GrabModeAsync, GrabModeAsync, None, None); |
| 225 | - |
| 226 | - if (scrolllock_mask) |
| 227 | - XGrabButton (dpy, button, modifier | scrolllock_mask, |
| 228 | - (win ? win : DefaultRootWindow (dpy)), |
| 229 | - False, ButtonPressMask | ButtonReleaseMask, |
| 230 | - GrabModeAsync, GrabModeAsync, None, None); |
| 231 | - |
| 232 | - if (numlock_mask && capslock_mask) |
| 233 | - XGrabButton (dpy, button, modifier | numlock_mask | capslock_mask, |
| 234 | - (win ? win : DefaultRootWindow (dpy)), |
| 235 | - False, ButtonPressMask | ButtonReleaseMask, |
| 236 | - GrabModeAsync, GrabModeAsync, None, None); |
| 237 | - |
| 238 | - if (numlock_mask && scrolllock_mask) |
| 239 | - XGrabButton (dpy, button, modifier | numlock_mask | scrolllock_mask, |
| 240 | - (win ? win : DefaultRootWindow (dpy)), |
| 241 | - False, ButtonPressMask | ButtonReleaseMask, |
| 242 | - GrabModeAsync, GrabModeAsync, None, None); |
| 243 | - |
| 244 | - if (capslock_mask && scrolllock_mask) |
| 245 | - XGrabButton (dpy, button, modifier | capslock_mask | scrolllock_mask, |
| 246 | - (win ? win : DefaultRootWindow (dpy)), |
| 247 | - False, ButtonPressMask | ButtonReleaseMask, |
| 248 | - GrabModeAsync, GrabModeAsync, None, None); |
| 249 | - |
| 250 | - if (numlock_mask && capslock_mask && scrolllock_mask) |
| 251 | - XGrabButton (dpy, button, |
| 252 | - modifier | numlock_mask | capslock_mask | scrolllock_mask, |
| 253 | - (win ? win : DefaultRootWindow (dpy)), False, |
| 254 | - ButtonPressMask | ButtonReleaseMask, GrabModeAsync, |
| 255 | - GrabModeAsync, None, None); |
| 256 | -} |
| 257 | - |
| 258 | -bool x11_hotkeys::grab_keys(Display *dpy, Keys_t keys[], int nb_keys) |
| 259 | -{ |
| 260 | - int i; |
| 261 | - int min, max; |
| 262 | - int screen; |
| 263 | - |
| 264 | - |
| 265 | - XDisplayKeycodes(dpy, &min, &max); |
| 266 | - |
| 267 | -#ifdef DEBUG |
| 268 | - printf("\n"); |
| 269 | - printf("min_keycode=%d max_keycode=%d (ie: know keycodes)\n", |
| 270 | - min, max); |
| 271 | -#endif |
| 272 | - |
| 273 | - |
| 274 | - for (i = 0; i < nb_keys; i++) { |
| 275 | -#ifdef DEBUG |
| 276 | - print_key(dpy, &keys[i]); |
| 277 | -#endif |
| 278 | - if (keys[i].type == SYM) { |
| 279 | - for (screen = 0; screen < ScreenCount (dpy); screen++) { |
| 280 | - my_grab_key(dpy, XKeysymToKeycode(dpy, keys[i].key.sym), |
| 281 | - keys[i].modifier, RootWindow(dpy, screen)); |
| 282 | - } |
| 283 | - } else if (keys[i].type == BUTTON) { |
| 284 | - for (screen = 0; screen < ScreenCount (dpy); screen++) { |
| 285 | - my_grab_button(dpy, keys[i].key.button, keys[i].modifier, |
| 286 | - RootWindow (dpy, screen)); |
| 287 | - } |
| 288 | - } else { |
| 289 | - if (keys[i].key.code >= min && keys[i].key.code <= max) { |
| 290 | - for (screen = 0; screen < ScreenCount (dpy); screen++) { |
| 291 | - my_grab_key (dpy, keys[i].key.code, keys[i].modifier, |
| 292 | - RootWindow (dpy, screen)); |
| 293 | - } |
| 294 | - } else { |
| 295 | -#ifdef DEBUG |
| 296 | - print_key (dpy, &keys[i]); |
| 297 | - |
| 298 | - |
| 299 | - fprintf (stderr, |
| 300 | - " The keycode %d cannot be used, as it's not between the\n" |
| 301 | - " min(%d) and max(%d) keycode of your keyboard.\n" |
| 302 | - " Please increase the 'maximum' value in\n" |
| 303 | - " /usr/X11R6/lib/X11/xkb/keycodes/xfree86,\n" |
| 304 | - " then restart X.\n", keys[i].key.code, min, max); |
| 305 | -#endif |
| 306 | - return false; |
| 307 | - } |
| 308 | - } |
| 309 | - } |
| 310 | - |
| 311 | - return true; |
| 312 | -} |
| 313 | - |
| 314 | - |
| 315 | -x11_hotkeys::x11_hotkeys(GtkWindow *win_) : |
| 316 | - win(win_), |
| 317 | - pressed(false), |
| 318 | - def_hot_keys(new gtk_hotkeys(win_)) |
| 319 | -{ |
| 320 | - possb_combs=def_hot_keys->possible_combs(); |
| 321 | - possb_combs.push_back("Ctrl+e"); |
| 322 | - possb_combs.push_back("F1"); |
| 323 | - possb_combs.push_back("F2"); |
| 324 | - possb_combs.push_back("F3"); |
| 325 | - possb_combs.push_back("F4"); |
| 326 | - display=gdk_x11_display_get_xdisplay(gdk_screen_get_display(gtk_window_get_screen(win))); |
| 327 | - get_offending_modifiers(display); |
| 328 | - gdk_window_add_filter(NULL, GdkFilterFunc(key_filter), this); |
| 329 | -} |
| 330 | - |
| 331 | -x11_hotkeys::~x11_hotkeys() |
| 332 | -{ |
| 333 | - ungrabkeys(); |
| 334 | -} |
| 335 | - |
| 336 | -const std::list<std::string>& x11_hotkeys::possible_combs() |
| 337 | -{ |
| 338 | - return possb_combs; |
| 339 | -} |
| 340 | - |
| 341 | -void x11_hotkeys::set_comb(const std::string& val) |
| 342 | -{ |
| 343 | - if (comb==val) |
| 344 | - return; |
| 345 | - |
| 346 | - unsigned int modifier=0; |
| 347 | - KeySym key=0; |
| 348 | - std::string::size_type pos=std::string::npos; |
| 349 | - |
| 350 | - do { |
| 351 | - std::string::size_type prev_pos=pos; |
| 352 | - pos=val.find('+', pos+1); |
| 353 | - std::string cur; |
| 354 | - if (pos!=std::string::npos) |
| 355 | - cur.assign(val, prev_pos+1, pos-prev_pos-1); |
| 356 | - else |
| 357 | - cur.assign(val, prev_pos+1, val.length()-prev_pos-1); |
| 358 | - if (cur=="Ctrl") { |
| 359 | - modifier|=ControlMask; |
| 360 | - } else if (cur=="Alt") { |
| 361 | - modifier|=Mod1Mask; |
| 362 | - } else if (cur=="Shift") { |
| 363 | - modifier|=ShiftMask; |
| 364 | - } else if (cur=="Win") { |
| 365 | - modifier|=Mod4Mask; |
| 366 | - } else { |
| 367 | - key=XStringToKeysym(cur.c_str()); |
| 368 | - } |
| 369 | - } while (pos!=std::string::npos); |
| 370 | - |
| 371 | - comb=val; |
| 372 | - pressed=false; |
| 373 | - grab_key.key.sym=0; |
| 374 | - if (key!=0) { |
| 375 | - ungrabkeys(); |
| 376 | - grab_key.type=SYM; |
| 377 | - grab_key.event_type=PRESS; |
| 378 | - grab_key.key.sym=key; |
| 379 | - grab_key.modifier=modifier; |
| 380 | - grab_keys(display, &grab_key, 1); |
| 381 | - } else |
| 382 | - def_hot_keys->set_comb(val); |
| 383 | -} |
| 384 | - |
| 385 | -bool x11_hotkeys::is_pressed() |
| 386 | -{ |
| 387 | - if (grab_key.key.sym!=0) |
| 388 | - return pressed; |
| 389 | - |
| 390 | - return def_hot_keys->is_pressed(); |
| 391 | -} |
| 392 | - |
| 393 | -void x11_hotkeys::ungrabkeys() |
| 394 | -{ |
| 395 | - if (grab_key.key.sym==0) |
| 396 | - return; |
| 397 | - Display *d=display; |
| 398 | - |
| 399 | - for (int screen = 0; screen<ScreenCount(d); screen++) { |
| 400 | - XUngrabKey(d, AnyKey, AnyModifier, RootWindow (d, screen)); |
| 401 | - XUngrabButton(d, AnyButton, AnyModifier, RootWindow (d, screen)); |
| 402 | - } |
| 403 | -} |
| 404 | - |
| 405 | -GdkFilterReturn x11_hotkeys::key_filter(GdkXEvent *gdk_xevent, |
| 406 | - GdkEvent *event, |
| 407 | - x11_hotkeys *th) |
| 408 | -{ |
| 409 | - int type; |
| 410 | - XKeyEvent *xevent; |
| 411 | - |
| 412 | - xevent = (XKeyEvent *)gdk_xevent; |
| 413 | - type = xevent->type; |
| 414 | - KeySym keysym = XKeycodeToKeysym(GDK_DISPLAY(), ((XKeyEvent *)xevent)->keycode, 0); |
| 415 | - unsigned int state=xevent->state; |
| 416 | - state &= ~(numlock_mask | capslock_mask | scrolllock_mask); |
| 417 | - if (type == KeyPress) { |
| 418 | - if (keysym==th->grab_key.key.sym && state==th->grab_key.modifier) { |
| 419 | - th->pressed=true; |
| 420 | - } |
| 421 | - } else if (type==KeyRelease) { |
| 422 | - if (keysym==th->grab_key.key.sym) { |
| 423 | - th->pressed=false; |
| 424 | - } |
| 425 | - } |
| 426 | - |
| 427 | - return GDK_FILTER_CONTINUE; |
| 428 | -} |
| 429 | diff --git a/src/x11_iskeyspressed.hpp b/src/x11_iskeyspressed.hpp |
| 430 | index f7391ad..8b13789 100644 |
| 431 | --- a/src/x11_iskeyspressed.hpp |
| 432 | @@ -1,66 +1 @@ |
| 433 | -#ifndef _X11_ISKEYSPRESSED_HPP_ |
| 434 | -#define _X11_ISKEYSPRESSED_HPP_ |
| 435 | |
| 436 | -#include <memory> |
| 437 | - |
| 438 | -#include <gdk/gdkx.h> |
| 439 | -#include <X11/keysym.h> |
| 440 | -#include <gtk/gtk.h> |
| 441 | - |
| 442 | -#include "iskeyspressed.hpp" |
| 443 | - |
| 444 | -typedef enum { SYM, CODE, BUTTON } KeyType_t; |
| 445 | -typedef enum { PRESS, RELEASE } EventType_t; |
| 446 | - |
| 447 | -struct Keys_t { |
| 448 | - |
| 449 | - KeyType_t type; |
| 450 | - |
| 451 | - EventType_t event_type; |
| 452 | - |
| 453 | - union { |
| 454 | - KeySym sym; |
| 455 | - KeyCode code; |
| 456 | - unsigned int button; |
| 457 | - } key; |
| 458 | - |
| 459 | - unsigned int modifier; |
| 460 | - |
| 461 | - Keys_t(KeyType_t t=SYM, EventType_t et=PRESS, KeySym s=0, unsigned int m=0) : |
| 462 | - type(t), event_type(et), modifier(m) |
| 463 | - { |
| 464 | - key.sym=s; |
| 465 | - } |
| 466 | -}; |
| 467 | - |
| 468 | -class x11_hotkeys : public hotkeys { |
| 469 | -public: |
| 470 | - x11_hotkeys(GtkWindow *win_); |
| 471 | - ~x11_hotkeys(); |
| 472 | - const std::list<std::string>& possible_combs(); |
| 473 | - void set_comb(const std::string& comb); |
| 474 | - bool is_pressed(); |
| 475 | -private: |
| 476 | - std::string comb; |
| 477 | - GtkWindow *win; |
| 478 | - bool pressed; |
| 479 | - Keys_t grab_key; |
| 480 | - std::list<std::string> possb_combs; |
| 481 | - std::auto_ptr<hotkeys> def_hot_keys;/*I don't want to duplicate work, |
| 482 | - so hold here pointer to default |
| 483 | - object of this class*/ |
| 484 | - Display *display; |
| 485 | - static unsigned int numlock_mask, scrolllock_mask, capslock_mask; |
| 486 | - |
| 487 | - static GdkFilterReturn key_filter(GdkXEvent *gdk_xevent, |
| 488 | - GdkEvent *event, x11_hotkeys *th); |
| 489 | - void ungrabkeys(void); |
| 490 | - static void get_offending_modifiers(Display * dpy); |
| 491 | - static void my_grab_key(Display * dpy, KeyCode keycode, |
| 492 | - unsigned int modifier, Window win); |
| 493 | - static void my_grab_button(Display * dpy, unsigned int button, |
| 494 | - unsigned int modifier, Window win); |
| 495 | - static bool grab_keys(Display *dpy, Keys_t keys[], int nb_keys); |
| 496 | -}; |
| 497 | - |
| 498 | -#endif//!_X11_ISKEYSPRESSED_HPP_ |