From 5f667f41c4dcb111f1639a8b4c3a2f70ff05d957 Mon Sep 17 00:00:00 2001 From: Paul Goins Date: Sun, 16 Nov 2008 09:04:30 +0900 Subject: [PATCH] Windows Makefile/NSI installer updates (Internet downloading!) plus bugfixes Details: * Makefile.win updated for current build environment, with lots of notes added about how to successfully build on Windows... Still -not- a fun or easy process, though. * installer.nsi updated to support internet downloading of optional dictionaries and stroke order diagrams and unzipping of optional packages. EDICT2 and KANJIDIC are included in the installer without downloading, while KANJIDIC2 and both stroke order diagram packages are downloaded if the user desires them. Source packages can also be installed through the Windows installer. * SOD checkboxes are not auto-greyed in dialog_config. This is because the flags they represented were not being cleared when SOD files were not found. This is essentially a workaround until I solve the problem more gracefully. * Bugfix in dialog_kanjitest: preference keys kanjitest.kanji{read,write} changed to kanjitest.{reading,writing}. * kdict.cpp: Since GTKTextViews don't support animated SODs, only static SODs are used. Animated SODs may still be used in the kanji test mode since the images are displayed using a different GTK control which allows animation. * Small string changes in dialog_config, mainly to reflect the change in kdict.cpp * Small change to widget_kanjihwpad, made while tracking down a Windows-specific error. The changes are not vital, but I'm leaving them in. --- src/Makefile.win | 80 +++++++++++++++++-------- src/dialog_config.cpp | 9 ++- src/dialog_kanjitest.cpp | 12 ++-- src/installer.nsi | 147 +++++++++++++++++++++++++++++++++++++--------- src/kdict.cpp | 7 +++ src/widget_kanjihwpad.cpp | 15 ++++- 6 files changed, 207 insertions(+), 63 deletions(-) diff --git a/src/Makefile.win b/src/Makefile.win index be1b1f0..03ffdac 100644 --- a/src/Makefile.win +++ b/src/Makefile.win @@ -3,7 +3,7 @@ # binary if at all possible. # # Windows builds expect MinGW WITH MSys, -# one of the gcc 4 compilers (for wstrings), +# a -not broken- gcc 4 compiler (for wstrings) (4.3.0 alpha does NOT work!), # plus 7-Zip, NSIS and GTK binaries in your path for "make install". # PKG_CONFIG_PATH must also be set appropriately. # @@ -11,17 +11,30 @@ # # LAST SUCCESSFUL BUILD used: # MinGW -# * MinGW-5.1.4.exe (automated installer) -# * update: gcc-4.3.0-20080502-mingw32-alpha-bin.7z +# * MinGW-5.1.4.exe (automated installer), using current release install, +# minimum plus g++ install +# * update: gcc-{core,g++}-4.2.1-sjlj-2.tar.gz # (updated GCC with wstrings and TR1 hash maps) +# ***IMPORTANT***: Compiled all code using "export CC=gcc-sjlj CXX=g++-sjlj". +# (Otherwise, the regular 3.x gcc would be used.) # MSys -# * MSYS-1.0.10.exe -# * Updates: installed all known MSYS updates, from oldest to newest, being -# careful not to overwrite newer files -# GTKmm: gtkmm-win32-devel-2.14.1-3.exe (includes gtk dev environment as well) +# * Install MSYS-1.0.10.exe, then add in msysCORE-1.0.11-20080826.tar.gz. +# If you don't do this, then once you reach pangomm you'll have configure +# errors. +# GTK+ package: gtk-2.14.1 all-in-one development bundle +# * Need to add the bin folder to your PATH, so pkg-config will work right! +# GTKmm-related packages +# * libsigc++-2.2.3 +# * glibmm-2.18.1 +# * cairomm-1.7.0 +# * pangomm-2.14.1 +# * gtkmm-2.14.3 +# (Built from source, -in the above order-. Refer to +# http://live.gnome.org/gtkmm/MSWindows/BuildingGtkmm for full details. +# Again, remember to "export CC=gcc-sjlj CXX=g++-sjlj" before building!) # Boost: boost_1_37_0.7z # * The Boost::Regex library must be built. See the note below. -# libxml2: libxml2-2.7.2.win32.zip +# libxml2: libxml2-2.7.2.win32.zip # libiconv: iconv-1.9.2-1-bin.zip and iconv-1.9.2-1-lib.zip # (Extract to the same folder) # zlib: zlib123-dll.zip @@ -30,9 +43,10 @@ # # Sources for these files: # http://mingw.sourceforge.net/: MinGW homepage (MSys is here, too) -# http://live.gnome.org/gtkmm/MSWindows: gtkmm runtime and development binaries +# http://www.gtk.org/: gtk+ all-in-one dev package +# http://www.gtkmm.org/: gtkmm source code # http://www.boost.org/: Boost libraries -# http://www.zlatkovic.com/libxml.en.html: libxml2 for Windows +# http://www.zlatkovic.com/libxml.en.html: libxml2 for Windows # http://gnuwin32.sourceforge.net/packages/libiconv.htm: libiconv for Windows # http://www.zlib.net/: zlib library; look for "zlib compiled DLL" # @@ -52,11 +66,17 @@ # NOTES TO SELF: # On library/GUI split, these things will (eventually) need to be taken care of: -# 1. libxml2: It seems like having a separate libxml2 package conflicts with the -# one supplied by GTKmm. For now, we'll just use GTKmm's stuff. -# 2. gettext: handled by GTKmm's i18n package, but will need to be handled +# 1. gettext: handled by GTKmm's i18n package, but will need to be handled # manually when the core is separated into a dll. +# BEFORE BUILDING: +# PKG_CONFIG_PATH must be set properly. Include both GTK's and libxml's +# pkgconfig files in the path. +# (Example: export PKG_CONFIG_PATH=/local/lib/pkgconfig:/c/devel/libxml2-2.7.2.win32/lib/pkgconfig) +# +# COMMAND TO EXECUTE BUILD: make -f Makefile.win CC=gcc-sjlj CXX=g++-sjlj +# (If CC/CXX are not explicitly specified like this, then don't expect to get +# very far. ;) ) # === MAKEFILE BEGINS HERE === @@ -76,27 +96,39 @@ CC = gcc mingwbase = C:/MinGW # Library base directories -gtkmmbase = C:/devel/GTKmm-2.14.1 +gtkbase = C:/devel/gtk-2.14.1 zlibbase = C:/devel/zlib123-dll iconvbase = C:/devel/libiconv-1.9.2-1 boostbase = C:/devel/boost_1_37_0 -#xmlbase = C:/devel/libxml2-2.7.2.win32 +xmlbase = C:/devel/libxml2-2.7.2.win32 + +# No libxml-2.0.pc is included with the official libxml2 port. +# Follow the procedure on +# http://www.go-evolution.org/Building_Evolution_on_Windows#libxml2 +# for writing the file, plus for making a proper ".a" link lib. # Direct lib paths (for non-gcc-style names) -#libxml = $(xmlbase)/lib/libxml2.lib libzlib = $(zlibbase)/lib/zdll.lib -libboost_regex = $(boostbase)/stage/lib/libboost_regex-mgw43-mt-1_37.lib -#The below should be a direct path to the boost::regex library -#The below variables point towards the path to a configured, -#redistributable GTK/GTKmm environment. It's used by the Windows -#"make install" target. If you need help setting this up, contact the -#author directly. +#libxml = $(xmlbase)/lib/libxml2.lib +# The below should be a direct path to the boost::regex library. +# Note: There's release/debug versions, with multithreading, static runtime +# linking, both, and neither. Lots of options! I -think- runtime link +# static does static linking to the C library or something like that... so +# let's link just the multithreaded, no linked runtime version. +# (Decision based on reading thread at +# http://osdir.com/ml/lib.boost.build/2002-12/msg00062.html) +libboost_regex = C:/devel/boost_bin_1_37_0/boost/bin.v2/libs/regex/build/gcc-mingw-4.2.1/release/link-static/threading-multi/libboost_regex-mgw42-mt-1_37.lib + +# The below variables point towards the path to a configured, +# redistributable GTK/GTKmm environment. It's used by the Windows +# "make install" target. If you need help setting this up, see this article: +# http://live.gnome.org/gtkmm/MSWindows gtkredist = C:/gtk-redist #===LEAVE THESE ALONE=== -SharedCXXFLAGS = -I$(zlibbase)/include -I$(iconvbase)/include -I$(boostbase) -I$(gtkmmbase)/include `pkg-config --cflags libxml-2.0 gtkmm-2.4` +SharedCXXFLAGS = -I$(zlibbase)/include -I$(iconvbase)/include -I$(boostbase) -I$(gtkbase)/include `pkg-config --cflags gtkmm-2.4 libxml-2.0` SharedCPPFLAGS = -D__WIN32__ -libs = $(libzlib) -L$(iconvbase)/lib -liconv.dll $(libboost_regex) `pkg-config --libs libxml-2.0 gtkmm-2.4` -mwindows +libs = $(libzlib) -L$(iconvbase)/lib -liconv.dll $(libboost_regex) `pkg-config --libs gtkmm-2.4 libxml-2.0` -mwindows ########################################## # DO NOT EDIT BEYOND THIS POINT! # # (Unless you know what you're doing ;)) # diff --git a/src/dialog_config.cpp b/src/dialog_config.cpp index d704f3e..c723db3 100644 --- a/src/dialog_config.cpp +++ b/src/dialog_config.cpp @@ -50,8 +50,8 @@ DialogConfig::DialogConfig(Gtk::Window& parent) "which use the kanji")), chkLowImp(_("Other information (Radical #'s, " "Korean and Pinyin romanization)")), - chkSodStatic(_("Use KanjiCafe.com stroke order diagrams")), - chkSodAnim(_("Use KanjiCafe.com animated stroke order diagrams")), + chkSodStatic(_("Use stroke order diagrams if present")), + chkSodAnim(_("Use animated stroke order diagrams if present (tests only)")), tblFonts(4, 3), lblJaNormal(_("Japanese Font, Normal")), lblJaLarge (_("Japanese Font, Large")), @@ -337,7 +337,11 @@ void DialogConfig::Update() { chkSodStatic .set_active(options & KDO_SOD_STATIC); chkSodAnim .set_active(options & KDO_SOD_ANIM); +#if 0 /* Enable/disable SOD/SODA checkboxes based on existance of directory */ + /* (DISABLED for now; J-Ben should auto-disable the flag if dicts + are not found, but obviously that needs to be done in the prefs + loader. I'll add that later.) */ string sodDir = Preferences::Get()->GetSetting("sod_dir"); chkSodStatic.set_sensitive( FileExists( @@ -353,6 +357,7 @@ void DialogConfig::Update() { .append("soda-utf8-hex") .append(1,DSCHAR) .append("README-License").c_str())); +#endif for(size_t i=0;iset_active(dictionaries & (1ul << i)); diff --git a/src/dialog_kanjitest.cpp b/src/dialog_kanjitest.cpp index 62da8e6..a00dd1e 100644 --- a/src/dialog_kanjitest.cpp +++ b/src/dialog_kanjitest.cpp @@ -236,19 +236,19 @@ void DialogKanjiTest::ShowNextKanji() { switch(testMode) { case DKT_TM_Reading: ctvKanji.Show(); - if (prefs->GetSetting("kanjitest.kanjiread.showenglish")=="true") + if (prefs->GetSetting("kanjitest.reading.showenglish")=="true") ctvMeaning.Show(); - if (prefs->GetSetting("kanjitest.kanjiread.showkunyomi")=="true") + if (prefs->GetSetting("kanjitest.reading.showkunyomi")=="true") ctvKunyomi.Show(); - if (prefs->GetSetting("kanjitest.kanjiread.showonyomi")=="true") + if (prefs->GetSetting("kanjitest.reading.showonyomi")=="true") ctvOnyomi.Show(); break; case DKT_TM_Writing: - if (prefs->GetSetting("kanjitest.kanjiwrite.showenglish")=="true") + if (prefs->GetSetting("kanjitest.writing.showenglish")=="true") ctvMeaning.Show(); - if (prefs->GetSetting("kanjitest.kanjiwrite.showkunyomi")=="true") + if (prefs->GetSetting("kanjitest.writing.showkunyomi")=="true") ctvKunyomi.Show(); - if (prefs->GetSetting("kanjitest.kanjiwrite.showonyomi")=="true") + if (prefs->GetSetting("kanjitest.writing.showonyomi")=="true") ctvOnyomi.Show(); break; } diff --git a/src/installer.nsi b/src/installer.nsi index 3c6ca27..77e3563 100644 --- a/src/installer.nsi +++ b/src/installer.nsi @@ -1,3 +1,5 @@ +# This installer requires a version of NSIS with NSISdl support (any recent one), +# plus the ZipDLL plugin. Name "J-Ben ${version}" OutFile "..\archives\${version}\J-Ben_${version}_Installer.exe" InstallDir $PROGRAMFILES\J-Ben @@ -39,13 +41,10 @@ Section "!J-Ben Core" File /r "..\J-Ben\share" # Program Files\J-Ben\dicts - # Although the user could add their own dictionaries one-by-one, - # I think we can safely use /r here on installation and removal. - File /r "..\J-Ben\dicts" + SetOutPath "$INSTDIR\dicts" + File "..\J-Ben\dicts\README" # Program Files\J-Ben\sods - # No SODs are loaded by default; this is an optional component. - # The only file to be copied is a readme. SetOutPath "$INSTDIR\sods" File "..\J-Ben\sods\README" @@ -65,7 +64,48 @@ Section "!J-Ben Core" WriteUninstaller "$INSTDIR\uninstall.exe" SectionEnd -Section "J-Ben Documentation" +SectionGroup "Dictionary Files" + Section "EDICT2" + SetOutPath "$INSTDIR\dicts" + File "..\J-Ben\dicts\edict2.gz" + SectionEnd + Section "KANJIDIC" + SetOutPath "$INSTDIR\dicts" + File "..\J-Ben\dicts\kanjidic.gz" + SectionEnd + Section /o "KANJIDIC2 (Download)" + SetOutPath "$INSTDIR\dicts" + NSISdl::download http://www.vultaire.net/software/jben/files/dicts/kanjidic2.xml.gz kanjidic2.xml.gz + Pop $R0 + StrCmp $R0 "success" +2 + MessageBox MB_OK "The installer was unable to download KANJIDIC2. Installation will continue, but the program may not work properly." + SectionEnd +SectionGroupEnd + +SectionGroup "Stroke Order Diagrams (Download)" + Section /o "KanjiCafe.com SODs" + SetOutPath "$INSTDIR\sods" + NSISdl::download http://www.vultaire.net/software/jben/files/sods/sod-utf8-hex.zip sod-utf8-hex.zip + Pop $R0 + StrCmp $R0 "success" +3 + MessageBox MB_OK "The installer was unable to download the KanjiCafe.com SODs. Installation will continue without them." + Return + ZipDLL::extractall "sod-utf8-hex.zip" "$INSTDIR\sods" + Delete "sod-utf8-hex.zip" + SectionEnd + Section /o "KanjiCafe.com Animated SODs" + SetOutPath "$INSTDIR\sods" + NSISdl::download http://www.vultaire.net/software/jben/files/sods/soda-utf8-hex.zip soda-utf8-hex.zip + Pop $R0 + StrCmp $R0 "success" +3 + MessageBox MB_OK "The installer was unable to download the KanjiCafe.com animated SODs. Installation will continue without them." + Return + ZipDLL::extractall "soda-utf8-hex.zip" "$INSTDIR\sods" + Delete "soda-utf8-hex.zip" + SectionEnd +SectionGroupEnd + +Section "Documentation" # Program Files\J-Ben SetOutPath "$INSTDIR" # The following folders will always be added/removed in full, @@ -73,23 +113,30 @@ Section "J-Ben Documentation" File /r "..\J-Ben\doc" SectionEnd -Section "Create Start Menu Icons" - SetOutPath "$INSTDIR\bin" - CreateDirectory "$SMPROGRAMS\J-Ben" - CreateShortcut "$SMPROGRAMS\J-Ben\J-Ben.lnk" "$INSTDIR\bin\jben.exe" - CreateShortcut "$SMPROGRAMS\J-Ben\Uninstall J-Ben.lnk" "$INSTDIR\uninstall.exe" +Section /o "Source code (Download)" + SetOutPath "$INSTDIR\src" + NSISdl::download http://www.vultaire.net/software/jben/files/${version}/jben-${version}-source.zip source.zip + Pop $R0 + StrCmp $R0 "success" +3 + MessageBox MB_OK "The installer was unable to download the J-Ben source code package. Installation will continue without it." + Return + ZipDLL::extractall "source.zip" "$INSTDIR\src" + Delete "source.zip" SectionEnd -Section "Create Desktop Icon" - SetOutPath "$INSTDIR\bin" - CreateShortcut "$DESKTOP\J-Ben.lnk" "$INSTDIR\bin\jben.exe" -SectionEnd - -;Section "J-Ben Documentation" -;SectionEnd +SectionGroup "Shortcuts" + Section "Create Start Menu Shortcuts" + SetOutPath "$INSTDIR\bin" + CreateDirectory "$SMPROGRAMS\J-Ben" + CreateShortcut "$SMPROGRAMS\J-Ben\J-Ben.lnk" "$INSTDIR\bin\jben.exe" + CreateShortcut "$SMPROGRAMS\J-Ben\Uninstall J-Ben.lnk" "$INSTDIR\uninstall.exe" + SectionEnd -;Section "J-Ben Source Code" -;SectionEnd + Section "Create Desktop Shortcut" + SetOutPath "$INSTDIR\bin" + CreateShortcut "$DESKTOP\J-Ben.lnk" "$INSTDIR\bin\jben.exe" + SectionEnd +SectionGroupEnd Section "un.J-Ben Core" # Program Files\J-Ben @@ -106,14 +153,8 @@ Section "un.J-Ben Core" RMDir /r "$INSTDIR\license" RMDir /r "$INSTDIR\share" - # Program Files\J-Ben\dicts - # Although the user could add their own dictionaries one-by-one, - # I think we can safely use /r here on installation and removal. - RMDir /r "$INSTDIR\dicts" - - # Program Files\J-Ben\sods - # No SODs are loaded by default; this is an optional component. - # The only file to be copied is a readme. + Delete "dicts\README" + RMDir "$INSTDIR\dicts" Delete "sods\README" RMDir "$INSTDIR\sods" @@ -125,6 +166,49 @@ Section "un.J-Ben Core" "Software\Microsoft\Windows\CurrentVersion\Uninstall\J-Ben" SectionEnd +SectionGroup "un.Dictionaries" + Section "un.EDICT2" + SetOutPath "$INSTDIR" + Delete "dicts\edict2.gz" + RMDir "$INSTDIR\dicts" + SetOutPath "$INSTDIR\.." + RMDir "$INSTDIR" + SectionEnd + Section "un.KANJIDIC" + SetOutPath "$INSTDIR" + Delete "dicts\kanjidic.gz" + RMDir "$INSTDIR\dicts" + SetOutPath "$INSTDIR\.." + RMDir "$INSTDIR" + SectionEnd + Section "un.KANJIDIC2" + SetOutPath "$INSTDIR" + Delete "dicts\kanjidic2.xmlgz" + RMDir "$INSTDIR\dicts" + SetOutPath "$INSTDIR\.." + RMDir "$INSTDIR" + SectionEnd +SectionGroupEnd + +SectionGroup "un.Stroke Order Diagrams" + Section "un.KanjiCafe.com SODs" + SetOutPath "$INSTDIR\sods" + RMDir /r "$INSTDIR\sods\sod-utf8-hex" + SetOutPath "$INSTDIR" + RMDir "$INSTDIR\sods" + SetOutPath "$INSTDIR\.." + RMDir "$INSTDIR" + SectionEnd + Section "un.KanjiCafe.com Animated SODs" + SetOutPath "$INSTDIR\sods" + RMDir /r "$INSTDIR\sods\soda-utf8-hex" + SetOutPath "$INSTDIR" + RMDir "$INSTDIR\sods" + SetOutPath "$INSTDIR\.." + RMDir "$INSTDIR" + SectionEnd +SectionGroupEnd + Section "un.J-Ben Documentation" # Program Files\J-Ben SetOutPath "$INSTDIR" @@ -142,3 +226,10 @@ Section "un.Start Menu and Desktop Shortcuts" RMDir "$SMPROGRAMS\J-Ben" Delete "$DESKTOP\J-Ben.lnk" SectionEnd + +Section "un.Source code" + SetOutPath "$INSTDIR" + RMDir /r "$INSTDIR\src" + SetOutPath "$INSTDIR\.." + RMDir "$INSTDIR" +SectionEnd diff --git a/src/kdict.cpp b/src/kdict.cpp index 1fcea6d..d5c4896 100644 --- a/src/kdict.cpp +++ b/src/kdict.cpp @@ -1491,9 +1491,16 @@ string KDict::KInfoToTextBuf(const KInfo& k, result << "" << k.literal << "\n\n"; /* Insert KanjiCafe.com SODs if present */ +#if 0 if((options & (KDO_SOD_STATIC | KDO_SOD_ANIM)) != 0) { result << GetSODTextBuf(k, options); } +#endif + /* Animated gifs are not supported by GTKTextViews. Only the first + frame shows. So, for now, we'll only show static SODs. */ + if((options & KDO_SOD_STATIC) != 0) { + result << GetSODTextBuf(k, options); + } /* Japanese readings */ if((options & KDO_READINGS) != 0) { diff --git a/src/widget_kanjihwpad.cpp b/src/widget_kanjihwpad.cpp index 6c6c204..686a28c 100644 --- a/src/widget_kanjihwpad.cpp +++ b/src/widget_kanjihwpad.cpp @@ -121,7 +121,7 @@ bool KanjiHWPad::OnExpose(GdkEventExpose* event) { } return true; } - + bool KanjiHWPad::OnMotion(GdkEventMotion* event) { if(event->state & Gdk::BUTTON1_MASK) { if(pCurrentLine) @@ -297,8 +297,17 @@ void KanjiHWPad::LookupChars() { } } else { ostringstream oss; - oss << ERR_PREF << "Bad call to kpengine!"; - el.Push(EL_Error, oss.str()); + if (error->domain == G_SPAWN_ERROR) { + el.Push(EL_Error, + (boost::format(_("%s:%d: G_SPAWN_ERROR, code = %d, message = \"%s\"")) + % __FILE__ % __LINE__ + % error->code % error->message).str()); + } else { + el.Push(EL_Error, + (boost::format(_("%s:%d: Bad call to kpengine! Domain = %d, code = %d, message = \"%s\"")) + % __FILE__ % __LINE__ + % error->domain % error->code % error->message).str()); + } } /* cleanup */ -- 2.11.4.GIT