diff -Nru chmsee-1.0.6/CMakeLists.txt chmsee-1.0.7/CMakeLists.txt --- chmsee-1.0.6/CMakeLists.txt 2009-07-12 04:02:53.000000000 +0100 +++ chmsee-1.0.7/CMakeLists.txt 2010-03-21 03:36:12.000000000 +0000 @@ -1,8 +1,28 @@ project(chmsee) cmake_minimum_required(VERSION 2.6.2 FATAL_ERROR) -set(PACKAGE_VERSION "1.0.6" ) +set(PACKAGE_VERSION "1.0.7" ) find_package(PkgConfig) -pkg_check_modules (CHMSEE REQUIRED gthread-2.0 glib-2.0 libxml-2.0 gtk+-2.0 libglade-2.0 libxul-embedding-unstable>=1.9 libxul-embedding-unstable<=1.9.0.999) + +pkg_check_modules (CHMSEE REQUIRED gthread-2.0 glib-2.0 libxml-2.0 gtk+-2.0 libglade-2.0 nspr) +pkg_search_module(XULRUNNER REQUIRED libxul-embedding-unstable>=1.9 xulrunner-gtkmozembed>=1.8) +set(CHMSEE_INCLUDE_DIRS ${CHMSEE_INCLUDE_DIRS} ${XULRUNNER_INCLUDE_DIRS}) +set(CHMSEE_CFLAGS_OTHER ${CHMSEE_CFLAGS_OTHER} ${XULRUNNER_CFLAGS_OTHER} -Wall) +set(CHMSEE_LIBRARY_DIRS ${CHMSEE_LIBRARY_DIRS} ${XULRUNNER_LIBRARY_DIRS}) +set(CHMSEE_LIBRARIES ${CHMSEE_LIBRARIES} ${XULRUNNER_LIBRARIES} chm gcrypt) + + +if(XULRUNNER_VERSION MATCHES "1\\.8\\..*") + set(XULRUNNER18 1) +endif() +if(XULRUNNER_VERSION MATCHES "1\\.9\\..*") + set(XULRUNNER19 1) +endif() +if(XULRUNNER_VERSION MATCHES "1\\.9\\.0\\..*") + set(XULRUNNER190 1) +endif() +if(XULRUNNER_VERSION MATCHES "1\\.9\\.1\\..*") + set(XULRUNNER191 1) +endif() set(CHMSEE_BOOKMARK_FILE "chmsee_bookmarks") set(CHMSEE_BOOKINFO_FILE "chmsee_bookinfo") @@ -28,9 +48,10 @@ find_library(LIBGCRYPT gcrypt) if(${LIBGCRYPT} STREQUAL "LIBGCRYPT-NOTFOUND") - message(FATAL_ERROR "libgcrypt not found, you can find one in ftp://ftp.gnupg.org/gcrypt/libgcrypt/") + message(FATAL_ERROR "libgcrypt not found, you can find one in ftp://ftp.gnupg.org/gcrypt/libgcrypt/") endif() + add_subdirectory(src) add_subdirectory(data) add_subdirectory(po) @@ -45,6 +66,6 @@ DEPENDS chmsee ) add_custom_target(love-gdb - COMMAND gdb --args src/chmsee -vvv --datadir=data + COMMAND gdb --args src/chmsee --g-fatal-warnings -vv --datadir=data DEPENDS chmsee ) diff -Nru chmsee-1.0.6/data/chmsee.glade chmsee-1.0.7/data/chmsee.glade --- chmsee-1.0.6/data/chmsee.glade 2009-07-12 04:02:53.000000000 +0100 +++ chmsee-1.0.7/data/chmsee.glade 2009-09-14 14:51:03.000000000 +0100 @@ -11,354 +11,6 @@ True - - True - - - True - - - True - _File - True - - - - - gtk-open - True - True - True - - - - - True - _New Tab - True - - - - - True - _Close Tab - True - - - - - True - - - - - gtk-quit - True - True - True - - - - - - - - - True - _Edit - True - - - - - gtk-copy - True - True - True - - - - - True - - - - - gtk-preferences - True - True - True - - - - - - - - - True - _View - True - - - - - gtk-home - True - True - True - - - - - gtk-go-back - True - True - True - - - - - gtk-go-forward - True - True - True - - - - - True - - - - - True - _Full Screen - True - - - - - True - False - Side _Pane - True - True - - - - - - - - - True - _Help - True - - - - - gtk-about - True - True - True - - - - - - - - - - - False - 0 - - - - - True - - - True - icons - - - True - Open File - gtk-open - - - False - True - - - - - True - - - False - - - - - True - Show/Hide Panel - Panel - True - - - False - True - - - - - True - False - Back - gtk-go-back - - - False - True - - - - - True - False - Forward - gtk-go-forward - - - False - True - - - - - True - False - Home - Home - True - gtk-home - - - False - True - - - - - True - False - Zoom In - gtk-zoom-in - - - False - True - - - - - True - False - Normal - gtk-zoom-100 - - - False - True - - - - - True - False - Zoom Out - gtk-zoom-out - - - False - True - - - - - True - - - False - - - - - True - Setup - Setup - True - gtk-preferences - - - False - True - - - - - True - About... - About - True - gtk-about - - - False - True - - - - - - - False - False - 1 - - - - - True - True - 2 - 200 - - - True - - - - - - False - False - - - - - - - - 2 - - - True @@ -591,11 +243,11 @@ True Universal Simplified Chinese -Tradtional Chinese +Traditional Chinese Japanese Korean Russian -Ukrainain +Ukrainian 5 @@ -731,58 +383,4 @@ - - True - - - True - _Back - True - - - - - True - _Forward - True - - - - - True - _Copy - True - - - - - True - Select _All - True - - - - - True - Copy Page _Location - True - - - - - - - True - Open Link in New _Tab - True - - - - - True - _Copy Link Location - True - - - diff -Nru chmsee-1.0.6/debian/changelog chmsee-1.0.7/debian/changelog --- chmsee-1.0.6/debian/changelog 2010-03-21 03:36:11.000000000 +0000 +++ chmsee-1.0.7/debian/changelog 2010-03-21 03:36:12.000000000 +0000 @@ -1,3 +1,56 @@ +chmsee (1.0.7-1.2ubuntu1) lucid; urgency=low + + [ Micah Gersten ] + * debian/patches/xulrunner1.9.2.diff: + - libxul-embedding is no longer unstable + - Bump GRE version + - Add XULRUNNER192 variable + + [ Chris Coulson ] + * Merge from Debian unstable, remaining changes: + - debian/control: + + Build-depend on quilt + - debian/rules: + + Include patchsys-quilt.mk + * debian/patches/xulrunner1.9.2.diff: + - Update for new source version + - Ensure regex for testing for xulrunner 1.9.2 matches "1.9.2" as + well as "1.9.2.*" + + -- Chris Coulson Sun, 21 Mar 2010 01:16:14 +0000 + +chmsee (1.0.7-1.2) unstable; urgency=low + + * Non-maintainer upload. + * Fix FTFBS on GNU/kFreeBSD (Closes: #557159): + - Remove FreeBSD detection from CMakeLists.txt, so that -lmd doesn't + get added for GNU/kFreeBSD. That's not meant to be a final + solution, just a temporary band-aid until a CMake master drives by. + - Tweak src/models/chmfile.c to check for __GLIBC__ in addition to + checking for __linux__. + + -- Cyril Brulebois Mon, 21 Dec 2009 08:21:07 +0100 + +chmsee (1.0.7-1.1) unstable; urgency=low + + * Non-maintainer upload for transition to xulrunner 1.9.1. + (Closes: #548671) + * debian/rules: Use dh_xulrunner + * debian/control: + - Build-depend on a xulrunner-dev that provides dh_xulrunner. + - Let dh_xulrunner fill shlibs:Depends with the proper xulrunner + dependency. + + -- Mike Hommey Sat, 10 Oct 2009 11:32:05 +0200 + +chmsee (1.0.7-1) unstable; urgency=low + + * new upstream release. + - Fix "should honor GTK toolbar settings" (Closes: #536691) + * debian/control: bump standards version to 3.8.3. + + -- LI Daobing Mon, 14 Sep 2009 22:24:01 +0800 + chmsee (1.0.6-1ubuntu2) karmic; urgency=low * LP: #455517 - supersede firefox 3.0 and xulrunner-1.9 in karmic; diff -Nru chmsee-1.0.6/debian/control chmsee-1.0.7/debian/control --- chmsee-1.0.6/debian/control 2010-03-21 03:36:11.000000000 +0000 +++ chmsee-1.0.7/debian/control 2010-03-21 03:36:12.000000000 +0000 @@ -4,9 +4,9 @@ Maintainer: Ubuntu Developers XSBC-Original-Maintainer: LI Daobing Build-Depends: cdbs (>= 0.4.23-1.1), cmake (>= 2.6.2), debhelper (>= 5), - xulrunner-dev (>= 1.9.1) | xulrunner-1.9.1-dev, libchm-dev, libgcrypt11-dev, intltool, + xulrunner-dev (>= 1.9.2), libchm-dev, libgcrypt11-dev, intltool, pkg-config, libglade2-dev (>= 2.4.0), libgtk2.0-dev (>= 2.8.0), quilt -Standards-Version: 3.8.2 +Standards-Version: 3.8.3 DM-Upload-Allowed: yes Vcs-Browser: http://git.debian.org/?p=chinese/chmsee.git Vcs-Git: git://git.debian.org/git/chinese/chmsee.git @@ -14,7 +14,7 @@ Package: chmsee Architecture: any -Depends: ${shlibs:Depends}, ${misc:Depends}, xulrunner-1.9.1 +Depends: ${shlibs:Depends}, ${misc:Depends} Description: A chm file viewer written in GTK+ ChmSee is a Compiled HTML Help (CHM) file viewer written in GTK+. . diff -Nru chmsee-1.0.6/debian/patches/series chmsee-1.0.7/debian/patches/series --- chmsee-1.0.6/debian/patches/series 2010-03-21 03:36:11.000000000 +0000 +++ chmsee-1.0.7/debian/patches/series 2010-03-21 03:36:12.000000000 +0000 @@ -1 +1 @@ -xulrunner1.9.1.diff +xulrunner1.9.2.diff diff -Nru chmsee-1.0.6/debian/patches/xulrunner1.9.1.diff chmsee-1.0.7/debian/patches/xulrunner1.9.1.diff --- chmsee-1.0.6/debian/patches/xulrunner1.9.1.diff 2010-03-21 03:36:11.000000000 +0000 +++ chmsee-1.0.7/debian/patches/xulrunner1.9.1.diff 1970-01-01 01:00:00.000000000 +0100 @@ -1,73 +0,0 @@ -commit 8b752f4344e1143ec83caf7e1cbd81de7f9b6000 -Author: LI Daobing -Date: Fri Aug 14 18:07:31 2009 +0800 - - work with xulrunner 1.9.1 - -Index: chmsee-1.0.6/CMakeLists.txt -=================================================================== ---- chmsee-1.0.6.orig/CMakeLists.txt 2009-08-20 14:26:21.132457709 +0300 -+++ chmsee-1.0.6/CMakeLists.txt 2009-08-20 14:31:10.735543739 +0300 -@@ -2,7 +2,25 @@ - cmake_minimum_required(VERSION 2.6.2 FATAL_ERROR) - set(PACKAGE_VERSION "1.0.6" ) - find_package(PkgConfig) --pkg_check_modules (CHMSEE REQUIRED gthread-2.0 glib-2.0 libxml-2.0 gtk+-2.0 libglade-2.0 libxul-embedding-unstable>=1.9 libxul-embedding-unstable<=1.9.0.999) -+pkg_check_modules (CHMSEE REQUIRED gthread-2.0 glib-2.0 libxml-2.0 gtk+-2.0 libglade-2.0 nspr) -+pkg_search_module(XULRUNNER REQUIRED libxul-embedding-unstable>=1.9 xulrunner-gtkmozembed>=1.8) -+set(CHMSEE_INCLUDE_DIRS ${CHMSEE_INCLUDE_DIRS} ${XULRUNNER_INCLUDE_DIRS}) -+set(CHMSEE_CFLAGS_OTHER ${CHMSEE_CFLAGS_OTHER} ${XULRUNNER_CFLAGS_OTHER} -Wall) -+set(CHMSEE_LIBRARY_DIRS ${CHMSEE_LIBRARY_DIRS} ${XULRUNNER_LIBRARY_DIRS}) -+set(CHMSEE_LIBRARIES ${CHMSEE_LIBRARIES} ${XULRUNNER_LIBRARIES} chm gcrypt) -+ -+if(XULRUNNER_VERSION MATCHES "1\\.8\\..*") -+ set(XULRUNNER18 1) -+endif() -+if(XULRUNNER_VERSION MATCHES "1\\.9\\..*") -+ set(XULRUNNER19 1) -+endif() -+if(XULRUNNER_VERSION MATCHES "1\\.9\\.0\\..*") -+ set(XULRUNNER190 1) -+endif() -+if(XULRUNNER_VERSION MATCHES "1\\.9\\.1\\..*") -+ set(XULRUNNER191 1) -+endif() - - set(CHMSEE_BOOKMARK_FILE "chmsee_bookmarks") - set(CHMSEE_BOOKINFO_FILE "chmsee_bookinfo") -Index: chmsee-1.0.6/src/gecko_utils.cpp -=================================================================== ---- chmsee-1.0.6.orig/src/gecko_utils.cpp 2009-08-20 14:26:21.108438245 +0300 -+++ chmsee-1.0.6/src/gecko_utils.cpp 2009-08-20 14:29:55.296437878 +0300 -@@ -205,10 +205,17 @@ - #ifdef XPCOM_GLUE - NS_LogInit(); - -+#if XULRUNNER191 -+ static const GREVersionRange greVersion = { -+ "1.9.1", PR_TRUE, -+ "1.9.2", PR_FALSE -+ }; -+#else - static const GREVersionRange greVersion = { - "1.9a", PR_TRUE, - "1.9.1", PR_FALSE - }; -+#endif - - char xpcomLocation[4096]; - rv = GRE_GetGREPathWithProperties(&greVersion, 1, nsnull, 0, xpcomLocation, 4096); -Index: chmsee-1.0.6/src/config.h.in -=================================================================== ---- chmsee-1.0.6.orig/src/config.h.in 2009-08-20 14:26:21.120445986 +0300 -+++ chmsee-1.0.6/src/config.h.in 2009-08-20 14:29:55.296437878 +0300 -@@ -9,3 +9,9 @@ - #define PACKAGE "chmsee" - #define GETTEXT_PACKAGE "chmsee" - #define PACKAGE_LOCALE_DIR "${CMAKE_INSTALL_PREFIX}/share/locale" -+#cmakedefine XULRUNNER_VERSION "${XULRUNNER_VERSION}" -+#cmakedefine XULRUNNER18 1 -+#cmakedefine XULRUNNER19 1 -+#cmakedefine XULRUNNER190 1 -+#cmakedefine XULRUNNER191 1 -+#cmakedefine GECKO_LIB_ROOT "${GECKO_LIB_ROOT}" diff -Nru chmsee-1.0.6/debian/patches/xulrunner1.9.2.diff chmsee-1.0.7/debian/patches/xulrunner1.9.2.diff --- chmsee-1.0.6/debian/patches/xulrunner1.9.2.diff 1970-01-01 01:00:00.000000000 +0100 +++ chmsee-1.0.7/debian/patches/xulrunner1.9.2.diff 2010-03-21 03:36:12.000000000 +0000 @@ -0,0 +1,63 @@ +Index: chmsee-1.0.7/CMakeLists.txt +=================================================================== +--- chmsee-1.0.7.orig/CMakeLists.txt 2010-03-21 02:07:43.580783390 +0000 ++++ chmsee-1.0.7/CMakeLists.txt 2010-03-21 02:36:14.690847242 +0000 +@@ -4,16 +4,13 @@ + find_package(PkgConfig) + + pkg_check_modules (CHMSEE REQUIRED gthread-2.0 glib-2.0 libxml-2.0 gtk+-2.0 libglade-2.0 nspr) +-pkg_search_module(XULRUNNER REQUIRED libxul-embedding-unstable>=1.9 xulrunner-gtkmozembed>=1.8) ++pkg_search_module(XULRUNNER REQUIRED libxul-embedding>=1.9.2 libxul-embedding-unstable>=1.9 xulrunner-gtkmozembed>=1.9) + set(CHMSEE_INCLUDE_DIRS ${CHMSEE_INCLUDE_DIRS} ${XULRUNNER_INCLUDE_DIRS}) + set(CHMSEE_CFLAGS_OTHER ${CHMSEE_CFLAGS_OTHER} ${XULRUNNER_CFLAGS_OTHER} -Wall) + set(CHMSEE_LIBRARY_DIRS ${CHMSEE_LIBRARY_DIRS} ${XULRUNNER_LIBRARY_DIRS}) + set(CHMSEE_LIBRARIES ${CHMSEE_LIBRARIES} ${XULRUNNER_LIBRARIES} chm gcrypt) + + +-if(XULRUNNER_VERSION MATCHES "1\\.8\\..*") +- set(XULRUNNER18 1) +-endif() + if(XULRUNNER_VERSION MATCHES "1\\.9\\..*") + set(XULRUNNER19 1) + endif() +@@ -23,6 +20,9 @@ + if(XULRUNNER_VERSION MATCHES "1\\.9\\.1\\..*") + set(XULRUNNER191 1) + endif() ++if(XULRUNNER_VERSION MATCHES "1\\.9\\.2\\..*" OR XULRUNNER_VERSION MATCHES "1\\.9\\.2") ++ set(XULRUNNER192 1) ++endif() + + set(CHMSEE_BOOKMARK_FILE "chmsee_bookmarks") + set(CHMSEE_BOOKINFO_FILE "chmsee_bookinfo") +Index: chmsee-1.0.7/src/config.h.in +=================================================================== +--- chmsee-1.0.7.orig/src/config.h.in 2010-03-21 02:07:43.530784089 +0000 ++++ chmsee-1.0.7/src/config.h.in 2010-03-21 02:36:14.690847242 +0000 +@@ -10,8 +10,8 @@ + #define GETTEXT_PACKAGE "chmsee" + #define PACKAGE_LOCALE_DIR "${CMAKE_INSTALL_PREFIX}/share/locale" + #cmakedefine XULRUNNER_VERSION "${XULRUNNER_VERSION}" +-#cmakedefine XULRUNNER18 1 + #cmakedefine XULRUNNER19 1 + #cmakedefine XULRUNNER190 1 + #cmakedefine XULRUNNER191 1 ++#cmakedefine XULRUNNER192 1 + #cmakedefine GECKO_LIB_ROOT "${GECKO_LIB_ROOT}" +Index: chmsee-1.0.7/src/gecko_utils.cpp +=================================================================== +--- chmsee-1.0.7.orig/src/gecko_utils.cpp 2010-03-21 02:07:43.550786979 +0000 ++++ chmsee-1.0.7/src/gecko_utils.cpp 2010-03-21 02:36:41.013283402 +0000 +@@ -210,10 +210,10 @@ + #ifdef XPCOM_GLUE + NS_LogInit(); + +-#if XULRUNNER191 ++#if XULRUNNER191 || XULRUNNER192 + static const GREVersionRange greVersion = { + "1.9.1", PR_TRUE, +- "1.9.2", PR_FALSE ++ "1.9.3", PR_FALSE + }; + #else + static const GREVersionRange greVersion = { diff -Nru chmsee-1.0.6/debian/rules chmsee-1.0.7/debian/rules --- chmsee-1.0.6/debian/rules 2010-03-21 03:36:11.000000000 +0000 +++ chmsee-1.0.7/debian/rules 2010-03-21 03:36:12.000000000 +0000 @@ -19,3 +19,6 @@ rm -f intltool-extract intltool-merge intltool-update po/.intltool-merge-cache; \ if test -d doc; then find doc -name '*.omf.out' -exec rm -f \{\} \; ; fi; \ if test -d help; then find help -name '*.omf.out' -exec rm -f \{\} \; ; fi + +binary-predeb/chmsee:: + dh_xulrunner -pchmsee Binary files /tmp/RpYmA2xSGG/chmsee-1.0.6/doc/screenshot01.png and /tmp/s1CLns69BU/chmsee-1.0.7/doc/screenshot01.png differ Binary files /tmp/RpYmA2xSGG/chmsee-1.0.6/doc/screenshot02.png and /tmp/s1CLns69BU/chmsee-1.0.7/doc/screenshot02.png differ diff -Nru chmsee-1.0.6/.gitignore chmsee-1.0.7/.gitignore --- chmsee-1.0.6/.gitignore 2009-07-12 04:02:53.000000000 +0100 +++ chmsee-1.0.7/.gitignore 2009-09-14 14:51:03.000000000 +0100 @@ -54,3 +54,4 @@ gtester.xml report.html test/test +install_manifest.txt diff -Nru chmsee-1.0.6/NEWS chmsee-1.0.7/NEWS --- chmsee-1.0.6/NEWS 2009-07-12 04:02:53.000000000 +0100 +++ chmsee-1.0.7/NEWS 2009-09-14 14:51:03.000000000 +0100 @@ -1,5 +1,29 @@ -ChmSee 1.0.6 ------------- +ChmSee 1.0.7 2009-09-14 +----------------------- + +Features +~~~~~~~~ + +* issue 47: jump to specify index page from command line. + +Bugs +~~~~ + +* issue 43: honor GTK toolbar settings +* issue 44: support xulrunner 1.9.1. +* issue 46: fix compile error (on some system, the xulrunner develop package + does not depends on nspr develop package) +* issue 48: support xulrunner 1.8 again. + +l10n +~~~~ + +* New: de, zh_TW +* Updated: es, ru, sv, zh_CN + + +ChmSee 1.0.6 2009-07-12 +----------------------- Features ~~~~~~~~ diff -Nru chmsee-1.0.6/po/chmsee.pot chmsee-1.0.7/po/chmsee.pot --- chmsee-1.0.6/po/chmsee.pot 2009-07-12 04:02:53.000000000 +0100 +++ chmsee-1.0.7/po/chmsee.pot 2009-09-14 14:51:03.000000000 +0100 @@ -8,7 +8,7 @@ msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2009-07-04 13:15+0800\n" +"POT-Creation-Date: 2009-09-06 18:35+0800\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -29,22 +29,10 @@ msgstr "" #: ../data/chmsee.glade.h:4 -msgid "About" -msgstr "" - -#: ../data/chmsee.glade.h:5 -msgid "About..." -msgstr "" - -#: ../data/chmsee.glade.h:6 msgid "Auto-Detect:" msgstr "" -#: ../data/chmsee.glade.h:7 -msgid "Back" -msgstr "" - -#: ../data/chmsee.glade.h:8 +#: ../data/chmsee.glade.h:5 msgid "" "CHM files extracted in this cache folder, you can press Clear button to free " "disk space.\n" @@ -52,135 +40,47 @@ "NOTE: If you are viewing a CHM file, you need reopen it after cleaning." msgstr "" -#: ../data/chmsee.glade.h:11 ../data/chmsee.desktop.in.h:1 +#: ../data/chmsee.glade.h:8 ../data/chmsee.desktop.in.h:1 msgid "ChmSee" msgstr "" -#: ../data/chmsee.glade.h:12 -msgid "Copy Page _Location" -msgstr "" - -#: ../data/chmsee.glade.h:13 +#: ../data/chmsee.glade.h:9 msgid "Fixed Width:" msgstr "" -#: ../data/chmsee.glade.h:14 -msgid "Forward" -msgstr "" - -#: ../data/chmsee.glade.h:15 -msgid "Home" -msgstr "" - -#: ../data/chmsee.glade.h:16 -msgid "Normal" -msgstr "" - -#: ../data/chmsee.glade.h:17 +#: ../data/chmsee.glade.h:10 msgid "Open File" msgstr "" -#: ../data/chmsee.glade.h:18 -msgid "Open Link in New _Tab" -msgstr "" - -#: ../data/chmsee.glade.h:19 -msgid "Panel" -msgstr "" - -#: ../data/chmsee.glade.h:20 -msgid "Select _All" -msgstr "" - -#: ../data/chmsee.glade.h:21 +#: ../data/chmsee.glade.h:11 msgid "Setup" msgstr "" -#: ../data/chmsee.glade.h:22 -msgid "Show/Hide Panel" -msgstr "" - -#: ../data/chmsee.glade.h:23 -msgid "Side _Pane" -msgstr "" - -#: ../data/chmsee.glade.h:24 +#: ../data/chmsee.glade.h:12 msgid "The HTML Help(CHM) viewer for Unix/Linux" msgstr "" -#: ../data/chmsee.glade.h:25 +#: ../data/chmsee.glade.h:13 msgid "" "Universal\n" "Simplified Chinese\n" -"Tradtional Chinese\n" +"Traditional Chinese\n" "Japanese\n" "Korean\n" "Russian\n" -"Ukrainain" +"Ukrainian" msgstr "" -#: ../data/chmsee.glade.h:32 +#: ../data/chmsee.glade.h:20 msgid "Variable Width:" msgstr "" -#: ../data/chmsee.glade.h:33 -msgid "Zoom In" -msgstr "" - -#: ../data/chmsee.glade.h:34 -msgid "Zoom Out" -msgstr "" - -#: ../data/chmsee.glade.h:35 -msgid "_Back" -msgstr "" - -#: ../data/chmsee.glade.h:36 -msgid "_Close Tab" -msgstr "" - -#: ../data/chmsee.glade.h:37 -msgid "_Copy" -msgstr "" - -#: ../data/chmsee.glade.h:38 -msgid "_Copy Link Location" -msgstr "" - -#: ../data/chmsee.glade.h:39 -msgid "_Edit" -msgstr "" - -#: ../data/chmsee.glade.h:40 -msgid "_File" -msgstr "" - -#: ../data/chmsee.glade.h:41 -msgid "_Forward" -msgstr "" - -#: ../data/chmsee.glade.h:42 -msgid "_Full Screen" -msgstr "" - -#: ../data/chmsee.glade.h:43 -msgid "_Help" -msgstr "" - -#: ../data/chmsee.glade.h:44 -msgid "_New Tab" -msgstr "" - -#: ../data/chmsee.glade.h:45 -msgid "_View" -msgstr "" - -#: ../data/chmsee.glade.h:46 +#: ../data/chmsee.glade.h:21 msgid "http://code.google.com/p/chmsee" msgstr "" #. TRANSLATORS: Replace this string with your names, one name per line. -#: ../data/chmsee.glade.h:48 +#: ../data/chmsee.glade.h:23 msgid "translator-credits" msgstr "" @@ -188,86 +88,98 @@ msgid "HTML Help(CHM) viewer" msgstr "" -#: ../src/chmsee.c:506 +#: ../src/chmsee.c:484 ../src/ui_chmfile.c:418 #, c-format msgid "URI redirect: \"%s\" -> \"%s\"" msgstr "" -#: ../src/chmsee.c:671 +#: ../src/chmsee.c:555 msgid "CHM Files" msgstr "" -#: ../src/chmsee.c:676 +#: ../src/chmsee.c:560 msgid "All Files" msgstr "" -#: ../src/chmsee.c:1196 +#: ../src/chmsee.c:839 msgid "Ready!" msgstr "" -#: ../src/chmsee.c:1253 +#: ../src/chmsee.c:971 +#, c-format +msgid "Error loading file '%s'" +msgstr "" + +#: ../src/ui_bookmarks.c:315 +msgid "Bookmark" +msgstr "" + +#: ../src/ui_chmfile.c:664 msgid "Topics" msgstr "" -#: ../src/chmsee.c:1267 +#: ../src/ui_chmfile.c:673 msgid "Index" msgstr "" -#: ../src/chmsee.c:1276 +#: ../src/ui_chmfile.c:679 msgid "Bookmarks" msgstr "" #. Custom label widget, with a close button -#: ../src/chmsee.c:1440 ../src/chmsee.c:1615 +#: ../src/ui_chmfile.c:869 ../src/ui_chmfile.c:1002 msgid "No Title" msgstr "" -#: ../src/chmsee.c:1719 -#, c-format -msgid "Error loading file '%s'" +#: ../src/main.cpp:108 +msgid "Specify index" msgstr "" -#: ../src/models/chmfile.c:253 -#, c-format -msgid "cannot open chmfile: %s" +#: ../src/main.cpp:109 +msgid "INDEX" msgstr "" -#: ../src/models/chmfile.c:260 -#, c-format -msgid "Extract chmfile failed: %s" +#: ../src/main.cpp:113 +msgid "Display the version and exit" msgstr "" -#: ../src/models/chmfile.c:286 -#, c-format -msgid "open \"%s\" failed: %s" +#: ../src/main.cpp:118 +msgid "be verbose, repeat 3 times to get all info" msgstr "" -#: ../src/models/chmfile.c:336 -#, c-format -msgid "Can not open chm file %s." +#: ../src/main.cpp:123 +msgid "be quiet, repeat 2 times to disable all info" msgstr "" -#: ../src/models/chmfile.c:594 -msgid "Can't found hhc file." +#: ../src/main.cpp:129 +msgid "PATH" msgstr "" -#: ../src/ui_bookmarks.c:315 -msgid "Bookmark" +#: ../src/main.cpp:160 +#, c-format +msgid "more than 1 argument\n" msgstr "" -#: ../src/main.cpp:107 -msgid "Display the version and exit" +#: ../src/models/chmfile.c:254 +#, c-format +msgid "cannot open chmfile: %s" msgstr "" -#: ../src/main.cpp:112 -msgid "be verbose, repeat 3 times to get all info" +#: ../src/models/chmfile.c:261 +#, c-format +msgid "Extract chmfile failed: %s" msgstr "" -#: ../src/main.cpp:117 -msgid "be quiet, repeat 2 times to disable all info" +#: ../src/models/chmfile.c:287 +#, c-format +msgid "open \"%s\" failed: %s" msgstr "" -#: ../src/main.cpp:154 +#: ../src/models/chmfile.c:337 #, c-format -msgid "more than 1 argument\n" +msgid "Can not open chm file %s." +msgstr "" + +#: ../src/models/chmfile.c:595 +msgid "Can't found hhc file." msgstr "" diff -Nru chmsee-1.0.6/po/CMakeLists.txt chmsee-1.0.7/po/CMakeLists.txt --- chmsee-1.0.6/po/CMakeLists.txt 2009-07-12 04:02:53.000000000 +0100 +++ chmsee-1.0.7/po/CMakeLists.txt 2009-09-14 14:51:03.000000000 +0100 @@ -1,4 +1,4 @@ -set(CATALOGS bn ca cs da el en_GB es fr he id it ms nb pl pt pt_BR ro ru sk sv sw uk vi zh_CN) +set(CATALOGS bn ca cs da de el en_GB es fr he id it ms nb pl pt pt_BR ro ru sk sv sw uk vi zh_CN zh_TW) set(UPDATE_PO_TARGETS ) set(COMPILE_PO_TARGETS ) add_custom_target(update-pot diff -Nru chmsee-1.0.6/po/de.po chmsee-1.0.7/po/de.po --- chmsee-1.0.6/po/de.po 1970-01-01 01:00:00.000000000 +0100 +++ chmsee-1.0.7/po/de.po 2009-09-14 14:51:03.000000000 +0100 @@ -0,0 +1,308 @@ +# English (United Kingdom) translation for chmsee +# Copyright (c) 2009 Rosetta Contributors and Canonical Ltd 2009 +# This file is distributed under the same license as the chmsee package. +# FIRST AUTHOR , 2009. +# +msgid "" +msgstr "" +"Project-Id-Version: chmsee\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2009-07-14 21:48+0800\n" +"PO-Revision-Date: 2009-07-28 15:41+0000\n" +"Last-Translator: Moritz Baumann \n" +"Language-Team: English (United Kingdom) \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Launchpad-Export-Date: 2009-09-06 10:48+0000\n" +"X-Generator: Launchpad (build Unknown)\n" + +#: ../data/chmsee.glade.h:1 +msgid "Cache" +msgstr "Cache" + +#: ../data/chmsee.glade.h:2 +msgid "Charset" +msgstr "Zeichensatz" + +#: ../data/chmsee.glade.h:3 +msgid "Font" +msgstr "Schriftart" + +#: ../data/chmsee.glade.h:4 +msgid "About" +msgstr "Über" + +#: ../data/chmsee.glade.h:5 +msgid "About..." +msgstr "Über..." + +#: ../data/chmsee.glade.h:6 +msgid "Auto-Detect:" +msgstr "Automatisch:" + +#: ../data/chmsee.glade.h:7 +msgid "Back" +msgstr "Zurück" + +#: ../data/chmsee.glade.h:8 +msgid "" +"CHM files extracted in this cache folder, you can press Clear button to free " +"disk space.\n" +"\n" +"NOTE: If you are viewing a CHM file, you need reopen it after cleaning." +msgstr "" +"Die CHM-Dateien wurden in den Cache-Ordner extrahiert, Sie können den " +"\"Löschen\"-Knopf drücken um Speicherplatz zu sparen\n" +" Hinweis: Wenn Sie gerade eine CHM-Datei betrachten müssen Sie diese danach " +"noch einmal öffnen." + +#: ../data/chmsee.glade.h:11 ../data/chmsee.desktop.in.h:1 +msgid "ChmSee" +msgstr "ChmSee" + +#: ../data/chmsee.glade.h:12 +msgid "Copy Page _Location" +msgstr "Adresse der Seite kopieren" + +#: ../data/chmsee.glade.h:13 +msgid "Fixed Width:" +msgstr "Dicktengleich:" + +#: ../data/chmsee.glade.h:14 +msgid "Forward" +msgstr "Weiter" + +#: ../data/chmsee.glade.h:15 +msgid "Home" +msgstr "Startseite" + +#: ../data/chmsee.glade.h:16 +msgid "Normal" +msgstr "Normale Größe" + +#: ../data/chmsee.glade.h:17 +msgid "Open File" +msgstr "Datei öffnen" + +#: ../data/chmsee.glade.h:18 +msgid "Open Link in New _Tab" +msgstr "Link in einem neuen Rei_ter öffnen" + +#: ../data/chmsee.glade.h:19 +msgid "Panel" +msgstr "Seitenleiste" + +#: ../data/chmsee.glade.h:20 +msgid "Select _All" +msgstr "Alles auswählen" + +#: ../data/chmsee.glade.h:21 +msgid "Setup" +msgstr "Einstellungen" + +#: ../data/chmsee.glade.h:22 +msgid "Show/Hide Panel" +msgstr "Seitenleiste anzeigen/verbergen" + +#: ../data/chmsee.glade.h:23 +msgid "Side _Pane" +msgstr "Seitenleiste" + +#: ../data/chmsee.glade.h:24 +msgid "The HTML Help(CHM) viewer for Unix/Linux" +msgstr "Der HTML-Hilfe(CHM) Betrachter für Unix/Linux" + +#: ../data/chmsee.glade.h:25 +msgid "" +"Universal\n" +"Simplified Chinese\n" +"Traditional Chinese\n" +"Japanese\n" +"Korean\n" +"Russian\n" +"Ukrainian" +msgstr "" + +#: ../data/chmsee.glade.h:32 +msgid "Variable Width:" +msgstr "Variabel:" + +#: ../data/chmsee.glade.h:33 +msgid "Zoom In" +msgstr "Vergrößern" + +#: ../data/chmsee.glade.h:34 +msgid "Zoom Out" +msgstr "Verkleinern" + +#: ../data/chmsee.glade.h:35 +msgid "_Back" +msgstr "_Zurück" + +#: ../data/chmsee.glade.h:36 +msgid "_Close Tab" +msgstr "_Reiter schließen" + +#: ../data/chmsee.glade.h:37 +msgid "_Copy" +msgstr "_Kopieren" + +#: ../data/chmsee.glade.h:38 +msgid "_Copy Link Location" +msgstr "_Link-Adresse kopieren" + +#: ../data/chmsee.glade.h:39 +msgid "_Edit" +msgstr "_Bearbeiten" + +#: ../data/chmsee.glade.h:40 +msgid "_File" +msgstr "_Datei" + +#: ../data/chmsee.glade.h:41 +msgid "_Forward" +msgstr "Weiter" + +#: ../data/chmsee.glade.h:42 +msgid "_Full Screen" +msgstr "Vollbild" + +#: ../data/chmsee.glade.h:43 +msgid "_Help" +msgstr "_Hilfe" + +#: ../data/chmsee.glade.h:44 +msgid "_New Tab" +msgstr "_Neuer Reiter" + +#: ../data/chmsee.glade.h:45 +msgid "_View" +msgstr "_Ansicht" + +#: ../data/chmsee.glade.h:46 +msgid "http://code.google.com/p/chmsee" +msgstr "http://code.google.com/p/chmsee" + +#. TRANSLATORS: Replace this string with your names, one name per line. +#: ../data/chmsee.glade.h:48 +msgid "translator-credits" +msgstr "" +"Überstzungen von\n" +"\n" +"Launchpad Contributions:\n" +" Bart https://launchpad.net/~bart-neeneenee\n" +" Moritz Baumann https://launchpad.net/~mo-germany" + +#: ../data/chmsee.desktop.in.h:2 +msgid "HTML Help(CHM) viewer" +msgstr "HTML-Hilfe(CHM)-Betrachter" + +#: ../src/chmsee.c:506 +#, c-format +msgid "URI redirect: \"%s\" -> \"%s\"" +msgstr "URI-Weiterleitung: »%s« -> »%s«" + +#: ../src/chmsee.c:671 +msgid "CHM Files" +msgstr "CHM-Dateien" + +#: ../src/chmsee.c:676 +msgid "All Files" +msgstr "Alle Dateien" + +#: ../src/chmsee.c:1196 +msgid "Ready!" +msgstr "Fertig!" + +#: ../src/chmsee.c:1253 +msgid "Topics" +msgstr "Inhalt" + +#: ../src/chmsee.c:1267 +msgid "Index" +msgstr "" + +#: ../src/chmsee.c:1276 +msgid "Bookmarks" +msgstr "Lesezeichen" + +#. Custom label widget, with a close button +#: ../src/chmsee.c:1440 ../src/chmsee.c:1615 +msgid "No Title" +msgstr "Unbenannt" + +#: ../src/chmsee.c:1719 +#, c-format +msgid "Error loading file '%s'" +msgstr "Fehler beim Laden der Datei '%s'" + +#: ../src/models/chmfile.c:253 +#, c-format +msgid "cannot open chmfile: %s" +msgstr "Die CHM-Datei %s kann nicht geöffnet werden." + +#: ../src/models/chmfile.c:260 +#, c-format +msgid "Extract chmfile failed: %s" +msgstr "Extrahieren der CHM-Datei %s ist gescheitert." + +#: ../src/models/chmfile.c:286 +#, c-format +msgid "open \"%s\" failed: %s" +msgstr "\"%s\" zu öffnen ist gescheitert: %s" + +#: ../src/models/chmfile.c:336 +#, c-format +msgid "Can not open chm file %s." +msgstr "Die CHM-Datei %s kann nicht geöffnet werden." + +#: ../src/models/chmfile.c:594 +msgid "Can't found hhc file." +msgstr "Die hhc-Datei wurde nicht gefunden." + +#: ../src/ui_bookmarks.c:315 +msgid "Bookmark" +msgstr "Lesezeichen" + +#: ../src/main.cpp:107 +msgid "Display the version and exit" +msgstr "Die Version anzeigen und beenden" + +#: ../src/main.cpp:112 +msgid "be verbose, repeat 3 times to get all info" +msgstr "" +"ausführliche Anzeige, 3 mal wiederholen um alle Informationen zu erhalten" + +#: ../src/main.cpp:117 +msgid "be quiet, repeat 2 times to disable all info" +msgstr "" +"dezente Anzeige, 2 mal wiederholen um alle Informationen zu unterdrücken" + +#: ../src/main.cpp:154 +#, c-format +msgid "more than 1 argument\n" +msgstr "Mehr als 1 Argument erhalten\n" + +#~ msgid "" +#~ "Universal\n" +#~ "Simplified Chinese\n" +#~ "Tradtional Chinese\n" +#~ "Japanese\n" +#~ "Korean\n" +#~ "Russian\n" +#~ "Ukrainain" +#~ msgstr "" +#~ "Universell\n" +#~ "Vereinfachtes Chinesisch\n" +#~ "Tradtionelles Chinesisch\n" +#~ "Japanisch\n" +#~ "Koreanisch\n" +#~ "Russisch\n" +#~ "Ukrainainisch" + +#~ msgid "_Home" +#~ msgstr "_Home" + +#~ msgid "_Setup" +#~ msgstr "_Setup" diff -Nru chmsee-1.0.6/po/es.po chmsee-1.0.7/po/es.po --- chmsee-1.0.6/po/es.po 2009-07-12 04:02:53.000000000 +0100 +++ chmsee-1.0.7/po/es.po 2009-09-14 14:51:03.000000000 +0100 @@ -7,14 +7,14 @@ msgstr "" "Project-Id-Version: chmsee\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2009-05-10 22:47+0800\n" -"PO-Revision-Date: 2009-05-20 19:47+0000\n" -"Last-Translator: DiegoJ \n" +"POT-Creation-Date: 2009-07-14 21:48+0800\n" +"PO-Revision-Date: 2009-08-14 00:51+0000\n" +"Last-Translator: Mauro de Carvalho \n" "Language-Team: Spanish \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2009-07-04 04:44+0000\n" +"X-Launchpad-Export-Date: 2009-09-06 10:48+0000\n" "X-Generator: Launchpad (build Unknown)\n" #: ../data/chmsee.glade.h:1 @@ -103,6 +103,10 @@ msgid "Show/Hide Panel" msgstr "Mostrar/Ocultar panel" +#: ../data/chmsee.glade.h:23 +msgid "Side _Pane" +msgstr "_Panel lateral" + #: ../data/chmsee.glade.h:24 msgid "The HTML Help(CHM) viewer for Unix/Linux" msgstr "El visor de Ayuda HTML (CHM) para Unix/Linux" @@ -111,15 +115,15 @@ msgid "" "Universal\n" "Simplified Chinese\n" -"Tradtional Chinese\n" +"Traditional Chinese\n" "Japanese\n" "Korean\n" "Russian\n" -"Ukrainain" +"Ukrainian" msgstr "" "Universal\n" -"Chino simplificado\n" -"Chino tradicional\n" +"Chino Simplificado\n" +"Chino Tradicional\n" "Japonés\n" "Coreano\n" "Ruso\n" @@ -165,6 +169,10 @@ msgid "_Forward" msgstr "_Adelante" +#: ../data/chmsee.glade.h:42 +msgid "_Full Screen" +msgstr "_Pantalla completa" + #: ../data/chmsee.glade.h:43 msgid "_Help" msgstr "_Ayuda" @@ -189,68 +197,73 @@ " DiegoJ https://launchpad.net/~diegojromerolopez\n" "\n" "Launchpad Contributions:\n" -" DiegoJ https://launchpad.net/~diegojromerolopez" +" DiegoJ https://launchpad.net/~diegojromerolopez\n" +" Mauro de Carvalho https://launchpad.net/~mauro-dec" #: ../data/chmsee.desktop.in.h:2 msgid "HTML Help(CHM) viewer" msgstr "Visor de Ayuda HTML (CHM)" -#: ../src/chmsee.c:449 +#: ../src/chmsee.c:506 #, c-format msgid "URI redirect: \"%s\" -> \"%s\"" msgstr "Redirección de URI: \"%s\" -> \"%s\"" -#: ../src/chmsee.c:610 +#: ../src/chmsee.c:671 msgid "CHM Files" msgstr "Archivos CHM" -#: ../src/chmsee.c:615 +#: ../src/chmsee.c:676 msgid "All Files" msgstr "Todos los archivos" -#: ../src/chmsee.c:1135 +#: ../src/chmsee.c:1196 msgid "Ready!" msgstr "¡Listo!" -#: ../src/chmsee.c:1191 +#: ../src/chmsee.c:1253 msgid "Topics" msgstr "Temas" -#: ../src/chmsee.c:1208 +#: ../src/chmsee.c:1267 +msgid "Index" +msgstr "Índice" + +#: ../src/chmsee.c:1276 msgid "Bookmarks" msgstr "Marcadores" #. Custom label widget, with a close button -#: ../src/chmsee.c:1370 ../src/chmsee.c:1545 +#: ../src/chmsee.c:1440 ../src/chmsee.c:1615 msgid "No Title" msgstr "Sin título" -#: ../src/chmsee.c:1649 +#: ../src/chmsee.c:1719 #, c-format msgid "Error loading file '%s'" msgstr "Error cargando el archivo '%s'" -#: ../src/models/chmfile.c:239 +#: ../src/models/chmfile.c:253 #, c-format msgid "cannot open chmfile: %s" msgstr "no se puede abrir el archivo CHM: %s" -#: ../src/models/chmfile.c:246 +#: ../src/models/chmfile.c:260 #, c-format msgid "Extract chmfile failed: %s" msgstr "Ha fallado la extracción del archivo CHM: %s" -#: ../src/models/chmfile.c:272 +#: ../src/models/chmfile.c:286 #, c-format msgid "open \"%s\" failed: %s" msgstr "la apertura de \"%s\" ha fallado: %s" -#: ../src/models/chmfile.c:322 +#: ../src/models/chmfile.c:336 #, c-format msgid "Can not open chm file %s." msgstr "No se puede abrir el archivo chm %s." -#: ../src/models/chmfile.c:580 +#: ../src/models/chmfile.c:594 msgid "Can't found hhc file." msgstr "No se encontró el archivo hhc" @@ -258,34 +271,43 @@ msgid "Bookmark" msgstr "Marcador" -#: ../src/main.cpp:88 +#: ../src/main.cpp:107 msgid "Display the version and exit" msgstr "Mostrar la versión y salir" -#: ../src/main.cpp:93 +#: ../src/main.cpp:112 msgid "be verbose, repeat 3 times to get all info" msgstr "ser más explícito, repítalo 3 veces para obtener toda la información" -#: ../src/main.cpp:98 +#: ../src/main.cpp:117 msgid "be quiet, repeat 2 times to disable all info" msgstr "" "ser silencioso, repítalo 2 veces para deshabilitar toda la información" -#: ../src/main.cpp:135 +#: ../src/main.cpp:154 #, c-format msgid "more than 1 argument\n" msgstr "más de un argumento\n" -#~ msgid "_Home" -#~ msgstr "_Inicio" +#~ msgid "" +#~ "Universal\n" +#~ "Simplified Chinese\n" +#~ "Tradtional Chinese\n" +#~ "Japanese\n" +#~ "Korean\n" +#~ "Russian\n" +#~ "Ukrainain" +#~ msgstr "" +#~ "Universal\n" +#~ "Chino simplificado\n" +#~ "Chino tradicional\n" +#~ "Japonés\n" +#~ "Coreano\n" +#~ "Ruso\n" +#~ "Ucraniano" #~ msgid "_Setup" #~ msgstr "_Configurar" -#: ../data/chmsee.glade.h:23 -msgid "Side _Pane" -msgstr "_Panel lateral" - -#: ../data/chmsee.glade.h:42 -msgid "_Full Screen" -msgstr "_Pantalla completa" +#~ msgid "_Home" +#~ msgstr "_Inicio" diff -Nru chmsee-1.0.6/po/POTFILES.in chmsee-1.0.7/po/POTFILES.in --- chmsee-1.0.6/po/POTFILES.in 2009-07-12 04:02:53.000000000 +0100 +++ chmsee-1.0.7/po/POTFILES.in 2009-09-14 14:51:03.000000000 +0100 @@ -2,10 +2,25 @@ # Please keep this file sorted alphabetically. data/chmsee.glade data/chmsee.desktop.in +src/booktree.c src/chmsee.c -src/models/chmfile.c -src/models/bookmarks.c -src/ui_bookmarks.c src/html.c +src/html-factory.c +src/ihtml.c +src/marshal.c +src/marshal_main.c src/setup.c +src/startup.c +src/ui_bookmarks.c +src/ui_chmfile.c +src/ui_index.c +src/gecko_utils.cpp src/main.cpp +src/models/bookmarks.c +src/models/chmfile.c +src/models/chmfile-factory.c +src/models/chmindex.c +src/models/hhc.c +src/models/ichmfile.c +src/models/link.c +src/utils/utils.c diff -Nru chmsee-1.0.6/po/ru.po chmsee-1.0.7/po/ru.po --- chmsee-1.0.6/po/ru.po 2009-07-12 04:02:53.000000000 +0100 +++ chmsee-1.0.7/po/ru.po 2009-09-14 14:51:03.000000000 +0100 @@ -7,14 +7,14 @@ msgstr "" "Project-Id-Version: chmsee\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2009-05-10 22:47+0800\n" -"PO-Revision-Date: 2009-03-06 14:09+0000\n" -"Last-Translator: Vadim Peretokin \n" +"POT-Creation-Date: 2009-07-14 21:48+0800\n" +"PO-Revision-Date: 2009-08-11 00:08+0000\n" +"Last-Translator: Dmitry Korzhenevsky \n" "Language-Team: Russian \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2009-07-04 04:44+0000\n" +"X-Launchpad-Export-Date: 2009-09-06 10:48+0000\n" "X-Generator: Launchpad (build Unknown)\n" #: ../data/chmsee.glade.h:1 @@ -106,6 +106,10 @@ msgid "Show/Hide Panel" msgstr "Показать/скрыть панель" +#: ../data/chmsee.glade.h:23 +msgid "Side _Pane" +msgstr "Боковая _панель" + #: ../data/chmsee.glade.h:24 msgid "The HTML Help(CHM) viewer for Unix/Linux" msgstr "Просмоторщик файлов HTML Help (СHM) для Unix\\Linux" @@ -114,19 +118,19 @@ msgid "" "Universal\n" "Simplified Chinese\n" -"Tradtional Chinese\n" +"Traditional Chinese\n" "Japanese\n" "Korean\n" "Russian\n" -"Ukrainain" +"Ukrainian" msgstr "" -"Универсальная\n" -"Упрощённая китайская\n" -"Традиционная китайская\n" -"Японская\n" -"Корейская\n" -"Русская\n" -"Украинская" +"Общий\n" +"Упрощенный Китайский\n" +"Традиционный Китайский\n" +"Японский\n" +"Корейский\n" +"Русский\n" +"Украинский" #: ../data/chmsee.glade.h:32 msgid "Variable Width:" @@ -168,6 +172,10 @@ msgid "_Forward" msgstr "_Вперед" +#: ../data/chmsee.glade.h:42 +msgid "_Full Screen" +msgstr "_Во весь экран" + #: ../data/chmsee.glade.h:43 msgid "_Help" msgstr "_Справка" @@ -194,7 +202,9 @@ "\n" "Launchpad Contributions:\n" " Alexander Slovesnik https://launchpad.net/~unghost\n" +" Dmitry Korzhenevsky https://launchpad.net/~lynx-programist\n" " Max Habets https://launchpad.net/~sky3\n" +" Nkolay Parukhin https://launchpad.net/~parukhin\n" " Vadim Peretokin https://launchpad.net/~vperetokin\n" " andvalb https://launchpad.net/~andvalb" @@ -202,96 +212,109 @@ msgid "HTML Help(CHM) viewer" msgstr "Просмоторщик файлов HTML Help (CHM)" -#: ../src/chmsee.c:610 +#: ../src/chmsee.c:506 +#, c-format +msgid "URI redirect: \"%s\" -> \"%s\"" +msgstr "Перенаправление ссылки: \"%s\" -> \"%s\"" + +#: ../src/chmsee.c:671 msgid "CHM Files" msgstr "Файлы CHM" -#: ../src/chmsee.c:615 +#: ../src/chmsee.c:676 msgid "All Files" msgstr "Все файлы" -#: ../src/chmsee.c:1135 +#: ../src/chmsee.c:1196 msgid "Ready!" msgstr "Готов!" -#: ../src/chmsee.c:1191 +#: ../src/chmsee.c:1253 msgid "Topics" msgstr "Содержание" -#: ../src/chmsee.c:1208 +#: ../src/chmsee.c:1267 +msgid "Index" +msgstr "Индекс" + +#: ../src/chmsee.c:1276 msgid "Bookmarks" msgstr "Закладки" #. Custom label widget, with a close button -#: ../src/chmsee.c:1370 ../src/chmsee.c:1545 +#: ../src/chmsee.c:1440 ../src/chmsee.c:1615 msgid "No Title" msgstr "Заголовок отсутствует" -#: ../src/chmsee.c:1649 +#: ../src/chmsee.c:1719 #, c-format msgid "Error loading file '%s'" msgstr "Ошибка загрузки файла '%s'" -#: ../src/models/chmfile.c:239 +#: ../src/models/chmfile.c:253 #, c-format msgid "cannot open chmfile: %s" msgstr "не могу открыть файл chm: %s" -#: ../src/models/chmfile.c:246 +#: ../src/models/chmfile.c:260 #, c-format msgid "Extract chmfile failed: %s" msgstr "Ошибка извлечения файла chm: %s" -#: ../src/models/chmfile.c:272 +#: ../src/models/chmfile.c:286 #, c-format msgid "open \"%s\" failed: %s" msgstr "при открытии \"%s\" ошибка: %s" +#: ../src/models/chmfile.c:336 +#, c-format +msgid "Can not open chm file %s." +msgstr "Не удалось открыть chm файл %s." + +#: ../src/models/chmfile.c:594 +msgid "Can't found hhc file." +msgstr "Не удалось найти hhc файл." + #: ../src/ui_bookmarks.c:315 msgid "Bookmark" msgstr "Закладка" -#: ../src/main.cpp:88 +#: ../src/main.cpp:107 msgid "Display the version and exit" msgstr "Отобразить версию и выйти" -#: ../src/main.cpp:135 +#: ../src/main.cpp:112 +msgid "be verbose, repeat 3 times to get all info" +msgstr "подробно, для вывода всей информации повторить 3 раза" + +#: ../src/main.cpp:117 +msgid "be quiet, repeat 2 times to disable all info" +msgstr "тихо, для отключения вывода всей информации повторить 2 раза" + +#: ../src/main.cpp:154 #, c-format msgid "more than 1 argument\n" msgstr "больше чем 1 аргумент\n" -#~ msgid "_Home" -#~ msgstr "_Домой" - #~ msgid "_Setup" #~ msgstr "_Установить" -#: ../data/chmsee.glade.h:23 -msgid "Side _Pane" -msgstr "" - -#: ../data/chmsee.glade.h:42 -msgid "_Full Screen" -msgstr "" - -#: ../src/chmsee.c:449 -#, c-format -msgid "URI redirect: \"%s\" -> \"%s\"" -msgstr "" - -#: ../src/models/chmfile.c:322 -#, c-format -msgid "Can not open chm file %s." -msgstr "" - -#: ../src/models/chmfile.c:580 -msgid "Can't found hhc file." -msgstr "" - -#: ../src/main.cpp:93 -msgid "be verbose, repeat 3 times to get all info" -msgstr "" +#~ msgid "_Home" +#~ msgstr "_Домой" -#: ../src/main.cpp:98 -msgid "be quiet, repeat 2 times to disable all info" -msgstr "" +#~ msgid "" +#~ "Universal\n" +#~ "Simplified Chinese\n" +#~ "Tradtional Chinese\n" +#~ "Japanese\n" +#~ "Korean\n" +#~ "Russian\n" +#~ "Ukrainain" +#~ msgstr "" +#~ "Универсальная\n" +#~ "Упрощённая китайская\n" +#~ "Традиционная китайская\n" +#~ "Японская\n" +#~ "Корейская\n" +#~ "Русская\n" +#~ "Украинская" diff -Nru chmsee-1.0.6/po/sv.po chmsee-1.0.7/po/sv.po --- chmsee-1.0.6/po/sv.po 2009-07-12 04:02:53.000000000 +0100 +++ chmsee-1.0.7/po/sv.po 2009-09-14 14:51:03.000000000 +0100 @@ -7,14 +7,14 @@ msgstr "" "Project-Id-Version: chmsee\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2009-05-10 22:47+0800\n" -"PO-Revision-Date: 2009-01-11 09:27+0000\n" -"Last-Translator: Daniel Nylander \n" +"POT-Creation-Date: 2009-07-14 21:48+0800\n" +"PO-Revision-Date: 2009-08-26 11:45+0000\n" +"Last-Translator: Martin Lindhe \n" "Language-Team: Swedish \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2009-07-04 04:44+0000\n" +"X-Launchpad-Export-Date: 2009-09-06 10:48+0000\n" "X-Generator: Launchpad (build Unknown)\n" #: ../data/chmsee.glade.h:1 @@ -61,6 +61,10 @@ msgid "ChmSee" msgstr "ChmSee" +#: ../data/chmsee.glade.h:12 +msgid "Copy Page _Location" +msgstr "Kopiera sidans _sökväg" + #: ../data/chmsee.glade.h:13 msgid "Fixed Width:" msgstr "Fast bredd:" @@ -101,6 +105,10 @@ msgid "Show/Hide Panel" msgstr "Visa/dölj panel" +#: ../data/chmsee.glade.h:23 +msgid "Side _Pane" +msgstr "Sido_panel" + #: ../data/chmsee.glade.h:24 msgid "The HTML Help(CHM) viewer for Unix/Linux" msgstr "HTML-hjälpvisare (CHM) för Unix/Linux" @@ -109,19 +117,12 @@ msgid "" "Universal\n" "Simplified Chinese\n" -"Tradtional Chinese\n" +"Traditional Chinese\n" "Japanese\n" "Korean\n" "Russian\n" -"Ukrainain" +"Ukrainian" msgstr "" -"Universell\n" -"Förenklad kinesiska\n" -"Tradtionell kinesiska\n" -"Japanska\n" -"Koreanska\n" -"Ryska\n" -"Ukrainska" #: ../data/chmsee.glade.h:32 msgid "Variable Width:" @@ -163,6 +164,10 @@ msgid "_Forward" msgstr "_Framåt" +#: ../data/chmsee.glade.h:42 +msgid "_Full Screen" +msgstr "_Helskärm" + #: ../data/chmsee.glade.h:43 msgid "_Help" msgstr "_Hjälp" @@ -175,6 +180,10 @@ msgid "_View" msgstr "_Visa" +#: ../data/chmsee.glade.h:46 +msgid "http://code.google.com/p/chmsee" +msgstr "" + #. TRANSLATORS: Replace this string with your names, one name per line. #: ../data/chmsee.glade.h:48 msgid "translator-credits" @@ -183,110 +192,116 @@ " Daniel Nylander https://launchpad.net/~yeager\n" "\n" "Launchpad Contributions:\n" -" Daniel Nylander https://launchpad.net/~yeager" +" Daniel Nylander https://launchpad.net/~yeager\n" +" Martin Lindhe https://launchpad.net/~martin-unicorn" #: ../data/chmsee.desktop.in.h:2 msgid "HTML Help(CHM) viewer" msgstr "HTML-hjälpvisare (CHM)" -#: ../src/chmsee.c:610 +#: ../src/chmsee.c:506 +#, c-format +msgid "URI redirect: \"%s\" -> \"%s\"" +msgstr "URI omdirigering: \"%s\" -> \"%s\"" + +#: ../src/chmsee.c:671 msgid "CHM Files" msgstr "CHM-filer" -#: ../src/chmsee.c:615 +#: ../src/chmsee.c:676 msgid "All Files" msgstr "Alla filer" -#: ../src/chmsee.c:1135 +#: ../src/chmsee.c:1196 msgid "Ready!" msgstr "Redo!" -#: ../src/chmsee.c:1191 +#: ../src/chmsee.c:1253 msgid "Topics" msgstr "Ämnen" -#: ../src/chmsee.c:1208 +#: ../src/chmsee.c:1267 +msgid "Index" +msgstr "Översikt" + +#: ../src/chmsee.c:1276 msgid "Bookmarks" msgstr "Bokmärken" #. Custom label widget, with a close button -#: ../src/chmsee.c:1370 ../src/chmsee.c:1545 +#: ../src/chmsee.c:1440 ../src/chmsee.c:1615 msgid "No Title" msgstr "Ingen titel" -#: ../src/chmsee.c:1649 +#: ../src/chmsee.c:1719 #, c-format msgid "Error loading file '%s'" msgstr "Fel vid inläsning av filen \"%s\"" -#: ../src/ui_bookmarks.c:315 -msgid "Bookmark" -msgstr "Bokmärke" - -#~ msgid "_Home" -#~ msgstr "_Hem" - -#~ msgid "_Setup" -#~ msgstr "_Inställningar" - -#: ../data/chmsee.glade.h:12 -msgid "Copy Page _Location" -msgstr "" - -#: ../data/chmsee.glade.h:23 -msgid "Side _Pane" -msgstr "" - -#: ../data/chmsee.glade.h:42 -msgid "_Full Screen" -msgstr "" - -#: ../data/chmsee.glade.h:46 -msgid "http://code.google.com/p/chmsee" -msgstr "" - -#: ../src/chmsee.c:449 -#, c-format -msgid "URI redirect: \"%s\" -> \"%s\"" -msgstr "" - -#: ../src/models/chmfile.c:239 +#: ../src/models/chmfile.c:253 #, c-format msgid "cannot open chmfile: %s" -msgstr "" +msgstr "Kan inte öppna chm-fil: %s" -#: ../src/models/chmfile.c:246 +#: ../src/models/chmfile.c:260 #, c-format msgid "Extract chmfile failed: %s" -msgstr "" +msgstr "Misslyckades att packa upp chm-fil: %s" -#: ../src/models/chmfile.c:272 +#: ../src/models/chmfile.c:286 #, c-format msgid "open \"%s\" failed: %s" -msgstr "" +msgstr "Misslyckades att öppna \"%s\": %s" -#: ../src/models/chmfile.c:322 +#: ../src/models/chmfile.c:336 #, c-format msgid "Can not open chm file %s." -msgstr "" +msgstr "Kan inte öppna chm-fil %s." -#: ../src/models/chmfile.c:580 +#: ../src/models/chmfile.c:594 msgid "Can't found hhc file." -msgstr "" +msgstr "Kan inte hitta hhc-fil." -#: ../src/main.cpp:88 +#: ../src/ui_bookmarks.c:315 +msgid "Bookmark" +msgstr "Bokmärke" + +#: ../src/main.cpp:107 msgid "Display the version and exit" -msgstr "" +msgstr "Visa versionen och avsluta" -#: ../src/main.cpp:93 +#: ../src/main.cpp:112 msgid "be verbose, repeat 3 times to get all info" -msgstr "" +msgstr "var detaljerad, upprepa 3 gånger för att visa all information" -#: ../src/main.cpp:98 +#: ../src/main.cpp:117 msgid "be quiet, repeat 2 times to disable all info" -msgstr "" +msgstr "var tyst, upprepa 2 gånger för att stänga av all information" -#: ../src/main.cpp:135 +#: ../src/main.cpp:154 #, c-format msgid "more than 1 argument\n" -msgstr "" +msgstr "mer än ett argument\n" + +#~ msgid "" +#~ "Universal\n" +#~ "Simplified Chinese\n" +#~ "Tradtional Chinese\n" +#~ "Japanese\n" +#~ "Korean\n" +#~ "Russian\n" +#~ "Ukrainain" +#~ msgstr "" +#~ "Universell\n" +#~ "Förenklad kinesiska\n" +#~ "Tradtionell kinesiska\n" +#~ "Japanska\n" +#~ "Koreanska\n" +#~ "Ryska\n" +#~ "Ukrainska" + +#~ msgid "_Setup" +#~ msgstr "_Inställningar" + +#~ msgid "_Home" +#~ msgstr "_Hem" diff -Nru chmsee-1.0.6/po/zh_CN.po chmsee-1.0.7/po/zh_CN.po --- chmsee-1.0.6/po/zh_CN.po 2009-07-12 04:02:53.000000000 +0100 +++ chmsee-1.0.7/po/zh_CN.po 2009-09-14 14:51:03.000000000 +0100 @@ -7,14 +7,14 @@ msgstr "" "Project-Id-Version: ChmSee 1.0.2\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2009-05-10 22:47+0800\n" -"PO-Revision-Date: 2009-06-03 13:28+0000\n" -"Last-Translator: zhangmiao \n" +"POT-Creation-Date: 2009-07-14 21:48+0800\n" +"PO-Revision-Date: 2009-08-27 03:19+0000\n" +"Last-Translator: Careone \n" "Language-Team: szlug \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2009-07-04 04:44+0000\n" +"X-Launchpad-Export-Date: 2009-09-06 10:48+0000\n" "X-Generator: Launchpad (build Unknown)\n" #: ../data/chmsee.glade.h:1 @@ -104,6 +104,10 @@ msgid "Show/Hide Panel" msgstr "显示/隐藏导航栏" +#: ../data/chmsee.glade.h:23 +msgid "Side _Pane" +msgstr "侧边栏(_P)" + #: ../data/chmsee.glade.h:24 msgid "The HTML Help(CHM) viewer for Unix/Linux" msgstr "Unix/Linux 下的 HTML Help(CHM) 阅读工具" @@ -112,19 +116,20 @@ msgid "" "Universal\n" "Simplified Chinese\n" -"Tradtional Chinese\n" +"Traditional Chinese\n" "Japanese\n" "Korean\n" "Russian\n" -"Ukrainain" +"Ukrainian" msgstr "" -"自动选择\n" -"简体中文\n" -"繁体中文\n" -"日语\n" -"朝鲜语\n" -"俄语\n" -"乌克兰语" +"Copy text \t\n" +"Universal (通用)\n" +"Simplified Chinese (简体中文)\n" +"Traditional Chinese (繁体中文)\n" +"Japanese (日语)\n" +"Korean (朝鲜语)\n" +"Russian (俄语)\n" +"Ukrainian (乌克兰语)" #: ../data/chmsee.glade.h:32 msgid "Variable Width:" @@ -166,6 +171,10 @@ msgid "_Forward" msgstr "前进(_F)" +#: ../data/chmsee.glade.h:42 +msgid "_Full Screen" +msgstr "全屏(_F)" + #: ../data/chmsee.glade.h:43 msgid "_Help" msgstr "帮助(_H)" @@ -189,6 +198,7 @@ "翻译人员\n" "\n" "Launchpad Contributions:\n" +" Careone https://launchpad.net/~zzbusagain\n" " Ji YongGang https://launchpad.net/~jungle-soforge-studio\n" " LI Daobing https://launchpad.net/~lidaobing\n" " zhangmiao https://launchpad.net/~mymzhang" @@ -197,62 +207,66 @@ msgid "HTML Help(CHM) viewer" msgstr "HTML Help(CHM) 文件阅读工具" -#: ../src/chmsee.c:449 +#: ../src/chmsee.c:506 #, c-format msgid "URI redirect: \"%s\" -> \"%s\"" msgstr "URI 重定向: \"%s\" -> \"%s\"" -#: ../src/chmsee.c:610 +#: ../src/chmsee.c:671 msgid "CHM Files" msgstr "CHM 文件" -#: ../src/chmsee.c:615 +#: ../src/chmsee.c:676 msgid "All Files" msgstr "所有文件" -#: ../src/chmsee.c:1135 +#: ../src/chmsee.c:1196 msgid "Ready!" msgstr "就绪!" -#: ../src/chmsee.c:1191 +#: ../src/chmsee.c:1253 msgid "Topics" msgstr "目录" -#: ../src/chmsee.c:1208 +#: ../src/chmsee.c:1267 +msgid "Index" +msgstr "索引" + +#: ../src/chmsee.c:1276 msgid "Bookmarks" msgstr "书签" #. Custom label widget, with a close button -#: ../src/chmsee.c:1370 ../src/chmsee.c:1545 +#: ../src/chmsee.c:1440 ../src/chmsee.c:1615 msgid "No Title" msgstr "无标题" -#: ../src/chmsee.c:1649 +#: ../src/chmsee.c:1719 #, c-format msgid "Error loading file '%s'" msgstr "打开文件错误 '%s'" -#: ../src/models/chmfile.c:239 +#: ../src/models/chmfile.c:253 #, c-format msgid "cannot open chmfile: %s" msgstr "无法打开 chmfile: %s" -#: ../src/models/chmfile.c:246 +#: ../src/models/chmfile.c:260 #, c-format msgid "Extract chmfile failed: %s" msgstr "解包 chmfile 失败: %s" -#: ../src/models/chmfile.c:272 +#: ../src/models/chmfile.c:286 #, c-format msgid "open \"%s\" failed: %s" msgstr "打开 \"%s\" 失败: %s" -#: ../src/models/chmfile.c:322 +#: ../src/models/chmfile.c:336 #, c-format msgid "Can not open chm file %s." msgstr "无法打开 chm 文件 %s。" -#: ../src/models/chmfile.c:580 +#: ../src/models/chmfile.c:594 msgid "Can't found hhc file." msgstr "无法找到 hhc 文件。" @@ -260,33 +274,42 @@ msgid "Bookmark" msgstr "书签" -#: ../src/main.cpp:88 +#: ../src/main.cpp:107 msgid "Display the version and exit" msgstr "显示版本并退出" -#: ../src/main.cpp:135 +#: ../src/main.cpp:112 +msgid "be verbose, repeat 3 times to get all info" +msgstr "详细,重复 3 次获得全部信息" + +#: ../src/main.cpp:117 +msgid "be quiet, repeat 2 times to disable all info" +msgstr "安静,重复 2 次关闭全部信息" + +#: ../src/main.cpp:154 #, c-format msgid "more than 1 argument\n" msgstr "超过 1 个参数\n" +#~ msgid "" +#~ "Universal\n" +#~ "Simplified Chinese\n" +#~ "Tradtional Chinese\n" +#~ "Japanese\n" +#~ "Korean\n" +#~ "Russian\n" +#~ "Ukrainain" +#~ msgstr "" +#~ "自动选择\n" +#~ "简体中文\n" +#~ "繁体中文\n" +#~ "日语\n" +#~ "朝鲜语\n" +#~ "俄语\n" +#~ "乌克兰语" + #~ msgid "_Home" #~ msgstr "首页(_H)" #~ msgid "_Setup" #~ msgstr "设置(_S)" - -#: ../data/chmsee.glade.h:23 -msgid "Side _Pane" -msgstr "侧边栏(_P)" - -#: ../data/chmsee.glade.h:42 -msgid "_Full Screen" -msgstr "全屏(_F)" - -#: ../src/main.cpp:93 -msgid "be verbose, repeat 3 times to get all info" -msgstr "详细,重复 3 次获得全部信息" - -#: ../src/main.cpp:98 -msgid "be quiet, repeat 2 times to disable all info" -msgstr "安静,重复 2 次关闭全部信息" diff -Nru chmsee-1.0.6/po/zh_TW.po chmsee-1.0.7/po/zh_TW.po --- chmsee-1.0.6/po/zh_TW.po 1970-01-01 01:00:00.000000000 +0100 +++ chmsee-1.0.7/po/zh_TW.po 2009-09-14 14:51:03.000000000 +0100 @@ -0,0 +1,298 @@ +# Traditional Chinese translation for chmsee. +# Copyright (C) 2006 Free Software Foundation, Inc. +# This file is distributed under the same license as the chmsee package. +# Wei-Lun Chao , 2009. +# +msgid "" +msgstr "" +"Project-Id-Version: chmsee 1.0.6\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2009-07-14 21:48+0800\n" +"PO-Revision-Date: 2009-07-14 15:36+0000\n" +"Last-Translator: Wei-Lun Chao \n" +"Language-Team: Chinese (traditional) \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Launchpad-Export-Date: 2009-09-06 10:48+0000\n" +"X-Generator: Launchpad (build Unknown)\n" + +#: ../data/chmsee.glade.h:1 +msgid "Cache" +msgstr "快取" + +#: ../data/chmsee.glade.h:2 +msgid "Charset" +msgstr "字元集" + +#: ../data/chmsee.glade.h:3 +msgid "Font" +msgstr "字型" + +#: ../data/chmsee.glade.h:4 +msgid "About" +msgstr "關於" + +#: ../data/chmsee.glade.h:5 +msgid "About..." +msgstr "關於…" + +#: ../data/chmsee.glade.h:6 +msgid "Auto-Detect:" +msgstr "自動偵測:" + +#: ../data/chmsee.glade.h:7 +msgid "Back" +msgstr "向後" + +#: ../data/chmsee.glade.h:8 +msgid "" +"CHM files extracted in this cache folder, you can press Clear button to free " +"disk space.\n" +"\n" +"NOTE: If you are viewing a CHM file, you need reopen it after cleaning." +msgstr "" +"CHM 檔案在這個快取資料夾中被擷取出來,您可以按下清空按鈕以釋放磁碟空間。\n" +"\n" +"註:如果您正在觀看 CHM 檔案,您需要在清理之後重新開啟它。" + +#: ../data/chmsee.glade.h:11 ../data/chmsee.desktop.in.h:1 +msgid "ChmSee" +msgstr "檢視 CHM" + +#: ../data/chmsee.glade.h:12 +msgid "Copy Page _Location" +msgstr "複製頁面位置(_L)" + +#: ../data/chmsee.glade.h:13 +msgid "Fixed Width:" +msgstr "固定寬度:" + +#: ../data/chmsee.glade.h:14 +msgid "Forward" +msgstr "向前" + +#: ../data/chmsee.glade.h:15 +msgid "Home" +msgstr "首頁" + +#: ../data/chmsee.glade.h:16 +msgid "Normal" +msgstr "原始大小" + +#: ../data/chmsee.glade.h:17 +msgid "Open File" +msgstr "開啟檔案" + +#: ../data/chmsee.glade.h:18 +msgid "Open Link in New _Tab" +msgstr "在新分頁中開啟鏈結(_T)" + +#: ../data/chmsee.glade.h:19 +msgid "Panel" +msgstr "面板" + +#: ../data/chmsee.glade.h:20 +msgid "Select _All" +msgstr "全選(_A)" + +#: ../data/chmsee.glade.h:21 +msgid "Setup" +msgstr "設定" + +#: ../data/chmsee.glade.h:22 +msgid "Show/Hide Panel" +msgstr "顯示/隱藏面板" + +#: ../data/chmsee.glade.h:23 +msgid "Side _Pane" +msgstr "側邊窗格(_P)" + +#: ../data/chmsee.glade.h:24 +msgid "The HTML Help(CHM) viewer for Unix/Linux" +msgstr "用於 Unix/Linux 的 HTML 說明檔(CHM) 檢視器" + +#: ../data/chmsee.glade.h:25 +msgid "" +"Universal\n" +"Simplified Chinese\n" +"Traditional Chinese\n" +"Japanese\n" +"Korean\n" +"Russian\n" +"Ukrainian" +msgstr "" + +#: ../data/chmsee.glade.h:32 +msgid "Variable Width:" +msgstr "可變寬度:" + +#: ../data/chmsee.glade.h:33 +msgid "Zoom In" +msgstr "放大" + +#: ../data/chmsee.glade.h:34 +msgid "Zoom Out" +msgstr "縮小" + +#: ../data/chmsee.glade.h:35 +msgid "_Back" +msgstr "向後(_B)" + +#: ../data/chmsee.glade.h:36 +msgid "_Close Tab" +msgstr "關閉分頁(_C)" + +#: ../data/chmsee.glade.h:37 +msgid "_Copy" +msgstr "複製(_C)" + +#: ../data/chmsee.glade.h:38 +msgid "_Copy Link Location" +msgstr "複製鏈結位置(_C)" + +#: ../data/chmsee.glade.h:39 +msgid "_Edit" +msgstr "編輯(_E)" + +#: ../data/chmsee.glade.h:40 +msgid "_File" +msgstr "檔案(_F)" + +#: ../data/chmsee.glade.h:41 +msgid "_Forward" +msgstr "向前(_F)" + +#: ../data/chmsee.glade.h:42 +msgid "_Full Screen" +msgstr "全螢幕(_F)" + +#: ../data/chmsee.glade.h:43 +msgid "_Help" +msgstr "求助(_H)" + +#: ../data/chmsee.glade.h:44 +msgid "_New Tab" +msgstr "新分頁(_N)" + +#: ../data/chmsee.glade.h:45 +msgid "_View" +msgstr "檢視(_V)" + +#: ../data/chmsee.glade.h:46 +msgid "http://code.google.com/p/chmsee" +msgstr "http://code.google.com/p/chmsee" + +#. TRANSLATORS: Replace this string with your names, one name per line. +#: ../data/chmsee.glade.h:48 +msgid "translator-credits" +msgstr "" +"趙惟倫 \n" +"\n" +"Launchpad Contributions:\n" +" Wei-Lun Chao https://launchpad.net/~chaoweilun" + +#: ../data/chmsee.desktop.in.h:2 +msgid "HTML Help(CHM) viewer" +msgstr "HTML 說明檔(CHM) 檢視器" + +#: ../src/chmsee.c:506 +#, c-format +msgid "URI redirect: \"%s\" -> \"%s\"" +msgstr "URI 重新導向:「%s」->「%s」" + +#: ../src/chmsee.c:671 +msgid "CHM Files" +msgstr "CHM 檔案" + +#: ../src/chmsee.c:676 +msgid "All Files" +msgstr "所有檔案" + +#: ../src/chmsee.c:1196 +msgid "Ready!" +msgstr "就緒!" + +#: ../src/chmsee.c:1253 +msgid "Topics" +msgstr "主題" + +#: ../src/chmsee.c:1267 +msgid "Index" +msgstr "索引" + +#: ../src/chmsee.c:1276 +msgid "Bookmarks" +msgstr "書籤" + +#. Custom label widget, with a close button +#: ../src/chmsee.c:1440 ../src/chmsee.c:1615 +msgid "No Title" +msgstr "無標題" + +#: ../src/chmsee.c:1719 +#, c-format +msgid "Error loading file '%s'" +msgstr "載入檔案「%s」時發生錯誤" + +#: ../src/models/chmfile.c:253 +#, c-format +msgid "cannot open chmfile: %s" +msgstr "無法開啟 chm 檔案:%s" + +#: ../src/models/chmfile.c:260 +#, c-format +msgid "Extract chmfile failed: %s" +msgstr "擷取 chm 檔案時失敗:%s" + +#: ../src/models/chmfile.c:286 +#, c-format +msgid "open \"%s\" failed: %s" +msgstr "開啟「%s」時失敗:%s" + +#: ../src/models/chmfile.c:336 +#, c-format +msgid "Can not open chm file %s." +msgstr "無法開啟 chm 檔案 %s。" + +#: ../src/models/chmfile.c:594 +msgid "Can't found hhc file." +msgstr "無法找到 hhc 檔案。" + +#: ../src/ui_bookmarks.c:315 +msgid "Bookmark" +msgstr "加入書籤" + +#: ../src/main.cpp:107 +msgid "Display the version and exit" +msgstr "顯示版本然後離開" + +#: ../src/main.cpp:112 +msgid "be verbose, repeat 3 times to get all info" +msgstr "細節模式,重複三次以取得所有資訊" + +#: ../src/main.cpp:117 +msgid "be quiet, repeat 2 times to disable all info" +msgstr "安靜模式,重複兩次以停用全部資訊" + +#: ../src/main.cpp:154 +#, c-format +msgid "more than 1 argument\n" +msgstr "多於一項引數\n" + +#~ msgid "" +#~ "Universal\n" +#~ "Simplified Chinese\n" +#~ "Tradtional Chinese\n" +#~ "Japanese\n" +#~ "Korean\n" +#~ "Russian\n" +#~ "Ukrainain" +#~ msgstr "" +#~ "通用\n" +#~ "簡體中文\n" +#~ "繁體中文\n" +#~ "日語\n" +#~ "韓語\n" +#~ "俄語\n" +#~ "烏克蘭語" diff -Nru chmsee-1.0.6/src/booktree.c chmsee-1.0.7/src/booktree.c --- chmsee-1.0.6/src/booktree.c 2009-07-12 04:02:53.000000000 +0100 +++ chmsee-1.0.7/src/booktree.c 2009-09-14 14:51:03.000000000 +0100 @@ -1,5 +1,6 @@ /* * Copyright (c) 2006 Ji YongGang + * Copyright (C) 2009 LI Daobing * * ChmSee is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,10 +20,13 @@ #include "config.h" #include "booktree.h" + +#include "models/hhc.h" #include "utils/utils.h" -static void booktree_class_init(BookTreeClass *); -static void booktree_init(BookTree *); +#define selfp (self->priv) + +static void booktree_dispose(GObject *); static void booktree_finalize(GObject *); static void booktree_selection_changed_cb(GtkTreeSelection *, BookTree *); @@ -34,6 +38,25 @@ static void booktree_insert_node(BookTree *, GNode *, GtkTreeIter *); static void on_row_activated(BookTree* self, GtkTreePath* path); +typedef struct { + GdkPixbuf *pixbuf_opened; + GdkPixbuf *pixbuf_closed; + GdkPixbuf *pixbuf_doc; +} BookTreePixbufs; + +typedef struct { + const gchar *uri; + gboolean found; + GtkTreeIter iter; + GtkTreePath *path; +} FindURIData; + +struct _BookTreePrivate { + GtkTreeStore *store; + BookTreePixbufs *pixbufs; + Hhc *link_tree; +}; + /* Signals */ enum { LINK_SELECTED, @@ -48,43 +71,21 @@ N_COLUMNS }; -static GtkTreeViewClass *parent_class = NULL; static gint signals[LAST_SIGNAL] = { 0 }; -GType -booktree_get_type (void) -{ - static GType type = 0; - - if (!type) { - static const GTypeInfo info = { - sizeof (BookTreeClass), - NULL, - NULL, - (GClassInitFunc)booktree_class_init, - NULL, - NULL, - sizeof (BookTree), - 0, - (GInstanceInitFunc)booktree_init, - }; - - type = g_type_register_static(GTK_TYPE_TREE_VIEW, - "BookTree", - &info, 0); - } +#define GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), TYPE_BOOKTREE, BookTreePrivate)) - return type; -} +G_DEFINE_TYPE (BookTree, booktree, GTK_TYPE_TREE_VIEW); static void booktree_class_init(BookTreeClass *klass) { GObjectClass *object_class; + g_type_class_add_private(klass, sizeof(BookTreePrivate)); object_class = (GObjectClass *)klass; - parent_class = g_type_class_peek_parent(klass); + object_class->dispose = booktree_dispose; object_class->finalize = booktree_finalize; signals[LINK_SELECTED] = @@ -103,13 +104,14 @@ static void booktree_init(BookTree *self) { - self->store = gtk_tree_store_new(N_COLUMNS, + self->priv = GET_PRIVATE(self); + selfp->store = gtk_tree_store_new(N_COLUMNS, GDK_TYPE_PIXBUF, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_POINTER); gtk_tree_view_set_model(GTK_TREE_VIEW (self), - GTK_TREE_MODEL (self->store)); + GTK_TREE_MODEL (selfp->store)); gtk_tree_view_set_headers_visible(GTK_TREE_VIEW (self), FALSE); gtk_tree_view_set_enable_search(GTK_TREE_VIEW(self), TRUE); @@ -124,27 +126,46 @@ } static void +booktree_dispose(GObject* object) { + BookTree* self = BOOKTREE(object); + + if(selfp->store) { + g_object_unref(selfp->store); + selfp->store = NULL; + } + + if(selfp->pixbufs->pixbuf_opened) { + g_object_unref(selfp->pixbufs->pixbuf_opened); + selfp->pixbufs->pixbuf_opened = NULL; + } + + if(selfp->pixbufs->pixbuf_closed) { + g_object_unref(selfp->pixbufs->pixbuf_closed); + selfp->pixbufs->pixbuf_closed = NULL; + } + + if(selfp->pixbufs->pixbuf_doc) { + g_object_unref(selfp->pixbufs->pixbuf_doc); + selfp->pixbufs->pixbuf_doc = NULL; + } +} + +static void booktree_finalize(GObject *object) { - BookTree *tree; + BookTree *self; - tree = BOOKTREE (object); + self = BOOKTREE (object); - g_object_unref(tree->store); + g_free(selfp->pixbufs); - g_object_unref(tree->pixbufs->pixbuf_opened); - g_object_unref(tree->pixbufs->pixbuf_closed); - g_object_unref(tree->pixbufs->pixbuf_doc); - g_free(tree->pixbufs); - - if (G_OBJECT_CLASS (parent_class)->finalize) - G_OBJECT_CLASS (parent_class)->finalize(object); + G_OBJECT_CLASS (booktree_parent_class)->finalize(object); } /* internal functions */ static void -booktree_create_pixbufs(BookTree *tree) +booktree_create_pixbufs(BookTree *self) { BookTreePixbufs *pixbufs; @@ -154,7 +175,7 @@ pixbufs->pixbuf_opened = gdk_pixbuf_new_from_file(get_resource_path("book-open.png"), NULL); pixbufs->pixbuf_doc = gdk_pixbuf_new_from_file(get_resource_path("helpdoc.png"), NULL); - tree->pixbufs = pixbufs; + selfp->pixbufs = pixbufs; } static void @@ -202,18 +223,20 @@ } static void -booktree_populate_tree(BookTree *tree) +booktree_populate_tree(BookTree *self) { GNode *node; - for (node = g_node_first_child(tree->link_tree); + for (node = g_node_first_child(selfp->link_tree); node; node = g_node_next_sibling(node)) - booktree_insert_node(tree, node, NULL); + { + booktree_insert_node(self, node, NULL); + } } static void -booktree_insert_node(BookTree *tree, GNode *node, GtkTreeIter *parent_iter) +booktree_insert_node(BookTree *self, GNode *node, GtkTreeIter *parent_iter) { GtkTreeIter iter; Link *link; @@ -224,30 +247,32 @@ if (g_node_n_children(node)) link_change_type(link, LINK_TYPE_BOOK); - gtk_tree_store_append(tree->store, &iter, parent_iter); + gtk_tree_store_append(selfp->store, &iter, parent_iter); /* d(g_debug("insert node::name = %s", link->name)); */ /* d(g_debug("insert node::uri = %s", link->uri)); */ - if (link->type == LINK_TYPE_BOOK) - gtk_tree_store_set(tree->store, &iter, - COL_OPEN_PIXBUF, tree->pixbufs->pixbuf_opened, - COL_CLOSED_PIXBUF, tree->pixbufs->pixbuf_closed, + if (link->type == LINK_TYPE_BOOK) { + gtk_tree_store_set(selfp->store, &iter, + COL_OPEN_PIXBUF, selfp->pixbufs->pixbuf_opened, + COL_CLOSED_PIXBUF, selfp->pixbufs->pixbuf_closed, COL_TITLE, link->name, COL_LINK, link, -1); - else - gtk_tree_store_set(tree->store, &iter, - COL_OPEN_PIXBUF, tree->pixbufs->pixbuf_doc, - COL_CLOSED_PIXBUF, tree->pixbufs->pixbuf_doc, + } else { + gtk_tree_store_set(selfp->store, &iter, + COL_OPEN_PIXBUF, selfp->pixbufs->pixbuf_doc, + COL_CLOSED_PIXBUF, selfp->pixbufs->pixbuf_doc, COL_TITLE, link->name, COL_LINK, link, -1); + } for (child = g_node_first_child(node); child; - child = g_node_next_sibling(child)) - booktree_insert_node(tree, child, &iter); + child = g_node_next_sibling(child)) { + booktree_insert_node(self, child, &iter); + } } static gboolean @@ -269,21 +294,38 @@ return data->found; } +static gboolean +booktree_find_name_foreach(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, FindURIData *data) +{ + Link *link; + + gtk_tree_model_get(model, iter, COL_LINK, &link, -1); + + if (g_strcmp0(data->uri, link->name) == 0) { + data->found = TRUE; + data->iter = *iter; + data->path = gtk_tree_path_copy(path); + } + + return data->found; +} + + /* callbacks */ static void -booktree_selection_changed_cb(GtkTreeSelection *selection, BookTree *tree) +booktree_selection_changed_cb(GtkTreeSelection *selection, BookTree *self) { GtkTreeIter iter; Link *link; if (gtk_tree_selection_get_selected(selection, NULL, &iter)) { - gtk_tree_model_get(GTK_TREE_MODEL (tree->store), + gtk_tree_model_get(GTK_TREE_MODEL (selfp->store), &iter, COL_LINK, &link, -1); g_debug("book tree emiting '%s'\n", link->uri); - g_signal_emit(tree, signals[LINK_SELECTED], 0, link); + g_signal_emit(self, signals[LINK_SELECTED], 0, link); } } @@ -292,32 +334,48 @@ GtkWidget * booktree_new(GNode *link_tree) { - BookTree *tree; + BookTree *self; - tree = g_object_new(TYPE_BOOKTREE, NULL); + self = g_object_new(TYPE_BOOKTREE, NULL); - tree->link_tree = link_tree; + selfp->link_tree = link_tree; - booktree_populate_tree(tree); + booktree_populate_tree(self); - return GTK_WIDGET (tree); + return GTK_WIDGET (self); } +void booktree_set_model(BookTree* self, GNode* model) { + g_object_unref(selfp->store); + selfp->store = gtk_tree_store_new(N_COLUMNS, + GDK_TYPE_PIXBUF, + GDK_TYPE_PIXBUF, + G_TYPE_STRING, + G_TYPE_POINTER); + gtk_tree_view_set_model(GTK_TREE_VIEW (self), + GTK_TREE_MODEL (selfp->store)); + + + selfp->link_tree = model; + booktree_populate_tree(self); +} + + void -booktree_select_uri(BookTree *tree, const gchar *uri) +booktree_select_uri(BookTree *self, const gchar *uri) { GtkTreeSelection *selection; FindURIData data; gchar *real_uri; - g_return_if_fail(IS_BOOKTREE (tree)); + g_return_if_fail(IS_BOOKTREE (self)); real_uri = get_real_uri(uri); data.found = FALSE; data.uri = real_uri; - gtk_tree_model_foreach(GTK_TREE_MODEL (tree->store), + gtk_tree_model_foreach(GTK_TREE_MODEL (selfp->store), (GtkTreeModelForeachFunc) booktree_find_uri_foreach, &data); @@ -326,19 +384,19 @@ return; } - selection = gtk_tree_view_get_selection(GTK_TREE_VIEW (tree)); + selection = gtk_tree_view_get_selection(GTK_TREE_VIEW (self)); g_signal_handlers_block_by_func(selection, booktree_selection_changed_cb, - tree); + self); - gtk_tree_view_expand_to_path(GTK_TREE_VIEW (tree), data.path); + gtk_tree_view_expand_to_path(GTK_TREE_VIEW (self), data.path); gtk_tree_selection_select_iter(selection, &data.iter); - gtk_tree_view_set_cursor(GTK_TREE_VIEW (tree), data.path, NULL, 0); + gtk_tree_view_set_cursor(GTK_TREE_VIEW (self), data.path, NULL, 0); g_signal_handlers_unblock_by_func(selection, booktree_selection_changed_cb, - tree); + self); gtk_tree_path_free(data.path); g_free(real_uri); @@ -384,3 +442,32 @@ gtk_tree_view_expand_row(GTK_TREE_VIEW(self), path, FALSE); } } + +gboolean booktree_select_link_by_name(BookTree* self, const gchar* name) { + GtkTreeSelection *selection; + FindURIData data; + + g_return_val_if_fail(IS_BOOKTREE (self), FALSE); + + data.found = FALSE; + data.uri = name; + + gtk_tree_model_foreach(GTK_TREE_MODEL (selfp->store), + (GtkTreeModelForeachFunc) booktree_find_name_foreach, + &data); + + if (!data.found) { + g_debug("booktree select uri: cannot found data"); + return FALSE; + } + + selection = gtk_tree_view_get_selection(GTK_TREE_VIEW (self)); + + gtk_tree_view_expand_to_path(GTK_TREE_VIEW (self), data.path); + gtk_tree_selection_select_iter(selection, &data.iter); + gtk_tree_view_set_cursor(GTK_TREE_VIEW (self), data.path, NULL, 0); + + gtk_tree_path_free(data.path); + return TRUE; +} + diff -Nru chmsee-1.0.6/src/booktree.h chmsee-1.0.7/src/booktree.h --- chmsee-1.0.6/src/booktree.h 2009-07-12 04:02:53.000000000 +0100 +++ chmsee-1.0.7/src/booktree.h 2009-09-14 14:51:03.000000000 +0100 @@ -1,5 +1,6 @@ /* * Copyright (c) 2006 Ji YongGang + * Copyright (C) 2009 LI Daobing * * ChmSee is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -17,14 +18,13 @@ * Boston, MA 02110-1301, USA. */ -#ifndef __BOOKTREE_H__ -#define __BOOKTREE_H__ +#ifndef __CHMSEE_BOOKTREE_H__ +#define __CHMSEE_BOOKTREE_H__ #include #include #include "models/link.h" -#include "models/hhc.h" #define TYPE_BOOKTREE \ (booktree_get_type()) @@ -37,29 +37,14 @@ #define IS_BOOKTREE_CLASS(k) \ (G_TYPE_CHECK_CLASS_TYPE ((o), TYPE_BOOKTREE)) -typedef struct { - GdkPixbuf *pixbuf_opened; - GdkPixbuf *pixbuf_closed; - GdkPixbuf *pixbuf_doc; -} BookTreePixbufs; - -typedef struct { - const gchar *uri; - gboolean found; - GtkTreeIter iter; - GtkTreePath *path; -} FindURIData; typedef struct _BookTree BookTree; +typedef struct _BookTreePrivate BookTreePrivate; typedef struct _BookTreeClass BookTreeClass; struct _BookTree { GtkTreeView parent; - - GtkTreeStore *store; - - BookTreePixbufs *pixbufs; - Hhc *link_tree; + BookTreePrivate* priv; }; struct _BookTreeClass { @@ -70,9 +55,16 @@ }; GType booktree_get_type(void); -GtkWidget *booktree_new(GNode *); + +GtkWidget* booktree_new(GNode* model); +void booktree_set_model(BookTree* self, GNode* model); void booktree_select_uri(BookTree *, const gchar *); const gchar *booktree_get_selected_book_title(BookTree *); +/** + * @return true if successful. else return false. + */ +gboolean booktree_select_link_by_name(BookTree* self, const gchar* name); + #endif /* !__BOOKTREE_H__ */ diff -Nru chmsee-1.0.6/src/chmsee.c chmsee-1.0.7/src/chmsee.c --- chmsee-1.0.6/src/chmsee.c 2009-07-12 04:02:53.000000000 +0100 +++ chmsee-1.0.7/src/chmsee.c 2009-09-14 14:51:03.000000000 +0100 @@ -48,6 +48,7 @@ #include "booktree.h" #include "ui_bookmarks.h" #include "ui_index.h" +#include "ui_chmfile.h" #include "setup.h" #include "link.h" #include "utils/utils.h" @@ -61,16 +62,14 @@ }; struct _ChmSeePrivate { - GtkWidget *control_notebook; - GtkWidget *html_notebook; + GtkWidget* menubar; + GtkWidget* toolbar; + GtkWidget* ui_chmfile; + GtkWidget *statusbar; - GtkWidget *booktree; - GtkWidget *bookmark_tree; - GtkWidget* uiIndex; /* the gtktreeview */ - GtkWidget* indexPage; /* the index tab under control_notebook */ - - GtkWidget *statusbar; + GtkActionGroup* action_group; + GtkUIManager* ui_manager; guint scid_default; gboolean has_toc; @@ -89,47 +88,33 @@ gchar *home; gchar *cache_dir; gchar *last_dir; + gchar* context_menu_link; gint state; /* see enum CHMSEE_STATE_* */ }; + + #define selfp (self->priv) #define CHMSEE_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TYPE_CHMSEE, ChmSeePrivate)) -static void chmsee_class_init(ChmSeeClass *); -static void chmsee_init(ChmSee *); static void chmsee_finalize(GObject *); static void chmsee_dispose(GObject* self); static void chmsee_load_config(ChmSee *self); static void chmsee_save_config(ChmSee *self); static void chmsee_set_fullscreen(ChmSee* self, gboolean fullscreen); -static void chmsee_refresh_index(ChmSee* self); -static GtkWidget* chmsee_new_index_page(ChmSee* self); -static void chmsee_on_ui_index_link_selected(ChmSee* self, Link* link); static gboolean delete_cb(GtkWidget *, GdkEvent *, ChmSee *); static void destroy_cb(GtkWidget *, ChmSee *); static gboolean on_configure_event(GtkWidget *, GdkEventConfigure *, ChmSee *); -static gboolean on_keypress_event(GtkWidget *, GdkEventKey *, ChmSee *); static void open_response_cb(GtkWidget *, gint, ChmSee *); static void about_response_cb(GtkDialog *, gint, gpointer); -static void booktree_link_selected_cb(GObject *, Link *, ChmSee *); -static void bookmarks_link_selected_cb(GObject *, Link *, ChmSee *); -static void control_switch_page_cb(GtkNotebook *, GtkNotebookPage *, guint , ChmSee *); -static void html_switch_page_cb(GtkNotebook *, GtkNotebookPage *, guint , ChmSee *); -static void html_location_changed_cb(ChmseeIhtml *, const gchar *, ChmSee *); -static gboolean html_open_uri_cb(ChmseeIhtml *, const gchar *, ChmSee *); -static void html_title_changed_cb(ChmseeIhtml *, const gchar *, ChmSee *); -static void html_context_normal_cb(ChmseeIhtml *, ChmSee *); -static void html_context_link_cb(ChmseeIhtml *, const gchar *, ChmSee *); -static void html_open_new_tab_cb(ChmseeIhtml *, const gchar *, ChmSee *); -static void html_link_message_cb(ChmseeIhtml *, const gchar *, ChmSee *); static void show_sidepane(ChmSee* self); static void hide_sidepane(ChmSee* self); static void set_sidepane_state(ChmSee* self, gboolean state); +static void on_keyboard_escape(GtkWidget*, ChmSee* self); static void on_open(GtkWidget *, ChmSee *); -static void on_close_tab(GtkWidget *, ChmSee *); static void on_setup(GtkWidget *, ChmSee *); static void on_copy(GtkWidget *, ChmSee *); static void on_copy_page_location(GtkWidget*, ChmSee*); @@ -145,25 +130,23 @@ static void on_close_current_tab(GtkWidget *, ChmSee *); static void on_context_new_tab(GtkWidget *, ChmSee *); static void on_context_copy_link(GtkWidget *, ChmSee *); -static void on_fullscreen_toggled(ChmSee* self, GtkWidget* menu); -static void on_sidepane_toggled(ChmSee* self, GtkWidget* menu); +static void on_fullscreen_toggled(GtkWidget*, ChmSee* self); +static void on_sidepane_toggled(GtkWidget*, ChmSee* self); static void on_map(ChmSee* self); static gboolean on_window_state_event(ChmSee* self, GdkEventWindowState* event); static gboolean on_scroll_event(ChmSee* self, GdkEventScroll* event); +static void on_ui_chmfile_model_changed(ChmSee* self, ChmseeIchmfile* chm_file); +static void on_ui_chmfile_html_changed(ChmSee* self, ChmseeIhtml* html); +static void on_ui_chmfile_html_link_message_notify(ChmSee* self, GParamSpec* pspec, ChmseeUiChmfile* ui_chmfile); + static void chmsee_quit(ChmSee *); static void chmsee_open_uri(ChmSee *chmsee, const gchar *uri); static void chmsee_open_file(ChmSee *self, const gchar *filename); static GtkWidget *get_widget(ChmSee *, gchar *); static void populate_window(ChmSee *); -static void display_book(ChmSee *, ChmseeIchmfile *, const gchar *); -static void close_current_book(ChmSee *); static void new_tab(ChmSee *, const gchar *); static ChmseeIhtml *get_active_html(ChmSee *); -static void check_history(ChmSee *, ChmseeIhtml *); -static void update_tab_title(ChmSee *, ChmseeIhtml *); -static void tab_set_title(ChmSee *, ChmseeIhtml *, const gchar *); -static void open_homepage(ChmSee *); static void reload_current_page(ChmSee *); static void update_status_bar(ChmSee *, const gchar *); static void @@ -175,11 +158,116 @@ guint info, guint time); -static gchar *context_menu_link = NULL; +/* static gchar *context_menu_link = NULL; */ static const GtkTargetEntry view_drop_targets[] = { { "text/uri-list", 0, 0 } }; +/* Normal items */ +static const GtkActionEntry entries[] = { + { "FileMenu", NULL, "_File" }, + { "EditMenu", NULL, "_Edit" }, + { "ViewMenu", NULL, "_View" }, + { "HelpMenu", NULL, "_Help" }, + + { "Open", GTK_STOCK_OPEN, "_Open", "O", "Open a file", G_CALLBACK(on_open)}, + { "NewTab", NULL, "_New Tab", "T", NULL, G_CALLBACK(on_open_new_tab)}, + { "CloseTab", NULL, "_Close Tab", "W", NULL, G_CALLBACK(on_close_current_tab)}, + { "Exit", GTK_STOCK_QUIT, "E_xit", "Q", "Exit the program", G_CALLBACK(destroy_cb)}, + + { "Copy", GTK_STOCK_COPY, "_Copy", "C", NULL, G_CALLBACK(on_copy)}, + { "Preferences", GTK_STOCK_PREFERENCES, "_Preferences", NULL, NULL, G_CALLBACK(on_setup)}, + + { "Home", GTK_STOCK_HOME, "_Home", NULL, NULL, G_CALLBACK(on_home)}, + { "Back", GTK_STOCK_GO_BACK, "_Back", "Left", NULL, G_CALLBACK(on_back)}, + { "Forward", GTK_STOCK_GO_FORWARD, "_Forward", "Right", NULL, G_CALLBACK(on_forward)}, + + { "About", GTK_STOCK_ABOUT, "_About", NULL, NULL, G_CALLBACK(on_about)}, + + { "ZoomIn", GTK_STOCK_ZOOM_IN, "Zoom _In", "plus", NULL, G_CALLBACK(on_zoom_in)}, + { "ZoomReset", GTK_STOCK_ZOOM_100, "Normal Size", "0", NULL, G_CALLBACK(on_zoom_reset)}, + { "ZoomOut", GTK_STOCK_ZOOM_OUT, "Zoom _Out", "minus", NULL, G_CALLBACK(on_zoom_out)}, + + { "OpenLinkInNewTab", NULL, "Open Link in New _Tab", NULL, NULL, G_CALLBACK(on_context_new_tab)}, + { "CopyLinkLocation", NULL, "_Copy Link Location", NULL, NULL, G_CALLBACK(on_context_copy_link)}, + { "SelectAll", NULL, "Select _All", NULL, NULL, G_CALLBACK(on_select_all)}, + { "CopyPageLocation", NULL, "Copy Page _Location", NULL, NULL, G_CALLBACK(on_copy_page_location)}, + + { "OnKeyboardEscape", NULL, NULL, "Escape", NULL, G_CALLBACK(on_keyboard_escape)}, + { "OnKeyboardControlEqual", NULL, NULL, "equal", NULL, G_CALLBACK(on_zoom_in)} +}; + +/* Toggle items */ +static const GtkToggleActionEntry toggle_entries[] = { + { "FullScreen", NULL, "_Full Screen", "F11", "Switch between full screen and windowed mode", G_CALLBACK(on_fullscreen_toggled), FALSE }, + { "SidePane", NULL, "Side _Pane", "F9", NULL, G_CALLBACK(on_sidepane_toggled), TRUE } +}; + +/* Radio items */ +static const GtkRadioActionEntry radio_entries[] = { +}; + +static const char *ui_description = + "" + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + "" + "" + ""; + + G_DEFINE_TYPE (ChmSee, chmsee, GTK_TYPE_WINDOW); static void @@ -209,10 +297,9 @@ selfp->lang = 0; selfp->last_dir = g_strdup(g_get_home_dir()); + selfp->context_menu_link = NULL; - selfp->uiIndex = NULL; selfp->book = NULL; - selfp->html_notebook = NULL; selfp->pos_x = -100; selfp->pos_y = -100; selfp->width = 0; @@ -227,10 +314,6 @@ gtk_widget_add_events(GTK_WIDGET(self), GDK_STRUCTURE_MASK | GDK_BUTTON_PRESS_MASK ); - g_signal_connect(G_OBJECT (self), - "key-press-event", - G_CALLBACK (on_keypress_event), - self); g_signal_connect(G_OBJECT(self), "scroll-event", G_CALLBACK(on_scroll_event), @@ -248,6 +331,38 @@ view_drop_targets, G_N_ELEMENTS (view_drop_targets), GDK_ACTION_COPY); + /* Quit event handle */ + g_signal_connect(G_OBJECT (self), + "delete_event", + G_CALLBACK (delete_cb), + self); + g_signal_connect(G_OBJECT (self), + "destroy", + G_CALLBACK (destroy_cb), + self); + + /* Widget size changed event handle */ + g_signal_connect(G_OBJECT (self), + "configure-event", + G_CALLBACK (on_configure_event), + self); + + /* Init gecko */ + chmsee_html_init_system(); + chmsee_html_set_default_lang(selfp->lang); + + populate_window(self); + chmsee_load_config(self); + if (selfp->pos_x >= 0 && selfp->pos_y >= 0) + gtk_window_move(GTK_WINDOW (self), selfp->pos_x, selfp->pos_y); + + if (selfp->width > 0 && selfp->height > 0) + gtk_window_resize(GTK_WINDOW (self), selfp->width, selfp->height); + else + gtk_window_resize(GTK_WINDOW (self), 800, 600); + + gtk_window_set_title(GTK_WINDOW (self), "ChmSee"); + gtk_window_set_icon_from_file(GTK_WINDOW (self), get_resource_path("chmsee-icon.png"), NULL); } @@ -270,6 +385,9 @@ g_free(selfp->last_dir); selfp->last_dir = NULL; } + + g_free(selfp->context_menu_link); + selfp->context_menu_link = NULL; G_OBJECT_CLASS (chmsee_parent_class)->finalize (object); } @@ -282,6 +400,16 @@ selfp->book = NULL; } + if(selfp->action_group) { + g_object_unref(selfp->action_group); + selfp->action_group = NULL; + } + + if(selfp->ui_manager) { + g_object_unref(selfp->ui_manager); + selfp->ui_manager = NULL; + } + G_OBJECT_CLASS(chmsee_parent_class)->dispose(gobject); } @@ -304,9 +432,9 @@ static gboolean on_configure_event(GtkWidget *widget, GdkEventConfigure *event, ChmSee *self) { - if (selfp->html_notebook != NULL - && (event->width != selfp->width || event->height != selfp->height)) + if (event->width != selfp->width || event->height != selfp->height) { reload_current_page(self); + } if(!selfp->fullscreen) { selfp->width = event->width; @@ -318,73 +446,6 @@ return FALSE; } -static gboolean -on_keypress_event_when_fullscreen(GtkWidget *widget, GdkEventKey *event, ChmSee *self) { - switch(event->keyval) { - case GDK_Escape: - case GDK_F11: - chmsee_set_fullscreen(self, FALSE); - return TRUE; - break; - case GDK_F9: - set_sidepane_state(self, - !gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(get_widget(self, "menu_sidepane")))); - return TRUE; - break; - case GDK_Left: - if(event->state & GDK_MOD1_MASK) { - on_back(NULL, self); - return TRUE; - } - break; - case GDK_Right: - if(event->state & GDK_MOD1_MASK) { - on_forward(NULL, self); - return TRUE; - } - break; - case GDK_minus: - if(event->state & GDK_CONTROL_MASK) { - on_zoom_out(NULL, self); - return TRUE; - } - break; - case GDK_plus: - if(event->state & GDK_CONTROL_MASK) { - on_zoom_in(NULL, self); - return TRUE; - } - break; - default: - break; - } - return FALSE; -} - -static gboolean -on_keypress_event_when_unfullscreen(GtkWidget *widget, GdkEventKey *event, ChmSee *self) { - switch(event->keyval) { - case GDK_Escape: - gtk_window_iconify(GTK_WINDOW (self)); - return TRUE; - break; - default: - break; - } - return FALSE; -} - -static gboolean -on_keypress_event(GtkWidget *widget, GdkEventKey *event, ChmSee *self) -{ - g_debug("enter on_keypress_event with event->keyval = %d and event->state = %d", event->keyval, event->state); - if(selfp->fullscreen) { - return on_keypress_event_when_fullscreen(widget, event, self); - } else { - return on_keypress_event_when_unfullscreen(widget, event, self); - } -} - static void open_response_cb(GtkWidget *widget, gint response_id, ChmSee *chmsee) { @@ -401,90 +462,7 @@ g_free(filename); } -static void -booktree_link_selected_cb(GObject *ignored, Link *link, ChmSee *self) -{ - ChmseeIhtml* html; - - g_debug("booktree link selected: %s", link->uri); - if (!g_ascii_strcasecmp(CHMSEE_NO_LINK, link->uri)) - return; - - html = get_active_html(self); - - g_signal_handlers_block_by_func(html, html_open_uri_cb, self); - - chmsee_ihtml_open_uri(html, g_build_filename( - chmsee_ichmfile_get_dir(selfp->book), link->uri, NULL)); - - g_signal_handlers_unblock_by_func(html, html_open_uri_cb, self); - - check_history(self, html); -} - -static void -bookmarks_link_selected_cb(GObject *ignored, Link *link, ChmSee *chmsee) -{ - chmsee_ihtml_open_uri(get_active_html(chmsee), link->uri); - check_history(chmsee, get_active_html(chmsee)); -} - -static void -control_switch_page_cb(GtkNotebook *notebook, GtkNotebookPage *page, guint new_page_num, ChmSee *chmsee) -{ - g_debug("switch page : current page = %d", gtk_notebook_get_current_page(notebook)); -} - -static void -html_switch_page_cb(GtkNotebook *notebook, GtkNotebookPage *page, guint new_page_num, ChmSee *self) -{ - GtkWidget *new_page; - - new_page = gtk_notebook_get_nth_page(notebook, new_page_num); - - if (new_page) { - ChmseeIhtml* new_html; - const gchar* title; - const gchar* location; - - new_html = g_object_get_data(G_OBJECT (new_page), "html"); - - update_tab_title(self, new_html); - - title = chmsee_ihtml_get_title(new_html); - location = chmsee_ihtml_get_location(new_html); - - if (location != NULL && strlen(location)) { - if (strlen(title)) { - ui_bookmarks_set_current_link(UIBOOKMARKS (selfp->bookmark_tree), title, location); - } else { - const gchar *book_title; - - book_title = booktree_get_selected_book_title(BOOKTREE (selfp->booktree)); - ui_bookmarks_set_current_link(UIBOOKMARKS (selfp->bookmark_tree), book_title, location); - } - - /* Sync the book tree. */ - if (selfp->has_toc) - booktree_select_uri(BOOKTREE (selfp->booktree), location); - } - - check_history(self, new_html); - } else { - gtk_window_set_title(GTK_WINDOW (self), "ChmSee"); - check_history(self, NULL); - } -} - -static void -html_location_changed_cb(ChmseeIhtml *html, const gchar *location, ChmSee *chmsee) -{ - g_debug("html location changed cb: %s", location); - - if (html == get_active_html(chmsee)) - check_history(chmsee, html); -} - +#if 0 static gboolean html_open_uri_cb(ChmseeIhtml* html, const gchar *uri, ChmSee *self) { @@ -520,133 +498,39 @@ return FALSE; } +#endif -static void -html_title_changed_cb(ChmseeIhtml *html, const gchar *title, ChmSee *self) -{ - const gchar *location; - - g_debug("html title changed cb %s", title); - - update_tab_title(self, get_active_html(self)); - - location = chmsee_ihtml_get_location(html); - - if (location != NULL && strlen(location)) { - if (strlen(title)) - ui_bookmarks_set_current_link(UIBOOKMARKS (selfp->bookmark_tree), title, location); - else { - const gchar *book_title; - - book_title = booktree_get_selected_book_title(BOOKTREE (selfp->booktree)); - ui_bookmarks_set_current_link(UIBOOKMARKS (selfp->bookmark_tree), book_title, location); - } - } -} - +#if 0 /* Popup html context menu */ static void -html_context_normal_cb(ChmseeIhtml *html, ChmSee *chmsee) +html_context_normal_cb(ChmseeIhtml *html, ChmSee *self) { - GladeXML *glade; - GtkWidget *menu; - GtkWidget *menu_item; - - gboolean back_state, forward_state; - - g_message("html context-normal event"); - - back_state = chmsee_ihtml_can_go_back(html); - forward_state = chmsee_ihtml_can_go_forward(html); - - glade = glade_xml_new(get_resource_path(GLADE_FILE), "html_context_normal", NULL); - menu = glade_xml_get_widget(glade, "html_context_normal"); - - menu_item = glade_xml_get_widget(glade, "menu_back"); - g_signal_connect(G_OBJECT (menu_item), - "activate", - G_CALLBACK (on_back), - chmsee); - gtk_widget_set_sensitive(menu_item, back_state); - - menu_item = glade_xml_get_widget(glade, "menu_forward"); - g_signal_connect(G_OBJECT (menu_item), - "activate", - G_CALLBACK (on_forward), - chmsee); - gtk_widget_set_sensitive(menu_item, forward_state); - - menu_item = glade_xml_get_widget(glade, "menu_copy"); - g_signal_connect(G_OBJECT (menu_item), - "activate", - G_CALLBACK (on_copy), - chmsee); - - menu_item = glade_xml_get_widget(glade, "menu_select_all"); - g_signal_connect(G_OBJECT (menu_item), - "activate", - G_CALLBACK (on_select_all), - chmsee); - - g_signal_connect(G_OBJECT(glade_xml_get_widget(glade, "menu_copy_page_location")), - "activate", - G_CALLBACK(on_copy_page_location), - chmsee); - - gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, 0, GDK_CURRENT_TIME); - - g_object_unref(glade); + g_message("html context-normal event"); + gtk_menu_popup(GTK_MENU(gtk_ui_manager_get_widget(selfp->ui_manager, "/HtmlContextNormal")), + NULL, NULL, NULL, NULL, 0, GDK_CURRENT_TIME); } /* Popup html context menu when mouse over hyper link */ static void -html_context_link_cb(ChmseeIhtml *html, const gchar *link, ChmSee *chmsee) +html_context_link_cb(ChmseeIhtml *html, const gchar *link, ChmSee* self) { - GladeXML *glade; - GtkWidget *menu; - GtkWidget *menu_item; - - g_debug("html context-link event: %s", link); + g_debug("html context-link event: %s", link); + chmsee_set_context_menu_link(self, link); + gtk_action_set_sensitive(gtk_action_group_get_action(selfp->action_group, "OpenLinkInNewTab"), + g_str_has_prefix(selfp->context_menu_link, "file://")); - g_free(context_menu_link); - - context_menu_link = g_strdup(link); - - glade = glade_xml_new(get_resource_path(GLADE_FILE), "html_context_link", NULL); - menu = glade_xml_get_widget(glade, "html_context_link"); - - menu_item = glade_xml_get_widget(glade, "menu_new_tab"); - g_signal_connect(G_OBJECT (menu_item), - "activate", - G_CALLBACK (on_context_new_tab), - chmsee); - if (!g_str_has_prefix(context_menu_link, "file://")) - gtk_widget_set_sensitive(menu_item, FALSE); - - menu_item = glade_xml_get_widget(glade, "menu_copy_link"); - g_signal_connect(G_OBJECT (menu_item), - "activate", - G_CALLBACK (on_context_copy_link), - chmsee); - - gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, 0, GDK_CURRENT_TIME); - - g_object_unref(glade); -} - -static void -html_open_new_tab_cb(ChmseeIhtml *html, const gchar *location, ChmSee *chmsee) -{ - g_debug("html open new tab callback: %s", location); + gtk_menu_popup(GTK_MENU(gtk_ui_manager_get_widget(selfp->ui_manager, "/HtmlContextLink")), + NULL, NULL, NULL, NULL, 0, GDK_CURRENT_TIME); - new_tab(chmsee, location); } - +#endif +#if 0 static void html_link_message_cb(ChmseeIhtml *html, const gchar *url, ChmSee *chmsee) { update_status_bar(chmsee, url); } +#endif /* Toolbar button events */ @@ -686,53 +570,9 @@ } static void -on_close_tab(GtkWidget *widget, ChmSee *self) -{ - gint num_pages, number, i; - GtkWidget *tab_label, *page; - - number = -1; - num_pages = gtk_notebook_get_n_pages(GTK_NOTEBOOK (selfp->html_notebook)); - - if (num_pages == 1) { - chmsee_quit(self); - - return; - } - - for (i = 0; i < num_pages; i++) { - GList *children, *l; - - g_debug("page %d", i); - page = gtk_notebook_get_nth_page(GTK_NOTEBOOK (selfp->html_notebook), i); - - tab_label = gtk_notebook_get_tab_label(GTK_NOTEBOOK (selfp->html_notebook), page); - g_message("tab_label"); - children = gtk_container_get_children(GTK_CONTAINER (tab_label)); - - for (l = children; l; l = l->next) { - if (widget == l->data) { - g_debug("found tab on page %d", i); - number = i; - break; - } - } - - if (number >= 0) { - gtk_notebook_remove_page(GTK_NOTEBOOK (selfp->html_notebook), number); - - break; - } - } -} - -static void on_copy(GtkWidget *widget, ChmSee *self) { - g_message("On Copy"); - - g_return_if_fail(GTK_IS_NOTEBOOK (selfp->html_notebook)); - + g_debug("On Copy"); chmsee_ihtml_copy_selection(get_active_html(self)); } @@ -755,14 +595,10 @@ static void on_select_all(GtkWidget *widget, ChmSee *self) { - ChmseeIhtml *html; - - g_message("On Select All"); - - g_return_if_fail(GTK_IS_NOTEBOOK (selfp->html_notebook)); - - html = get_active_html(self); - chmsee_ihtml_select_all(html); + ChmseeIhtml *html; + g_message("On Select All"); + html = get_active_html(self); + chmsee_ihtml_select_all(html); } static void @@ -787,7 +623,8 @@ on_home(GtkWidget *widget, ChmSee *self) { if (chmsee_ichmfile_get_home(selfp->book) != NULL) { - open_homepage(self); + /* TODO: + * open_homepage(self); */ } } @@ -842,14 +679,6 @@ } static void -hpanes_toggled_cb(GtkToggleToolButton *widget, ChmSee *self) -{ - gboolean state; - g_object_get(widget, "active", &state, NULL); - set_sidepane_state(self, state); -} - -static void on_open_new_tab(GtkWidget *widget, ChmSee *self) { ChmseeIhtml *html; @@ -857,8 +686,6 @@ g_message("Open new tab"); - g_return_if_fail(GTK_IS_NOTEBOOK (selfp->html_notebook)); - html = get_active_html(self); location = chmsee_ihtml_get_location(html); @@ -868,41 +695,26 @@ } static void -on_close_current_tab(GtkWidget *widget, ChmSee *self) +on_context_new_tab(GtkWidget *widget, ChmSee *self) { - g_return_if_fail(GTK_IS_NOTEBOOK (selfp->html_notebook)); + g_debug("On context open new tab: %s", selfp->context_menu_link); - if (gtk_notebook_get_n_pages(GTK_NOTEBOOK (selfp->html_notebook)) == 1) - return chmsee_quit(self); - - gint page_num; - - page_num = gtk_notebook_get_current_page(GTK_NOTEBOOK (selfp->html_notebook)); - - if (page_num >= 0) - gtk_notebook_remove_page(GTK_NOTEBOOK (selfp->html_notebook), page_num); -} - -static void -on_context_new_tab(GtkWidget *widget, ChmSee *chmsee) -{ - g_debug("On context open new tab: %s", context_menu_link); - - if (context_menu_link != NULL) - new_tab(chmsee, context_menu_link); + if (selfp->context_menu_link != NULL) { + new_tab(self, selfp->context_menu_link); + } } static void -on_context_copy_link(GtkWidget *widget, ChmSee *chmsee) +on_context_copy_link(GtkWidget *widget, ChmSee *self) { - g_debug("On context copy link: %s", context_menu_link); + g_debug("On context copy link: %s", selfp->context_menu_link); - if (context_menu_link != NULL) { - gtk_clipboard_set_text(gtk_clipboard_get(GDK_SELECTION_PRIMARY), - context_menu_link, -1); - gtk_clipboard_set_text(gtk_clipboard_get(GDK_SELECTION_CLIPBOARD), - context_menu_link, -1); - } + if (selfp->context_menu_link != NULL) { + gtk_clipboard_set_text(gtk_clipboard_get(GDK_SELECTION_PRIMARY), + selfp->context_menu_link, -1); + gtk_clipboard_set_text(gtk_clipboard_get(GDK_SELECTION_CLIPBOARD), + selfp->context_menu_link, -1); + } } @@ -911,14 +723,8 @@ static void chmsee_quit(ChmSee *self) { - if (selfp->book) { - close_current_book(self); - } - chmsee_save_config(self); - g_free(context_menu_link); - if(get_active_html(self)) { chmsee_ihtml_shutdown(get_active_html(self)); } @@ -942,6 +748,8 @@ static void populate_window(ChmSee *self) { + GtkWidget* vbox = gtk_vbox_new(FALSE, 0); + GladeXML *glade; glade = glade_xml_new(get_resource_path(GLADE_FILE), "main_vbox", NULL); @@ -955,240 +763,75 @@ GtkWidget *main_vbox; main_vbox = get_widget(self, "main_vbox"); - gtk_container_add(GTK_CONTAINER (self), main_vbox); + gtk_container_add(GTK_CONTAINER (self), vbox); + + GtkActionGroup* action_group = gtk_action_group_new ("MenuActions"); + selfp->action_group = action_group; + gtk_action_group_add_actions (action_group, entries, G_N_ELEMENTS (entries), self); + gtk_action_group_add_toggle_actions (action_group, toggle_entries, G_N_ELEMENTS (toggle_entries), self); + + gtk_action_set_sensitive(gtk_action_group_get_action(action_group, "NewTab"), FALSE); + gtk_action_set_sensitive(gtk_action_group_get_action(action_group, "CloseTab"), FALSE); + gtk_action_set_sensitive(gtk_action_group_get_action(action_group, "Home"), FALSE); + gtk_action_set_sensitive(gtk_action_group_get_action(action_group, "Back"), FALSE); + gtk_action_set_sensitive(gtk_action_group_get_action(action_group, "Forward"), FALSE); + gtk_action_set_sensitive(gtk_action_group_get_action(action_group, "SidePane"), FALSE); + gtk_action_set_sensitive(gtk_action_group_get_action(action_group, "ZoomIn"), FALSE); + gtk_action_set_sensitive(gtk_action_group_get_action(action_group, "ZoomOut"), FALSE); + gtk_action_set_sensitive(gtk_action_group_get_action(action_group, "ZoomReset"), FALSE); + + GtkUIManager* ui_manager = gtk_ui_manager_new (); + selfp->ui_manager = ui_manager; + gtk_ui_manager_insert_action_group (ui_manager, action_group, 0); + + GtkAccelGroup* accel_group = gtk_ui_manager_get_accel_group (ui_manager); + gtk_window_add_accel_group (GTK_WINDOW (self), accel_group); + + GError* error = NULL; + if (!gtk_ui_manager_add_ui_from_string (ui_manager, ui_description, -1, &error)) + { + g_message ("building menus failed: %s", error->message); + g_error_free (error); + exit (EXIT_FAILURE); + } + + GtkWidget* menubar = gtk_handle_box_new(); + selfp->menubar = menubar; + gtk_container_add(GTK_CONTAINER(menubar), gtk_ui_manager_get_widget (ui_manager, "/MainMenu")); + gtk_box_pack_start (GTK_BOX (vbox), menubar, FALSE, FALSE, 0); + + GtkWidget* toolbar = gtk_handle_box_new(); + selfp->toolbar = toolbar; + gtk_container_add(GTK_CONTAINER(toolbar), gtk_ui_manager_get_widget(ui_manager, "/toolbar")); + gtk_box_pack_start(GTK_BOX(vbox), toolbar, FALSE, FALSE, 0); + + GtkWidget* ui_chmfile = chmsee_ui_chmfile_new(); + selfp->ui_chmfile = ui_chmfile; + gtk_box_pack_start(GTK_BOX(vbox), ui_chmfile, TRUE, TRUE, 0); + gtk_container_set_focus_child(GTK_CONTAINER(vbox), ui_chmfile); + g_signal_connect_swapped(ui_chmfile, + "model_changed", + G_CALLBACK(on_ui_chmfile_model_changed), + self); + g_signal_connect_swapped(ui_chmfile, + "html_changed", + G_CALLBACK(on_ui_chmfile_html_changed), + self); + g_signal_connect_swapped(ui_chmfile, + "notify::link-message", + G_CALLBACK(on_ui_chmfile_html_link_message_notify), + self); + + gtk_tool_button_set_icon_widget( + GTK_TOOL_BUTTON(gtk_ui_manager_get_widget(ui_manager, "/toolbar/sidepane")), + gtk_image_new_from_file(get_resource_path("show-pane.png"))); - GtkAccelGroup *accel_group; + gtk_box_pack_start (GTK_BOX (vbox), main_vbox, FALSE, FALSE, 0); + gtk_widget_show_all(vbox); accel_group = g_object_new(GTK_TYPE_ACCEL_GROUP, NULL); gtk_window_add_accel_group(GTK_WINDOW (self), accel_group); - /* menu item */ - GtkWidget *menu_item; - - menu_item = get_widget(self, "menu_open"); - g_signal_connect(G_OBJECT (menu_item), - "activate", - G_CALLBACK (on_open), - self); - gtk_widget_add_accelerator(menu_item, - "activate", - accel_group, - GDK_o, - GDK_CONTROL_MASK, - GTK_ACCEL_VISIBLE); - - menu_item = get_widget(self, "menu_new_tab"); - g_signal_connect(G_OBJECT (menu_item), - "activate", - G_CALLBACK (on_open_new_tab), - self); - gtk_widget_add_accelerator(menu_item, - "activate", - accel_group, - GDK_t, - GDK_CONTROL_MASK, - GTK_ACCEL_VISIBLE); - gtk_widget_set_sensitive(menu_item, FALSE); - - menu_item = get_widget(self, "menu_close_tab"); - g_signal_connect(G_OBJECT (menu_item), - "activate", - G_CALLBACK (on_close_current_tab), - self); - gtk_widget_add_accelerator(menu_item, - "activate", - accel_group, - GDK_w, - GDK_CONTROL_MASK, - GTK_ACCEL_VISIBLE); - gtk_widget_set_sensitive(menu_item, FALSE); - - menu_item = get_widget(self, "menu_setup"); - g_signal_connect(G_OBJECT (menu_item), - "activate", - G_CALLBACK (on_setup), - self); - - menu_item = get_widget(self, "menu_copy"); - g_signal_connect(G_OBJECT (menu_item), - "activate", - G_CALLBACK (on_copy), - self); - gtk_widget_add_accelerator(menu_item, - "activate", - accel_group, - GDK_c, - GDK_CONTROL_MASK, - GTK_ACCEL_VISIBLE); - - menu_item = get_widget(self, "menu_quit"); - g_signal_connect(G_OBJECT (menu_item), - "activate", - G_CALLBACK (destroy_cb), - self); - gtk_widget_add_accelerator(menu_item, - "activate", - accel_group, - GDK_q, - GDK_CONTROL_MASK, - GTK_ACCEL_VISIBLE); - - menu_item = get_widget(self, "menu_home"); - g_signal_connect(G_OBJECT (menu_item), - "activate", - G_CALLBACK (on_home), - self); - gtk_widget_set_sensitive(menu_item, FALSE); - - menu_item = get_widget(self, "menu_back"); - g_signal_connect(G_OBJECT (menu_item), - "activate", - G_CALLBACK (on_back), - self); - gtk_widget_set_sensitive(menu_item, FALSE); - - menu_item = get_widget(self, "menu_forward"); - g_signal_connect(G_OBJECT (menu_item), - "activate", - G_CALLBACK (on_forward), - self); - gtk_widget_set_sensitive(menu_item, FALSE); - - menu_item = get_widget(self, "menu_fullscreen"); - g_signal_connect_swapped(G_OBJECT(menu_item), - "toggled", - G_CALLBACK(on_fullscreen_toggled), - self); - gtk_widget_add_accelerator(menu_item, - "activate", - accel_group, - GDK_F11, - 0, - GTK_ACCEL_VISIBLE); - - menu_item = get_widget(self, "menu_sidepane"); - g_signal_connect_swapped(G_OBJECT(menu_item), - "toggled", - G_CALLBACK(on_sidepane_toggled), - self); - gtk_widget_add_accelerator(menu_item, - "activate", - accel_group, - GDK_F9, - 0, - GTK_ACCEL_VISIBLE); - - menu_item = get_widget(self, "menu_about"); - g_signal_connect(G_OBJECT (menu_item), - "activate", - G_CALLBACK (on_about), - self); - - /* toolbar buttons */ - GtkWidget *toolbar_button; - GtkWidget *icon_widget; - - toolbar_button = get_widget(self, "toolbar_open"); - g_signal_connect(G_OBJECT (toolbar_button), - "clicked", - G_CALLBACK (on_open), - self); - - toolbar_button = get_widget(self, "toolbar_setup"); - g_signal_connect(G_OBJECT (toolbar_button), - "clicked", - G_CALLBACK (on_setup), - self); - - toolbar_button = get_widget(self, "toolbar_about"); - g_signal_connect(G_OBJECT (toolbar_button), - "clicked", - G_CALLBACK (on_about), - NULL); - - toolbar_button = get_widget(self, "toolbar_hpanes"); - icon_widget = gtk_image_new_from_file(get_resource_path("show-pane.png")); - gtk_widget_show(icon_widget); - gtk_tool_button_set_icon_widget(GTK_TOOL_BUTTON (toolbar_button), icon_widget); - g_object_set(toolbar_button, "active", FALSE, NULL); - gtk_widget_set_sensitive(toolbar_button, FALSE); - g_signal_connect(G_OBJECT (toolbar_button), - "toggled", - G_CALLBACK (hpanes_toggled_cb), - self); - - toolbar_button = get_widget(self, "toolbar_back"); - g_signal_connect(G_OBJECT (toolbar_button), - "clicked", - G_CALLBACK (on_back), - self); - gtk_widget_add_accelerator(toolbar_button, - "clicked", - accel_group, - GDK_Left, - GDK_MOD1_MASK, - GTK_ACCEL_VISIBLE); - - toolbar_button = get_widget(self, "toolbar_forward"); - g_signal_connect(G_OBJECT (toolbar_button), - "clicked", - G_CALLBACK (on_forward), - self); - gtk_widget_add_accelerator(toolbar_button, - "clicked", - accel_group, - GDK_Right, - GDK_MOD1_MASK, - GTK_ACCEL_VISIBLE); - - toolbar_button = get_widget(self, "toolbar_home"); - g_signal_connect(G_OBJECT (toolbar_button), - "clicked", - G_CALLBACK (on_home), - self); - - toolbar_button = get_widget(self, "toolbar_zoom_in"); - g_signal_connect(G_OBJECT (toolbar_button), - "clicked", - G_CALLBACK (on_zoom_in), - self); - gtk_widget_add_accelerator(toolbar_button, - "clicked", - accel_group, - GDK_plus, - GDK_CONTROL_MASK, - GTK_ACCEL_VISIBLE); - - - toolbar_button = get_widget(self, "toolbar_zoom_reset"); - g_signal_connect(G_OBJECT (toolbar_button), - "clicked", - G_CALLBACK (on_zoom_reset), - self); - gtk_widget_add_accelerator(toolbar_button, - "clicked", - accel_group, - GDK_0, - GDK_CONTROL_MASK, - GTK_ACCEL_VISIBLE); - - toolbar_button = get_widget(self, "toolbar_zoom_out"); - g_signal_connect(G_OBJECT (toolbar_button), - "clicked", - G_CALLBACK (on_zoom_out), - self); - gtk_widget_add_accelerator(toolbar_button, - "clicked", - accel_group, - GDK_minus, - GDK_CONTROL_MASK, - GTK_ACCEL_VISIBLE); - - GtkWidget *control_vbox; - - control_vbox = get_widget(self, "control_vbox"); - gtk_widget_hide(control_vbox); - /* status bar */ selfp->statusbar = glade_xml_get_widget(glade, "statusbar"); selfp->scid_default = gtk_statusbar_get_context_id(GTK_STATUSBAR (selfp->statusbar), @@ -1196,122 +839,19 @@ update_status_bar(self, _("Ready!")); } -static void -display_book(ChmSee* self, ChmseeIchmfile *book, const gchar *filename) +void +chmsee_set_model(ChmSee* self, ChmseeIchmfile *book) { - GNode *link_tree; - GList *bookmarks_list; - - GtkWidget *booktree_sw; - GtkWidget *control_vbox; - g_debug("display book"); selfp->state = CHMSEE_STATE_LOADING; /* Close currently opened book */ - if (selfp->book) - close_current_book(self); - - selfp->book = book; - - control_vbox = get_widget(self, "control_vbox"); - - /* Book contents TreeView widget */ - selfp->control_notebook = gtk_notebook_new(); - - gtk_box_pack_start(GTK_BOX (control_vbox), - GTK_WIDGET (selfp->control_notebook), - TRUE, - TRUE, - 2); - g_signal_connect(G_OBJECT (selfp->control_notebook), - "switch-page", - G_CALLBACK (control_switch_page_cb), - self); - - /* TOC */ - if (chmsee_ichmfile_get_link_tree(selfp->book) != NULL) { - link_tree = chmsee_ichmfile_get_link_tree(selfp->book); - - booktree_sw = gtk_scrolled_window_new(NULL, NULL); - gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW (booktree_sw), - GTK_POLICY_NEVER, - GTK_POLICY_AUTOMATIC); - gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW (booktree_sw), - GTK_SHADOW_IN); - gtk_container_set_border_width(GTK_CONTAINER (booktree_sw), 2); - - selfp->booktree = GTK_WIDGET(g_object_ref_sink(booktree_new(link_tree))); - g_signal_connect_swapped(selfp->booktree, - "scroll-event", - G_CALLBACK(on_scroll_event), - self); - - gtk_container_add(GTK_CONTAINER (booktree_sw), selfp->booktree); - gtk_notebook_append_page(GTK_NOTEBOOK (selfp->control_notebook), - booktree_sw, - gtk_label_new(_("Topics"))); - - g_signal_connect(G_OBJECT (selfp->booktree), - "link-selected", - G_CALLBACK (booktree_link_selected_cb), - self); - - g_debug("chmsee has toc"); - selfp->has_toc = TRUE; + if (selfp->book) { + g_object_unref(selfp->book); } - /* Index */ - gtk_notebook_append_page(GTK_NOTEBOOK (selfp->control_notebook), - chmsee_new_index_page(self), - gtk_label_new(_("Index"))); - chmsee_refresh_index(self); - - /* Bookmarks */ - bookmarks_list = chmsee_ichmfile_get_bookmarks_list(selfp->book); - selfp->bookmark_tree = GTK_WIDGET (ui_bookmarks_new(bookmarks_list)); - - gtk_notebook_append_page(GTK_NOTEBOOK (selfp->control_notebook), - selfp->bookmark_tree, - gtk_label_new (_("Bookmarks"))); - - g_signal_connect(G_OBJECT (selfp->bookmark_tree), - "link-selected", - G_CALLBACK (bookmarks_link_selected_cb), - self); - - GtkWidget *hpaned; - - hpaned = get_widget(self, "hpaned1"); - - /* HTML tabs notebook */ - selfp->html_notebook = gtk_notebook_new(); - gtk_paned_add2 (GTK_PANED (hpaned), selfp->html_notebook); - - g_signal_connect(G_OBJECT (selfp->html_notebook), - "switch-page", - G_CALLBACK (html_switch_page_cb), - self); - - gtk_widget_show_all(hpaned); - new_tab(self, NULL); - - gtk_notebook_set_current_page(GTK_NOTEBOOK (selfp->control_notebook), - g_list_length(bookmarks_list) && selfp->has_toc ? 1 : 0); - - /* Toolbar buttons state */ - GtkWidget *toolbar_button; - - toolbar_button = get_widget(self, "toolbar_hpanes"); - gtk_widget_set_sensitive(toolbar_button, TRUE); - g_object_set(toolbar_button, "active", TRUE, NULL); - - toolbar_button = get_widget(self, "toolbar_zoom_in"); - gtk_widget_set_sensitive(toolbar_button, TRUE); - toolbar_button = get_widget(self, "toolbar_zoom_reset"); - gtk_widget_set_sensitive(toolbar_button, TRUE); - toolbar_button = get_widget(self, "toolbar_zoom_out"); - gtk_widget_set_sensitive(toolbar_button, TRUE); + selfp->book = g_object_ref(book); + chmsee_ui_chmfile_set_model(CHMSEE_UI_CHMFILE(selfp->ui_chmfile), book); /* Window title */ gchar *window_title; @@ -1320,180 +860,20 @@ && g_ascii_strcasecmp(chmsee_ichmfile_get_title(selfp->book), "(null)") != 0 ) { window_title = g_strdup_printf("%s - ChmSee", chmsee_ichmfile_get_title(selfp->book)); } else { - window_title = g_strdup_printf("%s - ChmSee", filename); + window_title = g_strdup_printf("%s - ChmSee", + g_path_get_basename(chmsee_ichmfile_get_filename(book))); } gtk_window_set_title(GTK_WINDOW (self), window_title); g_free(window_title); - chmsee_ihtml_set_variable_font(get_active_html(self), - chmsee_ichmfile_get_variable_font(selfp->book)); - chmsee_ihtml_set_fixed_font(get_active_html(self), - chmsee_ichmfile_get_fixed_font(selfp->book)); - - if (chmsee_ichmfile_get_home(selfp->book)) { - GtkWidget *menu_item; - - open_homepage(self); - - menu_item = get_widget(self, "menu_new_tab"); - gtk_widget_set_sensitive(menu_item, TRUE); - - menu_item = get_widget(self, "menu_close_tab"); - gtk_widget_set_sensitive(menu_item, TRUE); - - menu_item = get_widget(self, "menu_home"); - gtk_widget_set_sensitive(menu_item, TRUE); - - gtk_widget_set_sensitive(get_widget(self, "menu_sidepane"), TRUE); - - toolbar_button = get_widget(self, "toolbar_home"); - gtk_widget_set_sensitive(toolbar_button, TRUE); - } selfp->state = CHMSEE_STATE_NORMAL; -} - -static void -close_current_book(ChmSee *self) -{ - gchar* bookmark_fname = g_build_filename(chmsee_ichmfile_get_dir(selfp->book), CHMSEE_BOOKMARK_FILE, NULL); - bookmarks_save(ui_bookmarks_get_list(UIBOOKMARKS (selfp->bookmark_tree)), bookmark_fname); - g_free(bookmark_fname); - g_object_unref(selfp->book); - gtk_widget_destroy(GTK_WIDGET (selfp->control_notebook)); - gtk_widget_destroy(GTK_WIDGET (selfp->html_notebook)); - - selfp->book = NULL; - selfp->control_notebook = NULL; - selfp->html_notebook = NULL; - selfp->state = CHMSEE_STATE_INIT; -} - -static GtkWidget* -new_tab_content(ChmSee *chmsee, const gchar *str) -{ - GtkWidget *widget; - GtkWidget *label; - GtkWidget *close_button, *close_image; - - widget = gtk_hbox_new(FALSE, 3); - - label = gtk_label_new(str); - gtk_label_set_ellipsize(GTK_LABEL (label), PANGO_ELLIPSIZE_END); - gtk_label_set_single_line_mode(GTK_LABEL (label), TRUE); - gtk_misc_set_alignment(GTK_MISC (label), 0.0, 0.5); - gtk_misc_set_padding(GTK_MISC (label), 0, 0); - gtk_box_pack_start(GTK_BOX (widget), label, TRUE, TRUE, 0); - g_object_set_data(G_OBJECT (widget), "label", label); - - close_button = gtk_button_new(); - gtk_button_set_relief(GTK_BUTTON(close_button), GTK_RELIEF_NONE); - close_image = gtk_image_new_from_stock(GTK_STOCK_CLOSE, GTK_ICON_SIZE_MENU); - gtk_widget_show(close_image); - gtk_container_add(GTK_CONTAINER (close_button), close_image); - g_signal_connect(G_OBJECT (close_button), - "clicked", - G_CALLBACK (on_close_tab), - chmsee); - - gtk_box_pack_start(GTK_BOX (widget), close_button, FALSE, FALSE, 0); - - gtk_widget_show_all(widget); - - return widget; -} - -static void -new_tab(ChmSee *self, const gchar *location) -{ - ChmseeIhtml *html; - GtkWidget *frame; - GtkWidget *view; - GtkWidget *tab_content; - gint num; - - g_debug("new_tab : %s", location); - - /* Ignore external link */ - if (location != NULL && !g_str_has_prefix(location, "file://")) - return; - - html = chmsee_html_new(); - g_signal_connect_swapped(chmsee_ihtml_get_widget(html), - "dom-mouse-click", - G_CALLBACK(on_scroll_event), - self); - - view = chmsee_ihtml_get_widget(html); - gtk_widget_show(view); - - frame = gtk_frame_new(NULL); - gtk_widget_show(frame); - - gtk_frame_set_shadow_type(GTK_FRAME (frame), GTK_SHADOW_IN); - gtk_container_set_border_width(GTK_CONTAINER (frame), 2); - gtk_container_add(GTK_CONTAINER (frame), view); - - g_object_set_data(G_OBJECT (frame), "html", html); - - /* Custom label widget, with a close button */ - tab_content = new_tab_content(self, _("No Title")); - - g_signal_connect(G_OBJECT (html), - "title-changed", - G_CALLBACK (html_title_changed_cb), - self); - g_signal_connect(G_OBJECT (html), - "open-uri", - G_CALLBACK (html_open_uri_cb), - self); - g_signal_connect(G_OBJECT (html), - "location-changed", - G_CALLBACK (html_location_changed_cb), - self); - g_signal_connect(G_OBJECT (html), - "context-normal", - G_CALLBACK (html_context_normal_cb), - self); - g_signal_connect(G_OBJECT (html), - "context-link", - G_CALLBACK (html_context_link_cb), - self); - g_signal_connect(G_OBJECT (html), - "open-new-tab", - G_CALLBACK (html_open_new_tab_cb), - self); - g_signal_connect(G_OBJECT (html), - "link-message", - G_CALLBACK (html_link_message_cb), - self); - g_signal_connect_swapped(chmsee_ihtml_get_widget(html), - "scroll-event", - G_CALLBACK(on_scroll_event), - self); - - num = gtk_notebook_append_page(GTK_NOTEBOOK (selfp->html_notebook), - frame, tab_content); - - gtk_notebook_set_tab_label_packing(GTK_NOTEBOOK (selfp->html_notebook), - frame, - TRUE, TRUE, - GTK_PACK_START); - gtk_widget_realize(view); - - if (location != NULL) { - chmsee_ihtml_open_uri(html, location); - - if (selfp->has_toc) - booktree_select_uri(BOOKTREE (selfp->booktree), location); - } else { - chmsee_ihtml_clear(html); - } - - gtk_notebook_set_current_page(GTK_NOTEBOOK (selfp->html_notebook), num); + selfp->last_dir = g_strdup_printf("%s", g_path_get_dirname( + chmsee_ichmfile_get_filename(book))); } +#if 0 static void open_homepage(ChmSee *self) { @@ -1515,6 +895,7 @@ check_history(self, html); } +#endif static void reload_current_page(ChmSee *self) @@ -1524,8 +905,6 @@ g_message("Reload current page"); - g_return_if_fail(GTK_IS_NOTEBOOK (selfp->html_notebook)); - html = get_active_html(self); location = chmsee_ihtml_get_location(html); @@ -1537,99 +916,7 @@ static ChmseeIhtml * get_active_html(ChmSee *self) { - GtkWidget *frame; - gint page_num; - - if(!selfp->html_notebook) { - return NULL; - } - page_num = gtk_notebook_get_current_page(GTK_NOTEBOOK (selfp->html_notebook)); - - if (page_num == -1) - return NULL; - - frame = gtk_notebook_get_nth_page(GTK_NOTEBOOK (selfp->html_notebook), page_num); - - return g_object_get_data(G_OBJECT (frame), "html"); -} - -static void -check_history(ChmSee *chmsee, ChmseeIhtml *html) -{ - GtkWidget *menu_item, *toolbar_button; - gboolean back_state, forward_state; - - back_state = chmsee_ihtml_can_go_back(html); - forward_state = chmsee_ihtml_can_go_forward(html); - - menu_item = get_widget(chmsee, "menu_back"); - gtk_widget_set_sensitive(menu_item, back_state); - menu_item = get_widget(chmsee, "menu_forward"); - gtk_widget_set_sensitive(menu_item, forward_state); - - toolbar_button = get_widget(chmsee, "toolbar_back"); - gtk_widget_set_sensitive(toolbar_button, back_state); - toolbar_button = get_widget(chmsee, "toolbar_forward"); - gtk_widget_set_sensitive(toolbar_button, forward_state); -} - -static void -update_tab_title(ChmSee *self, ChmseeIhtml *html) -{ - const gchar* html_title; - const gchar* tab_title; - const gchar* book_title; - - html_title = chmsee_ihtml_get_title(html); - - if (selfp->has_toc) - book_title = booktree_get_selected_book_title(BOOKTREE (selfp->booktree)); - else - book_title = ""; - - if (book_title && book_title[0] != '\0' && - html_title && html_title[0] != '\0' && - ncase_compare_utf8_string(book_title, html_title)) - tab_title = g_strdup_printf("%s : %s", book_title, html_title); - else if (book_title && book_title[0] != '\0') - tab_title = g_strdup(book_title); - else if (html_title && html_title[0] != '\0') - tab_title = g_strdup(html_title); - else - tab_title = g_strdup(""); - - tab_set_title(self, html, tab_title); -} - -static void -tab_set_title(ChmSee *self, ChmseeIhtml *html, const gchar *title) -{ - GtkWidget *view; - GtkWidget *page; - GtkWidget *widget, *label; - gint num_pages, i; - - view = chmsee_ihtml_get_widget(html); - - if (title == NULL || title[0] == '\0') - title = _("No Title"); - - num_pages = gtk_notebook_get_n_pages(GTK_NOTEBOOK (selfp->html_notebook)); - - for (i = 0; i < num_pages; i++) { - page = gtk_notebook_get_nth_page(GTK_NOTEBOOK (selfp->html_notebook), i); - - if (gtk_bin_get_child(GTK_BIN (page)) == view) { - widget = gtk_notebook_get_tab_label(GTK_NOTEBOOK (selfp->html_notebook), page); - - label = g_object_get_data(G_OBJECT (widget), "label"); - - if (label != NULL) - gtk_label_set_text(GTK_LABEL (label), title); - - break; - } - } + return chmsee_ui_chmfile_get_active_html(CHMSEE_UI_CHMFILE(selfp->ui_chmfile)); } static void @@ -1654,39 +941,6 @@ self = g_object_new(TYPE_CHMSEE, NULL); - /* Quit event handle */ - g_signal_connect(G_OBJECT (self), - "delete_event", - G_CALLBACK (delete_cb), - self); - g_signal_connect(G_OBJECT (self), - "destroy", - G_CALLBACK (destroy_cb), - self); - - /* Widget size changed event handle */ - g_signal_connect(G_OBJECT (self), - "configure-event", - G_CALLBACK (on_configure_event), - self); - - /* Init gecko */ - chmsee_html_init_system(); - chmsee_html_set_default_lang(selfp->lang); - - populate_window(self); - chmsee_load_config(self); - if (selfp->pos_x >= 0 && selfp->pos_y >= 0) - gtk_window_move(GTK_WINDOW (self), selfp->pos_x, selfp->pos_y); - - if (selfp->width > 0 && selfp->height > 0) - gtk_window_resize(GTK_WINDOW (self), selfp->width, selfp->height); - else - gtk_window_resize(GTK_WINDOW (self), 800, 600); - - gtk_window_set_title(GTK_WINDOW (self), "ChmSee"); - gtk_window_set_icon_from_file(GTK_WINDOW (self), get_resource_path("chmsee-icon.png"), NULL); - if(filename != NULL) { chmsee_open_file(self, filename); } @@ -1705,9 +959,7 @@ book = chmsee_chmfile_new(filename); if (book) { - display_book(self, book, g_path_get_basename(filename)); - - selfp->last_dir = g_strdup_printf("%s", g_path_get_dirname(filename)); + chmsee_set_model(self, book); } else { /* Popup an error message dialog */ GtkWidget *msg_dialog; @@ -1768,7 +1020,7 @@ int chmsee_get_hpaned_position(ChmSee* self) { gint position; - g_object_get(G_OBJECT(get_widget(self, "hpaned1")), + g_object_get(G_OBJECT(selfp->ui_chmfile), "position", &position, NULL ); @@ -1785,7 +1037,7 @@ */ } -void on_fullscreen_toggled(ChmSee* self, GtkWidget* menu) { +void on_fullscreen_toggled(GtkWidget* menu, ChmSee* self) { g_return_if_fail(IS_CHMSEE(self)); gboolean active; g_object_get(G_OBJECT(menu), @@ -1795,7 +1047,7 @@ chmsee_set_fullscreen(self, active); } -void on_sidepane_toggled(ChmSee* self, GtkWidget* menu) { +void on_sidepane_toggled(GtkWidget* menu, ChmSee* self) { g_return_if_fail(IS_CHMSEE(self)); gboolean active; g_object_get(G_OBJECT(menu), @@ -1810,26 +1062,9 @@ void set_sidepane_state(ChmSee* self, gboolean state) { GtkWidget* icon_widget; - - if(state) { - gtk_widget_show(get_widget(self, "control_vbox")); - } else { - gtk_widget_hide(get_widget(self, "control_vbox")); - } - - gboolean menu_state = gtk_check_menu_item_get_active( - GTK_CHECK_MENU_ITEM(get_widget(self, "menu_sidepane"))); - if(menu_state != state) { - gtk_check_menu_item_set_active( - GTK_CHECK_MENU_ITEM(get_widget(self, "menu_sidepane")), state); - } - - gboolean toolbar_state = gtk_toggle_tool_button_get_active( - GTK_TOGGLE_TOOL_BUTTON(get_widget(self, "toolbar_hpanes"))); - if(toolbar_state != state) { - gtk_toggle_tool_button_set_active( - GTK_TOGGLE_TOOL_BUTTON(get_widget(self, "toolbar_hpanes")), state); - } + g_object_set(selfp->ui_chmfile, + "sidepane-visible", state, + NULL); if (state) { icon_widget = gtk_image_new_from_file(get_resource_path("hide-pane.png")); @@ -1837,7 +1072,9 @@ icon_widget = gtk_image_new_from_file(get_resource_path("show-pane.png")); } gtk_widget_show(icon_widget); - gtk_tool_button_set_icon_widget(GTK_TOOL_BUTTON (get_widget(self, "toolbar_hpanes")), icon_widget); + gtk_tool_button_set_icon_widget( + GTK_TOOL_BUTTON(gtk_ui_manager_get_widget(selfp->ui_manager, "/toolbar/sidepane")), + icon_widget); }; void show_sidepane(ChmSee* self) { @@ -1851,7 +1088,7 @@ void on_map(ChmSee* self) { if(selfp->hpaned_position >= 0) { - g_object_set(G_OBJECT(get_widget(self, "hpaned1")), + g_object_set(G_OBJECT(selfp->ui_chmfile), "position", selfp->hpaned_position, NULL ); @@ -1862,21 +1099,17 @@ static void on_fullscreen(ChmSee* self) { g_debug("enter on_fullscreen"); selfp->fullscreen = TRUE; - gtk_widget_hide(get_widget(self, "handlebox_menu")); - gtk_widget_hide(get_widget(self, "handlebox_toolbar")); + gtk_widget_hide(selfp->menubar); + gtk_widget_hide(selfp->toolbar); gtk_widget_hide(get_widget(self, "statusbar")); - gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(get_widget(self, "menu_fullscreen")), - TRUE); } static void on_unfullscreen(ChmSee* self) { g_debug("enter on_unfullscreen"); selfp->fullscreen = FALSE; - gtk_widget_show(get_widget(self, "handlebox_menu")); - gtk_widget_show(get_widget(self, "handlebox_toolbar")); + gtk_widget_show(selfp->menubar); + gtk_widget_show(selfp->toolbar); gtk_widget_show(get_widget(self, "statusbar")); - gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(get_widget(self, "menu_fullscreen")), - FALSE); } gboolean on_window_state_event(ChmSee* self, GdkEventWindowState* event) { @@ -2070,42 +1303,59 @@ } } -void chmsee_refresh_index(ChmSee* self) { - ChmIndex* chmIndex = NULL; - if(selfp->book) { - chmIndex = chmsee_ichmfile_get_index(selfp->book); - } - chmsee_ui_index_set_model(CHMSEE_UI_INDEX(selfp->uiIndex), chmIndex); - if(chmIndex != NULL) { - g_debug("chmIndex != NULL"); - gtk_widget_show(selfp->indexPage); + +gboolean chmsee_jump_index_by_name(ChmSee* self, const gchar* name) { + g_return_val_if_fail(IS_CHMSEE(self), FALSE); + return chmsee_ui_chmfile_jump_index_by_name(CHMSEE_UI_CHMFILE(selfp->ui_chmfile), name); +} + +static void on_keyboard_escape(GtkWidget* widget, ChmSee* self) { + if(selfp->fullscreen) { + chmsee_set_fullscreen(self, FALSE); } else { - g_debug("chmIndex == NULL"); - gtk_widget_hide(selfp->indexPage); + gtk_window_iconify(GTK_WINDOW(self)); } } -static GtkWidget* chmsee_new_index_page(ChmSee* self) { - GtkWidget* booktree_sw = gtk_scrolled_window_new(NULL, NULL); - gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW (booktree_sw), - GTK_POLICY_NEVER, - GTK_POLICY_AUTOMATIC); - gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW (booktree_sw), - GTK_SHADOW_IN); - gtk_container_set_border_width(GTK_CONTAINER (booktree_sw), 2); - - GtkWidget* uiIndex = chmsee_ui_index_new(NULL); - gtk_container_add(GTK_CONTAINER (booktree_sw), uiIndex); - g_signal_connect_swapped(uiIndex, - "link-selected", - G_CALLBACK (chmsee_on_ui_index_link_selected), - self); - - selfp->indexPage = booktree_sw; - selfp->uiIndex = uiIndex; - return GTK_WIDGET(booktree_sw); +static void new_tab(ChmSee * self, const gchar * location) { + chmsee_ui_chmfile_new_tab(CHMSEE_UI_CHMFILE(selfp->ui_chmfile), location); +} + +static void on_close_current_tab(GtkWidget* widget, ChmSee* self) { + chmsee_ui_chmfile_close_current_tab(CHMSEE_UI_CHMFILE(selfp->ui_chmfile)); +} + +void on_ui_chmfile_model_changed(ChmSee* self, ChmseeIchmfile* chm_file) { + gboolean has_model = (chm_file != NULL); + + gtk_action_set_sensitive(gtk_action_group_get_action(selfp->action_group, "NewTab"), has_model); + gtk_action_set_sensitive(gtk_action_group_get_action(selfp->action_group, "CloseTab"), has_model); + gtk_action_set_sensitive(gtk_action_group_get_action(selfp->action_group, "Home"), has_model); + gtk_action_set_sensitive(gtk_action_group_get_action(selfp->action_group, "SidePane"), has_model); + gtk_action_set_sensitive(gtk_action_group_get_action(selfp->action_group, "ZoomIn"), has_model); + gtk_action_set_sensitive(gtk_action_group_get_action(selfp->action_group, "ZoomOut"), has_model); + gtk_action_set_sensitive(gtk_action_group_get_action(selfp->action_group, "ZoomReset"), has_model); +} + +void on_ui_chmfile_html_changed(ChmSee* self, ChmseeIhtml* html) { + gboolean back_state, forward_state; + + g_debug("%s:%d:recieve html_changed signal from %p", __FILE__, __LINE__, html); + + back_state = chmsee_ihtml_can_go_back(html); + forward_state = chmsee_ihtml_can_go_forward(html); + + + gtk_action_set_sensitive(gtk_action_group_get_action(selfp->action_group, "Back"), back_state); + gtk_action_set_sensitive(gtk_action_group_get_action(selfp->action_group, "Forward"), forward_state); } -void chmsee_on_ui_index_link_selected(ChmSee* self, Link* link) { - booktree_link_selected_cb(NULL, link, self); +void on_ui_chmfile_html_link_message_notify(ChmSee* self, GParamSpec* pspec, ChmseeUiChmfile* ui_chmfile) { + gchar* link_message; + g_object_get(ui_chmfile, + "link-message", &link_message, + NULL); + + update_status_bar(self, link_message); + g_free(link_message); } diff -Nru chmsee-1.0.6/src/chmsee.h chmsee-1.0.7/src/chmsee.h --- chmsee-1.0.6/src/chmsee.h 2009-07-12 04:02:53.000000000 +0100 +++ chmsee-1.0.7/src/chmsee.h 2009-09-14 14:51:03.000000000 +0100 @@ -30,10 +30,6 @@ #ifndef __CHMSEE_H__ #define __CHMSEE_H__ -#ifdef HAVE_CONFIG_H -# include -#endif - #include #include #include @@ -71,6 +67,8 @@ GType chmsee_get_type(void); ChmSee * chmsee_new(const gchar* fname); +void chmsee_set_model(ChmSee* self, ChmseeIchmfile *book); +gboolean chmsee_jump_index_by_name(ChmSee* self, const gchar* name); /* void chmsee_open_file(ChmSee *, const gchar *); */ int chmsee_get_hpaned_position(ChmSee* self); void chmsee_set_hpaned_position(ChmSee* self, int hpaned_position); diff -Nru chmsee-1.0.6/src/CMakeLists.txt chmsee-1.0.7/src/CMakeLists.txt --- chmsee-1.0.6/src/CMakeLists.txt 2009-07-12 04:02:53.000000000 +0100 +++ chmsee-1.0.7/src/CMakeLists.txt 2009-09-14 14:51:03.000000000 +0100 @@ -4,7 +4,6 @@ ${CHMSEE_INCLUDE_DIRS} ) add_definitions( - -Wall ${CHMSEE_CFLAGS_OTHER} ) add_custom_command( @@ -31,6 +30,7 @@ ihtml.h ihtml.c html-factory.h html-factory.c ui_index.h ui_index.c + ui_chmfile.h ui_chmfile.c ) set(CHMSEE_SRCS ${CHMSEE_SRCS} @@ -49,13 +49,11 @@ add_library(chmseelib STATIC ${CHMSEE_SRCS}) target_link_libraries(chmseelib ${CHMSEE_LIBRARIES} - chm - gcrypt ) add_executable(chmsee main.cpp) target_link_libraries(chmsee chmseelib ) - + install(TARGETS chmsee DESTINATION bin) diff -Nru chmsee-1.0.6/src/config.h.in chmsee-1.0.7/src/config.h.in --- chmsee-1.0.6/src/config.h.in 2009-07-12 04:02:53.000000000 +0100 +++ chmsee-1.0.7/src/config.h.in 2009-09-14 14:51:03.000000000 +0100 @@ -9,3 +9,9 @@ #define PACKAGE "chmsee" #define GETTEXT_PACKAGE "chmsee" #define PACKAGE_LOCALE_DIR "${CMAKE_INSTALL_PREFIX}/share/locale" +#cmakedefine XULRUNNER_VERSION "${XULRUNNER_VERSION}" +#cmakedefine XULRUNNER18 1 +#cmakedefine XULRUNNER19 1 +#cmakedefine XULRUNNER190 1 +#cmakedefine XULRUNNER191 1 +#cmakedefine GECKO_LIB_ROOT "${GECKO_LIB_ROOT}" diff -Nru chmsee-1.0.6/src/gecko_utils.cpp chmsee-1.0.7/src/gecko_utils.cpp --- chmsee-1.0.6/src/gecko_utils.cpp 2009-07-12 04:02:53.000000000 +0100 +++ chmsee-1.0.7/src/gecko_utils.cpp 2009-09-14 14:51:03.000000000 +0100 @@ -53,7 +53,13 @@ #include #include #include -#include +#if XULRUNNER18 + #include + #include +#else + #include + #include +#endif #include #include @@ -65,7 +71,6 @@ #include #include #include -#include #include #include "utils/utils.h" @@ -205,10 +210,17 @@ #ifdef XPCOM_GLUE NS_LogInit(); +#if XULRUNNER191 + static const GREVersionRange greVersion = { + "1.9.1", PR_TRUE, + "1.9.2", PR_FALSE + }; +#else static const GREVersionRange greVersion = { "1.9a", PR_TRUE, "1.9.1", PR_FALSE }; +#endif char xpcomLocation[4096]; rv = GRE_GetGREPathWithProperties(&greVersion, 1, nsnull, 0, xpcomLocation, 4096); diff -Nru chmsee-1.0.6/src/main.cpp chmsee-1.0.7/src/main.cpp --- chmsee-1.0.6/src/main.cpp 2009-07-12 04:02:53.000000000 +0100 +++ chmsee-1.0.7/src/main.cpp 2009-09-14 14:51:03.000000000 +0100 @@ -85,6 +85,7 @@ ChmSee *chmsee; const gchar* filename = NULL; const gchar* datadir = NULL; + const gchar* index = NULL; GError* error = NULL; gboolean option_version = FALSE; @@ -102,6 +103,11 @@ GOptionEntry options[] = { + {"index", 'i', + 0, G_OPTION_ARG_STRING, &index, + _("Specify index"), + _("INDEX") + }, {"version", 0, 0, G_OPTION_ARG_NONE, &option_version, _("Display the version and exit"), @@ -120,7 +126,7 @@ {"datadir", 0, G_OPTION_FLAG_FILENAME, G_OPTION_ARG_FILENAME, &datadir, "choose data dir, default is " CHMSEE_DATA_DIR_DEFAULT, - "PATH" + _("PATH") }, {NULL} }; @@ -165,6 +171,9 @@ /* Create main window */ chmsee = chmsee_new(filename); + if(index != NULL) { + chmsee_jump_index_by_name(chmsee, index); + } gtk_widget_show(GTK_WIDGET (chmsee)); diff -Nru chmsee-1.0.6/src/models/chmfile.c chmsee-1.0.7/src/models/chmfile.c --- chmsee-1.0.6/src/models/chmfile.c 2009-07-12 04:02:53.000000000 +0100 +++ chmsee-1.0.7/src/models/chmfile.c 2010-03-21 03:36:12.000000000 +0000 @@ -29,7 +29,7 @@ #include #include -#if defined(__linux__) +#if defined(__linux__) || defined(__GLIBC__) #include #include #else @@ -118,24 +118,25 @@ static void chmfile_finalize(GObject *object) { - ChmFile *chmfile; + ChmFile *self; - chmfile = CHMFILE (object); + self = CHMFILE (object); g_message("chmfile finalize"); - save_fileinfo(chmfile); - g_free(chmfile->encoding); - g_free(chmfile->filename); - g_free(chmfile->hhc); - g_free(chmfile->hhk); - g_free(chmfile->home); - g_free(chmfile->title); - g_free(chmfile->variable_font); - g_free(chmfile->fixed_font); + save_fileinfo(self); + g_free(self->dir); + g_free(self->encoding); + g_free(self->filename); + g_free(self->hhc); + g_free(self->hhk); + g_free(self->home); + g_free(self->title); + g_free(self->variable_font); + g_free(self->fixed_font); - if(chmfile->link_tree) { - g_node_destroy(chmfile->link_tree); + if(self->link_tree) { + g_node_destroy(self->link_tree); } G_OBJECT_CLASS (parent_class)->finalize (object); @@ -266,7 +267,7 @@ return TRUE; } -#if defined(__linux__) +#if defined(__linux__) || defined(__GLIBC__) static char * MD5File(const char *filename, char *buf) { @@ -531,7 +532,7 @@ ChmFile * chmfile_new(const gchar *filename) { - ChmFile *chmfile; + ChmFile *self; gchar *bookmark_file; gchar *md5; @@ -541,51 +542,51 @@ return NULL; } - chmfile = g_object_new(TYPE_CHMFILE, NULL); + self = g_object_new(TYPE_CHMFILE, NULL); + self->filename = g_strdup(filename); - chmfile->dir = g_build_filename(g_getenv("HOME"), + self->dir = g_build_filename(g_getenv("HOME"), ".chmsee", "bookshelf", md5, NULL); - g_debug("book dir = %s", chmfile->dir); + g_debug("book dir = %s", self->dir); /* If this chm file extracted before, load it's bookinfo */ - if (!g_file_test(chmfile->dir, G_FILE_TEST_IS_DIR)) { - if (!extract_chm(filename, chmfile)) { + if (!g_file_test(self->dir, G_FILE_TEST_IS_DIR)) { + if (!extract_chm(filename, self)) { g_debug("extract_chm failed: %s", filename); return NULL; } - chmfile->filename = g_strdup(filename); - g_debug("chmfile->filename = %s", chmfile->filename); + g_debug("chmfile->filename = %s", self->filename); - chmfile_file_info(chmfile); - save_fileinfo(chmfile); + chmfile_file_info(self); + save_fileinfo(self); } else { - load_fileinfo(chmfile); + load_fileinfo(self); } - g_debug("chmfile->hhc = %s", chmfile->hhc); - g_debug("chmfile->hhk = %s", chmfile->hhk); - g_debug("chmfile->home = %s", chmfile->home); - g_debug("chmfile->title = %s", chmfile->title); - g_debug("chmfile->endcoding = %s", chmfile->encoding); + g_debug("chmfile->hhc = %s", self->hhc); + g_debug("chmfile->hhk = %s", self->hhk); + g_debug("chmfile->home = %s", self->home); + g_debug("chmfile->title = %s", self->title); + g_debug("chmfile->endcoding = %s", self->encoding); /* Parse hhc and store result to tree view */ - if (chmfile->hhc != NULL && g_ascii_strcasecmp(chmfile->hhc, "(null)") != 0) { + if (self->hhc != NULL && g_ascii_strcasecmp(self->hhc, "(null)") != 0) { gchar *hhc; - hhc = g_strdup_printf("%s%s", chmfile->dir, chmfile->hhc); + hhc = g_strdup_printf("%s%s", self->dir, self->hhc); if (g_file_test(hhc, G_FILE_TEST_EXISTS)) { - chmfile->link_tree = hhc_load(hhc, chmfile->encoding); + self->link_tree = hhc_load(hhc, self->encoding); } else { gchar *hhc_ncase; hhc_ncase = file_exist_ncase(hhc); - chmfile->link_tree = hhc_load(hhc_ncase, chmfile->encoding); + self->link_tree = hhc_load(hhc_ncase, self->encoding); g_free(hhc_ncase); } @@ -595,11 +596,12 @@ } /* Load bookmarks */ - bookmark_file = g_build_filename(chmfile->dir, CHMSEE_BOOKMARK_FILE, NULL); - chmfile->bookmarks_list = bookmarks_load(bookmark_file); + bookmark_file = g_build_filename(self->dir, CHMSEE_BOOKMARK_FILE, NULL); + self->bookmarks_list = bookmarks_load(bookmark_file); g_free(bookmark_file); + g_free(md5); - return chmfile; + return self; } void load_fileinfo(ChmFile *book) @@ -655,6 +657,7 @@ } free_config_list(pairs); + g_free(path); } void @@ -721,6 +724,11 @@ return self->variable_font; } +static const gchar* chmfile_get_filename(ChmseeIchmfile* self_) { + ChmFile* self = CHMFILE(self_); + return self->filename; +} + static Hhc* chmfile_get_link_tree(ChmFile* self) { return self->link_tree; } @@ -751,6 +759,7 @@ iface->set_fixed_font = chmfile_set_fixed_font; iface->set_variable_font = chmfile_set_variable_font; iface->get_index = chmfile_get_index; + iface->get_filename = chmfile_get_filename; } void chmfile_set_encoding(ChmFile* self, const char* encoding) { diff -Nru chmsee-1.0.6/src/models/chmfile-factory.h chmsee-1.0.7/src/models/chmfile-factory.h --- chmsee-1.0.6/src/models/chmfile-factory.h 2009-07-12 04:02:53.000000000 +0100 +++ chmsee-1.0.7/src/models/chmfile-factory.h 2009-09-14 14:51:03.000000000 +0100 @@ -22,6 +22,10 @@ #include "ichmfile.h" +G_BEGIN_DECLS + ChmseeIchmfile* chmsee_chmfile_new(const gchar* fname); +G_END_DECLS + #endif diff -Nru chmsee-1.0.6/src/models/chmindex.c chmsee-1.0.7/src/models/chmindex.c --- chmsee-1.0.6/src/models/chmindex.c 2009-07-12 04:02:53.000000000 +0100 +++ chmsee-1.0.7/src/models/chmindex.c 2009-09-14 14:51:03.000000000 +0100 @@ -37,7 +37,7 @@ ChmIndex* chmindex_new(const char* filename, const char* encoding) { GNode* node = hhc_load(filename, encoding); - if(node == NULL) { + if(g_node_first_child(node) == NULL) { return NULL; } diff -Nru chmsee-1.0.6/src/models/ichmfile.c chmsee-1.0.7/src/models/ichmfile.c --- chmsee-1.0.6/src/models/ichmfile.c 2009-07-12 04:02:53.000000000 +0100 +++ chmsee-1.0.7/src/models/ichmfile.c 2009-09-14 14:51:03.000000000 +0100 @@ -81,6 +81,13 @@ return CHMSEE_ICHMFILE_GET_INTERFACE(self)->get_fixed_font(self); } +const gchar* chmsee_ichmfile_get_filename(ChmseeIchmfile* self) +{ + g_return_val_if_fail(CHMSEE_IS_ICHMFILE(self), NULL); + return CHMSEE_ICHMFILE_GET_INTERFACE(self)->get_filename(self); +} + + Hhc* chmsee_ichmfile_get_link_tree(ChmseeIchmfile* self) { g_return_val_if_fail(CHMSEE_IS_ICHMFILE(self), NULL); diff -Nru chmsee-1.0.6/src/models/ichmfile.h chmsee-1.0.7/src/models/ichmfile.h --- chmsee-1.0.6/src/models/ichmfile.h 2009-07-12 04:02:53.000000000 +0100 +++ chmsee-1.0.7/src/models/ichmfile.h 2009-09-14 14:51:03.000000000 +0100 @@ -43,6 +43,7 @@ const gchar* (*get_title) (ChmseeIchmfile* self); const gchar* (*get_variable_font) (ChmseeIchmfile* self); const gchar* (*get_fixed_font) (ChmseeIchmfile* self); + const gchar* (*get_filename) (ChmseeIchmfile* self); Hhc* (*get_link_tree) (ChmseeIchmfile* self); Bookmarks* (*get_bookmarks_list) (ChmseeIchmfile* self); ChmIndex* (*get_index) (ChmseeIchmfile* self); @@ -60,6 +61,7 @@ const gchar* chmsee_ichmfile_get_title(ChmseeIchmfile* self); const gchar* chmsee_ichmfile_get_variable_font(ChmseeIchmfile* self); const gchar* chmsee_ichmfile_get_fixed_font(ChmseeIchmfile* self); +const gchar* chmsee_ichmfile_get_filename(ChmseeIchmfile* self); void chmsee_ichmfile_set_variable_font(ChmseeIchmfile* self, const gchar* font); void chmsee_ichmfile_set_fixed_font(ChmseeIchmfile* self, const gchar* font); diff -Nru chmsee-1.0.6/src/setup.h chmsee-1.0.7/src/setup.h --- chmsee-1.0.6/src/setup.h 2009-07-12 04:02:53.000000000 +0100 +++ chmsee-1.0.7/src/setup.h 2009-09-14 14:51:03.000000000 +0100 @@ -27,8 +27,8 @@ * (at your option) any later version. * ***************************************************************************/ -#ifndef __SETUP_H__ -#define __SETUP_H__ +#ifndef __CHMSEE_SETUP_H__ +#define __CHMSEE_SETUP_H__ #include "chmsee.h" diff -Nru chmsee-1.0.6/src/ui_bookmarks.c chmsee-1.0.7/src/ui_bookmarks.c --- chmsee-1.0.6/src/ui_bookmarks.c 2009-07-12 04:02:53.000000000 +0100 +++ chmsee-1.0.7/src/ui_bookmarks.c 2009-09-14 14:51:03.000000000 +0100 @@ -372,6 +372,12 @@ return GTK_WIDGET(bookmarks); } +void ui_bookmarks_set_model(UiBookmarks* self, GList* model) { + self->links = model; + update_bookmarks_treeview(self, NULL); +} + + void ui_bookmarks_set_current_link(UiBookmarks *bookmarks, const gchar *name, const gchar *uri) diff -Nru chmsee-1.0.6/src/ui_bookmarks.h chmsee-1.0.7/src/ui_bookmarks.h --- chmsee-1.0.6/src/ui_bookmarks.h 2009-07-12 04:02:53.000000000 +0100 +++ chmsee-1.0.7/src/ui_bookmarks.h 2009-09-14 14:51:03.000000000 +0100 @@ -61,7 +61,8 @@ }; GType ui_bookmarks_get_type(void); -GtkWidget *ui_bookmarks_new(GList *); +GtkWidget *ui_bookmarks_new(GList* model); +void ui_bookmarks_set_model(UiBookmarks* self, GList* model); void ui_bookmarks_set_current_link(UiBookmarks *, const gchar *, const gchar *); void ui_bookmarks_grab_focus(UiBookmarks *); diff -Nru chmsee-1.0.6/src/ui_chmfile.c chmsee-1.0.7/src/ui_chmfile.c --- chmsee-1.0.6/src/ui_chmfile.c 1970-01-01 01:00:00.000000000 +0100 +++ chmsee-1.0.7/src/ui_chmfile.c 2009-09-14 14:51:03.000000000 +0100 @@ -0,0 +1,1173 @@ +/* + * Copyright (C) 2006 Ji YongGang + * Copyright (C) 2009 LI Daobing + * + * ChmSee 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 2, or (at your option) + * any later version. + + * ChmSee 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 General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with ChmseeUiChmfile; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +/*************************************************************************** + * Copyright (C) 2003 by zhong * + * zhongz@163.com * + * * + * 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 2 of the License, or * + * (at your option) any later version. * + ***************************************************************************/ + +#include "config.h" +#include "ui_chmfile.h" + +#include +#include +#include +#include + +#include /* R_OK */ + +#include +#include +#include +#include + +#include "ihtml.h" +#include "html-factory.h" +#include "booktree.h" +#include "ui_bookmarks.h" +#include "ui_index.h" +#include "link.h" +#include "utils/utils.h" + +#include "models/chmfile-factory.h" + +enum { + CHMSEE_STATE_INIT, /* init state, no book is loaded */ + CHMSEE_STATE_LOADING, /* loading state, don't pop up an error window when open homepage failed */ + CHMSEE_STATE_NORMAL /* normal state, one book is loaded */ +}; + + +/* Signals */ +enum { + MODEL_CHANGED, + HTML_CHANGED, + LAST_SIGNAL +}; +static gint signals[LAST_SIGNAL] = { 0 }; + +enum { + PROP_0, + + PROP_SIDEPANE_VISIBLE, + PROP_LINK_MESSAGE +}; + +struct _ChmseeUiChmfilePrivate { + GtkWidget* control_notebook; + + GtkWidget* topic_page; + GtkWidget* ui_topic; + + GtkWidget* index_page; /* the index tab under control_notebook */ + GtkWidget* ui_index; /* the gtktreeview */ + + GtkWidget* bookmark_page; + + GtkWidget* html_notebook; + + GtkActionGroup* action_group; + GtkUIManager* ui_manager; + + + guint scid_default; + + gboolean has_toc; + gboolean has_index; + gint pos_x; + gint pos_y; + gint width; + gint height; + gint hpaned_position; + gint lang; + + ChmseeIchmfile *model; + + gchar *home; + gchar *cache_dir; + gchar *last_dir; + gchar* context_menu_link; + gint state; /* see enum CHMSEE_STATE_* */ + gchar* link_message; +}; + + + +#define selfp (self->priv) +#define GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), CHMSEE_TYPE_UI_CHMFILE, ChmseeUiChmfilePrivate)) + +static void chmsee_ui_chmfile_finalize(GObject *); +static void chmsee_ui_chmfile_dispose(GObject* self); +static void chmsee_ui_chmfile_set_property(GObject* self, + guint property_id, + const GValue* value, + GParamSpec* pspec); +static void chmsee_ui_chmfile_get_property(GObject* self, + guint property_id, + GValue* value, + GParamSpec* pspec); + +static void chmsee_set_context_menu_link(ChmseeUiChmfile* self, const gchar* link); + +static void chmsee_refresh_index(ChmseeUiChmfile* self); +static GtkWidget* chmsee_new_index_page(ChmseeUiChmfile* self); +static void on_ui_index_link_selected(ChmseeUiChmfile* self, Link* link); + +static void on_booktree_link_selected(GObject *, Link *, ChmseeUiChmfile *); +static void on_bookmarks_link_selected(GObject *, Link *, ChmseeUiChmfile *); +static void on_html_notebook_switch_page(GtkNotebook *, GtkNotebookPage *, guint , ChmseeUiChmfile *); +static void on_html_location_changed(ChmseeIhtml *, const gchar *, ChmseeUiChmfile *); +static gboolean on_html_open_uri(ChmseeIhtml *, const gchar *, ChmseeUiChmfile *); +static void on_html_title_changed(ChmseeIhtml *, const gchar *, ChmseeUiChmfile *); +static void on_html_context_normal(ChmseeIhtml *, ChmseeUiChmfile *); +static void on_html_context_link(ChmseeIhtml *, const gchar *, ChmseeUiChmfile *); +static void on_html_open_new_tab(ChmseeIhtml *, const gchar *, ChmseeUiChmfile *); +static void on_html_link_message(ChmseeIhtml *, const gchar *, ChmseeUiChmfile *); + +static void on_close_tab(GtkWidget *, ChmseeUiChmfile *); +static void on_copy(GtkWidget *, ChmseeUiChmfile *); +static void on_copy_page_location(GtkWidget*, ChmseeUiChmfile*); +static void on_select_all(GtkWidget *, ChmseeUiChmfile *); +static void on_back(GtkWidget *, ChmseeUiChmfile *); +static void on_forward(GtkWidget *, ChmseeUiChmfile *); +static void on_zoom_in(GtkWidget *, ChmseeUiChmfile *); +static void on_context_new_tab(GtkWidget *, ChmseeUiChmfile *); +static void on_context_copy_link(GtkWidget *, ChmseeUiChmfile *); + +static void chmsee_ui_chmfile_populate_window(ChmseeUiChmfile *); +static void chmsee_ui_chmfile_close_current_book(ChmseeUiChmfile *); +static void update_tab_title(ChmseeUiChmfile *, ChmseeIhtml *); +static void tab_set_title(ChmseeUiChmfile *, ChmseeIhtml *, const gchar *); +static void open_homepage(ChmseeUiChmfile *); + +static const GtkActionEntry entries[] = { + { "Copy", GTK_STOCK_COPY, "_Copy", "C", NULL, G_CALLBACK(on_copy)}, + { "Back", GTK_STOCK_GO_BACK, "_Back", "Left", NULL, G_CALLBACK(on_back)}, + { "Forward", GTK_STOCK_GO_FORWARD, "_Forward", "Right", NULL, G_CALLBACK(on_forward)}, + { "OpenLinkInNewTab", NULL, "Open Link in New _Tab", NULL, NULL, G_CALLBACK(on_context_new_tab)}, + { "CopyLinkLocation", NULL, "_Copy Link Location", NULL, NULL, G_CALLBACK(on_context_copy_link)}, + { "SelectAll", NULL, "Select _All", NULL, NULL, G_CALLBACK(on_select_all)}, + { "CopyPageLocation", NULL, "Copy Page _Location", NULL, NULL, G_CALLBACK(on_copy_page_location)}, + { "OnKeyboardControlEqual", NULL, NULL, "equal", NULL, G_CALLBACK(on_zoom_in)} +}; + +/* Radio items */ +static const GtkRadioActionEntry radio_entries[] = { +}; + +static const char *ui_description = + "" + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + "" + ""; + + +G_DEFINE_TYPE (ChmseeUiChmfile, chmsee_ui_chmfile, GTK_TYPE_HPANED); + +void +chmsee_ui_chmfile_class_init(ChmseeUiChmfileClass *klass) +{ + GParamSpec* pspec; + + g_type_class_add_private(klass, sizeof(ChmseeUiChmfilePrivate)); + G_OBJECT_CLASS(klass)->finalize = chmsee_ui_chmfile_finalize; + G_OBJECT_CLASS(klass)->dispose = chmsee_ui_chmfile_dispose; + G_OBJECT_CLASS(klass)->set_property = chmsee_ui_chmfile_set_property; + G_OBJECT_CLASS(klass)->get_property = chmsee_ui_chmfile_get_property; + + signals[MODEL_CHANGED] = + g_signal_new ("model_changed", + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, + 0, + NULL, + NULL, + g_cclosure_marshal_VOID__POINTER, + G_TYPE_NONE, + 1, + G_TYPE_POINTER); + + signals[HTML_CHANGED] = + g_signal_new("html_changed", + G_TYPE_FROM_CLASS(klass), + G_SIGNAL_RUN_LAST, + 0, + NULL, + NULL, + g_cclosure_marshal_VOID__POINTER, + G_TYPE_NONE, + 1, + G_TYPE_POINTER); + + pspec = g_param_spec_boolean("sidepane-visible", NULL, NULL, TRUE, G_PARAM_READWRITE); + g_object_class_install_property(G_OBJECT_CLASS(klass), PROP_SIDEPANE_VISIBLE, pspec); + + pspec = g_param_spec_string("link-message", NULL, NULL, "", G_PARAM_READABLE); + g_object_class_install_property(G_OBJECT_CLASS(klass), PROP_LINK_MESSAGE, pspec); +} + +static void +chmsee_ui_chmfile_init(ChmseeUiChmfile* self) +{ + self->priv = GET_PRIVATE(self); + selfp->home = g_build_filename(g_get_home_dir(), ".chmsee", NULL); + + g_debug("chmsee home = %s", selfp->home); + + if (!g_file_test(selfp->home, G_FILE_TEST_IS_DIR)) + mkdir(selfp->home, 0777); + + selfp->cache_dir = g_build_filename(selfp->home, "bookshelf", NULL); + + if (!g_file_test(selfp->cache_dir, G_FILE_TEST_IS_DIR)) + mkdir(selfp->cache_dir, 0777); + + selfp->lang = 0; + selfp->last_dir = g_strdup(g_get_home_dir()); + selfp->context_menu_link = NULL; + + selfp->model = NULL; + selfp->pos_x = -100; + selfp->pos_y = -100; + selfp->width = 0; + selfp->height = 0; + selfp->hpaned_position = -1; + selfp->has_toc = FALSE; + selfp->has_index = FALSE; + selfp->state = CHMSEE_STATE_INIT; + selfp->link_message = NULL; + + + /* Init gecko */ + chmsee_html_init_system(); + chmsee_html_set_default_lang(selfp->lang); + + chmsee_ui_chmfile_populate_window(self); + +} + +static void +chmsee_ui_chmfile_finalize(GObject *object) +{ + ChmseeUiChmfile* self = CHMSEE_UI_CHMFILE(object); + + if(selfp->home) { + g_free(selfp->home); + selfp->home = NULL; + } + + if(selfp->cache_dir) { + g_free(selfp->cache_dir); + selfp->cache_dir = NULL; + } + + if(selfp->last_dir) { + g_free(selfp->last_dir); + selfp->last_dir = NULL; + } + + g_free(selfp->context_menu_link); + selfp->context_menu_link = NULL; + G_OBJECT_CLASS (chmsee_ui_chmfile_parent_class)->finalize (object); +} + +static void chmsee_ui_chmfile_dispose(GObject* gobject) +{ + ChmseeUiChmfile* self = CHMSEE_UI_CHMFILE(gobject); + + if(selfp->model) { + g_object_unref(selfp->model); + selfp->model = NULL; + } + + if(selfp->action_group) { + g_object_unref(selfp->action_group); + selfp->action_group = NULL; + } + + if(selfp->ui_manager) { + g_object_unref(selfp->ui_manager); + selfp->ui_manager = NULL; + } + + G_OBJECT_CLASS(chmsee_ui_chmfile_parent_class)->dispose(gobject); +} + +static void +on_booktree_link_selected(GObject *ignored, Link *link, ChmseeUiChmfile *self) +{ + ChmseeIhtml* html; + + g_debug("booktree link selected: %s", link->uri); + if (!g_ascii_strcasecmp(CHMSEE_NO_LINK, link->uri)) + return; + + html = chmsee_ui_chmfile_get_active_html(self); + + g_signal_handlers_block_by_func(html, on_html_open_uri, self); + + chmsee_ihtml_open_uri(html, g_build_filename( + chmsee_ichmfile_get_dir(selfp->model), link->uri, NULL)); + + g_signal_handlers_unblock_by_func(html, on_html_open_uri, self); +} + +static void +on_bookmarks_link_selected(GObject *ignored, Link *link, ChmseeUiChmfile *chmsee) +{ + chmsee_ihtml_open_uri(chmsee_ui_chmfile_get_active_html(chmsee), link->uri); +} + +static void +on_html_notebook_switch_page(GtkNotebook *notebook, GtkNotebookPage *page, guint new_page_num, ChmseeUiChmfile *self) +{ + GtkWidget *new_page; + + new_page = gtk_notebook_get_nth_page(notebook, new_page_num); + + if (new_page) { + ChmseeIhtml* new_html; + const gchar* title; + const gchar* location; + + new_html = g_object_get_data(G_OBJECT (new_page), "html"); + + update_tab_title(self, new_html); + + title = chmsee_ihtml_get_title(new_html); + location = chmsee_ihtml_get_location(new_html); + + if (location != NULL && strlen(location)) { + if (title && title[0]) { + ui_bookmarks_set_current_link(UIBOOKMARKS (selfp->bookmark_page), title, location); + } else { + const gchar *book_title; + + book_title = booktree_get_selected_book_title(BOOKTREE (selfp->ui_topic)); + ui_bookmarks_set_current_link(UIBOOKMARKS (selfp->bookmark_page), book_title, location); + } + + /* Sync the book tree. */ + if (selfp->has_toc) + booktree_select_uri(BOOKTREE (selfp->ui_topic), location); + } + } else { + gtk_window_set_title(GTK_WINDOW (self), "ChmseeUiChmfile"); + } + g_signal_emit(self, signals[HTML_CHANGED], 0, chmsee_ui_chmfile_get_active_html(self)); +} + +static void +on_html_location_changed(ChmseeIhtml *html, const gchar *location, ChmseeUiChmfile* self) +{ + g_debug("%s:%d:html location changed cb: %s", __FILE__, __LINE__, location); + g_signal_emit(self, signals[HTML_CHANGED], 0, chmsee_ui_chmfile_get_active_html(self)); +} + +static gboolean +on_html_open_uri(ChmseeIhtml* html, const gchar *uri, ChmseeUiChmfile *self) +{ + g_debug("enter html_open_uri_cb with uri = %s", uri); + static const char* prefix = "file://"; + static int prefix_len = 7; + + if(g_str_has_prefix(uri, prefix)) { + /* FIXME: can't disable the DND function of GtkMozEmbed */ + if(g_str_has_suffix(uri, ".chm") + || g_str_has_suffix(uri, ".CHM")) { + /* TODO: should popup an event */ + /* chmsee_open_uri(self, uri); */ + } + + if(g_access(uri+prefix_len, R_OK) < 0) { + g_debug("%s:%d:html_open_uri_cb:%s does not exist", __FILE__, __LINE__, uri+prefix_len); + gchar* newfname = correct_filename(uri+prefix_len); + if(newfname) { + g_message(_("URI redirect: \"%s\" -> \"%s\""), uri, newfname); + chmsee_ihtml_open_uri(html, newfname); + g_free(newfname); + return TRUE; + } + + if(selfp->state == CHMSEE_STATE_LOADING) { + return TRUE; + } + } + } + + if ((html == chmsee_ui_chmfile_get_active_html(self)) && selfp->has_toc) + booktree_select_uri(BOOKTREE (selfp->ui_topic), uri); + + return FALSE; +} + +static void +on_html_title_changed(ChmseeIhtml *html, const gchar *title, ChmseeUiChmfile *self) +{ + const gchar *location; + + g_debug("html title changed cb %s", title); + + update_tab_title(self, chmsee_ui_chmfile_get_active_html(self)); + + location = chmsee_ihtml_get_location(html); + + if (location != NULL && strlen(location)) { + if (strlen(title)) + ui_bookmarks_set_current_link(UIBOOKMARKS (selfp->bookmark_page), title, location); + else { + const gchar *book_title; + + book_title = booktree_get_selected_book_title(BOOKTREE (selfp->ui_topic)); + ui_bookmarks_set_current_link(UIBOOKMARKS (selfp->bookmark_page), book_title, location); + } + } +} + +/* Popup html context menu */ +static void +on_html_context_normal(ChmseeIhtml *html, ChmseeUiChmfile *self) +{ + g_debug("html context-normal event"); + gtk_menu_popup(GTK_MENU(gtk_ui_manager_get_widget(selfp->ui_manager, "/HtmlContextNormal")), + NULL, NULL, NULL, NULL, 0, GDK_CURRENT_TIME); +} + +/* Popup html context menu when mouse over hyper link */ +static void +on_html_context_link(ChmseeIhtml *html, const gchar *link, ChmseeUiChmfile* self) +{ + g_debug("html context-link event: %s", link); + chmsee_set_context_menu_link(self, link); + gtk_action_set_sensitive(gtk_action_group_get_action(selfp->action_group, "OpenLinkInNewTab"), + g_str_has_prefix(selfp->context_menu_link, "file://")); + + gtk_menu_popup(GTK_MENU(gtk_ui_manager_get_widget(selfp->ui_manager, "/HtmlContextLink")), + NULL, NULL, NULL, NULL, 0, GDK_CURRENT_TIME); +} + +static void +on_html_open_new_tab(ChmseeIhtml *html, const gchar *location, ChmseeUiChmfile *chmsee) +{ + g_debug("html open new tab callback: %s", location); + + chmsee_ui_chmfile_new_tab(chmsee, location); +} + +static void +on_html_link_message(ChmseeIhtml *html, const gchar *url, ChmseeUiChmfile *self) +{ + g_free(selfp->link_message); + selfp->link_message = g_strdup(url); + g_object_notify(G_OBJECT(self), "link-message"); +} + +static void +on_close_tab(GtkWidget *widget, ChmseeUiChmfile *self) +{ + gint num_pages, number, i; + GtkWidget *tab_label, *page; + + number = -1; + num_pages = gtk_notebook_get_n_pages(GTK_NOTEBOOK (selfp->html_notebook)); + + if (num_pages == 1) { + /* TODO: should open a new empty tab */ + return; + } + + for (i = 0; i < num_pages; i++) { + GList *children, *l; + + g_debug("page %d", i); + page = gtk_notebook_get_nth_page(GTK_NOTEBOOK (selfp->html_notebook), i); + + tab_label = gtk_notebook_get_tab_label(GTK_NOTEBOOK (selfp->html_notebook), page); + g_message("tab_label"); + children = gtk_container_get_children(GTK_CONTAINER (tab_label)); + + for (l = children; l; l = l->next) { + if (widget == l->data) { + g_debug("found tab on page %d", i); + number = i; + break; + } + } + + if (number >= 0) { + gtk_notebook_remove_page(GTK_NOTEBOOK (selfp->html_notebook), number); + + break; + } + } +} + +static void +on_copy(GtkWidget *widget, ChmseeUiChmfile *self) +{ + g_message("On Copy"); + + g_return_if_fail(GTK_IS_NOTEBOOK (selfp->html_notebook)); + + chmsee_ihtml_copy_selection(chmsee_ui_chmfile_get_active_html(self)); +} + +static void +on_copy_page_location(GtkWidget* widget, ChmseeUiChmfile* chmsee) { + ChmseeIhtml* html = chmsee_ui_chmfile_get_active_html(chmsee); + const gchar* location = chmsee_ihtml_get_location(html); + if(!location) return; + + gtk_clipboard_set_text( + gtk_clipboard_get(GDK_SELECTION_PRIMARY), + location, + -1); + gtk_clipboard_set_text( + gtk_clipboard_get(GDK_SELECTION_CLIPBOARD), + location, + -1); +} + +static void +on_select_all(GtkWidget *widget, ChmseeUiChmfile *self) +{ + ChmseeIhtml *html; + + g_message("On Select All"); + + g_return_if_fail(GTK_IS_NOTEBOOK (selfp->html_notebook)); + + html = chmsee_ui_chmfile_get_active_html(self); + chmsee_ihtml_select_all(html); +} + +static void +on_back(GtkWidget *widget, ChmseeUiChmfile *chmsee) +{ + chmsee_ihtml_go_back(chmsee_ui_chmfile_get_active_html(chmsee)); +} + +static void +on_forward(GtkWidget *widget, ChmseeUiChmfile *chmsee) +{ + chmsee_ihtml_go_forward(chmsee_ui_chmfile_get_active_html(chmsee)); +} + +static void +on_zoom_in(GtkWidget *widget, ChmseeUiChmfile *self) +{ + ChmseeIhtml* html = chmsee_ui_chmfile_get_active_html(self); + if(html != NULL) { + chmsee_ihtml_increase_size(html); + } +} + +void chmsee_ui_chmfile_close_current_tab(ChmseeUiChmfile* self) { + g_return_if_fail(GTK_IS_NOTEBOOK (selfp->html_notebook)); + + if (gtk_notebook_get_n_pages(GTK_NOTEBOOK (selfp->html_notebook)) == 1) { + /* TODO: should open a new tab */ + } + + gint page_num; + + page_num = gtk_notebook_get_current_page(GTK_NOTEBOOK (selfp->html_notebook)); + + if (page_num >= 0) + gtk_notebook_remove_page(GTK_NOTEBOOK (selfp->html_notebook), page_num); +} + +static void +on_context_new_tab(GtkWidget *widget, ChmseeUiChmfile *self) +{ + g_debug("On context open new tab: %s", selfp->context_menu_link); + + if (selfp->context_menu_link != NULL) { + chmsee_ui_chmfile_new_tab(self, selfp->context_menu_link); + } +} + +static void +on_context_copy_link(GtkWidget *widget, ChmseeUiChmfile *self) +{ + g_debug("On context copy link: %s", selfp->context_menu_link); + + if (selfp->context_menu_link != NULL) { + gtk_clipboard_set_text(gtk_clipboard_get(GDK_SELECTION_PRIMARY), + selfp->context_menu_link, -1); + gtk_clipboard_set_text(gtk_clipboard_get(GDK_SELECTION_CLIPBOARD), + selfp->context_menu_link, -1); + } +} + + +static void +chmsee_ui_chmfile_populate_window(ChmseeUiChmfile *self) +{ + GtkWidget* control_vbox = gtk_vbox_new(FALSE, 0); + gtk_widget_show(control_vbox); + + GtkWidget* control_notebook = gtk_notebook_new(); + gtk_box_pack_start(GTK_BOX (control_vbox), + GTK_WIDGET (control_notebook), + TRUE, + TRUE, + 2); + gtk_widget_show(control_notebook); + + + GtkWidget* topic_page = gtk_scrolled_window_new(NULL, NULL); + gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW (topic_page), + GTK_POLICY_NEVER, + GTK_POLICY_AUTOMATIC); + gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW (topic_page), + GTK_SHADOW_IN); + gtk_container_set_border_width(GTK_CONTAINER (topic_page), 2); + + GtkWidget* booktree = GTK_WIDGET(g_object_ref_sink(booktree_new(NULL))); + gtk_container_add(GTK_CONTAINER (topic_page), booktree); + gtk_widget_show_all(topic_page); + gtk_notebook_append_page(GTK_NOTEBOOK (control_notebook), + topic_page, + gtk_label_new(_("Topics"))); + + g_signal_connect(G_OBJECT (booktree), + "link-selected", + G_CALLBACK (on_booktree_link_selected), + self); + + gtk_notebook_append_page(GTK_NOTEBOOK (control_notebook), + chmsee_new_index_page(self), + gtk_label_new(_("Index"))); + + selfp->bookmark_page = GTK_WIDGET (ui_bookmarks_new(NULL)); + + gtk_notebook_append_page(GTK_NOTEBOOK (control_notebook), + selfp->bookmark_page, + gtk_label_new (_("Bookmarks"))); + + g_signal_connect(G_OBJECT (selfp->bookmark_page), + "link-selected", + G_CALLBACK (on_bookmarks_link_selected), + self); + + gtk_paned_add1(GTK_PANED(self), control_vbox); + + /* HTML tabs notebook */ + GtkWidget* html_notebook = gtk_notebook_new(); + g_signal_connect(G_OBJECT (html_notebook), + "switch-page", + G_CALLBACK (on_html_notebook_switch_page), + self); + + gtk_widget_show(html_notebook); + gtk_paned_add2 (GTK_PANED (self), html_notebook); + gtk_widget_show_all(GTK_WIDGET(self)); + + g_signal_connect(G_OBJECT (html_notebook), + "switch-page", + G_CALLBACK (on_html_notebook_switch_page), + self); + + + selfp->control_notebook = control_notebook; + selfp->html_notebook = html_notebook; + selfp->ui_topic = booktree; + selfp->topic_page = topic_page; + + chmsee_ui_chmfile_new_tab(self, NULL); + + GtkActionGroup* action_group = gtk_action_group_new ("UiChmfileActions"); + selfp->action_group = action_group; + gtk_action_group_add_actions (action_group, entries, G_N_ELEMENTS (entries), self); + + gtk_action_set_sensitive(gtk_action_group_get_action(action_group, "Back"), FALSE); + gtk_action_set_sensitive(gtk_action_group_get_action(action_group, "Forward"), FALSE); + + GtkUIManager* ui_manager = gtk_ui_manager_new (); + selfp->ui_manager = ui_manager; + gtk_ui_manager_insert_action_group (ui_manager, action_group, 0); + + GError* error = NULL; + if (!gtk_ui_manager_add_ui_from_string (ui_manager, ui_description, -1, &error)) + { + g_message ("building menus failed: %s", error->message); + g_error_free (error); + exit (EXIT_FAILURE); + } + +} + +void +chmsee_ui_chmfile_set_model2(ChmseeUiChmfile* self, ChmseeIchmfile *book) +{ + GNode *link_tree; + GList *bookmarks_list; + + g_debug("display book"); + selfp->state = CHMSEE_STATE_LOADING; + + /* Close currently opened book */ + if (selfp->model) { + chmsee_ui_chmfile_close_current_book(self); + } + + selfp->model = g_object_ref(book); + + /* TOC */ + if (chmsee_ichmfile_get_link_tree(selfp->model) != NULL) { + booktree_set_model(BOOKTREE(selfp->ui_topic), link_tree = chmsee_ichmfile_get_link_tree(selfp->model)); + gtk_widget_show(selfp->topic_page); + selfp->has_toc = TRUE; + } else { + gtk_widget_hide(selfp->topic_page); + selfp->has_toc = FALSE; + } + + /* Index */ + chmsee_refresh_index(self); + + /* Bookmarks */ + bookmarks_list = chmsee_ichmfile_get_bookmarks_list(selfp->model); + ui_bookmarks_set_model(UIBOOKMARKS(selfp->bookmark_page), bookmarks_list); + + + gtk_notebook_set_current_page(GTK_NOTEBOOK (selfp->control_notebook), + g_list_length(bookmarks_list) && selfp->has_toc ? 1 : 0); + + chmsee_ihtml_set_variable_font(chmsee_ui_chmfile_get_active_html(self), + chmsee_ichmfile_get_variable_font(selfp->model)); + chmsee_ihtml_set_fixed_font(chmsee_ui_chmfile_get_active_html(self), + chmsee_ichmfile_get_fixed_font(selfp->model)); + + if (chmsee_ichmfile_get_home(selfp->model)) { + open_homepage(self); + + } + selfp->state = CHMSEE_STATE_NORMAL; + + selfp->last_dir = g_strdup_printf("%s", g_path_get_dirname( + chmsee_ichmfile_get_filename(book))); +} + +void +chmsee_ui_chmfile_set_model(ChmseeUiChmfile* self, ChmseeIchmfile *book) +{ + chmsee_ui_chmfile_set_model2(self, book); + g_signal_emit(self, signals[MODEL_CHANGED], 0, book); +} + + + +static void +chmsee_ui_chmfile_close_current_book(ChmseeUiChmfile *self) +{ + gchar* bookmark_fname = g_build_filename(chmsee_ichmfile_get_dir(selfp->model), CHMSEE_BOOKMARK_FILE, NULL); + bookmarks_save(ui_bookmarks_get_list(UIBOOKMARKS (selfp->bookmark_page)), bookmark_fname); + g_free(bookmark_fname); + g_object_unref(selfp->model); + + selfp->model = NULL; + selfp->state = CHMSEE_STATE_INIT; +} + +static GtkWidget* +new_tab_content(ChmseeUiChmfile *chmsee, const gchar *str) +{ + GtkWidget *widget; + GtkWidget *label; + GtkWidget *close_button, *close_image; + + widget = gtk_hbox_new(FALSE, 3); + + label = gtk_label_new(str); + gtk_label_set_ellipsize(GTK_LABEL (label), PANGO_ELLIPSIZE_END); + gtk_label_set_single_line_mode(GTK_LABEL (label), TRUE); + gtk_misc_set_alignment(GTK_MISC (label), 0.0, 0.5); + gtk_misc_set_padding(GTK_MISC (label), 0, 0); + gtk_box_pack_start(GTK_BOX (widget), label, TRUE, TRUE, 0); + g_object_set_data(G_OBJECT (widget), "label", label); + + close_button = gtk_button_new(); + gtk_button_set_relief(GTK_BUTTON(close_button), GTK_RELIEF_NONE); + close_image = gtk_image_new_from_stock(GTK_STOCK_CLOSE, GTK_ICON_SIZE_MENU); + gtk_widget_show(close_image); + gtk_container_add(GTK_CONTAINER (close_button), close_image); + g_signal_connect(G_OBJECT (close_button), + "clicked", + G_CALLBACK (on_close_tab), + chmsee); + + gtk_box_pack_start(GTK_BOX (widget), close_button, FALSE, FALSE, 0); + + gtk_widget_show_all(widget); + + return widget; +} + +void +chmsee_ui_chmfile_new_tab(ChmseeUiChmfile *self, const gchar *location) +{ + ChmseeIhtml *html; + GtkWidget *frame; + GtkWidget *view; + GtkWidget *tab_content; + gint num; + + g_debug("new_tab : %s", location); + + /* Ignore external link */ + if (location != NULL && !g_str_has_prefix(location, "file://")) + return; + + html = chmsee_html_new(); + view = chmsee_ihtml_get_widget(html); + gtk_widget_show(view); + + frame = gtk_frame_new(NULL); + gtk_widget_show(frame); + + gtk_frame_set_shadow_type(GTK_FRAME (frame), GTK_SHADOW_IN); + gtk_container_set_border_width(GTK_CONTAINER (frame), 2); + gtk_container_add(GTK_CONTAINER (frame), view); + + g_object_set_data(G_OBJECT (frame), "html", html); + + /* Custom label widget, with a close button */ + tab_content = new_tab_content(self, _("No Title")); + + g_signal_connect(G_OBJECT (html), + "title-changed", + G_CALLBACK (on_html_title_changed), + self); + g_signal_connect(G_OBJECT (html), + "open-uri", + G_CALLBACK (on_html_open_uri), + self); + g_signal_connect(G_OBJECT (html), + "location-changed", + G_CALLBACK (on_html_location_changed), + self); + g_signal_connect(G_OBJECT (html), + "context-normal", + G_CALLBACK (on_html_context_normal), + self); + g_signal_connect(G_OBJECT (html), + "context-link", + G_CALLBACK (on_html_context_link), + self); + g_signal_connect(G_OBJECT (html), + "open-new-tab", + G_CALLBACK (on_html_open_new_tab), + self); + g_signal_connect(G_OBJECT (html), + "link-message", + G_CALLBACK (on_html_link_message), + self); + num = gtk_notebook_append_page(GTK_NOTEBOOK (selfp->html_notebook), + frame, tab_content); + + gtk_notebook_set_tab_label_packing(GTK_NOTEBOOK (selfp->html_notebook), + frame, + TRUE, TRUE, + GTK_PACK_START); + + if (location != NULL) { + chmsee_ihtml_open_uri(html, location); + + if (selfp->has_toc) + booktree_select_uri(BOOKTREE (selfp->ui_topic), location); + } else { + /* chmsee_ihtml_clear(html); */ + } + + gtk_notebook_set_current_page(GTK_NOTEBOOK (selfp->html_notebook), num); + g_signal_emit(self, + signals[HTML_CHANGED], + 0, + chmsee_ui_chmfile_get_active_html(self)); +} + +static void +open_homepage(ChmseeUiChmfile *self) +{ + ChmseeIhtml *html; + + html = chmsee_ui_chmfile_get_active_html(self); + + /* g_signal_handlers_block_by_func(html, html_open_uri_cb, self); */ + + chmsee_ihtml_open_uri(html, g_build_filename(chmsee_ichmfile_get_dir(selfp->model), + chmsee_ichmfile_get_home(selfp->model), NULL)); + + /* g_signal_handlers_unblock_by_func(html, html_open_uri_cb, self); */ + + if (selfp->has_toc) { + booktree_select_uri(BOOKTREE (selfp->ui_topic), + chmsee_ichmfile_get_home(selfp->model)); + } +} + +ChmseeIhtml * +chmsee_ui_chmfile_get_active_html(ChmseeUiChmfile *self) +{ + GtkWidget *frame; + gint page_num; + + if(!selfp->html_notebook) { + return NULL; + } + page_num = gtk_notebook_get_current_page(GTK_NOTEBOOK (selfp->html_notebook)); + + if (page_num == -1) + return NULL; + + frame = gtk_notebook_get_nth_page(GTK_NOTEBOOK (selfp->html_notebook), page_num); + + return g_object_get_data(G_OBJECT (frame), "html"); +} + +static void +update_tab_title(ChmseeUiChmfile *self, ChmseeIhtml *html) +{ + gchar* html_title; + const gchar* tab_title; + const gchar* book_title; + + html_title = g_strdup(chmsee_ihtml_get_title(html)); + + if (selfp->has_toc) + book_title = booktree_get_selected_book_title(BOOKTREE (selfp->ui_topic)); + else + book_title = ""; + + if (book_title && book_title[0] != '\0' && + html_title && html_title[0] != '\0' && + ncase_compare_utf8_string(book_title, html_title)) + tab_title = g_strdup_printf("%s : %s", book_title, html_title); + else if (book_title && book_title[0] != '\0') + tab_title = g_strdup(book_title); + else if (html_title && html_title[0] != '\0') + tab_title = g_strdup(html_title); + else + tab_title = g_strdup(""); + + tab_set_title(self, html, tab_title); + g_free(html_title); +} + +static void +tab_set_title(ChmseeUiChmfile *self, ChmseeIhtml *html, const gchar *title) +{ + GtkWidget *view; + GtkWidget *page; + GtkWidget *widget, *label; + gint num_pages, i; + + view = chmsee_ihtml_get_widget(html); + + if (title == NULL || title[0] == '\0') + title = _("No Title"); + + num_pages = gtk_notebook_get_n_pages(GTK_NOTEBOOK (selfp->html_notebook)); + + for (i = 0; i < num_pages; i++) { + page = gtk_notebook_get_nth_page(GTK_NOTEBOOK (selfp->html_notebook), i); + + if (gtk_bin_get_child(GTK_BIN (page)) == view) { + widget = gtk_notebook_get_tab_label(GTK_NOTEBOOK (selfp->html_notebook), page); + + label = g_object_get_data(G_OBJECT (widget), "label"); + + if (label != NULL) + gtk_label_set_text(GTK_LABEL (label), title); + + break; + } + } +} + +int chmsee_ui_chmfile_get_hpaned_position(ChmseeUiChmfile* self) { + return gtk_paned_get_position(GTK_PANED(self)); +} + +void chmsee_ui_chmfile_set_hpaned_position(ChmseeUiChmfile* self, int hpaned_position) { + selfp->hpaned_position = hpaned_position; + /* + g_object_set(G_OBJECT(get_widget(self, "hpaned1")), + "position", hpaned_position, + NULL + ); + */ +} + +const gchar* chmsee_ui_chmfile_get_cache_dir(ChmseeUiChmfile* self) { + return selfp->cache_dir; +} + +const gchar* chmsee_ui_chmfile_get_variable_font(ChmseeUiChmfile* self) { + g_return_val_if_fail(selfp->model, NULL); + return chmsee_ichmfile_get_variable_font(selfp->model); +} + +void chmsee_ui_chmfile_set_variable_font(ChmseeUiChmfile* self, const gchar* font_name) { + g_return_if_fail(selfp->model); + chmsee_ichmfile_set_variable_font(selfp->model, font_name); +} + +const gchar* chmsee_ui_chmfile_get_fixed_font(ChmseeUiChmfile* self) { + g_return_val_if_fail(selfp->model, NULL); + return chmsee_ichmfile_get_fixed_font(selfp->model); +} + +void chmsee_ui_chmfile_set_fixed_font(ChmseeUiChmfile* self, const gchar* font_name) { + g_return_if_fail(selfp->model); + chmsee_ichmfile_set_fixed_font(selfp->model, font_name); +} + +int chmsee_ui_chmfile_get_lang(ChmseeUiChmfile* self) { + return selfp->lang; +} +void chmsee_ui_chmfile_set_lang(ChmseeUiChmfile* self, int lang) { + selfp->lang = lang; +} + +gboolean chmsee_ui_chmfile_has_book(ChmseeUiChmfile* self) { + return selfp->model != NULL; +} + +void chmsee_refresh_index(ChmseeUiChmfile* self) { + ChmIndex* chmIndex = NULL; + if(selfp->model) { + chmIndex = chmsee_ichmfile_get_index(selfp->model); + } + chmsee_ui_index_set_model(CHMSEE_UI_INDEX(selfp->ui_index), chmIndex); + if(chmIndex != NULL) { + g_debug("chmIndex != NULL"); + gtk_widget_show(selfp->index_page); + } else { + g_debug("chmIndex == NULL"); + gtk_widget_hide(selfp->index_page); + } +} + +static GtkWidget* chmsee_new_index_page(ChmseeUiChmfile* self) { + GtkWidget* booktree_sw = gtk_scrolled_window_new(NULL, NULL); + gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW (booktree_sw), + GTK_POLICY_NEVER, + GTK_POLICY_AUTOMATIC); + gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW (booktree_sw), + GTK_SHADOW_IN); + gtk_container_set_border_width(GTK_CONTAINER (booktree_sw), 2); + + GtkWidget* uiIndex = chmsee_ui_index_new(NULL); + gtk_container_add(GTK_CONTAINER (booktree_sw), uiIndex); + g_signal_connect_swapped(uiIndex, + "link-selected", + G_CALLBACK (on_ui_index_link_selected), + self); + + selfp->index_page = booktree_sw; + selfp->ui_index = uiIndex; + return GTK_WIDGET(booktree_sw); +} + +void on_ui_index_link_selected(ChmseeUiChmfile* self, Link* link) { + on_booktree_link_selected(NULL, link, self); +} + + +gboolean chmsee_ui_chmfile_jump_index_by_name(ChmseeUiChmfile* self, const gchar* name) { + g_return_val_if_fail(CHMSEE_IS_UI_CHMFILE(self), FALSE); + + gboolean res = chmsee_ui_index_select_link_by_name( + CHMSEE_UI_INDEX(self->priv->ui_index), + name); + + if(res) { + /* TODO: hard-code page num 1 */ + gtk_notebook_set_current_page(GTK_NOTEBOOK(self->priv->control_notebook), 1); + } + return res; +} + +static void chmsee_set_context_menu_link(ChmseeUiChmfile* self, const gchar* link) { + g_free(selfp->context_menu_link); + selfp->context_menu_link = g_strdup(link); +} + +GtkWidget* chmsee_ui_chmfile_new() { + return GTK_WIDGET(g_object_new(CHMSEE_TYPE_UI_CHMFILE, NULL)); +} + +void chmsee_ui_chmfile_set_property(GObject* object, + guint property_id, + const GValue* value, + GParamSpec* pspec) +{ + ChmseeUiChmfile* self = CHMSEE_UI_CHMFILE(object); + + switch(property_id) { + case PROP_SIDEPANE_VISIBLE: + if(g_value_get_boolean(value)) { + gtk_widget_show(gtk_paned_get_child1(GTK_PANED(self))); + } else { + gtk_widget_hide(gtk_paned_get_child1(GTK_PANED(self))); + } + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} +void chmsee_ui_chmfile_get_property(GObject* object, + guint property_id, + GValue* value, + GParamSpec* pspec) +{ + ChmseeUiChmfile* self = CHMSEE_UI_CHMFILE(object); + + switch(property_id) { + case PROP_SIDEPANE_VISIBLE: + g_value_set_boolean(value, GTK_WIDGET_VISIBLE(gtk_paned_get_child1(GTK_PANED(self)))); + break; + case PROP_LINK_MESSAGE: + g_value_set_string(value, selfp->link_message); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} diff -Nru chmsee-1.0.6/src/ui_chmfile.h chmsee-1.0.7/src/ui_chmfile.h --- chmsee-1.0.6/src/ui_chmfile.h 1970-01-01 01:00:00.000000000 +0100 +++ chmsee-1.0.7/src/ui_chmfile.h 2009-09-14 14:51:03.000000000 +0100 @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2006 Ji YongGang + * Copyright (C) 2009 LI Daobing + * + * ChmSee 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 2, or (at your option) + * any later version. + + * ChmSee 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 General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with ChmSee; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +/*************************************************************************** + * Copyright (C) 2003 by zhong * + * zhongz@163.com * + * * + * 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 2 of the License, or * + * (at your option) any later version. * + ***************************************************************************/ + +#ifndef __CHMSEE_UI_CHMFILE_H__ +#define __CHMSEE_UI_CHMFILE_H__ + +#include +#include +#include + +#include "models/ichmfile.h" +#include "ihtml.h" + +G_BEGIN_DECLS + +typedef struct _ChmseeUiChmfile ChmseeUiChmfile; +typedef struct _ChmseeUiChmfilePrivate ChmseeUiChmfilePrivate; +typedef struct _ChmseeUiChmfileClass ChmseeUiChmfileClass; + +#define CHMSEE_TYPE_UI_CHMFILE \ + (chmsee_ui_chmfile_get_type ()) +#define CHMSEE_UI_CHMFILE(o) \ + (G_TYPE_CHECK_INSTANCE_CAST ((o), CHMSEE_TYPE_UI_CHMFILE, ChmseeUiChmfile)) +#define CHMSEE_IS_UI_CHMFILE(o) \ + (G_TYPE_CHECK_INSTANCE_TYPE ((o), CHMSEE_TYPE_UI_CHMFILE)) + + +struct _ChmseeUiChmfile { + GtkHPaned parent; + ChmseeUiChmfilePrivate* priv; +}; + +struct _ChmseeUiChmfileClass { + GtkHPanedClass parent_class; +}; + +GType chmsee_ui_chmfile_get_type(void); +GtkWidget* chmsee_ui_chmfile_new(void); +void chmsee_ui_chmfile_set_model(ChmseeUiChmfile* self, ChmseeIchmfile* model); +ChmseeIhtml* chmsee_ui_chmfile_get_active_html(ChmseeUiChmfile* self); +gboolean chmsee_ui_chmfile_jump_index_by_name(ChmseeUiChmfile* self, const gchar* name); +void chmsee_ui_chmfile_new_tab(ChmseeUiChmfile *self, const gchar *location); +void chmsee_ui_chmfile_close_current_tab(ChmseeUiChmfile* self); + +G_END_DECLS + +#endif /* !__CHMSEE_UI_CHMFILE_H__ */ diff -Nru chmsee-1.0.6/src/ui_index.c chmsee-1.0.7/src/ui_index.c --- chmsee-1.0.6/src/ui_index.c 2009-07-12 04:02:53.000000000 +0100 +++ chmsee-1.0.7/src/ui_index.c 2009-09-14 14:51:03.000000000 +0100 @@ -37,8 +37,6 @@ ChmIndex* chmIndex; }; -static GtkViewportClass* parent_class; - #define CHMSEE_UI_INDEX_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), CHMSEE_TYPE_UI_INDEX, ChmseeUiIndexPrivate)) G_DEFINE_TYPE(ChmseeUiIndex, chmsee_ui_index, GTK_TYPE_VIEWPORT); @@ -53,8 +51,6 @@ G_OBJECT_CLASS(klass)->dispose = chmsee_ui_index_dispose; G_OBJECT_CLASS(klass)->finalize = chmsee_ui_index_finalize; - parent_class = g_type_class_peek_parent(klass); - signals[LINK_SELECTED] = g_signal_new ("link_selected", G_TYPE_FROM_CLASS (klass), @@ -72,6 +68,13 @@ chmsee_ui_index_init(ChmseeUiIndex* self) { self->priv = CHMSEE_UI_INDEX_GET_PRIVATE(self); selfp->chmIndex = NULL; + GtkWidget* widget = booktree_new(NULL); + gtk_container_add(GTK_CONTAINER(self), + widget); + g_signal_connect_swapped(widget, + "link_selected", + G_CALLBACK(chmsee_ui_index_on_link_selected), + self); } GtkWidget* chmsee_ui_index_new(ChmIndex* chmIndex) { @@ -86,11 +89,11 @@ g_object_unref(selfp->chmIndex); selfp->chmIndex = NULL; } - G_OBJECT_CLASS(parent_class)->dispose(object); + G_OBJECT_CLASS(chmsee_ui_index_parent_class)->dispose(object); } static void chmsee_ui_index_finalize(GObject* object) { - G_OBJECT_CLASS(parent_class)->finalize(object); + G_OBJECT_CLASS(chmsee_ui_index_parent_class)->finalize(object); } void chmsee_ui_index_set_model(ChmseeUiIndex* self, ChmIndex* chmIndex) { @@ -108,28 +111,25 @@ void chmsee_ui_index_refresh(ChmseeUiIndex* self) { - GtkWidget* widget = NULL; - if(selfp->chmIndex != NULL) { - GNode* node = chmindex_get_data(selfp->chmIndex); - if(node != NULL) { - widget = booktree_new(node); - } - } + GNode* node = NULL; - GtkWidget* child = gtk_bin_get_child(GTK_BIN(self)); - if(child != NULL) { - gtk_widget_destroy(child); - } + if(selfp->chmIndex != NULL) { + node = chmindex_get_data(selfp->chmIndex); + } - if(widget != NULL) { - gtk_container_add(GTK_CONTAINER(self), widget); - g_signal_connect_swapped(widget, "link_selected", (GCallback)chmsee_ui_index_on_link_selected, self); - } else { - gtk_container_add(GTK_CONTAINER(self), gtk_tree_view_new()); - } + booktree_set_model(BOOKTREE(gtk_bin_get_child(GTK_BIN(self))), + node); } void chmsee_ui_index_on_link_selected(ChmseeUiIndex* self, Link* link) { g_signal_emit(self, signals[LINK_SELECTED], 0, link); } +gboolean chmsee_ui_index_select_link_by_name(ChmseeUiIndex* self, const gchar* name) { + GtkWidget* child = gtk_bin_get_child(GTK_BIN(self)); + if(!IS_BOOKTREE(child)) { + return FALSE; + } + + return booktree_select_link_by_name(BOOKTREE(child), name); +} diff -Nru chmsee-1.0.6/src/ui_index.h chmsee-1.0.7/src/ui_index.h --- chmsee-1.0.6/src/ui_index.h 2009-07-12 04:02:53.000000000 +0100 +++ chmsee-1.0.7/src/ui_index.h 2009-09-14 14:51:03.000000000 +0100 @@ -49,5 +49,10 @@ void chmsee_ui_index_set_model(ChmseeUiIndex* self, ChmIndex* chmIndex); void chmsee_ui_index_refresh(ChmseeUiIndex* self); +/** + * @return true if successful. else return false. + */ +gboolean chmsee_ui_index_select_link_by_name(ChmseeUiIndex* self, const gchar* name); + #endif /* UI_INDEX_H_ */