mirror of
git://projects.qi-hardware.com/openwrt-packages.git
synced 2024-11-04 23:21:53 +02:00
[stardict] add patches, stardict work in nanonote
This commit is contained in:
parent
c47e3af7ce
commit
cf93b3148b
394
stardict/patches/001-fix-compile-error.patch
Normal file
394
stardict/patches/001-fix-compile-error.patch
Normal file
@ -0,0 +1,394 @@
|
||||
fix compile error
|
||||
|
||||
From: Xiangfu Liu <xiangfu@sharism.cc>
|
||||
|
||||
|
||||
---
|
||||
|
||||
src/gconf_file.cpp | 2 ++
|
||||
src/inifile.cpp | 1 +
|
||||
src/lib/common.cpp | 2 ++
|
||||
src/lib/data.cpp | 1 +
|
||||
src/lib/http_client.cpp | 1 +
|
||||
src/lib/pluginmanager.cpp | 2 +-
|
||||
src/lib/stardict_client.cpp | 1 +
|
||||
src/lib/treedict.cpp | 1 +
|
||||
src/pangoview.cpp | 2 ++
|
||||
src/prefsdlg.cpp | 1 +
|
||||
src/readword.cpp | 1 +
|
||||
src/sigc++/signal.h | 2 +-
|
||||
src/utils.cpp | 2 ++
|
||||
src/x11_iskeyspressed.hpp | 2 ++
|
||||
.../stardict_dictdotcn.cpp | 2 +-
|
||||
.../stardict-espeak-tts-plugin/stardict_espeak.cpp | 1 +
|
||||
.../stardict_gucharmap.cpp | 3 ++-
|
||||
.../stardict_html_parsedata.cpp | 2 ++
|
||||
.../stardict-man-plugin/stardict_man.cpp | 2 +-
|
||||
.../stardict_powerword_parsedata.cpp | 1 +
|
||||
.../stardict-qqwry-plugin/stardict_qqwry.cpp | 3 ++-
|
||||
.../stardict-spell-plugin/stardict_spell.cpp | 1 +
|
||||
.../stardict_wiki2xml.cpp | 1 +
|
||||
.../stardict_wiki_parsedata.cpp | 1 +
|
||||
.../stardict-wordnet-plugin/court_widget.cpp | 1 +
|
||||
.../stardict-wordnet-plugin/stardict_wordnet.cpp | 1 +
|
||||
.../stardict_wordnet_parsedata.cpp | 1 +
|
||||
.../stardict_xdxf_parsedata.cpp | 1 +
|
||||
tests/t_config_file.cpp | 1 +
|
||||
tests/t_xml.cpp | 1 +
|
||||
30 files changed, 38 insertions(+), 6 deletions(-)
|
||||
|
||||
|
||||
diff --git a/src/gconf_file.cpp b/src/gconf_file.cpp
|
||||
index a5b81c6..e1d43aa 100644
|
||||
--- a/src/gconf_file.cpp
|
||||
+++ b/src/gconf_file.cpp
|
||||
@@ -22,6 +22,8 @@
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
+#include <memory>
|
||||
+
|
||||
#include <glib/gi18n.h>
|
||||
|
||||
#include "gconf_file.hpp"
|
||||
diff --git a/src/inifile.cpp b/src/inifile.cpp
|
||||
index 2f73f7b..e652709 100644
|
||||
--- a/src/inifile.cpp
|
||||
+++ b/src/inifile.cpp
|
||||
@@ -25,6 +25,7 @@
|
||||
#include <vector>
|
||||
#include <cerrno>
|
||||
#include <cstring>
|
||||
+#include <cstdlib>
|
||||
#include <cstdio>
|
||||
#include <glib/gi18n.h>
|
||||
#include <glib/gstdio.h>
|
||||
diff --git a/src/lib/common.cpp b/src/lib/common.cpp
|
||||
index 6575ad9..29faf9e 100644
|
||||
--- a/src/lib/common.cpp
|
||||
+++ b/src/lib/common.cpp
|
||||
@@ -24,6 +24,8 @@
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
+#include <cstdlib>
|
||||
+#include <cstring>
|
||||
#include "common.hpp"
|
||||
|
||||
static void parse_description(const char *p, long len, std::string &description)
|
||||
diff --git a/src/lib/data.cpp b/src/lib/data.cpp
|
||||
index 45c7d1a..1b29ec3 100644
|
||||
--- a/src/lib/data.cpp
|
||||
+++ b/src/lib/data.cpp
|
||||
@@ -22,6 +22,7 @@
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
+#include <cstring>
|
||||
#include "kmp.h"
|
||||
|
||||
#include "data.hpp"
|
||||
diff --git a/src/lib/http_client.cpp b/src/lib/http_client.cpp
|
||||
index 802a469..732f205 100644
|
||||
--- a/src/lib/http_client.cpp
|
||||
+++ b/src/lib/http_client.cpp
|
||||
@@ -2,6 +2,7 @@
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
+#include <cstring>
|
||||
#include "http_client.h"
|
||||
#include "sockets.hpp"
|
||||
|
||||
diff --git a/src/lib/pluginmanager.cpp b/src/lib/pluginmanager.cpp
|
||||
index de3e92d..28a46c4 100644
|
||||
--- a/src/lib/pluginmanager.cpp
|
||||
+++ b/src/lib/pluginmanager.cpp
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "pluginmanager.h"
|
||||
#include "file.hpp"
|
||||
-#include <string>
|
||||
+#include <cstring>
|
||||
|
||||
StarDictPluginBaseObject::StarDictPluginBaseObject(const char *filename, GModule *module_, plugin_configure_func_t configure_func_):
|
||||
plugin_filename(filename), module(module_), configure_func(configure_func_)
|
||||
diff --git a/src/lib/stardict_client.cpp b/src/lib/stardict_client.cpp
|
||||
index dcae5ce..c3d2511 100644
|
||||
--- a/src/lib/stardict_client.cpp
|
||||
+++ b/src/lib/stardict_client.cpp
|
||||
@@ -25,6 +25,7 @@
|
||||
#include <glib.h>
|
||||
#include <glib/gi18n.h>
|
||||
|
||||
+#include <cstdlib>
|
||||
#include "sockets.hpp"
|
||||
#include "md5.h"
|
||||
#include "getuint32.h"
|
||||
diff --git a/src/lib/treedict.cpp b/src/lib/treedict.cpp
|
||||
index 01fa89a..f0b3322 100644
|
||||
--- a/src/lib/treedict.cpp
|
||||
+++ b/src/lib/treedict.cpp
|
||||
@@ -25,6 +25,7 @@
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
+#include <cstring>
|
||||
#include "file.hpp"
|
||||
#include "getuint32.h"
|
||||
|
||||
diff --git a/src/pangoview.cpp b/src/pangoview.cpp
|
||||
index eb5d34d..e400ac3 100644
|
||||
--- a/src/pangoview.cpp
|
||||
+++ b/src/pangoview.cpp
|
||||
@@ -22,6 +22,8 @@
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
+#include <cstring>
|
||||
+
|
||||
#include "gtktextviewpango.h"
|
||||
#include "utils.h"
|
||||
#include "skin.h"//for SkinCursor definition
|
||||
diff --git a/src/prefsdlg.cpp b/src/prefsdlg.cpp
|
||||
index 33648ed..14e3f15 100644
|
||||
--- a/src/prefsdlg.cpp
|
||||
+++ b/src/prefsdlg.cpp
|
||||
@@ -21,6 +21,7 @@
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
+#include <cstdlib>
|
||||
#include <glib/gi18n.h>
|
||||
#include <glib/gstdio.h>
|
||||
|
||||
diff --git a/src/readword.cpp b/src/readword.cpp
|
||||
index 340fbb6..f6efb2c 100644
|
||||
--- a/src/readword.cpp
|
||||
+++ b/src/readword.cpp
|
||||
@@ -3,6 +3,7 @@
|
||||
#endif
|
||||
|
||||
#include <cstring>
|
||||
+#include <cstdlib>
|
||||
#include <string>
|
||||
|
||||
#include <glib/gi18n.h>
|
||||
diff --git a/src/sigc++/signal.h b/src/sigc++/signal.h
|
||||
index 282a5b1..b103dbf 100644
|
||||
--- a/src/sigc++/signal.h
|
||||
+++ b/src/sigc++/signal.h
|
||||
@@ -18,7 +18,7 @@
|
||||
//Compilers, such as older versions of SUN Forte C++, that do not allow this also often
|
||||
//do not allow a typedef to have the same name as a class in the typedef's definition.
|
||||
//For Sun Forte CC 5.7 (SUN Workshop 10), comment this out to fix the build.
|
||||
- #define SIGC_TYPEDEF_REDEFINE_ALLOWED 1
|
||||
+// #define SIGC_TYPEDEF_REDEFINE_ALLOWED 1
|
||||
#endif
|
||||
|
||||
namespace sigc {
|
||||
diff --git a/src/utils.cpp b/src/utils.cpp
|
||||
index 4a09f30..2ce059b 100644
|
||||
--- a/src/utils.cpp
|
||||
+++ b/src/utils.cpp
|
||||
@@ -22,6 +22,8 @@
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
+#include <cstring>
|
||||
+
|
||||
#include <glib.h>
|
||||
#include <glib/gi18n.h>
|
||||
#include <cstdlib>
|
||||
diff --git a/src/x11_iskeyspressed.hpp b/src/x11_iskeyspressed.hpp
|
||||
index 9b0d375..f7391ad 100644
|
||||
--- a/src/x11_iskeyspressed.hpp
|
||||
+++ b/src/x11_iskeyspressed.hpp
|
||||
@@ -1,6 +1,8 @@
|
||||
#ifndef _X11_ISKEYSPRESSED_HPP_
|
||||
#define _X11_ISKEYSPRESSED_HPP_
|
||||
|
||||
+#include <memory>
|
||||
+
|
||||
#include <gdk/gdkx.h>
|
||||
#include <X11/keysym.h>
|
||||
#include <gtk/gtk.h>
|
||||
diff --git a/stardict-plugins/stardict-dictdotcn-plugin/stardict_dictdotcn.cpp b/stardict-plugins/stardict-dictdotcn-plugin/stardict_dictdotcn.cpp
|
||||
index b779046..f608fb1 100644
|
||||
--- a/stardict-plugins/stardict-dictdotcn-plugin/stardict_dictdotcn.cpp
|
||||
+++ b/stardict-plugins/stardict-dictdotcn-plugin/stardict_dictdotcn.cpp
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "stardict_dictdotcn.h"
|
||||
#include <glib/gi18n.h>
|
||||
-#include <string>
|
||||
+#include <cstring>
|
||||
#include <list>
|
||||
|
||||
#ifdef _WIN32
|
||||
diff --git a/stardict-plugins/stardict-espeak-tts-plugin/stardict_espeak.cpp b/stardict-plugins/stardict-espeak-tts-plugin/stardict_espeak.cpp
|
||||
index 08d6f91..340cf5c 100644
|
||||
--- a/stardict-plugins/stardict-espeak-tts-plugin/stardict_espeak.cpp
|
||||
+++ b/stardict-plugins/stardict-espeak-tts-plugin/stardict_espeak.cpp
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "stardict_espeak.h"
|
||||
+#include <cstring>
|
||||
#include <espeak/speak_lib.h>
|
||||
#include <glib/gi18n.h>
|
||||
|
||||
diff --git a/stardict-plugins/stardict-gucharmap-plugin/stardict_gucharmap.cpp b/stardict-plugins/stardict-gucharmap-plugin/stardict_gucharmap.cpp
|
||||
index f522e07..855c5fd 100644
|
||||
--- a/stardict-plugins/stardict-gucharmap-plugin/stardict_gucharmap.cpp
|
||||
+++ b/stardict-plugins/stardict-gucharmap-plugin/stardict_gucharmap.cpp
|
||||
@@ -1,7 +1,8 @@
|
||||
#include "stardict_gucharmap.h"
|
||||
#include <glib/gi18n.h>
|
||||
#include <gucharmap/gucharmap.h>
|
||||
-#include <string>
|
||||
+#include <cstring>
|
||||
+#include <cstdlib>
|
||||
|
||||
static char *build_dictdata(char type, const char *definition)
|
||||
{
|
||||
diff --git a/stardict-plugins/stardict-html-parsedata-plugin/stardict_html_parsedata.cpp b/stardict-plugins/stardict-html-parsedata-plugin/stardict_html_parsedata.cpp
|
||||
index 8bb78e8..1803299 100644
|
||||
--- a/stardict-plugins/stardict-html-parsedata-plugin/stardict_html_parsedata.cpp
|
||||
+++ b/stardict-plugins/stardict-html-parsedata-plugin/stardict_html_parsedata.cpp
|
||||
@@ -1,4 +1,6 @@
|
||||
#include "stardict_html_parsedata.h"
|
||||
+#include <cstring>
|
||||
+#include <cstdlib>
|
||||
#include <glib/gi18n.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
diff --git a/stardict-plugins/stardict-man-plugin/stardict_man.cpp b/stardict-plugins/stardict-man-plugin/stardict_man.cpp
|
||||
index 1587e46..dfd7560 100644
|
||||
--- a/stardict-plugins/stardict-man-plugin/stardict_man.cpp
|
||||
+++ b/stardict-plugins/stardict-man-plugin/stardict_man.cpp
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "stardict_man.h"
|
||||
#include <glib/gi18n.h>
|
||||
-#include <string>
|
||||
+#include <cstring>
|
||||
|
||||
static const StarDictPluginSystemInfo *plugin_info = NULL;
|
||||
static bool need_prefix;
|
||||
diff --git a/stardict-plugins/stardict-powerword-parsedata-plugin/stardict_powerword_parsedata.cpp b/stardict-plugins/stardict-powerword-parsedata-plugin/stardict_powerword_parsedata.cpp
|
||||
index 068ebbe..4da5c81 100644
|
||||
--- a/stardict-plugins/stardict-powerword-parsedata-plugin/stardict_powerword_parsedata.cpp
|
||||
+++ b/stardict-plugins/stardict-powerword-parsedata-plugin/stardict_powerword_parsedata.cpp
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "stardict_powerword_parsedata.h"
|
||||
+#include <cstring>
|
||||
#include <glib/gi18n.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
diff --git a/stardict-plugins/stardict-qqwry-plugin/stardict_qqwry.cpp b/stardict-plugins/stardict-qqwry-plugin/stardict_qqwry.cpp
|
||||
index 65234dc..b5a7046 100644
|
||||
--- a/stardict-plugins/stardict-qqwry-plugin/stardict_qqwry.cpp
|
||||
+++ b/stardict-plugins/stardict-qqwry-plugin/stardict_qqwry.cpp
|
||||
@@ -1,7 +1,8 @@
|
||||
#include "stardict_qqwry.h"
|
||||
#include <glib/gi18n.h>
|
||||
#include <glib/gstdio.h>
|
||||
-#include <string>
|
||||
+#include <cstring>
|
||||
+#include <cstdlib>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
diff --git a/stardict-plugins/stardict-spell-plugin/stardict_spell.cpp b/stardict-plugins/stardict-spell-plugin/stardict_spell.cpp
|
||||
index af3e8ae..d5e66af 100644
|
||||
--- a/stardict-plugins/stardict-spell-plugin/stardict_spell.cpp
|
||||
+++ b/stardict-plugins/stardict-spell-plugin/stardict_spell.cpp
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "stardict_spell.h"
|
||||
+#include <cstring>
|
||||
#include <glib.h>
|
||||
#include <glib/gi18n.h>
|
||||
#include <enchant.h>
|
||||
diff --git a/stardict-plugins/stardict-wiki-parsedata-plugin/stardict_wiki2xml.cpp b/stardict-plugins/stardict-wiki-parsedata-plugin/stardict_wiki2xml.cpp
|
||||
index 0cfade9..f1a0277 100644
|
||||
--- a/stardict-plugins/stardict-wiki-parsedata-plugin/stardict_wiki2xml.cpp
|
||||
+++ b/stardict-plugins/stardict-wiki-parsedata-plugin/stardict_wiki2xml.cpp
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "stardict_wiki2xml.h"
|
||||
#include "WIKI2XML.h"
|
||||
+#include <cstring>
|
||||
#include <glib.h>
|
||||
|
||||
std::string wiki2xml(std::string &str)
|
||||
diff --git a/stardict-plugins/stardict-wiki-parsedata-plugin/stardict_wiki_parsedata.cpp b/stardict-plugins/stardict-wiki-parsedata-plugin/stardict_wiki_parsedata.cpp
|
||||
index fdf5270..8a6f7b0 100644
|
||||
--- a/stardict-plugins/stardict-wiki-parsedata-plugin/stardict_wiki_parsedata.cpp
|
||||
+++ b/stardict-plugins/stardict-wiki-parsedata-plugin/stardict_wiki_parsedata.cpp
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "stardict_wiki_parsedata.h"
|
||||
#include "stardict_wiki2xml.h"
|
||||
+#include <cstring>
|
||||
#include <glib/gi18n.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
diff --git a/stardict-plugins/stardict-wordnet-plugin/court_widget.cpp b/stardict-plugins/stardict-wordnet-plugin/court_widget.cpp
|
||||
index 37b227e..1e49f90 100644
|
||||
--- a/stardict-plugins/stardict-wordnet-plugin/court_widget.cpp
|
||||
+++ b/stardict-plugins/stardict-wordnet-plugin/court_widget.cpp
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "court_widget.h"
|
||||
+#include <cstring>
|
||||
#include <math.h>
|
||||
#include <list>
|
||||
|
||||
diff --git a/stardict-plugins/stardict-wordnet-plugin/stardict_wordnet.cpp b/stardict-plugins/stardict-wordnet-plugin/stardict_wordnet.cpp
|
||||
index 043afaf..bc4c9ff 100644
|
||||
--- a/stardict-plugins/stardict-wordnet-plugin/stardict_wordnet.cpp
|
||||
+++ b/stardict-plugins/stardict-wordnet-plugin/stardict_wordnet.cpp
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "stardict_wordnet.h"
|
||||
#include "court_widget.h"
|
||||
+#include <cstring>
|
||||
#include <glib/gi18n.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
diff --git a/stardict-plugins/stardict-wordnet-plugin/stardict_wordnet_parsedata.cpp b/stardict-plugins/stardict-wordnet-plugin/stardict_wordnet_parsedata.cpp
|
||||
index 9f9ab9f..c5397e1 100644
|
||||
--- a/stardict-plugins/stardict-wordnet-plugin/stardict_wordnet_parsedata.cpp
|
||||
+++ b/stardict-plugins/stardict-wordnet-plugin/stardict_wordnet_parsedata.cpp
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "stardict_wordnet_parsedata.h"
|
||||
+#include <cstring>
|
||||
#include <glib/gi18n.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
diff --git a/stardict-plugins/stardict-xdxf-parsedata-plugin/stardict_xdxf_parsedata.cpp b/stardict-plugins/stardict-xdxf-parsedata-plugin/stardict_xdxf_parsedata.cpp
|
||||
index 905a01d..b143b90 100644
|
||||
--- a/stardict-plugins/stardict-xdxf-parsedata-plugin/stardict_xdxf_parsedata.cpp
|
||||
+++ b/stardict-plugins/stardict-xdxf-parsedata-plugin/stardict_xdxf_parsedata.cpp
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "stardict_xdxf_parsedata.h"
|
||||
+#include <cstring>
|
||||
#include <glib/gi18n.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
diff --git a/tests/t_config_file.cpp b/tests/t_config_file.cpp
|
||||
index 73e2a52..24715cf 100644
|
||||
--- a/tests/t_config_file.cpp
|
||||
+++ b/tests/t_config_file.cpp
|
||||
@@ -8,6 +8,7 @@
|
||||
#include <cstring>
|
||||
#include <iterator>
|
||||
#include <iostream>
|
||||
+#include <memory>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "config_file.hpp"
|
||||
diff --git a/tests/t_xml.cpp b/tests/t_xml.cpp
|
||||
index a20422d..29b3d2a 100644
|
||||
--- a/tests/t_xml.cpp
|
||||
+++ b/tests/t_xml.cpp
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <glib.h>
|
||||
#include <cstdlib>
|
||||
#include <string>
|
||||
+#include <cstring>
|
||||
|
||||
|
||||
static void xml_decode(const char *str, std::string& decoded)
|
504
stardict/patches/002-dont-need-hotkey-in-nanonote.patch
Normal file
504
stardict/patches/002-dont-need-hotkey-in-nanonote.patch
Normal file
@ -0,0 +1,504 @@
|
||||
don't need hotkey in nanonote
|
||||
|
||||
From: Xiangfu Liu <xiangfu@sharism.cc>
|
||||
|
||||
|
||||
---
|
||||
|
||||
configure.in | 2
|
||||
src/class_factory.cpp | 2
|
||||
src/conf.cpp | 6 -
|
||||
src/stardict.cpp | 6 -
|
||||
src/x11_iskeyspressed.cpp | 351 ---------------------------------------------
|
||||
src/x11_iskeyspressed.hpp | 65 --------
|
||||
6 files changed, 8 insertions(+), 424 deletions(-)
|
||||
|
||||
|
||||
diff --git a/configure.in b/configure.in
|
||||
index 83d3d95..3676e2c 100644
|
||||
--- a/configure.in
|
||||
+++ b/configure.in
|
||||
@@ -428,7 +428,7 @@ 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)
|
||||
diff --git a/src/class_factory.cpp b/src/class_factory.cpp
|
||||
index 8bff538..d1dddc2 100644
|
||||
--- a/src/class_factory.cpp
|
||||
+++ b/src/class_factory.cpp
|
||||
@@ -54,7 +54,7 @@ void *PlatformFactory::create_class_by_name(const std::string& name, void *param
|
||||
#ifdef _WIN32
|
||||
return new win32_hotkeys();
|
||||
#else
|
||||
- return new x11_hotkeys(GTK_WINDOW(param));
|
||||
+ return NULL; //new x11_hotkeys(GTK_WINDOW(param));
|
||||
#endif
|
||||
}
|
||||
return NULL;
|
||||
diff --git a/src/conf.cpp b/src/conf.cpp
|
||||
index 2d0f89d..a35bc5c 100644
|
||||
--- a/src/conf.cpp
|
||||
+++ b/src/conf.cpp
|
||||
@@ -34,9 +34,9 @@ const int DEFAULT_WINDOW_WIDTH=238;
|
||||
const int DEFAULT_WINDOW_HEIGHT=279;
|
||||
const int DEFAULT_HPANED_POS=79;
|
||||
#else
|
||||
-const int DEFAULT_WINDOW_WIDTH=463;
|
||||
-const int DEFAULT_WINDOW_HEIGHT=321;
|
||||
-const int DEFAULT_HPANED_POS=127;
|
||||
+const int DEFAULT_WINDOW_WIDTH=320;
|
||||
+const int DEFAULT_WINDOW_HEIGHT=240;
|
||||
+const int DEFAULT_HPANED_POS=79;
|
||||
#endif
|
||||
|
||||
std::auto_ptr<AppConf> conf;
|
||||
diff --git a/src/stardict.cpp b/src/stardict.cpp
|
||||
index 326ca4a..4c51d61 100644
|
||||
--- a/src/stardict.cpp
|
||||
+++ b/src/stardict.cpp
|
||||
@@ -351,9 +351,9 @@ void AppCore::Create(gchar *queryword)
|
||||
oTopWin.Create(vbox);
|
||||
oMidWin.Create(vbox);
|
||||
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")));
|
||||
+ //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,
|
||||
diff --git a/src/x11_iskeyspressed.cpp b/src/x11_iskeyspressed.cpp
|
||||
index 15e8fb0..8b13789 100644
|
||||
--- a/src/x11_iskeyspressed.cpp
|
||||
+++ b/src/x11_iskeyspressed.cpp
|
||||
@@ -1,352 +1 @@
|
||||
-/*
|
||||
- * This file part of StarDict - A international dictionary for GNOME.
|
||||
- * http://stardict.sourceforge.net
|
||||
- *
|
||||
- * Copyright (C) 2005 Evgeniy <dushistov@mail.ru>
|
||||
- *
|
||||
- * This program is free software; you can redistribute it and/or modify
|
||||
- * it under the terms of the GNU General Public License as published by
|
||||
- * the Free Software Foundation; either version 3 of the License, or
|
||||
- * (at your option) any later version.
|
||||
- *
|
||||
- * This program is distributed in the hope that it will be useful,
|
||||
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
- * GNU Library General Public License for more details.
|
||||
- *
|
||||
- * You should have received a copy of the GNU General Public License
|
||||
- * along with this program; if not, write to the Free Software
|
||||
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
- */
|
||||
|
||||
-/*
|
||||
- * goal: react on key press even if there are window
|
||||
- * have no focus in XWindows. This code based on xbindkeys.
|
||||
- */
|
||||
-
|
||||
-#ifdef HAVE_CONFIG_H
|
||||
-# include "config.h"
|
||||
-#endif
|
||||
-
|
||||
-#include "gtk_iskeyspressed.hpp"
|
||||
-
|
||||
-#include "x11_iskeyspressed.hpp"
|
||||
-
|
||||
-
|
||||
-
|
||||
-unsigned int x11_hotkeys::numlock_mask, x11_hotkeys::scrolllock_mask,
|
||||
- x11_hotkeys::capslock_mask;
|
||||
-
|
||||
-void x11_hotkeys::get_offending_modifiers(Display * dpy)
|
||||
-{
|
||||
- int i;
|
||||
- XModifierKeymap *modmap;
|
||||
- KeyCode nlock, slock;
|
||||
- static int mask_table[8] = {
|
||||
- ShiftMask, LockMask, ControlMask, Mod1Mask,
|
||||
- Mod2Mask, Mod3Mask, Mod4Mask, Mod5Mask
|
||||
- };
|
||||
-
|
||||
- nlock = XKeysymToKeycode (dpy, XK_Num_Lock);
|
||||
- slock = XKeysymToKeycode (dpy, XK_Scroll_Lock);
|
||||
-
|
||||
- /*
|
||||
- * Find out the masks for the NumLock and ScrollLock modifiers,
|
||||
- * so that we can bind the grabs for when they are enabled too.
|
||||
- */
|
||||
- modmap = XGetModifierMapping (dpy);
|
||||
-
|
||||
- if (modmap != NULL && modmap->max_keypermod > 0) {
|
||||
- for (i = 0; i < 8 * modmap->max_keypermod; i++) {
|
||||
- if (modmap->modifiermap[i] == nlock && nlock != 0)
|
||||
- numlock_mask = mask_table[i / modmap->max_keypermod];
|
||||
- else if (modmap->modifiermap[i] == slock && slock != 0)
|
||||
- scrolllock_mask = mask_table[i / modmap->max_keypermod];
|
||||
- }
|
||||
- }
|
||||
-
|
||||
- capslock_mask = LockMask;
|
||||
-
|
||||
- if (modmap)
|
||||
- XFreeModifiermap (modmap);
|
||||
-}
|
||||
-
|
||||
-void x11_hotkeys::my_grab_key(Display * dpy, KeyCode keycode,
|
||||
- unsigned int modifier, Window win)
|
||||
-{
|
||||
- modifier &= ~(numlock_mask | capslock_mask | scrolllock_mask);
|
||||
-
|
||||
-
|
||||
- XGrabKey(dpy, keycode, modifier, (win ? win : DefaultRootWindow(dpy)),
|
||||
- False, GrabModeAsync, GrabModeAsync);
|
||||
-
|
||||
- if (modifier == AnyModifier)
|
||||
- return;
|
||||
-
|
||||
- if (numlock_mask)
|
||||
- XGrabKey (dpy, keycode, modifier | numlock_mask,
|
||||
- (win ? win : DefaultRootWindow (dpy)),
|
||||
- False, GrabModeAsync, GrabModeAsync);
|
||||
-
|
||||
- if (capslock_mask)
|
||||
- XGrabKey (dpy, keycode, modifier | capslock_mask,
|
||||
- (win ? win : DefaultRootWindow (dpy)),
|
||||
- False, GrabModeAsync, GrabModeAsync);
|
||||
-
|
||||
- if (scrolllock_mask)
|
||||
- XGrabKey (dpy, keycode, modifier | scrolllock_mask,
|
||||
- (win ? win : DefaultRootWindow (dpy)),
|
||||
- False, GrabModeAsync, GrabModeAsync);
|
||||
-
|
||||
- if (numlock_mask && capslock_mask)
|
||||
- XGrabKey (dpy, keycode, modifier | numlock_mask | capslock_mask,
|
||||
- (win ? win : DefaultRootWindow (dpy)),
|
||||
- False, GrabModeAsync, GrabModeAsync);
|
||||
-
|
||||
- if (numlock_mask && scrolllock_mask)
|
||||
- XGrabKey (dpy, keycode, modifier | numlock_mask | scrolllock_mask,
|
||||
- (win ? win : DefaultRootWindow (dpy)),
|
||||
- False, GrabModeAsync, GrabModeAsync);
|
||||
-
|
||||
- if (capslock_mask && scrolllock_mask)
|
||||
- XGrabKey (dpy, keycode, modifier | capslock_mask | scrolllock_mask,
|
||||
- (win ? win : DefaultRootWindow (dpy)),
|
||||
- False, GrabModeAsync, GrabModeAsync);
|
||||
-
|
||||
- if (numlock_mask && capslock_mask && scrolllock_mask)
|
||||
- XGrabKey (dpy, keycode,
|
||||
- modifier | numlock_mask | capslock_mask | scrolllock_mask,
|
||||
- (win ? win : DefaultRootWindow (dpy)), False, GrabModeAsync,
|
||||
- GrabModeAsync);
|
||||
-
|
||||
-}
|
||||
-
|
||||
-
|
||||
-void x11_hotkeys::my_grab_button(Display * dpy, unsigned int button,
|
||||
- unsigned int modifier, Window win)
|
||||
-{
|
||||
- modifier &= ~(numlock_mask | capslock_mask | scrolllock_mask);
|
||||
-
|
||||
- XGrabButton (dpy, button, modifier, (win ? win : DefaultRootWindow (dpy)),
|
||||
- False, ButtonPressMask | ButtonReleaseMask,
|
||||
- GrabModeAsync, GrabModeAsync, None, None);
|
||||
-
|
||||
- if (modifier == AnyModifier)
|
||||
- return;
|
||||
-
|
||||
- if (numlock_mask)
|
||||
- XGrabButton (dpy, button, modifier | numlock_mask,
|
||||
- (win ? win : DefaultRootWindow (dpy)),
|
||||
- False, ButtonPressMask | ButtonReleaseMask,
|
||||
- GrabModeAsync, GrabModeAsync, None, None);
|
||||
-
|
||||
-
|
||||
- if (capslock_mask)
|
||||
- XGrabButton (dpy, button, modifier | capslock_mask,
|
||||
- (win ? win : DefaultRootWindow (dpy)),
|
||||
- False, ButtonPressMask | ButtonReleaseMask,
|
||||
- GrabModeAsync, GrabModeAsync, None, None);
|
||||
-
|
||||
- if (scrolllock_mask)
|
||||
- XGrabButton (dpy, button, modifier | scrolllock_mask,
|
||||
- (win ? win : DefaultRootWindow (dpy)),
|
||||
- False, ButtonPressMask | ButtonReleaseMask,
|
||||
- GrabModeAsync, GrabModeAsync, None, None);
|
||||
-
|
||||
- if (numlock_mask && capslock_mask)
|
||||
- XGrabButton (dpy, button, modifier | numlock_mask | capslock_mask,
|
||||
- (win ? win : DefaultRootWindow (dpy)),
|
||||
- False, ButtonPressMask | ButtonReleaseMask,
|
||||
- GrabModeAsync, GrabModeAsync, None, None);
|
||||
-
|
||||
- if (numlock_mask && scrolllock_mask)
|
||||
- XGrabButton (dpy, button, modifier | numlock_mask | scrolllock_mask,
|
||||
- (win ? win : DefaultRootWindow (dpy)),
|
||||
- False, ButtonPressMask | ButtonReleaseMask,
|
||||
- GrabModeAsync, GrabModeAsync, None, None);
|
||||
-
|
||||
- if (capslock_mask && scrolllock_mask)
|
||||
- XGrabButton (dpy, button, modifier | capslock_mask | scrolllock_mask,
|
||||
- (win ? win : DefaultRootWindow (dpy)),
|
||||
- False, ButtonPressMask | ButtonReleaseMask,
|
||||
- GrabModeAsync, GrabModeAsync, None, None);
|
||||
-
|
||||
- if (numlock_mask && capslock_mask && scrolllock_mask)
|
||||
- XGrabButton (dpy, button,
|
||||
- modifier | numlock_mask | capslock_mask | scrolllock_mask,
|
||||
- (win ? win : DefaultRootWindow (dpy)), False,
|
||||
- ButtonPressMask | ButtonReleaseMask, GrabModeAsync,
|
||||
- GrabModeAsync, None, None);
|
||||
-}
|
||||
-
|
||||
-bool x11_hotkeys::grab_keys(Display *dpy, Keys_t keys[], int nb_keys)
|
||||
-{
|
||||
- int i;
|
||||
- int min, max;
|
||||
- int screen;
|
||||
-
|
||||
-
|
||||
- XDisplayKeycodes(dpy, &min, &max);
|
||||
-
|
||||
-#ifdef DEBUG
|
||||
- printf("\n");
|
||||
- printf("min_keycode=%d max_keycode=%d (ie: know keycodes)\n",
|
||||
- min, max);
|
||||
-#endif
|
||||
-
|
||||
-
|
||||
- for (i = 0; i < nb_keys; i++) {
|
||||
-#ifdef DEBUG
|
||||
- print_key(dpy, &keys[i]);
|
||||
-#endif
|
||||
- if (keys[i].type == SYM) {
|
||||
- for (screen = 0; screen < ScreenCount (dpy); screen++) {
|
||||
- my_grab_key(dpy, XKeysymToKeycode(dpy, keys[i].key.sym),
|
||||
- keys[i].modifier, RootWindow(dpy, screen));
|
||||
- }
|
||||
- } else if (keys[i].type == BUTTON) {
|
||||
- for (screen = 0; screen < ScreenCount (dpy); screen++) {
|
||||
- my_grab_button(dpy, keys[i].key.button, keys[i].modifier,
|
||||
- RootWindow (dpy, screen));
|
||||
- }
|
||||
- } else {
|
||||
- if (keys[i].key.code >= min && keys[i].key.code <= max) {
|
||||
- for (screen = 0; screen < ScreenCount (dpy); screen++) {
|
||||
- my_grab_key (dpy, keys[i].key.code, keys[i].modifier,
|
||||
- RootWindow (dpy, screen));
|
||||
- }
|
||||
- } else {
|
||||
-#ifdef DEBUG
|
||||
- print_key (dpy, &keys[i]);
|
||||
-
|
||||
-
|
||||
- fprintf (stderr,
|
||||
- " The keycode %d cannot be used, as it's not between the\n"
|
||||
- " min(%d) and max(%d) keycode of your keyboard.\n"
|
||||
- " Please increase the 'maximum' value in\n"
|
||||
- " /usr/X11R6/lib/X11/xkb/keycodes/xfree86,\n"
|
||||
- " then restart X.\n", keys[i].key.code, min, max);
|
||||
-#endif
|
||||
- return false;
|
||||
- }
|
||||
- }
|
||||
- }
|
||||
-
|
||||
- return true;
|
||||
-}
|
||||
-
|
||||
-
|
||||
-x11_hotkeys::x11_hotkeys(GtkWindow *win_) :
|
||||
- win(win_),
|
||||
- pressed(false),
|
||||
- def_hot_keys(new gtk_hotkeys(win_))
|
||||
-{
|
||||
- possb_combs=def_hot_keys->possible_combs();
|
||||
- possb_combs.push_back("Ctrl+e");
|
||||
- possb_combs.push_back("F1");
|
||||
- possb_combs.push_back("F2");
|
||||
- possb_combs.push_back("F3");
|
||||
- possb_combs.push_back("F4");
|
||||
- display=gdk_x11_display_get_xdisplay(gdk_screen_get_display(gtk_window_get_screen(win)));
|
||||
- get_offending_modifiers(display);
|
||||
- gdk_window_add_filter(NULL, GdkFilterFunc(key_filter), this);
|
||||
-}
|
||||
-
|
||||
-x11_hotkeys::~x11_hotkeys()
|
||||
-{
|
||||
- ungrabkeys();
|
||||
-}
|
||||
-
|
||||
-const std::list<std::string>& x11_hotkeys::possible_combs()
|
||||
-{
|
||||
- return possb_combs;
|
||||
-}
|
||||
-
|
||||
-void x11_hotkeys::set_comb(const std::string& val)
|
||||
-{
|
||||
- if (comb==val)
|
||||
- return;
|
||||
-
|
||||
- unsigned int modifier=0;
|
||||
- KeySym key=0;
|
||||
- std::string::size_type pos=std::string::npos;
|
||||
-
|
||||
- do {
|
||||
- std::string::size_type prev_pos=pos;
|
||||
- pos=val.find('+', pos+1);
|
||||
- std::string cur;
|
||||
- if (pos!=std::string::npos)
|
||||
- cur.assign(val, prev_pos+1, pos-prev_pos-1);
|
||||
- else
|
||||
- cur.assign(val, prev_pos+1, val.length()-prev_pos-1);
|
||||
- if (cur=="Ctrl") {
|
||||
- modifier|=ControlMask;
|
||||
- } else if (cur=="Alt") {
|
||||
- modifier|=Mod1Mask;
|
||||
- } else if (cur=="Shift") {
|
||||
- modifier|=ShiftMask;
|
||||
- } else if (cur=="Win") {
|
||||
- modifier|=Mod4Mask;
|
||||
- } else {
|
||||
- key=XStringToKeysym(cur.c_str());
|
||||
- }
|
||||
- } while (pos!=std::string::npos);
|
||||
-
|
||||
- comb=val;
|
||||
- pressed=false;
|
||||
- grab_key.key.sym=0;
|
||||
- if (key!=0) {
|
||||
- ungrabkeys();
|
||||
- grab_key.type=SYM;
|
||||
- grab_key.event_type=PRESS;
|
||||
- grab_key.key.sym=key;
|
||||
- grab_key.modifier=modifier;
|
||||
- grab_keys(display, &grab_key, 1);
|
||||
- } else
|
||||
- def_hot_keys->set_comb(val);
|
||||
-}
|
||||
-
|
||||
-bool x11_hotkeys::is_pressed()
|
||||
-{
|
||||
- if (grab_key.key.sym!=0)
|
||||
- return pressed;
|
||||
-
|
||||
- return def_hot_keys->is_pressed();
|
||||
-}
|
||||
-
|
||||
-void x11_hotkeys::ungrabkeys()
|
||||
-{
|
||||
- if (grab_key.key.sym==0)
|
||||
- return;
|
||||
- Display *d=display;
|
||||
-
|
||||
- for (int screen = 0; screen<ScreenCount(d); screen++) {
|
||||
- XUngrabKey(d, AnyKey, AnyModifier, RootWindow (d, screen));
|
||||
- XUngrabButton(d, AnyButton, AnyModifier, RootWindow (d, screen));
|
||||
- }
|
||||
-}
|
||||
-
|
||||
-GdkFilterReturn x11_hotkeys::key_filter(GdkXEvent *gdk_xevent,
|
||||
- GdkEvent *event,
|
||||
- x11_hotkeys *th)
|
||||
-{
|
||||
- int type;
|
||||
- XKeyEvent *xevent;
|
||||
-
|
||||
- xevent = (XKeyEvent *)gdk_xevent;
|
||||
- type = xevent->type;
|
||||
- KeySym keysym = XKeycodeToKeysym(GDK_DISPLAY(), ((XKeyEvent *)xevent)->keycode, 0);
|
||||
- unsigned int state=xevent->state;
|
||||
- state &= ~(numlock_mask | capslock_mask | scrolllock_mask);
|
||||
- if (type == KeyPress) {
|
||||
- if (keysym==th->grab_key.key.sym && state==th->grab_key.modifier) {
|
||||
- th->pressed=true;
|
||||
- }
|
||||
- } else if (type==KeyRelease) {
|
||||
- if (keysym==th->grab_key.key.sym) {
|
||||
- th->pressed=false;
|
||||
- }
|
||||
- }
|
||||
-
|
||||
- return GDK_FILTER_CONTINUE;
|
||||
-}
|
||||
diff --git a/src/x11_iskeyspressed.hpp b/src/x11_iskeyspressed.hpp
|
||||
index f7391ad..8b13789 100644
|
||||
--- a/src/x11_iskeyspressed.hpp
|
||||
+++ b/src/x11_iskeyspressed.hpp
|
||||
@@ -1,66 +1 @@
|
||||
-#ifndef _X11_ISKEYSPRESSED_HPP_
|
||||
-#define _X11_ISKEYSPRESSED_HPP_
|
||||
|
||||
-#include <memory>
|
||||
-
|
||||
-#include <gdk/gdkx.h>
|
||||
-#include <X11/keysym.h>
|
||||
-#include <gtk/gtk.h>
|
||||
-
|
||||
-#include "iskeyspressed.hpp"
|
||||
-
|
||||
-typedef enum { SYM, CODE, BUTTON } KeyType_t;
|
||||
-typedef enum { PRESS, RELEASE } EventType_t;
|
||||
-
|
||||
-struct Keys_t {
|
||||
-
|
||||
- KeyType_t type;
|
||||
-
|
||||
- EventType_t event_type;
|
||||
-
|
||||
- union {
|
||||
- KeySym sym;
|
||||
- KeyCode code;
|
||||
- unsigned int button;
|
||||
- } key;
|
||||
-
|
||||
- unsigned int modifier;
|
||||
-
|
||||
- Keys_t(KeyType_t t=SYM, EventType_t et=PRESS, KeySym s=0, unsigned int m=0) :
|
||||
- type(t), event_type(et), modifier(m)
|
||||
- {
|
||||
- key.sym=s;
|
||||
- }
|
||||
-};
|
||||
-
|
||||
-class x11_hotkeys : public hotkeys {
|
||||
-public:
|
||||
- x11_hotkeys(GtkWindow *win_);
|
||||
- ~x11_hotkeys();
|
||||
- const std::list<std::string>& possible_combs();
|
||||
- void set_comb(const std::string& comb);
|
||||
- bool is_pressed();
|
||||
-private:
|
||||
- std::string comb;
|
||||
- GtkWindow *win;
|
||||
- bool pressed;
|
||||
- Keys_t grab_key;
|
||||
- std::list<std::string> possb_combs;
|
||||
- std::auto_ptr<hotkeys> def_hot_keys;/*I don't want to duplicate work,
|
||||
- so hold here pointer to default
|
||||
- object of this class*/
|
||||
- Display *display;
|
||||
- static unsigned int numlock_mask, scrolllock_mask, capslock_mask;
|
||||
-
|
||||
- static GdkFilterReturn key_filter(GdkXEvent *gdk_xevent,
|
||||
- GdkEvent *event, x11_hotkeys *th);
|
||||
- void ungrabkeys(void);
|
||||
- static void get_offending_modifiers(Display * dpy);
|
||||
- static void my_grab_key(Display * dpy, KeyCode keycode,
|
||||
- unsigned int modifier, Window win);
|
||||
- static void my_grab_button(Display * dpy, unsigned int button,
|
||||
- unsigned int modifier, Window win);
|
||||
- static bool grab_keys(Display *dpy, Keys_t keys[], int nb_keys);
|
||||
-};
|
||||
-
|
||||
-#endif//!_X11_ISKEYSPRESSED_HPP_
|
Loading…
Reference in New Issue
Block a user