Codebase list granule / b9f3618
granule 1.2.4 Eric Dorland 17 years ago
80 changed file(s) with 7549 addition(s) and 1904 deletion(s). Raw diff Collapse all Expand all
0 Release 1.2.4
1 Jan 14 2007 Vladislav Grinchenko (vlg[AT]users.sourceforge.net)
2 - Made bg_/fg_color text settings configurable in DeckPlayer.
3 (Bug #1628956).
4 - Added show/hide various controls of DeckPlayer dialog in
5 PDA version to maximize usable viewing area.
6 - Double-clicking an entry in DeckView dialog brings up
7 CardView editing dialog for the card selected.
8 - Load multiple DeckFiles at once (FR #1618817).
9 - Fixed "Answer line selector is ignored" (Bug #1618820).
10 - Changed sound command arguments to require file type extension
11 (from %s to %s.wav for wav files).
12 - Added custom Deck Appearance preferences available via
13 DeckPlayer->EditDeck->DeckInfo dialog.
14 - Added 'normalize' (remove extra newlines/whitespaces) and
15 'add index' edit shortcut buttons to CardView dialog.
16 - Took [Cancel] button out of focus chain (Feature Req #1620622).
17 - Added alternative config file command-line option with
18 { --config-file=/path/name }.
19 - Added pane separators to CardView dialog to adjust the height
20 of the multiline input fields.
21 - Added padding control for all text fields in DeckPlayer.
22 - Added (opional) two-sided sound clip playback.
23 - Changed sound playback to asynchronous.
24 - Ported to OpenEmbedded GPE PDAs (240x320 screen size)
25 (Patch #1560198).
26 - Fixed granule.spec.in to fit FC extras strict spec rules.
27 - Added text alignment controls for Front/Back text fields.
28 - Fixed format of DeckInfo dialog and proper setting of alternative
29 sound path.
30 - Added multi-line CSV file import (Feature Request #1588158).
31
032 Release 1.2.3
1 Nov 1 2006 Vladislav Grinchenko (vlg-AT-users-DOT-sourceforge-DOT-net)
33 Oct 8 2006 Vladislav Grinchenko (vlg[AT]users.sourceforge.net)
234 - Fixed multi-row selection in DeckView bug (when adding new cards).
335 - Make Front and Back fields in CardView high enough to fit two
436 complete rows of data.
840 - [maemo 2.0] Fixed application exit by closing window [x].
941
1042 Release 1.2.2
11 Sep 4 2006 Vladislav Grinchenko (vlg-AT-users-DOT-sourceforge-DOT-net)
43 Sep 4 2006 Vladislav Grinchenko (vlg[AT]users.sourceforge.net)
1244 - Port to Maemo 2.0 (Nokia770 IT2006).
1345 - Port to libassa-3.4.2 (mingw32 networking code support).
1446 - Memory management fix for gcc-4.0.
2355 - Fixed crash when deleting the last card in DeckView (Bug #1554481).
2456
2557 Release 1.2.1
26 Mar 18 2006 Vladislav Grinchenko (vlg-AT-users-DOT-sourceforge-DOT-net)
58 Mar 18 2006 Vladislav Grinchenko (vlg[AT]users.sourceforge.net)
2759 - Native port to Hildon/ARM (nokia770 internet tablet).
2860 - Add 'Paste' button to CardView dialog.
2961 - Disable assa event handler.
3668 - Add "Input font" configuration option to Preferences dialog.
3769
3870 Release 1.2.0
39 Nov 30 2005 Vladislav Grinchenko (vlg-AT-users-DOT-sourceforge-DOT-net)
71 Nov 30 2005 Vladislav Grinchenko (vlg[AT]users.sourceforge.net)
4072 - Fix CardFile Save option greyed out bug (bug #1261317).
4173 - Add an option to disable keyboard shortcuts in DeckPlayer.
4274 - Add hours/minutes scheduling resolution (rfe #1256643).
4779 - Make CardView input dialog fully tabular.
4880 - Add Pango markup shortcut controls to CardView dialog.
4981 - Add Japanese translation by Jeff Ames
50 (jeffames-AT-users-DOT-sourceforge-DOT-net)
82 (jeffames[AT]users.sourceforge.net)
5183 - Catch illegal pango markup and give the user a chance to fix it.
5284 - Get rid of libxml++ dependency (uses basic libxml2 instead).
5385 - Port to libassa-3.4.x.
5486 - Port to cygwin32.
5587 - Port to x86_ia64 - Konstantin Riabitsev
56 (graf25-AT-users-DOT-sourceforge-DOT-net)
88 (graf25[AT]users.sourceforge.net)
5789
5890 Release 1.1.6
59 Jul 3 2005 Vladislav Grinchenko (vlg-AT-users-DOT-sourceforge-DOT-net)
91 Jul 3 2005 Vladislav Grinchenko (vlg[AT]users.sourceforge.net)
6092 - Fix markup of multiple tildas in the Example field.
6193 - Add colored comparison match feedback in DeckPlayer dialog.
6294 - Location-independent DTD paths (taken from a port of granule
76108 - Removed 'u' hot key.
77109
78110 Release 1.1.5
79 Apr 17 2005 Vladislav Grinchenko (vlg-AT-users-DOT-sourceforge-DOT-net)
111 Apr 17 2005 Vladislav Grinchenko (vlg[AT]users.sourceforge.net)
80112 - Full i18n support.
81113 - Update DeckPlayer's confirmation icons.
82114 - Add input verification control to DeckPlayer (rfe #1101697).
103135 data members in CardBox c'tor.
104136
105137 Release 1.1.4
106 Nov 27 2004 Vladislav Grinchenko (vlg-AT-users-DOT-sourceforge-DOT-net)
138 Nov 27 2004 Vladislav Grinchenko (vlg[AT]users.sourceforge.net)
107139 - Fix core dumps on exit from libsigc-2.0 (bug #1068433).
108140 - Add 'commit' option to shuffling the cards in a Deck.
109141 When 'Shuffle' button is pressed, the user is asked if she wants
112144 partition (for the duration of a session).
113145
114146 Release 1.1.3
115 Nov 14 2004 Vladislav Grinchenko (vlg-AT-users-DOT-sourceforge-DOT-net)
147 Nov 14 2004 Vladislav Grinchenko (vlg[AT]users.sourceforge.net)
116148 - Fixes moving cards up and down in the list in the DeckView dialog.
117149 - Fixes viewing and deletion of the cards from sorted list
118150 in DeckView (bugs #1057777 and #105775).
131163 latter is empty (bug #1047324).
132164
133165 Release 1.1.2
134 Sep 25 2004 Vladislav Grinchenko (vlg-AT-users-DOT-sourceforge-DOT-net)
166 Sep 25 2004 Vladislav Grinchenko (vlg[AT]users.sourceforge.net)
135167 - Adds markup language for all text fields (bug #1022746).
136168 - Fixes misleading error message when loading invalid Deck
137169 file (bug #1022748).
141173 - Fixes sound playback bug (sound wouldn't play).
142174
143175 Release 1.1.1
144 Aug 09 2004 Vladislav Grinchenko (vlg-AT-users-DOT-sourceforge-DOT-net)
176 Aug 09 2004 Vladislav Grinchenko (vlg[AT]users.sourceforge.net)
145177 - Fixes libxml++ dependency. Now we check for libxml++-2.6
146178 which covers both versions 2.6 and 2.7 of libxml++ (bug #976948).
147179
148180 Release 1.1.0
149 Jul 23 2004 Vladislav Grinchenko (vlg-AT-users-DOT-sourceforge-DOT-net)
181 Jul 23 2004 Vladislav Grinchenko (vlg[AT]users.sourceforge.net)
150182 - Port to gtkmm2-2.4.x
151183 - DeckPlayer toolbar changes to UIManager/Action paradigm.
152184 - Properly registers SayIt application icon with IconFactory.
158190 - Adds right-click menu for a entry in a DeckList.
159191
160192 Release 1.0.2
161 Jun 26 2004 Vladislav Grinchenko (vlg-AT-users-DOT-sourceforge-DOT-net)
193 Jun 26 2004 Vladislav Grinchenko (vlg[AT]users.sourceforge.net)
162194 - Fixes scheduling count/lights.
163195 - Fixes duplicate Decks in DeckList.
164196 - Adds DeckView activation of a Deck from DeckList in the
166198 - Sets expiration date for CardBox 1 to 4 days in default config file.
167199
168200 Release 1.0.1
169 Jun 12 2004 Vladislav Grinchenko (vlg-AT-users-DOT-sourceforge-DOT-net)
201 Jun 12 2004 Vladislav Grinchenko (vlg[AT]users.sourceforge.net)
170202 - Fixes tar.gz/rpm build from a wrong CVS tree.
171203 - Changes XML DTD file location from $prefix/share/granule/xml
172204 to /etc/xml/granule. This way no matter how package is built,
181213 are expired.
182214
183215 Release 1.0.0
184 Jun 3 2004 Vladislav Grinchenko (vlg-AT-users-DOT-sourceforge-DOT-net)
216 Jun 3 2004 Vladislav Grinchenko (vlg[AT]users.sourceforge.net)
185217 - initial release.
5050 bootstrap.debian \
5151 bootstrap.hildon \
5252 bootstrap.win32 \
53 bootstrap.pda \
5354 $(icon_DATA) \
5455 $(xml_DATA) \
5556 README-win32.txt \
5657 intltool-extract.in \
5758 intltool-merge.in \
5859 intltool-update.in \
59 debian/changelog \
60 debian/compat \
61 debian/control \
62 debian/copyright \
63 debian/docs \
60 debian/changelog \
61 debian/compat \
62 debian/control \
63 debian/copyright \
64 debian/docs \
6465 debian/granule.install \
65 debian/granule.xpm \
66 debian/menu \
67 debian/rules \
66 debian/granule.xpm \
67 debian/menu \
68 debian/rules \
6869 debian.hildon/changelog \
6970 debian.hildon/compat \
7071 debian.hildon/control \
198198 USE_HILDON_FALSE = @USE_HILDON_FALSE@
199199 USE_HILDON_TRUE = @USE_HILDON_TRUE@
200200 USE_NLS = @USE_NLS@
201 USE_PDA_FALSE = @USE_PDA_FALSE@
202 USE_PDA_TRUE = @USE_PDA_TRUE@
201203 VERSION = @VERSION@
202204 WIN32_EXTRA_LIBADD = @WIN32_EXTRA_LIBADD@
203205 XGETTEXT = @XGETTEXT@
289291 bootstrap.debian \
290292 bootstrap.hildon \
291293 bootstrap.win32 \
294 bootstrap.pda \
292295 $(icon_DATA) \
293296 $(xml_DATA) \
294297 README-win32.txt \
295298 intltool-extract.in \
296299 intltool-merge.in \
297300 intltool-update.in \
298 debian/changelog \
299 debian/compat \
300 debian/control \
301 debian/copyright \
302 debian/docs \
301 debian/changelog \
302 debian/compat \
303 debian/control \
304 debian/copyright \
305 debian/docs \
303306 debian/granule.install \
304 debian/granule.xpm \
305 debian/menu \
306 debian/rules \
307 debian/granule.xpm \
308 debian/menu \
309 debian/rules \
307310 debian.hildon/changelog \
308311 debian.hildon/compat \
309312 debian.hildon/control \
0 # bootstrap.pda
1 #
2 # $Id: bootstrap.pda,v 1.2 2006/11/20 03:22:44 vlg Exp $
3 #
4
5 rm -f intltool-extract.in intltool-merge.in intltool-update.in
6 rm -f po/Makefile.in.in
7 rm -f config.guess config.sub depcomp install-sh missing
8 rm -rf autom4te.cache
9
10
11 glib-gettextize --copy --force || exit 1
12 intltoolize --automake --copy --force || exit 1
13
14 libtoolize --force --copy
15
16 aclocal $ACLOCAL_FLAGS || exit 1
17 autoheader
18 touch stamp-h
19
20 automake --add-missing --gnu --copy
21 autoconf
22
23 configure --enable-pda=yes
24
25 echo "Now type 'make' to compile Granule for OpenEmbedded PDAs"
308308 # include <unistd.h>
309309 #endif"
310310
311 ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS APP_VERSION APP_SUBVERSION APP_RELEASE INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar MAINTAINER_MODE_TRUE MAINTAINER_MODE_FALSE MAINT build build_cpu build_vendor build_os host host_cpu host_vendor host_os CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE CPP EGREP CXX CXXFLAGS ac_ct_CXX CXXDEPMODE am__fastdepCXX_TRUE am__fastdepCXX_FALSE CXXCPP INTLTOOL_DESKTOP_RULE INTLTOOL_DIRECTORY_RULE INTLTOOL_KEYS_RULE INTLTOOL_PROP_RULE INTLTOOL_OAF_RULE INTLTOOL_PONG_RULE INTLTOOL_SERVER_RULE INTLTOOL_SHEET_RULE INTLTOOL_SOUNDLIST_RULE INTLTOOL_UI_RULE INTLTOOL_XAM_RULE INTLTOOL_KBD_RULE INTLTOOL_XML_RULE INTLTOOL_XML_NOMERGE_RULE INTLTOOL_CAVES_RULE INTLTOOL_SCHEMAS_RULE INTLTOOL_THEME_RULE INTLTOOL_SERVICE_RULE INTLTOOL_EXTRACT INTLTOOL_MERGE INTLTOOL_UPDATE INTLTOOL_PERL INTLTOOL_ICONV INTLTOOL_MSGFMT INTLTOOL_MSGMERGE INTLTOOL_XGETTEXT GETTEXT_PACKAGE USE_NLS MSGFMT GMSGFMT XGETTEXT CATALOGS CATOBJEXT DATADIRNAME GMOFILES INSTOBJEXT INTLLIBS PO_IN_DATADIR_TRUE PO_IN_DATADIR_FALSE POFILES POSUB MKINSTALLDIRS PKG_CONFIG ac_pt_PKG_CONFIG GTKMM_CFLAGS GTKMM_LIBS XMLCPP_CFLAGS XMLCPP_LIBS ASSA_CFLAGS ASSA_LIBS USE_HILDON_TRUE USE_HILDON_FALSE HILDON_CFLAGS HILDON_LIBS DBUS_CFLAGS DBUS_LIBS OSSO_CFLAGS OSSO_LIBS desktopentrydir serviceentrydir icon_26x26dir icon_34x34dir icon_40x40dir icon_50x50dir icon_scalabledir runtime_root runtime_datadir runtime_xmldir pkg_datadir pkg_xmldir WIN32_EXTRA_LIBADD LIBOBJS LTLIBOBJS'
311 ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS APP_VERSION APP_SUBVERSION APP_RELEASE INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar MAINTAINER_MODE_TRUE MAINTAINER_MODE_FALSE MAINT build build_cpu build_vendor build_os host host_cpu host_vendor host_os CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE CPP EGREP CXX CXXFLAGS ac_ct_CXX CXXDEPMODE am__fastdepCXX_TRUE am__fastdepCXX_FALSE CXXCPP INTLTOOL_DESKTOP_RULE INTLTOOL_DIRECTORY_RULE INTLTOOL_KEYS_RULE INTLTOOL_PROP_RULE INTLTOOL_OAF_RULE INTLTOOL_PONG_RULE INTLTOOL_SERVER_RULE INTLTOOL_SHEET_RULE INTLTOOL_SOUNDLIST_RULE INTLTOOL_UI_RULE INTLTOOL_XAM_RULE INTLTOOL_KBD_RULE INTLTOOL_XML_RULE INTLTOOL_XML_NOMERGE_RULE INTLTOOL_CAVES_RULE INTLTOOL_SCHEMAS_RULE INTLTOOL_THEME_RULE INTLTOOL_SERVICE_RULE INTLTOOL_EXTRACT INTLTOOL_MERGE INTLTOOL_UPDATE INTLTOOL_PERL INTLTOOL_ICONV INTLTOOL_MSGFMT INTLTOOL_MSGMERGE INTLTOOL_XGETTEXT GETTEXT_PACKAGE USE_NLS MSGFMT GMSGFMT XGETTEXT CATALOGS CATOBJEXT DATADIRNAME GMOFILES INSTOBJEXT INTLLIBS PO_IN_DATADIR_TRUE PO_IN_DATADIR_FALSE POFILES POSUB MKINSTALLDIRS PKG_CONFIG ac_pt_PKG_CONFIG GTKMM_CFLAGS GTKMM_LIBS XMLCPP_CFLAGS XMLCPP_LIBS ASSA_CFLAGS ASSA_LIBS USE_HILDON_TRUE USE_HILDON_FALSE HILDON_CFLAGS HILDON_LIBS DBUS_CFLAGS DBUS_LIBS OSSO_CFLAGS OSSO_LIBS desktopentrydir serviceentrydir icon_26x26dir icon_34x34dir icon_40x40dir icon_50x50dir icon_scalabledir USE_PDA_TRUE USE_PDA_FALSE runtime_root runtime_datadir runtime_xmldir pkg_datadir pkg_xmldir WIN32_EXTRA_LIBADD LIBOBJS LTLIBOBJS'
312312 ac_subst_files=''
313313
314314 # Initialize some variables set by options.
918918 --enable-dependency-tracking do not reject slow dependency extractors
919919 --enable-mingw32 Compile with mingw32
920920 --enable-hildon Compile with hildon support
921 --enable-pda Compile with OpenEmbedded PDA support
921922
922923 Some influential environment variables:
923924 CC C compiler command
13911392
13921393 APP_MAJOR_VERSION=1
13931394 APP_MINOR_VERSION=2
1394 APP_MICRO_VERSION=3
1395 APP_MICRO_VERSION=4
13951396
13961397 APP_VERSION=$APP_MAJOR_VERSION.$APP_MINOR_VERSION.$APP_MICRO_VERSION
13971398 APP_SUBVERSION=$APP_MAJOR_VERSION.$APP_MINOR_VERSION
73577358 pkg_cv_XMLCPP_CFLAGS="$XMLCPP_CFLAGS"
73587359 else
73597360 if test -n "$PKG_CONFIG" && \
7360 { (echo "$as_me:$LINENO: \$PKG_CONFIG --exists --print-errors \"libxml-2.0 >= 2.6.11\"") >&5
7361 ($PKG_CONFIG --exists --print-errors "libxml-2.0 >= 2.6.11") 2>&5
7361 { (echo "$as_me:$LINENO: \$PKG_CONFIG --exists --print-errors \"libxml-2.0 >= 2.6.10\"") >&5
7362 ($PKG_CONFIG --exists --print-errors "libxml-2.0 >= 2.6.10") 2>&5
73627363 ac_status=$?
73637364 echo "$as_me:$LINENO: \$? = $ac_status" >&5
73647365 (exit $ac_status); }; then
7365 pkg_cv_XMLCPP_CFLAGS=`$PKG_CONFIG --cflags "libxml-2.0 >= 2.6.11" 2>/dev/null`
7366 pkg_cv_XMLCPP_CFLAGS=`$PKG_CONFIG --cflags "libxml-2.0 >= 2.6.10" 2>/dev/null`
73667367 else
73677368 pkg_failed=yes
73687369 fi
73757376 pkg_cv_XMLCPP_LIBS="$XMLCPP_LIBS"
73767377 else
73777378 if test -n "$PKG_CONFIG" && \
7378 { (echo "$as_me:$LINENO: \$PKG_CONFIG --exists --print-errors \"libxml-2.0 >= 2.6.11\"") >&5
7379 ($PKG_CONFIG --exists --print-errors "libxml-2.0 >= 2.6.11") 2>&5
7379 { (echo "$as_me:$LINENO: \$PKG_CONFIG --exists --print-errors \"libxml-2.0 >= 2.6.10\"") >&5
7380 ($PKG_CONFIG --exists --print-errors "libxml-2.0 >= 2.6.10") 2>&5
73807381 ac_status=$?
73817382 echo "$as_me:$LINENO: \$? = $ac_status" >&5
73827383 (exit $ac_status); }; then
7383 pkg_cv_XMLCPP_LIBS=`$PKG_CONFIG --libs "libxml-2.0 >= 2.6.11" 2>/dev/null`
7384 pkg_cv_XMLCPP_LIBS=`$PKG_CONFIG --libs "libxml-2.0 >= 2.6.10" 2>/dev/null`
73847385 else
73857386 pkg_failed=yes
73867387 fi
73997400 _pkg_short_errors_supported=no
74007401 fi
74017402 if test $_pkg_short_errors_supported = yes; then
7402 XMLCPP_PKG_ERRORS=`$PKG_CONFIG --short-errors --errors-to-stdout --print-errors "libxml-2.0 >= 2.6.11"`
7403 XMLCPP_PKG_ERRORS=`$PKG_CONFIG --short-errors --errors-to-stdout --print-errors "libxml-2.0 >= 2.6.10"`
74037404 else
7404 XMLCPP_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "libxml-2.0 >= 2.6.11"`
7405 XMLCPP_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "libxml-2.0 >= 2.6.10"`
74057406 fi
74067407 # Put the nasty error message in config.log where it belongs
74077408 echo "$XMLCPP_PKG_ERRORS" >&5
74087409
7409 { { echo "$as_me:$LINENO: error: Package requirements (libxml-2.0 >= 2.6.11) were not met:
7410 { { echo "$as_me:$LINENO: error: Package requirements (libxml-2.0 >= 2.6.10) were not met:
74107411
74117412 $XMLCPP_PKG_ERRORS
74127413
74177418 and XMLCPP_LIBS to avoid the need to call pkg-config.
74187419 See the pkg-config man page for more details.
74197420 " >&5
7420 echo "$as_me: error: Package requirements (libxml-2.0 >= 2.6.11) were not met:
7421 echo "$as_me: error: Package requirements (libxml-2.0 >= 2.6.10) were not met:
74217422
74227423 $XMLCPP_PKG_ERRORS
74237424
87458746
87468747
87478748
8749 pda=false
8750
8751 # Check whether --enable-pda or --disable-pda was given.
8752 if test "${enable_pda+set}" = set; then
8753 enableval="$enable_pda"
8754
8755 if test "x$enableval" = "xyes"; then
8756 pda=true
8757 fi
8758
8759 fi;
8760
8761
8762
8763 if $pda; then
8764 USE_PDA_TRUE=
8765 USE_PDA_FALSE='#'
8766 else
8767 USE_PDA_TRUE='#'
8768 USE_PDA_FALSE=
8769 fi
8770
8771
87488772
87498773
87508774
87568780
87578781
87588782
8759 pkg_datadir=$prefix/share/$PACKAGE/
8760 pkg_xmldir=$prefix/share/$PACKAGE/xml
8783
8784 pkg_datadir=${datadir}/$PACKAGE/
8785 pkg_xmldir=${datadir}/$PACKAGE/xml
87618786
87628787
87638788
89108935 { { echo "$as_me:$LINENO: error: conditional \"USE_HILDON\" was never defined.
89118936 Usually this means the macro was only invoked conditionally." >&5
89128937 echo "$as_me: error: conditional \"USE_HILDON\" was never defined.
8938 Usually this means the macro was only invoked conditionally." >&2;}
8939 { (exit 1); exit 1; }; }
8940 fi
8941 if test -z "${USE_PDA_TRUE}" && test -z "${USE_PDA_FALSE}"; then
8942 { { echo "$as_me:$LINENO: error: conditional \"USE_PDA\" was never defined.
8943 Usually this means the macro was only invoked conditionally." >&5
8944 echo "$as_me: error: conditional \"USE_PDA\" was never defined.
89138945 Usually this means the macro was only invoked conditionally." >&2;}
89148946 { (exit 1); exit 1; }; }
89158947 fi
95869618 s,@icon_40x40dir@,$icon_40x40dir,;t t
95879619 s,@icon_50x50dir@,$icon_50x50dir,;t t
95889620 s,@icon_scalabledir@,$icon_scalabledir,;t t
9621 s,@USE_PDA_TRUE@,$USE_PDA_TRUE,;t t
9622 s,@USE_PDA_FALSE@,$USE_PDA_FALSE,;t t
95899623 s,@runtime_root@,$runtime_root,;t t
95909624 s,@runtime_datadir@,$runtime_datadir,;t t
95919625 s,@runtime_xmldir@,$runtime_xmldir,;t t
00 dnl ----------------------------------------------------------------------------
11 dnl configure.in
22 dnl
3 dnl $Id: configure.in,v 1.39 2006/10/08 02:46:30 vlg Exp $
3 dnl $Id: configure.in,v 1.43 2007/01/08 04:32:36 vlg Exp $
44 dnl ----------------------------------------------------------------------------
55
66 dnl Process this file with autoconf to produce a configure script.
2121
2222 APP_MAJOR_VERSION=1
2323 APP_MINOR_VERSION=2
24 APP_MICRO_VERSION=3
24 APP_MICRO_VERSION=4
2525
2626 APP_VERSION=$APP_MAJOR_VERSION.$APP_MINOR_VERSION.$APP_MICRO_VERSION
2727 APP_SUBVERSION=$APP_MAJOR_VERSION.$APP_MINOR_VERSION
9797 dnl Replace with the current version number
9898 dnl ----------------------------------------------------------------------------
9999
100 PKG_CHECK_MODULES(XMLCPP, libxml-2.0 >= 2.6.11)
100 PKG_CHECK_MODULES(XMLCPP, libxml-2.0 >= 2.6.10)
101101 AC_SUBST(XMLCPP_CFLAGS)
102102 AC_SUBST(XMLCPP_LIBS)
103103
181181 runtime_root=$prefix
182182 fi
183183 ])
184
184
185185 AM_CONDITIONAL(USE_HILDON, $hildon)
186186
187187 if test "$hildon" = true ; then
221221 AC_SUBST(icon_50x50dir)
222222 AC_SUBST(icon_scalabledir)
223223
224 dnl ----------------------------------------------------------------------------
225 dnl Check for OpenEmbedded (GPE-based 320x240 PDAs)
226 dnl ----------------------------------------------------------------------------
227 pda=false
228
229 AC_ARG_ENABLE(pda,
230 AC_HELP_STRING([--enable-pda],[Compile with OpenEmbedded PDA support]),[
231 if test "x$enableval" = "xyes"; then
232 pda=true
233 fi
234 ])
235
236 AM_CONDITIONAL(USE_PDA, $pda)
237
224238 dnl-----------------------------------------------------------------------------
225239 dnl runtime_{}dir is where the executable looks for the data files at runtime.
226240 dnl pkg_{}dir is where the data files are installed.
238252
239253 dnl Points to where data files are installed, relative to --prefix=PATH
240254
241 pkg_datadir=$prefix/share/$PACKAGE/
242 pkg_xmldir=$prefix/share/$PACKAGE/xml
255 dnl This breaks for some reason RPM packaging (???)
256 dnl
257 dnl pkg_datadir=$prefix/share/$PACKAGE/
258 dnl pkg_xmldir=$prefix/share/$PACKAGE/xml
259
260 pkg_datadir=${datadir}/$PACKAGE/
261 pkg_xmldir=${datadir}/$PACKAGE/xml
243262
244263 AC_SUBST(pkg_datadir)
245264 AC_SUBST(pkg_xmldir)
0 granule (1.2.4-1) unstable; urgency=low
1
2 * New upstream release.
3
4 -- Eric Dorland <eric@debian.org> Sun, 29 Apr 2007 19:05:09 -0400
5
06 granule (1.2.3-1) unstable; urgency=medium
17
28 * New upstream release. Urgency medium to try to beat the release.
0 granule (1.2.4) unstable; urgency=low
1 * Made bg_/fg_color text settings configurable in DeckPlayer
2 (Bug #1628956).
3 * Added show/hide various controls of DeckPlayer dialog in
4 PDA version to maximize usable viewing area.
5 * Double-clicking an entry in DeckView dialog brings up
6 CardView editing dialog for the card selected.
7 * Load multiple DeckFiles at once (FR #1618817).
8 * Fixed "Answer line selector is ignored" (Bug #1618820).
9 * Changed sound command arguments to require file type extension
10 (from %s to %s.wav for wav files).
11 * Added custom Deck Appearance preferences available via
12 DeckPlayer->EditDeck->DeckInfo dialog.
13 * Added 'normalize' (remove extra newlines/whitespaces) and
14 'add index' edit shortcut buttons to CardView dialog.
15 * Took [Cancel] button out of focus chain (Feature Req #1620622).
16 * Added alternative config file command-line option with
17 { --config-file=/path/name }.
18 * Added pane separators to CardView dialog to adjust the height
19 of the multiline input fields.
20 * Added padding control for all text fields in DeckPlayer.
21 * Added (opional) two-sided sound clip playback.
22 * Changed sound playback to asynchronous.
23 * Ported to OpenEmbedded GPE PDAs (240x320 screen size) (Patch #1560198).
24 * Fixed granule.spec.in to fit FC extras strict spec rules.
25 * Added text alignment controls for Front/Back text fields.
26 * Fixed format of DeckInfo dialog and proper setting of alternative
27 sound path.
28 * Added multi-line CSV file import (Feature Request #1588158).
29
30 -- Vladislav Grinchenko <vlg@users.sourceforge.net> Sat, 13 Jan 2007 21:14:20 +0000
31
032 granule (1.2.3-1) stable; urgency=low
133
234 * Fixed multi-row selection in DeckView bug (when adding new cards).
88
99 [Default]
1010 filesel_path=
11 question_font_desc="Sans 14"
12 answer_font_desc="Sans 14"
13 example_font_desc="Sans 14"
14 input_font_desc="Sans 12"
11 question_font_desc="Sans 20"
12 answer_font_desc="Sans 18"
13 example_font_desc="Sans 16"
14 input_font_desc="Sans 14"
15 app_font_desc=Normal
16 front_x_alignment=center
17 front_y_alignment=center
18 front_justification=left
19 front_x_padding=4
20 front_y_padding=4
21 back_x_alignment=center
22 back_y_alignment=center
23 back_justification=left
24 back_x_padding=1
25 back_y_padding=1
26 example_x_alignment=left
27 example_y_alignment=top
28 example_justification=left
29 example_x_padding=4
30 example_y_padding=1
1531 mainwin_geometry=361x411
1632 cardview_geometry=396x543
1733 deckplayer_geometry=343x571
2238 snd_archive_path=/usr/share/WyabdcRealPeopleTTS/
2339 with_relative_paths=true
2440 history_size=5
25 root_x=521
26 root_y=164
41 root_x=91
42 root_y=30
2743 disable_key_shortcuts=false
44 auto_pronounce=true
2845
2946 [Scheduling]
3047 1=1/0/0/0
00 <?xml version="1.0" encoding="UTF-8"?>
11
2 <!ELEMENT deck ((author, description, sound_path), (card)*)>
2 <!ELEMENT deck ((author, description, sound_path, appearance*), (card)*)>
33 <!ELEMENT author (#PCDATA)>
44 <!ELEMENT description (#PCDATA)>
55 <!ELEMENT sound_path (#PCDATA)>
66
7 <!ELEMENT appearance (fonts, front_app, back_app, example_app)*>
8 <!ATTLIST appearance
9 enabled (yes|no) #REQUIRED>
10
11 <!ELEMENT fonts EMPTY>
12 <!ATTLIST fonts
13 question_font CDATA #REQUIRED
14 answer_font CDATA #IMPLIED
15 example_font CDATA #IMPLIED>
16
17 <!ELEMENT front_app EMPTY>
18 <!ATTLIST front_app
19 x_alignment (center|left|right) #REQUIRED
20 y_alignment (center|top|bottom) #REQUIRED
21 x_padding CDATA #REQUIRED
22 y_padding CDATA #REQUIRED
23 justification (center|left|right|fill) #REQUIRED>
24
25 <!ELEMENT back_app EMPTY>
26 <!ATTLIST back_app
27 x_alignment (center|left|right) #REQUIRED
28 y_alignment (center|top|bottom) #REQUIRED
29 x_padding CDATA #REQUIRED
30 y_padding CDATA #REQUIRED
31 justification (center|left|right|fill) #REQUIRED>
32
33 <!ELEMENT example_app EMPTY>
34 <!ATTLIST example_app
35 x_alignment (center|left|right) #REQUIRED
36 y_alignment (center|top|bottom) #REQUIRED
37 x_padding CDATA #REQUIRED
38 y_padding CDATA #REQUIRED
39 justification (center|left|right|fill) #REQUIRED>
40
741 <!ELEMENT card (front, back, back_example)>
842 <!ATTLIST card
9 id CDATA #REQUIRED
10 >
11 <!ELEMENT front (#PCDATA)>
43 id CDATA #REQUIRED>
44
45 <!ELEMENT front (#PCDATA)>
1246 <!ATTLIST front
1347 alt_spelling CDATA #IMPLIED>
14 <!ELEMENT back (#PCDATA)>
48
49 <!ELEMENT back (#PCDATA)>
50 <!ATTLIST back
51 alt_spelling CDATA #IMPLIED>
52
1553 <!ELEMENT back_example (#PCDATA)>
0 # -*- rpm-spec -*-
1 #===============================================================================
2 #
3 # GRANULE spec.in file.
4 #
5 # RPM format: name-version-release.rpm
6 #
7 # $Id: granule.spec.in,v 1.16 2005/11/13 02:50:47 vlg Exp $
8 #===============================================================================
9 %define debug_package %{nil}
0 ##
1 ## $Id: granule.spec.in,v 1.18 2006/10/23 01:14:56 vlg Exp $
2 ##
3 Summary: Flashcards program based on Leitner methodology
4 Name: granule
5 Version: 1.2.4
6 Release: 2
7 License: GPL
8 Group: Applications/Multimedia
9 URL: http://granule.sourceforge.net/
10 Source: http://dl.sf.net/sourceforge/granule/granule-%{version}.tar.gz
11 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
1012
11 %define name granule
12 %define ver 1.2.3
13
14 %define rel 1
15 %define disttag fc2
16 %define release %{rel}.%{disttag}
17
18 %define prefix /usr
19 %define datadir %{prefix}/share
20 %define localedir %{datadir}/locale
21
22 Summary: granule
23 Name: %name
24 Version: %ver
25 Release: %{release}
26 Source: %{name}-%{version}.tar.gz
27 License: GPL
28 Group: Applications
29 Packager: Vladislav Grinchenko (vlg@users.sourceforge.net)
30 Source: %{name}-%{version}.tar.gz
31 URL: http://granule.sourceforge.net/
32 Prefix: /usr
33 BuildRoot: /var/tmp/%{name}-%{version}-root
13 BuildRequires: gtkmm24-devel >= 2.4.0
14 BuildRequires: libassa-devel
15 BuildRequires: libxml2-devel
16 BuildRequires: desktop-file-utils
17 BuildRequires: gettext
18 # Only for the glib-gettextize and intltoolize hack.
19 BuildRequires: glib2-devel intltool
3420
3521 %description
3622 granule is a flashcard program that implements Leither cardfile
3723 methodology for learing new words. It features both short-term and
3824 long-term memory training capabilities with scheduling.
3925
40 #===============================================================================
41 # preparation section
42 #===============================================================================
4326
4427 %prep
45 %setup
28 %setup -q
4629
47 #===============================================================================
48 # build section
49 #===============================================================================
5030
5131 %build
52
5332 glib-gettextize --copy --force
5433 intltoolize --automake --copy --force
34 %configure
35 make %{?_smp_mflags}
5536
56 %configure
57 if [ "$SMP" != "" ]; then
58 make -j$SMP "MAKE=make -j$SMP"
59 else
60 make
61 fi
62
63 #===============================================================================
64 # install section
65 #===============================================================================
6637
6738 %install
68 if [ -d $RPM_BUILD_ROOT ]; then rm -rf $RPM_BUILD_ROOT; fi
39 rm -rf $RPM_BUILD_ROOT
6940 make DESTDIR=$RPM_BUILD_ROOT install
70
7141 %find_lang %{name} --with-gnome
7242
73 #===============================================================================
74 # clenup section
75 #===============================================================================
43 mkdir -p -m0755 ${RPM_BUILD_ROOT}%{_datadir}/granule/pixmaps
44 mkdir -p -m0755 ${RPM_BUILD_ROOT}%{_datadir}/granule/xml
45
46 install -p -m 0644 granule ${RPM_BUILD_ROOT}%{_datadir}/granule/
47 install -p -m 0644 pixmaps/*.png ${RPM_BUILD_ROOT}%{_datadir}/granule/pixmaps/
48 install -p -m 0644 *.dtd ${RPM_BUILD_ROOT}%{_datadir}/granule/xml/
49
50 desktop-file-install --vendor "" \
51 --dir ${RPM_BUILD_ROOT}%{_datadir}/applications \
52 --add-category X-Fedora \
53 %{name}.desktop
54
7655
7756 %clean
78 rm -rf $RPM_BUILD_ROOT
57 %{__rm} -rf ${RPM_BUILD_ROOT}
7958
80 #===============================================================================
81 # files that go into libassa package
82 #===============================================================================
8359
84 %files
85 %defattr(-,root,root)
60 %files -f %{name}.lang
61 %defattr(-,root,root, -)
62 %doc COPYING AUTHORS README ChangeLog NEWS
63 %{_bindir}/%{name}
64 %{_datadir}/applications/%{name}.desktop
65 %{_datadir}/pixmaps/%{name}.png
66 %{_datadir}/%{name}/
8667
87 %doc COPYING AUTHORS README ChangeLog NEWS INSTALL
88
89 %{prefix}/bin/granule
90 %{datadir}/granule/granule
91 %{datadir}/granule/pixmaps/*
92 %{datadir}/granule/xml/*
93 %{localedir}/*/*/*
94 %{datadir}/applications/granule.desktop
95 %{datadir}/pixmaps/granule.png
96
97 #===============================================================================
9868
9969 %changelog
70 * Wed Oct 18 2006 Michael Schwendt <mschwendt[AT]users.sf.net> - 1.2.3-2
71 - Fix missing BR and remaining spec issues.
72
73 * Sat Oct 14 2006 Vladislav Grinchenko <vlg@users.sourceforge.net> - 1.2.3
74 - Overall makeup to adhere to the RPM packaging guidelines.
75
10076 * Sun Nov 6 2005 Vladislav Grinchenko <vlg@users.sourceforge.net>
10177 - Fixed License tag
10278
0 # -*- rpm-spec -*-
1 #===============================================================================
2 #
3 # GRANULE spec.in file.
4 #
5 # RPM format: name-version-release.rpm
6 #
7 # $Id: granule.spec.in,v 1.16 2005/11/13 02:50:47 vlg Exp $
8 #===============================================================================
9 %define debug_package %{nil}
0 ##
1 ## $Id: granule.spec.in,v 1.18 2006/10/23 01:14:56 vlg Exp $
2 ##
3 Summary: Flashcards program based on Leitner methodology
4 Name: @PACKAGE@
5 Version: @VERSION@
6 Release: 2
7 License: GPL
8 Group: Applications/Multimedia
9 URL: http://granule.sourceforge.net/
10 Source: http://dl.sf.net/sourceforge/granule/granule-%{version}.tar.gz
11 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
1012
11 %define name @PACKAGE@
12 %define ver @VERSION@
13
14 %define rel 1
15 %define disttag fc2
16 %define release %{rel}.%{disttag}
17
18 %define prefix /usr
19 %define datadir %{prefix}/share
20 %define localedir %{datadir}/locale
21
22 Summary: granule
23 Name: %name
24 Version: %ver
25 Release: %{release}
26 Source: %{name}-%{version}.tar.gz
27 License: GPL
28 Group: Applications
29 Packager: Vladislav Grinchenko (vlg@users.sourceforge.net)
30 Source: %{name}-%{version}.tar.gz
31 URL: http://granule.sourceforge.net/
32 Prefix: /usr
33 BuildRoot: /var/tmp/%{name}-%{version}-root
13 BuildRequires: gtkmm24-devel >= 2.4.0
14 BuildRequires: libassa-devel
15 BuildRequires: libxml2-devel
16 BuildRequires: desktop-file-utils
17 BuildRequires: gettext
18 # Only for the glib-gettextize and intltoolize hack.
19 BuildRequires: glib2-devel intltool
3420
3521 %description
36 @PACKAGE@ is a flashcard program that implements Leither cardfile
22 granule is a flashcard program that implements Leither cardfile
3723 methodology for learing new words. It features both short-term and
3824 long-term memory training capabilities with scheduling.
3925
40 #===============================================================================
41 # preparation section
42 #===============================================================================
4326
4427 %prep
45 %setup
28 %setup -q
4629
47 #===============================================================================
48 # build section
49 #===============================================================================
5030
5131 %build
52
5332 glib-gettextize --copy --force
5433 intltoolize --automake --copy --force
34 %configure
35 make %{?_smp_mflags}
5536
56 %configure
57 if [ "$SMP" != "" ]; then
58 make -j$SMP "MAKE=make -j$SMP"
59 else
60 make
61 fi
62
63 #===============================================================================
64 # install section
65 #===============================================================================
6637
6738 %install
68 if [ -d $RPM_BUILD_ROOT ]; then rm -rf $RPM_BUILD_ROOT; fi
39 rm -rf $RPM_BUILD_ROOT
6940 make DESTDIR=$RPM_BUILD_ROOT install
70
7141 %find_lang %{name} --with-gnome
7242
73 #===============================================================================
74 # clenup section
75 #===============================================================================
43 mkdir -p -m0755 ${RPM_BUILD_ROOT}%{_datadir}/granule/pixmaps
44 mkdir -p -m0755 ${RPM_BUILD_ROOT}%{_datadir}/granule/xml
45
46 install -p -m 0644 granule ${RPM_BUILD_ROOT}%{_datadir}/granule/
47 install -p -m 0644 pixmaps/*.png ${RPM_BUILD_ROOT}%{_datadir}/granule/pixmaps/
48 install -p -m 0644 *.dtd ${RPM_BUILD_ROOT}%{_datadir}/granule/xml/
49
50 desktop-file-install --vendor "" \
51 --dir ${RPM_BUILD_ROOT}%{_datadir}/applications \
52 --add-category X-Fedora \
53 %{name}.desktop
54
7655
7756 %clean
78 rm -rf $RPM_BUILD_ROOT
57 %{__rm} -rf ${RPM_BUILD_ROOT}
7958
80 #===============================================================================
81 # files that go into libassa package
82 #===============================================================================
8359
84 %files
85 %defattr(-,root,root)
60 %files -f %{name}.lang
61 %defattr(-,root,root, -)
62 %doc COPYING AUTHORS README ChangeLog NEWS
63 %{_bindir}/%{name}
64 %{_datadir}/applications/%{name}.desktop
65 %{_datadir}/pixmaps/%{name}.png
66 %{_datadir}/%{name}/
8667
87 %doc COPYING AUTHORS README ChangeLog NEWS INSTALL
88
89 %{prefix}/bin/granule
90 %{datadir}/@PACKAGE@/granule
91 %{datadir}/@PACKAGE@/pixmaps/*
92 %{datadir}/@PACKAGE@/xml/*
93 %{localedir}/*/*/*
94 %{datadir}/applications/@PACKAGE@.desktop
95 %{datadir}/pixmaps/granule.png
96
97 #===============================================================================
9868
9969 %changelog
70 * Wed Oct 18 2006 Michael Schwendt <mschwendt[AT]users.sf.net> - 1.2.3-2
71 - Fix missing BR and remaining spec issues.
72
73 * Sat Oct 14 2006 Vladislav Grinchenko <vlg@users.sourceforge.net> - 1.2.3
74 - Overall makeup to adhere to the RPM packaging guidelines.
75
10076 * Sun Nov 6 2005 Vladislav Grinchenko <vlg@users.sourceforge.net>
10177 - Fixed License tag
10278
177177 USE_HILDON_FALSE = @USE_HILDON_FALSE@
178178 USE_HILDON_TRUE = @USE_HILDON_TRUE@
179179 USE_NLS = @USE_NLS@
180 USE_PDA_FALSE = @USE_PDA_FALSE@
181 USE_PDA_TRUE = @USE_PDA_TRUE@
180182 VERSION = @VERSION@
181183 WIN32_EXTRA_LIBADD = @WIN32_EXTRA_LIBADD@
182184 XGETTEXT = @XGETTEXT@
0 # $Id: Makefile.am,v 1.10 2006/06/14 02:26:48 vlg Exp $
0 # $Id: Makefile.am,v 1.12 2007/01/04 03:39:53 vlg Exp $
11 #
22 # src/pixmaps/Makefile.am
33 #
1818 sched_red.png \
1919 sched_yellow.png \
2020 speaker_24.png \
21 text_addindex.png \
2122 text_big.png \
2223 text_block.png \
2324 text_bold.png \
2930 text_italic.png \
3031 text_left.png \
3132 text_monospaced.png \
33 text_normalize.png \
3234 text_paste.png \
3335 text_remove_tags.png \
3436 text_right.png \
3739 text_superscript.png \
3840 text_underlined.png \
3941 thumbdown.png \
40 thumbup.png
42 thumbup.png \
43 show_control.png \
44 hide_control.png
4145
4246
4347 EXTRA_DIST = $(pixmap_DATA)
1313
1414 @SET_MAKE@
1515
16 # $Id: Makefile.am,v 1.10 2006/06/14 02:26:48 vlg Exp $
16 # $Id: Makefile.am,v 1.12 2007/01/04 03:39:53 vlg Exp $
1717 #
1818 # src/pixmaps/Makefile.am
1919 #
166166 USE_HILDON_FALSE = @USE_HILDON_FALSE@
167167 USE_HILDON_TRUE = @USE_HILDON_TRUE@
168168 USE_NLS = @USE_NLS@
169 USE_PDA_FALSE = @USE_PDA_FALSE@
170 USE_PDA_TRUE = @USE_PDA_TRUE@
169171 VERSION = @VERSION@
170172 WIN32_EXTRA_LIBADD = @WIN32_EXTRA_LIBADD@
171173 XGETTEXT = @XGETTEXT@
239241 sched_red.png \
240242 sched_yellow.png \
241243 speaker_24.png \
244 text_addindex.png \
242245 text_big.png \
243246 text_block.png \
244247 text_bold.png \
250253 text_italic.png \
251254 text_left.png \
252255 text_monospaced.png \
256 text_normalize.png \
253257 text_paste.png \
254258 text_remove_tags.png \
255259 text_right.png \
258262 text_superscript.png \
259263 text_underlined.png \
260264 thumbdown.png \
261 thumbup.png
265 thumbup.png \
266 show_control.png \
267 hide_control.png
262268
263269 EXTRA_DIST = $(pixmap_DATA)
264270 all: all-am
Binary diff not shown
Binary diff not shown
Binary diff not shown
Binary diff not shown
+0
-1
po/LINGUAS less more
0 bg de_DE en_GB ja_JP ru
00 // -*- c++ -*-
11 // generated by glade--
22 //------------------------------------------------------------------------------
3 // $Id: AboutGRAPP.cpp,v 1.9 2006/08/30 12:22:35 vlg Exp $
3 // $Id: AboutGRAPP.cpp,v 1.13 2007/01/14 02:59:57 vlg Exp $
44 //------------------------------------------------------------------------------
55 // AboutGRAPP.cpp
66 //------------------------------------------------------------------------------
1919 #include <gtkmm/image.h>
2020 #include <gtkmm/label.h>
2121 #include <gtkmm/alignment.h>
22 #include <gtkmm/scrolledwindow.h>
2223
2324 #ifdef HAVE_CONFIG_H
2425 # include "config.h"
2526 #endif
2627
2728 #include "AboutGRAPP.h"
29
30 #ifdef IS_PDA
31 static const int AG_PADDING = 0;
32 #else
33 static const int AG_PADDING = 20;
34 #endif
2835
2936 AboutGRAPP::
3037 AboutGRAPP () :
3845
3946 Gtk::Label* label;
4047
41 Gtk::Alignment* align = manage (new Gtk::Alignment (0.5, 0.2, 0, 0));
42 get_vbox ()->pack_start (*align);
43 align->set_border_width (20);
48 Gtk::Alignment* align;
4449
45 Gtk::VBox* contents = manage (new Gtk::VBox (false, 20));
50 align = manage (new Gtk::Alignment (0.5, 0.2, 0, 0));
51 align->set_border_width (AG_PADDING);
52
53 Gtk::VBox* contents = manage (new Gtk::VBox (false, AG_PADDING));
4654 align->add (*contents);
4755
4856 /** HBox holds Icon image and package name
6371 /** Label is the rest of it
6472 */
6573 Glib::ustring info_msg ("\nThe Flashcard Program.\n");
66 info_msg += "Copyright (C) 2004-2006 Vladislav Grinchenko\n";
74 info_msg += "Vladislav Grinchenko\n Copyright (C) 2004-2007\n";
6775 label = manage (new Gtk::Label (info_msg));
6876
6977 contents->pack_start (*label);
7886 close_b->signal_clicked ().connect (
7987 sigc::mem_fun (*this, &AboutGRAPP::on_close_clicked));
8088
89 #if defined(IS_HILDON) || defined(IS_PDA)
90 Gtk::ScrolledWindow* scrollw = Gtk::manage (new Gtk::ScrolledWindow);
91 scrollw->set_flags (Gtk::CAN_FOCUS);
92 scrollw->set_shadow_type (Gtk::SHADOW_NONE);
93 scrollw->set_policy (Gtk::POLICY_AUTOMATIC , Gtk::POLICY_AUTOMATIC);
94 scrollw->property_window_placement ().set_value (Gtk::CORNER_TOP_LEFT);
95
96 scrollw->add (*align);
97 get_vbox ()->pack_start (*scrollw);
98
99 #ifdef IS_PDA
100 set_resizable (false);
101 Gdk::Geometry dp_geometry = { 240, 320, 240, 320, 240, 320,-1, -1, -1, -1};
102 set_geometry_hints (*this, dp_geometry,
103 Gdk::HINT_MIN_SIZE | Gdk::HINT_MAX_SIZE | Gdk::HINT_BASE_SIZE);
104 #endif
105
106 #ifdef IS_HILDON
107 Gdk::Geometry dp_geometry = { 640, 480, 640, 480, 640, 480, -1, -1, -1, -1};
108 set_geometry_hints (*this, dp_geometry,
109 Gdk::HINT_MIN_SIZE | Gdk::HINT_MAX_SIZE | Gdk::HINT_BASE_SIZE);
110 #endif
111
112 #else /* Desktop */
113 get_vbox ()->pack_start (*align);
114 #endif
115
81116 show_all_children ();
82117 }
83118
00 // -*- c++ -*-
11 // generated by glade--
22 //------------------------------------------------------------------------------
3 // $Id: AppearancePrefs.cpp,v 1.1 2006/09/03 19:26:35 vlg Exp $
3 // $Id: AppearancePrefs.cpp,v 1.7 2006/12/18 03:33:14 vlg Exp $
44 //------------------------------------------------------------------------------
55 // AppearancePrefs.cpp
66 //------------------------------------------------------------------------------
2525 #include "GrappConf.h"
2626 #include "PrefWindow.h"
2727 #include "AppearancePrefs.h"
28 #include "TextAlignment.h"
2829
2930 #include "Intern.h" // i18n macros
3031
3132 using sigc::mem_fun;
3233 using sigc::bind;
3334
35 //------------------------------------------------------------------------------
3436 static const char* flabels[] = {
3537 _("Question font: "),
3638 _("Answer font: "),
4244 enum { QFONT, AFONT, EFONT, IFONT, PFONT };
4345
4446 #define SET_FONTS_FRAME(f,l,w) \
47 f->set_border_width (4); \
4548 f->set_shadow_type (Gtk::SHADOW_ETCHED_IN); \
46 f->set_border_width (4); \
4749 f->set_label_align (Gtk::ALIGN_TOP, Gtk::ALIGN_CENTER); \
4850 f->set_label_widget (*l); \
49 f->add (*w);
51 f->add (*w);
5052
5153 #define SET_FONTS_LABEL(l) \
5254 l->set_padding (0,0); \
6769 trace_with_mask("AppearancePrefs::AppearancePrefs",GUITRACE);
6870
6971 int i;
72
73 #if defined(IS_HILDON) || defined(IS_PDA)
74 set_border_width(0);
75 #else
7076 set_border_width(14);
77 #endif
7178
7279 m_font_table = Gtk::manage (new Gtk::Table (FONT_ENTRY_SZ, 3, false));
7380
132139 SET_FONTS_FRAME (fonts_frame, fonts_label, m_font_table);
133140
134141 scrollw_vbox->pack_start (*fonts_frame, Gtk::PACK_SHRINK, 4);
142
143 /** Text Alignment Widget
144 */
145 m_text_alignment = Gtk::manage (new TextAlignment (pwin_));
146
147 scrollw_vbox->pack_start (*m_text_alignment, Gtk::PACK_SHRINK, 4);
148
149 /** Add ScrollWindow
150 */
135151 scrollw->add (*scrollw_vbox);
136152 pack_start (*scrollw);
137153
166182 m_fentry [EFONT].m_entry->set_text(CONFIG->get_example_font ().to_string());
167183 m_fentry [IFONT].m_entry->set_text(CONFIG->get_input_font ().to_string());
168184 m_fentry [PFONT].m_entry->set_text(CONFIG->get_app_font ().to_string());
185
186 m_text_alignment->set_x_alignment (FRONT, CONFIG->x_alignment (FRONT));
187 m_text_alignment->set_y_alignment (FRONT, CONFIG->y_alignment (FRONT));
188 m_text_alignment->set_x_padding (FRONT, CONFIG->x_padding (FRONT));
189 m_text_alignment->set_y_padding (FRONT, CONFIG->y_padding (FRONT));
190 m_text_alignment->set_justification (FRONT, CONFIG->justification (FRONT));
191
192 m_text_alignment->set_x_alignment (BACK, CONFIG->x_alignment (BACK));
193 m_text_alignment->set_y_alignment (BACK, CONFIG->y_alignment (BACK));
194 m_text_alignment->set_x_padding (BACK, CONFIG->x_padding (BACK));
195 m_text_alignment->set_y_padding (BACK, CONFIG->y_padding (BACK));
196 m_text_alignment->set_justification (BACK, CONFIG->justification (BACK));
197
198 m_text_alignment->set_x_alignment (EXAMPLE, CONFIG->x_alignment (EXAMPLE));
199 m_text_alignment->set_y_alignment (EXAMPLE, CONFIG->y_alignment (EXAMPLE));
200 m_text_alignment->set_x_padding (EXAMPLE, CONFIG->x_padding (EXAMPLE));
201 m_text_alignment->set_y_padding (EXAMPLE, CONFIG->y_padding (EXAMPLE));
202 m_text_alignment->set_justification(EXAMPLE,CONFIG->justification(EXAMPLE));
169203 }
170204
171205 void
179213 CONFIG->set_example_font (m_fentry [EFONT].m_entry->get_text ());
180214 CONFIG->set_input_font (m_fentry [IFONT].m_entry->get_text ());
181215 CONFIG->set_app_font (m_fentry [PFONT].m_entry->get_text ());
216
217 CONFIG->x_alignment (FRONT, m_text_alignment->get_x_alignment (FRONT));
218 CONFIG->y_alignment (FRONT, m_text_alignment->get_y_alignment (FRONT));
219 CONFIG->x_padding (FRONT, m_text_alignment->get_x_padding (FRONT));
220 CONFIG->y_padding (FRONT, m_text_alignment->get_y_padding (FRONT));
221 CONFIG->justification (FRONT, m_text_alignment->get_justification (FRONT));
222
223 CONFIG->x_alignment (BACK, m_text_alignment->get_x_alignment (BACK));
224 CONFIG->y_alignment (BACK, m_text_alignment->get_y_alignment (BACK));
225 CONFIG->x_padding (BACK, m_text_alignment->get_x_padding (BACK));
226 CONFIG->y_padding (BACK, m_text_alignment->get_y_padding (BACK));
227 CONFIG->justification (BACK, m_text_alignment->get_justification (BACK));
228
229 CONFIG->x_alignment (EXAMPLE, m_text_alignment->get_x_alignment (EXAMPLE));
230 CONFIG->y_alignment (EXAMPLE, m_text_alignment->get_y_alignment (EXAMPLE));
231 CONFIG->x_padding (EXAMPLE, m_text_alignment->get_x_padding (EXAMPLE));
232 CONFIG->y_padding (EXAMPLE, m_text_alignment->get_y_padding (EXAMPLE));
233 CONFIG->justification(EXAMPLE,m_text_alignment->get_justification(EXAMPLE));
182234 }
183235
184236 void
00 // -*- c++ -*-
11 //------------------------------------------------------------------------------
2 // $Id: AppearancePrefs.h,v 1.1 2006/09/03 19:26:35 vlg Exp $
2 // $Id: AppearancePrefs.h,v 1.2 2006/10/29 12:51:02 vlg Exp $
33 //------------------------------------------------------------------------------
44 // AppearancePrefs.h
55 //------------------------------------------------------------------------------
2727 #include <gtkmm/fontselection.h>
2828
2929 class PrefWindow;
30 class TextAlignment;
3031
3132 /**-----------------------------------------------------------------------------
3233 Compound Font Entry
6566
6667 FontEntry m_fentry [FONT_ENTRY_SZ];
6768 Gtk::Table* m_font_table;
69
70 TextAlignment* m_text_alignment;
6871 };
6972
7073 /**-----------------------------------------------------------------------------
0 // -*- c++ -*-
1 //------------------------------------------------------------------------------
2 // CSVExportDialog.cpp
3 //------------------------------------------------------------------------------
4 // $Id: CSVExportDialog.cpp,v 1.1 2006/11/13 01:05:14 vlg Exp $
5 //------------------------------------------------------------------------------
6 // Copyright (c) 2006 by Vladislav Grinchenko
7 //
8 // This program is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU General Public License
10 // as published by the Free Software Foundation; either version
11 // 2 of the License, or (at your option) any later version.
12 //------------------------------------------------------------------------------
13 // 11/12/2006 VLG Created
14 //------------------------------------------------------------------------------
15 #include <gdk/gdkkeysyms.h>
16 #include <gtkmm/accelgroup.h>
17 #include <gtkmm/image.h>
18 #include <gtkmm/label.h>
19 #include <gtkmm/box.h>
20 #include <gtkmm/alignment.h>
21 #include <gtkmm/buttonbox.h>
22 #include <gtkmm/frame.h>
23 #include <gtkmm/table.h>
24
25 #include "CSVExportDialog.h"
26 #include "Intern.h"
27
28 CSVExportDialog::
29 CSVExportDialog() :
30 m_sep_selection (SPACE_SEP),
31 m_recursive_call (false)
32 {
33 CSVExportDialog* dialog = this;
34
35 Gtk::Image* image1;
36 Gtk::Label* label4;
37 Gtk::HBox* hbox3;
38 Gtk::Alignment* alignment1;
39 Gtk::Image* image2;
40 Gtk::Label* label5;
41 Gtk::HBox* hbox4;
42 Gtk::Alignment* alignment2;
43 Gtk::Label* linebrk_label;
44 Gtk::HBox* linebrk_hbox;
45 Gtk::Label* lb_frame_label;
46 Gtk::Frame* linebrk_frame;
47 Gtk::Table* sep_table;
48 Gtk::VBox* sep_vbox;
49 Gtk::Label* sep_frame_label;
50 Gtk::Frame* m_sep_frame;
51 Gtk::VBox* extra_vbox;
52
53
54 image1 = Gtk::manage (new Gtk::Image(Gtk::StockID("gtk-cancel"),
55 Gtk::IconSize(4)));
56 label4 = Gtk::manage (new Gtk::Label(_("Cancel")));
57 hbox3 = Gtk::manage (new Gtk::HBox(false, 2));
58 alignment1 = Gtk::manage (new Gtk::Alignment(0.5, 0.5, 0, 0));
59 m_cancel_button = Gtk::manage (new Gtk::Button());
60
61 image2 = Gtk::manage (new Gtk::Image(Gtk::StockID("gtk-apply"),
62 Gtk::IconSize(4)));
63 label5 = Gtk::manage (new Gtk::Label(_("Export")));
64 hbox4 = Gtk::manage (new Gtk::HBox(false, 2));
65 alignment2 = Gtk::manage (new Gtk::Alignment(0.5, 0.5, 0, 0));
66 m_import_button = Gtk::manage (new Gtk::Button());
67
68 linebrk_label = Gtk::manage (new Gtk::Label(_("Line Break:")));
69 m_unix_lf = Gtk::manage (new Gtk::CheckButton(_("UNIX (LF)")));
70 m_windoz_crlf = Gtk::manage (new Gtk::CheckButton(_("Windows (CR+LF)")));
71
72 linebrk_hbox = Gtk::manage (new Gtk::HBox(false, 15));
73 lb_frame_label = Gtk::manage (new Gtk::Label(_("")));
74 linebrk_frame = Gtk::manage (new Gtk::Frame());
75 m_space_sep = Gtk::manage (new Gtk::CheckButton(_("Space")));
76 m_tab_sep = Gtk::manage (new Gtk::CheckButton(_("Tab")));
77 m_semicolon_sep = Gtk::manage (new Gtk::CheckButton(_("Semicolon (;)")));
78 m_colon_sep = Gtk::manage (new Gtk::CheckButton(_("Colon (:)")));
79
80 m_comma_sep = Gtk::manage (new Gtk::CheckButton(_("Comma (,)")));
81
82 sep_table = Gtk::manage (new Gtk::Table(2, 3, true));
83 sep_vbox = Gtk::manage (new Gtk::VBox(false, 0));
84 sep_frame_label = Gtk::manage (new Gtk::Label(_("Select Fields")));
85 m_sep_frame = Gtk::manage (new Gtk::Frame());
86 m_with_example = Gtk::manage (new Gtk::CheckButton(
87 _("include Example field")));
88
89 extra_vbox = Gtk::manage (new Gtk::VBox(false, 0));
90
91 image1->set_alignment(0.5,0.5);
92 image1->set_padding(0,0);
93 label4->set_alignment(0.5,0.5);
94 label4->set_padding(0,0);
95 label4->set_justify(Gtk::JUSTIFY_LEFT);
96 label4->set_line_wrap(false);
97 label4->set_use_markup(false);
98 label4->set_selectable(false);
99 hbox3->pack_start(*image1, Gtk::PACK_SHRINK, 0);
100 hbox3->pack_start(*label4, Gtk::PACK_SHRINK, 0);
101 alignment1->add(*hbox3);
102 m_cancel_button->set_flags(Gtk::CAN_FOCUS);
103 m_cancel_button->set_relief(Gtk::RELIEF_NORMAL);
104 m_cancel_button->add(*alignment1);
105
106 image2->set_alignment(0.5,0.5);
107 image2->set_padding(0,0);
108 label5->set_alignment(0.5,0.5);
109 label5->set_padding(0,0);
110 label5->set_justify(Gtk::JUSTIFY_LEFT);
111 label5->set_line_wrap(false);
112 label5->set_use_markup(false);
113 label5->set_selectable(false);
114 hbox4->pack_start(*image2, Gtk::PACK_SHRINK, 0);
115 hbox4->pack_start(*label5, Gtk::PACK_SHRINK, 0);
116 alignment2->add(*hbox4);
117 m_import_button->set_flags(Gtk::CAN_FOCUS);
118 m_import_button->set_relief(Gtk::RELIEF_NORMAL);
119 m_import_button->add(*alignment2);
120 dialog->get_action_area()->property_layout_style().set_value(Gtk::BUTTONBOX_END);
121 linebrk_label->set_alignment(0.5,0.5);
122 linebrk_label->set_padding(18,0);
123 linebrk_label->set_justify(Gtk::JUSTIFY_LEFT);
124 linebrk_label->set_line_wrap(false);
125 linebrk_label->set_use_markup(false);
126 linebrk_label->set_selectable(false);
127 m_unix_lf->set_flags(Gtk::CAN_FOCUS);
128 m_unix_lf->set_border_width(5);
129 m_unix_lf->set_relief(Gtk::RELIEF_NORMAL);
130 m_unix_lf->set_mode(true);
131 m_unix_lf->set_active(true);
132 m_windoz_crlf->set_flags(Gtk::CAN_FOCUS);
133 m_windoz_crlf->set_border_width(5);
134 m_windoz_crlf->set_relief(Gtk::RELIEF_NORMAL);
135 m_windoz_crlf->set_mode(true);
136 m_windoz_crlf->set_active(false);
137 linebrk_hbox->set_border_width(2);
138 linebrk_hbox->pack_start(*linebrk_label, Gtk::PACK_SHRINK, 0);
139 linebrk_hbox->pack_start(*m_unix_lf, Gtk::PACK_SHRINK, 0);
140 linebrk_hbox->pack_start(*m_windoz_crlf, Gtk::PACK_SHRINK, 0);
141 lb_frame_label->set_alignment(0.5,0.5);
142 lb_frame_label->set_padding(0,0);
143 lb_frame_label->set_justify(Gtk::JUSTIFY_LEFT);
144 lb_frame_label->set_line_wrap(false);
145 lb_frame_label->set_use_markup(false);
146 lb_frame_label->set_selectable(false);
147 linebrk_frame->set_border_width(4);
148 linebrk_frame->set_shadow_type(Gtk::SHADOW_ETCHED_IN);
149 linebrk_frame->set_label_align(0,0.5);
150 linebrk_frame->add(*linebrk_hbox);
151 linebrk_frame->set_label_widget(*lb_frame_label);
152 m_space_sep->set_flags(Gtk::CAN_FOCUS);
153 m_space_sep->set_relief(Gtk::RELIEF_NORMAL);
154 m_space_sep->set_mode(true);
155 m_space_sep->set_active(true);
156 m_tab_sep->set_flags(Gtk::CAN_FOCUS);
157 m_tab_sep->set_relief(Gtk::RELIEF_NORMAL);
158 m_tab_sep->set_mode(true);
159 m_tab_sep->set_active(false);
160 m_semicolon_sep->set_flags(Gtk::CAN_FOCUS);
161 m_semicolon_sep->set_relief(Gtk::RELIEF_NORMAL);
162 m_semicolon_sep->set_mode(true);
163 m_semicolon_sep->set_active(false);
164 m_colon_sep->set_flags(Gtk::CAN_FOCUS);
165 m_colon_sep->set_relief(Gtk::RELIEF_NORMAL);
166 m_colon_sep->set_mode(true);
167 m_colon_sep->set_active(false);
168 m_comma_sep->set_flags(Gtk::CAN_FOCUS);
169 m_comma_sep->set_relief(Gtk::RELIEF_NORMAL);
170 m_comma_sep->set_mode(true);
171 m_comma_sep->set_active(false);
172
173 sep_table->set_row_spacings(4);
174 sep_table->set_col_spacings(4);
175
176 sep_table->attach(*m_space_sep,0,1,0,1,
177 Gtk::FILL,Gtk::AttachOptions (), 0,0);
178 sep_table->attach(*m_tab_sep, 1,2,0,1,
179 Gtk::FILL, Gtk::AttachOptions (), 0,0);
180 sep_table->attach(*m_semicolon_sep, 2,3,0,1,
181 Gtk::FILL, Gtk::AttachOptions (), 0,0);
182 sep_table->attach(*m_colon_sep,0,1,1,2,Gtk::FILL,
183 Gtk::AttachOptions (), 0,0);
184 sep_table->attach(*m_comma_sep,1,2,1,2,Gtk::FILL,
185 Gtk::AttachOptions (), 0,0);
186
187 sep_vbox->set_border_width(2);
188 sep_vbox->pack_start(*sep_table, Gtk::PACK_SHRINK, 3);
189 sep_frame_label->set_alignment(0.5,0.5);
190 sep_frame_label->set_padding(0,0);
191 sep_frame_label->set_justify(Gtk::JUSTIFY_LEFT);
192 sep_frame_label->set_line_wrap(false);
193 sep_frame_label->set_use_markup(false);
194 sep_frame_label->set_selectable(false);
195 m_sep_frame->set_border_width(3);
196 m_sep_frame->set_shadow_type(Gtk::SHADOW_ETCHED_IN);
197 m_sep_frame->set_label_align(0,0.5);
198 m_sep_frame->add(*sep_vbox);
199 m_sep_frame->set_label_widget(*sep_frame_label);
200 m_with_example->set_flags(Gtk::CAN_FOCUS);
201 m_with_example->set_border_width(4);
202 m_with_example->set_relief(Gtk::RELIEF_NORMAL);
203 m_with_example->set_mode(true);
204 m_with_example->set_active(false);
205 extra_vbox->set_border_width(2);
206 extra_vbox->pack_start(*m_with_example, Gtk::PACK_SHRINK, 0);
207 dialog->get_vbox()->set_homogeneous(false);
208 dialog->get_vbox()->set_spacing(0);
209 dialog->get_vbox()->pack_start(*linebrk_frame, Gtk::PACK_SHRINK, 0);
210 dialog->get_vbox()->pack_start(*m_sep_frame, Gtk::PACK_SHRINK, 0);
211 dialog->get_vbox()->pack_start(*extra_vbox, Gtk::PACK_SHRINK, 0);
212 dialog->set_border_width(1);
213 dialog->set_title(_("CSV Text Import"));
214 dialog->set_modal(true);
215 dialog->property_window_position().set_value(Gtk::WIN_POS_CENTER_ON_PARENT);
216 dialog->set_resizable(true);
217 dialog->property_destroy_with_parent().set_value(false);
218 dialog->set_has_separator(true);
219 dialog->add_action_widget(*m_cancel_button, Gtk::RESPONSE_CANCEL);
220 dialog->add_action_widget(*m_import_button, Gtk::RESPONSE_APPLY);
221
222 m_unix_lf->signal_toggled().connect (
223 mem_fun (*this, &CSVExportDialog::on_unix_lf_checked));
224 m_windoz_crlf->signal_toggled().connect (
225 mem_fun (*this, &CSVExportDialog::on_windoz_crlf_checked));
226
227 m_space_sep->signal_toggled().connect (
228 mem_fun (*this, &CSVExportDialog::on_space_sep_checked));
229 m_tab_sep->signal_toggled().connect (
230 mem_fun (*this, &CSVExportDialog::on_tab_sep_checked));
231 m_colon_sep->signal_toggled().connect (
232 mem_fun (*this, &CSVExportDialog::on_colon_sep_checked));
233 m_semicolon_sep->signal_toggled().connect (
234 mem_fun (*this, &CSVExportDialog::on_semicolon_sep_checked));
235 m_comma_sep->signal_toggled().connect (
236 mem_fun (*this, &CSVExportDialog::on_comma_sep_checked));
237
238 dialog->show_all ();
239 }
240
241 void
242 CSVExportDialog::
243 on_unix_lf_checked ()
244 {
245 trace_with_mask("CSVExportDialog::on_unix_lf_checked",GUITRACE);
246
247 if (!m_recursive_call) {
248 m_recursive_call = true;
249 m_windoz_crlf->set_active (false);
250 m_recursive_call = false;
251 }
252 }
253
254 void
255 CSVExportDialog::
256 on_windoz_crlf_checked ()
257 {
258 trace_with_mask("CSVExportDialog::on_windoz_crlf_checked",GUITRACE);
259
260 if (!m_recursive_call) {
261 m_recursive_call = true;
262 m_unix_lf->set_active (false);
263 m_recursive_call = false;
264 }
265 }
266
267 void
268 CSVExportDialog::
269 on_space_sep_checked ()
270 {
271 trace_with_mask("CSVExportDialog::on_space_sep_checked",GUITRACE);
272
273 if (!m_recursive_call) {
274 m_recursive_call = true;
275 m_tab_sep ->set_active (false);
276 m_colon_sep ->set_active (false);
277 m_semicolon_sep ->set_active (false);
278 m_comma_sep ->set_active (false);
279 m_sep_selection = SPACE_SEP;
280 m_recursive_call = false;
281 }
282 }
283
284 void
285 CSVExportDialog::
286 on_tab_sep_checked ()
287 {
288 trace_with_mask("CSVExportDialog::on_tab_sep_checked",GUITRACE);
289
290 if (!m_recursive_call) {
291 m_recursive_call = true;
292 m_space_sep ->set_active (false);
293 m_colon_sep ->set_active (false);
294 m_semicolon_sep ->set_active (false);
295 m_comma_sep ->set_active (false);
296 m_sep_selection = TAB_SEP;
297 m_recursive_call = false;
298 }
299 }
300
301 void
302 CSVExportDialog::
303 on_colon_sep_checked ()
304 {
305 trace_with_mask("CSVExportDialog::on_colon_sep_checked",GUITRACE);
306
307 if (!m_recursive_call) {
308 m_recursive_call = true;
309 m_space_sep ->set_active (false);
310 m_tab_sep ->set_active (false);
311 m_semicolon_sep ->set_active (false);
312 m_comma_sep ->set_active (false);
313 m_sep_selection = COLON_SEP;
314 m_recursive_call = false;
315 }
316 }
317
318 void
319 CSVExportDialog::
320 on_semicolon_sep_checked ()
321 {
322 trace_with_mask("CSVExportDialog::on_semicolon_sep_checked",GUITRACE);
323
324 if (!m_recursive_call) {
325 m_recursive_call = true;
326 m_space_sep ->set_active (false);
327 m_tab_sep ->set_active (false);
328 m_colon_sep ->set_active (false);
329 m_comma_sep ->set_active (false);
330 m_sep_selection = SEMICOLON_SEP;
331 m_recursive_call = false;
332 }
333 }
334
335 void
336 CSVExportDialog::
337 on_comma_sep_checked ()
338 {
339 trace_with_mask("CSVExportDialog::",GUITRACE);
340
341 if (!m_recursive_call) {
342 m_recursive_call = true;
343 m_space_sep ->set_active (false);
344 m_tab_sep ->set_active (false);
345 m_colon_sep ->set_active (false);
346 m_semicolon_sep ->set_active (false);
347
348 m_sep_selection = COMMA_SEP;
349 m_recursive_call = false;
350 }
351 }
352
353 const char*
354 CSVExportDialog::
355 get_separator () const
356 {
357 char* ret = "";
358
359 switch (m_sep_selection)
360 {
361 case SPACE_SEP: ret = " "; break;
362 case TAB_SEP: ret = "\t"; break;
363 case COLON_SEP: ret = ":"; break;
364 case SEMICOLON_SEP: ret = ";"; break;
365 case COMMA_SEP: ret = ","; break;
366 }
367 return ret;
368 }
369
370 const char*
371 CSVExportDialog::
372 get_double_separator () const
373 {
374 char* ret = "";
375
376 switch (m_sep_selection)
377 {
378 case SPACE_SEP: ret = " "; break;
379 case TAB_SEP: ret = "\t\t"; break;
380 case COLON_SEP: ret = "::"; break;
381 case SEMICOLON_SEP: ret = ";;"; break;
382 case COMMA_SEP: ret = ",,"; break;
383 }
384 return ret;
385 }
0 // -*- c++ -*-
1 //------------------------------------------------------------------------------
2 // CSVExportDialog.h
3 //------------------------------------------------------------------------------
4 // $Id: CSVExportDialog.h,v 1.1 2006/11/13 01:05:14 vlg Exp $
5 //------------------------------------------------------------------------------
6 // Copyright (c) 2006 by Vladislav Grinchenko
7 //
8 // This program is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU General Public License
10 // as published by the Free Software Foundation; either version
11 // 2 of the License, or (at your option) any later version.
12 //------------------------------------------------------------------------------
13 // 11/12/2006 VLG Created
14 //------------------------------------------------------------------------------
15 #ifndef CSV_EXPORT_DIALOG_H
16 #define CSV_EXPORT_DIALOG_H
17
18 #include <gtkmm/dialog.h>
19 #include <gtkmm/button.h>
20 #include <gtkmm/checkbutton.h>
21
22 #include "Granule-main.h"
23
24 class CSVExportDialog : public Gtk::Dialog
25 {
26 public:
27 CSVExportDialog();
28
29 /// Do we break on LF or CR+LF?
30 bool is_windoz_linebreak () const {
31 return m_windoz_crlf->get_active ();
32 }
33
34 /// Return separator selected
35 const char* get_separator () const;
36
37 /// Return double separator
38 const char* get_double_separator () const;
39
40 /** If true, then replace each pair of adjacent separators with one.
41 */
42 bool with_example () const {
43 return m_with_example->get_active ();
44 }
45
46 /** callbacks
47 */
48 void on_unix_lf_checked ();
49 void on_windoz_crlf_checked ();
50
51 void on_space_sep_checked ();
52 void on_tab_sep_checked ();
53 void on_colon_sep_checked ();
54 void on_semicolon_sep_checked ();
55 void on_comma_sep_checked ();
56
57 private:
58 Gtk::Button* m_cancel_button;
59 Gtk::Button* m_import_button;
60
61 Gtk::CheckButton* m_unix_lf;
62 Gtk::CheckButton* m_windoz_crlf;
63
64 Gtk::CheckButton* m_space_sep;
65 Gtk::CheckButton* m_tab_sep;
66 Gtk::CheckButton* m_colon_sep;
67 Gtk::CheckButton* m_semicolon_sep;
68 Gtk::CheckButton* m_comma_sep;
69 Gtk::CheckButton* m_with_example;
70
71 CSVSeparator m_sep_selection;
72 bool m_recursive_call;
73 };
74
75 #endif
11 //------------------------------------------------------------------------------
22 // CSVImportDialog.cpp
33 //------------------------------------------------------------------------------
4 // $Id: CSVImportDialog.cpp,v 1.2 2006/09/21 01:25:20 vlg Exp $
5 //------------------------------------------------------------------------------
6 // Copyright (c) 2005 by Vladislav Grinchenko
4 // $Id: CSVImportDialog.cpp,v 1.3 2006/11/10 03:47:42 vlg Exp $
5 //------------------------------------------------------------------------------
6 // Copyright (c) 2005-2006 by Vladislav Grinchenko
77 //
88 // This program is free software; you can redistribute it and/or
99 // modify it under the terms of the GNU General Public License
11 //------------------------------------------------------------------------------
22 // Card.h
33 //------------------------------------------------------------------------------
4 // $Id: Card.h,v 1.10 2006/09/06 02:07:59 vlg Exp $
4 // $Id: Card.h,v 1.11 2006/12/18 03:33:14 vlg Exp $
55 //
66 // Date: Jan 8, 2004
77 //------------------------------------------------------------------------------
1919 virtual void set_question (const ustring& q_);
2020 virtual void set_answer (const ustring& a_);
2121 virtual void set_example (const ustring& e_);
22 virtual void set_alt_spelling (const ustring& a_);
22 virtual void set_alt_spelling (SideSelection side_, const ustring& a_);
2323
2424 void set_id (long id_);
2525
2626 virtual ustring get_question () const { return m_question; }
2727 virtual ustring get_answer () const { return m_answer; }
2828 virtual ustring get_example () const { return m_example; }
29 virtual ustring get_alt_spelling () const { return m_alt_spelling; }
29 virtual ustring get_alt_spelling (SideSelection side_) const;
3030 virtual long get_id () const { return m_id; }
3131
3232 virtual void dump () const;
3636 virtual bool equal_expiration (const VCard& rhs_) { return true; }
3737
3838 private:
39 long m_id;
40 ustring m_question;
41 ustring m_answer;
42 ustring m_example;
43 ustring m_alt_spelling;
39 long m_id;
40 ustring m_question;
41 ustring m_answer;
42 ustring m_example;
43 ustring m_front_alt_spelling;
44 ustring m_back_alt_spelling;
4445 };
46
47 inline ustring
48 Card::get_alt_spelling (SideSelection side_) const
49 {
50 trace_with_mask("Card::get_alt_spelling",GUITRACE);
51
52 ustring ret;
53 if (side_ == FRONT) {
54 DL ((GRAPP,"Return front.alt.spell = %s\n",
55 m_front_alt_spelling.c_str ()));
56 ret = m_front_alt_spelling;
57 }
58 else {
59 DL ((GRAPP,"Return back.alt.spell = %s\n",
60 m_back_alt_spelling.c_str ()));
61 ret = m_back_alt_spelling;
62 }
63 return ret;
64
65 #ifdef BLOCK
66 return (side_ == FRONT ? m_front_alt_spelling : m_back_alt_spelling);
67 #endif
68 }
69
70 inline void
71 Card::set_alt_spelling (SideSelection side_, const ustring& a_)
72 {
73 // trace_with_mask("Card::set_alt_spelling",GUITRACE);
74
75 if (side_ == FRONT) {
76 DL ((GRAPP,"Set front.alt.spell = %s\n", a_.c_str ()));
77 m_front_alt_spelling = a_;
78 }
79 else {
80 DL ((GRAPP,"Set back.alt.spell = %s\n", a_.c_str ()));
81 m_back_alt_spelling = a_;
82 }
83 mark_dirty ();
84 }
4585
4686 inline void
4787 Card::set_question (const ustring& q_)
65105 }
66106
67107 inline void
68 Card::set_alt_spelling (const ustring& a_)
69 {
70 m_alt_spelling = a_;
71 mark_dirty ();
72 }
73
74 inline void
75108 Card::set_id (long id_)
76109 {
77110 m_id = id_;
00 // -*- c++ -*-
11 //------------------------------------------------------------------------------
2 // $Id: CardBox.cpp,v 1.58 2006/10/06 02:04:47 vlg Exp $
2 // $Id: CardBox.cpp,v 1.64 2007/01/14 02:00:12 vlg Exp $
33 //------------------------------------------------------------------------------
44 // CardBox.cpp
55 //------------------------------------------------------------------------------
240240 * CardBox class methods
241241 *------------------------------------------------------------------------------
242242 */
243 #if defined(IS_PDA) && (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION >= 6)
244 # define CB_SHRINK_ICONS ,34,39,false
245 #else
246 # define CB_SHRINK_ICONS
247 #endif
248
243249 CardBox::
244250 CardBox ()
245251 {
252258 m_cdplayers [i] = NULL;
253259 }
254260
255 m_drawer_empty =
256 Gdk::Pixbuf::create_from_file(find_pixmap_path ("drawer_empty.png"));
257
258 DL ((GRAPP,"Success on first icon\n"));
259
260 m_drawer_one =
261 Gdk::Pixbuf::create_from_file(find_pixmap_path ("drawer_one.png"));
262 DL ((GRAPP,"second icon ok\n"));
263
264 m_drawer_many =
265 Gdk::Pixbuf::create_from_file(find_pixmap_path ("drawer_many.png"));
266 DL ((GRAPP,"third icon ok\n"));
261 m_drawer_empty = Gdk::Pixbuf::create_from_file(
262 find_pixmap_path ("drawer_empty.png") CB_SHRINK_ICONS);
263 m_drawer_one = Gdk::Pixbuf::create_from_file(
264 find_pixmap_path ("drawer_one.png") CB_SHRINK_ICONS);
265 m_drawer_many = Gdk::Pixbuf::create_from_file(
266 find_pixmap_path ("drawer_many.png") CB_SHRINK_ICONS);
267267
268268 m_sched_green =
269269 Gdk::Pixbuf::create_from_file(find_pixmap_path ("sched_green.png"));
274274 m_sched_yellow =
275275 Gdk::Pixbuf::create_from_file(find_pixmap_path ("sched_yellow.png"));
276276
277 DL ((GRAPP,"last icon ok\n"));
278
279277 for (i = 0; i < CARD_BOX_SIZE; i++) {
280278 m_cbs.push_back (CardBoxIF ());
281279 m_cbs [i].m_sched_light = manage (new Gtk::Image);
308306 m_cbs [i].m_total_count->set_padding (8,0);
309307 m_cbs [i].m_total_count->set_justify (Gtk::JUSTIFY_RIGHT);
310308 m_cbs [i].m_total_count->set_line_wrap (false);
309 #if defined (IS_PDA)
310 m_cbs [i].m_total_count->set_text (_("0"));
311 #else
311312 m_cbs [i].m_total_count->set_text (_("0 cards"));
313 #endif
312314 }
313315
314316 Gtk::Table* cbt = manage (new Gtk::Table (5, 3, false));
358360 update_count (int idx_)
359361 {
360362 std::ostringstream os;
361
363
364 #ifdef IS_PDA
365 os << m_card_deck [idx_].size ();
366 #else
362367 os << m_card_deck [idx_].size () << " cards";
368 #endif
369
363370 m_cbs [idx_].m_total_count->set_text (os.str ());
364
365371 m_cbs [idx_].m_box_pic->clear ();
372
366373 if (m_card_deck [idx_].size () == 0) {
367374 m_cbs [idx_].m_box_pic->set (m_drawer_empty);
368375 }
00 // -*- c++ -*-
11 //------------------------------------------------------------------------------
2 // $Id: CardBox.h,v 1.29 2006/09/30 20:42:27 vlg Exp $
2 // $Id: CardBox.h,v 1.30 2006/12/02 05:43:10 vlg Exp $
33 //------------------------------------------------------------------------------
44 // CardBox.h
55 //------------------------------------------------------------------------------
103103 m_total_count (NULL), m_expired_count (0)
104104 { /* no-op */ }
105105
106 void reset ()
107 {
108 m_sched_count->set_text ("0");
109 m_total_count->set_text ("0 cards");
110 m_expired_count = 0;
111 }
106 void reset ();
112107 void add_one () { m_expired_count++; }
113108 };
114109
165160 trace_with_mask("CardBox::~CardBox",GUITRACE);
166161 }
167162
163 inline void
164 CardBox::CardBoxIF::
165 reset ()
166 {
167 m_sched_count->set_text ("0");
168 m_expired_count = 0;
169
170 #ifdef IS_PDA
171 m_total_count->set_text ("0");
172 #else
173 m_total_count->set_text ("0 cards");
174 #endif
175
176 }
177
168178 #endif /* CARD_BOX_H */
11 //------------------------------------------------------------------------------
22 // CardDeck.cpp
33 //------------------------------------------------------------------------------
4 // $Id: CardDeck.cpp,v 1.25 2006/09/30 20:42:27 vlg Exp $
4 // $Id: CardDeck.cpp,v 1.26 2006/12/18 03:33:14 vlg Exp $
55 //
66 // Copyright (c) 2004,2006 by Vladislav Grinchenko
77 //
7474
7575 void
7676 CardDeck::
77 play_card (VDeck::cardlist_iterator& iter_)
77 play_card (SideSelection side_, VDeck::cardlist_iterator& iter_)
7878 {
7979 CardRef* cref = dynamic_cast<CardRef*>(*iter_);
8080 Assure_exit (cref);
81 cref->get_deck ().play_card (iter_);
81 cref->get_deck ().play_card (side_, iter_);
8282 }
8383
8484 void
11 //------------------------------------------------------------------------------
22 // CardDeck.h
33 //------------------------------------------------------------------------------
4 // $Id: CardDeck.h,v 1.20 2006/08/30 12:22:35 vlg Exp $
4 // $Id: CardDeck.h,v 1.21 2006/12/18 03:33:14 vlg Exp $
55 //
66 // Copyright (c) 2004,2006 by Vladislav Grinchenko
77 //
9595 virtual SideSelection get_side_selection () { return m_side_selection; }
9696 virtual void set_side_selection (SideSelection s_) { m_side_selection=s_; }
9797
98 virtual void play_card (VDeck::cardlist_iterator& iter_);
98 virtual void play_card (SideSelection s_, VDeck::cardlist_iterator& iter_);
9999
100100 virtual const string& get_name () const { return m_cdname; }
101101
2525 virtual void set_question (const ustring& q_) { m_card.set_question (q_); }
2626 virtual void set_answer (const ustring& a_) { m_card.set_answer (a_); }
2727 virtual void set_example (const ustring& e_) { m_card.set_example (e_); }
28 virtual void set_alt_spelling (const ustring& a_)
29 {
30 m_card.set_alt_spelling (a_);
31 }
28 virtual void set_alt_spelling (SideSelection side_, const ustring& a_);
3229
3330 virtual ustring get_question () const { return m_card.get_question (); }
3431 virtual ustring get_answer () const { return m_card.get_answer (); }
3532 virtual ustring get_example () const { return m_card.get_example (); }
36 virtual ustring get_alt_spelling () const
37 {
38 return m_card.get_alt_spelling ();
39 }
40 virtual long get_id () const { return m_card.get_id (); }
33 virtual ustring get_alt_spelling (SideSelection side_) const;
34
35 virtual long get_id () const { return m_card.get_id (); }
4136
4237 virtual void set_expiration (const ASSA::TimeVal& e_);
4338 virtual ASSA::TimeVal get_expiration () const { return m_exp_date; }
5752 Card& m_card;
5853 Deck& m_deck;
5954 long m_exp_date; /**< Date this card is scheduled to be repeated */
55 };
6056
61 // SideSelection m_selection_side;
62 };
57
58 inline void
59 CardRef::set_alt_spelling (SideSelection side_, const ustring& a_)
60 {
61 m_card.set_alt_spelling (side_, a_);
62 }
63
64 inline ustring
65 CardRef::get_alt_spelling (SideSelection side_) const
66 {
67 return m_card.get_alt_spelling (side_);
68 }
6369
6470 inline bool
6571 CardRef::less_then_expiration (const VCard& rhs_)
11 //------------------------------------------------------------------------------
22 // CardView.cpp
33 //------------------------------------------------------------------------------
4 // $Id: CardView.cpp,v 1.37 2006/09/30 20:42:27 vlg Exp $
4 // $Id: CardView.cpp,v 1.50 2007/01/14 02:00:13 vlg Exp $
55 //
6 // Copyright (c) 2004-2005 by Vladislav Grinchenko
6 // Copyright (c) 2004-2006 by Vladislav Grinchenko
77 //
88 // This program is free software; you can redistribute it and/or
99 // modify it under the terms of the GNU General Public License
1313 // Date: Feb 15, 2004
1414 //------------------------------------------------------------------------------
1515
16 #include <gtkmmconfig.h>
1617 #include <gtkmm/image.h>
1718 #include <gtkmm/label.h>
1819 #include <gtkmm/box.h>
2223 #include <gtkmm/scrolledwindow.h>
2324 #include <gtkmm/table.h>
2425 #include <gtkmm/messagedialog.h>
26 #include <gtkmm/paned.h>
2527
2628 #include "Granule.h"
2729 #include "MainWindow.h"
3133 #include "Card.h"
3234 #include "CardRef.h"
3335 #include "EditControls.h"
34 #include "Intern.h"
36 #include "Intern.h" /* always last */
3537
3638 #define SET_CV_LABEL(l) \
3739 l->set_alignment (0.5,0.5); \
5658 t->set_justification (Gtk::JUSTIFY_LEFT); \
5759 t->set_accepts_tab (false);
5860
59
61 #define SET_CV_SCROLLWIN(w,t) \
62 w->set_flags (Gtk::CAN_FOCUS); \
63 w->set_shadow_type (Gtk::SHADOW_NONE); \
64 w->set_policy (Gtk::POLICY_ALWAYS, Gtk::POLICY_ALWAYS); \
65 w->property_window_placement ().set_value (Gtk::CORNER_TOP_LEFT); \
66 w->add (*t)
67
68 /*------------------------------------------------------------------------------
69 ** CardView class implementation
70 **------------------------------------------------------------------------------
71 */
6072 CardView::
6173 CardView (VCard* card_)
6274 :
7082 m_keep_open (false),
7183
7284 m_cancel_button (NULL),
85 m_count_button (NULL),
7386 m_add_n_close_button (NULL),
7487 m_add_button (NULL),
7588 m_help_button (NULL),
7790 m_front_text (NULL),
7891 m_back_text (NULL),
7992 m_example_text (NULL),
80 m_altspell_text (NULL),
93 m_asf_text (NULL),
94 m_asb_text (NULL),
8195
8296 m_edit_controls (NULL),
8397 m_help_dialog (*this)
106120 Gtk::Alignment* alignment2;
107121 Gtk::Alignment* alignment3;
108122 Gtk::Alignment* alignment4;
109 Gtk::Alignment* alignment5;
110 Gtk::Alignment* alignment6;
111 Gtk::Alignment* alignment7;
112 Gtk::Alignment* alignment8;
113 Gtk::Alignment* alignment9;
123
124 Gtk::Alignment* bt_alignment;
125 Gtk::Alignment* ft_alignment;
126 Gtk::Alignment* et_alignment;
127
128 Gtk::Alignment* asf_alignment;
129 Gtk::Alignment* asb_alignment;
114130
115131 Gtk::ScrolledWindow* front_scrollwin;
116132 Gtk::ScrolledWindow* backtext_scrollwin;
117133 Gtk::ScrolledWindow* example_scrollwin;
118 Gtk::ScrolledWindow* altspell_scrollwin;
134 Gtk::ScrolledWindow* asf_scrollwin;
135 Gtk::ScrolledWindow* asb_scrollwin;
119136
120137 Gtk::Label* back_label;
121138 Gtk::Label* example_label;
122139 Gtk::Label* front_label;
123 Gtk::Label* altspell_label;
140 Gtk::Label* asf_label;
141 Gtk::Label* asb_label;
124142
125143 Gtk::VBox* vbox_frontlabel;
126144 Gtk::VBox* vbox_backlabel;
127145 Gtk::VBox* vbox_examplelabel;
128 Gtk::VBox* vbox_altspelllabel;
129
130 Gtk::Table* elems_table;
146 Gtk::HBox* hbox_asf;
147 Gtk::HBox* hbox_asb;
148
149 Gtk::Table* elems_table_1;
150 Gtk::Table* elems_table_2;
151 Gtk::Table* elems_table_3;
152
153 Gtk::VPaned* paned_1; /* Holds elems_table_1 and paned_2 */
154 Gtk::VPaned* paned_2; /* Holds elems_table_2 and elems_table_3 */
155
131156 Gtk::VBox* vbox_all;
132157
133 #if defined (IS_HILDON)
158 set_title ("Card View");
159
160 #ifdef IS_HILDON
134161 set_size_request (672, 396);
135162 #else
163 set_modal (true); // very important - we're not protected from multi-clicks
164 // property_window_position ().set_value (Gtk::WIN_POS_CENTER);
165
166 #ifdef IS_PDA
167 set_resizable (false);
168 Gdk::Geometry dp_geometry = { 240, 320, 240, 320, 240, 320,-1, -1, -1, -1};
169 set_geometry_hints (*this, dp_geometry,
170 Gdk::HINT_MIN_SIZE | Gdk::HINT_MAX_SIZE | Gdk::HINT_BASE_SIZE);
171 #else
172 set_resizable (true);
136173 set_icon_from_file (GRAPPDATDIR "/pixmaps/cardview_32x32.png");
137
138174 Gdk::Rectangle geom = CONFIG->get_card_view_geometry ();
139175 set_size_request (geom.get_width (), geom.get_height ());
140
141 set_title ("Card View");
142 set_resizable (true);
143 set_modal (true); // very important - we're not protected from multi-clicks
144176 set_transient_for (*MAINWIN);
145 property_window_position ().set_value (Gtk::WIN_POS_CENTER);
146 #endif // ifdef IS_HILDON
147
148 /** <Clear> button
149 */
150 image1 = Gtk::manage (new Gtk::Image (Gtk::StockID ("gtk-clear"),
177 #endif // (!IS_PDA)
178
179 #endif // (!IS_HILDON)
180
181 /** <Clear> button - OBSOLETE -
182 */
183 image1 = Gtk::manage (new Gtk::Image (Gtk::StockID ("gtk-help"),
151184 Gtk::IconSize (4)));
152 label1 = Gtk::manage (new Gtk::Label (_("Clear")));
153 hbox1 = Gtk::manage (new Gtk::HBox (false, 2));
154 alignment1 = Gtk::manage (new Gtk::Alignment (0.5, 0.5, 0, 0));
185 label1 = Gtk::manage (new Gtk::Label (_("Help")));
186 hbox1 = Gtk::manage (new Gtk::HBox (false, 2));
187 alignment1 = Gtk::manage (new Gtk::Alignment (0.5, 0.5, 0, 0));
188 m_help_button = Gtk::manage (new Gtk::Button ());
155189
156190 /** <Cancel> Button
157191 */
162196 alignment2 = Gtk::manage (new Gtk::Alignment (0.5, 0.5, 0, 0));
163197 m_cancel_button = Gtk::manage (new Gtk::Button ());
164198
199 /** <Count> *Button*
200 */
201 m_count_button = Gtk::manage (new Gtk::Button ());
202
165203 /** <Add> Button
166204 */
167 image3 = Gtk::manage (new Gtk::Image (Gtk::StockID ("gtk-add"),
168 Gtk::IconSize (4)));
169 label3 = Gtk::manage (new Gtk::Label (_("Add")));
170 hbox3 = Gtk::manage (new Gtk::HBox (false, 2));
171 alignment3 = Gtk::manage (new Gtk::Alignment (0.5, 0.5, 0, 0));
205 image3 = Gtk::manage (new Gtk::Image (Gtk::StockID ("gtk-add"),
206 Gtk::IconSize (4)));
207 label3 = Gtk::manage (new Gtk::Label (_("Add")));
208 hbox3 = Gtk::manage (new Gtk::HBox (false, 2));
209 alignment3 = Gtk::manage (new Gtk::Alignment (0.5, 0.5, 0, 0));
172210 m_add_button = Gtk::manage (new Gtk::Button ());
173211
174212 /** <Add'n'Close> Button
180218 alignment4 = Gtk::manage (new Gtk::Alignment (0.5, 0.5, 0, 0));
181219 m_add_n_close_button = Gtk::manage (new Gtk::Button ());
182220
183 /** <Help> Button
184 */
185 image5 = Gtk::manage (new Gtk::Image (Gtk::StockID ("gtk-help"),
186 Gtk::IconSize (4)));
187 label5 = Gtk::manage (new Gtk::Label (_("Help")));
188 hbox5 = Gtk::manage (new Gtk::HBox (false, 2));
189 alignment8 = Gtk::manage (new Gtk::Alignment (0.5, 0.5, 0, 0));
190 m_help_button = Gtk::manage (new Gtk::Button ());
191
192221 /** Text
193222 */
194223 m_front_text = Gtk::manage (new Gtk::TextView);
195224 front_scrollwin = Gtk::manage (new Gtk::ScrolledWindow);
196 front_label = Gtk::manage (new Gtk::Label (_("Front :\n \n \n")));
197 alignment6 = Gtk::manage (new Gtk::Alignment (0.84, 0.5, 0, 0));
225 front_label = Gtk::manage (new Gtk::Label (_("Front")));
226 ft_alignment = Gtk::manage (new Gtk::Alignment (0.5, 0.5, 0, 0));
198227 vbox_frontlabel = Gtk::manage (new Gtk::VBox (false, 0));
199228
200229 m_back_text = Gtk::manage (new Gtk::TextView);
201230 backtext_scrollwin = Gtk::manage (new Gtk::ScrolledWindow);
202 back_label = Gtk::manage (new Gtk::Label (_("Back :\n \n \n")));
203 alignment5 = Gtk::manage (new Gtk::Alignment (0.76, 0.5, 0, 0));
231 back_label = Gtk::manage (new Gtk::Label (_("Back")));
232 bt_alignment = Gtk::manage (new Gtk::Alignment (0.5, 0.5, 0, 0));
204233 vbox_backlabel = Gtk::manage (new Gtk::VBox (false, 0));
205234
206235 m_example_text = Gtk::manage (new Gtk::TextView);
207236 example_scrollwin = Gtk::manage (new Gtk::ScrolledWindow);
208 example_label = Gtk::manage (new Gtk::Label (_("Example : ")));
209 alignment7 = Gtk::manage (new Gtk::Alignment (0.84, 0.5, 0, 0));
237 example_label = Gtk::manage (new Gtk::Label (_("Example")));
238 et_alignment = Gtk::manage (new Gtk::Alignment (0.5, 0.5, 0, 0));
210239 vbox_examplelabel = Gtk::manage (new Gtk::VBox (false, 0));
211240
212 m_altspell_text = Gtk::manage (new Gtk::TextView);
213 altspell_scrollwin = Gtk::manage (new Gtk::ScrolledWindow);
214 altspell_label = Gtk::manage (new Gtk::Label (_("Alt\nSpelling : ")));
215 alignment9 = Gtk::manage (new Gtk::Alignment (0.84, 0.5, 0, 0));
216 vbox_altspelllabel = Gtk::manage (new Gtk::VBox (false, 0));
217
218 elems_table = Gtk::manage (new Gtk::Table (2, 5, false));
219 vbox_all = Gtk::manage (new Gtk::VBox (false, 0));
241 m_asf_text = Gtk::manage (new Gtk::TextView);
242 asf_scrollwin = Gtk::manage (new Gtk::ScrolledWindow);
243 asf_label = Gtk::manage (new Gtk::Label (_("ASF")));
244 asf_alignment = Gtk::manage (new Gtk::Alignment (0, 0.5, 0, 0));
245 hbox_asf = Gtk::manage (new Gtk::HBox (false, 0));
246
247 m_asb_text = Gtk::manage (new Gtk::TextView);
248 asb_scrollwin = Gtk::manage (new Gtk::ScrolledWindow);
249 asb_label = Gtk::manage (new Gtk::Label (_("ASB")));
250 asb_alignment = Gtk::manage (new Gtk::Alignment (0, 0.5, 0, 0));
251 hbox_asb = Gtk::manage (new Gtk::HBox (false, 0));
252
253 elems_table_1 = Gtk::manage (new Gtk::Table (2, 2, false));
254 elems_table_2 = Gtk::manage (new Gtk::Table (2, 1, false));
255 elems_table_3 = Gtk::manage (new Gtk::Table (2, 2, false));
256
257 paned_1 = Gtk::manage (new Gtk::VPaned);
258 paned_2 = Gtk::manage (new Gtk::VPaned);
259
260 vbox_all = Gtk::manage (new Gtk::VBox (false, 0));
220261
221262 m_front_text ->modify_font (CONFIG->get_example_font ());
222263 m_back_text ->modify_font (CONFIG->get_example_font ());
223264 m_example_text ->modify_font (CONFIG->get_example_font ());
224 m_altspell_text->modify_font (CONFIG->get_example_font ());
225
265 m_asf_text ->modify_font (CONFIG->get_example_font ());
266 m_asb_text ->modify_font (CONFIG->get_example_font ());
267
268
269 /**----------------**
270 ** Edit Controls **
271 **----------------**
272 */
273 m_edit_controls = Gtk::manage(new EditControls(m_front_text->get_buffer()));
274 m_edit_controls->unset_flags (Gtk::CAN_FOCUS);
275 vbox_all->pack_start (*m_edit_controls, Gtk::PACK_SHRINK, 0);
276
277 /**---------------**
278 ** Setup buttons **
279 **---------------**
280 */
281
282 /** [Help] Button
283 */
226284 image1->set_alignment (0.5,0.5);
227285 image1->set_padding (0,0);
286
287 #if !defined(IS_PDA)
228288 SET_CV_LABEL(label1);
229
230289 hbox1->pack_start (*image1, Gtk::PACK_SHRINK, 0);
231290 hbox1->pack_start (*label1, Gtk::PACK_SHRINK, 0);
232291 alignment1->add (*hbox1);
233
292 m_help_button->set_relief (Gtk::RELIEF_NORMAL);
293 m_help_button->add (*alignment1);
294 #else
295 m_help_button->add (*image1);
296 #endif
297 m_help_button->unset_flags (Gtk::CAN_FOCUS); // Take help off the chain
298
299 /** [Cancel] Button
300 */
234301 image2->set_alignment (0.5,0.5);
235302 image2->set_padding (0,0);
303
236304 SET_CV_LABEL(label2);
237305 hbox2->pack_start (*image2, Gtk::PACK_SHRINK, 0);
238306 hbox2->pack_start (*label2, Gtk::PACK_SHRINK, 0);
239307 alignment2->add (*hbox2);
240
241 m_cancel_button->set_flags (Gtk::CAN_FOCUS);
308 m_cancel_button->unset_flags (Gtk::CAN_FOCUS);
242309 m_cancel_button->set_relief (Gtk::RELIEF_NORMAL);
243310 m_cancel_button->add (*alignment2);
244311
312 /** [Count] Label
313 */
314 m_count_button->set_focus_on_click (false);
315 m_count_button->unset_flags (Gtk::CAN_FOCUS);
316 m_count_button->set_relief (Gtk::RELIEF_NONE);
317 m_count_button->set_use_stock (false);
318 m_count_button->set_use_underline (false);
319
320 /** [+ Add] Button
321 */
245322 image3->set_alignment (0.5,0.5);
246323 image3->set_padding (0,0);
247324 SET_CV_LABEL(label3);
248325 hbox3->pack_start (*image3, Gtk::PACK_SHRINK, 0);
249326 hbox3->pack_start (*label3, Gtk::PACK_SHRINK, 0);
250327 alignment3->add (*hbox3);
251
252328 m_add_button->set_flags (Gtk::CAN_FOCUS);
253329 m_add_button->set_relief (Gtk::RELIEF_NORMAL);
254330 m_add_button->add (*alignment3);
255331
332 /** [Add-n-Close]
333 */
256334 image4->set_alignment (0.5,0.5);
257335 image4->set_padding (0,0);
258336 SET_CV_LABEL(label4);
264342 m_add_n_close_button->set_relief (Gtk::RELIEF_NORMAL);
265343 m_add_n_close_button->add (*alignment4);
266344
267 image5->set_alignment (0.5,0.5);
268 image5->set_padding (0,0);
269 SET_CV_LABEL(label5);
270 hbox5->pack_start (*image5, Gtk::PACK_SHRINK, 0);
271 hbox5->pack_start (*label5, Gtk::PACK_SHRINK, 0);
272 alignment8->add (*hbox5);
273
274 m_help_button->unset_flags (Gtk::CAN_FOCUS); // Take help off the chain
275 m_help_button->set_relief (Gtk::RELIEF_NORMAL);
276 m_help_button->add (*alignment8);
277
278345 /**--------------**
279346 ** Front Text **
280347 **--------------**
281348 */
282349 SET_CV_TEXT(m_front_text);
283 m_front_text->get_buffer ()->set_text (_("Fill up the front of the card"));
284
285 front_scrollwin->set_flags (Gtk::CAN_FOCUS);
286 front_scrollwin->set_shadow_type (Gtk::SHADOW_NONE);
287 front_scrollwin->set_policy (Gtk::POLICY_ALWAYS, Gtk::POLICY_ALWAYS);
288 front_scrollwin->
289 property_window_placement ().set_value (Gtk::CORNER_TOP_LEFT);
290 front_scrollwin->add (*m_front_text);
291
350 SET_CV_SCROLLWIN(front_scrollwin,m_front_text);
292351 SET_CV_LABEL(front_label);
293 alignment6->add (*front_label);
294 vbox_frontlabel->pack_start (*alignment6, Gtk::PACK_SHRINK, 0);
352 #ifndef IS_HILDON
353 #if (GTKMM_MINOR_VERSION < 6)
354 front_label->set_text ("Q:");
355 #else
356 front_label->set_angle (90.0);
357 #endif
358 #endif
359 ft_alignment->add (*front_label);
360 vbox_frontlabel->pack_start (*ft_alignment, Gtk::PACK_SHRINK, 0);
295361
296
297362 /**--------------**
298363 ** Back Text **
299364 **--------------**
300365 */
301366 SET_CV_TEXT(m_back_text);
302 m_back_text->get_buffer ()->set_text (_("Fill up the back of the card"));
303
304 backtext_scrollwin->set_flags (Gtk::CAN_FOCUS);
305 backtext_scrollwin->set_shadow_type (Gtk::SHADOW_NONE);
306 backtext_scrollwin->set_policy (Gtk::POLICY_ALWAYS, Gtk::POLICY_ALWAYS);
307 backtext_scrollwin->
308 property_window_placement ().set_value (Gtk::CORNER_TOP_LEFT);
309 backtext_scrollwin->add (*m_back_text);
310
367 SET_CV_SCROLLWIN(backtext_scrollwin,m_back_text);
311368 SET_CV_LABEL(back_label);
312 alignment5->add (*back_label);
313 vbox_backlabel->pack_start (*alignment5, Gtk::PACK_SHRINK, 0);
369 #ifndef IS_HILDON
370 #if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION >= 6)
371 back_label->set_angle (90.0);
372 #else
373 back_label->set_text ("A:");
374 #endif
375 #endif
376 bt_alignment->add (*back_label);
377 vbox_backlabel->pack_start (*bt_alignment, Gtk::PACK_SHRINK, 0);
314378
315379 /**----------------**
316380 ** Example Text **
317381 **----------------**
318382 */
319383 SET_CV_TEXT(m_example_text);
320 m_example_text->get_buffer ()->set_text (_("Fill up an example"));
321
322 example_scrollwin->set_flags (Gtk::CAN_FOCUS);
323 example_scrollwin->set_shadow_type (Gtk::SHADOW_NONE);
324 example_scrollwin->set_policy (Gtk::POLICY_ALWAYS, Gtk::POLICY_ALWAYS);
325 example_scrollwin->
326 property_window_placement ().set_value (Gtk::CORNER_TOP_LEFT);
327 example_scrollwin->add (*m_example_text);
328
384 SET_CV_SCROLLWIN(example_scrollwin,m_example_text);
329385 SET_CV_LABEL(example_label);
386 #ifndef IS_HILDON
387 #if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION >= 6)
388 example_label->set_angle (90.0);
389 #else
390 example_label->set_text ("E:");
391 #endif
392 #endif
330393 vbox_examplelabel->pack_start (*example_label, Gtk::PACK_SHRINK, 0);
331394
332 /**-----------------**
333 ** AltSpell Text **
334 **-----------------**
335 */
336 SET_CV_TEXT(m_altspell_text);
337
338 altspell_scrollwin->set_flags (Gtk::CAN_FOCUS);
339 altspell_scrollwin->set_shadow_type (Gtk::SHADOW_NONE);
340 altspell_scrollwin->set_policy (Gtk::POLICY_ALWAYS, Gtk::POLICY_ALWAYS);
341 altspell_scrollwin->
342 property_window_placement ().set_value (Gtk::CORNER_TOP_LEFT);
343 altspell_scrollwin->add (*m_altspell_text);
344
345 SET_CV_LABEL(altspell_label);
346 alignment9->add (*altspell_label);
347 vbox_altspelllabel->pack_start (*alignment9, Gtk::PACK_SHRINK, 0);
348
349 /**----------------**
350 ** Edit Controls **
351 **----------------**
352 */
353 m_edit_controls = Gtk::manage(new EditControls(m_front_text->get_buffer()));
354 vbox_examplelabel->pack_end (*m_edit_controls, Gtk::PACK_SHRINK, 0);
355
395 /**------------------------------------**
396 ** AltSpell Text for Front and Back **
397 **------------------------------------**
398 */
399 SET_CV_TEXT(m_asf_text);
400 SET_CV_LABEL(asf_label);
401 asf_alignment->add (*asf_label);
402
403 hbox_asf->pack_start (*asf_alignment, Gtk::PACK_SHRINK, 0);
404 hbox_asf->pack_start (*m_asf_text, Gtk::PACK_EXPAND_WIDGET, 0);
405 hbox_asf->unset_flags (Gtk::CAN_FOCUS);
406
407 SET_CV_TEXT(m_asb_text);
408 SET_CV_LABEL(asb_label);
409 asb_alignment->add (*asb_label);
410
411 hbox_asb->pack_start (*asb_alignment, Gtk::PACK_SHRINK, 0);
412 hbox_asb->pack_start (*m_asb_text, Gtk::PACK_EXPAND_WIDGET, 0);
413 hbox_asb->unset_flags (Gtk::CAN_FOCUS);
414
415 /** Hook up callbacks
416 */
356417 m_front_text->signal_grab_focus ().connect (
357418 bind<Gtk::TextView*> (mem_fun (*m_edit_controls,
358419 &EditControls::on_focus_changed),
368429 &EditControls::on_focus_changed),
369430 m_example_text));
370431
371 m_altspell_text->signal_grab_focus ().connect (
432 m_asf_text->signal_grab_focus ().connect (
372433 bind<Gtk::TextView*> (mem_fun (*m_edit_controls,
373434 &EditControls::on_focus_changed),
374 m_altspell_text));
375
435 m_asf_text));
436 m_asb_text->signal_grab_focus ().connect (
437 bind<Gtk::TextView*> (mem_fun (*m_edit_controls,
438 &EditControls::on_focus_changed),
439 m_asb_text));
376440 #ifdef IS_HILDON
377441 /** Trap 'on virtual keyboard close' event to restore
378442 * original size of the dialog
381445 mem_fun (*this, &CardView::hildon_im_close_cb));
382446 #endif
383447
384 /**
448 /*************************************************
385449 * Table holds elements together:
386450 *
387 * |----------------+------------------|
388 * | vbox(label) | scrollwin(text) |
389 * |----------------+------------------|
390 */
391 elems_table->set_border_width (4);
392 elems_table->set_row_spacings (8);
393 elems_table->set_col_spacings (2);
394 elems_table->set_name ("CardViewElemsTable");
451 * 0 1 2
452 * 0 .----------------+------------------.
453 * | vbox(label) | scrollwin(text) | Front
454 * 1 `----------------+------------------'
455 * --------------------------[=]-------- <-- pane
456 * 0 1 2
457 * 0 .----------------+------------------.
458 * | | scrollwin(text) | Front Alt Spell
459 * 1 `----------------+------------------'
460 * | vbox(label) | scrollwin(text) | Back
461 * 2 `----------------+------------------'
462 * --------------------------[=]-------- <-- paen
463 * 0 1 2
464 * 0 .----------------+------------------.
465 * | vbox(label) | scrollwin(text) | Example
466 * 1 `----------------+------------------'
467 * | | scrollwin(text) | Back Alt Spell
468 * 2 `----------------+------------------'
469 *
470 *************************************************
471 */
472
473 elems_table_1->set_border_width (4);
474 elems_table_1->set_row_spacings (2);
475 elems_table_1->set_col_spacings (2);
476 elems_table_1->set_name ("CVElemsTableFront");
477
478 elems_table_2->set_border_width (4);
479 elems_table_2->set_row_spacings (2);
480 elems_table_2->set_col_spacings (2);
481 elems_table_2->set_name ("CVElemsTableBack");
482
483 elems_table_3->set_border_width (4);
484 elems_table_3->set_row_spacings (2);
485 elems_table_3->set_col_spacings (2);
486 elems_table_3->set_name ("CVElemsTableExample");
395487
396488 /*-----------------------------------------------------------*/
397 elems_table->attach (*vbox_frontlabel, 0, 1, 0, 1,
398 Gtk::FILL, Gtk::FILL, 0, 0);
399
400 elems_table->attach (*front_scrollwin, 1, 2, 0, 1,
401 Gtk::EXPAND|Gtk::FILL, Gtk::FILL, 0, 0);
402
489 /* y-beg, y-end, x-beg, x-end */
403490 /*-----------------------------------------------------------*/
404 elems_table->attach (*vbox_backlabel, 0, 1, 1, 2,
405 Gtk::FILL, Gtk::FILL, 0, 0);
406
407 elems_table->attach (*backtext_scrollwin, 1, 2, 1, 2,
408 Gtk::EXPAND|Gtk::FILL, Gtk::FILL, 0, 0);
491 elems_table_1->attach (*vbox_frontlabel, 0, 1, 0, 1,
492 Gtk::FILL, Gtk::FILL, 0, 0);
493
494 elems_table_1->attach (*front_scrollwin, 1, 2, 0, 1,
495 Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
409496
410497 /*-----------------------------------------------------------*/
411 elems_table->attach (*vbox_examplelabel, 0, 1, 2, 3,
412 Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
413
414 elems_table->attach (*example_scrollwin, 1, 2, 2, 3,
415 Gtk::FILL, Gtk::FILL, 0, 0);
498 elems_table_2->attach (*hbox_asf, 1, 2, 0, 1,
499 Gtk::FILL|Gtk::EXPAND, Gtk::SHRINK, 0, 0);
416500
417501 /*-----------------------------------------------------------*/
418 elems_table->attach (*vbox_altspelllabel, 0, 1, 3, 4,
419 Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
420
421 elems_table->attach (*altspell_scrollwin, 1, 2, 3, 4,
422 Gtk::FILL, Gtk::FILL, 0, 0);
502 elems_table_2->attach (*vbox_backlabel, 0, 1, 1, 2,
503 Gtk::FILL, Gtk::FILL, 0, 0);
504
505 elems_table_2->attach (*backtext_scrollwin, 1, 2, 1, 2,
506 Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
423507
424508 /*-----------------------------------------------------------*/
425 elems_table->attach (*alignment7, 0, 1, 4, 5,
426 Gtk::FILL, Gtk::FILL, 0, 0);
427
428 #ifdef IS_HILDON
429 /** Maemo has a narrow screen and thus requires
509 elems_table_3->attach (*vbox_examplelabel, 0, 1, 0, 1,
510 Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
511
512 elems_table_3->attach (*example_scrollwin, 1, 2, 0, 1,
513 Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
514
515 /*-----------------------------------------------------------*/
516 elems_table_3->attach (*hbox_asb, 1, 2, 1, 2,
517 Gtk::FILL|Gtk::EXPAND, Gtk::SHRINK, 0, 0);
518 /*-----------------------------------------------------------*/
519
520 /** Pane 1 holds top elems_table and Pane 2.
521 * Pane 2 holds both middle and the bottom elems_table.
522 */
523 paned_2->pack1 (*elems_table_2, false, false);
524 paned_2->pack2 (*elems_table_3, true, false);
525
526 paned_1->pack1 (*elems_table_1, true, false);
527 paned_1->pack2 (*paned_2, true, false);
528
529 /** Both PDAs and Maemo have a narrow screen and thus requires
430530 * smart packing.
431531 */
532 #if defined(IS_HILDON) || defined (IS_PDA)
432533 Gtk::ScrolledWindow* scrollw = Gtk::manage (new Gtk::ScrolledWindow);
433 scrollw->set_flags (Gtk::CAN_FOCUS);
434 scrollw->set_shadow_type (Gtk::SHADOW_NONE);
435 scrollw->set_policy (Gtk::POLICY_AUTOMATIC, Gtk::POLICY_ALWAYS);
436 scrollw->property_window_placement ().set_value (Gtk::CORNER_TOP_LEFT);
437
438 scrollw->add (*elems_table);
534 SET_CV_SCROLLWIN (scrollw, paned_1);
439535 vbox_all->pack_start (*scrollw);
440536 #else // Regular desktop
441 vbox_all->pack_start (*elems_table);
442 #endif
443
444 /**-------------------------**
445 ** Create and pack buttons **
446 **-------------------------**
537 vbox_all->pack_start (*paned_1);
538 #endif
539
540 /**--------------------------------------------------**
541 ** Pack [Help] [Cancel][+ Add][Add-n-Close] Buttons **
542 **--------------------------------------------------**
447543 */
448544 Gtk::HBox* hbbox = Gtk::manage(new Gtk::HBox(false, 0));
449545 Gtk::HSeparator* hseparator = manage (new Gtk::HSeparator);
546
547 #if !defined(IS_PDA)
450548 Gtk::HButtonBox* hbuttonbox = manage (new Gtk::HButtonBox);
451 hbuttonbox->set_homogeneous ();
452 hbuttonbox->set_spacing (8);
549
550 hbuttonbox->set_homogeneous (false);
551 hbuttonbox->set_spacing (0);
453552 hbuttonbox->set_layout (Gtk::BUTTONBOX_END);
454553 hbuttonbox->set_name ("CardView_CtrlButtonBox");
455554
456 hbuttonbox->pack_end (*m_cancel_button, false, false, 1);
457 hbuttonbox->pack_end (*m_add_button, false, false, 1);
458 hbuttonbox->pack_end (*m_add_n_close_button, false, false, 1);
459
460 hbbox->pack_start (*m_help_button, Gtk::PACK_SHRINK, 5);
555 hbuttonbox->pack_end (*m_count_button, Gtk::PACK_SHRINK, 0);
556 hbuttonbox->pack_end (*m_cancel_button, Gtk::PACK_SHRINK, 0);
557 hbuttonbox->pack_end (*m_add_button, Gtk::PACK_SHRINK, 0);
558 hbuttonbox->pack_end (*m_add_n_close_button, Gtk::PACK_SHRINK, 0);
559
560 hbbox->pack_start (*m_help_button, Gtk::PACK_SHRINK, 0);
461561 hbbox->pack_start (*hbuttonbox);
462
463 vbox_all->pack_start (*hseparator, Gtk::PACK_SHRINK, 3);
464 vbox_all->pack_start (*hbbox, Gtk::PACK_SHRINK, 5);
562 #else
563 hbbox->pack_start (*m_help_button, Gtk::PACK_SHRINK, 0);
564 hbbox->pack_end (*m_add_button, Gtk::PACK_SHRINK, 0);
565 hbbox->pack_end (*m_add_n_close_button, Gtk::PACK_SHRINK, 0);
566 hbbox->pack_end (*m_cancel_button, Gtk::PACK_SHRINK, 0);
567 hbbox->pack_end (*m_count_button, Gtk::PACK_SHRINK, 0);
568 #endif
569
570 vbox_all->pack_start (*hseparator, Gtk::PACK_SHRINK, 0);
571 vbox_all->pack_start (*hbbox, Gtk::PACK_SHRINK, 0);
465572
466573 add (*vbox_all);
467574
493600 m_front_text ->get_buffer ()->set_text (m_card->get_question ());
494601 m_back_text ->get_buffer ()->set_text (m_card->get_answer ());
495602 m_example_text ->get_buffer ()->set_text (m_card->get_example ());
496 m_altspell_text->get_buffer ()->set_text (m_card->get_alt_spelling ());
603 m_asf_text->get_buffer ()->set_text (m_card->get_alt_spelling (FRONT));
604 m_asb_text->get_buffer ()->set_text (m_card->get_alt_spelling (BACK));
497605 }
498606
499607 /** Set Widget names - very helpful with debugging!
500608 */
501 m_front_text->set_name ("FrontText");
502 m_back_text ->set_name ("BackText");
503 m_example_text->set_name ("ExampleText");
504 m_altspell_text->set_name ("AltSpellText");
505 m_help_button->set_name ("HelpButton");
506 m_cancel_button->set_name ("CancelButton");
507 m_add_button->set_name ("AddButton");
609 m_front_text ->set_name ("FrontText");
610 m_back_text ->set_name ("BackText");
611 m_example_text ->set_name ("ExampleText");
612 m_asf_text ->set_name ("AltSpellFrontText");
613 m_asb_text ->set_name ("AltSpellBackText");
614 m_help_button ->set_name ("HelpButton");
615 m_cancel_button ->set_name ("CancelButton");
616 m_add_button ->set_name ("AddButton");
508617 m_add_n_close_button->set_name ("AddNCloseButton");
509618
510619 vbox_all->set_name ("CardView_VBoxAll");
555664 * - DeckView::on_add_clicked ()
556665 *
557666 * Possible values returned by run():
667 *
558668 * <Cancel> - Gtk::RESPONSE_CANCEL
559669 * <Add> - Gtk::RESPONSE_APPLY
560670 * <Ok> - Gtk::RESPONSE_OK
567677
568678 m_syntax_error = false;
569679 take_snapshot ();
680 set_cards_count (deckview_);
570681
571682 #ifdef IS_HILDON
572683 GRANULE->register_appview (this);
573684 Gtk::Main::run (*HILDONAPPWIN);
574
575685 #else
576686 Gtk::Main::run (*this);
577687 #endif
616726 break;
617727 }
618728 deckview_.add_new_card (dynamic_cast<Card*>(m_card));
729 bump_cards_count ();
619730 }
620731
621732 done:
654765 DL((GEOM,"key_pressed = %d\n", event_->keyval));
655766
656767 /** Trap and disable ESC key event.
657 The values for all keysyms are found
658 in $prefix/gtk-2.0/gdk/gdkkeysyms.h
659 */
768 * The values for all keysyms are found
769 * in $prefix/gtk-2.0/gdk/gdkkeysyms.h
770 */
660771 if (event_->keyval == GDK_Escape) {
661772 return false;
662773 }
676787 on_addnclose_clicked ()
677788 {
678789 trace_with_mask("CardView::on_addnclose_clicked",GUITRACE);
679
790
680791 m_response = Gtk::RESPONSE_OK;
681792
682 if (!Granule::check_markup (m_front_text->get_buffer ()->get_text ())) {
793 Glib::ustring text = m_front_text->get_buffer ()->get_text ();
794
795 if (text.length () == 0)
796 {
797 Gtk::MessageDialog err0 (
798 _("<b>Front:</b> text field <span foreground=\"red\">IS EMPTY</span>!\n"
799 "This is an illegal syntax.\n"
800 "You must fill it with (unique) text.\n"),
801 true, Gtk::MESSAGE_ERROR);
802 err0.run ();
803 m_syntax_error = true;
804 return;
805 }
806
807 if (!Granule::check_markup (text))
808 {
683809 Gtk::MessageDialog err1 (
684810 _("FRONT field contains illegal markup tag(s)."),
685811 false, Gtk::MESSAGE_ERROR);
688814 return;
689815 }
690816
691 if (!Granule::check_markup (m_back_text->get_buffer ()->get_text ())) {
817 if (!Granule::check_markup (m_back_text->get_buffer ()->get_text ()))
818 {
692819 Gtk::MessageDialog err2 (
693820 _("BACK field contains illegal markup tag(s)."),
694821 false, Gtk::MESSAGE_ERROR);
697824 return;
698825 }
699826
700 if (!Granule::check_markup (m_example_text->get_buffer ()->get_text ())) {
701 Gtk::MessageDialog err2 (
827 if (!Granule::check_markup (m_example_text->get_buffer ()->get_text ()))
828 {
829 Gtk::MessageDialog err3 (
702830 _("EXAMPLE field contains illegal markup tag(s)."),
703831 false, Gtk::MESSAGE_ERROR);
704 err2.run ();
832 err3.run ();
705833 m_syntax_error = true;
706834 return;
707835 }
708836
709 /** Transfer data from the widget to the card
837 /** Transfer data from the widget to the Card object
710838 */
711839 if (m_card != NULL && text_modified ())
712840 {
713841 m_card->set_question (m_front_text ->get_buffer ()->get_text ());
714842 m_card->set_answer (m_back_text ->get_buffer ()->get_text ());
715843 m_card->set_example (m_example_text ->get_buffer ()->get_text ());
716 m_card->set_alt_spelling (m_altspell_text->get_buffer ()->get_text ());
844
845 m_card->set_alt_spelling (FRONT, m_asf_text->get_buffer()->get_text ());
846 m_card->set_alt_spelling (BACK, m_asb_text->get_buffer()->get_text ());
717847 }
718848 m_keep_open = false;
719849 m_front_text->grab_focus ();
726856 #else
727857 Gtk::Main::quit ();
728858 #endif
859 /* done */
729860 }
730861
731862 void
737868 m_snapshot_front = m_front_text ->get_buffer ()->get_text ();
738869 m_snapshot_back = m_back_text ->get_buffer ()->get_text ();
739870 m_snapshot_example = m_example_text ->get_buffer ()->get_text ();
740 m_snapshot_altspell = m_altspell_text->get_buffer ()->get_text ();
871 m_snapshot_asf = m_asf_text ->get_buffer ()->get_text ();
872 m_snapshot_asb = m_asb_text ->get_buffer ()->get_text ();
741873 }
742874
743875 bool
747879 return (m_snapshot_front != m_front_text ->get_buffer ()->get_text () ||
748880 m_snapshot_back != m_back_text ->get_buffer ()->get_text () ||
749881 m_snapshot_example != m_example_text ->get_buffer ()->get_text () ||
750 m_snapshot_altspell != m_altspell_text->get_buffer ()->get_text ());
882 m_snapshot_asf != m_asf_text ->get_buffer ()->get_text () ||
883 m_snapshot_asb != m_asb_text ->get_buffer ()->get_text ());
751884 }
752885
753886 void
778911 m_front_text ->get_buffer ()->set_text ("");
779912 m_back_text ->get_buffer ()->set_text ("");
780913 m_example_text->get_buffer ()->set_text ("");
781 m_altspell_text->get_buffer ()->set_text ("");
914 m_asf_text ->get_buffer ()->set_text ("");
915 m_asb_text ->get_buffer ()->set_text ("");
782916
783917 m_snapshot_front = "";
784918 m_snapshot_back = "";
785919 m_snapshot_example = "";
786 m_snapshot_altspell = "";
920 m_snapshot_asf = "";
921 m_snapshot_asb = "";
787922 }
788923
789924 void
806941 set_size_request (672, 396);
807942 }
808943 #endif
944
945 void
946 CardView::
947 set_cards_count (DeckView& deckview_)
948 {
949 static char buf [32];
950 m_cards_count = deckview_.get_deck_size ();
951
952 #ifdef IS_PDA
953 sprintf (buf, "%d", m_cards_count);
954 #else
955 sprintf (buf, "%d cards", m_cards_count);
956 #endif
957 m_count_button->set_label (buf);
958 }
959
960 void
961 CardView::
962 bump_cards_count ()
963 {
964 static char buf [32];
965
966 ++m_cards_count;
967
968 #ifdef IS_PDA
969 sprintf (buf, "%d", m_cards_count);
970 #else
971 sprintf (buf, "%d cards", m_cards_count);
972 #endif
973
974 m_count_button->set_label (buf);
975 }
11 //------------------------------------------------------------------------------
22 // CardView.h
33 //------------------------------------------------------------------------------
4 // $Id: CardView.h,v 1.20 2006/09/06 02:07:59 vlg Exp $
4 // $Id: CardView.h,v 1.22 2006/12/18 03:33:14 vlg Exp $
55 //
66 // Copyright (c) 2004-2005 by Vladislav Grinchenko
77 //
7878 void clear_dialog ();
7979
8080 void take_snapshot ();
81 void set_cards_count (DeckView& deckview_);
82 void bump_cards_count ();
8183 bool text_modified ();
8284
8385 private:
8991 // -*- GUI components -*-
9092 //
9193 Gtk::Button* m_cancel_button;
94 Gtk::Button* m_count_button; // functions as a label
9295 Gtk::Button* m_add_n_close_button;
9396 Gtk::Button* m_add_button;
9497 Gtk::Button* m_help_button;
9699 Gtk::TextView* m_front_text;
97100 Gtk::TextView* m_back_text;
98101 Gtk::TextView* m_example_text;
99 Gtk::TextView* m_altspell_text;
102 Gtk::TextView* m_asf_text; // Alt.Spell Front
103 Gtk::TextView* m_asb_text; // Alt.Spell Back
100104
101105 // -*- Snapshot to detect true changes -*-
102106 //
103107 Glib::ustring m_snapshot_front;
104108 Glib::ustring m_snapshot_back;
105109 Glib::ustring m_snapshot_example;
106 Glib::ustring m_snapshot_altspell;
110 Glib::ustring m_snapshot_asf;
111 Glib::ustring m_snapshot_asb;
107112
108113 EditControls* m_edit_controls;
109114
110115 CardViewHelpDialog m_help_dialog;
116
117 int m_cards_count; // tied up to m_count_button
111118 };
112119
113120
11 //------------------------------------------------------------------------------
22 // Deck.cpp
33 //------------------------------------------------------------------------------
4 // $Id: Deck.cpp,v 1.49 2006/09/30 20:42:27 vlg Exp $
4 // $Id: Deck.cpp,v 1.59 2007/01/15 04:09:08 vlg Exp $
55 //
66 // Copyright (c) 2004-2006 by Vladislav Grinchenko
77 //
3636 #include "MainWindow.h"
3737 #include "GrappConf.h"
3838 #include "CSVImportDialog.h"
39 #include "CSVExportDialog.h"
40
3941 #include "Intern.h"
4042
4143 /** Compare real cards by their IDs
5254 }
5355 };
5456
57 /** C'tor for existing deck
58 */
59 Deck::
60 Deck (DeckEditStatus status_)
61 :
62 m_side_selection (FRONT),
63 m_status (status_),
64 m_needs_renaming (false),
65 m_snd_enabled (false)
66 {
67 trace_with_mask("Deck::Deck",GUITRACE|DECK);
68
69 m_active_snd_path = Glib::filename_to_utf8(CONFIG->get_snd_archive_path ());
70 init_appearance ();
71 }
72
5573 /** C'tor for the new deck
5674 */
5775 Deck::
6583 trace_with_mask("Deck::Deck(untitled)",GUITRACE|DECK);
6684
6785 m_author = Glib::locale_to_utf8 (CONFIG->get_user_name ());
68 m_snd_path = Glib::filename_to_utf8 (CONFIG->get_snd_archive_path ());
86 m_active_snd_path = Glib::filename_to_utf8(CONFIG->get_snd_archive_path ());
87
6988 {
7089 ASSA::TimeVal today = ASSA::TimeVal::gettimeofday ();
7190 m_desc += Glib::locale_to_utf8 (today.fmtString ("%c"));
7291 }
92 init_appearance ();
7393 dump_deck_status ();
94 }
95
96 void
97 Deck::
98 init_appearance ()
99 {
100 m_custom_app_enabled = false;
101 m_question_font = "Sans 18";
102 m_front_x_alignment = "left";
103 m_front_y_alignment = "top";
104 m_front_x_padding = "20";
105 m_front_y_padding = "20";
106 m_front_justification = "left";
107 m_back_x_alignment = "center";
108 m_back_y_alignment = "center";
109 m_back_x_padding = "10";
110 m_back_y_padding = "10";
111 m_back_justification = "left";
112 m_example_x_alignment = "left";
113 m_example_y_alignment = "top";
114 m_example_x_padding = "12";
115 m_example_y_padding = "12";
116 m_example_justification = "left";
74117 }
75118
76119 int
124167 }
125168
126169 DL((GRAPP,"Parsing the deck ...\n"));
170 m_status = CLEAN_DECK;
127171
128172 ret = parse_xml_tree (parser, error_msg);
129173 xmlFreeDoc (parser);
142186 DECKMGR->on_deck_loaded (this, LOAD_OK);
143187 }
144188
145 m_status = CLEAN_DECK;
146189 dump_deck_status ();
147190
148191 return 0;
154197 {
155198 trace_with_mask("Deck::parse_xml_tree",GUITRACE|DECK);
156199
200 char buffer[128];
157201 char xpath [64];
158202 xmlChar* result;
159203 Card* card;
160204 std::ostringstream os;
205 int illegal_count = 0;
161206
162207 result = Granule::get_node_by_xpath (parser_, "/deck/author");
163208 if (result) {
173218
174219 result = Granule::get_node_by_xpath (parser_, "/deck/sound_path");
175220 if (result) {
176 m_snd_path = Glib::locale_from_utf8 ((const char*) result);
221 DL ((APP,"/deck/sound_path = \"%s\"\n", (const char*) result));
222 if (strlen ((const char*) result) != 0) {
223 m_snd_path = Glib::locale_from_utf8 ((const char*) result);
224 m_active_snd_path = m_snd_path;
225 }
177226 xmlFree (result);
178227 }
179
180 struct stat st;
181 if (::stat (m_snd_path.c_str (), &st) != 0 || !S_ISDIR (st.st_mode)) {
182 DL((APP,"Running with sound disabled\n"));
183 DL((APP,"Path \"%s\" is wrong or non-existent\n",m_snd_path.c_str ()));
184 m_with_snd = false;
185 }
228 DL ((APP,"Loaded m_snd_path \"%s\"\n", m_snd_path.c_str ()));
229 test_active_snd_path ();
230
231 /*******************************************
232 * Load text appearance settings (optional)
233 *******************************************/
234
235 result = Granule::get_node_by_xpath (parser_, "/deck/appearance/@enabled");
236 if (result != NULL) {
237 if (!strcmp ((const char*) result, "no")) {
238 m_custom_app_enabled = false;
239 xmlFree (result);
240 goto done_appearance;
241 }
242 m_custom_app_enabled = true;
243 xmlFree (result);
244
245 if (m_custom_app_enabled) {
246 /** question font
247 */
248 result = Granule::get_node_by_xpath (parser_,
249 "/deck/appearance/fonts/@question_font");
250 if (result == NULL) {
251 goto done_appearance;
252 }
253 m_question_font = (const char*) result;
254 xmlFree (result);
255
256 /** front
257 */
258 result = Granule::get_node_by_xpath (parser_,
259 "/deck/appearance/front_app/@x_alignment");
260 if (result == NULL) {
261 goto done_appearance;
262 }
263 m_front_x_alignment = (const char*) result;
264 xmlFree (result);
265
266 result = Granule::get_node_by_xpath (parser_,
267 "/deck/appearance/front_app/@y_alignment");
268 if (result == NULL) {
269 goto done_appearance;
270 }
271 m_front_y_alignment = (const char*) result;
272 xmlFree (result);
273
274 result = Granule::get_node_by_xpath (parser_,
275 "/deck/appearance/front_app/@x_padding");
276 if (result == NULL) {
277 goto done_appearance;
278 }
279 m_front_x_padding = (const char*) result;
280 xmlFree (result);
281
282 result = Granule::get_node_by_xpath (parser_,
283 "/deck/appearance/front_app/@y_padding");
284 if (result == NULL) {
285 goto done_appearance;
286 }
287 m_front_y_padding = (const char*) result;
288 xmlFree (result);
289
290 result = Granule::get_node_by_xpath (parser_,
291 "/deck/appearance/front_app/@justification");
292 if (result == NULL) {
293 goto done_appearance;
294 }
295 m_front_justification = (const char*) result;
296 xmlFree (result);
297
298 /** back
299 */
300 result = Granule::get_node_by_xpath (parser_,
301 "/deck/appearance/back_app/@x_alignment");
302 if (result == NULL) {
303 goto done_appearance;
304 }
305 m_back_x_alignment = (const char*) result;
306 xmlFree (result);
307
308 result = Granule::get_node_by_xpath (parser_,
309 "/deck/appearance/back_app/@y_alignment");
310 if (result == NULL) {
311 goto done_appearance;
312 }
313 m_back_y_alignment = (const char*) result;
314 xmlFree (result);
315
316 result = Granule::get_node_by_xpath (parser_,
317 "/deck/appearance/back_app/@x_padding");
318 if (result == NULL) {
319 goto done_appearance;
320 }
321 m_back_x_padding = (const char*) result;
322 xmlFree (result);
323
324 result = Granule::get_node_by_xpath (parser_,
325 "/deck/appearance/back_app/@y_padding");
326 if (result == NULL) {
327 goto done_appearance;
328 }
329 m_back_y_padding = (const char*) result;
330 xmlFree (result);
331
332 result = Granule::get_node_by_xpath (parser_,
333 "/deck/appearance/back_app/@justification");
334 if (result == NULL) {
335 goto done_appearance;
336 }
337 m_back_justification = (const char*) result;
338 xmlFree (result);
339
340 /** example
341 */
342 result = Granule::get_node_by_xpath (parser_,
343 "/deck/appearance/example_app/@x_alignment");
344 if (result == NULL) {
345 goto done_appearance;
346 }
347 m_example_x_alignment = (const char*) result;
348 xmlFree (result);
349
350 result = Granule::get_node_by_xpath (parser_,
351 "/deck/appearance/example_app/@y_alignment");
352 if (result == NULL) {
353 goto done_appearance;
354 }
355 m_example_y_alignment = (const char*) result;
356 xmlFree (result);
357
358 result = Granule::get_node_by_xpath (parser_,
359 "/deck/appearance/example_app/@x_padding");
360 if (result == NULL) {
361 goto done_appearance;
362 }
363 m_example_x_padding = (const char*) result;
364 xmlFree (result);
365
366 result = Granule::get_node_by_xpath (parser_,
367 "/deck/appearance/example_app/@y_padding");
368 if (result == NULL) {
369 goto done_appearance;
370 }
371 m_example_y_padding = (const char*) result;
372 xmlFree (result);
373
374 result = Granule::get_node_by_xpath (parser_,
375 "/deck/appearance/example_app/@justification");
376 if (result == NULL) {
377 goto done_appearance;
378 }
379 m_example_justification = (const char*) result;
380 xmlFree (result);
381 }
382
383 }
384 done_appearance:
186385 dump ();
187386
188 /** Load the cards
189 */
190 for (int cards_counter = 1; ; cards_counter++) {
387 /**********************
388 * Load the cards *
389 **********************/
390
391 for (int cards_counter = 1; ; cards_counter++)
392 {
191393 sprintf (xpath, "/deck/card[%d]", cards_counter);
192394
193395 result = Granule::get_node_by_xpath (parser_, xpath);
198400 */
199401 card = new Card;
200402
403 //-----------------------------------------------------
201404 sprintf (xpath, "/deck/card[%d]/@id", cards_counter);
202405 result = Granule::get_node_by_xpath (parser_, xpath);
203406 if (result == NULL) {
209412 card->set_id (::atol ((const char*) result+1));
210413 xmlFree (result);
211414
415 //-----------------------------------------------------
212416 sprintf (xpath, "/deck/card[%d]/front", cards_counter);
213417 result = Granule::get_node_by_xpath (parser_, xpath);
214418 if (result == NULL) {
215 os << "<front> tag is missing in card # " << cards_counter
216 << "\nof the deck " << m_fname;
217 error_msg_ = os.str ();
218 return -1;
219 }
220 card->set_question ((const char*) result);
221 xmlFree (result);
419 illegal_count++;
420 sprintf (buffer, "<span foreground=\"red\" size=\"large\" "
421 "background=\"black\">Missing entry %d</span>",
422 illegal_count);
423 card->set_question (buffer);
424 mark_as_modified ();
425 }
426 else {
427 card->set_question ((const char*) result);
428 xmlFree (result);
429 }
222430
223431 sprintf (xpath, "/deck/card[%d]/front/@alt_spelling", cards_counter);
224432 result = Granule::get_node_by_xpath (parser_, xpath);
225433 if (result != NULL) {
226 card->set_alt_spelling ((const char*) result);
227 xmlFree (result);
228 }
229
434 card->set_alt_spelling (FRONT, (const char*) result);
435 xmlFree (result);
436 }
437
438 //-----------------------------------------------------
230439 sprintf (xpath, "/deck/card[%d]/back", cards_counter);
231440 result = Granule::get_node_by_xpath (parser_, xpath);
232441 if (result != NULL) { /* can be empty */
234443 xmlFree (result);
235444 }
236445
237 /** back_example node might be empty - thus non-critical.
446 sprintf (xpath, "/deck/card[%d]/back/@alt_spelling", cards_counter);
447 result = Granule::get_node_by_xpath (parser_, xpath);
448 if (result != NULL) {
449 card->set_alt_spelling (BACK, (const char*) result);
450 xmlFree (result);
451 }
452
453 /*----------------------------------------------------------
454 ** back_example node might be empty - thus non-critical.
238455 */
239456 sprintf (xpath, "/deck/card[%d]/back_example", cards_counter);
240457 result = Granule::get_node_by_xpath (parser_, xpath);
290507 }
291508 }
292509
293 /**
510 /*------------------------------------------------------------------------------
511 * import_from_csv ()
512 *
294513 * Variations:
295514 *
296515 * 1: [ ]
297516 * 2: [ ];[ ]
298517 * 3: [ ];[ ];[_________]
299518 * 4: [ ];[ ];[ ];[ ]; ... ;[______]
519 *
520 * and much more
521 *------------------------------------------------------------------------------
300522 */
301523 bool
302524 Deck::
304526 {
305527 trace_with_mask("Deck::import_from_csv",GUITRACE|DECK);
306528
307 const int size = 1024;
529 const int size = 1024;
308530 static char inbuf [size];
309 Card* card;
310 std::list<Card*> card_list;
311 std::list<Card*>::iterator clist_iter;
312
313 TimeVal t (TimeVal::gettimeofday ());
531 static char failed_fname [size];
532
533 int ret;
534 std::vector<Glib::ustring> tokens;
535 ParserState state;
536 bool bracket_flag;
537
538 Glib::ustring instream;
539 Glib::ustring question;
540 Glib::ustring answer;
541 Glib::ustring example;
542
543 std::ifstream source;
544 int ok_count = 0;
545
546 std::ofstream ffailed; // Log input that fails to parse for the user
547 int failed_count = 0; // to deal with later
548
549 ASSA::TimeVal t (ASSA::TimeVal::gettimeofday ());
314550 long card_id = t.sec ();
315551
316552 CSVImportDialog impd;
553
317554 if (impd.run () != Gtk::RESPONSE_APPLY) {
318555 return false;
319556 }
320557 impd.hide ();
321558
322 ifstream source (file_.c_str (), std::ios::in);
559 source.open (file_.c_str (), std::ios::in);
560
323561 if (!source.good ()) {
324562 Gtk::MessageDialog emsg (
325563 _("Failed to open import file.\nCheck file permissions."),
326 MESSAGE_ERROR);
564 Gtk::MESSAGE_ERROR);
327565 emsg.run ();
328566 return false;
329567 }
568
569 sprintf (failed_fname, "%s.failed", file_.c_str ());
570 ffailed.open (failed_fname, std::ios::out);
571
330572 DL ((GRAPP,"separator = %s\n", impd.get_separator ()));
331573 DL ((GRAPP,"doubld_separator = %s\n", impd.get_double_separator ()));
332574
575 state = ST_BEGIN;
576 bracket_flag = false;
577
333578 while (source) {
334 DL ((GRAPP,"-----------------------------------------\n"));
579 DL ((GRAPP,"-------------- next line --------------------\n"));
335580 source.getline (inbuf, size, '\n');
336 DL((GRAPP,"Input: \"%s\"\n", inbuf));
337
338 if (::strlen (inbuf) == 0) {
581
582 DL((GRAPP,"Input: [%s]\n", inbuf));
583 if (::strlen (inbuf) == 0 && !bracket_flag) {
339584 continue;
340585 }
586
587 DL ((GRAPP, "state = %s\n", get_state_name (state)));
341588
342589 if (impd.is_windoz_linebreak () && inbuf [strlen (inbuf)-1] == 0x0D) {
343590 inbuf [strlen (inbuf)-1] = '\0';
344591 }
345592
346 /** Remove extra adjacent separators.
593 instream = inbuf;
594 ret = split_tokens (instream,
595 tokens,
596 impd.get_separator ()[0],
597 bracket_flag);
598
599 /****************************
600 * CASE: 0 separators found *
601 ***************************/
602 if (ret == 0) {
603 if (tokens[0][0] == '"') {
604 open_double_quote (bracket_flag);
605 change_state (state); // => ST_1ST_FIELD;
606 }
607 switch (state) {
608 case ST_BEGIN:
609 question = tokens [0];
610 add_new_card (question, answer, example, card_id, ok_count);
611 break;
612 case ST_1ST_FIELD:
613 if (tokens[0][0] != '"') {
614 question += "\n";
615 }
616 question += tokens [0];
617 break;
618 case ST_2ND_FIELD:
619 answer += bracket_flag ? "\n" : "";
620 answer += tokens [0];
621 break;
622 case ST_3RD_FIELD:
623 example += bracket_flag ? "\n" : "";
624 example += tokens [0];
625 break;
626 }
627
628 if (state > ST_BEGIN) {
629 if (tokens[0][tokens[0].size()-1] == '"') {
630 close_double_quote (bracket_flag);
631 }
632 if (!bracket_flag) {
633 add_new_card (question, answer, example, card_id, ok_count);
634 reset_state (state);
635 }
636 }
637 }
638 /***************************
639 * CASE: 1 separator found *
640 **************************/
641 else if (ret == 1) {
642 if (bracket_flag) {
643 if (tokens[0][tokens[0].size()-1] != '"') {
644 DL((ASSA::ASSAERR,"Exception 11: bad input [%s]\n",inbuf));
645 ffailed << "--------------------------\n"
646 << "question: " << question << "\n"
647 << "answer : " << answer << "\n"
648 << "example : " << example << std::endl;
649 reset_state (state);
650 failed_count++;
651 continue;
652 }
653 switch (state) {
654 case ST_1ST_FIELD:
655 question += bracket_flag ? "\n" : "";
656 question += tokens [0];
657 DL ((GRAPP,"Completed parsing Question:\n%s\n",
658 question.c_str ()));
659 change_state (state); // => ST_2ND_FIELD;
660 break;
661 case ST_2ND_FIELD:
662 answer += bracket_flag ? "\n" : "";
663 answer += tokens [0];
664 change_state (state); // => ST_3RD_FIELD;
665 break;
666 case ST_3RD_FIELD:
667 DL((ASSA::ASSAERR, "Exception 12: bad input [%s]\n",inbuf));
668 ffailed << "--------------------------\n"
669 << "question: " << question << "\n"
670 << "answer : " << answer << "\n"
671 << "example : " << example << std::endl;
672 reset_state (state);
673 failed_count++;
674 continue;
675 break;
676 }
677 close_double_quote (bracket_flag);
678 }
679 else { // bracket not open
680 if (state > ST_1ST_FIELD) {
681 DL((ASSA::ASSAERR, "Exception 13: bad input [%s]\n",inbuf));
682 ffailed << "--------------------------\n"
683 << "question: " << question << "\n"
684 << "answer : " << answer << "\n"
685 << "example : " << example << std::endl;
686 reset_state (state);
687 failed_count++;
688 continue;
689 }
690 question += tokens [0];
691 state = ST_2ND_FIELD; // => ST_2ND_FIELD;
692 }
693
694 if (tokens[1][0] == '"') {
695 open_double_quote (bracket_flag);
696 }
697
698 switch (state) {
699 case ST_2ND_FIELD:
700 answer += tokens [1];
701 if (tokens[1][tokens[1].size()-1] == '"') {
702 close_double_quote (bracket_flag);
703 }
704 break;
705 case ST_3RD_FIELD:
706 example += tokens [1];
707 if (tokens[1][tokens[1].size()-1] == '"') {
708 close_double_quote (bracket_flag);
709 }
710 break;
711 }
712
713 if (!bracket_flag) {
714 add_new_card (question, answer, example, card_id, ok_count);
715 reset_state (state);
716 }
717 }
718 /***************************
719 * CASE: 2 separators fond *
720 **************************/
721 else {
722 if (bracket_flag) {
723 if (tokens[0][tokens[0].size ()-1] == '"') {
724 if (state != ST_1ST_FIELD) {
725 DL((ASSA::ASSAERR,"Exception 21: bad input [%s]\n",
726 inbuf));
727 ffailed << "--------------------------\n"
728 << "question: " << question << "\n"
729 << "answer : " << answer << "\n"
730 << "example : " << example << std::endl;
731 reset_state (state);
732 failed_count++;
733 continue;
734 }
735 question += bracket_flag ? "\n" : "";
736 question += tokens [0];
737 close_double_quote (bracket_flag);
738 }
739 }
740 else { // bracket not opened
741 change_state (state); // => ST_1ND_FIELD;
742 question = tokens [0];
743 }
744 change_state (state); // => ST_2ND_FIELD;
745
746 // Second field is always defined
747 answer = tokens[1];
748 change_state (state); // => ST_3RD_FIELD;
749
750 // Third field can span multiline
751 example = tokens[2];
752 if (tokens[2][0] == '"') {
753 open_double_quote (bracket_flag);
754 }
755 if (tokens[2][tokens[2].size ()-1] == '"') {
756 close_double_quote (bracket_flag);
757 }
758 if (!bracket_flag) { // finished record parsing
759 add_new_card (question, answer, example, card_id, ok_count);
760 change_state (state); // => ST_BEGIN;
761 }
762 }
763 } // while
764
765 source.close ();
766 ffailed.close ();
767
768 if (failed_count == 0) {
769 ::unlink (failed_fname);
770 sprintf (inbuf, "Successful records parsed: %d\n", ok_count);
771 }
772 else {
773 sprintf (inbuf, "Successful records parsed: %d\n"
774 "Failed records: %d\n"
775 "Examine failed log file\n\"%s\"\n"
776 "for syntax errors",
777 ok_count, failed_count, failed_fname);
778 }
779 Gtk::MessageDialog im (inbuf, Gtk::MESSAGE_INFO);
780 im.run ();
781
782 return true;
783 }
784
785 int
786 Deck::
787 split_tokens (const Glib::ustring& instream_,
788 std::vector<Glib::ustring>& tokens_,
789 char separator_,
790 bool bracket_flag_)
791 {
792 trace_with_mask("Deck::split_tokens",GUITRACE);
793
794 int pos_start = 0;
795 int pos_end = 0;
796 bool bracket_open = bracket_flag_;
797
798 tokens_.clear ();
799
800 for (int i = 0; i < 3; i++)
801 {
802 while (pos_end != instream_.size ())
803 {
804 DL ((CSVPARSER,"pos_start = '%c', pos_end = '%c'\n",
805 instream_[pos_start], instream_[pos_end]));
806
807 if (instream_[pos_end] == separator_ && !bracket_open) {
808 DL ((CSVPARSER,"copying [%s]\n",
809 instream_.substr (pos_start, pos_end-pos_start).c_str ()));
810 tokens_.push_back (instream_.substr (pos_start, pos_end-pos_start));
811 pos_end++;
812 pos_start = pos_end;
813 DL ((CSVPARSER,"-- next token --\n"));
814 break;
815 }
816 if (instream_[pos_end] == '"') {
817 bracket_open = !bracket_open;
818 }
819 pos_end++;
820 }
821
822 if (pos_end == instream_.size ()) {
823 break;
824 }
825 }
826
827 tokens_.push_back (instream_.substr (pos_start, pos_end));
828
829 if (tokens_.size () == 1) { DL ((GRAPP,"Case #0 (1 token)\n")); }
830 else if (tokens_.size () == 2) { DL ((GRAPP,"Case #1 (2 tokens)\n")); }
831 else if (tokens_.size () == 3) { DL ((GRAPP,"Case #2 (3 tokens)\n")); }
832
833 for (int i=0; i < tokens_.size (); i++) {
834 DL ((GRAPP,"token [%d] = [%s]\n", i, tokens_[i].c_str ()));
835 }
836
837 return (tokens_.size ()-1);
838 }
839
840 void
841 Deck::
842 add_new_card (Glib::ustring& q_,
843 Glib::ustring& a_,
844 Glib::ustring& e_,
845 long& card_id_,
846 int& ok_count_)
847 {
848 Card* card = new Card;
849 card->set_id (card_id_++);
850
851 /** Trim and replace escape characters as necessary
852 */
853 trim_escaped_quotes (q_);
854 trim_escaped_quotes (a_);
855 trim_escaped_quotes (e_);
856
857 card->set_question (q_);
858 card->set_answer (a_);
859 card->set_example (e_);
860
861 m_cards.push_back (card);
862 ok_count_++;
863 DL ((GRAPP,"*** record accepted\n"));
864
865 q_ = a_ = e_ = ""; // cleanup
866 }
867
868 void
869 Deck::
870 trim_escaped_quotes (Glib::ustring& s_)
871 {
872 static const Glib::ustring escape_char ("\"\"");
873 static const Glib::ustring escape_char2 ("\\\"");
874
875 Glib::ustring::size_type idx;
876 size_t last;
877
878 if (s_[0] == '"') {
879 s_.replace (0, 1, "");
880 }
881 last = s_.size ()-1;
882
883 if (s_[last] == '"') {
884 s_.replace (last, 1, "");
885 }
886
887 while ((idx = s_.find (escape_char)) != Glib::ustring::npos) {
888 s_.replace (idx, 1, "");
889 }
890
891 while ((idx = s_.find (escape_char2)) != Glib::ustring::npos) {
892 s_.replace (idx, 1, "");
893 }
894
895 }
896
897 void
898 Deck::
899 change_state (ParserState& state_)
900 {
901 ParserState old_state = state_;
902
903 switch (old_state) {
904 case ST_BEGIN: state_ = ST_1ST_FIELD; break;
905 case ST_1ST_FIELD: state_ = ST_2ND_FIELD; break;
906 case ST_2ND_FIELD: state_ = ST_3RD_FIELD; break;
907 case ST_3RD_FIELD: state_ = ST_BEGIN; break;
908 }
909 DL ((GRAPP,"state change %s -> %s\n",
910 get_state_name (old_state),
911 get_state_name (state_)));
912 }
913
914 void
915 Deck::
916 reset_state (ParserState& state_)
917 {
918 DL ((GRAPP,"state change %s -> ST_BEGIN\n",get_state_name (state_)));
919 state_ = ST_BEGIN;
920 }
921
922 /*------------------------------------------------------------------------------
923 * export_to_csv()
924 *------------------------------------------------------------------------------
925 */
926 bool
927 Deck::
928 export_to_csv (const string& file_)
929 {
930 trace_with_mask("Deck::export_to_csv",GUITRACE|DECK);
931
932 std::ofstream sink;
933 int ok_count = 0;
934
935 CSVExportDialog expd;
936 if (expd.run () != Gtk::RESPONSE_APPLY) {
937 return false;
938 }
939 expd.hide ();
940
941 sink.open (file_.c_str (), std::ios::out);
942
943 if (!sink.good ()) {
944 Gtk::MessageDialog emsg (
945 _("Failed to open export file.\nCheck file permissions."),
946 Gtk::MESSAGE_ERROR);
947 emsg.run ();
948 return false;
949 }
950
951 Glib::ustring sep (expd.get_separator ());
952 gunichar eol = '\n';
953 gunichar dbq = '\"';
954
955 Glib::ustring field;
956 VDeck::cardlist_const_iterator i = m_cards.begin ();
957
958 while (i != m_cards.end ())
959 {
960 /** question
347961 */
348 Glib::ustring line (inbuf);
349 Glib::ustring lhs;
350 Glib::ustring rhs;
351 Glib::ustring::size_type idx;
352
353 if (impd.consume_adjacent_separators ()) {
354 while ((idx = line.find (impd.get_double_separator ()))
355 != Glib::ustring::npos)
356 {
357 line.replace (idx, 2, impd.get_separator ());
358 }
359 }
360 card = new Card;
361 card->set_id (card_id++);
362 if ((idx = line.find (impd.get_separator ())) == Glib::ustring::npos) {
363 DL ((GRAPP,"question = \"%s\"\n", line.c_str ()));
364 card->set_question (line);
365 m_cards.push_back (card);
366 continue;
367 }
368 DL ((GRAPP,"question = \"%s\"\n", line.substr (0,idx).c_str ()));
369 card->set_question (line.substr (0, idx));
370 line.replace (0, idx+1, "");
371 DL ((GRAPP,"remains = \"%s\"\n", line.c_str ()));
372
373 if ((idx = line.find (impd.get_separator ())) == Glib::ustring::npos) {
374 DL ((GRAPP,"answer = \"%s\"\n", line.c_str ()));
375 card->set_answer (line);
376 m_cards.push_back (card);
377 continue;
378 }
379 DL ((GRAPP,"answer = \"%s\"\n", line.substr (0,idx).c_str ()));
380 card->set_answer (line.substr (0, idx));
381 line.replace (0, idx+1, "");
382 DL ((GRAPP,"remains = \"%s\"\n", line.c_str ()));
383
384 if (line.size ()) {
385 DL ((GRAPP,"example = \"%s\"\n", line.c_str ()));
386 card->set_example (line);
387 }
388 m_cards.push_back (card);
389 }
390 return true;
391 }
392
962 field = (*i)->get_question ();
963 if (field.find (sep) != Glib::ustring::npos ||
964 field.find (eol) != Glib::ustring::npos ||
965 field.find (dbq) != Glib::ustring::npos)
966 {
967 escape_double_quotes (field);
968 sink << "\"" << field.raw () << "\"";
969 }
970 else {
971 sink << field.raw ();
972 }
973 sink << sep;
974
975 /** answer
976 */
977 field = (*i)->get_answer ();
978 if (field.find (sep) != Glib::ustring::npos ||
979 field.find (eol) != Glib::ustring::npos ||
980 field.find (dbq) != Glib::ustring::npos)
981 {
982 escape_double_quotes (field);
983 sink << "\"" << field.raw () << "\"";
984 }
985 else {
986 sink << field.raw ();
987 }
988
989 /** example
990 */
991 if (expd.with_example ())
992 {
993 sink << sep;
994 field = (*i)->get_example ();
995 if (field.find (sep) != Glib::ustring::npos ||
996 field.find (eol) != Glib::ustring::npos ||
997 field.find (dbq) != Glib::ustring::npos)
998 {
999 escape_double_quotes (field);
1000 sink << "\"" << field.raw () << "\"";
1001 }
1002 else {
1003 sink << field.raw ();
1004 }
1005 }
1006 sink << std::endl;
1007 i++;
1008 ok_count++;
1009 }
1010 sink.close ();
1011
1012 char msg [64];
1013 sprintf (msg, "Saved %d CSV records", ok_count);
1014 Gtk::MessageDialog im (msg, Gtk::MESSAGE_INFO);
1015 im.run ();
1016 }
1017
1018 void
1019 Deck::
1020 escape_double_quotes (Glib::ustring& input_)
1021 {
1022 Glib::ustring output;
1023 u_int i;
1024
1025 for (i = 0; i < input_.size (); i++) {
1026 if (input_[i] == '"') {
1027 output.append ("\\");
1028 output.append ("\"");
1029 }
1030 else {
1031 output.append (1, input_[i]);
1032 }
1033 }
1034 input_ = output;
1035 }
1036
1037 /*------------------------------------------------------------------------------
1038 * erase()
1039 *------------------------------------------------------------------------------
1040 */
3931041 bool
3941042 Deck::
3951043 erase (VCard* vcard_)
4581106 trace_with_mask("Deck::save",GUITRACE|DECK);
4591107
4601108 static const char dtd_url [] = "http://granule.sourceforge.net/granule.dtd";
1109
4611110 int ret = 0;
4621111 xmlTextWriterPtr writer;
4631112 Glib::ustring alt_spell;
1113 cardlist_const_iterator citer;
1114
4641115 g_remove (m_fname.c_str ());
4651116
4661117 writer = xmlNewTextWriterFilename (m_fname.c_str (), 0);
4951146 ret = xmlTextWriterWriteElement (writer, BAD_CAST "sound_path",
4961147 BAD_CAST Glib::locale_to_utf8 (m_snd_path).c_str ());
4971148
498 cardlist_const_iterator citer = m_cards.begin ();
1149 //--------------------------------------------------------
1150 ret = xmlTextWriterStartElement (writer, BAD_CAST "appearance");
1151
1152 //--------------------------------------------------------
1153 ret = xmlTextWriterWriteAttribute (writer, BAD_CAST "enabled",
1154 BAD_CAST (m_custom_app_enabled ? "yes":"no"));
1155 //--------------------------------------------------------
1156 if (!m_custom_app_enabled) {
1157 ret = xmlTextWriterEndElement (writer); // @appearance
1158 goto skip;
1159 }
1160 //--------------------------------------------------------
1161 // Continue with Appearance attributes
1162 //
1163 ret = xmlTextWriterStartElement (writer, BAD_CAST "fonts");
1164 ret = xmlTextWriterWriteAttribute (writer, BAD_CAST "question_font",
1165 BAD_CAST m_question_font.c_str ());
1166 ret = xmlTextWriterEndElement (writer); // @fonts
1167 //--------------------------------------------------------
1168 ret = xmlTextWriterStartElement (writer, BAD_CAST "front_app");
1169 ret = xmlTextWriterWriteAttribute (writer, BAD_CAST "x_alignment",
1170 BAD_CAST m_front_x_alignment.c_str ());
1171 ret = xmlTextWriterWriteAttribute (writer, BAD_CAST "y_alignment",
1172 BAD_CAST m_front_y_alignment.c_str ());
1173 ret = xmlTextWriterWriteAttribute (writer, BAD_CAST "x_padding",
1174 BAD_CAST m_front_x_padding.c_str ());
1175 ret = xmlTextWriterWriteAttribute (writer, BAD_CAST "y_padding",
1176 BAD_CAST m_front_y_padding.c_str ());
1177 ret = xmlTextWriterWriteAttribute (writer, BAD_CAST "justification",
1178 BAD_CAST m_front_justification.c_str ());
1179 ret = xmlTextWriterEndElement (writer); // @front_app
1180 //--------------------------------------------------------
1181 ret = xmlTextWriterStartElement (writer, BAD_CAST "back_app");
1182 ret = xmlTextWriterWriteAttribute (writer, BAD_CAST "x_alignment",
1183 BAD_CAST m_back_x_alignment.c_str ());
1184 ret = xmlTextWriterWriteAttribute (writer, BAD_CAST "y_alignment",
1185 BAD_CAST m_back_y_alignment.c_str ());
1186 ret = xmlTextWriterWriteAttribute (writer, BAD_CAST "x_padding",
1187 BAD_CAST m_back_x_padding.c_str ());
1188 ret = xmlTextWriterWriteAttribute (writer, BAD_CAST "y_padding",
1189 BAD_CAST m_back_y_padding.c_str ());
1190 ret = xmlTextWriterWriteAttribute (writer, BAD_CAST "justification",
1191 BAD_CAST m_back_justification.c_str ());
1192 ret = xmlTextWriterEndElement (writer); // @back_app
1193 //--------------------------------------------------------
1194 ret = xmlTextWriterStartElement (writer, BAD_CAST "example_app");
1195 ret = xmlTextWriterWriteAttribute (writer, BAD_CAST "x_alignment",
1196 BAD_CAST m_example_x_alignment.c_str ());
1197 ret = xmlTextWriterWriteAttribute (writer, BAD_CAST "y_alignment",
1198 BAD_CAST m_example_y_alignment.c_str ());
1199 ret = xmlTextWriterWriteAttribute (writer, BAD_CAST "x_padding",
1200 BAD_CAST m_example_x_padding.c_str ());
1201 ret = xmlTextWriterWriteAttribute (writer, BAD_CAST "y_padding",
1202 BAD_CAST m_example_y_padding.c_str ());
1203 ret = xmlTextWriterWriteAttribute (writer, BAD_CAST "justification",
1204 BAD_CAST m_example_justification.c_str());
1205 ret = xmlTextWriterEndElement (writer); // @example_app
1206 //--------------------------------------------------------
1207
1208 ret = xmlTextWriterEndElement (writer); // @appearance
1209 //--------------------------------------------------------
1210
1211 skip:
1212 citer = m_cards.begin ();
4991213 while (citer != m_cards.end ())
5001214 {
1215 //--------------------------------------------------------
5011216 ret = xmlTextWriterStartElement (writer, BAD_CAST "card");
1217 //--------------------------------------------------------
5021218 ret = xmlTextWriterWriteAttribute (writer, BAD_CAST "id",
5031219 BAD_CAST (*citer)->get_id_str ().c_str ());
5041220
505 ret = xmlTextWriterStartElement (writer, BAD_CAST "front");
506
507 alt_spell = (*citer)->get_alt_spelling ();
1221 //--------------------------------------------------------
1222 ret = xmlTextWriterStartElement (writer, BAD_CAST "front"); // @start
1223
1224 alt_spell = (*citer)->get_alt_spelling (FRONT);
5081225 if (alt_spell.length () > 0) {
5091226 ret = xmlTextWriterWriteAttribute (writer, BAD_CAST "alt_spelling",
5101227 BAD_CAST alt_spell.c_str ());
5131230 BAD_CAST (*citer)->get_question ().c_str ());
5141231 ret = xmlTextWriterEndElement (writer); // @end front
5151232
516 ret = xmlTextWriterWriteElement (writer, BAD_CAST "back",
1233 //--------------------------------------------------------
1234 ret = xmlTextWriterStartElement (writer, BAD_CAST "back"); // @start
1235
1236 alt_spell = (*citer)->get_alt_spelling (BACK);
1237 if (alt_spell.length () > 0) {
1238 ret = xmlTextWriterWriteAttribute (writer, BAD_CAST "alt_spelling",
1239 BAD_CAST alt_spell.c_str ());
1240 }
1241 ret = xmlTextWriterWriteString (writer,
5171242 BAD_CAST (*citer)->get_answer ().c_str ());
518
1243 ret = xmlTextWriterEndElement (writer); // @end back
1244
1245 //--------------------------------------------------------
5191246 ret = xmlTextWriterWriteElement (writer, BAD_CAST "back_example",
5201247 BAD_CAST (*citer)->get_example ().c_str ());
5211248
5221249 ret = xmlTextWriterEndElement (writer); // @end card
5231250 citer++;
5241251 }
1252
5251253 /** Close <deck> and write out the file
5261254 */
5271255 xmlTextWriterEndElement (writer); // @end deck
5671295 Deck::
5681296 find_card_by_id (long id_)
5691297 {
570 // trace_with_mask("Deck::find_card_by_id",GUITRACE|DECK);
571
5721298 cardlist_iterator iter = m_cards.begin ();
5731299 while (iter != m_cards.end ()) {
5741300 if ((*iter)->get_id () == id_) {
5921318 */
5931319 void
5941320 Deck::
595 play_card (Deck::cardlist_iterator& iter_)
1321 play_card (SideSelection side_, Deck::cardlist_iterator& iter_)
5961322 {
5971323 trace_with_mask("Deck::play_card",GUITRACE|DECK);
1324
5981325 static char execmdbuf [1024];
599
600 if (! m_with_snd) {
601 return;
602 }
6031326 std::vector<string> v;
6041327 string w;
6051328
606 w = Glib::locale_from_utf8 ((*iter_)->get_alt_spelling ());
607 if (w.length () == 0) {
1329 if (!m_snd_enabled) {
1330 DL ((GRAPP,"Sound is disabled!\n"));
1331 return;
1332 }
1333
1334 DL ((GRAPP,"play card for side '%s'\n", (side_==FRONT?"Front":"Back")));
1335
1336 w = Glib::locale_from_utf8 ((*iter_)->get_alt_spelling (side_));
1337
1338 if (w.length () == 0)
1339 {
6081340 w = Glib::locale_from_utf8 ((*iter_)->get_question ());
6091341 ASSA::Utils::split (w.c_str (), v);
610 if (v.size () > 1) {
1342 if (v.size () > 1)
1343 {
6111344 if (v[0] != "to") {
6121345 return;
6131346 }
6141347 w = v[1];
6151348 }
6161349 }
617 string sfn (m_snd_path + G_DIR_SEPARATOR_S);
1350 string sfn (m_active_snd_path + G_DIR_SEPARATOR_S);
6181351 sfn += w[0];
619 sfn += G_DIR_SEPARATOR_S + w + ".wav";
620
621 struct stat st;
622 if (::stat (sfn.c_str (), &st) != 0 || !S_ISREG (st.st_mode)) {
623 DL((APP,"Can't stat sound file \"%s\"\n", sfn.c_str ()));
624 return;
625 }
626
627 DL((APP,"Playing \"%s\" WAV\n", sfn.c_str ()));
1352 sfn += G_DIR_SEPARATOR_S + w; /// + ".wav";
1353
1354 // struct stat st;
1355 // if (::stat (sfn.c_str (), &st) != 0 || !S_ISREG (st.st_mode)) {
1356 // DL((APP,"Can't stat sound file \"%s\"\n", sfn.c_str ()));
1357 // return;
1358 // }
1359
1360 DL((APP,"Play sound bite \"%s\"\n", sfn.c_str ()));
6281361
6291362 #if defined (WIN32)
6301363
631 PlaySound (sfn.c_str (), NULL, SND_FILENAME| SND_ASYNC);
1364 int n;
1365 const char* cmd = CONFIG->get_snd_player_cmd ();
1366 if (cmd != NULL && strlen (cmd) != 0) {
1367 n = sprintf (execmdbuf, "\"%s\" ", cmd);
1368 sprintf (execmdbuf+n, CONFIG->get_snd_player_args (), sfn.c_str ());
1369
1370 DL((GRAPP,"Win32: playing \"%s %s\"\n", execmdbuf));
1371 system (execmdbuf);
1372 }
1373 else {
1374 PlaySound (sfn.c_str (), NULL, SND_FILENAME| SND_ASYNC);
1375 }
6321376
6331377 #elif defined (IS_HILDON)
6341378
635 hildon_play_system_sound (sfn.c_str ());
1379 snprintf (execmdbuf, 512, CONFIG->get_snd_player_args (), sfn.c_str ());
1380 hildon_play_system_sound (execmdbuf);
6361381
6371382 #else /* POSIX */
6381383
6391384 snprintf (execmdbuf, 512, CONFIG->get_snd_player_args (), sfn.c_str ());
640 DL((APP,"Playing \"%s %s\"\n", CONFIG->get_snd_player_cmd (), execmdbuf));
6411385
6421386 /**
6431387 * Better yet to route WAV playing through esd (if it is running):
6471391 * We have to preserve it - otherwise, we would crash and burn.
6481392 * COLLECT_STATUS option does that for us here.
6491393 */
1394 DL((APP,"POSIX: playing \"%s %s\"\n",
1395 CONFIG->get_snd_player_cmd (), execmdbuf));
1396
1397
6501398 ASSA::Fork::fork_exec (CONFIG->get_snd_player_cmd (),
651 execmdbuf, ASSA::Fork::COLLECT_STATUS);
1399 execmdbuf, ASSA::Fork::IGNORE_STATUS);
6521400 #endif
6531401 }
6541402
7391487 }
7401488 }
7411489
1490 /** Called by the DeckInfo
1491 */
1492 void
1493 Deck::
1494 set_snd_path (const string& spath_)
1495 {
1496 trace_with_mask("Deck::set_snd_path",GUITRACE|DECK);
1497
1498 m_snd_path = Glib::locale_from_utf8 (spath_.c_str ());
1499 DL ((APP,"Testing new snd_path \"%s\"\n", m_snd_path.c_str ()));
1500
1501 if (m_snd_path.length () > 0) {
1502 m_active_snd_path = m_snd_path;
1503 }
1504 else {
1505 m_active_snd_path =
1506 Glib::filename_to_utf8(CONFIG->get_snd_archive_path ());
1507 }
1508
1509 test_active_snd_path ();
1510
1511 DL ((APP,"Updated active_snd_path \"%s\"\n", m_active_snd_path.c_str ()));
1512 }
1513
1514 /** An empty sound path in the Deck file indicates that
1515 * the Sound Settings from the application Preferences should
1516 * be used instead.
1517 */
1518 void
1519 Deck::
1520 test_active_snd_path ()
1521 {
1522 trace_with_mask("Deck::test_active_snd_path",GUITRACE|DECK);
1523
1524 if (m_active_snd_path.size () > 0)
1525 {
1526 struct stat st;
1527 if (::stat (m_active_snd_path.c_str (), &st) != 0 ||
1528 !S_ISDIR (st.st_mode))
1529 {
1530 DL((APP,"Running with sound disabled.\n"));
1531 DL((APP,"Path \"%s\" is invalid\n", m_active_snd_path.c_str ()));
1532 m_snd_enabled = false;
1533 return;
1534 }
1535 }
1536
1537 DL((APP,"Running with sound enabled.\n"));
1538 DL((APP,"sound_path=\"%s\"\n", m_active_snd_path.c_str ()));
1539 m_snd_enabled = true;
1540 }
1541
7421542 //------------------------------------------------------------------------------
743 // LEFTOVERS FOR HEAVY DEBUGGING
1543 // LEFTOVERS FROM HEAVY DEBUGGING IN THE PAST
7441544 //------------------------------------------------------------------------------
7451545 #if 0
7461546 void
11 //------------------------------------------------------------------------------
22 // Deck.h
33 //------------------------------------------------------------------------------
4 // $Id: Deck.h,v 1.25 2006/09/07 02:34:04 vlg Exp $
4 // $Id: Deck.h,v 1.34 2006/12/29 03:12:13 vlg Exp $
55 //
66 // Copyright (c) 2004 by Vladislav Grinchenko
77 //
1818 #include "VDeck.h"
1919 #include <libxml/tree.h> // xmlDocPtr
2020
21 typedef enum _ParserState {
22 ST_BEGIN,
23 ST_1ST_FIELD,
24 ST_2ND_FIELD,
25 ST_3RD_FIELD
26 } ParserState;
27
2128 class Card;
2229
2330 class Deck : public VDeck
3037 virtual int load (const string& fname_, DeckAction = INSTALL_DECK);
3138 void insert (const string& from_file_);
3239 bool import_from_csv (const string& file_);
40 bool export_to_csv (const string& file_);
3341 virtual int save ();
3442 virtual int save_as (const string& fname_);
3543
5159
5260 virtual const string& get_name (void) const { return m_fname; }
5361 virtual void get_progress (float& pct_done_, std::string& msg_, int idx_);
54 virtual void play_card (Deck::cardlist_iterator& iter_);
62 virtual void play_card (SideSelection s_, Deck::cardlist_iterator& iter_);
5563
5664 VCard* find_card_by_id (long id_);
5765 DeckEditStatus get_status ();
66
5867 const string& get_snd_path () const { return m_snd_path; }
5968 const Glib::ustring& get_author () const { return m_author; }
6069 const Glib::ustring& get_desc () const { return m_desc; }
6170
62 void set_snd_path (const string& spath_) { m_snd_path = spath_; }
71 void set_snd_path (const string& spath_);
6372 void set_author (const Glib::ustring& s_) { m_author = s_; }
6473 void set_desc (const Glib::ustring& s_) { m_desc = s_; }
6574
75 void test_active_snd_path ();
76
77 void enable_custom_appearance (bool v_ = true) { m_custom_app_enabled=v_; }
78 bool with_custom_appearance () const { return m_custom_app_enabled; }
79
80 /** Text alignment controls
81 */
82 std::string question_font () const;
83
84 std::string x_alignment (SideSelection s_) const;
85 std::string y_alignment (SideSelection s_) const;
86 std::string x_padding (SideSelection s_) const;
87 std::string y_padding (SideSelection s_) const;
88 std::string justification (SideSelection s_) const;
89
90 void question_font (const std::string& v_);
91
92 void x_alignment (SideSelection s_, const std::string& v_);
93 void y_alignment (SideSelection s_, const std::string& v_);
94 void x_padding (SideSelection s_, const std::string& v_);
95 void y_padding (SideSelection s_, const std::string& v_);
96 void justification (SideSelection s_, const std::string& v_);
97
98 /** Utility functions
99 */
66100 void mark_as_modified () { m_status = MODIFIED_DECK; }
67101 bool needs_renaming () const { return m_needs_renaming; }
68102 DeckEditStatus get_status () const { return m_status; }
78112
79113 void reset_snd_setup ();
80114
115 int split_tokens (const Glib::ustring& instream_,
116 std::vector<Glib::ustring>& tokens_,
117 char separator_,
118 bool bracket_flag_);
119
120 void trim_escaped_quotes (Glib::ustring& s_);
121 void escape_double_quotes (Glib::ustring& input_);
122 void add_new_card (Glib::ustring& q_,
123 Glib::ustring& a_,
124 Glib::ustring& e_,
125 long& card_id_,
126 int& ok_count_);
127
128 void open_double_quote (bool& flag);
129 void close_double_quote (bool& flag);
130 const char* get_state_name (ParserState state_);
131 void change_state (ParserState& state_);
132 void reset_state (ParserState& state_);
133
134 private:
135 void init_appearance ();
136
81137 private:
82138 string m_fname; // full XML file path name
83139 cardlist_type m_cards;
84140 string m_indent; // for pretty printing
85141
142 DeckEditStatus m_status;
143 bool m_needs_renaming;
144
86145 Glib::ustring m_author;
87146 Glib::ustring m_desc;
88147 SideSelection m_side_selection; // Tells which side to play next time
89148
90 string m_snd_path; // The location of WyabdcRealPeopleTTS package
91 bool m_with_snd;
92
93 DeckEditStatus m_status;
94 bool m_needs_renaming;
149 /** Active sound path is used to construct the name of the
150 * sound bite file for playing it through the sound card.
151 */
152 string m_active_snd_path;
153
154 /** True if m_active_snd_path holds a valid path
155 */
156 bool m_snd_enabled;
157
158 /** The sound path associated with the Deck. This is an alternative
159 * sound path if the user wished to overwrite the default from
160 * application preferences.
161 * It is accessible via DeckInfo dialog and is recorded in
162 * XML .dkf file. When empty, it is assumed disabled.
163 */
164 string m_snd_path;
165
166 /** Indicate if XML file carries a custom appearance definition block.
167 */
168 bool m_custom_app_enabled;
169
170 std::string m_question_font;
171
172 std::string m_front_x_alignment;
173 std::string m_front_y_alignment;
174 std::string m_front_x_padding;
175 std::string m_front_y_padding;
176 std::string m_front_justification;
177
178 std::string m_back_x_alignment;
179 std::string m_back_y_alignment;
180 std::string m_back_x_padding;
181 std::string m_back_y_padding;
182 std::string m_back_justification;
183
184 std::string m_example_x_alignment;
185 std::string m_example_y_alignment;
186 std::string m_example_x_padding;
187 std::string m_example_y_padding;
188 std::string m_example_justification;
95189 };
96190
97 /** C'tor for existing deck which would be
98 loaded later on.
99 */
100191 inline
101 Deck::
102 Deck (DeckEditStatus status_)
103 :
104 m_side_selection (FRONT),
105 m_with_snd (true),
106 m_status (status_),
107 m_needs_renaming (false)
108 {
109 trace_with_mask("Deck::Deck",GUITRACE|DECK);
110 }
111
112 inline
113 Deck::
114 ~Deck ()
192 Deck::~Deck ()
115193 {
116194 trace_with_mask("Deck::~Deck",GUITRACE|DECK);
117195 dump_deck_status ();
118196 }
119197
198 inline void
199 Deck::open_double_quote (bool& flag)
200 {
201 DL ((GRAPP,"double_bracket_flag: <true>\n"));
202 flag = true;
203 }
204
205 inline void
206 Deck::close_double_quote (bool& flag)
207 {
208 DL ((GRAPP,"double_bracket_flag: <false>\n"));
209 flag = false;
210 }
211
212 inline const char*
213 Deck::get_state_name (ParserState state_)
214 {
215 return (state_ == ST_BEGIN ? "ST_BEGIN" :
216 state_ == ST_1ST_FIELD ? "ST_1ST_FIELD" :
217 state_ == ST_2ND_FIELD ? "ST_2ND_FIELD" : "ST_3RD_FIELD");
218 }
219
220 /**-------------------------
221 **** Retrieve a property **
222 **-------------------------
223 */
224 inline std::string
225 Deck::question_font () const
226 {
227 return m_question_font;
228 }
229
230 inline std::string
231 Deck::x_alignment (SideSelection s_) const
232 {
233 if (s_ == FRONT) { return m_front_x_alignment; }
234 else if (s_ == BACK) { return m_back_x_alignment; }
235 else /* EXAMPLE */ { return m_example_x_alignment; }
236 }
237
238 inline std::string
239 Deck::y_alignment (SideSelection s_) const
240 {
241 if (s_ == FRONT) { return m_front_y_alignment; }
242 else if (s_ == BACK) { return m_back_y_alignment; }
243 else /* EXAMPLE */ { return m_example_y_alignment; }
244 }
245
246 inline std::string
247 Deck::x_padding (SideSelection s_) const
248 {
249 if (s_ == FRONT) { return m_front_x_padding; }
250 else if (s_ == BACK) { return m_back_x_padding; }
251 else /* EXAMPLE */ { return m_example_x_padding; }
252 }
253
254 inline std::string
255 Deck::y_padding (SideSelection s_) const
256 {
257 if (s_ == FRONT) { return m_front_y_padding; }
258 else if (s_ == BACK) { return m_back_y_padding; }
259 else /* EXAMPLE */ { return m_example_y_padding; }
260 }
261
262 inline std::string
263 Deck::justification (SideSelection s_) const
264 {
265 if (s_ == FRONT) { return m_front_justification; }
266 else if (s_ == BACK) { return m_back_justification; }
267 else /* EXAMPLE */ { return m_example_justification; }
268 }
269
270 /**--------------------
271 **** Set a property **
272 **--------------------
273 */
274 inline void
275 Deck::question_font (const std::string& v_)
276 {
277 m_question_font = v_;
278 }
279
280 inline void
281 Deck::x_alignment (SideSelection s_, const std::string& v_)
282 {
283 if (s_ == FRONT) { m_front_x_alignment = v_; }
284 else if (s_ == BACK) { m_back_x_alignment = v_; }
285 else /* EXAMPLE */ { m_example_x_alignment = v_; }
286 }
287
288 inline void
289 Deck::y_alignment (SideSelection s_, const std::string& v_)
290 {
291 if (s_ == FRONT) { m_front_y_alignment = v_; }
292 else if (s_ == BACK) { m_back_y_alignment = v_; }
293 else /* EXAMPLE */ { m_example_y_alignment = v_; }
294 }
295
296 inline void
297 Deck::x_padding (SideSelection s_, const std::string& v_)
298 {
299 if (s_ == FRONT) { m_front_x_padding = v_; }
300 else if (s_ == BACK) { m_back_x_padding = v_; }
301 else /* EXAMPLE */ { m_example_x_padding = v_; }
302 }
303
304 inline void
305 Deck::y_padding (SideSelection s_, const std::string& v_)
306 {
307 if (s_ == FRONT) { m_front_y_padding = v_; }
308 else if (s_ == BACK) { m_back_y_padding = v_; }
309 else /* EXAMPLE */ { m_example_y_padding = v_; }
310 }
311
312 inline void
313 Deck::justification (SideSelection s_, const std::string& v_)
314 {
315 if (s_ == FRONT) { m_front_justification = v_; }
316 else if (s_ == BACK) { m_back_justification = v_; }
317 else /* EXAMPLE */ { m_example_justification = v_; }
318 }
319
120320 #endif /* DECK_H */
00 // -*- c++ -*-
11 //------------------------------------------------------------------------------
2 // $Id: DeckInfo.cpp,v 1.10 2006/03/06 03:59:38 vlg Exp $
2 // $Id: DeckInfo.cpp,v 1.19 2007/01/14 02:59:57 vlg Exp $
33 //------------------------------------------------------------------------------
44 // DeckInfo.cpp
55 //------------------------------------------------------------------------------
2727 #include <gtkmm/table.h>
2828 #include <gtkmm/box.h>
2929 #include <gtkmm/stock.h>
30 #include <gtkmm/filechooserdialog.h>
3130 #include <gtkmm/main.h>
3231
3332 #include "Granule-main.h"
3433 #include "Granule.h"
3534 #include "DeckInfo.h"
3635 #include "Deck.h"
37
38 DeckInfo::
39 DeckInfo (Gtk::Window& parent_, Deck& deck_) :
36 #include "GrappConf.h"
37 #include "MyFolderChooseDialog.h"
38 #include "TextAlignment.h"
39
40 #include "Intern.h"
41
42 //------------------------------------------------------------------------------
43 // Useful Macros
44 //------------------------------------------------------------------------------
45
46 #define DI_SET_LABEL(l) \
47 l->set_alignment (0.5,0.5); \
48 l->set_padding (0,0); \
49 l->set_justify (Gtk::JUSTIFY_LEFT); \
50 l->set_line_wrap (false); \
51 l->set_use_markup (false); \
52 l->set_selectable (false);
53
54 #define DI_SET_ENTRY(e, t, d) \
55 e->set_flags (Gtk::CAN_FOCUS); \
56 e->set_visibility (true); \
57 e->set_editable (d); \
58 e->set_max_length (0); \
59 e->set_text (t); \
60 e->set_has_frame (true); \
61 e->set_activates_default (false);
62
63 #define DI_SET_FRAME(f,w) \
64 f->set_shadow_type (Gtk::SHADOW_ETCHED_IN); \
65 f->set_border_width (4); \
66 f->set_label_align (1, 1); \
67 f->add (*w);
68
69
70 #define DI_SET_CHECKBUTTON(b,a) \
71 b->set_flags (Gtk::CAN_FOCUS); \
72 b->set_relief (Gtk::RELIEF_NORMAL); \
73 b->set_mode (true); \
74 b->set_active (a); \
75 b->set_border_width (4); \
76 b->set_alignment (0.1, 0);
77
78 //------------------------------------------------------------------------------
79 // Class DIFontEntry
80 //------------------------------------------------------------------------------
81 DIFontEntry::
82 DIFontEntry ()
83 {
84 Gtk::Frame* fonts_frame = this;
85
86 m_font_table = Gtk::manage (new Gtk::Table (1, 3, false));
87
88 m_label = Gtk::manage(new Gtk::Label ("Question font:"));
89 m_entry = Gtk::manage(new Gtk::Entry);
90 m_button = Gtk::manage(new Gtk::Button ("Select"));
91
92 m_label->set_alignment(Gtk::ALIGN_RIGHT,Gtk::ALIGN_CENTER);
93 m_label->set_padding(0,0);
94 m_label->set_justify(Gtk::JUSTIFY_LEFT);
95 m_label->set_line_wrap(false);
96 m_label->set_use_markup(false);
97 m_label->set_selectable(false);
98
99 m_entry->set_flags(Gtk::CAN_FOCUS);
100 m_entry->set_visibility(true);
101 m_entry->set_editable(true);
102 m_entry->set_max_length(0);
103 m_entry->set_text("");
104 m_entry->set_has_frame(true);
105 m_entry->set_activates_default(false);
106 #ifdef IS_HILDON
107 m_entry->set_width_chars (26);
108 #endif
109
110 m_button->set_flags(Gtk::CAN_FOCUS);
111 int i = 0;
112
113 m_font_table->attach (*m_label,
114 0, 1, i, i+1,
115 Gtk::FILL,
116 Gtk::AttachOptions (), 2, 2);
117
118 m_font_table->attach (*m_entry,
119 1, 2, i, i+1,
120 #ifdef IS_HILDON
121 Gtk::FILL,
122 #else
123 Gtk::EXPAND|Gtk::FILL,
124 #endif
125 Gtk::AttachOptions(), 2, 2);
126
127 m_font_table->attach (*m_button,
128 2, 3, i, i+1,
129 Gtk::FILL,
130 Gtk::AttachOptions (), 2, 2);
131
132 Gtk::Label* fonts_label = Gtk::manage(new Gtk::Label("<b>Fonts</b>"));
133 fonts_label->set_padding (0,0);
134 fonts_label->set_line_wrap (false);
135 fonts_label->set_use_markup (true);
136 fonts_label->set_selectable (false);
137
138 fonts_frame->set_border_width (4);
139 fonts_frame->set_shadow_type (Gtk::SHADOW_ETCHED_IN);
140 fonts_frame->set_label_align (Gtk::ALIGN_TOP, Gtk::ALIGN_CENTER);
141 fonts_frame->set_label_widget (*fonts_label);
142 fonts_frame->add (*m_font_table);
143
144 m_button->signal_clicked().connect (
145 mem_fun (*this, &DIFontEntry::on_select_clicked));
146
147 show_all_children ();
148 }
149
150 void
151 DIFontEntry::
152 on_select_clicked ()
153 {
154 Gtk::FontSelectionDialog sfd ("Select Text Font");
155 sfd.set_font_name (m_entry->get_text ());
156
157 if (sfd.run () != Gtk::RESPONSE_OK) {
158 return;
159 }
160 m_entry->set_text (sfd.get_font_name ());
161 }
162
163 //------------------------------------------------------------------------------
164 // Class DeckInfo
165 //------------------------------------------------------------------------------
166
167 DeckInfo::
168 DeckInfo (Gtk::Window& parent_, Deck& deck_)
169 :
40170 m_deck (deck_),
41 m_author_entry (Gtk::manage (new Gtk::Entry ())),
42 m_desc_entry (Gtk::manage (new Gtk::Entry ())),
43 m_snd_path_entry (Gtk::manage (new Gtk::Entry ()))
171 m_author_entry (Gtk::manage (new Gtk::Entry ())),
172 m_desc_entry (Gtk::manage (new Gtk::Entry ())),
173 m_snd_path_entry (Gtk::manage (new Gtk::Entry ())),
174 m_appearance_changed (false)
44175 {
45176 trace_with_mask("DeckInfo::DeckInfo", GUITRACE);
46177
47 set_modal (false);
48 property_window_position ().set_value (Gtk::WIN_POS_CENTER);
49 set_resizable (true);
50 property_destroy_with_parent ().set_value (false);
51 set_has_separator (true);
52 set_title ("Deck Info");
53 set_transient_for (parent_);
178 Gtk::VBox* all_vbox;
54179
55180 Gtk::Button* cancel_button;
56181 Gtk::Button* ok_button;
57 Gtk::Button* snd_browse_button;
58
59 Gtk::Label* author_label;
60 Gtk::Label* desc_label;
61 Gtk::Label* label12;
62
63 Gtk::Alignment* alignment7;
64 Gtk::Alignment* alignment8;
65 Gtk::Alignment* alignment9;
66
67 Gtk::Table* table1;
68
69 Gtk::HBox* hbox5;
70 Gtk::VBox* vbox1;
71
72 cancel_button = Gtk::manage(new Gtk::Button (Gtk::StockID ("gtk-cancel")));
73 ok_button = Gtk::manage (new Gtk::Button (Gtk::StockID ("gtk-ok")));
74 author_label = Gtk::manage (new Gtk::Label ("Author : "));
75 alignment7 = Gtk::manage (new Gtk::Alignment (0.95, 0.5, 0, 0));
76 desc_label = Gtk::manage (new Gtk::Label ("Description : "));
77 alignment8 = Gtk::manage (new Gtk::Alignment (0.91, 0.5, 0, 0));
78
79 table1 = Gtk::manage (new Gtk::Table (2, 2, false));
80 label12 = Gtk::manage (new Gtk::Label ("Default sound path : "));
81 alignment9 = Gtk::manage (new Gtk::Alignment (0.5, 0.55, 0, 0));
82 snd_browse_button = Gtk::manage (new Gtk::Button ("Browse ..."));
83 hbox5 = Gtk::manage (new Gtk::HBox (false, 2));
84 vbox1 = Gtk::manage (new Gtk::VBox (false, 0));
85
86 cancel_button->set_flags (Gtk::CAN_FOCUS);
182
183 Gtk::Table* info_table;
184
185 Gtk::Label* author_label;
186 Gtk::Label* desc_label;
187 Gtk::Label* snd_label;
188
189 Gtk::Alignment* author_alignment;
190 Gtk::Alignment* desc_alignment;
191 Gtk::Alignment* snd_label_alignment;
192
193 Gtk::HBox* snd_path_box;
194 Gtk::VBox* snd_vbox;
195 Gtk::Frame* snd_frame;
196
197 Gtk::Frame* app_frame;
198 Gtk::VBox* app_vbox;
199
200 /** Set up the dialog itself
201 */
202 set_title (_("Deck Info"));
203 set_has_separator (true);
204
205 set_modal (true);
206
207 #ifdef IS_PDA
208 set_resizable (false);
209 Gdk::Geometry dp_geometry = { 240, 320, 240, 320, 240, 320, -1, -1, -1, -1};
210 set_geometry_hints (*this, dp_geometry,
211 Gdk::HINT_MIN_SIZE | Gdk::HINT_MAX_SIZE | Gdk::HINT_BASE_SIZE);
212 #else
213
214 #ifdef IS_HILDON
215 Gdk::Geometry dp_geometry = { 640, 480, 640, 480, 640, 480, -1, -1, -1, -1};
216 set_geometry_hints (*this, dp_geometry,
217 Gdk::HINT_MIN_SIZE | Gdk::HINT_MAX_SIZE | Gdk::HINT_BASE_SIZE);
218 #else
219 set_size_request (400, 370); // width; height
220 #endif // @IS_HILDON
221
222 set_resizable (true);
223 set_transient_for (parent_);
224
225 #endif // @IS_PDA
226
227 /** Hold everything together
228 */
229 all_vbox = Gtk::manage (new Gtk::VBox (false, 0));
230
231 /***********************
232 * Control buttons
233 ***********************/
234 cancel_button = Gtk::manage (new Gtk::Button (Gtk::StockID ("gtk-cancel")));
235 ok_button = Gtk::manage (new Gtk::Button (Gtk::StockID ("gtk-ok")));
236
237 /***********************
238 * Author/Description
239 ***********************/
240 info_table = Gtk::manage (new Gtk::Table (2, 2, false));
241
242 author_label = Gtk::manage (new Gtk::Label (_("Author: ")));
243 author_alignment = Gtk::manage (new Gtk::Alignment (Gtk::ALIGN_LEFT,
244 Gtk::ALIGN_CENTER,
245 0.2, 0));
246 desc_label = Gtk::manage (new Gtk::Label (_("Description: ")));
247 desc_alignment = Gtk::manage (new Gtk::Alignment (Gtk::ALIGN_LEFT,
248 Gtk::ALIGN_CENTER,
249 0.2, 0));
250 /*************************
251 * Sound Dictionary Path
252 *************************/
253 snd_label = Gtk::manage (new Gtk::Label (_(" Path: ")));
254 snd_label_alignment = Gtk::manage (new Gtk::Alignment (Gtk::ALIGN_LEFT,
255 Gtk::ALIGN_CENTER,
256 0.2, 0));
257
258 m_snd_browse_button = Gtk::manage (new Gtk::Button (_("Browse")));
259 snd_path_box = Gtk::manage (new Gtk::HBox (false, 2));
260 snd_vbox = Gtk::manage (new Gtk::VBox (false, 2));
261 snd_frame = Gtk::manage (new Gtk::Frame ());
262 m_enable_alt_snd = Gtk::manage (new Gtk::CheckButton (
263 _("Enable alternative sound dictionary")));
264
265 /************************
266 * Custom Appearance
267 ************************/
268 m_question_font = Gtk::manage (new DIFontEntry ());
269
270 m_enable_custom_app = Gtk::manage (new Gtk::CheckButton (
271 _("Enable custom appearance")));
272 m_inner_app_vbox = Gtk::manage (new Gtk::VBox (false, 2));
273 app_vbox = Gtk::manage (new Gtk::VBox (false, 2));
274 app_frame = Gtk::manage (new Gtk::Frame ());
275
276 MyTextAlignmentsWidget::value_list_t align_x_list;
277 align_x_list.push_back ("center");
278 align_x_list.push_back ("left");
279 align_x_list.push_back ("right");
280
281 MyTextAlignmentsWidget::value_list_t align_y_list;
282 align_y_list.push_back ("center");
283 align_y_list.push_back ("top");
284 align_y_list.push_back ("bottom");
285
286 MyTextAlignmentsWidget::value_list_t paragraph_list;
287 paragraph_list.push_back ("center");
288 paragraph_list.push_back ("left");
289 paragraph_list.push_back ("right");
290 paragraph_list.push_back ("fill");
291
292 m_front_widget=new MyTextAlignmentsWidget("<b>Front Text Alignment</b>",
293 align_x_list,
294 align_y_list,
295 paragraph_list);
296
297 m_back_widget=new MyTextAlignmentsWidget("<b>Back Text Alignment</b>",
298 align_x_list,
299 align_y_list,
300 paragraph_list);
301
302 m_example_widget=new MyTextAlignmentsWidget("<b>Example Text Alignment</b>",
303 align_x_list,
304 align_y_list,
305 paragraph_list);
306
307 load_appearance ();
308
309 m_inner_app_vbox->pack_start (*m_question_font,
310 Gtk::PACK_SHRINK, 4);
311 m_inner_app_vbox->pack_start (*(m_front_widget->frame ()),
312 Gtk::PACK_SHRINK, 4);
313 m_inner_app_vbox->pack_start (*(m_back_widget->frame ()),
314 Gtk::PACK_SHRINK, 4);
315 m_inner_app_vbox->pack_start (*(m_example_widget->frame ()),
316 Gtk::PACK_SHRINK, 4);
317
318 /*******************
319 * Control buttons
320 *******************/
321 cancel_button->set_flags (Gtk::CAN_FOCUS);
87322 cancel_button->set_relief (Gtk::RELIEF_NORMAL);
88323
89 ok_button->set_flags (Gtk::CAN_FOCUS);
324 ok_button->set_flags (Gtk::CAN_FOCUS);
90325 ok_button->set_relief (Gtk::RELIEF_NORMAL);
91326
92327 get_action_area ()->property_layout_style ().set_value (Gtk::BUTTONBOX_END);
93328
94 author_label->set_alignment (0.5,0.5);
95 author_label->set_padding (0,0);
96 author_label->set_justify (Gtk::JUSTIFY_LEFT);
97 author_label->set_line_wrap (false);
98 author_label->set_use_markup (false);
99 author_label->set_selectable (false);
100 alignment7->add (*author_label);
101
102 desc_label->set_alignment (0.5,0.5);
103 desc_label->set_padding (0,0);
104 desc_label->set_justify (Gtk::JUSTIFY_LEFT);
105 desc_label->set_line_wrap (false);
106 desc_label->set_use_markup (false);
107 desc_label->set_selectable (false);
108 alignment8->add (*desc_label);
109
110 m_author_entry->set_flags (Gtk::CAN_FOCUS);
111 m_author_entry->set_visibility (true);
112 m_author_entry->set_editable (true);
113 m_author_entry->set_max_length (0);
114 m_author_entry->set_text (m_deck.get_author ());
115 m_author_entry->set_has_frame (true);
116 m_author_entry->set_activates_default (false);
117
118 m_desc_entry->set_flags (Gtk::CAN_FOCUS);
119 m_desc_entry->set_visibility (true);
120 m_desc_entry->set_editable (true);
121 m_desc_entry->set_max_length (0);
122 m_desc_entry->set_text (m_deck.get_desc ());
123 m_desc_entry->set_has_frame (true);
124 m_desc_entry->set_activates_default (false);
125
126 table1->set_row_spacings (0);
127 table1->set_col_spacings (0);
128 table1->attach (*alignment7, 0, 1, 0, 1,
129 Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
130 table1->attach (*alignment8, 0, 1, 1, 2,
131 Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
132 table1->attach (*m_author_entry, 1, 2, 0, 1,
133 Gtk::EXPAND|Gtk::FILL, Gtk::AttachOptions (), 0, 7);
134 table1->attach (*m_desc_entry, 1, 2, 1, 2,
135 Gtk::EXPAND|Gtk::FILL, Gtk::AttachOptions (), 0, 7);
136 label12->set_alignment (0.5,0.5);
137 label12->set_padding (0,0);
138 label12->set_justify (Gtk::JUSTIFY_LEFT);
139 label12->set_line_wrap (false);
140 label12->set_use_markup (false);
141 label12->set_selectable (false);
142 alignment9->add (*label12);
143
144 m_snd_path_entry->set_flags (Gtk::CAN_FOCUS);
145 m_snd_path_entry->set_visibility (true);
146 m_snd_path_entry->set_editable (false);
147 m_snd_path_entry->set_max_length (0);
148 m_snd_path_entry->set_text (m_deck.get_snd_path ());
149 m_snd_path_entry->set_has_frame (true);
150 m_snd_path_entry->set_activates_default (false);
151
152 snd_browse_button->set_flags (Gtk::CAN_FOCUS);
153 snd_browse_button->set_relief (Gtk::RELIEF_NORMAL);
154
155 hbox5->pack_start (*alignment9);
156 hbox5->pack_start (*m_snd_path_entry, Gtk::PACK_EXPAND_WIDGET, 6);
157 hbox5->pack_start (*snd_browse_button, Gtk::PACK_SHRINK, 2);
158 vbox1->pack_start (*table1, Gtk::PACK_SHRINK, 8);
159 vbox1->pack_start (*hbox5, Gtk::PACK_SHRINK, 7);
329 DI_SET_LABEL(author_label);
330 author_alignment->add (*author_label);
331
332 DI_SET_LABEL(desc_label);
333 desc_alignment->add (*desc_label);
334
335 DI_SET_ENTRY(m_author_entry, m_deck.get_author (), true);
336 DI_SET_ENTRY(m_desc_entry, m_deck.get_desc (), true);
337
338 info_table->set_row_spacings (1);
339 info_table->set_col_spacings (1);
340
341 /** Default [xy]options is Gtk::FILL|Gtk::EXPAND
342 */
343 info_table->attach (*author_alignment, 0, 1, 0, 1, Gtk::FILL);
344 info_table->attach (*desc_alignment, 0, 1, 1, 2, Gtk::SHRINK);
345 info_table->attach (*m_author_entry, 1, 2, 0, 1);
346 info_table->attach (*m_desc_entry, 1, 2, 1, 2);
347
348 /****************
349 * Setup sound
350 ****************/
351 DI_SET_LABEL(snd_label);
352 snd_label_alignment->add (*snd_label);
353
354 std::string snd_path = m_deck.get_snd_path ();
355
356 if (snd_path.length () == 0) {
357 DI_SET_CHECKBUTTON(m_enable_alt_snd,false);
358 m_snd_browse_button->set_sensitive (false);
359 }
360 else {
361 DI_SET_CHECKBUTTON(m_enable_alt_snd,true);
362 m_snd_browse_button->set_sensitive (true);
363 }
364
365 DI_SET_ENTRY(m_snd_path_entry, m_deck.get_snd_path (), false);
366
367 m_snd_browse_button->set_flags (Gtk::CAN_FOCUS);
368 m_snd_browse_button->set_relief (Gtk::RELIEF_NORMAL);
369
370 snd_path_box->pack_start (*snd_label_alignment, Gtk::PACK_SHRINK, 2);
371 snd_path_box->pack_start (*m_snd_path_entry, Gtk::PACK_EXPAND_WIDGET, 6);
372 snd_path_box->pack_start (*m_snd_browse_button, Gtk::PACK_SHRINK, 2);
373
374 snd_vbox->pack_start (*m_enable_alt_snd, Gtk::PACK_EXPAND_WIDGET, 4);
375 snd_vbox->pack_start (*snd_path_box, Gtk::PACK_SHRINK, 4);
376
377 DI_SET_FRAME(snd_frame, snd_vbox);
378
379 /********************
380 * Setup Appearance
381 ********************/
382 bool app_enabled = m_deck.with_custom_appearance ();
383 DI_SET_CHECKBUTTON(m_enable_custom_app, app_enabled);
384 m_inner_app_vbox->set_sensitive (app_enabled);
385
386 app_vbox->pack_start (*m_enable_custom_app, Gtk::PACK_EXPAND_WIDGET, 4);
387 app_vbox->pack_start (*m_inner_app_vbox, Gtk::PACK_SHRINK, 4);
388
389 DI_SET_FRAME(app_frame, app_vbox);
390
391 /********************
392 * Pack all up
393 ********************/
394 all_vbox->pack_start (*info_table, Gtk::PACK_SHRINK, 4);
395 all_vbox->pack_start (*snd_frame, Gtk::PACK_SHRINK, 4);
396 all_vbox->pack_start (*app_frame, Gtk::PACK_SHRINK, 4);
160397
161398 get_vbox ()->set_homogeneous (false);
162399 get_vbox ()->set_spacing (0);
163 get_vbox ()->pack_start (*vbox1);
164
400
401 Gtk::ScrolledWindow* scrollw = Gtk::manage (new Gtk::ScrolledWindow);
402 scrollw->set_flags (Gtk::CAN_FOCUS);
403 scrollw->set_shadow_type (Gtk::SHADOW_NONE);
404 scrollw->set_policy (Gtk::POLICY_AUTOMATIC , Gtk::POLICY_AUTOMATIC);
405 scrollw->property_window_placement ().set_value (Gtk::CORNER_TOP_LEFT);
406
407 scrollw->add (*all_vbox);
408 get_vbox ()->pack_start (*scrollw);
409
410 /************************
411 * Initialize callbacks
412 ************************/
165413 add_action_widget (*cancel_button, -6);
166414 add_action_widget (*ok_button, -5);
167415
168 /** Initialize callbacks
169 */
170416 ok_button->signal_clicked ().connect (
171417 sigc::mem_fun (*this, &DeckInfo::on_ok_clicked));
172 snd_browse_button->signal_clicked ().connect (
418
419 m_snd_browse_button->signal_clicked ().connect (
173420 sigc::mem_fun (*this, &DeckInfo::on_browse_clicked));
174421
422 m_enable_alt_snd->signal_toggled ().connect (
423 sigc::mem_fun (*this, &DeckInfo::on_enable_snd_clicked));
424
425 m_enable_custom_app->signal_toggled ().connect (
426 sigc::mem_fun (*this, &DeckInfo::on_enable_app_clicked));
427
175428 show_all ();
176429 }
177430
178431 void
179432 DeckInfo::
433 on_enable_snd_clicked ()
434 {
435 trace_with_mask("DeckInfo::on_enable_snd_clicked", GUITRACE);
436
437 m_snd_browse_button->set_sensitive (m_enable_alt_snd->get_active ());
438 }
439
440 void
441 DeckInfo::
442 on_enable_app_clicked ()
443 {
444 trace_with_mask("DeckInfo::on_enable_app_clicked", GUITRACE);
445
446 m_inner_app_vbox->set_sensitive (m_enable_custom_app->get_active ());
447 }
448
449 void
450 DeckInfo::
180451 on_browse_clicked ()
181452 {
182453 trace_with_mask("DeckInfo::on_browse_clicked", GUITRACE);
183454
184 Gtk::FileChooserDialog f ("Select Sound Dictionary",
185 Gtk::FILE_CHOOSER_ACTION_SELECT_FOLDER);
186 #ifdef IS_HILDON
187 set_transient_for (*HILDONAPPWIN);
188 #else
189 f.set_transient_for (*this);
190 #endif
191 f.add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
192 f.add_button ("Select", Gtk::RESPONSE_OK);
193 f.set_current_folder (m_snd_path_entry->get_text () + G_DIR_SEPARATOR_S);
194 f.set_local_only ();
455 MyFolderChooseDialog f (_("Select Sound Dictionary"), this);
456
457 if (!m_snd_path_entry->get_text ().empty ()) {
458 f.set_current_folder (m_snd_path_entry->get_text() + G_DIR_SEPARATOR_S);
459 }
195460
196461 if (f.run () == Gtk::RESPONSE_OK) {
197 m_snd_path_entry->set_text (
198 Glib::filename_from_utf8 (f.get_filename ()));
462 m_snd_path_entry->set_text (Glib::filename_from_utf8(f.get_filename()));
199463 }
200464 }
201465
209473 m_deck.set_author (m_author_entry->get_text ());
210474 m_deck.mark_as_modified ();
211475 }
476
212477 if (m_deck.get_desc () != m_desc_entry->get_text ()) {
213478 m_deck.set_desc (m_desc_entry->get_text ());
214479 m_deck.mark_as_modified ();
215480 }
216 if (m_deck.get_snd_path () != m_snd_path_entry->get_text ()) {
217 m_deck.set_snd_path (m_snd_path_entry->get_text ());
481
482 DL ((APP,"[%c] enable alt snd path\n",
483 (m_enable_alt_snd->get_active () ? 'Y' : 'N')));
484
485 if (m_enable_alt_snd->get_active () == false) {
486 m_deck.set_snd_path ("");
218487 m_deck.mark_as_modified ();
219488 }
220 }
221
222
489 else {
490 if (m_deck.get_snd_path () != m_snd_path_entry->get_text ()) {
491 m_deck.set_snd_path (m_snd_path_entry->get_text ());
492 m_deck.mark_as_modified ();
493 }
494 }
495
496 if (m_enable_custom_app->get_active () == false) {
497 m_deck.enable_custom_appearance (false);
498 }
499 else {
500 m_deck.enable_custom_appearance ();
501 save_appearance ();
502 m_deck.mark_as_modified ();
503 }
504 m_appearance_changed = true;
505 }
506
507 /**-----------------------------------------------------------------------------
508 ** Algnment widgets - this needs rethinking and consolidation with
509 ** TextAlignment/GrappConf implementation (which is cut-n-paste).
510 **-----------------------------------------------------------------------------
511 */
512 void
513 DeckInfo::
514 load_appearance ()
515 {
516 m_question_font->set_font (m_deck.question_font ());
517
518 set_x_alignment (FRONT, m_deck.x_alignment (FRONT));
519 set_y_alignment (FRONT, m_deck.y_alignment (FRONT));
520 set_x_padding (FRONT, m_deck.x_padding (FRONT));
521 set_y_padding (FRONT, m_deck.y_padding (FRONT));
522 set_justification (FRONT, m_deck.justification (FRONT));
523
524 set_x_alignment (BACK, m_deck.x_alignment (BACK));
525 set_y_alignment (BACK, m_deck.y_alignment (BACK));
526 set_x_padding (BACK, m_deck.x_padding (BACK));
527 set_y_padding (BACK, m_deck.y_padding (BACK));
528 set_justification (BACK, m_deck.justification (BACK));
529
530 set_x_alignment (EXAMPLE, m_deck.x_alignment (EXAMPLE));
531 set_y_alignment (EXAMPLE, m_deck.y_alignment (EXAMPLE));
532 set_x_padding (EXAMPLE, m_deck.x_padding (EXAMPLE));
533 set_y_padding (EXAMPLE, m_deck.y_padding (EXAMPLE));
534 set_justification (EXAMPLE,m_deck.justification(EXAMPLE));
535 }
536
537 void
538 DeckInfo::
539 save_appearance ()
540 {
541 m_deck.question_font (m_question_font->get_font ());
542
543 m_deck.x_alignment (FRONT, get_x_alignment (FRONT));
544 m_deck.y_alignment (FRONT, get_y_alignment (FRONT));
545 m_deck.x_padding (FRONT, get_x_padding (FRONT));
546 m_deck.y_padding (FRONT, get_y_padding (FRONT));
547 m_deck.justification (FRONT, get_justification (FRONT));
548
549 m_deck.x_alignment (BACK, get_x_alignment (BACK));
550 m_deck.y_alignment (BACK, get_y_alignment (BACK));
551 m_deck.x_padding (BACK, get_x_padding (BACK));
552 m_deck.y_padding (BACK, get_y_padding (BACK));
553 m_deck.justification (BACK, get_justification (BACK));
554
555 m_deck.x_alignment (EXAMPLE, get_x_alignment (EXAMPLE));
556 m_deck.y_alignment (EXAMPLE, get_y_alignment (EXAMPLE));
557 m_deck.x_padding (EXAMPLE, get_x_padding (EXAMPLE));
558 m_deck.y_padding (EXAMPLE, get_y_padding (EXAMPLE));
559 m_deck.justification(EXAMPLE, get_justification(EXAMPLE));
560 }
561
562 /** Set property value
563 */
564 void
565 DeckInfo::
566 set_x_alignment (SideSelection side_, const std::string& v_)
567 {
568 int value;
569
570 if (v_ == "center") { value = TA_X_ALIGN_CENTER; }
571 else if (v_ == "left") { value = TA_X_ALIGN_LEFT; }
572 else if (v_ == "right") { value = TA_X_ALIGN_RIGHT; }
573
574 if (side_ == FRONT) {
575 m_front_widget->x_align_combo ()->set_active (value);
576 }
577 else if (side_ == BACK) {
578 m_back_widget->x_align_combo ()->set_active (value);
579 }
580 else { /* side_ == EXAMPLE */
581 m_example_widget->x_align_combo ()->set_active (value);
582 }
583 }
584
585 void
586 DeckInfo::
587 set_y_alignment (SideSelection side_, const std::string& v_)
588 {
589 int value;
590
591 if (v_ == "center") { value = TA_Y_ALIGN_CENTER; }
592 else if (v_ == "top") { value = TA_Y_ALIGN_TOP; }
593 else if (v_ == "bottom") { value = TA_Y_ALIGN_BOTTOM; }
594
595 if (side_ == FRONT) {
596 m_front_widget->y_align_combo ()->set_active (value);
597 }
598 else if (side_ == BACK) {
599 m_back_widget->y_align_combo ()->set_active (value);
600 }
601 else { /* side_ == EXAMPLE */
602 m_example_widget->y_align_combo ()->set_active (value);
603 }
604 }
605
606 void
607 DeckInfo::
608 set_x_padding (SideSelection side_, const std::string& v_)
609 {
610 if (side_ == FRONT) {
611 m_front_widget->x_padding_entry ()->set_text (v_);
612 }
613 else if (side_ == BACK) {
614 m_back_widget->x_padding_entry ()->set_text (v_);
615 }
616 else /* == EXAMPLE */ {
617 m_example_widget->x_padding_entry ()->set_text (v_);
618 }
619 }
620
621 void
622 DeckInfo::
623 set_y_padding (SideSelection side_, const std::string& v_)
624 {
625 if (side_ == FRONT) {
626 m_front_widget->y_padding_entry ()->set_text (v_);
627 }
628 else if (side_ == BACK) {
629 m_back_widget->y_padding_entry ()->set_text (v_);
630 }
631 else /* == EXAMPLE */ {
632 m_example_widget->y_padding_entry ()->set_text (v_);
633 }
634 }
635
636 void
637 DeckInfo::
638 set_justification (SideSelection side_, const std::string& v_)
639 {
640 int value;
641
642 if (v_ == "center") { value = TA_JUSTIFY_CENTER; }
643 else if (v_ == "left") { value = TA_JUSTIFY_LEFT; }
644 else if (v_ == "right") { value = TA_JUSTIFY_RIGHT; }
645 else if (v_ == "fill") { value = TA_JUSTIFY_FILL; }
646
647 if (side_ == FRONT) {
648 m_front_widget->paragraph_combo ()->set_active (value);
649 }
650 else if (side_ == BACK) {
651 m_back_widget->paragraph_combo ()->set_active (value);
652 }
653 else { /* EXAMPLE */
654 m_example_widget->paragraph_combo ()->set_active (value);
655 }
656 }
657
658 /** Get property value
659 */
660 std::string
661 DeckInfo::
662 get_x_alignment (SideSelection side_) const
663 {
664 std::string result;
665 int value;
666
667 if (side_ == FRONT) {
668 value = m_front_widget->x_align_combo ()->get_active_row_number ();
669 }
670 else if (side_ == BACK) {
671 value = m_back_widget->x_align_combo ()->get_active_row_number ();
672 }
673 else { /* side_ == EXAMPLE */
674 value = m_example_widget->x_align_combo ()->get_active_row_number ();
675 }
676
677 switch (value) {
678 case TA_X_ALIGN_CENTER: result = "center"; break;
679 case TA_X_ALIGN_LEFT: result = "left"; break;
680 case TA_X_ALIGN_RIGHT: result = "right"; break;
681 default: result = "center";
682 }
683
684 return (result);
685 }
686
687
688 std::string
689 DeckInfo::
690 get_y_alignment (SideSelection side_) const
691 {
692 std::string result;
693 int value;
694
695 if (side_ == FRONT) {
696 value = m_front_widget->y_align_combo ()->get_active_row_number ();
697 }
698 else if (side_ == BACK) {
699 value = m_back_widget->y_align_combo ()->get_active_row_number ();
700 }
701 else { /* EXAMPLE */
702 value = m_example_widget->y_align_combo ()->get_active_row_number ();
703 }
704
705 switch (value) {
706 case TA_Y_ALIGN_CENTER: result = "center"; break;
707 case TA_Y_ALIGN_TOP: result = "top"; break;
708 case TA_Y_ALIGN_BOTTOM: result = "bottom"; break;
709 default: result = "center";
710 }
711
712 return (result);
713 }
714
715 std::string
716 DeckInfo::
717 get_x_padding (SideSelection side_) const
718 {
719 if (side_ == FRONT) {
720 return m_front_widget->x_padding_entry()->get_text();
721 }
722 else if(side_ == BACK){
723 return m_back_widget->x_padding_entry()->get_text();
724 }
725 else /* == EXAMPLE */ {
726 return m_example_widget->x_padding_entry()->get_text();
727 }
728 }
729
730 std::string
731 DeckInfo::
732 get_y_padding (SideSelection side_) const
733 {
734 if (side_ == FRONT) {
735 return m_front_widget->y_padding_entry()->get_text();
736 }
737 else if(side_ == BACK){
738 return m_back_widget->y_padding_entry()->get_text();
739 }
740 else /* == EXAMPLE */ {
741 return m_example_widget->y_padding_entry()->get_text();
742 }
743 }
744
745
746 /** Get property value
747 */
748 std::string
749 DeckInfo::
750 get_justification (SideSelection side_) const
751 {
752 std::string result;
753 int value;
754
755 if (side_ == FRONT) {
756 value = m_front_widget->paragraph_combo ()->get_active_row_number ();
757 }
758 else if (side_ == BACK) {
759 value = m_back_widget->paragraph_combo ()->get_active_row_number ();
760 }
761 else { /* side_ == EXAMPLE */
762 value = m_example_widget->paragraph_combo ()->get_active_row_number ();
763 }
764
765 switch (value) {
766 case TA_JUSTIFY_CENTER: result = "center"; break;
767 case TA_JUSTIFY_LEFT: result = "left"; break;
768 case TA_JUSTIFY_RIGHT: result = "right"; break;
769 case TA_JUSTIFY_FILL: result = "fill"; break;
770 default: result = "center";
771 }
772
773 return (result);
774 }
775
00 // -*- c++ -*-
11 //------------------------------------------------------------------------------
2 // $Id: DeckInfo.h,v 1.4 2005/01/17 04:19:46 vlg Exp $
2 // $Id: DeckInfo.h,v 1.8 2007/01/01 01:00:36 vlg Exp $
33 //------------------------------------------------------------------------------
44 // DeckInfo.h
55 //------------------------------------------------------------------------------
2222 #endif
2323
2424 #include <gtkmm/dialog.h>
25 #include <gtkmm/checkbutton.h>
26 #include <gtkmm/box.h>
2527
28 class Gtk::Entry;
2629 class Deck;
27 class Gtk::Entry;
30 class AppearancePrefs;
31 class MyTextAlignmentsWidget;
2832
33 //------------------------------------------------------------------------------
34 // Class FontEntry (duplicate from AppearancePrefs.h)
35 //------------------------------------------------------------------------------
36 // Compound Font Entry
37 //
38 // +-------+-------+---------------------------+
39 // | Label | Entry | Select Font Dialog Button |
40 // +-------+-------+---------------------------+
41 //------------------------------------------------------------------------------
42 class DIFontEntry : public Gtk::Frame
43 {
44 public:
45 DIFontEntry ();
46
47 void on_select_clicked ();
48
49 void set_font (const std::string& v_);
50 std::string get_font () const;
51
52 private:
53 Gtk::Table* m_font_table;
54
55 Gtk::Label* m_label;
56 Gtk::Entry* m_entry; // Font entry
57 Gtk::Button* m_button; // Font Dialog selection button
58 Pango::FontDescription m_question_font_desc;
59 };
60
61 inline void
62 DIFontEntry::
63 set_font (const std::string& v_)
64 {
65 m_entry->set_text (v_);
66 }
67
68 inline std::string
69 DIFontEntry::
70 get_font () const
71 {
72 return (m_entry->get_text ().c_str ());
73 }
74
75 //------------------------------------------------------------------------------
76 // Class DeckInfo
77 //------------------------------------------------------------------------------
2978 class DeckInfo : public Gtk::Dialog
3079 {
3180 public:
3382
3483 void on_ok_clicked ();
3584 void on_browse_clicked ();
85 void on_enable_snd_clicked ();
86 void on_enable_app_clicked ();
87
88 bool appearance_changed () const { return m_appearance_changed; }
89
90 private:
91 void load_appearance ();
92 void save_appearance ();
93
94 void set_question_font (const std::string& v_);
95 std::string get_question_font () const;
96
97 void set_x_alignment (SideSelection side_, const std::string& v_);
98 void set_y_alignment (SideSelection side_, const std::string& v_);
99 void set_x_padding (SideSelection side_, const std::string& v_);
100 void set_y_padding (SideSelection side_, const std::string& v_);
101 void set_justification (SideSelection side_, const std::string& v_);
102
103 std::string get_x_alignment (SideSelection side_) const;
104 std::string get_y_alignment (SideSelection side_) const;
105 std::string get_x_padding (SideSelection side_) const;
106 std::string get_y_padding (SideSelection side_) const;
107 std::string get_justification (SideSelection side_) const;
36108
37109 private:
38110 Deck& m_deck;
111
112 /** Origin
113 */
39114 Gtk::Entry* m_author_entry;
40115 Gtk::Entry* m_desc_entry;
41116 Gtk::Entry* m_snd_path_entry;
117
118 /** Custom sound preferences
119 */
120 Gtk::Button* m_snd_browse_button;
121 Gtk::CheckButton* m_enable_alt_snd;
122
123 /** Custom appearance
124 */
125 Gtk::CheckButton* m_enable_custom_app;
126 Gtk::VBox* m_inner_app_vbox;
127
128 MyTextAlignmentsWidget* m_front_widget;
129 MyTextAlignmentsWidget* m_back_widget;
130 MyTextAlignmentsWidget* m_example_widget;
131
132 DIFontEntry* m_question_font;
133 bool m_appearance_changed;
42134 };
43135
44136 #endif
00 // -*- c++ -*-
11 //------------------------------------------------------------------------------
2 // $Id: DeckList.cpp,v 1.18 2006/09/21 01:25:20 vlg Exp $
2 // $Id: DeckList.cpp,v 1.21 2006/12/11 03:07:22 vlg Exp $
33 //------------------------------------------------------------------------------
44 // DeckList.cpp
55 //------------------------------------------------------------------------------
6262 int cnt = m_tree_view.append_column ("Decks", m_columns.m_name);
6363 Gtk::TreeViewColumn* column = m_tree_view.get_column (cnt - 1);
6464 column->set_sizing (Gtk::TREE_VIEW_COLUMN_FIXED);
65 column->set_fixed_width (140);
65 // column->set_fixed_width (60);
6666 column->set_resizable ();
6767
6868 /** Enable column sorting
113113 /** Add Popup Menu dialog
114114 */
115115 MenuList& d = m_popup_menu.items ();
116
117 d.push_back (MenuElem ("Insert",
116
117 d.push_back (MenuElem ("Insert from Deck",
118118 mem_fun (*DECKMGR, &DeckManager::insert_deck_cb)));
119
120 d.push_back (SeparatorElem ()); /*-----------------------------------*/
121
119122 d.push_back (MenuElem ("Import from CSV",
120123 mem_fun (*DECKMGR, &DeckManager::import_deck_cb)));
124 d.push_back (MenuElem ("Export to CSV",
125 mem_fun (*DECKMGR, &DeckManager::export_deck_cb)));
126
121127 d.push_back (SeparatorElem ()); /*-----------------------------------*/
128
122129 d.push_back (MenuElem ("Save",
123130 mem_fun (*DECKMGR, &DeckManager::save_deck_cb)));
124131 d.push_back (MenuElem ("Save As",
125132 mem_fun (*DECKMGR, &DeckManager::save_as_deck_cb)));
133
126134 d.push_back (SeparatorElem ()); /*-----------------------------------*/
135
127136 d.push_back (MenuElem ("Play/Edit",
128137 mem_fun (*DECKMGR, &DeckManager::play_deck_cb)));
138
129139 /**----------------------------
130140 * [Deck]->[Add2Box] SubMenu
131141 */
00 // -*- c++ -*-
11 // Generated by assa-genesis
22 //------------------------------------------------------------------------------
3 // $Id: DeckManager.cpp,v 1.40 2006/09/21 01:25:20 vlg Exp $
3 // $Id: DeckManager.cpp,v 1.48 2007/01/15 04:09:08 vlg Exp $
44 //------------------------------------------------------------------------------
55 // DeckManager.cpp
66 //------------------------------------------------------------------------------
3030 #include "GrappConf.h"
3131 #include "CardRef.h"
3232 #include "CardBox.h"
33 #include "MyFileOpenDialog.h"
34 #include "MyFileSaveDialog.h"
35
36 // i18n macros - always last
37 #include "Intern.h"
38
39 static const char* DECK_REQEUST = "Select a Deck from the DeckList first";
40
41 #ifdef WIN32
42 extern char* dirname (const char* path_);
43 extern char* basename (const char* path_);
44 #endif
3345
3446 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
3547 // Toolbar callbacks
7991 }
8092 }
8193 else {
82 Gtk::MessageDialog w ("Select a deck from the list first", false,
83 MESSAGE_WARNING);
94 Gtk::MessageDialog w (_(DECK_REQEUST), false, MESSAGE_WARNING);
8495 w.run ();
8596 }
8697 }
137148 {
138149 trace_with_mask("DeckManager::open_deck_cb", GUITRACE);
139150
140 Gtk::FileChooserDialog f ("Select Deck File",
141 Gtk::FILE_CHOOSER_ACTION_OPEN);
142 #ifdef IS_HILDON
143 f.set_transient_for (*HILDONAPPWIN);
144 #else
145 f.set_transient_for (*MAINWIN);
146 #endif
147 f.add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
148 f.add_button ("Select", Gtk::RESPONSE_OK);
149
150 DL((GRAPP,"filesel_path=\"%s\"\n", CONFIG->get_filesel_path ().c_str ()));
151 f.set_current_folder (CONFIG->get_filesel_path ());
152 f.set_local_only ();
153
154 Gtk::FileFilter fcd_filter;
155 fcd_filter.set_name ("DeckFile");
156 fcd_filter.add_pattern ("*" DECK_FILE_EXT);
157 f.set_filter (fcd_filter);
158
151 MyFileOpenDialog f (_("Select Deck File"), MAINWIN,
152 "DeckFile", "*" DECK_FILE_EXT);
153 f.set_select_multiple ();
159154 if (f.run () != Gtk::RESPONSE_OK) {
160155 return;
161156 }
162157 f.hide ();
163158
164 DeckList::iterator iter = DECKLIST->begin ();
165 while (iter != DECKLIST->end ()) {
166 if (f.get_filename () == DECKLIST->get_deck (iter)->get_name ()) {
167 Gtk::MessageDialog msg ("The Deck you have selected\n"
168 "is already loaded.", false, MESSAGE_INFO);
169 msg.run ();
170 return;
171 }
172 iter++;
173 }
174
175 Deck* deck = new Deck (INVALID_DECK);
176 if (deck->load (f.get_filename ()) == 0) {
177 CONFIG->set_filesel_path (f.get_filename ());
159 /** Handle multiple selection
160 */
161 Glib::ustring fname;
162 DeckList::iterator dl_iter;
163
164 std::vector<Glib::ustring> answer_list = f.get_filenames ();
165 std::vector<Glib::ustring>::const_iterator citer = answer_list.begin ();
166
167 while (citer != answer_list.end ()) {
168 fname = (*citer);
169 dl_iter = DECKLIST->begin ();
170 while (dl_iter != DECKLIST->end ()) {
171 if (fname == DECKLIST->get_deck (dl_iter)->get_name ()) {
172 Gtk::MessageDialog msg (_("The Deck you have selected\n"
173 "is already loaded."),
174 false, MESSAGE_INFO);
175 msg.run ();
176 }
177 dl_iter++;
178 }
179 Deck* deck = new Deck (INVALID_DECK);
180 if (deck->load (fname) == 0) {
181 CONFIG->set_filesel_path (fname);
182 }
183 citer++;
178184 }
179185 }
180186
187193 trace_with_mask("DeckManager::insert_deck_cb", GUITRACE);
188194
189195 Deck* selected = DECKLIST->get_selected ();
190 if (selected == NULL) {
191 Gtk::MessageDialog w ("Select a deck from the list first", false,
192 MESSAGE_WARNING);
193 w.run ();
194 }
195 else {
196 Gtk::FileChooserDialog f ("Select a Deck to Insert",
197 Gtk::FILE_CHOOSER_ACTION_OPEN);
198 #ifdef IS_HILDON
199 f.set_transient_for (*HILDONAPPWIN);
200 #else
201 f.set_transient_for (*MAINWIN);
202 #endif
203 f.add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
204 f.add_button ("Select", Gtk::RESPONSE_OK);
205 f.set_current_folder (CONFIG->get_filesel_path ());
206 f.set_local_only ();
207
208 Gtk::FileFilter fcd_filter;
209 fcd_filter.set_name ("DeckFile");
210 fcd_filter.add_pattern ("*" DECK_FILE_EXT);
211 f.set_filter (fcd_filter);
212
213 if (f.run () == Gtk::RESPONSE_OK) {
196
197 if (selected == NULL)
198 {
199 Gtk::MessageDialog w (_(DECK_REQEUST), false, MESSAGE_WARNING);
200 w.run ();
201 }
202 else {
203 MyFileOpenDialog f (_("Select a Deck to Insert"), MAINWIN,
204 "DeckFile", "*" DECK_FILE_EXT);
205
206 if (f.run () == Gtk::RESPONSE_OK)
207 {
214208 selected->insert (f.get_filename ());
215209 CONFIG->set_filesel_path (f.get_filename ());
216210 DeckPlayerVectorIter iter = m_players.begin ();
217 while (iter != m_players.end ()) {
211
212 while (iter != m_players.end ())
213 {
218214 if (selected == dynamic_cast<Deck*>((*iter)->get_deck ())) {
219215 m_players.erase (iter);
220216 break;
236232
237233 Deck* selected = DECKLIST->get_selected ();
238234 if (selected == NULL) {
239 Gtk::MessageDialog w ("Select a deck from the list first", false,
240 MESSAGE_WARNING);
235 Gtk::MessageDialog w (_(DECK_REQEUST), false, MESSAGE_WARNING);
241236 w.run ();
242237 return;
243238 }
244 Gtk::FileChooserDialog f ("Select File To Import",
245 Gtk::FILE_CHOOSER_ACTION_OPEN);
246 #ifdef IS_HILDON
247 f.set_transient_for (*HILDONAPPWIN);
248 #else
249 f.set_transient_for (*MAINWIN);
250 #endif
251 f.add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
252 f.add_button ("Select", Gtk::RESPONSE_OK);
253 f.set_current_folder (CONFIG->get_filesel_path ());
254 f.set_local_only ();
255
256 if (f.run () == Gtk::RESPONSE_OK) {
239
240 MyFileOpenDialog f (_("Select File To Import from"), MAINWIN);
241
242 /** If response is OK and conversion was successful,
243 * recreate the DeckPlayer (which is a View of the Deck).
244 * Find the old one and nuke it. Then create a new DeckPlayer
245 */
246 if (f.run () == Gtk::RESPONSE_OK)
247 {
257248 f.hide ();
258249 if (selected->import_from_csv (f.get_filename ()) == false) {
259250 return;
260251 }
252
261253 CONFIG->set_filesel_path (f.get_filename ());
262254 DeckPlayerVectorIter iter = m_players.begin ();
255
263256 while (iter != m_players.end ()) {
264257 if (selected == dynamic_cast<Deck*>((*iter)->get_deck ())) {
265258 m_players.erase (iter);
268261 iter++;
269262 }
270263 m_players.push_back (new DeckPlayer (*selected));
264
265 /** This is a rather sour spot based purely on speculations:
266 *
267 * When importing from a CSV file, if the second card has a
268 * UTF-8 2 byte string, then going from the first card to the
269 * second without first flipping the first card kills the
270 * application with:
271 *
272 * glibmm-CRITICAL **:
273 * unhandled exception (type Glib::Error) in signal handler:
274 * domain: g_convert_error
275 * code : 1
276 * what : Invalid byte sequence in conversion input
277 *
278 * If, however, the first card is flipped, then going to the
279 * next does no harm. I suspect, some Glib events are queued and
280 * not processed.
281 *
282 * Flushing the event queue seems to cure this problem.
283 */
284 while (Gtk::Main::instance ()->events_pending ()) {
285 Gtk::Main::instance ()->iteration ();
286 }
287 }
288 }
289
290 /** Export cards to CSV-formatted file
291 */
292 void
293 DeckManager::
294 export_deck_cb ()
295 {
296 trace_with_mask("DeckManager::export_deck_cb", GUITRACE);
297
298 Deck* selected = DECKLIST->get_selected ();
299 if (selected == NULL) {
300 Gtk::MessageDialog w (_(DECK_REQEUST), false, MESSAGE_WARNING);
301 w.run ();
302 return;
303 }
304
305 MyFileSaveDialog f (_("Select File To Export to"), MAINWIN);
306
307 std::string::size_type idx;
308 std::string fname = basename (selected->get_name ().c_str ());
309 if ((idx = fname.find (DECK_FILE_EXT)) != string::npos) {
310 fname.replace (idx, idx+3, ".csv");
311 }
312 else {
313 fname += ".csv";
314 }
315
316 f.set_current_name (fname);
317
318 if (f.run () == Gtk::RESPONSE_OK) {
319 selected->export_to_csv (f.get_filename ());
320 CONFIG->set_filesel_path (f.get_filename ());
271321 }
272322 }
273323
276326 save_deck_cb ()
277327 {
278328 trace_with_mask("DeckManager::save_deck_cb", GUITRACE);
329
279330 Deck* selected = DECKLIST->get_selected ();
280331 if (selected != NULL) {
281332 if (selected->needs_renaming ()) {
286337 }
287338 }
288339 else {
289 Gtk::MessageDialog w ("Select a deck from the list first", false,
290 MESSAGE_WARNING);
340 Gtk::MessageDialog w (_(DECK_REQEUST), false, MESSAGE_WARNING);
291341 w.run ();
292342 }
293343 }
301351 bool save_all = false;
302352 DeckEditStatus dstat;
303353 DeckList::iterator iter = DECKLIST->begin ();
354 string fname;
304355
305356 DL((GRAPP,"Number of Decks in DeckList=%d\n", DECKLIST->size ()));
306357
315366
316367 if (DECKLIST->deck_needs_renaming (iter))
317368 {
318 Gtk::FileChooserDialog f ("Save New Deck",
319 Gtk::FILE_CHOOSER_ACTION_SAVE);
320 #ifdef IS_HILDON
321 f.set_transient_for (*HILDONAPPWIN);
322 #else
323 f.set_transient_for (*MAINWIN);
324 #endif
325 f.add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
326 f.add_button ("Save", Gtk::RESPONSE_OK);
327 f.set_current_folder (CONFIG->get_filesel_path ());
328 f.set_local_only ();
329
330 Gtk::FileFilter fcd_filter;
331 fcd_filter.set_name ("DeckFile");
332 fcd_filter.add_pattern ("*" DECK_FILE_EXT);
333
334 f.set_filter (fcd_filter);
369 MyFileSaveDialog f (_("Save New Deck"), MAINWIN,
370 "DeckFile", "*" DECK_FILE_EXT);
371
372 fname = basename (DECKLIST->get_deck (iter)->get_name ().c_str ());
373 f.set_current_name (fname);
335374
336375 if (f.run () == Gtk::RESPONSE_OK)
337376 {
338 DECKLIST->get_deck (iter)->save_as (f.get_filename ());
377 fname = f.get_filename ();
378 if (fname.find (DECK_FILE_EXT) == string::npos) {
379 fname += DECK_FILE_EXT;
380 }
381 DECKLIST->get_deck (iter)->save_as (fname);
339382 CONFIG->set_filesel_path (f.get_filename ());
340383 }
341384 }
348391 }
349392 Gtk::MessageDialog qm (
350393 "Deck \"" + DECKLIST->get_name (iter) +
351 "\" has been modified.\nWould you like to save it?",
394 "\" has been modified."
395 "\nWould you like to save it?",
352396 false,
353397 Gtk::MESSAGE_QUESTION,
354398 Gtk::BUTTONS_NONE,
378422 trace_with_mask("DeckManager::save_as_deck_cb", GUITRACE);
379423
380424 Deck* selected = DECKLIST->get_selected ();
381
382 if (selected != NULL) {
383 Gtk::FileChooserDialog f ("Save Deck As",
384 Gtk::FILE_CHOOSER_ACTION_SAVE);
385 f.add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
386 f.add_button ("Save", Gtk::RESPONSE_OK);
387 f.set_current_folder (CONFIG->get_filesel_path ());
388 f.set_local_only ();
389
390 Gtk::FileFilter fcd_filter;
391 fcd_filter.set_name ("DeckFile");
392 fcd_filter.add_pattern ("*" DECK_FILE_EXT);
393 f.set_filter (fcd_filter);
425 string ext (DECK_FILE_EXT);
426
427 if (selected != NULL)
428 {
429 MyFileSaveDialog f (_("Save Deck As"), MAINWIN,
430 "DeckFile", "*" DECK_FILE_EXT);
431
432 std::string::size_type idx;
433 std::string fname = basename (selected->get_name ().c_str ());
434 if ((idx = fname.find (ext)) != string::npos) {
435 fname.replace (idx, idx+3, "(copy).dkf");
436 }
437 else {
438 fname += "(copy).dkf";
439 }
440 f.set_current_name (fname);
394441
395442 if (f.run () == Gtk::RESPONSE_OK) {
396 selected->save_as (f.get_filename ());
443 fname = f.get_filename ();
444 if (fname.find (ext) == string::npos) {
445 fname += ext;
446 }
447 selected->save_as (fname);
397448 DECKLIST->refresh_selected_name ();
398449 CONFIG->set_filesel_path (f.get_filename ());
399450 }
400451 }
401452 else {
402 Gtk::MessageDialog w ("Select a deck from the list first", false,
403 MESSAGE_WARNING);
453 Gtk::MessageDialog w (_(DECK_REQEUST), false, MESSAGE_WARNING);
404454 w.run ();
405455 }
406456 }
422472 CARDBOX->add_deck_to_box (idx_, selected);
423473 }
424474 else {
425 Gtk::MessageDialog w ("Select a deck from the list first",
426 false,
427 MESSAGE_WARNING);
475 Gtk::MessageDialog w (_(DECK_REQEUST), false, MESSAGE_WARNING);
428476 w.run ();
429477 }
430478 }
00 // -*- c++ -*-
11 // Generated by assa-genesis
22 //------------------------------------------------------------------------------
3 // $Id: DeckManager.h,v 1.13 2005/05/16 03:02:02 vlg Exp $
3 // $Id: DeckManager.h,v 1.14 2006/11/13 01:05:17 vlg Exp $
44 //------------------------------------------------------------------------------
55 // DeckManager.h
66 //------------------------------------------------------------------------------
4545 void play_deck_cb ();
4646 void insert_deck_cb ();
4747 void import_deck_cb ();
48 void export_deck_cb ();
4849 void open_deck_cb ();
4950 void save_deck_cb ();
5051 void save_as_deck_cb ();
00 // -*- c++ -*-
11 //------------------------------------------------------------------------------
2 // $Id: DeckPlayer.cpp,v 1.102 2006/10/08 02:46:30 vlg Exp $
2 // $Id: DeckPlayer.cpp,v 1.122 2007/01/14 02:59:57 vlg Exp $
33 //------------------------------------------------------------------------------
44 // DeckPlayer.cpp
55 //------------------------------------------------------------------------------
5050 " "
5151 };
5252
53 enum { CHECK_ANSWER, NEXT, CORRECT, INCORRECT, EMPTY };
53 enum {
54 CHECK_ANSWER,
55 NEXT,
56 CORRECT,
57 INCORRECT,
58 EMPTY
59 };
5460
5561 static const gchar* states [] = { "VC_START", "VC_ARMED", "VC_VALIDATED" };
62
63 static const int QUESTION_PADDING_X =4; // Distance between text and an edge
64 static const int QUESTION_PADDING_Y =0; // Distance between text and an edge
65
66 static const int EXAMPLE_PADDING_X =2; // Distance between text and an edge
67 static const int EXAMPLE_PADDING_Y =0; // Distance between text and an edge
68
69 #ifdef IS_PDA
70 static const int ANSWER_BOX_SPACING =0; // How far box is placed from the edge
71 static const int ANSWER_CHILD_SPACING =0; // Spacing between child widgets
72 #else
73 static const int ANSWER_BOX_SPACING =4;
74 static const int ANSWER_CHILD_SPACING =4;
75 #endif
76
77 #if defined(IS_PDA) && (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION >= 6)
78 # define DP_SHRINK_ICONS ,10,10,false
79 #else
80 # define DP_SHRINK_ICONS
81 #endif
82
83 static int ustring_to_int (const ustring& s_)
84 {
85 return (::atoi (s_.c_str ()));
86 }
87
88 /*******************************************************************************
89 * TestLineEntry Member Functions *
90 *******************************************************************************
91 */
92 TestLineEntry::
93 TestLineEntry (VerifyControl* vc_)
94 :
95 m_adjustment (1, 1, 10),
96 m_label (_("Test line: "))
97 {
98 #ifdef IS_PDA
99 m_entry.set_flags (Gtk::CAN_FOCUS);
100 m_entry.set_visibility (true);
101 m_entry.set_editable (true);
102 m_entry.set_has_frame (false);
103 m_entry.set_activates_default (false); // Don't close dialog on [Enter]
104 m_entry.set_max_length (1);
105 m_entry.set_width_chars (1);
106 m_entry.set_text ("1");
107
108 pack_start (m_entry, Gtk::PACK_SHRINK, 0);
109
110 m_entry.signal_changed ().connect (
111 mem_fun (*vc_, &VerifyControl::on_test_line_changed));
112 #else
113 m_test_line_button.set_adjustment (m_adjustment);
114 pack_start (m_label, Gtk::PACK_SHRINK, 0);
115 pack_start (m_test_line_button, Gtk::PACK_SHRINK, 0);
116
117 m_test_line_button.signal_value_changed ().connect (
118 mem_fun (*vc_, &VerifyControl::on_test_line_changed));
119 #endif
120
121 vc_->attach (this);
122 vc_->set_focus_on_entry ();
123 }
124
125 int
126 TestLineEntry::
127 get_value_as_int () const
128 {
129 int v;
130
131 #ifdef IS_PDA
132 Glib::ustring s = m_entry.get_text ();
133 DL ((GRAPP,"TestLineEntry::get_value_as_int: s=\"%s\"\n", s.c_str ()));
134 if (s == "" || s == "0") {
135 v = 1;
136 TestLineEntry* tle_ptr = const_cast<TestLineEntry*> (this);
137 tle_ptr->m_entry.set_text ("1");
138 }
139 else {
140 v = ::atoi (s.c_str ());
141 }
142 #else
143 v = m_test_line_button.get_value_as_int ();
144 #endif
145
146 return (v);
147 }
148
149
150 /*******************************************************************************
151 * SideFlipControl Member Functions *
152 *******************************************************************************
153 */
154 SideFlipControl::
155 SideFlipControl (DeckPlayer& parent_)
156 : m_parent (parent_)
157 {
158 #ifdef IS_PDA
159 m_flip_button.set_flags (Gtk::CAN_FOCUS);
160 m_flip_button.set_relief (Gtk::RELIEF_NORMAL);
161
162 m_flip_button.set_label ("F");
163 m_side = FRONT;
164
165 m_flip_button.signal_clicked ().connect (
166 mem_fun (*this, &SideFlipControl::on_flip_button_clicked));
167
168 add (m_flip_button);
169
170 #else // Desktop, Hildon
171
172 Gtk::RadioButton::Group group;
173
174 m_radio_fb.set_group (group);
175 m_radio_bb.set_group (group);
176
177 m_radio_fb.set_label (_("Ask front"));
178 m_radio_bb.set_label (_("Ask back"));
179
180 m_button_box.pack_end (m_radio_fb, false, false, 1);
181 m_button_box.pack_end (m_radio_bb, false, false, 1);
182
183 m_radio_fb.signal_clicked ().connect (bind<SideSelection>(
184 mem_fun (parent_, &DeckPlayer::on_radio_selected), FRONT));
185 m_radio_bb.signal_clicked ().connect (bind<SideSelection>(
186 mem_fun (parent_, &DeckPlayer::on_radio_selected), BACK));
187
188 #ifndef IS_HILDON
189 m_button_box.set_homogeneous ();
190 m_button_box.set_spacing (1);
191 #endif
192
193 add (m_button_box);
194 #endif
195 }
196
197 void
198 SideFlipControl::
199 set_active (SideSelection s_)
200 {
201 #ifdef IS_PDA
202 if (s_ != m_side) {
203 on_flip_button_clicked ();
204 }
205 #else
206 if (s_ == FRONT) {
207 m_radio_fb.set_active ();
208 }
209 else {
210 m_radio_bb.set_active ();
211 }
212 #endif
213 }
214
215 void
216 SideFlipControl::
217 on_flip_button_clicked ()
218 {
219 #ifdef IS_PDA
220 if (m_side == FRONT) {
221 m_flip_button.set_label ("B");
222 m_parent.on_radio_selected (BACK);
223 m_side = BACK;
224 }
225 else {
226 m_flip_button.set_label ("F");
227 m_parent.on_radio_selected (FRONT);
228 m_side = FRONT;
229 }
230 #endif
231 }
56232
57233 /*******************************************************************************
58234 * VerifyControl Member Functions *
235 * *
236 * Widget composition: *
237 * ================== *
238 * Table *
239 * +--hbox1 *
240 * | +--Entry (m_entry) <-- modify_base/text *
241 * | +--Button (m_button) *
242 * | +--Label (blank1) *
243 * | *
244 * +--hbox2 *
245 * +--EventBox (m_report_box) *
246 * | +--Label (m_report) *
247 * +--Label (blank2) *
248 * *
59249 *******************************************************************************
60250 */
61251 VerifyControl::
77267 Gtk::Table* table = this;
78268
79269 m_report = Gtk::manage (new Gtk::Label);
270
80271 m_report->set_alignment (0, 0.5);
81272 m_report->set_padding (0,0);
82273 m_report->set_justify (Gtk::JUSTIFY_FILL);
83274 m_report->set_line_wrap (false);
84275 m_report->set_use_markup (false);
85276 m_report->set_selectable (false);
277 #if !defined (IS_PDA)
86278 m_report->set_size_request (80, -1); // width, height
279 #endif
87280 m_report->set_text (clabels [EMPTY]);
88281 m_report->set_sensitive (false);
89282
100293 m_entry->set_activates_default (false);
101294 m_entry->modify_font (CONFIG->get_input_font ());
102295
296 Gdk::Color text_bgcolor (CONFIG->text_bgcolor ());
297 Gdk::Color text_fgcolor (CONFIG->text_fgcolor ());
298
299 m_entry->modify_base (Gtk::STATE_NORMAL, text_bgcolor);
300 m_entry->modify_text (Gtk::STATE_NORMAL, text_fgcolor);
301
103302 for (int i = 0; i < LABELS_SZ; i++) {
104303 m_label [i] = Gtk::manage (new Gtk::Label (clabels [i]));
105304 m_label [i]->set_alignment (0, 0.5);
125324 blank2->set_text (" ");
126325
127326 m_report_box->add (*m_report);
128 hbox1->pack_start (*m_report_box, Gtk::PACK_SHRINK, 0);
327
328 hbox1->pack_start (*m_entry, Gtk::PACK_EXPAND_WIDGET, 3);
329 hbox1->pack_start (*m_button, Gtk::PACK_SHRINK, 0);
330 #if !defined(IS_PDA)
129331 hbox1->pack_start (*blank1, Gtk::PACK_SHRINK, 0);
130
131 hbox2->pack_start (*m_entry, Gtk::PACK_EXPAND_WIDGET, 3);
132 hbox2->pack_start (*m_button, Gtk::PACK_SHRINK, 0);
133 hbox2->pack_start (*blank2, Gtk::PACK_SHRINK, 0);
332 #endif
333
334 hbox2->pack_start (*m_report_box, Gtk::PACK_SHRINK, 0);
335
336 #if !defined(IS_PDA)
337 hbox2->pack_start (*blank2, Gtk::PACK_SHRINK, 0);
338 #endif
134339
135340 table->set_row_spacings (0);
136341 table->set_col_spacings (2);
137 table->attach (*hbox1, 1, 2, 0, 1,
138 Gtk::EXPAND|Gtk::FILL, Gtk::FILL, 0, 0);
139 table->attach (*hbox2, 0, 1, 0, 1,
140 Gtk::EXPAND|Gtk::SHRINK|Gtk::FILL, Gtk::FILL, 0, 0);
342
343 table->attach (*hbox1, 0, 1, 0, 1,
344 Gtk::EXPAND|Gtk::SHRINK|Gtk::FILL,
345 Gtk::FILL,
346 0, 0);
347
348 table->attach (*hbox2, 1, 2, 0, 1,
349 Gtk::EXPAND|Gtk::FILL,
350 Gtk::FILL,
351 0, 0);
141352
142353 m_entry->signal_changed ().connect (
143354 mem_fun (*this, &VerifyControl::on_entry_changed));
162373
163374 if (m_test_line != NULL) {
164375 m_line_num = m_test_line->get_value_as_int ();
165 DL ((GRAPP,"test line = %d\n", m_line_num));
376 DL ((GRAPP,"Testing line #%d\n", m_line_num));
166377 }
167378 }
168379
191402 the m_line_num > 1, then we fetch that line instead.
192403 If we are short of lines, that's a failed match.
193404 */
194 if (m_parent.get_selected_size () == BACK && m_line_num > 1)
405 if (m_line_num > 1)
195406 {
407 Glib::ustring::value_type end_of_line ('\n');
196408 std::vector<Glib::ustring> vec;
197 std::istringstream input (tmp.c_str ());
198409 Glib::ustring token;
199 while (input >> token) {
410 ustring::const_iterator iter = answer_.begin ();
411 while (iter != answer_.end ()) {
412 if (*iter == end_of_line) {
413 vec.push_back (token);
414 token = "";
415 }
416 else {
417 token += *iter;
418 }
419 iter++;
420 }
421 if (token.size ()) {
200422 vec.push_back (token);
201423 }
424
202425 if (vec.size () >= m_line_num) {
203426 tmp = vec [m_line_num-1];
204427 }
320543 * DeckPlayer Member Functions *
321544 *******************************************************************************
322545 */
323 Gtk::StockID DeckPlayer::SAY_IT ("say-it" );
324 Gtk::StockID DeckPlayer::THUMB_UP ("thumb-up" );
325 Gtk::StockID DeckPlayer::THUMB_DOWN ("thumb-down");
546 Gtk::StockID DeckPlayer::SAY_IT ("say-it");
547 Gtk::StockID DeckPlayer::THUMB_UP ("thumb-up");
548 Gtk::StockID DeckPlayer::THUMB_DOWN ("thumb-down");
549 //Gtk::StockID DeckPlayer::SHOW_CONTROL ("show-control");
550 //Gtk::StockID DeckPlayer::HIDE_CONTROL ("hide-control");
326551
327552 DeckPlayer::
328553 DeckPlayer (VDeck& vdeck_)
329554 :
330
331555 #ifdef IS_HILDON
332556 Hildon::AppView ("Deck Player"),
333557 m_hildon_fullscreen (false),
334558 #endif
335
336559 m_close_button (manage (new ButtonWithImageLabel (
337560 Gtk::Stock::CLOSE, _("Close")))),
561 #ifdef IS_PDA
562 m_shuffle_button (manage (new ButtonWithImageLabel (
563 Gtk::Stock::REFRESH, ""))),
564 m_edit_button (manage (new ButtonWithImageLabel (
565 Gtk::Stock::DND_MULTIPLE, ""))),
566 m_vcard_edit_button (manage (new ButtonWithImageLabel (
567 Gtk::Stock::DND, ""))),
568 #else /* DESKTOP */
338569 m_shuffle_button (manage (new ButtonWithImageLabel (
339570 Gtk::Stock::REFRESH, _("Shuffle")))),
340571 m_edit_button (manage (new ButtonWithImageLabel (
342573 _("Edit Deck")))),
343574 m_vcard_edit_button (manage (new ButtonWithImageLabel (
344575 Gtk::Stock::DND, _("Edit Card")))),
576 #endif
345577 m_selected_side (FRONT),
346578 m_notebook (manage (new Gtk::Notebook)),
347579 m_play_progress (manage (new Gtk::ProgressBar)),
580 m_question_box_width(0),
348581 m_answer_box_width (0),
349582 m_verify_control (manage (new VerifyControl (*this))),
350 m_bg_white ("white"),
351 m_bg_pink ("pink"),
352 m_bg_black ("black"),
353583 m_deck (vdeck_),
354584 m_deck_iter (m_deck.end ()), /* empty deck */
355585 m_is_lesson_learned (false),
359589 {
360590 trace_with_mask("DeckPlayer::DeckPlayer", GUITRACE);
361591
592 Gtk::Viewport *viewport;
593
362594 set_title ("DeckPlayer");
363595
364 #ifdef IS_HILDON
596 m_text_fgcolor = CONFIG->text_fgcolor ();
597 m_text_bgcolor = CONFIG->text_bgcolor ();
598 m_sep_color = CONFIG->sep_color ();
599
365600 /**
366601 * Not a dialog any more - it is a Bin (AppView) instead.
367602 * We handle packaging ourselves and mute all attributes of a
368603 * Dialog everywhere down the line.
369604 */
370 m_vbox = manage (new Gtk::VBox (false, 2));
605 m_vbox = manage (new Gtk::VBox (false, 0));
371606 add (*m_vbox);
372607
373 #else
374 /**
375 * A desktop Dialog - we can resize and move the window around
608 #ifdef IS_HILDON
609 /**
610 * hildon-specific
611 */
612 #elif IS_PDA
613 /**
614 * Make DeckPlayer expand to fill the whole screen. The screen size
615 * is 240x320, but oddly enough, the WM still leave a few pixels
616 * around. BTW, set_size_request() doesn't work - it makes the dialog
617 * shorter then the MainWindow by the order of the titlebar height.
618 * And, stay away from setting transient on parent.
619 */
620 Gdk::Geometry dp_geometry = { 240, 320, 240, 320, 240, 320, -1, -1, -1, -1};
621 set_geometry_hints (*this, dp_geometry,
622 Gdk::HINT_MIN_SIZE |
623 Gdk::HINT_MAX_SIZE |
624 Gdk::HINT_BASE_SIZE);
625
626 #else // Desktop
627 /** For desktop version we can resize and
628 * move the window around freely.
376629 */
630 set_modal (true);
631 set_transient_for (*MAINWIN);
377632 set_resizable (true);
378 set_position (Gtk::WIN_POS_CENTER_ALWAYS);
379633 Gdk::Rectangle geom = CONFIG->get_deck_player_geometry ();
380634 DL ((GRAPP,"Setting size to width=%d, height=%d\n",
381635 geom.get_width (), geom.get_height ()));
382 set_size_request (geom.get_width (), geom.get_height ());
383 set_modal (true);
384 set_transient_for (*MAINWIN);
385
386 #endif
387
388 /** Are we dealing with CardDeck?
389 */
390 if (dynamic_cast<Deck*>(&m_deck) == NULL) {
391 m_is_real_deck = false;
392 DL((GRAPP,"Deck isn't REAL!\n"));
393 }
394 else {
395 DL((GRAPP,"Yep, this IS a real deck\n"));
396 }
397
398 /** HBox holds both the notebook and controls/info side panel
399 */
400 Gtk::HBox* nb_box = manage (new Gtk::HBox (false, 2));
401 nb_box->pack_start (*m_notebook, true, true);
402
403 /********************
404 * Add the notebook *
405 ********************
406 */
407 m_notebook->set_tab_pos (Gtk::POS_BOTTOM);
408 m_notebook->set_show_border (true);
409 m_notebook->modify_bg (Gtk::STATE_NORMAL, m_bg_white);
410 m_notebook->modify_base (Gtk::STATE_NORMAL, m_bg_white);
411
412 #ifndef IS_HILDON
413
414 /** "The other useful fields are the min_aspect and max_aspect fields;
636 resize (geom.get_width (), geom.get_height ());
637
638 /**
639 * For desktop only, we optionally reinforce the card's geometry
640 * ratio as setup in Preferences->Geometry:
641 *
642 * "The other useful fields are the min_aspect and max_aspect fields;
415643 * these contain a width/height ratio as a floating point number.
416644 * If a geometry widget is set, the aspect applies to the geometry
417645 * widget rather than the entire window. The most common use of these
422650 {
423651 Gdk::Rectangle& rec = CONFIG->get_deck_player_aspect ();
424652 gdouble aspect = rec.get_width () * 1.0 / rec.get_height ();
425
426 Gdk::Geometry answer_box_geometry =
427 {
653 Gdk::Geometry answer_box_geometry = {
428654 geom.get_width(),/*min_width*/ geom.get_height (), /* min_height */
429655 10000, /* max_width; */ 10000, /* max_height */
430656 -1, /* base_width */ -1, /* base_height */
432658 aspect, /* min_aspect (width/height) */
433659 aspect /* max_aspect (width/height) */
434660 };
435
436661 set_geometry_hints (*this, answer_box_geometry,
437662 Gdk::HINT_ASPECT | Gdk::HINT_MIN_SIZE);
438663 }
439 #endif
440
441 /***********************************************
442 * Fill up notebook with elements *
443 ***********************************************
664 #endif // !(IS_PDA)
665
666 /** Are we dealing with CardDeck?
444667 */
445
446 /*********************
447 * Front of the card *
448 *********************
449 */
450 #ifdef IS_HILDON
451 m_front.set_alignment (Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER);
452 m_front.set_justify (Gtk::JUSTIFY_CENTER);
453
454 #else
455 m_front.set_alignment (0.46, 0.5);
456 m_front.set_justify (Gtk::JUSTIFY_LEFT);
457
458 m_front.set_selectable ();
459 #endif
460
461 m_front.set_use_markup ();
462 m_front.set_line_wrap (true);
463 m_front.modify_font (CONFIG->get_question_font ());
464
465 Gtk::Frame* question_frame = manage (new Gtk::Frame());
466 question_frame->set_label_align (0, 0);
467 question_frame->set_shadow_type (Gtk::SHADOW_ETCHED_IN);
468 question_frame->modify_bg (Gtk::STATE_NORMAL, m_bg_black);
469
470 question_frame->add (m_front);
471
472 Gtk::EventBox* question_evbox = Gtk::manage (new Gtk::EventBox);
473 question_evbox->modify_bg (Gtk::STATE_NORMAL, m_bg_white);
474 question_evbox->add (*question_frame);
475
476 m_notebook->pages ().push_back (
477 Gtk::Notebook_Helpers::TabElem (*question_evbox, _("Front")));
668 if (dynamic_cast<Deck*>(&m_deck) == NULL) {
669 m_is_real_deck = false;
670 DL((GRAPP,"Deck isn't REAL!\n"));
671 }
672 else {
673 DL((GRAPP,"Yep, this IS a real deck\n"));
674 }
675
676 /** HBox holds both the notebook and controls/info side panel
677 */
678 Gtk::HBox* nb_box = manage (new Gtk::HBox (false, 2));
679 nb_box->pack_start (*m_notebook, Gtk::PACK_EXPAND_WIDGET, 2);
478680
479681 /********************
480 * Back of the card *
682 * Add the notebook *
481683 ********************
482684 */
483
484 /** VBox holds front, separator, example.
685 m_notebook->set_tab_pos (Gtk::POS_BOTTOM);
686 m_notebook->set_show_border (true);
687
688 /***************************************************************************
689 * Fill up notebook with elements *
690 * *
691 * COLORS: We defeat the theme settings and set our own colors *
692 * according to the configuration file. The foreground color *
693 * can be set on the Gtk::Label itself via modify_fg(Gdk::Color). *
694 * The background color, however, must be set on the enclosing *
695 * container via modify_bg(Gdk::Color). But strangely enough, *
696 * if you put Gtk::Label into Gtk::ScrolledWindow which is a *
697 * Gtk::Container, it won't work! You need a Gtk::EventBox *
698 * sandwitched inbetween (???). Gtk::ScrolledWindow takes its *
699 * background color hint from the theme style, period. BTW, same *
700 * goes for Gtk::Box as well. *
701 * *
702 * For more, read *
703 * <http://ometer.com/gtk-colors.html> - Gtk Colors Mini HOWTO *
704 * *
705 ***************************************************************************
485706 */
486 m_answer_box = manage (new Gtk::VBox (false, 5));
487 m_answer_box->set_border_width (5); // How far box is placed from the edges.
707
708 /***************************************************************************
709 * Front of the card composition *
710 * *
711 * Question Label: *
712 * ============== *
713 * Notebook *
714 * +--Page *
715 * +--ScrolledWindow *
716 * +--VBox *
717 * +--EventBox <- modify_bg *
718 * +--Label <- modify_fg *
719 * *
720 ***************************************************************************
721 */
722 m_question_box = manage (new Gtk::VBox (false, ANSWER_BOX_SPACING));
723 m_question_box->set_border_width (ANSWER_CHILD_SPACING);
724
725 m_front.set_alignment (x_alignment_enum (FRONT),
726 y_alignment_enum (FRONT));
727 m_front.set_padding (x_padding_val (FRONT),
728 y_padding_val (FRONT));
729 m_front.set_justify (justification_enum (FRONT));
730 m_front.set_use_markup ();
731 m_front.set_line_wrap ();
732 m_front.modify_font (question_font ());
733
734 m_front.modify_fg (Gtk::STATE_NORMAL, m_text_fgcolor);
735
736 #if !defined(IS_HILDON)
737 m_front.set_selectable ();
738 #endif
739
740 Gtk::EventBox* question_evbox = Gtk::manage (new Gtk::EventBox);
741 question_evbox->modify_bg (Gtk::STATE_NORMAL, m_text_bgcolor);
742 question_evbox->add (m_front);
743 m_question_box->pack_start (*question_evbox);
744
745 Gtk::ScrolledWindow* scrollw;
746
747 scrollw = Gtk::manage (new Gtk::ScrolledWindow);
748 scrollw->set_flags (Gtk::CAN_FOCUS);
749 scrollw->set_shadow_type (Gtk::SHADOW_NONE);
750 scrollw->property_window_placement ().set_value (Gtk::CORNER_TOP_LEFT);
751 scrollw->set_policy (Gtk::POLICY_NEVER , Gtk::POLICY_AUTOMATIC);
752 scrollw->add (*m_question_box);
753
754 m_notebook->pages ().push_back (
755 Gtk::Notebook_Helpers::TabElem (*scrollw, _("Front")));
756
757 /***************************************************************************
758 * Back of the card composition: *
759 * *
760 * Notebook *
761 * +--Page *
762 * +--ScrolledWindow *
763 * +--Viewport <- modify_bg *
764 * +--VBox (m_answer_box) *
765 * +--Label (m_back) <- modify_fg *
766 * +--EventBox <- modify_bg *
767 * +--HSeparator *
768 * +--Label (m_example) <- modify_fg *
769 ***************************************************************************
770 */
771 m_answer_box = manage (new Gtk::VBox (false, ANSWER_BOX_SPACING));
772 m_answer_box->set_border_width (ANSWER_CHILD_SPACING);
488773
489774 /* -Back (the answer)-
490775 */
491 #ifdef IS_HILDON
492 m_back.set_justify (Gtk::JUSTIFY_CENTER);
493 m_back.set_alignment (Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER);
494 #else
495 m_back.set_justify (Gtk::JUSTIFY_FILL);
776 m_back.set_alignment (x_alignment_enum (BACK),
777 y_alignment_enum (BACK));
778 m_back.set_padding (x_padding_val (BACK),
779 y_padding_val (BACK));
780 m_back.set_justify (justification_enum (BACK));
781
782 m_back.modify_font (CONFIG->get_answer_font ());
783 m_back.modify_fg (Gtk::STATE_NORMAL, m_text_fgcolor);
784 m_back.set_use_markup ();
785 m_back.set_line_wrap ();
786
787 #if !defined(IS_HILDON)
496788 m_back.set_selectable ();
497789 #endif
498
499 m_back.set_use_markup ();
500 m_back.modify_font (CONFIG->get_answer_font ());
501 m_back.set_line_wrap ();
502
503 Gtk::EventBox* answer_evbox = Gtk::manage (new Gtk::EventBox);
504 answer_evbox->modify_bg (Gtk::STATE_NORMAL, m_bg_white);
505 answer_evbox->add (m_back);
506790
507791 /* -Separator-
508792 */
509793 Gtk::HSeparator* separator = manage (new Gtk::HSeparator);
510 separator->modify_fg (Gtk::STATE_NORMAL, m_bg_pink);
511 separator->modify_bg (Gtk::STATE_NORMAL, m_bg_pink);
512 separator->modify_base (Gtk::STATE_NORMAL, m_bg_pink);
794
795 Gtk::EventBox* sep_evbox = Gtk::manage (new Gtk::EventBox);
796 sep_evbox->modify_bg (Gtk::STATE_NORMAL, m_sep_color);
797 sep_evbox->add (*separator);
513798
514799 /* -Example-
515800 */
516 m_example.set_padding (4, 0); /* x - distance between text and
517 right/left edges */
518 m_example.set_justify (Gtk::JUSTIFY_LEFT);
519 #ifndef IS_HILDON
801 m_example.set_alignment (x_alignment_enum (EXAMPLE),
802 y_alignment_enum (EXAMPLE));
803 m_example.set_padding (x_padding_val (EXAMPLE),
804 y_padding_val (EXAMPLE));
805 m_example.set_justify (justification_enum (EXAMPLE));
806 m_example.set_use_markup ();
807 m_example.set_line_wrap ();
808 m_example.modify_font (CONFIG->get_example_font ());
809 m_example.modify_fg (Gtk::STATE_NORMAL, m_text_fgcolor);
810
811 #if !defined(IS_HILDON)
520812 m_example.set_selectable ();
521813 #endif
522 m_example.set_use_markup ();
523 m_example.modify_font (CONFIG->get_example_font ());
524 m_example.set_line_wrap ();
525
526 Gtk::EventBox* example_evbox = Gtk::manage (new Gtk::EventBox);
527 example_evbox->modify_bg (Gtk::STATE_NORMAL, m_bg_white);
528 example_evbox->add (m_example);
529
530 m_answer_box->pack_start (*answer_evbox, Gtk::PACK_SHRINK, 5);
531 m_answer_box->pack_start (*separator, Gtk::PACK_SHRINK, 5);
532 m_answer_box->pack_start (*example_evbox, Gtk::PACK_SHRINK, 5);
533
534 Gtk::Viewport *viewport =
535 Gtk::manage (new Gtk::Viewport (*manage (new Gtk::Adjustment(0,0,1)),
536 *manage (new Gtk::Adjustment(0,0,1))));
537
814
815 m_answer_box->pack_start (m_back, Gtk::PACK_SHRINK, 1);
816 m_answer_box->pack_start (*sep_evbox, Gtk::PACK_SHRINK, 1);
817 m_answer_box->pack_start (m_example, Gtk::PACK_SHRINK, 1);
818
819 /** You need viewport to get background color set right.
820 * Without it the whole Notebook page takes its background style
821 * from the theme, and then Answer/Example labels would have
822 * user-defined colors - yuk!
823 */
824 viewport = Gtk::manage (new Gtk::Viewport (
825 *manage (new Gtk::Adjustment(0,0,1)),
826 *manage (new Gtk::Adjustment(0,0,1))));
538827 viewport->set_shadow_type(Gtk::SHADOW_IN);
539 viewport->modify_bg (Gtk::STATE_NORMAL, m_bg_white);
540
828 viewport->modify_bg (Gtk::STATE_NORMAL, m_text_bgcolor);
541829 viewport->add (*m_answer_box);
542830
543831 /** Without horizontal AUTOMATIC policy, dialog's resizing
545833 * keeps growing in size every time there is more text to fit then
546834 * size allows.
547835 */
548 Gtk::ScrolledWindow* scrollw = Gtk::manage (new Gtk::ScrolledWindow);
549
836 scrollw = Gtk::manage (new Gtk::ScrolledWindow);
550837 scrollw->set_flags (Gtk::CAN_FOCUS);
551838 scrollw->set_shadow_type (Gtk::SHADOW_NONE);
552839 scrollw->property_window_placement ().set_value (Gtk::CORNER_TOP_LEFT);
553
554 #ifdef IS_HILDON
555840 scrollw->set_policy (Gtk::POLICY_NEVER , Gtk::POLICY_AUTOMATIC);
556 #else
557 scrollw->set_policy (Gtk::POLICY_AUTOMATIC , Gtk::POLICY_AUTOMATIC);
558 #endif
559841
560842 scrollw->add (*viewport);
561843
562844 m_notebook->pages ().push_back (
563845 Gtk::Notebook_Helpers::TabElem (*scrollw, _("Back")));
564846
565 /***********************
566 * Side-panel controls *
567 ***********************
847 /********************************************
848 * Side-panel controls *
849 ********************************************
850 * For PDAs, we spread side_box horizontally
851 * and place it to the left of [x Close] button.
568852 */
569 Gtk::VBox* vbox = manage (new Gtk::VBox (false, 3));
570
571 Gtk::RadioButton::Group group;
572 Gtk::RadioButton* radio_fb = NULL;
573 Gtk::RadioButton* radio_bb = NULL;
574 Gtk::VButtonBox* vbuttonbox = manage (new Gtk::VButtonBox);
575
576 #ifndef IS_HILDON
577 vbuttonbox->set_homogeneous ();
578 vbuttonbox->set_spacing (1);
579 #endif
580
581 radio_fb = manage (new Gtk::RadioButton (group, _("Ask front")));
582 radio_fb->signal_clicked ().connect (
583 bind<SideSelection>(
584 mem_fun (*this, &DeckPlayer::on_radio_selected), FRONT));
585 vbuttonbox->pack_end (*radio_fb, false, false, 1);
586
587 radio_bb = manage (new Gtk::RadioButton (group, _("Ask back")));
588 radio_bb->signal_clicked ().connect (
589 bind<SideSelection>(
590 mem_fun (*this, &DeckPlayer::on_radio_selected), BACK));
591 vbuttonbox->pack_end (*radio_bb, false, false, 1);
592 vbox->pack_start (*vbuttonbox, false, false, 0);
593
594 /** Add Line selection spin button
853 #ifdef IS_PDA
854 Gtk::HBox* side_box = manage (new Gtk::HBox (false, 3));
855 #else
856 Gtk::VBox* side_box = manage (new Gtk::VBox (false, 3));
857 #endif
858
859 /**
860 * Radio buttons
861 * o Ask front
862 * o Ask back
595863 */
596 Gtk::HBox* sb_hbox = manage (new Gtk::HBox);
597 Gtk::Adjustment* sb_adjust = manage (new Gtk::Adjustment (1,1,10));
598 Gtk::Label* sb_label = manage (new Gtk::Label (_("Test line: ")));
599 m_test_line_button = manage (new Gtk::SpinButton (*sb_adjust));
600
601 sb_hbox->pack_start (*sb_label, false, false, 0);
602 sb_hbox->pack_start (*m_test_line_button, false, false, 0);
603 vbox->pack_start (*sb_hbox, false, false, 0);
604 m_test_line_button->signal_value_changed ().connect (
605 mem_fun (*m_verify_control, &VerifyControl::on_test_line_changed));
606 m_verify_control->attach (m_test_line_button);
607 m_verify_control->set_focus_on_entry ();
864 SideFlipControl* sf_control = manage (new SideFlipControl (*this));
865
866 /** Add Test Line selection spin button
867 * Test line: [ 1 ]
868 */
869 m_test_line_entry = manage (new TestLineEntry (m_verify_control));
608870
609871 /** Fetch out the side history and adjust accordingly
610872 */
611 if ((m_selected_side = vdeck_.get_side_selection ()) == FRONT) {
612 radio_fb->set_active ();
613 m_test_line_button->set_sensitive (false);
614 }
615 else {
616 radio_bb->set_active ();
617 m_test_line_button->set_sensitive (true);
618 }
619
620 /** Side-panel buttons
873 m_selected_side = vdeck_.get_side_selection ();
874 sf_control->set_active (m_selected_side);
875 m_test_line_entry->set_sensitive (true);
876
877 #ifdef IS_PDA
878 /** Setup hide/show buttons to manipulate verify_control
879 ** and navigation buttons toolbar.
880 */
881 Gtk::VBox* hs_vbox = manage (new Gtk::VBox (false, 0));
882 m_hs_button_vc = manage (new Gtk::Button ());
883 m_hs_button_ntb = manage (new Gtk::Button ());
884
885 m_hide_control =
886 Gdk::Pixbuf::create_from_file (GRAPPDATDIR "/pixmaps/hide_control.png"
887 DP_SHRINK_ICONS);
888 m_show_control =
889 Gdk::Pixbuf::create_from_file (GRAPPDATDIR "/pixmaps/show_control.png"
890 DP_SHRINK_ICONS);
891
892 #if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION >= 6)
893 m_hs_button_vc->set_image (*manage (new Gtk::Image (m_show_control)));
894 m_hs_button_ntb->set_image (*manage (new Gtk::Image (m_show_control)));
895 #else
896 m_hs_button_vc->set_label (".");
897 m_hs_button_ntb->set_label (".");
898 #endif
899
900 hs_vbox->pack_start (*m_hs_button_vc, Gtk::PACK_SHRINK, 0);
901 hs_vbox->pack_start (*m_hs_button_ntb, Gtk::PACK_SHRINK, 0);
902
903 m_hs_button_vc->signal_clicked ().connect (
904 mem_fun (*this, &DeckPlayer::on_verify_control_hide_clicked));
905
906 m_hs_button_ntb->signal_clicked ().connect (
907 mem_fun (*this, &DeckPlayer::on_navigation_toolbar_hide_clicked));
908
909 side_box->pack_start (*hs_vbox, Gtk::PACK_SHRINK, 0);
910 #endif // (IS_PDA)
911
912 /** Side-panel buttons:
913 *
914 * [<> Front ]
915 * [<> Back ]
916 * [Test line: <1>]
917 * [Shuffle ]
918 * [Edit Deck]
919 * [Edit Card]
920 *
921 * or for PDAs:
922 *
923 * [%][<F>]<1> [Shuffle] [Edit Deck] [Edit Card] [x Close]
621924 */
925 side_box->pack_start (*sf_control, Gtk::PACK_SHRINK, 0);
926 side_box->pack_start (*m_test_line_entry, Gtk::PACK_SHRINK, 0);
927
928 side_box->pack_start (*m_shuffle_button, Gtk::PACK_SHRINK, 0);
929 side_box->pack_start (*m_edit_button, Gtk::PACK_SHRINK, 0);
930 side_box->pack_start (*m_vcard_edit_button, Gtk::PACK_SHRINK, 0);
931
622932 m_shuffle_button->signal_clicked ().connect (
623933 mem_fun (*this, &DeckPlayer::on_shuffle_clicked));
624 vbox->pack_start (*m_shuffle_button, false, false, 0);
625934
626935 m_edit_button->signal_clicked ().connect (
627936 mem_fun (*this, &DeckPlayer::on_edit_clicked));
628 vbox->pack_start (*m_edit_button, false, false, 0);
629937
630938 m_vcard_edit_button->signal_clicked ().connect (
631939 bind<bool>(mem_fun (*this, &DeckPlayer::on_vcard_edit_clicked), false));
632 vbox->pack_start (*m_vcard_edit_button, false, false, 0);
633
940
941 /** Count label and progress bar
942 *
943 * 1/138
944 * [XXXXX________]
945 */
634946 m_count_label.set_alignment (0.5, 0.5);
635947 m_count_label.set_padding (0, 0);
636948 m_count_label.set_justify (Gtk::JUSTIFY_FILL);
637949
638 vbox->pack_end (*m_play_progress, false, false, 4);
639 vbox->pack_end (m_count_label, false, false, 4);
640
641 nb_box->pack_start (*vbox, Gtk::PACK_SHRINK, 5);
950 #ifdef IS_PDA
951 get_vbox ()->set_homogeneous (false);
952 get_vbox ()->set_spacing (0);
953 get_vbox ()->pack_start (*nb_box, Gtk::PACK_EXPAND_WIDGET, 0);
954 #else
955 side_box->pack_end (*m_play_progress, Gtk::PACK_SHRINK, 2);
956 side_box->pack_end (m_count_label, Gtk::PACK_SHRINK, 2);
957 nb_box->pack_start (*side_box, Gtk::PACK_SHRINK, 2);
958
642959 get_vbox ()->pack_start (*nb_box);
960 #endif
961
643962 nb_box->show_all ();
644963
645964 /** Bottom playback controls toolbar panel
965 * --------------------------------------------------
966 * [spkr] [|<] [<] [>] [>|] [V] [A] [N/M]
967 * --------------------------------------------------
646968 */
647 m_playit_xpm = Gdk::Pixbuf::create_from_file (
648 GRAPPDATDIR "/pixmaps/speaker_24.png");
649
650969 Glib::RefPtr<Gtk::IconFactory> icon_factory = Gtk::IconFactory::create ();
651970
971 //------------------------------------------------------------------------
972 m_playit_xpm =
973 Gdk::Pixbuf::create_from_file (GRAPPDATDIR "/pixmaps/speaker_24.png");
652974 Gtk::IconSet spkr_set;
653975 Gtk::IconSource spkr_source;
654976 spkr_source.set_pixbuf (m_playit_xpm);
7051027 m_uimanager = Gtk::UIManager::create ();
7061028 m_uimanager->insert_action_group (m_actgroup);
7071029
708 #ifndef IS_HILDON
1030 #if !defined(IS_HILDON)
7091031 add_accel_group (m_uimanager->get_accel_group ());
7101032 #endif
7111033
7121034 try {
1035 #if !defined(IS_PDA)
7131036 Glib::ustring ui_info =
7141037 "<ui>"
7151038 " <toolbar name='Controls'>"
7241047 " <toolitem action='NoClue'/>"
7251048 " </toolbar>"
7261049 "</ui>";
1050 #else
1051 Glib::ustring ui_info =
1052 "<ui>"
1053 " <toolbar name='Controls'>"
1054 " <toolitem action='Say_It'/>"
1055 " <separator name='1'/>"
1056 " <toolitem action='Prev'/>"
1057 " <toolitem action='Next'/>"
1058 " <separator name='2'/>"
1059 " <toolitem action='IKnowIt'/>"
1060 " <toolitem action='NoClue'/>"
1061 " </toolbar>"
1062 "</ui>";
1063 #endif
7271064 m_uimanager->add_ui_from_string (ui_info);
7281065 }
7291066 catch (const Glib::Error& ex_) {
730 DL((GRAPP,"Building menues failed (%s)\n"));
731 std::cerr << "Failed: " << ex_.what ();
1067 DL((GRAPP,"Building menues failed (%s)\n", ex_.what ().c_str ()));
7321068 }
7331069
7341070 m_toolbar_go_first = m_uimanager->get_widget ("/Controls/First");
1071 m_toolbar_go_last = m_uimanager->get_widget ("/Controls/Last");
7351072 m_toolbar_go_prev = m_uimanager->get_widget ("/Controls/Prev");
7361073 m_toolbar_go_next = m_uimanager->get_widget ("/Controls/Next");
737 m_toolbar_go_last = m_uimanager->get_widget ("/Controls/Last");
7381074 m_toolbar_know_it = m_uimanager->get_widget ("/Controls/IKnowIt");
7391075 m_toolbar_no_clue = m_uimanager->get_widget ("/Controls/NoClue");
7401076
7421078 * Add input verification control
7431079 */
7441080 Gtk::HSeparator* hsep = manage (new Gtk::HSeparator);
1081 #ifdef IS_PDA
1082 get_vbox ()->pack_start (*hsep, Gtk::PACK_SHRINK, 0);
1083 #else
7451084 get_vbox ()->pack_start (*hsep, Gtk::PACK_SHRINK, 4);
746 get_vbox ()->pack_start (*m_verify_control, false, false, 0);
1085 #endif
1086 get_vbox ()->pack_start (*m_verify_control, Gtk::PACK_SHRINK, 0);
1087
7471088 m_verify_control->show_all ();
7481089
7491090 /**
7551096 ctrl_toolbar->set_toolbar_style (Gtk::TOOLBAR_ICONS);
7561097 ctrl_toolbar->set_tooltips (true);
7571098
758 #ifndef IS_HILDON
759 set_has_separator (false);
760 #endif
761
762 Gtk::HBox* hbox = manage (new Gtk::HBox);
763 hbox->pack_start (*ctrl_toolbar, true, true, 2);
764 hbox->pack_start (*m_close_button, false, false, 0);
765 get_vbox ()->pack_start (*hbox, false, false, 0);
766 hbox->show_all ();
767
1099 m_navigation_controls_hbox = manage (new Gtk::HBox);
1100 m_navigation_controls_hbox->pack_start (*ctrl_toolbar,
1101 Gtk::PACK_EXPAND_WIDGET, 2);
1102 #ifdef IS_PDA
1103 m_navigation_controls_hbox->pack_start (m_count_label, Gtk::PACK_SHRINK, 0);
1104 side_box->pack_end (*m_close_button, Gtk::PACK_SHRINK, 0);
1105 #else
1106 m_navigation_controls_hbox->pack_start (*m_close_button,Gtk::PACK_SHRINK,0);
1107 #endif
1108
1109 get_vbox ()->pack_start (*m_navigation_controls_hbox, Gtk::PACK_SHRINK, 0);
1110
1111 #ifdef IS_PDA
1112 get_vbox ()->pack_start (*side_box, Gtk::PACK_SHRINK, 0);
1113 #endif
1114
1115 m_navigation_controls_hbox->show_all ();
1116
1117 /************
1118 * Callbacks
1119 ************
1120 */
7681121 m_close_button->signal_clicked ().connect (
7691122 mem_fun (*this, &DeckPlayer::on_close_clicked));
7701123
7721125 * Setting resize callbacks. The answer box holds
7731126 * Back/Separator/Example triplet trapped in the scrollwindow.
7741127 */
1128 m_question_box->signal_size_allocate ().connect (
1129 mem_fun (*this, &DeckPlayer::question_box_size_allocate_cb));
1130
7751131 m_answer_box->signal_size_allocate ().connect (
7761132 mem_fun (*this, &DeckPlayer::answer_box_size_allocate_cb));
7771133
7981154
7991155 /** Grand finale
8001156 */
801 #ifndef IS_HILDON
1157 #if !defined(IS_HILDON)
8021158 set_icon_from_file (GRAPPDATDIR "/pixmaps/deckplayer_32x32.png");
8031159 #endif
8041160 set_sensitivity ();
8071163 set_win_name ();
8081164 show_deck ();
8091165 switch_side ();
1166
8101167 show_all_children ();
8111168
8121169 m_initialized = true;
8161173 // Utilities
8171174 //==============================================================================
8181175 //
1176
1177
1178 gint
1179 DeckPlayer::
1180 run ()
1181 {
1182 trace_with_mask("DeckPlayer::run",GUITRACE);
1183
8191184 #ifdef IS_HILDON
820
821 gint
822 DeckPlayer::
823 run ()
824 {
825 trace_with_mask("DeckPlayer::run",GUITRACE);
826
8271185 GRANULE->register_appview (this);
1186 m_verify_control->set_focus_on_entry ();
1187 #endif
1188
8281189 show ();
829 m_verify_control->set_focus_on_entry ();
830
8311190 DL ((APP,"Enter Main::run()\n"));
8321191 Gtk::Main::run ();
8331192
8341193 DL ((APP,"Exit Main::run()\n"));
8351194 return (Gtk::RESPONSE_NONE);
8361195 }
837 #endif
1196
8381197
8391198 void
8401199 DeckPlayer::
8441203
8451204 #ifdef IS_HILDON
8461205 GRANULE->unregister_appview (this);
1206 #else
1207 hide ();
1208 #endif
8471209
8481210 DL ((GRAPP,"Call Main::quit()\n"));
8491211 Gtk::Main::quit ();
850 #else
851 hide ();
852 #endif
8531212 }
8541213
8551214 void
8931252
8941253 clear_text ();
8951254
896 if (m_deck_iter != m_deck.end () || m_deck.size () > 0) {
1255 if (m_deck_iter != m_deck.end () || m_deck.size () > 0)
1256 {
8971257 while (!markup_is_valid ((*m_deck_iter))) {
8981258 Gtk::MessageDialog em (
8991259 _("The card you are about to see has invalid markup.\n"
9041264 em.hide ();
9051265 on_vcard_edit_clicked (true);
9061266 }
907 m_front.set_markup ((*m_deck_iter)->get_question ());
908 set_answer_field ((*m_deck_iter)->get_answer ());
909 m_example.set_markup (markup_tildas((*m_deck_iter)->get_example()));
1267 try {
1268 DL ((GRAPP,"Seting markup Question field.\n"));
1269 m_front.set_markup ((*m_deck_iter)->get_question ());
1270 DL ((GRAPP,"Seting markup Answer field.\n"));
1271 m_back.set_markup ((*m_deck_iter)->get_answer ());
1272 DL ((GRAPP,"Seting markup Example field.\n"));
1273 m_example.set_markup (markup_tildas((*m_deck_iter)->get_example()));
1274 DL ((GRAPP,"All fields are set.\n"));
1275 }
1276 catch (const Glib::ConvertError& e) {
1277 DL ((GRAPP,"Caught conversion error: \"%s\"\n",
1278 e.what ().c_str ()));
1279 switch (e.code ()) {
1280 case Glib::ConvertError::NO_CONVERSION:
1281 DL ((GRAPP,"code: no conversion\n"));
1282 break;
1283 case Glib::ConvertError::ILLEGAL_SEQUENCE:
1284 DL ((GRAPP,"code: illegal sequence\n"));
1285 break;
1286 case Glib::ConvertError::FAILED:
1287 DL ((GRAPP,"code: failed\n"));
1288 break;
1289 case Glib::ConvertError::PARTIAL_INPUT:
1290 DL ((GRAPP,"code: partial input\n"));
1291 break;
1292 case Glib::ConvertError::BAD_URI:
1293 DL ((GRAPP,"code: bad uri\n"));
1294 break;
1295 case Glib::ConvertError::NOT_ABSOLUTE_PATH:
1296 DL ((GRAPP,"code: not absolute path\n"));
1297 break;
1298 }
1299 }
9101300
9111301 if ((*m_deck_iter)->get_reversed ()) {
9121302 m_notebook->set_current_page (BACK);
9171307 adjust_count ();
9181308 }
9191309
920 #ifndef IS_HILDON
1310 #if !defined(IS_HILDON)
9211311 /** Calling set_focus_on_entry() causes crash with Maemo 2.0 when
9221312 * you open CardFile twice in the row.
9231313 * No clue - investigate later.
9251315 m_verify_control->set_focus_on_entry ();
9261316 #endif
9271317
928 }
929
930 void
931 DeckPlayer::
932 set_answer_field (Glib::ustring answer_)
933 {
934 trace_with_mask("DeckPlayer::set_answer_field",GUITRACE);
935
936 // DL ((GRAPP,"answer: \"%s\"\n", answer_.c_str ()));
937
938 m_back.set_markup (answer_);
939
940 /*
941 Multi-line right alignment works, but perhaps it should be
942 optional via Preferences
943
944 if (answer_.find ("\n") != Glib::ustring::npos) {
945 m_back.set_alignment (Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER);
946 }
947 else {
948 m_back.set_alignment (Gtk::ALIGN_CENTER, Gtk::ALIGN_CENTER);
949 }
950 */
9511318 }
9521319
9531320 void
9791346 m_toolbar_no_clue ->set_sensitive (false);
9801347 }
9811348 else {
1349 #if !defined(IS_PDA)
9821350 m_toolbar_go_first->set_sensitive (false);
1351 m_toolbar_go_last ->set_sensitive (false);
1352 #endif
9831353 m_toolbar_go_prev ->set_sensitive (false);
9841354 m_toolbar_go_next ->set_sensitive (false);
985 m_toolbar_go_last ->set_sensitive (false);
9861355 }
9871356 }
9881357
9971366 }
9981367 DL ((GRAPP,"Deck is empty\n"));
9991368
1000 if (m_deck.empty ()) {
1369 if (m_deck.empty ())
1370 {
10011371 m_shuffle_button ->set_sensitive (false);
10021372 m_vcard_edit_button ->set_sensitive (false);
1003
1373 #if !defined(IS_PDA)
10041374 m_toolbar_go_first ->set_sensitive (false);
1375 m_toolbar_go_last ->set_sensitive (false);
1376 #endif
10051377 m_toolbar_go_prev ->set_sensitive (false);
10061378 m_toolbar_go_next ->set_sensitive (false);
1007 m_toolbar_go_last ->set_sensitive (false);
10081379 }
10091380 else {
10101381 m_shuffle_button ->set_sensitive (true);
10111382 m_vcard_edit_button ->set_sensitive (true);
1012
1383 #if !defined(IS_PDA)
10131384 m_toolbar_go_first ->set_sensitive (true);
1385 m_toolbar_go_last ->set_sensitive (true);
1386 #endif
10141387 m_toolbar_go_prev ->set_sensitive (true);
10151388 m_toolbar_go_next ->set_sensitive (true);
1016 m_toolbar_go_last ->set_sensitive (true);
10171389 }
10181390 }
10191391
11641536 trace_with_mask("DeckPlayer::on_radio_selected",GUITRACE);
11651537
11661538 m_selected_side = selected_;
1539 DL ((GRAPP,"selected = %s\n",(m_selected_side == BACK ? "BACK" : "FRONT")));
1540
11671541 m_deck.set_side_selection (m_selected_side);
11681542 switch_side ();
1169 m_test_line_button->set_sensitive ((m_selected_side == BACK));
1170
1171 DL ((GRAPP,"selected = %s\n",
1172 (m_selected_side == BACK ? "BACK" : "FRONT")));
11731543 }
11741544
11751545 void
11771547 on_sayit_clicked ()
11781548 {
11791549 trace_with_mask("DeckPlayer::on_sayit_clicked",GUITRACE);
1550
11801551 if (m_deck_iter != m_deck.end ()) {
1181 m_deck.play_card (m_deck_iter);
1552 m_deck.play_card (SideSelection (m_notebook->get_current_page ()),
1553 m_deck_iter);
11821554 }
11831555 }
11841556
11881560 {
11891561 trace_with_mask("DeckPlayer::on_shuffle_clicked",GUITRACE);
11901562
1191 if (m_is_real_deck) {
1563 if (m_is_real_deck)
1564 {
11921565 random_shuffle (m_deck.begin (), m_deck.end ());
1193 /* Gtk::MessageDialog qm (*this, */
11941566 Gtk::MessageDialog qm (
11951567 _("Would you like to make cards\norder changes permanent?"),
11961568 false,
11991571 true);
12001572 qm.add_button (Gtk::Stock::NO, Gtk::RESPONSE_NO);
12011573 qm.add_button (Gtk::Stock::YES, Gtk::RESPONSE_YES);
1202 if (qm.run () == Gtk::RESPONSE_YES) {
1574
1575 if (qm.run () == Gtk::RESPONSE_YES)
1576 {
12031577 Deck& real_deck = dynamic_cast<Deck&>(m_deck);
12041578 real_deck.mark_as_modified ();
12051579 }
12341608 DeckView dv (m_deck, idx);
12351609 dv.run ();
12361610 dv_modified = dv.is_modified ();
1611 if (dv.appearance_changed ()) {
1612 repaint ();
1613 }
12371614 }
12381615
12391616 DL((GRAPP,"Deck size after edit = %d cards (modified = %s)\n",
12501627 CARDBOX->mark_as_modified ();
12511628 show_card ();
12521629
1253 #ifndef IS_HILDON
1630 #if !defined(IS_HILDON)
12541631 /** Under Hildon, this messes up return chain.
12551632 */
12561633 on_close_clicked ();
12791656 trace_with_mask("DeckPlayer::on_vcard_edit_clicked",GUITRACE);
12801657
12811658 if (m_deck_iter != m_deck.end () || m_deck.size () > 0) {
1659 hide ();
12821660 VCard* vc = *m_deck_iter;
12831661 CardView cview (vc);
12841662 int ret = cview.run (disable_cancel_);
12861664 if (ret == Gtk::RESPONSE_OK) {
12871665 show_card (false);
12881666 }
1667 show ();
12891668 }
12901669 else {
12911670 Gtk::MessageDialog em (_("The deck is empty!"), Gtk::MESSAGE_ERROR);
13871766 {
13881767 trace_with_mask("DeckPlayer::on_key_pressed",KEYIN);
13891768
1390 #ifndef IS_HILDON
1769 #if !defined(IS_HILDON)
13911770 if (evt_->keyval == GDK_F1) {
13921771 MAINWIN->iconify ();
13931772 }
15561935 }
15571936
15581937 /**
1938 Adjust the size of the 'question' label when size of
1939 the enclosing VBox is changed by the user via resize.
1940 */
1941 void
1942 DeckPlayer::
1943 question_box_size_allocate_cb (Gtk::Allocation& allocation_)
1944 {
1945 trace_with_mask("DeckPlayer::question_box_size_allocate_cb",GEOM);
1946
1947 DL((GEOM,"new question_box size (w=%d; h=%d)\n",
1948 allocation_.get_width (), allocation_.get_height ()));
1949
1950 if (m_question_box_width != allocation_.get_width ()) {
1951 m_front.set_size_request (allocation_.get_width () - 20, -1);
1952 m_question_box_width = allocation_.get_width ();
1953 }
1954 }
1955
1956 /**
15591957 Adjust the size of the 'example' label when size of
15601958 the enclosing VBox is changed by the user via resize.
15611959 */
15791977 repaint ()
15801978 {
15811979 trace_with_mask("DeckPlayer::repaint",GUITRACE);
1582
1583 m_front .modify_font (CONFIG->get_question_font ());
1584 m_back .modify_font (CONFIG->get_answer_font ());
1585 m_example.modify_font (CONFIG->get_example_font ());
1980
1981 Deck* deckp = dynamic_cast<Deck*>(&m_deck);
1982 if (deckp != NULL && deckp->with_custom_appearance ()) {
1983 Pango::FontDescription fdesk (deckp->question_font ());
1984 m_front.modify_font (fdesk);
1985 }
1986 else {
1987 m_front.modify_font (CONFIG->get_question_font ());
1988 }
1989 m_back .modify_font (CONFIG->get_answer_font ());
1990 m_example.modify_font (CONFIG->get_example_font ());
1991
1992 DL ((GRAPP,"Answer padding (x, y) = %d, %d\n",
1993 x_padding_val (BACK), y_padding_val (BACK)));
1994
15861995 m_verify_control->repaint ();
1587
15881996 update_geometry ();
1997
1998 /* Update text alignment
1999 */
2000 m_front.set_alignment (x_alignment_enum (FRONT),
2001 y_alignment_enum (FRONT));
2002 m_front.set_justify (justification_enum (FRONT));
2003
2004 m_back.set_alignment (x_alignment_enum (BACK),
2005 y_alignment_enum (BACK));
2006 m_back.set_justify (justification_enum (BACK));
15892007 }
15902008
15912009 /** Resize only if geometry stored in Configurator differs
15952013 DeckPlayer::
15962014 update_geometry ()
15972015 {
1598 #ifndef IS_HILDON
2016 #if !defined(IS_HILDON)
15992017 int actual_height = 0;
1600 int actual_width = 0;
2018 int actual_width = 0;
16012019
16022020 Gdk::Rectangle geom = CONFIG->get_deck_player_geometry ();
16032021 get_size (actual_width, actual_height);
16502068 {
16512069 // trace_with_mask("DeckPlayer::markup_tildas", GUITRACE);
16522070
1653 static const string tilda = "<span foreground=\"red\">~</span>";
2071 static Glib::ustring tilda ("<span foreground=\"red\">~</span>");
16542072 Glib::ustring ret;
16552073
16562074 if (src_.size () == 0) {
16722090 }
16732091 }
16742092 ret += src_.substr (b);
1675
16762093 return ret;
16772094 }
16782095
17252142
17262143 if (m_selected_side == side_ && CONFIG->auto_pronounce ())
17272144 {
1728 while (Gtk::Main::instance ()->events_pending ()) {
1729 Gtk::Main::instance ()->iteration ();
1730 }
1731
1732 m_deck.play_card (m_deck_iter);
2145 m_deck.play_card (m_selected_side, m_deck_iter);
17332146 }
17342147 }
17352148
17472160 }
17482161 }
17492162
2163 /*******************************************************************************
2164 Convert string alignment to Gtk::AlignmentEnum
2165 */
2166
2167 Gtk::AlignmentEnum
2168 DeckPlayer::
2169 x_alignment_enum (SideSelection side_)
2170 {
2171 Gtk::AlignmentEnum result = Gtk::ALIGN_CENTER;
2172 std::string val;
2173
2174 Deck* deckp = dynamic_cast<Deck*>(&m_deck);
2175 if (deckp != NULL && deckp->with_custom_appearance ()) {
2176 val = deckp->x_alignment (side_);
2177 }
2178 else {
2179 val = CONFIG->x_alignment (side_);
2180 }
2181
2182 if (val == "left") {
2183 result = Gtk::ALIGN_LEFT;
2184 }
2185 else if (val == "right") {
2186 result = Gtk::ALIGN_RIGHT;
2187 }
2188
2189 return (result);
2190 }
2191
2192 Gtk::AlignmentEnum
2193 DeckPlayer::
2194 y_alignment_enum (SideSelection side_)
2195 {
2196 Gtk::AlignmentEnum result = Gtk::ALIGN_CENTER;
2197 std::string val;
2198
2199 Deck* deckp = dynamic_cast<Deck*>(&m_deck);
2200 if (deckp != NULL && deckp->with_custom_appearance ()) {
2201 val = deckp->y_alignment (side_);
2202 }
2203 else {
2204 val = CONFIG->y_alignment (side_);
2205 }
2206
2207 if (val == "top") {
2208 result = Gtk::ALIGN_TOP;
2209 }
2210 else if (val == "bottom") {
2211 result = Gtk::ALIGN_BOTTOM;
2212 }
2213 return (result);
2214 }
2215
2216
2217 /*******************************************************************************
2218 Convert string justification to Gtk::Justification
2219 */
2220 Gtk::Justification
2221 DeckPlayer::
2222 justification_enum (SideSelection side_)
2223 {
2224 Gtk::Justification result = Gtk::JUSTIFY_CENTER;
2225 std::string val;
2226
2227 Deck* deckp = dynamic_cast<Deck*>(&m_deck);
2228 if (deckp != NULL && deckp->with_custom_appearance ()) {
2229 val = deckp->justification (side_);
2230 }
2231 else {
2232 val = CONFIG->justification (side_);
2233 }
2234
2235 if (val == "left") {
2236 result = Gtk::JUSTIFY_LEFT;
2237 }
2238 else if (val == "right") {
2239 result = Gtk::JUSTIFY_RIGHT;
2240 }
2241 else if (val == "fill") {
2242 result = Gtk::JUSTIFY_FILL;
2243 }
2244 return (result);
2245 }
2246
2247 int
2248 DeckPlayer::
2249 x_padding_val (SideSelection side_)
2250 {
2251 int result;
2252 Deck* deckp = dynamic_cast<Deck*>(&m_deck);
2253 if (deckp != NULL && deckp->with_custom_appearance ()) {
2254 result = ustring_to_int (deckp->x_padding (side_));
2255 }
2256 else {
2257 result = ustring_to_int (CONFIG->x_padding (side_));
2258 }
2259
2260 return (result);
2261 }
2262
2263 int
2264 DeckPlayer::
2265 y_padding_val (SideSelection side_)
2266 {
2267 int result;
2268 Deck* deckp = dynamic_cast<Deck*>(&m_deck);
2269 if (deckp != NULL && deckp->with_custom_appearance ()) {
2270 result = ustring_to_int (deckp->y_padding (side_));
2271 }
2272 else {
2273 result = ustring_to_int (CONFIG->y_padding (side_));
2274 }
2275
2276 return (result);
2277 }
2278
2279 Pango::FontDescription
2280 DeckPlayer::
2281 question_font ()
2282 {
2283 Deck* deckp = dynamic_cast<Deck*>(&m_deck);
2284
2285 if (deckp != NULL && deckp->with_custom_appearance ()) {
2286 return Pango::FontDescription (deckp->question_font ());
2287 }
2288
2289 return (CONFIG->get_question_font ());
2290 }
2291
2292 void
2293 DeckPlayer::
2294 on_verify_control_hide_clicked ()
2295 {
2296 if (m_verify_control->is_visible ()) {
2297 m_verify_control->hide ();
2298 #if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION >= 6)
2299 m_hs_button_vc->set_image (*manage (new Gtk::Image (m_hide_control)));
2300 #endif
2301 }
2302 else {
2303 m_verify_control->show ();
2304 #if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION >= 6)
2305 m_hs_button_vc->set_image (*manage (new Gtk::Image (m_show_control)));
2306 #endif
2307 }
2308 }
2309
2310 void
2311 DeckPlayer::
2312 on_navigation_toolbar_hide_clicked ()
2313 {
2314 if (m_navigation_controls_hbox->is_visible ()) {
2315 m_navigation_controls_hbox->hide ();
2316 #if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION >= 6)
2317 m_hs_button_ntb->set_image (*manage (new Gtk::Image (m_hide_control)));
2318 #endif
2319 }
2320 else {
2321 m_navigation_controls_hbox->show ();
2322 #if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION >= 6)
2323 m_hs_button_ntb->set_image (*manage (new Gtk::Image (m_show_control)));
2324 #endif
2325 }
2326 }
00 // -*- c++ -*-
11 //------------------------------------------------------------------------------
2 // $Id: DeckPlayer.h,v 1.49 2006/10/06 02:04:47 vlg Exp $
2 // $Id: DeckPlayer.h,v 1.60 2007/01/14 02:00:13 vlg Exp $
33 //------------------------------------------------------------------------------
44 // DeckPlayer.h
55 //------------------------------------------------------------------------------
5252 VC_VALIDATED // Entry text validated
5353 } VCState;
5454
55 /**
56 * Class VerifyControl encapsulates the verification element
57 * of the DeckPlayer dialog. This element is optionally shown
58 * in the dialog between the notebook and the control toolbar.
59 *
55 class VerifyControl;
56
57 /**=============================================================================
58 * Class TestLineEntry encapsulates line selection widget
59 **=============================================================================
60 */
61 class TestLineEntry : public Gtk::HBox
62 {
63 public:
64 TestLineEntry (VerifyControl* parent_);
65
66 int get_value_as_int () const;
67
68 private:
69 /** For desktop and Hildon
70 */
71 Gtk::Adjustment m_adjustment;
72 Gtk::Label m_label;
73 Gtk::SpinButton m_test_line_button;
74
75 /** For PDA
76 */
77 Gtk::Entry m_entry;
78 };
79
80 /**=============================================================================
81 * Class SideFlipControl encapsulates the side switch radio buttons
82 **=============================================================================
83 */
84 class SideFlipControl : public Gtk::EventBox
85 {
86 public:
87 SideFlipControl (DeckPlayer& parent_);
88
89 void set_active (SideSelection s_);
90
91 private:
92 void on_flip_button_clicked ();
93
94 private:
95 DeckPlayer& m_parent;
96
97 /** For desktop and Hildon
98 */
99 Gtk::RadioButton m_radio_fb;
100 Gtk::RadioButton m_radio_bb;
101 Gtk::VButtonBox m_button_box;
102
103 /** For PDA
104 */
105 Gtk::Button m_flip_button;
106 SideSelection m_side;
107 };
108
109 /**=============================================================================
110 * Class VerifyControl encapsulates the verification element
111 * of the DeckPlayer dialog. This element is optionally shown
112 * in the dialog between the notebook and the control toolbar.
113 **=============================================================================
60114 */
61115 class VerifyControl : public Gtk::Table
62116 {
75129 void on_entry_changed ();
76130 void on_test_line_changed ();
77131
78 void attach (Gtk::SpinButton* tl_) { m_test_line = tl_; }
132 void attach (TestLineEntry* tle_) { m_test_line = tle_; }
79133 void repaint () { m_entry->modify_font (CONFIG->get_input_font ()); }
80134
81135 private:
97151 Gdk::Color m_white;
98152 Gdk::Color m_black;
99153
100 Gtk::SpinButton* m_test_line; // Which line to compare for answer.
154 TestLineEntry* m_test_line; // Which line to compare for answer.
101155 int m_line_num; // Number of line to test
102156 };
103157
108162 #ifdef IS_HILDON
109163 class DeckPlayer : public Hildon::AppView
110164 #else
111 class DeckPlayer : public Gtk::Dialog
165 class DeckPlayer : public Gtk::Window
112166 #endif
113167 {
114168 public:
115169 DeckPlayer (VDeck& vdeck_);
116170
117 #ifdef IS_HILDON
171 //#ifdef IS_HILDON
118172 gint run ();
119 #endif
173 //#endif
120174
121175 /** Called in response to pressing <Close> button
122176 */
123177 void on_close_clicked ();
178
179 /** Called every time VBox that holds
180 the question size of the card is resized.
181 */
182 void question_box_size_allocate_cb (Gtk::Allocation& size_);
124183
125184 /** Called every time VBox that holds
126185 the answer size of the card is resized.
166225 // -*- Catch and process keyboard events -*-
167226 bool on_key_pressed (GdkEventKey* evt_);
168227
228 // Show/hide verify control hbox (for IS_PDA mode)
229 void on_verify_control_hide_clicked ();
230
231 // Show/hide navigations button toolbar (for IS_PDA mode)
232 void on_navigation_toolbar_hide_clicked ();
233
169234 /** Get the deck pointer for comparison
170235 */
171236 VDeck* get_deck () const { return &m_deck; }
201266 /// Auto-pronounce word on next/flip action
202267 void auto_pronounce_card (SideSelection side_);
203268
204 SideSelection get_selected_size () const { return m_selected_side; }
269 SideSelection get_selected_side () const { return m_selected_side; }
205270
206271 /** Remove all newlines and shrink all whitespace.
207272 */
220285 void set_sensitivity (); // De-sensetize inappropriate controls
221286 void set_win_name (); // Set tile name
222287
288 Pango::FontDescription question_font ();
289 Gtk::AlignmentEnum x_alignment_enum (SideSelection s_);
290 Gtk::AlignmentEnum y_alignment_enum (SideSelection s_);
291 Gtk::Justification justification_enum (SideSelection s_);
292 int x_padding_val (SideSelection s_);
293 int y_padding_val (SideSelection s_);
294
223295 /** If deck is empty, paralize controls. Deck can be loaded empty,
224296 * or become empty once the last card is removed. The reverse
225297 * applies as soon as first card is added.
235307 */
236308 Glib::ustring get_answer ();
237309
238 /** Adjust justification of the 'Answer' field depending on
239 * wether it is a single line or multiline
240 */
241 void set_answer_field (Glib::ustring answer_);
242
243310 /** Pango-markup tildas in the string
244311 */
245312 static Glib::ustring markup_tildas (const Glib::ustring& src_);
252319 bool check_F7_key (gint keyval_);
253320 bool check_F8_key (gint keyval_);
254321
255 #ifdef IS_HILDON
256322 Gtk::VBox* get_vbox () { return m_vbox; }
257 #endif
258323
259324 private:
260325
266331 Gtk::Button* m_shuffle_button;
267332 Gtk::Button* m_edit_button; // View/Edit a Deck
268333 Gtk::Button* m_vcard_edit_button; // Edit a Card
269 int m_match_front_row; // Which row to select for answer
334 int m_match_front_row; // Which row to select for answer
270335 Gtk::Label m_count_label;
271336 SideSelection m_selected_side;
272337 Gtk::Notebook* m_notebook;
274339 Gtk::Label m_front;
275340 Gtk::Label m_back;
276341 Gtk::Label m_example;
277 Gtk::SpinButton* m_test_line_button;
278
279 Gtk::VBox* m_answer_box; /* VBox that holds the back of a card */
280 int m_answer_box_width; /* last resize width */
342 TestLineEntry* m_test_line_entry;
343
344 Gtk::VBox* m_question_box; /* VBox that holds the front of a card */
345 int m_question_box_width; /* last resize width */
346 Gtk::VBox* m_answer_box; /* VBox that holds the back of a card */
347 int m_answer_box_width; /* last resize width */
281348
282349 VerifyControl* m_verify_control; // optional answer verification entry
283350
291358 Glib::RefPtr<Gdk::Pixbuf> m_playit_xpm; // Sound icon
292359 Gtk::Image* m_playit_icon;
293360
294 Gdk::Color m_bg_white;
295 Gdk::Color m_bg_pink;
296 Gdk::Color m_bg_black;
361 /** For compact portrait-like PDA mode
362 */
363 Glib::RefPtr<Gdk::Pixbuf> m_hide_control;
364 Glib::RefPtr<Gdk::Pixbuf> m_show_control;
365 Gtk::Button* m_hs_button_vc;
366 Gtk::Button* m_hs_button_ntb;
367
368 Gdk::Color m_text_fgcolor;
369 Gdk::Color m_text_bgcolor;
370 Gdk::Color m_sep_color;
297371
298372 VDeck& m_deck;
299373 VDeck::cardlist_iterator m_deck_iter; // Position in the Deck
307381 bool m_tab_activated; // Leave Tab+Spacebar/Enter event to Dialog
308382 bool m_initialized; // Has the object been fully constructed?
309383
310 #ifdef IS_HILDON
311384 Gtk::VBox* m_vbox;
312 #endif
385 Gtk::HBox* m_navigation_controls_hbox;
313386 };
314387
315388 inline void
00 // -*- c++ -*-
11 //------------------------------------------------------------------------------
2 // $Id: DeckView.cpp,v 1.48 2006/09/30 20:42:27 vlg Exp $
2 // $Id: DeckView.cpp,v 1.54 2007/01/15 04:09:08 vlg Exp $
33 //------------------------------------------------------------------------------
44 // DeckView.cpp
55 //------------------------------------------------------------------------------
3737 using sigc::bind;
3838 using sigc::mem_fun;
3939
40 #define DV_SETUP_LABEL(l) \
41 (l)->set_alignment (0.5,0.5); \
42 (l)->set_padding (0,0); \
43 (l)->set_justify (Gtk::JUSTIFY_LEFT); \
44 (l)->set_line_wrap (false); \
45 (l)->set_use_markup (false); \
46 (l)->set_selectable (false);
47
48 //------------------------------------------------------------------------------
49 // DeckView implementation
50 //------------------------------------------------------------------------------
4051 DeckView::
4152 DeckView (VDeck& deck_, int selected_row_)
4253 :
4354 #ifdef IS_HILDON
4455 Hildon::AppView ("Deck View"),
4556 #endif
46 m_add_button (manage (new Gtk::Button (Gtk::StockID ("gtk-add")))),
47 m_edit_button (manage (new ButtonWithImageLabel (
48 Gtk::Stock::DND, "Edit"))),
49 m_delete_button (manage (new Gtk::Button (Gtk::StockID("gtk-delete")))),
50 m_save_deck_button (manage (new ButtonWithImageLabel(
51 Gtk::Stock::SAVE,"Save Deck"))),
52 m_more_button (manage (new ButtonWithImageLabel (
53 Gtk::Stock::DIALOG_INFO, "Deck Info"))),
54 m_card_up_button (manage (new Gtk::Button (Gtk::Stock::GO_UP))),
55 m_card_down_button (manage (new Gtk::Button (Gtk::Stock::GO_DOWN))),
56 m_add_card_to_cardbox (manage (new ButtonWithImageLabel (
57 Gtk::Stock::UNDO, "Add to Box 1 "))),
5857 m_label_count (manage (new Gtk::Label ("0 cards"))),
5958 m_deck (deck_),
6059 m_row_idx (selected_row_),
6261 {
6362 trace_with_mask("DeckView::DeckView", GUITRACE);
6463
64 m_actgroup = Gtk::ActionGroup::create ();
65
66 m_actgroup->add (Gtk::Action::create ("Add",
67 Gtk::Stock::ADD,
68 "Add",
69 "Add new card"),
70 mem_fun (*this, &DeckView::on_add_clicked));
71
72 m_actgroup->add (Gtk::Action::create ("Edit",
73 Gtk::Stock::DND,
74 "Edit",
75 "Edit selected card"),
76 mem_fun (*this, &DeckView::on_edit_clicked));
77
78 m_actgroup->add (Gtk::Action::create ("Delete",
79 #ifdef WIN32
80 Gtk::Stock::CUT,
81 #else
82 Gtk::Stock::DELETE,
83 #endif
84 "Delete",
85 "Delete selected card"),
86 mem_fun (*this, &DeckView::on_delete_clicked));
87
88 m_actgroup->add (Gtk::Action::create ("Go_Up",
89 Gtk::Stock::GO_UP,
90 "Move Up",
91 "Move selecte card up"),
92 mem_fun (*this, &DeckView::on_card_up_clicked));
93
94 m_actgroup->add (Gtk::Action::create ("Go_Down",
95 Gtk::Stock::GO_DOWN,
96 "Move Down",
97 "Move selected card down"),
98 mem_fun (*this, &DeckView::on_card_down_clicked));
99
100 m_actgroup->add (Gtk::Action::create ("Add_Box1",
101 Gtk::Stock::UNDO,
102 "Add To Box1",
103 "Add selected card to Box1"),
104 mem_fun (*this, &DeckView::on_add_card_to_cardbox));
105
106 m_actgroup->add (Gtk::Action::create ("Deck_Info",
107 Gtk::Stock::DIALOG_INFO,
108 "Deck Info",
109 "Deck Information"),
110 mem_fun (*this, &DeckView::on_more_clicked));
111
112 m_actgroup->add (Gtk::Action::create ("Save_Deck",
113 Gtk::Stock::SAVE,
114 "Save",
115 "Save deck"),
116 mem_fun (*this, &DeckView::on_save_deck_clicked));
117
118 m_uimanager = Gtk::UIManager::create ();
119 m_uimanager->insert_action_group (m_actgroup);
120
121 #ifndef IS_HILDON
122 add_accel_group (m_uimanager->get_accel_group ());
123 #endif
124
125
126 /********************************
127 * Setup dialog attributes
128 ********************************/
65129 set_title("Deck View");
66 set_border_width (2);
67130
68131 #ifdef IS_HILDON
69132 /**
75138 add (*m_vbox);
76139 set_size_request (672, 396);
77140 #else
141 set_modal (true);
142 // set_position (Gtk::WIN_POS_CENTER_ALWAYS);
143 #ifdef IS_PDA
144 set_resizable(false);
145 Gdk::Geometry dp_geometry = { 240, 320, 240, 320, 240, 320, -1, -1, -1, -1};
146 set_geometry_hints (*this, dp_geometry,
147 Gdk::HINT_MIN_SIZE | Gdk::HINT_MAX_SIZE | Gdk::HINT_BASE_SIZE);
148 #else
78149 set_resizable(true);
79 set_position (Gtk::WIN_POS_CENTER_ALWAYS);
80 set_size_request (633, 410); // width; height
81 set_modal (true);
150 set_size_request (400, 370); // width; height
151 set_border_width (2);
82152 set_transient_for (*MAINWIN);
83 #endif
84
85 Gtk::Label* label_total = manage (new Gtk::Label ("Total: "));
86 Gtk::VBox* vbox = manage (new Gtk::VBox(false, 0));
87 Gtk::HBox* h_infobox = manage (new Gtk::HBox(false, 0));
88 Gtk::HBox* h_viewbox = manage (new Gtk::HBox(false, 0));
89
90 m_add_button ->set_flags (Gtk::CAN_FOCUS);
91 m_add_button ->set_relief (Gtk::RELIEF_NORMAL);
92 m_edit_button ->set_flags (Gtk::CAN_FOCUS);
93 m_edit_button ->set_relief (Gtk::RELIEF_NORMAL);
94 m_save_deck_button ->set_flags (Gtk::CAN_FOCUS);
95 m_save_deck_button ->set_relief (Gtk::RELIEF_NORMAL);
96 m_delete_button ->set_flags (Gtk::CAN_FOCUS);
97 m_delete_button ->set_relief (Gtk::RELIEF_NORMAL);
98 m_more_button ->set_flags (Gtk::CAN_FOCUS);
99 m_more_button ->set_relief (Gtk::RELIEF_NORMAL);
100 m_card_down_button ->set_flags (Gtk::CAN_FOCUS);
101 m_card_down_button ->set_relief (Gtk::RELIEF_NORMAL);
102 m_card_up_button ->set_flags (Gtk::CAN_FOCUS);
103 m_card_up_button ->set_relief (Gtk::RELIEF_NORMAL);
104 m_add_card_to_cardbox->set_flags (Gtk::CAN_FOCUS);
105 m_add_card_to_cardbox->set_relief (Gtk::RELIEF_NORMAL);
106
107 vbox->set_size_request (122,-1);
108 vbox->pack_start (*m_add_button, Gtk::PACK_SHRINK, 4);
109 vbox->pack_start (*m_edit_button, Gtk::PACK_SHRINK, 4);
110 vbox->pack_start (*m_delete_button, Gtk::PACK_SHRINK, 4);
111
112 vbox->pack_start (*m_card_up_button, Gtk::PACK_SHRINK, 4);
113 vbox->pack_start (*m_card_down_button, Gtk::PACK_SHRINK, 4);
114 vbox->pack_start (*m_add_card_to_cardbox, Gtk::PACK_SHRINK, 4);
115
116 vbox->pack_start (*m_more_button, Gtk::PACK_SHRINK, 4);
117 vbox->pack_start (*m_save_deck_button, Gtk::PACK_SHRINK, 4);
118
119 label_total->set_alignment (0.5,0.5);
120 label_total->set_padding (0,0);
121 label_total->set_justify (Gtk::JUSTIFY_LEFT);
122 label_total->set_line_wrap (false);
123 label_total->set_use_markup (false);
124 label_total->set_selectable (false);
125
126 m_label_count->set_alignment (0.5,0.5);
127 m_label_count->set_padding (0,0);
128 m_label_count->set_justify (Gtk::JUSTIFY_LEFT);
129 m_label_count->set_line_wrap (false);
130 m_label_count->set_use_markup (false);
131 m_label_count->set_selectable (false);
132
133 h_infobox->pack_start (*label_total, Gtk::PACK_SHRINK, 9);
134 h_infobox->pack_start (*m_label_count, Gtk::PACK_SHRINK, 0);
135
136 /** <Close> button
137 */
138 #ifdef IS_HILDON
139 m_close_button = manage (new ButtonWithImageLabel (Gtk::Stock::CLOSE,
140 "Close"));
141 #else
142 m_close_button = add_button (Gtk::StockID ("gtk-close"),
143 Gtk::RESPONSE_CLOSE );
144 #endif
145 m_close_button->set_flags (Gtk::CAN_FOCUS);
146 m_close_button->set_relief (Gtk::RELIEF_NORMAL);
147
148 m_close_button->signal_clicked ().connect (
149 mem_fun (*this, &DeckView::on_close_clicked));
150
151 /** List View
152 */
153 #endif // (!IS_PDA)
154 #endif // (!IS_HILDON)
155
156 /********************************
157 * Setup toolbar
158 ********************************/
159 try {
160 Glib::ustring ui_info =
161 "<ui>"
162 " <toolbar name='DV_Controls'>"
163 " <toolitem action='Add'/>"
164 " <toolitem action='Edit'/>"
165 " <toolitem action='Delete'/>"
166 " <toolitem action='Go_Up'/>"
167 " <toolitem action='Go_Down'/>"
168 " <toolitem action='Add_Box1'/>"
169 " <toolitem action='Deck_Info'/>"
170 " <toolitem action='Save_Deck'/>"
171 " </toolbar>"
172 "</ui>";
173 m_uimanager->add_ui_from_string (ui_info);
174 }
175 catch (const Glib::Error& ex_) {
176 DL((GRAPP,"Building menues failed (%s)\n", ex_.what ().c_str ()));
177 }
178
179 m_add_button = m_uimanager->get_widget ("/DV_Controls/Add");
180 m_edit_button = m_uimanager->get_widget ("/DV_Controls/Edit");
181 m_delete_button = m_uimanager->get_widget ("/DV_Controls/Delete");
182 m_card_up_button = m_uimanager->get_widget ("/DV_Controls/Go_Up");
183 m_card_down_button = m_uimanager->get_widget ("/DV_Controls/Go_Down");
184 m_add_card_to_cardbox = m_uimanager->get_widget ("/DV_Controls/Add_Box1");
185 m_more_button = m_uimanager->get_widget ("/DV_Controls/Deck_Info");
186 m_save_deck_button = m_uimanager->get_widget ("/DV_Controls/Save_Deck");
187
188 Gtk::Widget* controls = m_uimanager->get_widget ("/DV_Controls");
189 Gtk::Toolbar* ctrl_toolbar = dynamic_cast<Gtk::Toolbar*> (controls);
190
191 ctrl_toolbar->set_tooltips (true);
192 ctrl_toolbar->set_show_arrow ();
193 ctrl_toolbar->set_orientation (Gtk::ORIENTATION_HORIZONTAL);
194 ctrl_toolbar->set_toolbar_style (Gtk::TOOLBAR_ICONS);
195
196 get_vbox ()->pack_start (*ctrl_toolbar, Gtk::PACK_SHRINK, 0);
197
198 /**************************
199 * List View
200 **************************/
153201 m_scrollwin = manage (new Gtk::ScrolledWindow);
154202 m_scrollwin->set_shadow_type (Gtk::SHADOW_ETCHED_OUT);
155203 m_scrollwin->set_policy (Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
186234 m_list_store_ref->set_sort_func (
187235 1, (mem_fun (*this, &DeckView::on_sort_compare_back)));
188236
189 /** Create TreeView
190 */
237 /******************************
238 * Create TreeView
239 ******************************/
191240 DL((GRAPP,"Create TreeView\n"));
192241 m_tree_view.set_model (m_list_store_ref);
193242 m_tree_view.set_rules_hint ();
195244 Gtk::TreeView::Column* column;
196245 Gtk::CellRendererText* renderer;
197246
198 /** Front: Column
199 */
247 /******************************
248 * Front: Column
249 ******************************/
200250 column = Gtk::manage (new Gtk::TreeView::Column ("Front"));
201251 m_tree_view.append_column (*column);
202252 renderer = Gtk::manage (new Gtk::CellRendererText);
206256 m_columns.m_front_row);
207257
208258 column->set_sizing (Gtk::TREE_VIEW_COLUMN_FIXED);
209 column->set_fixed_width (140);
210259 column->set_resizable ();
211
212 /** Enable column sorting
213 */
260 #ifdef IS_PDA
261 column->set_fixed_width (125);
262 #else
263 column->set_fixed_width (250);
264 #endif
265
266 /******************************
267 * Enable column sorting
268 ******************************/
214269 column->set_sort_column_id (m_columns.m_front_row);
215270 column->set_sort_indicator (true);
216271 column->signal_clicked ().connect (
217272 mem_fun (*this, &DeckView::on_column_sorted));
218273
219 /** Back: Column
220 */
274 /******************************
275 * Back: Column
276 ******************************/
221277 column = Gtk::manage (new Gtk::TreeView::Column ("Back"));
222278 m_tree_view.append_column (*column);
223279 renderer = Gtk::manage (new Gtk::CellRendererText);
229285 column->set_sizing (Gtk::TREE_VIEW_COLUMN_FIXED);
230286 column->set_fixed_width (140);
231287
232 /** Enable column sorting
233 */
288 /****************************
289 * Enable column sorting
290 ****************************/
234291 column->set_sort_column_id (m_columns.m_back_row);
235292 column->set_sort_indicator (true);
236293 column->signal_clicked ().connect (
241298 m_tree_sel_ref->signal_changed ().connect (
242299 mem_fun (*this, &DeckView::on_card_selected));
243300
301 m_tree_view.add_events (Gdk::BUTTON_PRESS_MASK);
302 m_tree_view.signal_button_press_event ().connect (
303 sigc::mem_fun (*this, &DeckView::on_mouse_click), false);
304
244305 m_scrollwin->add (m_tree_view);
245306
246 /** Initialize callbacks
247 */
248 m_add_button->signal_clicked ().connect (
249 mem_fun (*this, &DeckView::on_add_clicked));
250 m_edit_button->signal_clicked ().connect (
251 mem_fun (*this, &DeckView::on_edit_clicked));
252 m_save_deck_button->signal_clicked ().connect (
253 mem_fun (*this, &DeckView::on_save_deck_clicked));
254 m_delete_button->signal_clicked ().connect (
255 mem_fun (*this, &DeckView::on_delete_clicked));
256 m_more_button->signal_clicked ().connect (
257 mem_fun (*this, &DeckView::on_more_clicked));
258 m_card_up_button->signal_clicked ().connect (
259 mem_fun (*this, &DeckView::on_card_up_clicked));
260 m_card_down_button->signal_clicked ().connect (
261 mem_fun (*this, &DeckView::on_card_down_clicked));
262 m_add_card_to_cardbox->signal_clicked ().connect (
263 mem_fun (*this, &DeckView::on_add_card_to_cardbox));
264
265 /** Pack 'em all
266 */
267 h_viewbox->pack_start (*m_scrollwin);
268 h_viewbox->pack_start (*vbox, Gtk::PACK_SHRINK, 8);
269
307 /*****************************
308 * Pack the cards list
309 *****************************/
310 Gtk::HBox* h_viewbox = manage (new Gtk::HBox(false, 0));
311 h_viewbox->pack_start (*m_scrollwin, Gtk::PACK_EXPAND_WIDGET, 0);
270312 get_vbox ()->pack_start (*h_viewbox);
313
314 /***********************************
315 * h_infobox holds:
316 * -------------------------
317 * [Total:] [XXX cards]
318 ***********************************/
319 Gtk::Label* label_total = manage (new Gtk::Label ("Total: "));
320 Gtk::HBox* h_infobox = manage (new Gtk::HBox(false, 0));
321
322 DV_SETUP_LABEL(label_total);
323 DV_SETUP_LABEL(m_label_count);
324
325 h_infobox->pack_start (*label_total, Gtk::PACK_SHRINK, 9);
326 h_infobox->pack_start (*m_label_count, Gtk::PACK_SHRINK, 0);
327
271328 get_vbox ()->pack_start (*h_infobox, Gtk::PACK_SHRINK, 4);
329
330 /** <Close> button
331 */
332 #ifdef IS_HILDON // Handle the button ourselves
333 m_close_button = manage (new ButtonWithImageLabel (Gtk::Stock::CLOSE,
334 "Close"));
335 #else // Add button to the Gtk::Dialog
336 m_close_button = add_button (Gtk::StockID ("gtk-close"),
337 Gtk::RESPONSE_CLOSE );
338 #endif
339 m_close_button->set_flags (Gtk::CAN_FOCUS);
340 m_close_button->set_relief (Gtk::RELIEF_NORMAL);
341
342 m_close_button->signal_clicked ().connect (
343 mem_fun (*this, &DeckView::on_close_clicked));
272344
273345 #ifdef IS_HILDON
274346 /**
281353 hbuttonbox->set_spacing (6);
282354 hbuttonbox->set_border_width (6);
283355
284 get_vbox ()->pack_start (*hbuttonbox, false, true, 0);
285 hbuttonbox->pack_end (*m_close_button, false, true, 0);
356 Gtk::Label* expander = manage (new Gtk::Label (""));
357 hbuttonbox->pack_start (*expander, Gtk::PACK_EXPAND_WIDGET);
358 hbuttonbox->pack_end (*m_close_button, Gtk::PACK_SHRINK);
359
360 get_vbox ()->pack_start (*hbuttonbox, Gtk::PACK_SHRINK);
361
286362 #endif
287363
288364 set_cards_count ();
289
290365 show_all ();
291366
292367 /** Select the same row (card) that the DeckPlayer has selected,
310385 set_sensitivity ();
311386 set_win_name ();
312387
313 #ifndef IS_HILDON
388 #if !defined(IS_HILDON) && !defined (IS_PDA)
314389 set_icon_from_file (GRAPPDATDIR "/pixmaps/deckview_32x32.png");
315390 #endif
316391
327402 set_cards_count ()
328403 {
329404 std::ostringstream os;
405
330406 os << m_deck.size () << " cards.";
331407 m_label_count->set_text (os.str ());
332408 }
335411 // Callbacks
336412 //------------------------------------------------------------------------------
337413
414 //#ifdef IS_HILDON
415 gint
416 DeckView::
417 run ()
418 {
419 trace_with_mask("DeckView::run",GUITRACE);
420
338421 #ifdef IS_HILDON
339 gint
340 DeckView::
341 run ()
342 {
343 trace_with_mask("DeckView::run",GUITRACE);
344
345422 GRANULE->register_appview (this);
423 #endif
346424 Gtk::Main::run ();
347425 return (Gtk::RESPONSE_NONE);
348426 }
349 #endif
427 //#endif
350428
351429 void
352430 DeckView::
357435 #ifdef IS_HILDON
358436 hide ();
359437 GRANULE->unregister_appview (this);
438 #endif
360439 DL ((GRAPP,"Call Main::quit()\n"));
361440 Gtk::Main::quit ();
362 #endif
363441 }
364442
365443 void
421499 {
422500 trace_with_mask("DeckView::on_add_clicked", GUITRACE);
423501
502 hide ();
503
424504 CardView cview (new Card);
425505
426506 int ret = cview.run (*this);
439519 DL((GRAPP|ASSA::ASSAERR, "Unexpected response = %d, "
440520 "see /path/to/gtkmm/dialog.h for details.\n", ret));
441521 }
522 show ();
442523 }
443524
444525 void
455536 Gtk::TreeModel::Row row = *m_list_store_ref->children ()[m_row_idx];
456537 VCard* card_iter = row [m_columns.m_card];
457538
458 #ifdef IS_HILDON
539 //#ifdef IS_HILDON
459540 hide ();
460 #endif
541 //#endif
461542
462543 CardView cview (card_iter);
463544 int ret = cview.run ();
469550 Granule::trim_multiline(card_iter->get_answer ());
470551 }
471552
472 #ifdef IS_HILDON
553 //#ifdef IS_HILDON
473554 show ();
474 #endif
555 //#endif
475556 }
476557
477558 void
593674 #ifdef IS_HILDON
594675 DeckInfo deck_info (*HILDONAPPWIN, dynamic_cast<Deck&>(m_deck));
595676 deck_info.run ();
677 m_repaint_player = deck_info.appearance_changed ();
596678 #else
597679 DeckInfo deck_info (*this, dynamic_cast<Deck&>(m_deck));
598680 deck_info.run ();
681 m_repaint_player = deck_info.appearance_changed ();
599682 #endif
600683
601684 }
852935
853936 DECKMGR->save_deck_cb ();
854937 }
938
939 /** Called when button is pressed on any of the rows.
940 We filter out everything except for the double-click
941 which brings the CardView dialog to edit selected entry.
942
943 The rest of the events are handled by the default event
944 handler of TreeView afterwards.
945 */
946 bool
947 DeckView::
948 on_mouse_click (GdkEventButton* event_)
949 {
950 trace_with_mask("DeckView::on_mouse_click", GUITRACE);
951
952 if (event_->type == GDK_2BUTTON_PRESS
953 #ifdef IS_HILDON
954 || event_->type == GDK_Escape // Hildon round button (Cancel,Close)
955 #endif
956 )
957 {
958 on_edit_clicked ();
959 }
960 return false;
961 }
00 // -*- c++ -*-
11 //------------------------------------------------------------------------------
2 // $Id: DeckView.h,v 1.26 2006/09/21 01:25:20 vlg Exp $
2 // $Id: DeckView.h,v 1.31 2007/01/03 03:49:11 vlg Exp $
33 //------------------------------------------------------------------------------
44 // DeckView.h
55 //------------------------------------------------------------------------------
3030 #include <gtkmm/treeview.h>
3131 #include <gtkmm/liststore.h>
3232 #include <gtkmm/scrolledwindow.h>
33 #include <gtkmm/uimanager.h>
34 #include <gtkmm/toolbar.h>
3335
3436 #ifdef IS_HILDON
3537 #include <hildon-widgetsmm/appview.h>
4749 DeckView (VDeck& deck_, int selected_row_);
4850 ~DeckView ();
4951
50 #ifdef IS_HILDON
52 //#ifdef IS_HILDON
5153 gint run ();
52 #endif
54 //#endif
5355
5456 /** Has the Deck been modified so that it might invalidate
5557 the iterators? Deleting a card and moving card(s) up/down
5860 */
5961 bool is_modified () const { return m_modified; }
6062
61 /** User selected a row in the cards view
63 /** Return true if user changed Appearance settings with
64 DeckInfo dialog.
65 */
66 bool appearance_changed () const { return m_repaint_player; }
67
68 /** User selected a row in the cards view list.
6269 */
6370 void on_card_selected ();
71
72 /** User double-clicked on a row in the cards view list.
73 */
74 bool on_mouse_click (GdkEventButton* event_);
6475
6576 /** Called in response to pressing <Close> button
6677 */
99110
100111 void add_new_card (Card* card_);
101112
113 /// Return number of cards in the view
114 int get_deck_size () const;
115
102116 private:
103117 /** Column sorting implementation
104118 */
134148 Gtk::TreeModelColumn<Glib::ustring> m_back_row;
135149 Gtk::TreeModelColumn<VCard*> m_card; // Hidden Card reference.
136150
137 ModelColumns ()
138 {
139 add (m_front_row); add (m_back_row); add (m_card);
140 }
151 ModelColumns () { add (m_front_row); add (m_back_row); add (m_card); }
141152 };
142153
143154 const ModelColumns m_columns;
151162 Glib::RefPtr<Gtk::TreeSelection> m_tree_sel_ref;
152163
153164 private:
154 Gtk::Button* m_add_button;
155 Gtk::Button* m_edit_button;
156 Gtk::Button* m_delete_button;
157 Gtk::Button* m_save_deck_button;
165 Glib::RefPtr<Gtk::UIManager> m_uimanager;
166 Glib::RefPtr<Gtk::ActionGroup> m_actgroup;
167
168 /** Control buttons
169 */
170 Gtk::Widget* m_add_button;
171 Gtk::Widget* m_edit_button;
172 Gtk::Widget* m_delete_button;
173 Gtk::Widget* m_card_up_button;
174 Gtk::Widget* m_card_down_button;
175 Gtk::Widget* m_add_card_to_cardbox;
176 Gtk::Widget* m_more_button;
177 Gtk::Widget* m_save_deck_button;
178
158179 Gtk::Button* m_close_button;
159 Gtk::Button* m_more_button;
160 Gtk::Button* m_card_up_button;
161 Gtk::Button* m_card_down_button;
162 Gtk::Button* m_add_card_to_cardbox;
163180
164181 Gtk::Label* m_label_count;
165182
166183 VDeck& m_deck;
167184 int m_row_idx; // The row selected in the model
168 bool m_modified; // Has Deck been modified to invalidate
185 bool m_modified; // Has Deck been modified to invalidate?
186 bool m_repaint_player; // Has Appearance prefs been modified?
169187
170188 #ifdef IS_HILDON
171189 Gtk::VBox* m_vbox;
173191
174192 };
175193
194 inline int
195 DeckView::
196 get_deck_size () const
197 {
198 return (m_deck.size ());
199 }
200
176201 #endif /* DECK_VIEWER_H */
00 // -*- c++ -*-
11 //------------------------------------------------------------------------------
2 // $Id: EditControls.cpp,v 1.7 2006/06/14 02:34:38 vlg Exp $
2 // $Id: EditControls.cpp,v 1.10 2007/01/03 03:49:11 vlg Exp $
33 //------------------------------------------------------------------------------
44 // EditControls.cpp
55 //------------------------------------------------------------------------------
1515 //
1616 //------------------------------------------------------------------------------
1717
18 #include <gtkmm/table.h>
18 #include <sstream>
19
20 #include <gtkmm/stock.h>
21 #include <gtkmm/iconfactory.h>
1922
2023 #include "Granule-main.h"
2124 #include "EditControls.h"
25 #include "MyInputDialog.h"
26
27 #include "Intern.h"
2228
2329 using Gtk::Image;
2430
31 Gtk::StockID EditControls::BOLD ("bold");
32 Gtk::StockID EditControls::ITALIC ("italic");
33 Gtk::StockID EditControls::UNDERLINE ("underline");
34 Gtk::StockID EditControls::MONOSPACE ("monospace");
35 Gtk::StockID EditControls::SUBSCRIPT ("subscript");
36 Gtk::StockID EditControls::SUPERSCRIPT ("superscript");
37 Gtk::StockID EditControls::BIG ("big");
38 Gtk::StockID EditControls::SMALL ("small");
39 Gtk::StockID EditControls::REMOVETAGS ("remove_tags");
40 Gtk::StockID EditControls::PASTE ("paste");
41 Gtk::StockID EditControls::NORMALIZE ("normalize");
42 Gtk::StockID EditControls::ADDINDEX ("add_index");
43
44 /**-----------------------------------------------------------------------------
45 */
46 static void
47 add_icon_to_factory (Glib::RefPtr<Gtk::IconFactory>& ifactory_,
48 Glib::RefPtr<Gdk::Pixbuf>& pixbuf_,
49 Gtk::StockID& id_)
50 {
51 Gtk::IconSet iset;
52 Gtk::IconSource isource;
53
54 isource.set_pixbuf (pixbuf_);
55 isource.set_size (Gtk::ICON_SIZE_BUTTON);
56 iset.add_source (isource);
57 ifactory_->add (id_, iset);
58 Gtk::Stock::add (Gtk::StockItem (id_, id_.get_string ()));
59 }
60
61 /**-----------------------------------------------------------------------------
62 */
2563 EditControls::
2664 EditControls (Glib::RefPtr<Gtk::TextBuffer> tb_ref_)
27 : Gtk::HBox (false, 2),
28 m_textbuf (tb_ref_)
65 : Gtk::HBox (false, 0),
66 m_textbuf (tb_ref_),
67 m_index_count (1)
2968 {
3069 trace_with_mask("EditControls::EditControls", GUITRACE);
3170
71 Gtk::Button* button;
3272 Glib::RefPtr<Gdk::Pixbuf> pixbuf_ref;
33
34 vector<Glib::ustring> widget_names;
35 widget_names.push_back ("TextBold");
36 widget_names.push_back ("TextItalic");
37 widget_names.push_back ("TextUnderline");
38 widget_names.push_back ("TextMonospace");
39 widget_names.push_back ("TextSubscript");
40 widget_names.push_back ("TextSuperscript");
41 widget_names.push_back ("TextBig");
42 widget_names.push_back ("TextSmall");
43 widget_names.push_back ("TextRemoveTags");
44 widget_names.push_back ("TextPaste");
73 Glib::RefPtr<Gtk::IconFactory> ifactory = Gtk::IconFactory::create ();
4574
4675 pixbuf_ref = Gdk::Pixbuf::create_from_file (
4776 GRAPPDATDIR "pixmaps/text_bold.png");
48 m_icon_list.push_back (icon_t ("bold",
49 manage (new Image (pixbuf_ref))));
50
77 add_icon_to_factory (ifactory, pixbuf_ref, EditControls::BOLD);
78 m_icon_list.push_back (icon_t (EditControls::BOLD,
79 manage (new Image (pixbuf_ref)),
80 "Apply bold tag"));
81
5182 pixbuf_ref = Gdk::Pixbuf::create_from_file (
5283 GRAPPDATDIR "pixmaps/text_italic.png");
53 m_icon_list.push_back (icon_t ("italic",
54 manage (new Image (pixbuf_ref))));
84 add_icon_to_factory (ifactory, pixbuf_ref, EditControls::ITALIC);
85 m_icon_list.push_back (icon_t (EditControls::ITALIC,
86 manage (new Image (pixbuf_ref)),
87 "Apply italic tag"));
5588
5689 pixbuf_ref = Gdk::Pixbuf::create_from_file (
5790 GRAPPDATDIR "pixmaps/text_underlined.png");
58 m_icon_list.push_back (icon_t ("underline",
59 manage (new Image (pixbuf_ref))));
91 add_icon_to_factory (ifactory, pixbuf_ref, EditControls::UNDERLINE);
92 m_icon_list.push_back (icon_t (EditControls::UNDERLINE,
93 manage (new Image (pixbuf_ref)),
94 "Apply underline tag"));
6095
6196 pixbuf_ref = Gdk::Pixbuf::create_from_file (
6297 GRAPPDATDIR "pixmaps/text_monospaced.png");
63 m_icon_list.push_back (icon_t ("monospace",
64 manage (new Image (pixbuf_ref))));
98 add_icon_to_factory (ifactory, pixbuf_ref, EditControls::MONOSPACE);
99 m_icon_list.push_back (icon_t (EditControls::MONOSPACE,
100 manage (new Image (pixbuf_ref)),
101 "Apply monospace tag"));
65102
66103 pixbuf_ref = Gdk::Pixbuf::create_from_file (
67104 GRAPPDATDIR "pixmaps/text_subscript.png");
68 m_icon_list.push_back (icon_t ("subscript",
69 manage (new Image (pixbuf_ref))));
105 add_icon_to_factory (ifactory, pixbuf_ref, EditControls::SUBSCRIPT);
106 m_icon_list.push_back (icon_t (EditControls::SUBSCRIPT,
107 manage (new Image (pixbuf_ref)),
108 "Apply subscript tag"));
70109
71110 pixbuf_ref = Gdk::Pixbuf::create_from_file (
72111 GRAPPDATDIR "pixmaps/text_superscript.png");
73 m_icon_list.push_back (icon_t ("superscript",
74 manage (new Image (pixbuf_ref))));
112 add_icon_to_factory (ifactory, pixbuf_ref, EditControls::SUPERSCRIPT);
113 m_icon_list.push_back (icon_t (EditControls::SUPERSCRIPT,
114 manage (new Image (pixbuf_ref)),
115 "Apply superscript tag"));
75116
76117 pixbuf_ref = Gdk::Pixbuf::create_from_file (
77118 GRAPPDATDIR "pixmaps/text_big.png");
78 m_icon_list.push_back (icon_t ("big",
79 manage (new Image (pixbuf_ref))));
119 add_icon_to_factory (ifactory, pixbuf_ref, EditControls::BIG);
120 m_icon_list.push_back (icon_t (EditControls::BIG,
121 manage (new Image (pixbuf_ref)),
122 "Make selection bigger"));
80123
81124 pixbuf_ref = Gdk::Pixbuf::create_from_file (
82125 GRAPPDATDIR "pixmaps/text_small.png");
83 m_icon_list.push_back (icon_t ("small",
84 manage (new Image (pixbuf_ref))));
126 add_icon_to_factory (ifactory, pixbuf_ref, EditControls::SMALL);
127 m_icon_list.push_back (icon_t (EditControls::SMALL,
128 manage (new Image (pixbuf_ref)),
129 "Make selection smaller"));
85130
86131 pixbuf_ref = Gdk::Pixbuf::create_from_file (
87132 GRAPPDATDIR "pixmaps/text_remove_tags.png");
88 m_icon_list.push_back (icon_t ("remove_tags",
89 manage (new Image (pixbuf_ref))));
133 add_icon_to_factory (ifactory, pixbuf_ref, EditControls::REMOVETAGS);
134 m_icon_list.push_back (icon_t (EditControls::REMOVETAGS,
135 manage (new Image (pixbuf_ref)),
136 "Remove all tags"));
90137
91138 pixbuf_ref = Gdk::Pixbuf::create_from_file (
92139 GRAPPDATDIR "pixmaps/text_paste.png");
93 m_icon_list.push_back (icon_t ("paste",
94 manage (new Image (pixbuf_ref))));
95
96 icon_list_t::iterator iter = m_icon_list.begin ();
97
98 Gtk::Button* button;
99 Gtk::Table* elems_table = Gtk::manage (new Gtk::Table (2, 5, false));
100
101 elems_table->set_border_width (0);
102 elems_table->set_row_spacings (1);
103 elems_table->set_col_spacings (1);
104 elems_table->set_name ("EditControlsTable");
105
106 int row = 0;
107 int col = 0;
140 add_icon_to_factory (ifactory, pixbuf_ref, EditControls::PASTE);
141 m_icon_list.push_back (icon_t (EditControls::PASTE,
142 manage (new Image (pixbuf_ref)),
143 "Paste from clipboard"));
144
145 pixbuf_ref = Gdk::Pixbuf::create_from_file (
146 GRAPPDATDIR "pixmaps/text_normalize.png");
147 add_icon_to_factory (ifactory, pixbuf_ref, EditControls::NORMALIZE);
148 m_icon_list.push_back (icon_t (EditControls::NORMALIZE,
149 manage (new Image (pixbuf_ref)),
150 "Remove extra spaces and newlines"));
151
152 pixbuf_ref = Gdk::Pixbuf::create_from_file (
153 GRAPPDATDIR "pixmaps/text_addindex.png");
154 add_icon_to_factory (ifactory, pixbuf_ref, EditControls::ADDINDEX);
155 m_icon_list.push_back (icon_t (EditControls::ADDINDEX,
156 manage (new Image (pixbuf_ref)),
157 "Add reference index"));
158
159 ifactory->add_default ();
160
161 /** Setup toolbar of buttons. This is a requirement
162 * imposed on us by broken implementation of the
163 * virtual keyboard in maemo as well as portrait
164 * geometry considerations for OpenHand PDAs.
165 */
166 m_actgroup = Gtk::ActionGroup::create ();
108167
109168 /** unset_flags () takes buttons out of the dialog's focus chain.
110169 There is no other way it can be achieved with set_focus_chain()
111170 in CardView dialog. I tried it and it doesn't work.
112171 */
113
114 while (iter != m_icon_list.end ()) {
172 icon_list_t::iterator iter = m_icon_list.begin ();
173 while (iter != m_icon_list.end ())
174 {
115175 button = manage (new Gtk::Button ());
116176 button->unset_flags (Gtk::CAN_FOCUS);
117 button->add (*((*iter).second));
118 elems_table->attach (*button, col, col+1, row, row+1,
119 Gtk::FILL, Gtk::FILL, 0, 0);
120 if (++col == 2) {
121 row++;
122 col = 0;
123 }
124 button->signal_clicked ().connect (
125 bind<string>(mem_fun(*this, &EditControls::on_edit_button_clicked),
126 (*iter).first));
177 button->add (*((*iter).get_image ()));
178
179 m_actgroup->add (Gtk::Action::create ((*iter).get_name (),
180 (*iter).get_stock_id (),
181 (*iter).get_name (),
182 (*iter).get_tooltip ()),
183 bind<string>(mem_fun (*this,
184 &EditControls::on_edit_button_clicked),
185 (*iter).get_name ()));
127186 iter++;
128187 }
129188
130 this->pack_start (*elems_table, Gtk::PACK_SHRINK);
189 m_uimanager = Gtk::UIManager::create ();
190 m_uimanager->insert_action_group (m_actgroup);
191
192 try {
193 Glib::ustring ui_info =
194 "<ui>"
195 " <toolbar name='EditControls'>"
196 " <toolitem action='paste'/>"
197 " <toolitem action='remove_tags'/>"
198 " <toolitem action='small'/>"
199 " <toolitem action='superscript'/>"
200 " <toolitem action='subscript'/>"
201 " <toolitem action='bold'/>"
202 " <toolitem action='italic'/>"
203 " <toolitem action='monospace'/>"
204 " <toolitem action='big'/>"
205 " <toolitem action='normalize'/>"
206 " <toolitem action='add_index'/>"
207 " </toolbar>"
208 "</ui>";
209 m_uimanager->add_ui_from_string (ui_info);
210 }
211 catch (const Glib::Error& ex_) {
212 DL((GRAPP,"Building menues failed (%s)\n", ex_.what ().c_str ()));
213 }
214 Gtk::Widget* controls = m_uimanager->get_widget ("/EditControls");
215 Gtk::Toolbar* ctrl_toolbar = dynamic_cast<Gtk::Toolbar*> (controls);
216
217 ctrl_toolbar->set_orientation (Gtk::ORIENTATION_HORIZONTAL);
218 ctrl_toolbar->set_toolbar_style (Gtk::TOOLBAR_ICONS);
219 ctrl_toolbar->set_tooltips (true);
220
221 /** Pack all up
222 */
223 this->pack_start (*ctrl_toolbar, Gtk::PACK_EXPAND_WIDGET, 0);
131224 }
132225
133226 void
135228 on_edit_button_clicked (const string& action_)
136229 {
137230 trace_with_mask("EditControls::on_edit_button_clicked",GUITRACE);
138
139 DL ((GRAPP,"Inserting <%s> tag.\n", action_.c_str ()));
231
232 DL ((GRAPP,"Processing <%s> tag request.\n", action_.c_str ()));
233
234 if (action_ == "normalize") {
235 normalize_text ();
236 return;
237 }
140238
141239 Gtk::TextBuffer::iterator iter;
142240 Gtk::TextBuffer::iterator start_iter;
148246 Comparing the marks, however, turned out to be useless -
149247 you ought to compares iterators only.
150248 */
151 if (!m_textbuf->get_selection_bounds (start_iter, end_iter)) {
152 DL ((GRAPP,"No selection has been made.\n"));
249 if (!m_textbuf->get_selection_bounds (start_iter, end_iter))
250 {
251 DL ((GRAPP,"No selection is made.\n"));
153252 if (action_ == "paste") {
154253 Glib::RefPtr<Gtk::Clipboard> ref_clipboard = Gtk::Clipboard::get ();
155254 ref_clipboard->request_text (
156255 sigc::mem_fun(*this,&EditControls::on_clipboard_text_received));
157256 }
158 return;
159 }
160
161 if (start_iter == end_iter) {
162 DL ((GRAPP,"Selection size is 0.\n"));
163257 return;
164258 }
165259
215309 else if (action_ == "remove_tags") {
216310 remove_tags (mb, me);
217311 }
312 else if (action_ == "add_index") {
313 add_index (mb, me);
314 }
218315 else {
219316 DL ((GRAPP,"Unexpected action!\n"));
220317 }
236333 {
237334 trace_with_mask("EditControls::remove_tags",GUITRACE);
238335
239 gunichar open_brace = '<';
240 gunichar close_brace = '>';
241
336 static const gunichar open_brace = '<';
337 static const gunichar close_brace = '>';
338
339 Glib::RefPtr<Gtk::TextBuffer::Mark> start_mark;
242340 Gtk::TextBuffer::iterator next_ch = begin_mark_->get_iter ();
243341 Gtk::TextBuffer::iterator last_ch = end_mark_->get_iter ();
244342
246344 display_unichar_at (next_ch),
247345 display_unichar_at (last_ch)));
248346
249 while (next_ch && next_ch != last_ch) {
250 if (next_ch.get_char () == open_brace) {
251 Glib::RefPtr<Gtk::TextBuffer::Mark> start_mark;
347 while (next_ch && next_ch != last_ch)
348 {
349 if (next_ch.get_char () == open_brace)
350 {
252351 start_mark = m_textbuf->create_mark ("start", next_ch);
253352 next_ch++;
254353
255 DL ((GRAPP,"outer: next_ch='%c', last_ch='%c'\n",
256 display_unichar_at (next_ch),
257 display_unichar_at (last_ch)));
354 DL ((GRAPP,"outer: next_ch='%c'\n", display_unichar_at (next_ch)));
258355
259356 while (next_ch && next_ch != last_ch) {
260357 if (next_ch.get_char () == close_brace) {
267364
268365 next_ch = start_mark->get_iter ();
269366 last_ch = end_mark_->get_iter ();
270
271 DL ((GRAPP,"erase: next_ch='%c', last_ch='%c'\n",
272 display_unichar_at (next_ch),
273 display_unichar_at (last_ch)));
274367 break;
275368 }
276369 next_ch++;
277370
278 DL ((GRAPP,"inner: next_ch='%c', last_ch='%c'\n",
279 display_unichar_at (next_ch),
280 display_unichar_at (last_ch)));
371 DL ((GRAPP,"inner: next_ch='%c'\n",
372 display_unichar_at(next_ch)));
281373 }
282374 m_textbuf->delete_mark (start_mark);
283375 }
284 next_ch++;
285
286 DL ((GRAPP,"outer: next_ch='%c', last_ch='%c'\n",
287 display_unichar_at (next_ch),
288 display_unichar_at (last_ch)));
289 }
376 if (next_ch.get_char () != open_brace) {
377 next_ch++;
378 }
379 DL ((GRAPP,"outer: next_ch='%c'\n", display_unichar_at (next_ch)));
380 }
381 }
382
383 /**
384 * Replace all newline characters with white spaces, and then
385 * remove extra adjacent white spaces. This comes especially
386 * handy when you copy-n-paste text from preformatted source
387 * which has text evenly distributed on each line (like a book).
388 */
389 void
390 EditControls::
391 normalize_text ()
392 {
393 trace_with_mask("EditControls::normalize_text",GUITRACE);
394
395 static const gunichar newline = '\n';
396 static const gunichar space = ' ';
397
398 bool inside_wsp = false;
399 Glib::ustring dest1;
400 Glib::ustring dest2;
401 Gtk::TextBuffer::iterator iter;
402 gunichar ch;
403
404 /** First pass - replace newlines
405 */
406 iter = m_textbuf->begin ();
407 while (iter != m_textbuf->end ()) {
408 ch = iter.get_char ();
409 if (ch == newline) {
410 dest1 += space;
411 }
412 else {
413 dest1 += ch;
414 }
415 iter++;
416 }
417 DL ((GRAPP,"dest1 =\"%s\"\n", dest1.c_str ()));
418
419 /** Second pass - replace extra adjancent white spaces.
420 */
421 for (int idx = 0; idx < dest1.length (); idx++)
422 {
423 if (dest1 [idx] != space) {
424 dest2 += dest1 [idx];
425 if (inside_wsp) { /* left whitespace block */
426 inside_wsp = false;
427 }
428 }
429 else {
430 if (!inside_wsp) { /* entered whitespace block */
431 dest2 += dest1 [idx];
432 inside_wsp = true;
433 }
434 }
435 }
436
437 DL ((GRAPP,"dest2 =\"%s\"\n", dest2.c_str ()));
438 m_textbuf->set_text (dest2);
439 }
440
441 /**
442 * Execute canned operation: if selection is being made,
443 * ask the user for the index number, and then
444 * surround selected box with
445 *
446 * <i>selected_block</i><sup>index</sup>
447 *
448 * Also, add the reference at the end of the text:
449 *
450 * [index] <i>selected_block</i> -
451 */
452 void
453 EditControls::
454 add_index (Glib::RefPtr<Gtk::TextBuffer::Mark> begin_mark_,
455 Glib::RefPtr<Gtk::TextBuffer::Mark> end_mark_)
456 {
457 trace_with_mask("EditControls::add_index",GUITRACE);
458
459 std::ostringstream oss;
460 Glib::ustring selection;
461 Glib::ustring s;
462 Glib::ustring idx_val;
463
464 oss << m_index_count;
465 MyInputDialog ask_index (_("Enter index number:"), oss.str ());
466 oss.str ("");
467
468 if (ask_index.run () == Gtk::RESPONSE_CANCEL) {
469 DL ((GRAPP, "action cancelled\n"));
470 return;
471 }
472 idx_val = ask_index.get_entry_value ();
473
474 selection = m_textbuf->get_slice (begin_mark_->get_iter (),
475 end_mark_->get_iter ());
476
477 m_textbuf->insert (begin_mark_->get_iter (), "<i>");
478 s = "</i><sup>" + idx_val + "</sup>";
479 m_textbuf->insert (end_mark_->get_iter (), s);
480
481 s = "\n[" + idx_val + "] <i>" + selection + "</i> - ";
482 m_textbuf->insert (m_textbuf->end (), s);
483
484 m_index_count = ::atoi (idx_val.c_str ());
485 m_index_count++;
290486 }
291487
292488 /**
322518 if (m_textbuf != text_view_->get_buffer ()) {
323519 m_textbuf->place_cursor (m_textbuf->begin ()); // cancel old select
324520 m_textbuf = text_view_->get_buffer ();
325 }
326 }
327
521 #ifdef IS_HILDON
522 m_start_mark.clear ();
523 m_end_mark.clear ();
524 #endif
525 }
526 }
527
528
529 /**
530 *
531 */
532 #ifdef IS_HILDON
533 void
534 EditControls::
535 on_mark_set (const Gtk::TextBuffer::iterator& iter_,
536 const Glib::RefPtr<Gtk::TextBuffer::Mark>& mark_)
537 {
538 Glib::RefPtr<Gtk::TextBuffer::Mark> start;
539 Glib::RefPtr<Gtk::TextBuffer::Mark> end;
540
541 start = m_textbuf->get_insert ();
542 end = m_textbuf->get_selection_bound ();
543
544 if (start == mark_ || end == mark_) { // Selection changed
545 if (start != end) {
546 m_start_mark = start;
547 m_end_mark = end;
548 }
549 }
550 }
551
552 #endif
00 // -*- c++ -*-
11 //------------------------------------------------------------------------------
2 // $Id: EditControls.h,v 1.3 2006/02/27 01:15:20 vlg Exp $
2 // $Id: EditControls.h,v 1.7 2007/01/07 03:00:43 vlg Exp $
33 //------------------------------------------------------------------------------
44 // EditControls.h
55 //------------------------------------------------------------------------------
1919
2020 #include <gtkmm/box.h>
2121 #include <gtkmm/textview.h>
22 #include <gtkmm/box.h>
2322 #include <gdkmm/pixbuf.h>
2423 #include <gtkmm/image.h>
2524 #include <gtkmm/clipboard.h>
25 #include <gtkmm/uimanager.h>
26 #include <gtkmm/toolbar.h>
2627
2728 using sigc::bind;
2829 using sigc::mem_fun;
3334 using std::vector;
3435 using std::string;
3536
36 /** EditControls is a collection of markup edit buttons
37 that are embedded in CardView for quick editing
38 the text in the input fields.
39 */
37 /**=============================================================================
38 ** MyIconInfo holds all information pertinent to the icon.
39 **=============================================================================
40 */
41 class MyIconInfo
42 {
43 public:
44 MyIconInfo (Gtk::StockID sid_, Gtk::Image* imgp_, const char* tooltip_)
45 :
46 m_stock_id (sid_), m_image_ref (imgp_), m_tooltip (tooltip_)
47 {
48 /* no-op */
49 }
50
51 Gtk::StockID get_stock_id () const { return m_stock_id; }
52 Glib::ustring get_name () const { return m_stock_id.get_string (); }
53 Gtk::Image* get_image () const { return m_image_ref; }
54 Glib::ustring get_tooltip () const { return m_tooltip; }
55
56 private:
57 Gtk::StockID m_stock_id;
58 Gtk::Image* m_image_ref;
59 Glib::ustring m_tooltip;
60 };
61
62 /**=============================================================================
63 ** EditControls is a collection of markup edit buttons that are embedded
64 ** in CardView for quick editing the text in the input fields.
65 **=============================================================================
66 */
4067 class EditControls : public Gtk::HBox
4168 {
4269 public:
4572 void on_focus_changed (Gtk::TextView* text_view_);
4673 void on_clipboard_text_received (const Glib::ustring& text_);
4774
75 #ifdef IS_HILDON
76 void on_mark_set (const Gtk::TextBuffer::iterator& iter_,
77 const Glib::RefPtr<Gtk::TextBuffer::Mark>& mark_);
78 #endif
79
4880 private:
4981 void on_edit_button_clicked (const string& action_);
5082
5183 void remove_tags (Glib::RefPtr<Gtk::TextBuffer::Mark> begin_mark_,
5284 Glib::RefPtr<Gtk::TextBuffer::Mark> end_mark_);
5385
54 static gunichar
55 display_unichar_at (Gtk::TextBuffer::iterator iter_)
56 {
57 gunichar c;
58 return ((c = iter_.get_char ()) ? c : ' ');
59 }
86 void add_index (Glib::RefPtr<Gtk::TextBuffer::Mark> begin_mark_,
87 Glib::RefPtr<Gtk::TextBuffer::Mark> end_mark_);
88
89 void normalize_text ();
90
91 static gunichar display_unichar_at (Gtk::TextBuffer::iterator iter_);
6092
6193 private:
62 typedef std::pair<string, Gtk::Image*> icon_t;
94 static Gtk::StockID BOLD;
95 static Gtk::StockID ITALIC;
96 static Gtk::StockID UNDERLINE;
97 static Gtk::StockID MONOSPACE;
98 static Gtk::StockID SUBSCRIPT;
99 static Gtk::StockID SUPERSCRIPT;
100 static Gtk::StockID BIG;
101 static Gtk::StockID SMALL;
102 static Gtk::StockID REMOVETAGS;
103 static Gtk::StockID PASTE;
104 static Gtk::StockID NORMALIZE;
105 static Gtk::StockID ADDINDEX;
106
107 private:
108 typedef MyIconInfo icon_t;
63109 typedef vector<icon_t> icon_list_t;
64110
65111 icon_list_t m_icon_list;
66 Glib::RefPtr<Gtk::TextBuffer> m_textbuf;
112
113 Glib::RefPtr<Gtk::TextBuffer> m_textbuf;
114 Glib::RefPtr<Gtk::UIManager> m_uimanager;
115 Glib::RefPtr<Gtk::ActionGroup> m_actgroup;
116
117 u_int m_index_count;
118
119 #ifdef IS_HILDON
120 Glib::RefPtr<Gtk::TextBuffer::Mark> m_start_mark;
121 Glib::RefPtr<Gtk::TextBuffer::Mark> m_end_mark;
122 #endif
67123 };
68124
125
126 inline gunichar
127 EditControls::
128 display_unichar_at (Gtk::TextBuffer::iterator iter_)
129 {
130 gunichar c;
131 return ((c = iter_.get_char ()) ? c : ' ');
132 }
133
69134 #endif /* EDIT_CONTROLS_H */
00 // -*- c++ -*-
11 // generated by glade--
22 //------------------------------------------------------------------------------
3 // $Id: GeneralPref.cpp,v 1.16 2006/09/21 01:25:20 vlg Exp $
3 // $Id: GeneralPref.cpp,v 1.18 2006/12/11 03:07:22 vlg Exp $
44 //------------------------------------------------------------------------------
55 // GeneralPref.cpp
66 //------------------------------------------------------------------------------
8989 {
9090 trace_with_mask("GeneralPref::GeneralPref",GUITRACE);
9191
92 #if defined(IS_HILDON) || defined(IS_PDA)
93 set_border_width(0);
94 #else
9295 set_border_width(14);
96 #endif
9397
9498 Gtk::Label* empty_label;
9599
161165
162166 Gtk::VBox* scrollw_vbox = Gtk::manage (new Gtk::VBox (false, 0));
163167
168 /** Pack history size
169 */
170 scrollw_vbox->pack_start (*frame3, Gtk::PACK_SHRINK, 0);
171
172 /** [] Auto-pronounce each card when answer checked
173 */
174 scrollw_vbox->pack_start (*frame5, Gtk::PACK_SHRINK, 0);
175
176 /** [] Remove duplicates when inserting ...
177 */
164178 scrollw_vbox->pack_start (*frame1, Gtk::PACK_SHRINK, 0);
179
180 /** [] Record all dynamic links in CardFile as relative paths
181 */
165182 scrollw_vbox->pack_start (*frame2, Gtk::PACK_SHRINK, 0);
183
184 /** [] Disable all shortcuts in DeckPlayer dialog
185 */
166186 scrollw_vbox->pack_start (*frame4, Gtk::PACK_SHRINK, 0);
167 scrollw_vbox->pack_start (*frame5, Gtk::PACK_SHRINK, 0);
168
169 /** Pack history size
170 */
171 scrollw_vbox->pack_start (*frame3, Gtk::PACK_SHRINK, 0);
172187
173188 scrollw->add (*scrollw_vbox);
174189 pack_start (*scrollw);
00 // -*- c++ -*-
11 // generated by glade--
22 //------------------------------------------------------------------------------
3 // $Id: GeneralPref.h,v 1.11 2006/09/05 03:25:29 vlg Exp $
3 // $Id: GeneralPref.h,v 1.12 2006/11/05 19:00:59 vlg Exp $
44 //------------------------------------------------------------------------------
55 // GeneralPref.h
66 //------------------------------------------------------------------------------
3030 class PrefWindow;
3131
3232 /**-----------------------------------------------------------------------------
33 Compound history size option
34 --------------------------------------------------------------------------------
35 */
33 ** Compound history size option
34 **-----------------------------------------------------------------------------
35 */
3636 class HistSizeBox : public Gtk::HBox
3737 {
3838 public:
00 // -*- c++ -*-
11 //------------------------------------------------------------------------------
2 // $Id: GeometryPrefs.cpp,v 1.11 2006/06/14 02:34:38 vlg Exp $
2 // $Id: GeometryPrefs.cpp,v 1.13 2006/12/11 03:07:22 vlg Exp $
33 //------------------------------------------------------------------------------
44 // GeometryPrefs.cpp
55 //------------------------------------------------------------------------------
4646 Gtk::Label* hidden_label;
4747 Gtk::Adjustment* spin_button_adj;
4848
49 hidden_label = Gtk::manage (new Gtk::Label (""));
50 m_label = Gtk::manage(new Gtk::Label(win_name_));
51
52 m_width_vbox = Gtk::manage (new Gtk::VBox (false, 0));
53 m_wlabel = Gtk::manage (new Gtk::Label ("Width:"));
54 spin_button_adj =
55 Gtk::manage (new Gtk::Adjustment (1, 100, 1600, 1, 10, 10));
56 m_wspin_button = Gtk::manage (new Gtk::SpinButton (*spin_button_adj, 1, 0));
57
58 m_height_vbox = Gtk::manage (new Gtk::VBox (false, 0));
59 m_hlabel = Gtk::manage (new Gtk::Label ("Height:"));
60 spin_button_adj =
61 Gtk::manage (new Gtk::Adjustment (1, 100, 1600, 1, 10, 10));
62 m_hspin_button = Gtk::manage (new Gtk::SpinButton (*spin_button_adj, 1, 0));
49 hidden_label = Gtk::manage (new Gtk::Label (""));
50 m_label = Gtk::manage(new Gtk::Label(win_name_));
51
52 m_width_vbox = Gtk::manage (new Gtk::VBox (false, 0));
53 m_wlabel = Gtk::manage (new Gtk::Label ("Width:"));
54 spin_button_adj = Gtk::manage (new Gtk::Adjustment (1,100,1600,1,10,10));
55 m_wspin_button = Gtk::manage (new Gtk::SpinButton (*spin_button_adj,1,0));
56
57 m_height_vbox = Gtk::manage (new Gtk::VBox (false, 0));
58 m_hlabel = Gtk::manage (new Gtk::Label ("Height:"));
59 spin_button_adj = Gtk::manage (new Gtk::Adjustment (1,100,1600,1,10,10));
60 m_hspin_button = Gtk::manage (new Gtk::SpinButton (*spin_button_adj,1,0));
6361
6462 m_label->set_alignment(Gtk::ALIGN_RIGHT, Gtk::ALIGN_CENTER);
6563 m_label->set_padding(0,0);
8179 m_wspin_button->set_digits(0);
8280 m_wspin_button->set_wrap(false);
8381
84 m_width_vbox->pack_start(*m_wlabel, Gtk::PACK_SHRINK, 0);
85 m_width_vbox->pack_start(*m_wspin_button, Gtk::PACK_SHRINK, 0);
82 m_width_vbox->pack_start (*m_wlabel, Gtk::PACK_SHRINK, 0);
83 m_width_vbox->pack_start( *m_wspin_button, Gtk::PACK_SHRINK, 0);
8684
8785 m_hlabel->set_alignment(0.5,0.5);
8886 m_hlabel->set_padding(0,0);
217215 }
218216
219217 /**-----------------------------------------------------------------------------
220 GeometryPrefs methods
221 --------------------------------------------------------------------------------
222 */
218 ** GeometryPrefs methods
219 **-----------------------------------------------------------------------------
220 **/
223221 GeometryPrefs::
224 GeometryPrefs (PrefWindow& pwin_) :
222 GeometryPrefs (PrefWindow& pwin_)
223 :
225224 Gtk::VBox (false, 0),
226225 m_pref_window (pwin_),
227226 m_change_in_progress (false)
229228 int i;
230229 trace_with_mask("GeometryPrefs::GeometryPrefs",GUITRACE);
231230
231 #ifdef IS_HILDON
232 set_border_width(0);
233 #else
234 set_border_width(14);
235 #endif
236
232237 m_table = Gtk::manage (new Gtk::Table (3, 3, false));
233238
234239 for (i = 0; i < WIN_ENTRY_SZ; i++) {
238243
239244 m_aspect = Gtk::manage (new AspectBox);
240245 m_aspect->set_value (CONFIG->keep_deck_player_aspect (),
241 CONFIG->get_deck_player_aspect ());
242
243 Gtk::Frame* options_frame = Gtk::manage(new Gtk::Frame());
244 Gtk::Label* hidden_label = Gtk::manage(new Gtk::Label(""));
246 CONFIG->get_deck_player_aspect ());
247
248 Gtk::Frame* options_frame = Gtk::manage(new Gtk::Frame ());
249 Gtk::Label* hidden_label = Gtk::manage(new Gtk::Label (""));
245250
246251 hidden_label->set_alignment (0.5,0.5);
247252 hidden_label->set_padding (0,0);
254259 options_frame->set_border_width (0);
255260 options_frame->set_label_align (1, 1);
256261 options_frame->set_label_widget (*hidden_label);
257 options_frame->add (*m_aspect);
258
259 set_border_width (14);
262 options_frame->add (*m_aspect);
260263
261264 /** Pack everything. Center the table in the middle
262 with two hidden buttons.
265 ** with two hidden buttons.
266 ** Update: left-align GeometryBox.
263267 */
264268 Gtk::HBox* hbox = manage (new Gtk::HBox (false, 0));
265 Gtk::Label* pre_hidden = manage (new Gtk::Label (""));
269
270 Gtk::Label* pre_hidden = manage (new Gtk::Label (""));
266271 Gtk::Label* post_hidden = manage (new Gtk::Label (""));
267 hbox->pack_start (*pre_hidden, Gtk::PACK_EXPAND_WIDGET);
272
268273 hbox->pack_start (*m_table, Gtk::PACK_SHRINK, 4);
269274 hbox->pack_start (*post_hidden, Gtk::PACK_EXPAND_WIDGET);
270275
271
272 /** Maemo has a narrow screen and thus requires
276 #if defined(IS_HILDON) || defined(IS_PDA)
277 /** Both Maemo and PDAs have a narrow screen and thus requires
273278 * smart packing.
274279 */
275 #ifdef IS_HILDON
276
277280 Gtk::ScrolledWindow* scrollw = Gtk::manage (new Gtk::ScrolledWindow);
278281 scrollw->set_flags (Gtk::CAN_FOCUS);
279282 scrollw->set_shadow_type (Gtk::SHADOW_NONE);
00 // -*- c++ -*-
11 // Generated by assa-genesis
22 //------------------------------------------------------------------------------
3 // $Id: Granule-main.cpp,v 1.13 2006/09/30 20:42:27 vlg Exp $
3 // $Id: Granule-main.cpp,v 1.14 2006/12/23 23:34:25 vlg Exp $
44 //------------------------------------------------------------------------------
55 // Granule-main.cpp
66 //------------------------------------------------------------------------------
3737 " -D, --log-file=NAME - Write debug to NAME file \n"
3838 " -z, --log-size=NUM - Maximum size debug file can reach (dfl: is 10Mb) \n"
3939 " \n"
40 " --config-file=NAME - Specify a fully-qualified path to the \n"
41 " alternative configuration file. \n"
42 " \n"
4043 " -d, --log-stdout=YESNO - Write debug to standard output \n"
4144 " \n"
4245 " --with-log-server=YESNO - Redirect log messages to the log server \n"
5154 " 0x00000010 - (GEOM) Log geometry changes \n"
5255 " 0x02000000 - (KEYIN) Log keyboard input activitiy \n"
5356 " \n"
54 " -h, --help - Print this messag \n"
55 " -v, --version - Print version number \n"
56 " \n"
5757 " --secs-in-day=NUM - Number of seconds in a day (used for debugging) \n"
5858 " --secs-in-week=NUM - Number of seconds in a week (used for debugging) \n"
5959 " --dump-cardboxes=YESNO - Dump content of each cardbox to a file, \n"
6464 " o --disable-crash-dialog - when application crashes \n"
6565 " suppress GNOME crash \n"
6666 " dialog. \n"
67 " \n"
68 " -h, --help - Print this messag \n"
69 " -v, --version - Print version number \n"
70 " \n"
6771 " \n";
6872 //------------------------------------------------------------------------------
6973
00 // -*- c++ -*-
11 // Generated by assa-genesis
22 //------------------------------------------------------------------------------
3 // $Id: Granule-main.h,v 1.18 2006/08/30 12:22:36 vlg Exp $
3 // $Id: Granule-main.h,v 1.21 2006/11/14 03:33:27 vlg Exp $
44 //------------------------------------------------------------------------------
55 // Granule-main.h
66 //------------------------------------------------------------------------------
2525 using ASSA::TRACE;
2626 using ASSA::ALL;
2727
28 enum { GRAPP = ASSA::APP, // 0x00000002
29 GUITRACE = ASSA::USR1, // 0x00000004
30 DECK = ASSA::USR2, // 0x00000008
31 GEOM = ASSA::USR3, // 0x00000010
32 KEYIN = ASSA::RES5 // 0x02000000
28 enum { GRAPP = ASSA::APP, // 0x00000002
29 GUITRACE = ASSA::USR1, // 0x00000004
30 DECK = ASSA::USR2, // 0x00000008
31 GEOM = ASSA::USR3, // 0x00000010
32 KEYIN = ASSA::RES5, // 0x02000000
33 CSVPARSER = ASSA::RES6 // 0x04000000
3334 };
3435
3536 typedef enum {
4142
4243 typedef enum {
4344 FRONT,
44 BACK
45 BACK,
46 EXAMPLE
4547 } SideSelection;
4648
4749 typedef enum {
7476 COMMA_SEP,
7577 } CSVSeparator;
7678
79 /** Indexes into text alignment combo control widgets.
80 * These differ from both Gtk::AlignmentEnum and Gtk::Justification.
81 */
82 enum {
83 TA_X_ALIGN_CENTER,
84 TA_X_ALIGN_LEFT,
85 TA_X_ALIGN_RIGHT
86 };
87
88 enum {
89 TA_Y_ALIGN_CENTER,
90 TA_Y_ALIGN_TOP,
91 TA_Y_ALIGN_BOTTOM
92 };
93
94 enum {
95 TA_JUSTIFY_CENTER,
96 TA_JUSTIFY_LEFT,
97 TA_JUSTIFY_RIGHT,
98 TA_JUSTIFY_FILL
99 };
100
101
77102 /*------------------------------------------------------------------------------
78103 * Some useful defines and define macros
79104 *------------------------------------------------------------------------------
00 // -*- c++ -*-
11 // Generated by assa-genesis
22 //------------------------------------------------------------------------------
3 // $Id: Granule.cpp,v 1.33 2006/10/08 02:46:30 vlg Exp $
3 // $Id: Granule.cpp,v 1.37 2007/01/15 04:09:08 vlg Exp $
44 //------------------------------------------------------------------------------
55 // Granule.cpp
66 //------------------------------------------------------------------------------
2525 #include <unistd.h> // access(2)
2626 #include <stdlib.h> // system(3)
2727
28
29 #include <gtk/gtklabel.h>
2830 #include <glibmm/ustring.h>
2931 #include <gtkmm/main.h>
3032 #include <gtkmm/rc.h>
8284 */
8385 /* m_mask = GRAPP | DECK | GUITRACE | ASSA::ASSAERR; */
8486 m_mask = 0;
85
8687 m_log_file = "granule.log";
8788 }
8889
106107 std::string v;
107108 bool parse_default_rc = true;
108109
109 #if !defined (WIN32) /* POSIX systems */
110
111 string defaultrc (GRAPPDATDIR);
112 defaultrc += "/granule";
113 rcfile = ASSA::Utils::strenv ("~/.granule");
114
115 if (::access (rcfile.c_str (), R_OK) < 0) {
116 if (::access (defaultrc.c_str (), R_OK) == 0) {
117 string cmd ("cp -p ");
118 cmd += defaultrc + " " + rcfile;
119 if (::system (cmd.c_str ()) < 0) {
110 #if !defined (WIN32) /* POSIX systems */
111 m_config_file = "none"; /* But note, GrappConf relies on this value! */
112 parse_args ((const char**) argv_);
113
114 if (m_config_file != "none") {
115 rcfile = ASSA::Utils::strenv (m_config_file.c_str ());
116 }
117 else {
118 string defaultrc (GRAPPDATDIR); /* /usr/share/granule/granule */
119 defaultrc += "/granule";
120 rcfile = ASSA::Utils::strenv ("~/.granule");
121
122 if (::access (rcfile.c_str (), R_OK) < 0) {
123 if (::access (defaultrc.c_str (), R_OK) == 0) {
124 string cmd ("cp -p ");
125 cmd += defaultrc + " " + rcfile;
126 if (::system (cmd.c_str ()) < 0) {
127 parse_default_rc = false;
128 }
129 }
130 else {
120131 parse_default_rc = false;
121132 }
122133 }
123 else {
124 parse_default_rc = false;
125 }
126 }
127
134 }
128135 #else /* WIN32 */
129
130136 rcfile = "granule.ini"; // same place where the binary is.
131
132 #endif
133
137 #endif
138
134139 /**
135140 * Load [options] section of the configuration file.
136141 */
149154
150155 ASSA::GenServer::init (argc_, argv_, help_info_);
151156
157 /** Fix alternative config file name if specified on command-line.
158 * On a command line it may look like --config-file=~/.granule.whatever.
159 * This is libassa bug!
160 */
161 if (m_config_file != "none") {
162 m_config_file = rcfile;
163 }
164
152165 /*
153166 TRACE = 0x00001
154167 APP = 0x00002 (GRAPP)
160173 FORK = 0x40000
161174 */
162175
163 if (m_log_level >= 0) {
164 switch (m_log_level) {
165 case 6: m_mask = ALL; break; // Log message flood!
166 case 5: m_mask = 0x3F; break; // ALL_APPS+ERRORS
167 case 4: m_mask = 0x40026; break; // +FORK
168 case 3: m_mask = 0x26; break; // GRAPP+GUITRACE+ERRORS
169 case 2: m_mask = 0x25; break; // TRACE+GUITRACE+ERRORS
170 case 1: m_mask = 0x22; break; // GRAPP+ERRORS
171 case 0: default: m_mask = 0x0;
176 if (m_log_level >= 0)
177 {
178 switch (m_log_level)
179 {
180 case 6: m_mask = ALL; break; // Log message flood!
181 case 5: m_mask = 0x3F; break; // ALL_APPS+ERRORS
182 case 4: m_mask = 0x40026; break; // +FORK
183 case 3: m_mask = 0x26; break; // GRAPP+GUITRACE+ERRORS
184 case 2: m_mask = 0x25; break; // TRACE+GUITRACE+ERRORS
185 case 1: m_mask = 0x22; break; // GRAPP+ERRORS
186 case 0: m_mask = 0x0; break;
187 default: m_mask = ALL; // >6
172188 }
173189 }
174
175190 LOGGER->enable_groups (m_mask);
176191
177 /** Install my own entity loader. This will let me redefine
178 DTD URLs and support backward compatability.
192 /** Install my own entity loader.
193 * This will let me redefine DTD URLs and support backward compatability.
179194 */
180195 m_default_entity_loader = xmlGetExternalEntityLoader();
181196 xmlSetExternalEntityLoader (my_xml_entity_loader);
211226 Granule::
212227 dump_package_envs ()
213228 {
214 DL((APP,"\n= Environment variables set by Autoconfig: =\n"
229 DL((APP,"\n= Environment variables set by automake: =\n"
215230 "\n"
216231 "\tGRAPPDATDIR..: \"%s\"\n"
217232 "\tGRAPPXMLDIR...: \"%s\"\n"
223238 "\tIS_HILDON.....: \"yes\"\n"
224239 #else
225240 "\tIS_HILDON.....: \"no\"\n"
241 #endif
242 #ifdef IS_PDA
243 "\tIS_PDA........: \"yes\"\n"
244 #else
245 "\tIS_PDA........: \"no\"\n"
226246 #endif
227247 "\n",
228248 GRAPPDATDIR, GRAPPXMLDIR, DATDIR, LOCALEDIR, PACKAGE, VERSION));
522542
523543 #endif // IS_HILDON
524544
545 void
546 Granule::
547 hide_fcd_gtk_labels (GtkContainer* container_, int& counter_)
548 {
549 #ifdef IS_PDA
550 const gchar* blabel;
551 GList* child;
552 GList* child2;
553
554 if (counter_ > 2) {
555 return;
556 }
557 child = gtk_container_get_children(container_);
558 while (child != NULL)
559 {
560 if (GTK_IS_LABEL (child->data)) {
561 blabel = gtk_label_get_text (GTK_LABEL (child->data));
562 if (blabel != NULL && (!strcmp (blabel, "Add") ||
563 !strcmp (blabel, "Remove")))
564 {
565 gtk_widget_hide (GTK_WIDGET (child->data));
566 ++counter_;
567 return;
568 }
569 }
570 if (GTK_IS_CONTAINER (child->data)) {
571 hide_fcd_gtk_labels (GTK_CONTAINER (child->data), counter_);
572 }
573 child = g_list_next(child);
574 }
575 #endif
576 }
00 // -*- c++ -*-
11 // Generated by assa-genesis
22 //------------------------------------------------------------------------------
3 // $Id: Granule.h,v 1.23 2006/09/21 01:25:20 vlg Exp $
3 // $Id: Granule.h,v 1.24 2007/01/03 03:49:11 vlg Exp $
44 //------------------------------------------------------------------------------
55 // Granule.h
66 //------------------------------------------------------------------------------
2929 using std::string;
3030 #include <stack>
3131
32 #include <gtk/gtkcontainer.h>
3233 #include <gtkmm.h>
3334
3435 #ifdef IS_HILDON
8384 void unregister_appview (Hildon::AppView* view_);
8485 #endif
8586
86 public: /** Common utilities used everywhere
87 */
87 public:
88 /** Common utilities used everywhere
89 *
90 * @{ start
91 */
8892 static gchar* strip_pango_markup (const char* src_);
8993 static void remove_common_prefixes (gchar*& src_);
9094 static Glib::ustring trim_multiline (const Glib::ustring& text_);
98102 @return true on success; false if entry is invalid
99103 */
100104 static bool check_markup (const Glib::ustring& str_);
105
106 /** Find 'Add' and 'Remove' buttons of the GtkFileChooserDialog
107 * and hide its labels, leaving icons only. This helps with
108 * portrait orientation of file-related dialogs in IS_PDA mode.
109 *
110 * @param container_ gobj() of Gtk::FileChooserDialog
111 * @param counter_ Should be set to 0 by the caller. Helps to
112 * abort the search earlier.
113 */
114 static void hide_fcd_gtk_labels (GtkContainer* container_, int& counter_);
115
116 /* }@ end
117 **/
101118
102119 private:
103120 void dump_package_envs ();
11 //------------------------------------------------------------------------------
22 // GrappConf.cpp
33 //------------------------------------------------------------------------------
4 // $Id: GrappConf.cpp,v 1.4 2006/09/30 20:42:27 vlg Exp $
4 // $Id: GrappConf.cpp,v 1.11 2007/01/15 04:09:08 vlg Exp $
55 //------------------------------------------------------------------------------
66 // Copyright (c) 2004-2006 by Vladislav Grinchenko
77 //
2626
2727
2828 #if !defined(WIN32)
29 # include <libgen.h> // basename(3), dirname(3)
29 # include <libgen.h> // basename(3), dirname(3)
3030 # include <pwd.h> // getpwnam(2), getlogin(2)
3131 #endif
3232
5353 */
5454 #if defined(WIN32)
5555
56 char *dirname (char *path_)
56 extern char *dirname (const char *path_)
5757 {
5858 static char path [MAX_PATH];
5959
6464 return path;
6565 }
6666
67 char *basename (char* path_)
67 extern char *basename (const char* path_)
6868 {
6969 static char path [MAX_PATH];
7070
117117 /******************************************************************************/
118118 GrappConf::
119119 GrappConf () :
120 m_proj_name ("untitled.cdf"),
121 m_dont_save_project (false),
122 m_mwin_geometry (0, 0, 430, 350),
123 m_dplyr_geometry (0, 0, 583, 350),
124 m_crdview_geometry (0, 0, 643, 386),
125 m_dplyr_keep_aspect (true),
126 m_dplyr_aspect (0, 0, 5, 3),
127 m_snd_player_cmd ("sox"),
128 m_snd_player_args ("%s -q -t ossdsp -v 1.7 -r 48000 /dev/dsp"),
129 m_config (NULL),
130 m_remove_dups (true),
120 m_proj_name ("untitled.cdf"),
121 m_dont_save_project (false),
122 m_text_fgcolor ("black"),
123 m_text_bgcolor ("white"),
124 m_sep_color ("pink"),
125 m_front_x_alignment ("center"),
126 m_front_y_alignment ("center"),
127 m_front_x_padding ("4"),
128 m_front_y_padding ("0"),
129 m_front_justification ("center"),
130 m_back_x_alignment ("center"),
131 m_back_y_alignment ("center"),
132 m_back_x_padding ("1"),
133 m_back_y_padding ("1"),
134 m_back_justification ("center"),
135 m_example_x_alignment ("left"),
136 m_example_y_alignment ("top"),
137 m_example_x_padding ("2"),
138 m_example_y_padding ("0"),
139 m_example_justification ("left"),
140 m_mwin_geometry (0, 0, 430, 350),
141 m_dplyr_geometry (0, 0, 583, 350),
142 m_crdview_geometry (0, 0, 643, 386),
143 m_dplyr_keep_aspect (true),
144 m_dplyr_aspect (0, 0, 5, 3),
145 m_snd_player_cmd ("sox"),
146 m_snd_player_args ("%s -q -t ossdsp -v 1.7 -r 48000 /dev/dsp"),
147 m_config (NULL),
148 m_remove_dups (true),
131149 m_with_relative_paths (false),
132 m_load_time (ASSA::TimeVal::gettimeofday ()),
133 m_root_x (0),
134 m_root_y (0),
150 m_load_time (ASSA::TimeVal::gettimeofday ()),
151 m_root_x (0),
152 m_root_y (0),
135153 m_disable_key_shortcuts (false),
136 m_auto_pronounce (false)
154 m_auto_pronounce (false)
137155 {
138156 trace_with_mask("GrappConf::GrappConf",GUITRACE);
139157
327345 *
328346 * [Default]
329347 * filesel_path=/path/to/
348 * text_bgcolor="white"
349 * text_fgcolor="black"
350 * sep_color="pink"
330351 * question_font_desc="Sans 14"
331352 * answer_font_desc="Sans 14"
332353 * example_font_desc="Sans 14"
333354 * input_font_desc="Sans 14"
334355 * app_font_desc="Bitstream Vera Sans 12"
356 * front_x_alignment="center"
357 * front_y_alignment="center"
358 * front_x_padding="4"
359 * front_y_padding="0"
360 * front_justification="center"
361 * back_x_alignment="center"
362 * back_y_alignment="center"
363 * back_x_padding="0"
364 * back_y_padding="0"
365 * back_justification="center"
366 * example_x_alignment="center"
367 * example_y_alignment="center"
368 * example_x_padding="2"
369 * example_y_padding="0"
370 * example_justification="left"
335371 * mainwin_geometry=430x350
336372 * cardview_geometry_height=643x386
337373 * deckplayer_geometry=583x350
353389 {
354390 trace_with_mask("GrappConf::load_config",GUITRACE);
355391
356 Glib::ustring usfont;
357 std::string s;
392 Glib::ustring ustr;
393 string s;
358394 int idx;
359395 IniFile::const_config_iterator section;
360396
361397 if (m_config == NULL) {
362398 s = GRANULE->get_config_file ();
363 if (s.size () == 0) {
399 if (s.size () == 0 || s == "none") {
364400 s = GRANULE->get_default_config_file ();
365401 }
366402 m_config = new IniFile (s);
367403 if (m_config->load () < 0) {
368 DL((APP, "Failed to load configuration file!\n"));
404 DL((GRAPP, "Failed to load configuration file!\n"));
369405 return;
370406 }
407 DL ((GRAPP,"Loaded configuration from \"%s\"\n", s.c_str ()));
371408 s = "";
372409 }
373410 /** Load [History] section
423460 if (section != m_config->sect_end ()) {
424461 DL((APP,"Scanning [History] section ...\n"));
425462 IniFile::const_tuple_iterator k = (*section).second.begin ();
426 std::string lhs;
427 std::string rhs;
463 string lhs;
464 string rhs;
428465
429466 while (k != (*section).second.end ()) {
430467 idx = ::atoi ((*k).first.c_str ()) - 1;
483520 }
484521
485522 DL((APP,"m_filesel_path = \"%s\"\n", m_filesel_path.c_str ()));
486 DL((APP,"m_font_desc = \"%s\"\n", usfont.c_str ()));
523 DL((APP,"m_font_desc = \"%s\"\n", ustr.c_str ()));
487524 DL((APP,"m_snd_player_cmd = \"%s\"\n", m_snd_player_cmd.c_str ()));
488525 DL((APP,"m_snd_player_args = \"%s\"\n", m_snd_player_args.c_str ()));
489526 DL((APP,"m_snd_archive_path = \"%s\"\n", m_snd_archive_path.c_str ()));
490527
491 usfont = m_config->get_value ("Default", "question_font_desc");
492 if (! usfont.empty ()) {
493 set_question_font (usfont);
494 }
495
496 usfont = m_config->get_value ("Default", "answer_font_desc");
497 if (! usfont.empty ()) {
498 set_answer_font (usfont);
499 }
500
501 usfont = m_config->get_value ("Default", "example_font_desc");
502 if (! usfont.empty ()) {
503 set_example_font (usfont);
504 }
505
506 usfont = m_config->get_value ("Default", "input_font_desc");
507 if (! usfont.empty ()) {
508 set_input_font (usfont);
509 }
510
511 usfont = m_config->get_value ("Default", "app_font_desc");
512 if (! usfont.empty ()) {
513 set_app_font (usfont);
528 ustr = m_config->get_value ("Default", "text_bgcolor");
529 if (! ustr.empty ()) {
530 text_bgcolor (ustr);
531 DL((APP,"m_text_bgcolor = \"%s\"\n", m_text_bgcolor.c_str ()));
532 }
533
534 ustr = m_config->get_value ("Default", "text_fgcolor");
535 if (! ustr.empty ()) {
536 text_fgcolor (ustr);
537 DL((APP,"m_text_fgcolor = \"%s\"\n", m_text_fgcolor.c_str ()));
538 }
539 ustr = m_config->get_value ("Default", "sep_color");
540 if (! ustr.empty ()) {
541 sep_color (ustr);
542 }
543
544 ustr = m_config->get_value ("Default", "question_font_desc");
545 if (! ustr.empty ()) {
546 set_question_font (ustr);
547 }
548
549 ustr = m_config->get_value ("Default", "answer_font_desc");
550 if (! ustr.empty ()) {
551 set_answer_font (ustr);
552 }
553
554 ustr = m_config->get_value ("Default", "example_font_desc");
555 if (! ustr.empty ()) {
556 set_example_font (ustr);
557 }
558
559 ustr = m_config->get_value ("Default", "input_font_desc");
560 if (! ustr.empty ()) {
561 set_input_font (ustr);
562 }
563
564 ustr = m_config->get_value ("Default", "app_font_desc");
565 if (! ustr.empty ()) {
566 set_app_font (ustr);
567 }
568
569 s = m_config->get_value ("Default", "front_x_alignment");
570 if (! s.empty ()) {
571 m_front_x_alignment = s;
572 }
573
574 s = m_config->get_value ("Default", "front_y_alignment");
575 if (! s.empty ()) {
576 m_front_y_alignment = s;
577 }
578
579 s = m_config->get_value ("Default", "front_x_padding");
580 if (! s.empty ()) {
581 m_front_x_padding = s;
582 }
583
584 s = m_config->get_value ("Default", "front_y_padding");
585 if (! s.empty ()) {
586 m_front_y_padding = s;
587 }
588
589 s = m_config->get_value ("Default", "front_justification");
590 if (! s.empty ()) {
591 m_front_justification = s;
592 }
593
594 s = m_config->get_value ("Default", "back_x_alignment");
595 if (! s.empty ()) {
596 m_back_x_alignment = s;
597 }
598
599 s = m_config->get_value ("Default", "back_y_alignment");
600 if (! s.empty ()) {
601 m_back_y_alignment = s;
602 }
603
604 s = m_config->get_value ("Default", "back_x_padding");
605 if (! s.empty ()) {
606 m_back_x_padding = s;
607 }
608
609 s = m_config->get_value ("Default", "back_y_padding");
610 if (! s.empty ()) {
611 m_back_y_padding = s;
612 }
613
614 s = m_config->get_value ("Default", "back_justification");
615 if (! s.empty ()) {
616 m_back_justification = s;
617 }
618
619 s = m_config->get_value ("Default", "example_x_alignment");
620 if (! s.empty ()) {
621 m_example_x_alignment = s;
622 }
623
624 s = m_config->get_value ("Default", "example_y_alignment");
625 if (! s.empty ()) {
626 m_example_y_alignment = s;
627 }
628
629 s = m_config->get_value ("Default", "example_x_padding");
630 if (! s.empty ()) {
631 m_example_x_padding = s;
632 }
633
634 s = m_config->get_value ("Default", "example_y_padding");
635 if (! s.empty ()) {
636 m_example_y_padding = s;
637 }
638
639 s = m_config->get_value ("Default", "example_justification");
640 if (! s.empty ()) {
641 m_example_justification = s;
514642 }
515643
516644 s = m_config->get_value ("Default", "mainwin_geometry");
567695 {
568696 trace_with_mask("GrappConf::save_config",GUITRACE);
569697
570 std::string s;
698 string s;
571699 const char* fname;
572700
573701 if (m_config == NULL) {
651779 iter++, position++;
652780 }
653781
654 Glib::ustring usfont;
782 Glib::ustring ustr;
655783 m_config->set_pair ("Default",
656784 IniFile::tuple_type("filesel_path", m_filesel_path));
657
785 /** Text colors
786 */
787 m_config->set_pair ("Default",
788 IniFile::tuple_type("text_fgcolor", m_text_fgcolor));
789 m_config->set_pair ("Default",
790 IniFile::tuple_type("text_bgcolor", m_text_bgcolor));
791 m_config->set_pair ("Default",
792 IniFile::tuple_type("sep_color", m_sep_color));
658793 /** Fonts
659794 */
660 usfont = m_question_font_desc.to_string ();
661 m_config->set_pair ("Default",
662 IniFile::tuple_type("question_font_desc",usfont));
663 usfont = m_answer_font_desc.to_string ();
664 m_config->set_pair ("Default",
665 IniFile::tuple_type("answer_font_desc",usfont));
666 usfont = m_example_font_desc.to_string ();
667 m_config->set_pair ("Default",
668 IniFile::tuple_type("example_font_desc",usfont));
669 usfont = m_input_font_desc.to_string ();
670 m_config->set_pair ("Default",
671 IniFile::tuple_type("input_font_desc",usfont));
672 usfont = m_app_font_desc.to_string ();
673 m_config->set_pair ("Default",
674 IniFile::tuple_type("app_font_desc",usfont));
675
795 ustr = m_question_font_desc.to_string ();
796 m_config->set_pair ("Default",
797 IniFile::tuple_type("question_font_desc", ustr));
798 ustr = m_answer_font_desc.to_string ();
799 m_config->set_pair ("Default",
800 IniFile::tuple_type("answer_font_desc", ustr));
801 ustr = m_example_font_desc.to_string ();
802 m_config->set_pair ("Default",
803 IniFile::tuple_type("example_font_desc", ustr));
804 ustr = m_input_font_desc.to_string ();
805 m_config->set_pair ("Default",
806 IniFile::tuple_type("input_font_desc", ustr));
807 ustr = m_app_font_desc.to_string ();
808 m_config->set_pair ("Default",
809 IniFile::tuple_type("app_font_desc", ustr));
810 /** Text alignment
811 */
812 m_config->set_pair ("Default",
813 IniFile::tuple_type("front_x_alignment",
814 m_front_x_alignment));
815 m_config->set_pair ("Default",
816 IniFile::tuple_type("front_y_alignment",
817 m_front_y_alignment));
818 m_config->set_pair ("Default",
819 IniFile::tuple_type("front_x_padding",
820 m_front_x_padding));
821 m_config->set_pair ("Default",
822 IniFile::tuple_type("front_y_padding",
823 m_front_y_padding));
824 m_config->set_pair ("Default",
825 IniFile::tuple_type("front_justification",
826 m_front_justification));
827 m_config->set_pair ("Default",
828 IniFile::tuple_type("back_x_alignment",
829 m_back_x_alignment));
830 m_config->set_pair ("Default",
831 IniFile::tuple_type("back_y_alignment",
832 m_back_y_alignment));
833 m_config->set_pair ("Default",
834 IniFile::tuple_type("back_x_padding",
835 m_back_x_padding));
836 m_config->set_pair ("Default",
837 IniFile::tuple_type("back_y_padding",
838 m_back_y_padding));
839 m_config->set_pair ("Default",
840 IniFile::tuple_type("back_justification",
841 m_back_justification));
842 m_config->set_pair ("Default",
843 IniFile::tuple_type("example_x_alignment",
844 m_example_x_alignment));
845 m_config->set_pair ("Default",
846 IniFile::tuple_type("example_y_alignment",
847 m_example_y_alignment));
848 m_config->set_pair ("Default",
849 IniFile::tuple_type("example_x_padding",
850 m_example_x_padding));
851 m_config->set_pair ("Default",
852 IniFile::tuple_type("example_y_padding",
853 m_example_y_padding));
854 m_config->set_pair ("Default",
855 IniFile::tuple_type("example_justification",
856 m_example_justification));
676857 /** Geometry
677858 */
678859 m_config->set_pair ("Default",
745926 {
746927 trace_with_mask("GrappConf::get_flipside_history",GUITRACE);
747928
748 if (fname_.find ("Untitled") != std::string::npos) {
929 if (fname_.find ("Untitled") != string::npos) {
749930 return (FRONT);
750931 }
751932 flipside_iter_t iter = m_flipside_history.begin ();
816997 */
817998 void
818999 GrappConf::
819 str_to_geometry (const std::string& src_, Gdk::Rectangle& aspect_)
1000 str_to_geometry (const string& src_, Gdk::Rectangle& aspect_)
8201001 {
8211002 trace_with_mask("GrappConf::str_to_geometry",GUITRACE);
8221003
8421023 sprintf (buf, "%dx%d", aspect_.get_height (), aspect_.get_width ());
8431024 return buf;
8441025 }
1026
11 //------------------------------------------------------------------------------
22 // GrappConf.h
33 //------------------------------------------------------------------------------
4 // $Id: GrappConf.h,v 1.4 2006/09/07 02:34:04 vlg Exp $
4 // $Id: GrappConf.h,v 1.9 2007/01/07 20:16:43 vlg Exp $
55 //------------------------------------------------------------------------------
66 // Copyright (c) 2004-2006 by Vladislav Grinchenko
77 //
2121 using std::string;
2222
2323 #include <pangomm/fontdescription.h>
24
2425 #include <gdkmm/rectangle.h>
26 #include <gdkmm/color.h>
2527
2628 #include <assa/Singleton.h>
2729 #include <assa/TimeVal.h>
126128 SideSelection get_flipside_history (const string& fname_);
127129 void set_flipside_history (const string& fname_, SideSelection side_);
128130
131 /** Text colors
132 */
133 Gdk::Color text_fgcolor () const { return Gdk::Color (m_text_fgcolor); }
134 Gdk::Color text_bgcolor () const { return Gdk::Color (m_text_bgcolor); }
135 Gdk::Color sep_color () const { return Gdk::Color (m_sep_color); }
136
137 void text_fgcolor (const Glib::ustring& s_) { m_text_fgcolor = s_; }
138 void text_bgcolor (const Glib::ustring& s_) { m_text_bgcolor = s_; }
139 void sep_color (const Glib::ustring& s_) { m_sep_color = s_; }
140
129141 /** Text fonts settings
130142 */
131143 Pango::FontDescription& get_question_font () { return m_question_font_desc;}
140152 void set_input_font (const Glib::ustring& font_);
141153 void set_app_font (const Glib::ustring& font_);
142154
155 /** Text alignment controls
156 */
157 string x_alignment (SideSelection s_) const;
158 string y_alignment (SideSelection s_) const;
159 string x_padding (SideSelection s_) const;
160 string y_padding (SideSelection s_) const;
161 string justification (SideSelection s_) const;
162
163 void x_alignment (SideSelection s_, const string& v_);
164 void y_alignment (SideSelection s_, const string& v_);
165 void x_padding (SideSelection s_, const string& v_);
166 void y_padding (SideSelection s_, const string& v_);
167 void justification (SideSelection s_, const string& v_);
168
143169 /** Windows geometry
144170 */
145171 Gdk::Rectangle get_main_window_geometry () { return m_mwin_geometry; }
203229 typedef std::vector<sidesel_t> flipside_t;
204230 typedef flipside_t::iterator flipside_iter_t;
205231
206 void str_to_geometry (const std::string& src_,
207 Gdk::Rectangle& allocation_);
232 void str_to_geometry (const string& src_,
233 Gdk::Rectangle& allocation_);
208234 const char* geometry_to_str (const Gdk::Rectangle& allocation_);
209235
210236 private:
213239 string m_filesel_path; // Path of the last FileSelection dialog
214240 bool m_dont_save_project; // Don't save project file
215241
242 Glib::ustring m_text_fgcolor;
243 Glib::ustring m_text_bgcolor;
244 Glib::ustring m_sep_color;
245
216246 Pango::FontDescription m_question_font_desc;
217247 Pango::FontDescription m_answer_font_desc;
218248 Pango::FontDescription m_example_font_desc;
219249 Pango::FontDescription m_input_font_desc;
220250 Pango::FontDescription m_app_font_desc;
251
252 string m_front_x_alignment;
253 string m_front_y_alignment;
254 string m_front_x_padding;
255 string m_front_y_padding;
256 string m_front_justification;
257
258 string m_back_x_alignment;
259 string m_back_y_alignment;
260 string m_back_x_padding;
261 string m_back_y_padding;
262 string m_back_justification;
263
264 string m_example_x_alignment;
265 string m_example_y_alignment;
266 string m_example_x_padding;
267 string m_example_y_padding;
268 string m_example_justification;
221269
222270 Gdk::Rectangle m_mwin_geometry;
223271 Gdk::Rectangle m_dplyr_geometry;
379427 {
380428 m_sched [idx_].mins (s_);
381429 }
430
431 /**-------------------------
432 **** Retrieve a property **
433 **-------------------------
434 */
435 inline string
436 GrappConf::x_alignment (SideSelection s_) const
437 {
438 if (s_ == FRONT) { return m_front_x_alignment; }
439 else if (s_ == BACK) { return m_back_x_alignment; }
440 else /* EXAMPLE */ { return m_example_x_alignment; }
441 }
442
443 inline string
444 GrappConf::y_alignment (SideSelection s_) const
445 {
446 if (s_ == FRONT) { return m_front_y_alignment; }
447 else if (s_ == BACK) { return m_back_y_alignment; }
448 else /* EXAMPLE */ { return m_example_y_alignment; }
449 }
450
451 inline string
452 GrappConf::x_padding (SideSelection s_) const
453 {
454 if (s_ == FRONT) { return m_front_x_padding; }
455 else if (s_ == BACK) { return m_back_x_padding; }
456 else /* EXAMPLE */ { return m_example_x_padding; }
457 }
458
459 inline string
460 GrappConf::y_padding (SideSelection s_) const
461 {
462 if (s_ == FRONT) { return m_front_y_padding; }
463 else if (s_ == BACK) { return m_back_y_padding; }
464 else /* EXAMPLE */ { return m_example_y_padding; }
465 }
466
467 inline string
468 GrappConf::justification (SideSelection s_) const
469 {
470 if (s_ == FRONT) { return m_front_justification; }
471 else if (s_ == BACK) { return m_back_justification; }
472 else /* EXAMPLE */ { return m_example_justification; }
473 }
474
475 /**--------------------
476 **** Set a property **
477 **--------------------
478 */
479 inline void
480 GrappConf::x_alignment (SideSelection s_, const string& v_)
481 {
482 if (s_ == FRONT) { m_front_x_alignment = v_; }
483 else if (s_ == BACK) { m_back_x_alignment = v_; }
484 else /* EXAMPLE */ { m_example_x_alignment = v_; }
485 }
486
487 inline void
488 GrappConf::y_alignment (SideSelection s_, const string& v_)
489 {
490 if (s_ == FRONT) { m_front_y_alignment = v_; }
491 else if (s_ == BACK) { m_back_y_alignment = v_; }
492 else /* EXAMPLE */ { m_example_y_alignment = v_; }
493 }
494
495 inline void
496 GrappConf::x_padding (SideSelection s_, const string& v_)
497 {
498 if (s_ == FRONT) { m_front_x_padding = v_; }
499 else if (s_ == BACK) { m_back_x_padding = v_; }
500 else /* EXAMPLE */ { m_example_x_padding = v_; }
501 }
502
503 inline void
504 GrappConf::y_padding (SideSelection s_, const string& v_)
505 {
506 if (s_ == FRONT) { m_front_y_padding = v_; }
507 else if (s_ == BACK) { m_back_y_padding = v_; }
508 else /* EXAMPLE */ { m_example_y_padding = v_; }
509 }
510
511 inline void
512 GrappConf::justification (SideSelection s_, const string& v_)
513 {
514 if (s_ == FRONT) { m_front_justification = v_; }
515 else if (s_ == BACK) { m_back_justification = v_; }
516 else /* EXAMPLE */ { m_example_justification = v_; }
517 }
518
382519
383520 #endif /* CONFIG_H */
00 // -*- c++ -*-
11 // Generated by assa-genesis
22 //------------------------------------------------------------------------------
3 // $Id: MainWindow.cpp,v 1.51 2006/09/21 01:25:20 vlg Exp $
3 // $Id: MainWindow.cpp,v 1.56 2007/01/14 02:00:13 vlg Exp $
44 //------------------------------------------------------------------------------
55 // MainWindow.cpp
66 //------------------------------------------------------------------------------
2222 #include <gtkmm/filechooserdialog.h>
2323 #include <gdkmm/pixbuf.h>
2424 #include <gdkmm/image.h>
25 #include <gtkmm/scrolledwindow.h>
2526
2627 #ifdef IS_HILDON
27 #include <libosso.h>
28 # include <libosso.h>
2829 #endif
2930
3031 #include "Granule-main.h"
3536 #include "CardBox.h"
3637 #include "PrefWindow.h"
3738 #include "AboutGRAPP.h"
38 #include "Intern.h" // i18n macros
39 #include "MyFileOpenDialog.h"
40 #include "MyFileSaveDialog.h"
41 #include "MyFolderChooseDialog.h"
42
43 // i18n macros - always last
44 #include "Intern.h"
3945
4046 //==============================================================================
4147 // Static locals
6167 MainWindow::
6268 MainWindow () :
6369 #ifdef IS_HILDON
64 Hildon::AppView ("Granule"),
70 Hildon::AppView ("Granule"),
6571 #endif
66 m_state (Start),
67 m_top_menu_bar (*this, m_deck_manager),
68 m_open_item (NULL),
69 m_app_title (PACKAGE),
70 m_pref_window (NULL),
71 m_about (NULL)
72 m_state (Start),
73 m_top_menu_bar (*this, m_deck_manager),
74 m_open_item (NULL),
75 m_app_title (PACKAGE),
76 m_pref_window (NULL),
77 m_about (NULL)
7278 {
7379 trace_with_mask("MainWindow::MainWindow",GUITRACE);
7480
75 int x = 0;
76 int y = 0;
81 int x = 0;
82 int y = 0;
7783
7884 m_app_title += "-" + string (VERSION);
7985
86 /** For OE, put main window in a scrollwindow
87 */
88 #if defined (IS_PDA)
89 Gtk::ScrolledWindow* scrollw = Gtk::manage (new Gtk::ScrolledWindow);
90 scrollw->set_flags (Gtk::CAN_FOCUS);
91 scrollw->set_shadow_type (Gtk::SHADOW_NONE);
92 scrollw->set_policy (Gtk::POLICY_AUTOMATIC , Gtk::POLICY_AUTOMATIC);
93 add (*scrollw);
94 scrollw->add (m_contents);
95 #else
8096 add (m_contents);
97 #endif
98
8199 set_title (_(m_app_title.c_str ()));
82100 set_border_width (2);
83101
84102 #if !defined (IS_HILDON)
85 /**
86 * AppView is a Bin and thus doesn't have any of the Gtk::Window
87 * attributes.
88 */
89 set_resizable ();
90
91 Gdk::Rectangle geom = CONFIG->get_main_window_geometry ();
92 set_size_request (geom.get_width (), geom.get_height ());
93
94 CONFIG->get_win_position (x, y);
103 /**
104 * AppView is a Bin and thus doesn't have any of the Gtk::Window
105 * attributes.
106 */
107 set_resizable ();
108
109 Gdk::Rectangle geom = CONFIG->get_main_window_geometry ();
110 set_size_request (geom.get_width (), geom.get_height ());
111
112 CONFIG->get_win_position (x, y);
95113 move (x, y);
96114 #endif
97115
98 /** Menu & Toolbar
99 */
116 /** Menu & Toolbar
117 */
100118 install_menus_and_toolbar ();
101119
102 /** Here go the guts of the main window (6 - spacing between cells).
103 */
104 Gtk::HBox* hbox = manage (new Gtk::HBox (false, 6));
105
106 Gtk::Frame* frame = manage (new Gtk::Frame);
107 frame->set_label (_("CardBox"));
108 m_cardbox = manage (new CardBox);
109 frame->add (*m_cardbox);
110 hbox->pack_start (*frame, Gtk::PACK_SHRINK);
111
112 frame = manage (new Gtk::Frame);
113 frame->set_border_width (8);
114 m_deck_list = manage (new DeckList);
115
116 m_top_menu_bar.set_deck_sensitivity (false, m_deck_list->size ());
117 frame->add (*m_deck_list);
118 hbox->pack_end (*frame);
119 m_contents.pack_start (*hbox, Gtk::PACK_SHRINK);
120 m_top_menu_bar.set_sensitivity (m_state);
120 /** Here go the guts of the main window (6 - spacing between cells).
121 */
122 Gtk::HBox* hbox = manage (new Gtk::HBox (false, 6));
123
124 Gtk::Frame* frame = manage (new Gtk::Frame);
125 frame->set_label (_("CardBox"));
126 m_cardbox = manage (new CardBox);
127 frame->add (*m_cardbox);
128 hbox->pack_start (*frame, Gtk::PACK_SHRINK);
129
130 frame = manage (new Gtk::Frame);
131 frame->set_border_width (8);
132 m_deck_list = manage (new DeckList);
133
134 m_top_menu_bar.set_deck_sensitivity (false, m_deck_list->size ());
135 frame->add (*m_deck_list);
136 hbox->pack_end (*frame);
137 m_contents.pack_start (*hbox, Gtk::PACK_SHRINK);
138 m_top_menu_bar.set_sensitivity (m_state);
121139
122140 #if !defined (IS_HILDON) && !defined (WIN32)
123 set_icon_from_file (DATDIR "/pixmaps/granule.png");
141 set_icon_from_file (DATDIR "/pixmaps/granule.png");
124142 #endif
125143
126 DL ((GRAPP,"Set Application icon\n"));
144 DL ((GRAPP,"Set Application icon\n"));
127145
128146 signal_size_allocate ().connect (
129 sigc::mem_fun (*this, &MainWindow::size_allocate_cb));
147 sigc::mem_fun (*this, &MainWindow::size_allocate_cb));
130148
131149 show_all ();
132150 }
137155 {
138156 trace_with_mask("MainWindow::~MainWindow",GUITRACE);
139157
140 if (m_pref_window != NULL) {
158 if (m_pref_window != NULL) {
141159 delete m_pref_window;
142160 m_pref_window = NULL;
143 }
144
161 }
162
145163 if (m_about != NULL) {
146164 delete m_about;
147165 m_about = NULL;
178196 {
179197 trace_with_mask("MainWindow::size_allocate_cb",GUITRACE);
180198
181 CONFIG->set_main_window_geometry (allocation_.get_width (),
182 allocation_.get_height ());
199 CONFIG->set_main_window_geometry (allocation_.get_width (),
200 allocation_.get_height ());
183201 }
184202
185203 void
188206 {
189207 trace_with_mask("MainWindow::install_menus_and_toolbar",GUITRACE);
190208
191 /** Create top menu bar
192 * ---------------------------------------
193 * [File] [Help]
194 * ---------------------------------------
195 */
196 m_top_menu_bar.create ();
209 /** Create top menu bar
210 * ---------------------------------------
211 * [File] [Help]
212 * ---------------------------------------
213 */
214 m_top_menu_bar.create ();
197215 m_contents.pack_start (*m_top_menu_bar.get_menu_bar (), Gtk::PACK_SHRINK);
198216 }
199217
203221 {
204222 trace_with_mask("MainWindow::on_delete_event",GUITRACE);
205223
206 exit_cb ();
207 this->hide ();
208 GRANULE->stop_service ();
209
210 return true;
224 exit_cb ();
225 this->hide ();
226 GRANULE->stop_service ();
227
228 return true;
211229 }
212230
213231 //==============================================================================
523541 {
524542 trace_with_mask("MainWindow::open_file",GUITRACE);
525543
526 Gtk::FileChooserDialog f ("Select Card File",
527 Gtk::FILE_CHOOSER_ACTION_OPEN);
528 #ifdef IS_HILDON
529 f.set_transient_for (*HILDONAPPWIN);
530 #else
531 f.set_transient_for (*this);
532 #endif
533
534 f.add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
535 f.add_button ("Select", Gtk::RESPONSE_OK);
536
537 f.set_current_folder (CONFIG->get_filesel_path ());
538 f.set_local_only ();
539
540 Gtk::FileFilter filter;
541 filter.set_name ("CardFile");
542 filter.add_pattern ("*" CARD_FILE_EXT);
543 f.set_filter (filter);
544 if (f.run () != Gtk::RESPONSE_OK) {
544 MyFileOpenDialog f (_("Select Card File"), this,
545 "CardFile", "*" CARD_FILE_EXT);
546
547 if (f.run () != Gtk::RESPONSE_OK) {
545548 return -1;
546 }
549 }
547550
548 return (m_cardbox->load (f.get_filename ()));
551 return (m_cardbox->load (f.get_filename ()));
549552 }
550553
551554 int
558561
559562 if (projname == UNKNOWN_FNAME)
560563 {
561 Gtk::FileChooserDialog f (_("Choose New CardFile name"),
562 Gtk::FILE_CHOOSER_ACTION_SAVE);
563 f.add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
564 f.add_button ("Save", Gtk::RESPONSE_OK);
565 f.set_current_folder (CONFIG->get_filesel_path ());
566 f.set_local_only ();
567
568 Gtk::FileFilter fcd_filter;
569 fcd_filter.set_name ("CardFile");
570 fcd_filter.add_pattern ("*" CARD_FILE_EXT);
571 f.set_filter (fcd_filter);
564 MyFileSaveDialog f (_("Choose New CardFile name"), this,
565 "CardFile", "*" CARD_FILE_EXT);
566
567 f.set_current_name ("Unknown.cdf");
572568
573569 if (f.run () != Gtk::RESPONSE_OK) {
574570 return -1;
605601 {
606602 trace_with_mask("MainWindow::save_file_as",GUITRACE);
607603
608 Gtk::FileChooserDialog f (_("Save Card File As ..."),
609 Gtk::FILE_CHOOSER_ACTION_SAVE);
610 #ifdef IS_HILDON
611 f.set_transient_for (*HILDONAPPWIN);
612 #else
613 f.set_transient_for (*this);
614 #endif
615 f.add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
616 f.add_button ("Save", Gtk::RESPONSE_OK);
617 f.set_current_folder (CONFIG->get_filesel_path ());
618 f.set_local_only ();
619
620 Gtk::FileFilter filter_cdf;
621 filter_cdf.set_name ("CardFile");
622 filter_cdf.add_pattern ("*" CARD_FILE_EXT);
623 f.set_filter (filter_cdf);
604 MyFileSaveDialog f (_("Save Card File As ..."), this,
605 "CardFile", "*" CARD_FILE_EXT);
624606
625607 if (f.run () != Gtk::RESPONSE_OK) {
626608 return -1;
644626
645627 #else
646628
647 /**
648 From GTK+ Reference Manual:
649
650 GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER -
651
652 Indicates an Open mode for selecting folders.
653 The file chooser will let the user pick an existing folder.
654 */
655 Gtk::FileChooserDialog f (*this, _("Select A Folder To Export To"),
656 Gtk::FILE_CHOOSER_ACTION_SELECT_FOLDER);
657
658 f.add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
659 f.add_button (_("Select"), Gtk::RESPONSE_OK);
660 f.set_current_folder (CONFIG->get_filesel_path ());
661 f.set_local_only ();
629 MyFolderChooseDialog f (_("Select A Folder To Export To"), this);
662630
663631 if (f.run () != Gtk::RESPONSE_OK) {
664632 return -1;
674642 m_cardbox->export_sound_bits (f.get_filename ());
675643
676644 #endif
645
677646 return 0;
678647 }
679648
00 // -*- c++ -*-
11 // Generated by assa-genesis
22 //------------------------------------------------------------------------------
3 // $Id: MainWindow.h,v 1.31 2006/09/20 01:56:24 vlg Exp $
3 // $Id: MainWindow.h,v 1.33 2007/01/01 01:00:36 vlg Exp $
44 //------------------------------------------------------------------------------
55 // MainWindow.h
66 //------------------------------------------------------------------------------
4949 MainWindow ();
5050 ~MainWindow ();
5151
52 /** Post-c'tor initialization
53 */
54 void init ();
52 /** Post-c'tor initialization
53 */
54 void init ();
5555
56 // -*- Toolbar Callbacks -*-
57 void about_cb ();
56 // -*- Toolbar Callbacks -*-
57 void about_cb ();
5858
59 // [File] Menu
60 void pref_cb ();
59 // [File] Menu
60 void pref_cb ();
6161 void exit_cb ();
6262
6363 // [CardFile] Menu
6666 void open_recent_cb (guint index_); // set in TopMenuBar
6767 void save_cb ();
6868 void save_as_cb ();
69 void export_sound_cb ();
69 void export_sound_cb ();
7070 void close_cb ();
71 void play_in_box (int idx_);
71 void play_in_box (int idx_);
7272
73 // [Deck] Menu
74 void unselect_deck_cb ();
73 // [Deck] Menu
74 void unselect_deck_cb ();
7575
76 /** Remember window size when resized.
77 */
78 void size_allocate_cb (Gtk::Allocation& size_);
76 /** Remember window size when resized.
77 */
78 void size_allocate_cb (Gtk::Allocation& size_);
7979
80 void set_mw_name ();
81 //virtual int delete_event_impl (GdkEventAny* event);
82 virtual bool on_delete_event (GdkEventAny* event_);
80 void set_mw_name ();
81 //virtual int delete_event_impl (GdkEventAny* event);
82 virtual bool on_delete_event (GdkEventAny* event_);
8383
84 DeckManager* get_deck_manager () { return &m_deck_manager; }
85 DeckList* get_deck_list () { return m_deck_list; }
86 CardBox* get_cardbox () { return m_cardbox; }
87 PrefWindow* get_pref_window () { return m_pref_window; }
88 TopMenuBar* get_top_menubar () { return &m_top_menu_bar; }
84 DeckManager* get_deck_manager () { return &m_deck_manager; }
85 DeckList* get_deck_list () { return m_deck_list; }
86 CardBox* get_cardbox () { return m_cardbox; }
87 TopMenuBar* get_top_menubar () { return &m_top_menu_bar; }
8988
90 friend void CardBox::add_deck_to_box (int idx_,
91 Deck* from_deck_);
89 friend void CardBox::add_deck_to_box (int idx_,
90 Deck* from_deck_);
9291
93 friend void CardBox::move_card_to_box (VDeck::cardlist_iterator card_ref_,
94 int from_deck_,
95 int to_deck_,
96 bool is_expired_);
92 friend void CardBox::move_card_to_box (VDeck::cardlist_iterator card_ref_,
93 int from_deck_,
94 int to_deck_,
95 bool is_expired_);
9796
98 friend int CardBox::add_cards_to_box (std::vector<CardRef*>& cardlist_);
97 friend int CardBox::add_cards_to_box (std::vector<CardRef*>& cardlist_);
9998
100 friend void CardBox::mark_as_modified ();
99 friend void CardBox::mark_as_modified ();
101100
102 void set_dnd_source (Deck* deck_) { m_dnd_source = deck_; }
103 Deck* get_dnd_source () { return m_dnd_source; }
101 void set_dnd_source (Deck* deck_) { m_dnd_source = deck_; }
102 Deck* get_dnd_source () { return m_dnd_source; }
104103
105104 private:
106 // -*- Utilities -*-
105 // -*- Utilities -*-
107106 void install_menus_and_toolbar ();
108107 void print_state (void) const;
109108
111110 int open_file ();
112111 int save_file ();
113112 int save_file_as ();
114 int export_sound_bits ();
115 void close_file ();
116 void go_state (WMState state_);
117 bool change_preferences ();
113 int export_sound_bits ();
114 void close_file ();
115 void go_state (WMState state_);
116 bool change_preferences ();
118117
119118 private:
120 static const char* states [];
119 static const char* states [];
121120
122 WMState m_state;
121 WMState m_state;
123122 Gtk::VBox m_contents;
124 DeckManager m_deck_manager;
125 TopMenuBar m_top_menu_bar;
126 Gtk::Widget* m_open_item;
127 string m_app_title;
128 DeckList* m_deck_list;
129 CardBox* m_cardbox; // Tray with cardboxes
130 PrefWindow* m_pref_window;
131 AboutGRAPP* m_about; // 'About' dialog
132 Deck* m_dnd_source;
123 DeckManager m_deck_manager;
124 TopMenuBar m_top_menu_bar;
125 Gtk::Widget* m_open_item;
126 string m_app_title;
127 DeckList* m_deck_list;
128 CardBox* m_cardbox; // Tray with cardboxes
129 PrefWindow* m_pref_window;
130 AboutGRAPP* m_about; // 'About' dialog
131 Deck* m_dnd_source;
133132 };
134133
135134 #endif // MAIN_WINDOW_H
11 # ------------------------------------------------------------------------------
22 # src/Makefile.am
33 #
4 # $Id: Makefile.am,v 1.31 2006/09/03 19:26:36 vlg Exp $
4 # $Id: Makefile.am,v 1.37 2006/12/26 04:53:55 vlg Exp $
55 # ------------------------------------------------------------------------------
66
77 bin_PROGRAMS = granule
1010 Intern.h \
1111 CSVImportDialog.h \
1212 CSVImportDialog.cpp \
13 CSVExportDialog.h \
14 CSVExportDialog.cpp \
1315 AboutGRAPP.h \
1416 AboutGRAPP.cpp \
1517 VDeck.h \
4143 CardView.cpp \
4244 CardViewHelpDialog.h \
4345 CardViewHelpDialog.cpp \
44 EditControls.h \
45 EditControls.cpp \
46 FileOpen.h \
46 EditControls.h \
47 EditControls.cpp \
48 FileOpen.h \
49 MyFileOpenDialog.h \
50 MyFileOpenDialog.cpp \
51 MyFileSaveDialog.h \
52 MyFileSaveDialog.cpp \
53 MyFolderChooseDialog.h \
54 MyFolderChooseDialog.cpp \
55 MyInputDialog.h \
56 MyInputDialog.cpp \
4757 GrappConf.h \
4858 GrappConf.cpp \
4959 TopMenuBar.h \
5868 GeometryPrefs.cpp \
5969 AppearancePrefs.h \
6070 AppearancePrefs.cpp \
71 MyTextAlignmentsWidget.h \
72 MyTextAlignmentsWidget.cpp \
73 TextAlignment.h \
74 TextAlignment.cpp \
6175 PrefWindow.h \
6276 PrefWindow.cpp \
6377 MyPropertyBox.h \
7589
7690 if USE_HILDON
7791 DEP_CFLAGS = -DIS_HILDON
92 endif
93
94 if USE_PDA
95 DEP_CFLAGS = -DIS_PDA
7896 endif
7997
8098 INCLUDES = \
1717 # ------------------------------------------------------------------------------
1818 # src/Makefile.am
1919 #
20 # $Id: Makefile.am,v 1.31 2006/09/03 19:26:36 vlg Exp $
20 # $Id: Makefile.am,v 1.37 2006/12/26 04:53:55 vlg Exp $
2121 # ------------------------------------------------------------------------------
2222
2323 srcdir = @srcdir@
5555 am__installdirs = "$(DESTDIR)$(bindir)"
5656 binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
5757 PROGRAMS = $(bin_PROGRAMS)
58 am_granule_OBJECTS = CSVImportDialog.$(OBJEXT) AboutGRAPP.$(OBJEXT) \
58 am_granule_OBJECTS = CSVImportDialog.$(OBJEXT) \
59 CSVExportDialog.$(OBJEXT) AboutGRAPP.$(OBJEXT) \
5960 CardDeck.$(OBJEXT) Deck.$(OBJEXT) CardBox.$(OBJEXT) \
6061 DeckView.$(OBJEXT) DeckInfo.$(OBJEXT) DeckPlayer.$(OBJEXT) \
6162 DeckManager.$(OBJEXT) DeckList.$(OBJEXT) \
6263 MyDialogWithCheckbutton.$(OBJEXT) VCard.$(OBJEXT) \
6364 CardRef.$(OBJEXT) Card.$(OBJEXT) CardView.$(OBJEXT) \
6465 CardViewHelpDialog.$(OBJEXT) EditControls.$(OBJEXT) \
66 MyFileOpenDialog.$(OBJEXT) MyFileSaveDialog.$(OBJEXT) \
67 MyFolderChooseDialog.$(OBJEXT) MyInputDialog.$(OBJEXT) \
6568 GrappConf.$(OBJEXT) TopMenuBar.$(OBJEXT) GeneralPref.$(OBJEXT) \
6669 SchedulingPrefs.$(OBJEXT) SoundPrefs.$(OBJEXT) \
6770 GeometryPrefs.$(OBJEXT) AppearancePrefs.$(OBJEXT) \
71 MyTextAlignmentsWidget.$(OBJEXT) TextAlignment.$(OBJEXT) \
6872 PrefWindow.$(OBJEXT) MyPropertyBox.$(OBJEXT) \
6973 ButtonWithImageLabel.$(OBJEXT) MainWindow.$(OBJEXT) \
7074 Granule.$(OBJEXT) Granule-main.$(OBJEXT)
194198 USE_HILDON_FALSE = @USE_HILDON_FALSE@
195199 USE_HILDON_TRUE = @USE_HILDON_TRUE@
196200 USE_NLS = @USE_NLS@
201 USE_PDA_FALSE = @USE_PDA_FALSE@
202 USE_PDA_TRUE = @USE_PDA_TRUE@
197203 VERSION = @VERSION@
198204 WIN32_EXTRA_LIBADD = @WIN32_EXTRA_LIBADD@
199205 XGETTEXT = @XGETTEXT@
256262 Intern.h \
257263 CSVImportDialog.h \
258264 CSVImportDialog.cpp \
265 CSVExportDialog.h \
266 CSVExportDialog.cpp \
259267 AboutGRAPP.h \
260268 AboutGRAPP.cpp \
261269 VDeck.h \
287295 CardView.cpp \
288296 CardViewHelpDialog.h \
289297 CardViewHelpDialog.cpp \
290 EditControls.h \
291 EditControls.cpp \
292 FileOpen.h \
298 EditControls.h \
299 EditControls.cpp \
300 FileOpen.h \
301 MyFileOpenDialog.h \
302 MyFileOpenDialog.cpp \
303 MyFileSaveDialog.h \
304 MyFileSaveDialog.cpp \
305 MyFolderChooseDialog.h \
306 MyFolderChooseDialog.cpp \
307 MyInputDialog.h \
308 MyInputDialog.cpp \
293309 GrappConf.h \
294310 GrappConf.cpp \
295311 TopMenuBar.h \
304320 GeometryPrefs.cpp \
305321 AppearancePrefs.h \
306322 AppearancePrefs.cpp \
323 MyTextAlignmentsWidget.h \
324 MyTextAlignmentsWidget.cpp \
325 TextAlignment.h \
326 TextAlignment.cpp \
307327 PrefWindow.h \
308328 PrefWindow.cpp \
309329 MyPropertyBox.h \
319339
320340 localedir = $(datadir)/locale
321341 @USE_HILDON_TRUE@DEP_CFLAGS = -DIS_HILDON
342 @USE_PDA_TRUE@DEP_CFLAGS = -DIS_PDA
322343 INCLUDES = \
323344 -g \
324345 -I$(top_srcdir) \
418439 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/AboutGRAPP.Po@am__quote@
419440 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/AppearancePrefs.Po@am__quote@
420441 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ButtonWithImageLabel.Po@am__quote@
442 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CSVExportDialog.Po@am__quote@
421443 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CSVImportDialog.Po@am__quote@
422444 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Card.Po@am__quote@
423445 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CardBox.Po@am__quote@
439461 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GrappConf.Po@am__quote@
440462 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MainWindow.Po@am__quote@
441463 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MyDialogWithCheckbutton.Po@am__quote@
464 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MyFileOpenDialog.Po@am__quote@
465 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MyFileSaveDialog.Po@am__quote@
466 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MyFolderChooseDialog.Po@am__quote@
467 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MyInputDialog.Po@am__quote@
442468 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MyPropertyBox.Po@am__quote@
469 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MyTextAlignmentsWidget.Po@am__quote@
443470 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PrefWindow.Po@am__quote@
444471 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SchedulingPrefs.Po@am__quote@
445472 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SoundPrefs.Po@am__quote@
473 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/TextAlignment.Po@am__quote@
446474 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/TopMenuBar.Po@am__quote@
447475 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/VCard.Po@am__quote@
448476
0 // -*- c++ -*-
1 //------------------------------------------------------------------------------
2 // MyFileOpenDialog.cpp
3 //------------------------------------------------------------------------------
4 // $Id: MyFileOpenDialog.cpp,v 1.5 2007/01/03 03:49:11 vlg Exp $
5 //------------------------------------------------------------------------------
6 // Copyright (c) 2006 by Vladislav Grinchenko
7 //
8 // This program is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU General Public License
10 // as published by the Free Software Foundation; either version
11 // 2 of the License, or (at your option) any later version.
12 //------------------------------------------------------------------------------
13
14 #include "GrappConf.h"
15 #include "MyFileOpenDialog.h"
16
17 /**
18 * Filenames are always returned in the character set specified by the
19 * G_FILENAME_ENCODING environment variable (local encoding).
20 *
21 * This means that while you can pass the result of FileChooser::get_filename()
22 * to open(2) or fopen(3), you may not be able to directly set it as the text
23 * of a Gtk::Label widget unless you convert it first to UTF-8, which all
24 * gtkmm widgets expect. You should use Glib::filename_to_utf8() to convert
25 * filenames into strings that can be passed to gtkmm widgets.
26 *
27 * Note:
28 * The gtkmm FileChooser API is broken in that methods return Glib::ustring
29 * even though the returned string is not necessarily UTF-8 encoded.
30 * Any FileChooser method that takes or returns a filename (not a URI) should
31 * have std::string as parameter or return type. Fortunately this mistake
32 * doesn't prevent you from handling filenames correctly in your application.
33 * Just pretend that the API uses std::string and call
34 * Glib::filename_to_utf8() or Glib::filename_from_utf8() as appropriate.
35 */
36 MyFileOpenDialog::
37 MyFileOpenDialog (const Glib::ustring& title_,
38 Gtk::Widget* parent_,
39 const Glib::ustring& filter_name_,
40 const Glib::ustring& filter_pattern_)
41 {
42 #ifdef OBSOLETE
43
44 m_dialog = new Gtk::FileSelection (title_);
45 m_dialog->hide_fileop_buttons ();
46 m_dialog->set_filename (CONFIG->get_filesel_path ());
47
48 #else /* Desktop, nokia770 */
49
50 m_dialog = new Gtk::FileChooserDialog (title_,
51 Gtk::FILE_CHOOSER_ACTION_OPEN);
52 int counter = 0;
53 Granule::hide_fcd_gtk_labels (GTK_CONTAINER (m_dialog->gobj ()), counter);
54
55 m_dialog->add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
56 m_dialog->add_button ("Select", Gtk::RESPONSE_OK);
57 m_dialog->set_current_folder (CONFIG->get_filesel_path ());
58 m_dialog->set_local_only ();
59
60 if (filter_name_.length () > 0)
61 {
62 Gtk::FileFilter filter;
63 filter.set_name (filter_name_);
64 filter.add_pattern (filter_pattern_);
65 m_dialog->set_filter (filter);
66 }
67 #endif
68
69 #ifdef IS_HILDON
70 m_dialog->set_transient_for (*HILDONAPPWIN);
71 #else
72 m_dialog->set_transient_for ((Gtk::Window&)*parent_);
73 #endif
74
75 }
76
77 std::vector<Glib::ustring>
78 MyFileOpenDialog::
79 get_filenames () const
80 {
81 #ifdef OBSOLETE
82 // not implemented, but can be via
83 //
84 // Glib::ArrayHandle<std::string> Gtk::FileSelection::get_selections()
85 //
86 #else
87 return (m_dialog->get_filenames ());
88 #endif
89 }
90
91
0 // -*- c++ -*-
1 //------------------------------------------------------------------------------
2 // MyFileOpenDialog.h
3 //------------------------------------------------------------------------------
4 // $Id: MyFileOpenDialog.h,v 1.4 2007/01/02 00:15:41 vlg Exp $
5 //------------------------------------------------------------------------------
6 // Copyright (c) 2006 by Vladislav Grinchenko
7 //
8 // This program is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU General Public License
10 // as published by the Free Software Foundation; either version
11 // 2 of the License, or (at your option) any later version.
12 //------------------------------------------------------------------------------
13 #ifndef MY_FILE_OPEN_DIALOG_H
14 #define MY_FILE_OPEN_DIALOG_H
15
16 #include <vector>
17 #include <gtkmm/filechooserdialog.h>
18 #include <gtkmm/fileselection.h>
19
20 #include "Granule-main.h"
21 #include "Granule.h"
22
23 class MyFileOpenDialog
24 {
25 public:
26 MyFileOpenDialog (const Glib::ustring& title_,
27 Gtk::Widget* parent_,
28 const Glib::ustring& filter_name_ = "",
29 const Glib::ustring& filter_pattern_ = "");
30
31 ~MyFileOpenDialog ();
32
33 /** For single-entry
34 */
35 void set_current_name (const Glib::ustring& name_);
36 Glib::ustring get_filename () const;
37
38 /** For multi-entries
39 */
40 void set_select_multiple (bool v_ = true);
41 std::vector<Glib::ustring> get_filenames () const;
42
43 int run ();
44 void show ();
45 void hide ();
46
47 private:
48
49 #ifdef OBSOLETE
50 Gtk::FileSelection* m_dialog;
51 #else
52 Gtk::FileChooserDialog* m_dialog;
53 #endif
54 bool m_multi_choice; // If true, allows to select multiple items
55 };
56
57 //------------------------------------------------------------------------------
58 // Inline functions
59 //------------------------------------------------------------------------------
60 inline
61 MyFileOpenDialog::
62 ~MyFileOpenDialog ()
63 {
64 if (m_dialog) {
65 delete m_dialog;
66 m_dialog = NULL;
67 }
68 }
69
70 inline Glib::ustring
71 MyFileOpenDialog::
72 get_filename () const
73 {
74 return (m_dialog->get_filename ());
75 }
76
77 inline void
78 MyFileOpenDialog::
79 set_current_name (const Glib::ustring& name_)
80 {
81 #ifdef OBSOLETE
82 m_dialog->set_filename (name_);
83 #else
84 m_dialog->set_current_name (name_);
85 #endif
86 }
87
88 inline void
89 MyFileOpenDialog::
90 set_select_multiple (bool v_)
91 {
92 #ifdef OBSOLETE
93 m_dialog->set_select_multiple (v_);
94 #else
95 m_dialog->set_select_multiple (v_);
96 #endif
97 }
98
99 inline int
100 MyFileOpenDialog::
101 run ()
102 {
103 return (m_dialog->run ());
104 }
105
106 inline void
107 MyFileOpenDialog::
108 hide ()
109 {
110 m_dialog->hide ();
111 }
112
113 inline void
114 MyFileOpenDialog::
115 show ()
116 {
117 m_dialog->show ();
118 }
119
120
121
122 #endif /* MY_FILE_OPEN_DIALOG_H */
0 // -*- c++ -*-
1 //------------------------------------------------------------------------------
2 // MyFileSaveDialog.cpp
3 //------------------------------------------------------------------------------
4 // $Id: MyFileSaveDialog.cpp,v 1.4 2007/01/03 03:49:11 vlg Exp $
5 //------------------------------------------------------------------------------
6 // Copyright (c) 2006 by Vladislav Grinchenko
7 //
8 // This program is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU General Public License
10 // as published by the Free Software Foundation; either version
11 // 2 of the License, or (at your option) any later version.
12 //------------------------------------------------------------------------------
13
14 #include "GrappConf.h"
15 #include "MyFileSaveDialog.h"
16
17 MyFileSaveDialog::
18 MyFileSaveDialog (const Glib::ustring& title_,
19 Gtk::Widget* parent_,
20 const Glib::ustring& filter_name_,
21 const Glib::ustring& filter_pattern_)
22 {
23 #ifdef OBSOLETE
24
25 m_dialog = new Gtk::FileSelection (title_);
26 m_dialog->set_filename (CONFIG->get_filesel_path ());
27
28 #else
29 m_dialog = new Gtk::FileChooserDialog (title_,
30 Gtk::FILE_CHOOSER_ACTION_SAVE);
31 int counter = 0;
32 Granule::hide_fcd_gtk_labels (GTK_CONTAINER (m_dialog->gobj ()), counter);
33
34 m_dialog->add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
35 m_dialog->add_button ("Save", Gtk::RESPONSE_OK);
36
37 m_dialog->set_current_folder (CONFIG->get_filesel_path ());
38 m_dialog->set_local_only ();
39
40 if (filter_name_.length () > 0)
41 {
42 Gtk::FileFilter filter;
43 filter.set_name (filter_name_);
44 filter.add_pattern (filter_pattern_);
45
46 m_dialog->set_filter (filter);
47 }
48 #endif
49
50 #ifdef IS_HILDON
51 m_dialog->set_transient_for (*HILDONAPPWIN);
52 #else
53 m_dialog->set_transient_for ((Gtk::Window&) *parent_);
54 #endif
55 }
56
0 // -*- c++ -*-
1 //------------------------------------------------------------------------------
2 // MyFileSaveDialog.h
3 //------------------------------------------------------------------------------
4 // $Id: MyFileSaveDialog.h,v 1.3 2006/12/21 03:36:35 vlg Exp $
5 //------------------------------------------------------------------------------
6 // Copyright (c) 2006 by Vladislav Grinchenko
7 //
8 // This program is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU General Public License
10 // as published by the Free Software Foundation; either version
11 // 2 of the License, or (at your option) any later version.
12 //------------------------------------------------------------------------------
13 #ifndef MY_FILE_SAVE_DIALOG_H
14 #define MY_FILE_SAVE_DIALOG_H
15
16 #include <gtkmm/filechooserdialog.h>
17 #include <gtkmm/fileselection.h>
18
19 #include "Granule-main.h"
20 #include "Granule.h"
21
22 class MyFileSaveDialog
23 {
24 public:
25 MyFileSaveDialog (const Glib::ustring& title_,
26 Gtk::Widget* parent_,
27 const Glib::ustring& filter_name_ = "",
28 const Glib::ustring& filter_pattern_ = "");
29
30 ~MyFileSaveDialog ();
31
32 Glib::ustring get_filename () const;
33 void set_current_name (const Glib::ustring& name_);
34
35 int run ();
36 void show ();
37 void hide ();
38
39 private:
40
41 #ifdef OBSOLETE
42 Gtk::FileSelection* m_dialog;
43 #else
44 Gtk::FileChooserDialog* m_dialog;
45 #endif
46 };
47
48 //------------------------------------------------------------------------------
49 // Inline functions
50 //------------------------------------------------------------------------------
51 inline
52 MyFileSaveDialog::
53 ~MyFileSaveDialog ()
54 {
55 if (m_dialog) {
56 delete m_dialog;
57 m_dialog = NULL;
58 }
59 }
60
61 inline Glib::ustring
62 MyFileSaveDialog::
63 get_filename () const
64 {
65 return (m_dialog->get_filename ());
66 }
67
68 inline void
69 MyFileSaveDialog::
70 set_current_name (const Glib::ustring& name_)
71 {
72 #ifdef OBSOLETE
73 m_dialog->set_filename (name_);
74 #else
75 m_dialog->set_current_name (name_);
76 #endif
77 }
78
79 inline int
80 MyFileSaveDialog::
81 run ()
82 {
83 return (m_dialog->run ());
84 }
85
86 inline void
87 MyFileSaveDialog::
88 hide ()
89 {
90 m_dialog->hide ();
91 }
92
93 inline void
94 MyFileSaveDialog::
95 show ()
96 {
97 m_dialog->show ();
98 }
99
100
101
102 #endif /* MY_FILE_SAVE_DIALOG_H */
0 // -*- c++ -*-
1 //------------------------------------------------------------------------------
2 // MyFolderChooseDialog.cpp
3 //------------------------------------------------------------------------------
4 // $Id: MyFolderChooseDialog.cpp,v 1.4 2007/01/03 03:49:11 vlg Exp $
5 //------------------------------------------------------------------------------
6 // Copyright (c) 2006 by Vladislav Grinchenko
7 //
8 // This program is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU General Public License
10 // as published by the Free Software Foundation; either version
11 // 2 of the License, or (at your option) any later version.
12 //------------------------------------------------------------------------------
13
14 #include "GrappConf.h"
15 #include "MyFolderChooseDialog.h"
16
17 /**
18 * From GTK+ Reference Manual:
19 *
20 * GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER -
21 *
22 * Indicates an Open mode for selecting folders.
23 * The file chooser will let the user pick an existing folder.
24 */
25
26 MyFolderChooseDialog::
27 MyFolderChooseDialog (const Glib::ustring& title_, Gtk::Widget* parent_)
28 {
29 #ifdef OBSOLETE
30
31 m_dialog = new Gtk::FileSelection (title_);
32 m_dialog->set_filename (CONFIG->get_filesel_path ());
33 m_dialog->get_file_list ()->get_parent ()->hide ();
34
35 #else
36
37 m_dialog = new Gtk::FileChooserDialog (title_,
38 Gtk::FILE_CHOOSER_ACTION_SELECT_FOLDER);
39 int counter = 0;
40 Granule::hide_fcd_gtk_labels (GTK_CONTAINER (m_dialog->gobj ()), counter);
41
42 m_dialog->add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
43 m_dialog->add_button ("Select", Gtk::RESPONSE_OK);
44
45 m_dialog->set_current_folder (CONFIG->get_filesel_path () +
46 G_DIR_SEPARATOR_S);
47 m_dialog->set_local_only ();
48 #endif
49
50 #ifdef IS_HILDON
51 m_dialog->set_transient_for (*HILDONAPPWIN);
52 #else
53 m_dialog->set_transient_for ((Gtk::Window&)*parent_);
54 #endif
55
56 }
57
0 // -*- c++ -*-
1 //------------------------------------------------------------------------------
2 // MyFolderChooseDialog.h
3 //------------------------------------------------------------------------------
4 // $Id: MyFolderChooseDialog.h,v 1.3 2006/12/21 03:36:35 vlg Exp $
5 //------------------------------------------------------------------------------
6 // Copyright (c) 2006 by Vladislav Grinchenko
7 //
8 // This program is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU General Public License
10 // as published by the Free Software Foundation; either version
11 // 2 of the License, or (at your option) any later version.
12 //------------------------------------------------------------------------------
13 #ifndef MY_FOLDER_CHOOSE_DIALOG_H
14 #define MY_FOLDER_CHOOSE_DIALOG_H
15
16 #include <gtkmm/filechooserdialog.h>
17 #include <gtkmm/fileselection.h>
18
19 #include "Granule-main.h"
20 #include "Granule.h"
21
22 class MyFolderChooseDialog
23 {
24 public:
25 MyFolderChooseDialog (const Glib::ustring& title_, Gtk::Widget* parent_);
26
27 ~MyFolderChooseDialog ();
28
29 Glib::ustring get_filename () const;
30 void set_current_folder (const Glib::ustring& name_);
31
32 int run ();
33 void show ();
34 void hide ();
35
36 private:
37
38 #ifdef OBSOLETE
39 Gtk::FileSelection* m_dialog;
40 #else
41 Gtk::FileChooserDialog* m_dialog;
42 #endif
43 };
44
45 //------------------------------------------------------------------------------
46 // Inline functions
47 //------------------------------------------------------------------------------
48 inline
49 MyFolderChooseDialog::
50 ~MyFolderChooseDialog ()
51 {
52 if (m_dialog) {
53 delete m_dialog;
54 m_dialog = NULL;
55 }
56 }
57
58 inline Glib::ustring
59 MyFolderChooseDialog::
60 get_filename () const
61 {
62 return (m_dialog->get_filename ());
63 }
64
65 inline void
66 MyFolderChooseDialog::
67 set_current_folder (const Glib::ustring& dirname_)
68 {
69 #ifdef OBSOLETE
70 m_dialog->set_filename (dirname_);
71 #else
72 m_dialog->set_current_folder (dirname_);
73 #endif
74 }
75
76 inline int
77 MyFolderChooseDialog::
78 run ()
79 {
80 return (m_dialog->run ());
81 }
82
83 inline void
84 MyFolderChooseDialog::
85 hide ()
86 {
87 m_dialog->hide ();
88 }
89
90 inline void
91 MyFolderChooseDialog::
92 show ()
93 {
94 m_dialog->show ();
95 }
96
97
98
99 #endif /* MY_FOLDER_CHOOSE_DIALOG_H */
0 // -*- c++ -*-
1 //------------------------------------------------------------------------------
2 // $Id: MyInputDialog.cpp,v 1.1 2006/12/26 04:53:55 vlg Exp $
3 //------------------------------------------------------------------------------
4 // MyInputDialog.cpp
5 //------------------------------------------------------------------------------
6 // Copyright (c) 2006 by Vladislav Grinchenko
7 //
8 // This program is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU General Public License
10 // as published by the Free Software Foundation; either version
11 // 2 of the License, or (at your option) any later version.
12 //------------------------------------------------------------------------------
13 //
14 // Date : Mon Dec 25 15:57:28 EST 2006
15 //
16 //------------------------------------------------------------------------------
17
18 #include <gtkmm/stock.h>
19
20 #include "MyInputDialog.h"
21
22 MyInputDialog::
23 MyInputDialog (const Glib::ustring& message_, const Glib::ustring& value_)
24 :
25 Gtk::MessageDialog (message_,
26 true, /* markup message? */
27 Gtk::MESSAGE_QUESTION,
28 Gtk::BUTTONS_NONE,
29 true), /* modal dialog */
30 m_local_entry (NULL)
31 {
32 add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL );
33 add_button (Gtk::Stock::OK, Gtk::RESPONSE_OK);
34
35 m_local_entry =Gtk::manage (new Gtk::Entry ());
36
37 m_local_entry->set_flags (Gtk::CAN_FOCUS);
38 m_local_entry->set_visibility (true);
39 m_local_entry->set_editable (true);
40 m_local_entry->set_has_frame (true);
41 m_local_entry->set_activates_default (true);
42
43 m_local_entry->set_text(value_);
44
45 get_vbox ()->pack_start (*m_local_entry, Gtk::PACK_SHRINK, 0);
46
47 show_all_children ();
48 }
49
0 // -*- c++ -*-
1 //------------------------------------------------------------------------------
2 // $Id: MyInputDialog.h,v 1.1 2006/12/26 04:53:55 vlg Exp $
3 //------------------------------------------------------------------------------
4 // MyInputDialog.h
5 //------------------------------------------------------------------------------
6 // Copyright (c) 2006 by Vladislav Grinchenko
7 //
8 // This program is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU General Public License
10 // as published by the Free Software Foundation; either version
11 // 2 of the License, or (at your option) any later version.
12 //------------------------------------------------------------------------------
13 //
14 // Date : Mon Dec 25 15:53:51 EST 2006
15 //
16 //------------------------------------------------------------------------------
17 #ifndef MY_INPUT_DIALOG_H
18 #define MY_INPUT_DIALOG_H
19
20 #include <gtkmm/messagedialog.h>
21 #include <gtkmm/entry.h>
22
23
24 /* @class MyInputDialog
25
26 A standard question dialog and two buttons, 'OK' and 'Cancel',
27 with additional input entry field positioned below the the message.
28
29 The run() method returns Gtk::RESPONSE_OK if 'OK' button is pressed
30 and Gtk::RESPONSE_CANCEL if 'Cancel' button is pressed.
31
32 @param message_ - Message to display
33 @param value_ - Initial value of the entry widget.
34 */
35 class MyInputDialog : public Gtk::MessageDialog
36 {
37 public:
38 MyInputDialog (const Glib::ustring& message_, const Glib::ustring& value_);
39
40 Glib::ustring get_entry_value () const;
41
42 private:
43 Gtk::Entry* m_local_entry;
44 };
45
46 inline
47 Glib::ustring
48 MyInputDialog::
49 get_entry_value () const
50 {
51 if (m_local_entry != NULL) {
52 return (m_local_entry->get_text ());
53 }
54 }
55
56 #endif /* MY_INPUT_DIALOG */
11 //------------------------------------------------------------------------------
22 // MyPropertyBox.cpp
33 //------------------------------------------------------------------------------
4 // $Id: MyPropertyBox.cpp,v 1.6 2006/03/19 15:39:44 vlg Exp $
4 // $Id: MyPropertyBox.cpp,v 1.7 2006/12/11 03:07:22 vlg Exp $
55 //------------------------------------------------------------------------------
66 // Copyright (c) 2002-2004 by Vladislav Grinchenko
77 //
7474 mem_fun (*this, &MyPropertyBox::hildon_im_close_cb));
7575 #endif
7676
77 m_notebook->set_show_border (); // to draw a bevel around the pages
78 m_notebook->set_scrollable (); // set the tab label area scrollable
79
7780 get_vbox ()->pack_start (*m_notebook);
78 m_notebook->set_show_border (true);
7981
8082 show_all_children ();
8183 }
0 // -*- c++ -*-
1 //------------------------------------------------------------------------------
2 // $Id: MyTextAlignmentsWidget.cpp,v 1.4 2007/01/08 04:32:36 vlg Exp $
3 //------------------------------------------------------------------------------
4 // MyTextAlignmentsWidget.cpp
5 //------------------------------------------------------------------------------
6 // Copyright (c) 2006 by Vladislav Grinchenko
7 //
8 // This program is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU General Public License
10 // as published by the Free Software Foundation; either version
11 // 2 of the License, or (at your option) any later version.
12 //------------------------------------------------------------------------------
13 //
14 // Date : Wed Nov 1 2006
15 //
16 //------------------------------------------------------------------------------
17 #include <gtkmm/button.h>
18 #include <gtkmm/buttonbox.h>
19 #include <gtkmm/label.h>
20 #include <gtkmm/frame.h>
21 #include <gtkmm/box.h>
22 #include <gtkmm/alignment.h>
23
24 #include "MyTextAlignmentsWidget.h"
25
26 #include "Intern.h" // i18n macros
27
28 using sigc::mem_fun;
29
30 /**-----------------------------------------------------------------------------
31 * Some useful macros
32 **-----------------------------------------------------------------------------
33 */
34 static void TA_SET_LABEL (Gtk::Label* l_, bool m_)
35 {
36 l_->set_alignment (0.5,0.5);
37 l_->set_padding (5,0);
38 l_->set_justify (Gtk::JUSTIFY_LEFT);
39 l_->set_line_wrap (false);
40 l_->set_use_markup (m_);
41 l_->set_selectable (false);
42 #ifndef IS_HILDON
43 #if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION >= 6)
44 l_->set_ellipsize (Pango::ELLIPSIZE_NONE);
45 l_->set_width_chars (-1);
46 l_->set_angle (0);
47 l_->set_single_line_mode (false);
48 #endif
49 #endif
50 }
51
52 static void TA_SET_FRAME (Gtk::Frame* f_,
53 Gtk::Label* l_,
54 Gtk::Alignment* a_,
55 Gtk::ShadowType etching_)
56 {
57 f_->set_border_width (4);
58 f_->set_shadow_type (etching_);
59 f_->set_label_align (Gtk::ALIGN_TOP, Gtk::ALIGN_CENTER);
60 f_->set_label_widget (*l_);
61 f_->add (*a_);
62 }
63
64 static void TA_SET_ENTRY (Gtk::Entry* e_)
65 {
66 e_->set_flags (Gtk::CAN_FOCUS);
67 e_->set_visibility (true);
68 e_->set_editable (true);
69 e_->set_max_length (0);
70 e_->set_has_frame (true);
71 e_->set_width_chars (4);
72 e_->set_activates_default (false);
73 }
74
75 /**-----------------------------------------------------------------------------
76 * MyTextAlignmentsWidget
77 *
78 * The widget encapsulates text label alignment controls.
79 * It consists of the x and y alignments and paragraph justification.
80 *
81 * ---------------
82 * +---| frame_label |------------------^-------------------------+<--m_frame
83 * | --------------- | (6pts) |
84 * | +----------------------------------v------------------------+<--alignment
85 * | |+---------------------------------------------------------+||
86 * | || --------------- |<---vbox
87 * | ||+---| block_label |--------------^----------------------+|||
88 * | ||| --------------- | (6pts) |<----block_frame
89 * | |||+-------------------------------v---------------------+||||
90 * | ||||+---------+---------------+---------+---------------+|||||
91 * | ||||| x_label | x_align_combo | y_label | y_align_combo |<--text_block_hbox
92 * | ||||+---------+---------------+---------+---------------+|||||
93 * | |||+-----------------------------------------------------+<-block_alignment
94 * | ||+-------------------------------------------------------+|||
95 * | |+---------------------------------------------------------+||
96 * | +-----------------------------------------------------------+|
97 * +--------------------------------------------------------------+
98 *
99 **-----------------------------------------------------------------------------
100 */
101 MyTextAlignmentsWidget::
102 MyTextAlignmentsWidget (const char* title_,
103 value_list_t& x_align_list_,
104 value_list_t& y_align_list_,
105 value_list_t& paragraph_list_)
106 {
107 Gtk::TreeModel::Row row;
108 vlist_citer_t citer;
109
110 /*------------------------------------
111 * Front Frame
112 *------------------------------------
113 */
114 Gtk::Label* frame_label;
115 Gtk::Alignment* alignment;
116 Gtk::VBox* vbox;
117
118 /*-- Text Block --*/
119 Gtk::Frame* block_frame;
120 Gtk::Alignment* block_alignment;
121 Gtk::Label* block_label;
122
123 Gtk::HBox* text_block_hbox;
124 Gtk::Label* x_label;
125 /* m_x_align_combo; */
126 Gtk::Label* y_label;
127 /* m_y_align_combo; */
128
129 /*-- Multiline (Paragraph) Text --*/
130 Gtk::Frame* paragraph_frame;
131 Gtk::Alignment* paragraph_alignment;
132 Gtk::Label* paragraph_label;
133
134 Gtk::HBox* paragraph_hbox;
135 Gtk::Label* paragraph_label2;
136 /* m_paragraph_combo; */
137
138 /*-- Padding Block --*/
139 Gtk::Frame* padding_frame;
140 Gtk::Alignment* padding_alignment;
141 Gtk::Label* padding_label;
142
143 Gtk::HBox* padding_block_hbox;
144 Gtk::Label* x_padding_label;
145 /* m_x_padding_entry; */
146 Gtk::Label* y_padding_label;
147 /* m_y_padding_entry; */
148
149 /**************************************
150 *
151 * Front Alignment
152 *
153 **************************************/
154
155 m_frame = Gtk::manage (new Gtk::Frame());
156 frame_label = Gtk::manage (new Gtk::Label(_(title_)));
157 alignment = Gtk::manage (new Gtk::Alignment(0.5, 0.5, 1, 1));
158 vbox = Gtk::manage (new Gtk::VBox(false, 0));
159
160 /*-- Text Block --*/
161 block_frame = Gtk::manage (new Gtk::Frame());
162 block_alignment = Gtk::manage (new Gtk::Alignment(0.5, 0.5, 1, 1));
163 block_label = Gtk::manage (new Gtk::Label(_("<b>Text Block</b>")));
164
165 text_block_hbox = Gtk::manage (new Gtk::HBox(false, 0));
166
167 /** [x:] <Choice>
168 */
169 x_label = Gtk::manage (new Gtk::Label(_("x:")));
170 m_x_align_combo = Gtk::manage (new Gtk::ComboBox());
171
172 m_falign_x_tree_model = Gtk::ListStore::create (m_falign_x_col);
173 m_x_align_combo->set_model (m_falign_x_tree_model);
174
175 citer = x_align_list_.begin ();
176 while (citer != x_align_list_.end ()) {
177 row = *(m_falign_x_tree_model->append ());
178 row [m_falign_x_col.m_value] = *citer;
179 citer++;
180 }
181
182 m_x_align_combo->pack_start (m_falign_x_col.m_value);
183 m_x_align_combo->set_active (0);
184
185 /** [y:] <Choice>
186 */
187 y_label = Gtk::manage (new Gtk::Label(_("y:")));
188 m_y_align_combo = Gtk::manage (new Gtk::ComboBox());
189
190 m_falign_y_tree_model = Gtk::ListStore::create (m_falign_y_col);
191 m_y_align_combo->set_model (m_falign_y_tree_model);
192
193 citer = y_align_list_.begin ();
194 while (citer != y_align_list_.end ()) {
195 row = *(m_falign_y_tree_model->append ());
196 row [m_falign_y_col.m_value] = *citer;
197 citer++;
198 }
199
200 m_y_align_combo->pack_start (m_falign_y_col.m_value);
201 m_y_align_combo->set_active (0);
202
203 /**-- Multiline Text Block --
204 */
205 paragraph_frame = Gtk::manage (new Gtk::Frame());
206 paragraph_alignment = Gtk::manage (new Gtk::Alignment(0.5,0.5,1,1));
207 paragraph_label = Gtk::manage (new Gtk::Label(_("<b>Multiline Text</b>")));
208
209
210 /** [Justification:] <Choice>
211 */
212 paragraph_hbox = Gtk::manage (new Gtk::HBox(false, 0));
213 paragraph_label2 = Gtk::manage (new Gtk::Label(_("Justification: ")));
214 m_paragraph_combo = Gtk::manage (new Gtk::ComboBox());
215
216 m_justify_tree_model = Gtk::ListStore::create (m_justify_col);
217 m_paragraph_combo->set_model (m_justify_tree_model);
218
219 citer = paragraph_list_.begin ();
220 while (citer != paragraph_list_.end ()) {
221 row = *(m_justify_tree_model->append ());
222 row [m_justify_col.m_value] = *citer;
223 citer++;
224 }
225
226 m_paragraph_combo->pack_start (m_justify_col.m_value);
227 m_paragraph_combo->set_active (0);
228
229 /*-- Padding Block --
230 */
231 padding_frame = Gtk::manage (new Gtk::Frame());
232 padding_alignment = Gtk::manage (new Gtk::Alignment(0.5, 0.5, 1, 1));
233 padding_label = Gtk::manage (new Gtk::Label(_("<b>Text Padding</b>")));
234
235 padding_block_hbox = Gtk::manage (new Gtk::HBox(false, 0));
236
237 /** [x:] <Choice>
238 */
239 x_padding_label = Gtk::manage (new Gtk::Label(_("x:")));
240 m_x_padding_entry = Gtk::manage (new Gtk::Entry ());
241
242 /* TODO: set initial value */
243
244 /** [y:] <Choice>
245 */
246 y_padding_label = Gtk::manage (new Gtk::Label(_("y:")));
247 m_y_padding_entry = Gtk::manage (new Gtk::Entry ());
248
249 /* TODO: set initial value */
250
251 /*-- Pack Front Text Block --*/
252
253 TA_SET_LABEL(x_label,false);
254 TA_SET_LABEL(y_label,false);
255
256 text_block_hbox->pack_start (*x_label, Gtk::PACK_SHRINK, 6);
257 text_block_hbox->pack_start (*m_x_align_combo, Gtk::PACK_SHRINK, 0);
258 text_block_hbox->pack_start (*y_label, Gtk::PACK_SHRINK, 6);
259 text_block_hbox->pack_start (*m_y_align_combo, Gtk::PACK_SHRINK, 0);
260
261 block_alignment->set_border_width (6);
262 block_alignment->add (*text_block_hbox);
263
264 TA_SET_LABEL (x_padding_label,false);
265 TA_SET_LABEL (y_padding_label,false);
266
267 TA_SET_ENTRY (m_x_padding_entry);
268 TA_SET_ENTRY (m_y_padding_entry);
269
270 padding_block_hbox->pack_start (*x_padding_label, Gtk::PACK_SHRINK, 6);
271 padding_block_hbox->pack_start (*m_x_padding_entry, Gtk::PACK_SHRINK, 0);
272 padding_block_hbox->pack_start (*y_padding_label, Gtk::PACK_SHRINK, 6);
273 padding_block_hbox->pack_start (*m_y_padding_entry, Gtk::PACK_SHRINK, 0);
274
275 padding_alignment->set_border_width (6);
276 padding_alignment->add (*padding_block_hbox);
277
278 TA_SET_LABEL(block_label,true);
279 TA_SET_FRAME (block_frame,
280 block_label,
281 block_alignment,
282 Gtk::SHADOW_NONE);
283
284 TA_SET_LABEL(padding_label,true);
285 TA_SET_FRAME (padding_frame,
286 padding_label,
287 padding_alignment,
288 Gtk::SHADOW_NONE);
289
290 /*-- Pack Front Paragraph Block --*/
291
292 TA_SET_LABEL(paragraph_label2,false);
293 paragraph_hbox->set_border_width(3);
294
295 paragraph_hbox->pack_start (*paragraph_label2, Gtk::PACK_SHRINK, 0);
296 paragraph_hbox->pack_start (*m_paragraph_combo, Gtk::PACK_SHRINK, 0);
297
298 TA_SET_LABEL(paragraph_label,true);
299
300 paragraph_alignment->set_border_width(6);
301 paragraph_alignment->add (*paragraph_hbox);
302
303 TA_SET_FRAME (paragraph_frame,
304 paragraph_label,
305 paragraph_alignment,
306 Gtk::SHADOW_NONE);
307
308 /*-- Pack Front --*/
309
310 vbox->set_border_width(3);
311 vbox->pack_start (*block_frame, Gtk::PACK_SHRINK, 0);
312 vbox->pack_start (*paragraph_frame, Gtk::PACK_SHRINK, 0);
313 vbox->pack_start (*padding_frame, Gtk::PACK_SHRINK, 0);
314
315 alignment->add (*vbox);
316
317 TA_SET_LABEL(frame_label,true);
318 TA_SET_FRAME (m_frame,
319 frame_label,
320 alignment,
321 Gtk::SHADOW_ETCHED_IN);
322 }
323
0 // -*- c++ -*-
1 //------------------------------------------------------------------------------
2 // $Id: MyTextAlignmentsWidget.h,v 1.2 2006/12/18 03:33:15 vlg Exp $
3 //------------------------------------------------------------------------------
4 // MyTextAlignmentsWidget.h
5 //------------------------------------------------------------------------------
6 // Copyright (c) 2006 by Vladislav Grinchenko
7 //
8 // This program is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU General Public License
10 // as published by the Free Software Foundation; either version
11 // 2 of the License, or (at your option) any later version.
12 //------------------------------------------------------------------------------
13 //
14 // Date : Wed Nov 1 2006
15 //
16 //------------------------------------------------------------------------------
17 #ifndef MY_TEXT_ALIGNMENT_H
18 #define MY_TEXT_ALIGNMENT_H
19
20 #include <vector>
21 #include <string>
22
23 #include <gtkmm/dialog.h>
24 #include <gtkmm/frame.h>
25 #include <gtkmm/alignment.h>
26 #include <gtkmm/box.h>
27 #include <gtkmm/checkbutton.h>
28 #include <gtkmm/combobox.h>
29 #include <gtkmm/entry.h>
30 #include <gtkmm/liststore.h>
31 #include <gtkmm/treemodel.h>
32
33 class MyTextAlignmentsWidget
34 {
35 public:
36 typedef std::vector<std::string> value_list_t;
37 typedef value_list_t::iterator vlist_iter_t;
38 typedef value_list_t::const_iterator vlist_citer_t;
39
40 public:
41 MyTextAlignmentsWidget (const char* title_,
42 value_list_t& x_align_list_,
43 value_list_t& y_align_list_,
44 value_list_t& paragraph_list_);
45
46 Gtk::ComboBox* x_align_combo () { return m_x_align_combo; }
47 Gtk::ComboBox* y_align_combo () { return m_y_align_combo; }
48 Gtk::Entry* x_padding_entry () { return m_x_padding_entry; }
49 Gtk::Entry* y_padding_entry () { return m_y_padding_entry; }
50 Gtk::ComboBox* paragraph_combo () { return m_paragraph_combo; }
51
52 Gtk::Frame* frame () { return m_frame; }
53
54 private:
55 Gtk::Frame* m_frame;
56
57 Gtk::ComboBox* m_x_align_combo;
58 Gtk::ComboBox* m_y_align_combo;
59 Gtk::Entry* m_x_padding_entry;
60 Gtk::Entry* m_y_padding_entry;
61 Gtk::ComboBox* m_paragraph_combo;
62
63 private:
64 /** Alignment Enum
65 */
66 class AlignmentType_Model : public Gtk::TreeModel::ColumnRecord
67 {
68 public:
69 AlignmentType_Model () { add (m_value); }
70
71 Gtk::TreeModelColumn<Glib::ustring> m_value;
72 };
73
74 AlignmentType_Model m_falign_x_col;
75 AlignmentType_Model m_falign_y_col;
76
77 Glib::RefPtr<Gtk::ListStore> m_falign_x_tree_model;
78 Glib::RefPtr<Gtk::ListStore> m_falign_y_tree_model;
79
80 private:
81 /** Justification
82 */
83 class JustifyType_Model : public Gtk::TreeModel::ColumnRecord
84 {
85 public:
86 JustifyType_Model () { add (m_value); }
87
88 Gtk::TreeModelColumn<Glib::ustring> m_value;
89 };
90
91 JustifyType_Model m_justify_col;
92 Glib::RefPtr<Gtk::ListStore> m_justify_tree_model;
93 };
94
95
96
97 #endif /* MY_TEXT_ALIGNMENTS_H */
00 // -*- c++ -*-
11 //------------------------------------------------------------------------------
2 // $Id: PrefWindow.cpp,v 1.12 2006/09/05 03:25:29 vlg Exp $
2 // $Id: PrefWindow.cpp,v 1.13 2006/11/05 19:00:59 vlg Exp $
33 //------------------------------------------------------------------------------
44 // PrefWindow.h
55 //------------------------------------------------------------------------------
3535 #ifdef IS_HILDON
3636 set_size_request (672, -1);
3737 #else
38 set_size_request (520, 380);
38 set_size_request (580, 380);
3939 set_transient_for (dynamic_cast<Gtk::Window&>(parent_));
4040 #endif
4141
6464
6565 m_ignore_callbacks = true;
6666 m_changed = false;
67 DL ((GRAPP,"m_changed set to false\n"));
6867
6968 /** Fill values of all pages with fresh values from Config
7069 */
71 m_general_pref.load_from_config ();
70 m_general_pref. load_from_config ();
7271 m_appearance_pref.load_from_config ();
7372 m_scheduling_pref.load_from_config ();
74 m_sound_pref.load_from_config ();
75 m_geometry_pref.load_from_config ();
73 m_sound_pref. load_from_config ();
74 m_geometry_pref. load_from_config ();
7675
7776 m_ignore_callbacks = false;
7877 m_apply_button->set_sensitive (false);
78
7979 show ();
8080
8181 #ifdef IS_HILDON
8585 Gtk::Main::run ();
8686 #endif
8787
88 DL ((GRAPP,"m_changed = %s\n", (m_changed ? "true":"false")));
8988 return m_changed;
9089 }
9190
9594 {
9695 trace_with_mask("PrefWindow::apply_impl",GUITRACE);
9796
98 m_general_pref.save_to_config ();
97 m_general_pref. save_to_config ();
9998 m_appearance_pref.save_to_config ();
10099 m_scheduling_pref.save_to_config ();
101 m_sound_pref.save_to_config ();
102 m_geometry_pref.save_to_config ();
100 m_sound_pref. save_to_config ();
101 m_geometry_pref. save_to_config ();
103102 }
00 // -*- c++ -*-
11 // generated by glade--
22 //------------------------------------------------------------------------------
3 // $Id: SchedulingPrefs.cpp,v 1.7 2006/06/14 02:34:38 vlg Exp $
3 // $Id: SchedulingPrefs.cpp,v 1.8 2006/12/11 03:07:22 vlg Exp $
44 //------------------------------------------------------------------------------
55 // SchedulingPref.h
66 //------------------------------------------------------------------------------
4747 {
4848 trace_with_mask("SchedulingPref::SchedulingPrefs",GUITRACE);
4949 int i;
50
51 #if defined(IS_HILDON) || defined(IS_PDA)
52 set_border_width(0);
53 #else
54 set_border_width(14);
55 #endif
5056
5157 Gtk::Label* label_b01000 = Gtk::manage(new Gtk::Label(" weeks "));
5258 Gtk::Label* label_b02000 = Gtk::manage(new Gtk::Label(" weeks "));
209215 m_frame->set_label_align(0,0.5);
210216 m_frame->set_label_widget(*frame_label);
211217
212 #ifdef IS_HILDON
218 #if defined(IS_HILDON) || defined(IS_PDA)
213219 Gtk::ScrolledWindow* scrollw = Gtk::manage (new Gtk::ScrolledWindow);
214220 scrollw->set_flags (Gtk::CAN_FOCUS);
215221 scrollw->set_shadow_type (Gtk::SHADOW_NONE);
217223 scrollw->property_window_placement ().set_value (Gtk::CORNER_TOP_LEFT);
218224
219225 scrollw->add (*m_sched_table);
220 m_frame->add(*scrollw);
226 m_frame->add (*scrollw);
221227
222228 #else // Desktop
223 m_frame->add(*m_sched_table);
229 m_frame->add (*m_sched_table);
224230 #endif
225231
226232 for (i = 0; i < CARD_BOX_SIZE; i++) {
243249
244250 }
245251
246 set_border_width(18);
252
247253 m_frame->show_all();
248254 pack_start(*m_frame);
249255 }
00 // -*- c++ -*-
11 // generated by glade--
22 //------------------------------------------------------------------------------
3 // $Id: SoundPrefs.cpp,v 1.6 2006/06/14 02:34:38 vlg Exp $
3 // $Id: SoundPrefs.cpp,v 1.8 2006/12/11 03:07:22 vlg Exp $
44 //------------------------------------------------------------------------------
55 // SoundPref.h
66 //------------------------------------------------------------------------------
1717 //------------------------------------------------------------------------------
1818 #include <gtkmm/label.h>
1919 #include <gtkmm/stock.h>
20 #include <gtkmm/filechooserdialog.h>
2120
2221 #include "Granule-main.h"
2322 #include "GrappConf.h"
2423 #include "SoundPrefs.h"
2524 #include "PrefWindow.h"
26
25 #include "MyFolderChooseDialog.h"
26
27 // i18n macros - always last
28 #include "Intern.h"
29
30 //------------------------------------------------------------------------------
2731 SoundPrefs::
2832 SoundPrefs (PrefWindow& pwin_) :
2933 VBox(false, 0),
3135 {
3236 trace_with_mask("SoundPrefs::SoundPrefs",GUITRACE);
3337
34 m_sound_player = Gtk::manage(new Gtk::Entry());
38 Gtk::Label* snd_player_lbl;
39 Gtk::Label* snd_args_lbl;
40 Gtk::Label* snd_path_lbl;
41
42 #if defined(IS_HILDON) || defined(IS_PDA)
43 set_border_width(0);
44 #else
45 set_border_width(14);
46 #endif
47
48 m_sound_player = Gtk::manage(new Gtk::Entry());
3549
36 Gtk::Label *snd_player_lbl = Gtk::manage(new Gtk::Label("Sound Player: "));
37 Gtk::Label *snd_args_lbl = Gtk::manage(new Gtk::Label("Sound Cmd Args:"));
38 m_snd_args = Gtk::manage(new Gtk::Entry());
50 snd_player_lbl = Gtk::manage(new Gtk::Label(_("Sound Player: ")));
51 snd_args_lbl = Gtk::manage(new Gtk::Label(_("Sound Cmd Args:")));
52 m_snd_args = Gtk::manage(new Gtk::Entry());
3953
40 Gtk::Label *snd_path_lbl = Gtk::manage(new Gtk::Label("Default Sound Path"));
41 m_snd_path = Gtk::manage(new Gtk::Entry());
42 m_browse_button = Gtk::manage(new Gtk::Button("Browse ..."));
54 snd_path_lbl = Gtk::manage(new Gtk::Label(_("Default Sound Path")));
55 m_snd_path = Gtk::manage(new Gtk::Entry());
56 m_browse_button = Gtk::manage(new Gtk::Button(_("Browse ...")));
4357
4458 Gtk::HBox *snd_path_hbox = Gtk::manage(new Gtk::HBox(false, 0));
4559 m_table = Gtk::manage(new Gtk::Table(2, 2, false));
111125 m_table->attach(*snd_path_hbox, 1, 2, 2, 3,
112126 Gtk::FILL, Gtk::FILL, 0, 0);
113127
128 m_table->show_all ();
129
130 #if defined(IS_HILDON) || defined(IS_PDA)
131 Gtk::ScrolledWindow* scrollw = Gtk::manage (new Gtk::ScrolledWindow);
132 scrollw->set_flags (Gtk::CAN_FOCUS);
133 scrollw->set_shadow_type (Gtk::SHADOW_NONE);
134 scrollw->set_policy (Gtk::POLICY_AUTOMATIC , Gtk::POLICY_ALWAYS);
135 scrollw->property_window_placement ().set_value (Gtk::CORNER_TOP_LEFT);
136
137 scrollw->add (*m_table);
138 pack_start (*scrollw);
139 #else
140 pack_start (*m_table);
141 #endif
142
143 /** Set callbacks
144 */
114145 m_sound_player->signal_changed().connect (
115146 sigc::mem_fun (m_pref_window, &PrefWindow::changed_cb));
116147 m_snd_args->signal_changed().connect (
121152 m_browse_button->signal_clicked ().connect (
122153 sigc::mem_fun (*this, &SoundPrefs::on_browse_clicked));
123154
124 set_border_width(18);
125 m_table->show_all ();
126 pack_start(*m_table);
127155 }
128156
129157 void
161189 {
162190 trace_with_mask("SoundPrefs::on_browse_clicked",GUITRACE);
163191
164 Gtk::FileChooserDialog f ("Select Sound Dictionary",
165 Gtk::FILE_CHOOSER_ACTION_SELECT_FOLDER);
166 #ifndef IS_HILDON
167 f.set_transient_for (m_pref_window);
168 #endif
169 f.add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
170 f.add_button ("Select", Gtk::RESPONSE_OK);
192 MyFolderChooseDialog f (_("Select Sound Dictionary"), &m_pref_window);
171193
172194 const char* snd_path = CONFIG->get_snd_archive_path ();
173195 if (snd_path && strlen (snd_path)) {
174196 f.set_current_folder (snd_path);
175197 }
176 else {
177 f.set_current_folder (CONFIG->get_filesel_path ());
178 }
179 f.set_local_only ();
180198
181199 if (f.run () == Gtk::RESPONSE_OK) {
182200 m_snd_path->set_text (Glib::filename_from_utf8 (f.get_filename ()));
0 // -*- c++ -*-
1 //------------------------------------------------------------------------------
2 // $Id: TextAlignment.cpp,v 1.6 2006/12/18 03:33:15 vlg Exp $
3 //------------------------------------------------------------------------------
4 // TextAlignment.cpp
5 //------------------------------------------------------------------------------
6 // Copyright (c) 2006 by Vladislav Grinchenko
7 //
8 // This program is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU General Public License
10 // as published by the Free Software Foundation; either version
11 // 2 of the License, or (at your option) any later version.
12 //------------------------------------------------------------------------------
13 //
14 // Date : Wed Oct 25 20:49:21 EDT 2006
15 //
16 //------------------------------------------------------------------------------
17
18 #include "Granule-main.h"
19 #include "TextAlignment.h"
20
21 #include "Intern.h" // i18n macros
22
23 using sigc::mem_fun;
24
25 /**-----------------------------------------------------------------------------
26 * TextAlignment
27 **-----------------------------------------------------------------------------
28 */
29 TextAlignment::
30 TextAlignment (PrefWindow& grandpa_)
31 :
32 Gtk::VBox (false, 0),
33 m_pref_window (grandpa_)
34 {
35 trace_with_mask("TextAlignment::TextAlignment",GUITRACE);
36
37 m_vbox = this;
38
39 MyTextAlignmentsWidget::value_list_t align_x_list;
40 align_x_list.push_back ("center");
41 align_x_list.push_back ("left");
42 align_x_list.push_back ("right");
43
44 MyTextAlignmentsWidget::value_list_t align_y_list;
45 align_y_list.push_back ("center");
46 align_y_list.push_back ("top");
47 align_y_list.push_back ("bottom");
48
49 MyTextAlignmentsWidget::value_list_t paragraph_list;
50 paragraph_list.push_back ("center");
51 paragraph_list.push_back ("left");
52 paragraph_list.push_back ("right");
53 paragraph_list.push_back ("fill");
54
55 m_front_widget = new MyTextAlignmentsWidget ("<b>Front Text Alignment</b>",
56 align_x_list,
57 align_y_list,
58 paragraph_list);
59
60 m_back_widget = new MyTextAlignmentsWidget ("<b>Back Text Alignment</b>",
61 align_x_list,
62 align_y_list,
63 paragraph_list);
64
65 m_example_widget = new MyTextAlignmentsWidget ("<b>Example Text Alignment</b>",
66 align_x_list,
67 align_y_list,
68 paragraph_list);
69 /** Pack all together
70 */
71 m_vbox->pack_start (*(m_front_widget->frame ()), Gtk::PACK_SHRINK, 4);
72 m_vbox->pack_start (*(m_back_widget->frame ()), Gtk::PACK_SHRINK, 4);
73 m_vbox->pack_start (*(m_example_widget->frame ()), Gtk::PACK_SHRINK, 4);
74
75 /** Setup callbacks
76 */
77 /// Front
78 m_front_widget->x_align_combo ()->signal_changed ().connect (
79 mem_fun (m_pref_window, &PrefWindow::changed_cb));
80
81 m_front_widget->y_align_combo ()->signal_changed ().connect (
82 mem_fun (m_pref_window, &PrefWindow::changed_cb));
83
84 m_front_widget->x_padding_entry ()->signal_changed ().connect (
85 mem_fun (m_pref_window, &PrefWindow::changed_cb));
86
87 m_front_widget->y_padding_entry ()->signal_changed ().connect (
88 mem_fun (m_pref_window, &PrefWindow::changed_cb));
89
90 m_front_widget->paragraph_combo ()->signal_changed ().connect (
91 mem_fun (m_pref_window, &PrefWindow::changed_cb));
92
93 /// Back
94 m_back_widget->x_align_combo ()->signal_changed ().connect (
95 mem_fun (m_pref_window, &PrefWindow::changed_cb));
96
97 m_back_widget->y_align_combo ()->signal_changed ().connect (
98 mem_fun (m_pref_window, &PrefWindow::changed_cb));
99
100 m_back_widget->x_padding_entry ()->signal_changed ().connect (
101 mem_fun (m_pref_window, &PrefWindow::changed_cb));
102
103 m_back_widget->y_padding_entry ()->signal_changed ().connect (
104 mem_fun (m_pref_window, &PrefWindow::changed_cb));
105
106 m_back_widget->paragraph_combo ()->signal_changed ().connect (
107 mem_fun (m_pref_window, &PrefWindow::changed_cb));
108
109 /// Example
110 m_example_widget->x_align_combo ()->signal_changed ().connect (
111 mem_fun (m_pref_window, &PrefWindow::changed_cb));
112
113 m_example_widget->y_align_combo ()->signal_changed ().connect (
114 mem_fun (m_pref_window, &PrefWindow::changed_cb));
115
116 m_example_widget->x_padding_entry ()->signal_changed ().connect (
117 mem_fun (m_pref_window, &PrefWindow::changed_cb));
118
119 m_example_widget->y_padding_entry ()->signal_changed ().connect (
120 mem_fun (m_pref_window, &PrefWindow::changed_cb));
121
122 m_example_widget->paragraph_combo ()->signal_changed ().connect (
123 mem_fun (m_pref_window, &PrefWindow::changed_cb));
124
125 show_all_children ();
126 }
127
128 /** Set property value
129 */
130 void
131 TextAlignment::
132 set_x_alignment (SideSelection side_, const std::string& v_)
133 {
134 int value;
135
136 if (v_ == "center") { value = TA_X_ALIGN_CENTER; }
137 else if (v_ == "left") { value = TA_X_ALIGN_LEFT; }
138 else if (v_ == "right") { value = TA_X_ALIGN_RIGHT; }
139
140 if (side_ == FRONT) {
141 m_front_widget->x_align_combo ()->set_active (value);
142 }
143 else if (side_ == BACK) {
144 m_back_widget->x_align_combo ()->set_active (value);
145 }
146 else { /* side_ == EXAMPLE */
147 m_example_widget->x_align_combo ()->set_active (value);
148 }
149 }
150
151 void
152 TextAlignment::
153 set_y_alignment (SideSelection side_, const std::string& v_)
154 {
155 int value;
156
157 if (v_ == "center") { value = TA_Y_ALIGN_CENTER; }
158 else if (v_ == "top") { value = TA_Y_ALIGN_TOP; }
159 else if (v_ == "bottom") { value = TA_Y_ALIGN_BOTTOM; }
160
161 if (side_ == FRONT) {
162 m_front_widget->y_align_combo ()->set_active (value);
163 }
164 else if (side_ == BACK) {
165 m_back_widget->y_align_combo ()->set_active (value);
166 }
167 else { /* side_ == EXAMPLE */
168 m_example_widget->y_align_combo ()->set_active (value);
169 }
170 }
171
172 void
173 TextAlignment::
174 set_x_padding (SideSelection side_, const std::string& v_)
175 {
176 if (side_ == FRONT) { m_front_widget ->x_padding_entry ()->set_text (v_); }
177 else if (side_ == BACK) { m_back_widget ->x_padding_entry ()->set_text (v_); }
178 else /* == EXAMPLE */ { m_example_widget->x_padding_entry ()->set_text (v_); }
179 }
180
181 void
182 TextAlignment::
183 set_y_padding (SideSelection side_, const std::string& v_)
184 {
185 if (side_ == FRONT) { m_front_widget ->y_padding_entry ()->set_text (v_); }
186 else if (side_ == BACK) { m_back_widget ->y_padding_entry ()->set_text (v_); }
187 else /* == EXAMPLE */ { m_example_widget->y_padding_entry ()->set_text (v_); }
188 }
189
190 void
191 TextAlignment::
192 set_justification (SideSelection side_, const std::string& v_)
193 {
194 int value;
195
196 if (v_ == "center") { value = TA_JUSTIFY_CENTER; }
197 else if (v_ == "left") { value = TA_JUSTIFY_LEFT; }
198 else if (v_ == "right") { value = TA_JUSTIFY_RIGHT; }
199 else if (v_ == "fill") { value = TA_JUSTIFY_FILL; }
200
201 if (side_ == FRONT) {
202 m_front_widget->paragraph_combo ()->set_active (value);
203 }
204 else if (side_ == BACK) {
205 m_back_widget->paragraph_combo ()->set_active (value);
206 }
207 else { /* EXAMPLE */
208 m_example_widget->paragraph_combo ()->set_active (value);
209 }
210 }
211
212 /** Get property value
213 */
214 std::string
215 TextAlignment::
216 get_x_alignment (SideSelection side_) const
217 {
218 std::string result;
219 int value;
220
221 if (side_ == FRONT) {
222 value = m_front_widget->x_align_combo ()->get_active_row_number ();
223 }
224 else if (side_ == BACK) {
225 value = m_back_widget->x_align_combo ()->get_active_row_number ();
226 }
227 else { /* side_ == EXAMPLE */
228 value = m_example_widget->x_align_combo ()->get_active_row_number ();
229 }
230
231 switch (value) {
232 case TA_X_ALIGN_CENTER: result = "center"; break;
233 case TA_X_ALIGN_LEFT: result = "left"; break;
234 case TA_X_ALIGN_RIGHT: result = "right"; break;
235 default: result = "center";
236 }
237
238 return (result);
239 }
240
241
242 std::string
243 TextAlignment::
244 get_y_alignment (SideSelection side_) const
245 {
246 std::string result;
247 int value;
248
249 if (side_ == FRONT) {
250 value = m_front_widget->y_align_combo ()->get_active_row_number ();
251 }
252 else if (side_ == BACK) {
253 value = m_back_widget->y_align_combo ()->get_active_row_number ();
254 }
255 else { /* EXAMPLE */
256 value = m_example_widget->y_align_combo ()->get_active_row_number ();
257 }
258
259 switch (value) {
260 case TA_Y_ALIGN_CENTER: result = "center"; break;
261 case TA_Y_ALIGN_TOP: result = "top"; break;
262 case TA_Y_ALIGN_BOTTOM: result = "bottom"; break;
263 default: result = "center";
264 }
265
266 return (result);
267 }
268
269 std::string
270 TextAlignment::
271 get_x_padding (SideSelection side_) const
272 {
273 if (side_ == FRONT) { return m_front_widget ->x_padding_entry()->get_text();}
274 else if(side_ == BACK){ return m_back_widget ->x_padding_entry()->get_text();}
275 else /* == EXAMPLE */ { return m_example_widget->x_padding_entry()->get_text();}
276 }
277
278 std::string
279 TextAlignment::
280 get_y_padding (SideSelection side_) const
281 {
282 if (side_ == FRONT) { return m_front_widget ->y_padding_entry()->get_text();}
283 else if(side_ == BACK){ return m_back_widget ->y_padding_entry()->get_text();}
284 else /* == EXAMPLE */ { return m_example_widget->y_padding_entry()->get_text();}
285 }
286
287
288 /** Get property value
289 */
290 std::string
291 TextAlignment::
292 get_justification (SideSelection side_) const
293 {
294 std::string result;
295 int value;
296
297 if (side_ == FRONT) {
298 value = m_front_widget->paragraph_combo ()->get_active_row_number ();
299 }
300 else if (side_ == BACK) {
301 value = m_back_widget->paragraph_combo ()->get_active_row_number ();
302 }
303 else { /* side_ == EXAMPLE */
304 value = m_example_widget->paragraph_combo ()->get_active_row_number ();
305 }
306
307 switch (value) {
308 case TA_JUSTIFY_CENTER: result = "center"; break;
309 case TA_JUSTIFY_LEFT: result = "left"; break;
310 case TA_JUSTIFY_RIGHT: result = "right"; break;
311 case TA_JUSTIFY_FILL: result = "fill"; break;
312 default: result = "center";
313 }
314
315 return (result);
316 }
317
0 // -*- c++ -*-
1 //------------------------------------------------------------------------------
2 // $Id: TextAlignment.h,v 1.5 2006/12/18 03:33:15 vlg Exp $
3 //------------------------------------------------------------------------------
4 // TextAlignment.h
5 //------------------------------------------------------------------------------
6 // Copyright (c) 2006 by Vladislav Grinchenko
7 //
8 // This program is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU General Public License
10 // as published by the Free Software Foundation; either version
11 // 2 of the License, or (at your option) any later version.
12 //------------------------------------------------------------------------------
13 //
14 // Date : Wed Oct 25 20:49:21 EDT 2006
15 //
16 //------------------------------------------------------------------------------
17 #ifndef TEXT_ALIGNMENT_H
18 #define TEXT_ALIGNMENT_H
19
20 #include "PrefWindow.h"
21 #include "MyTextAlignmentsWidget.h"
22
23 class TextAlignment : public Gtk::VBox
24 {
25 public:
26 TextAlignment (PrefWindow& grandpa_);
27
28 void set_x_alignment (SideSelection side_, const std::string& v_);
29 void set_y_alignment (SideSelection side_, const std::string& v_);
30 void set_x_padding (SideSelection side_, const std::string& v_);
31 void set_y_padding (SideSelection side_, const std::string& v_);
32 void set_justification (SideSelection side_, const std::string& v_);
33
34 std::string get_x_alignment (SideSelection side_) const;
35 std::string get_y_alignment (SideSelection side_) const;
36 std::string get_x_padding (SideSelection side_) const;
37 std::string get_y_padding (SideSelection side_) const;
38 std::string get_justification (SideSelection side_) const;
39
40 private:
41 PrefWindow& m_pref_window;
42 Gtk::VBox* m_vbox; /* parent */
43
44 MyTextAlignmentsWidget* m_front_widget;
45 MyTextAlignmentsWidget* m_back_widget;
46 MyTextAlignmentsWidget* m_example_widget;
47 };
48
49 #endif /* TEXT_ALIGNMENT_H */
11 //------------------------------------------------------------------------------
22 // TopMenuBar.cpp
33 //------------------------------------------------------------------------------
4 // $Id: TopMenuBar.cpp,v 1.27 2006/09/21 01:25:20 vlg Exp $
5 //------------------------------------------------------------------------------
6 // Copyright (c) 2004 by Vladislav Grinchenko
4 // $Id: TopMenuBar.cpp,v 1.28 2006/11/14 03:33:27 vlg Exp $
5 //------------------------------------------------------------------------------
6 // Copyright (c) 2004,2006 by Vladislav Grinchenko
77 //
88 // This program is free software; you can redistribute it and/or
99 // modify it under the terms of the GNU General Public License
140140 d.push_back (MenuElem ("_Open",
141141 mem_fun (m_dm, &DeckManager::open_deck_cb)));
142142 m_deck_open = &d.back ();
143 d.push_back (MenuElem ("_Insert",
143 d.push_back (MenuElem ("_Insert from Deck",
144144 mem_fun (m_dm, &DeckManager::insert_deck_cb)));
145145 m_deck_insert = &d.back ();
146146
148148 mem_fun (m_dm, &DeckManager::import_deck_cb)));
149149 m_deck_import = &d.back ();
150150
151 d.push_back (MenuElem ("Export to CSV",
152 mem_fun (m_dm, &DeckManager::export_deck_cb)));
153 m_deck_export = &d.back ();
154
151155 d.push_back (SeparatorElem ());
152156
153157 d.push_back (MenuElem ("_Save",
161165 d.push_back (MenuElem ("Save All",
162166 mem_fun(m_dm,&DeckManager::save_all_deck_cb)));
163167 m_deck_save_all = &d.back ();
164
168
165169 d.push_back (SeparatorElem ());
166170
167171 d.push_back (MenuElem ("_Play/Edit",
342346 m_deck_open ->set_sensitive (false);
343347 m_deck_insert ->set_sensitive (true );
344348 m_deck_import ->set_sensitive (true );
349 m_deck_export ->set_sensitive (true );
345350 m_deck_save ->set_sensitive (true );
346351 m_deck_save_as ->set_sensitive (true );
347352 m_deck_save_all ->set_sensitive (false);
354359 m_deck_open ->set_sensitive (true );
355360 m_deck_insert ->set_sensitive (false);
356361 m_deck_import ->set_sensitive (false);
362 m_deck_export ->set_sensitive (false);
357363 m_deck_save ->set_sensitive (false);
358364 m_deck_save_as ->set_sensitive (false);
359365 m_deck_save_all ->set_sensitive ((num_open_decks_ > 0));
11 //------------------------------------------------------------------------------
22 // TopMenuBar.h
33 //------------------------------------------------------------------------------
4 // $Id: TopMenuBar.h,v 1.16 2006/09/07 02:34:04 vlg Exp $
4 // $Id: TopMenuBar.h,v 1.17 2006/11/14 03:33:27 vlg Exp $
55 //------------------------------------------------------------------------------
6 // Copyright (c) 2004 by Vladislav Grinchenko
6 // Copyright (c) 2004,2006 by Vladislav Grinchenko
77 //
88 // This program is free software; you can redistribute it and/or
99 // modify it under the terms of the GNU General Public License
9090 MenuItem* m_deck_open;
9191 MenuItem* m_deck_insert;
9292 MenuItem* m_deck_import;
93 MenuItem* m_deck_export;
9394 MenuItem* m_deck_save;
9495 MenuItem* m_deck_save_as;
9596 MenuItem* m_deck_save_all;
110111 m_export (NULL), m_close (NULL),
111112 m_play_in (NULL),
112113 m_deck_new (NULL), m_deck_open (NULL),
113 m_deck_insert (NULL), m_deck_import (NULL),
114 m_deck_insert (NULL), m_deck_import (NULL),
115 m_deck_export (NULL),
114116 m_deck_save (NULL), m_deck_save_as (NULL),
115117 m_deck_save_all (NULL), m_deck_play (NULL),
116118 m_deck_unselect (NULL), m_add_to_box (NULL)
11 //------------------------------------------------------------------------------
22 // VCard.h
33 //------------------------------------------------------------------------------
4 // $Id: VCard.h,v 1.7 2006/09/06 02:07:59 vlg Exp $
4 // $Id: VCard.h,v 1.8 2006/12/18 03:33:15 vlg Exp $
55 //
66 // Date: Apr 24 2004
77 //------------------------------------------------------------------------------
1616
1717 #include <assa/TimeVal.h>
1818
19 #include "Granule-main.h"
20
1921 class VCard
2022 {
2123 public:
2527 virtual void set_question (const ustring& q_) = 0;
2628 virtual void set_answer (const ustring& a_) = 0;
2729 virtual void set_example (const ustring& e_) = 0;
28 virtual void set_alt_spelling (const ustring& a_) = 0;
30 virtual void set_alt_spelling (SideSelection side_,
31 const ustring& a_) = 0;
2932
3033 virtual ustring get_question () const = 0;
3134 virtual ustring get_answer () const = 0;
3235 virtual ustring get_example () const = 0;
33 virtual ustring get_alt_spelling () const = 0;
36 virtual ustring get_alt_spelling (SideSelection side_) const = 0;
3437 virtual long get_id () const = 0;
3538
3639 void set_reversed (bool r_) { m_reversed = r_; }
11 //------------------------------------------------------------------------------
22 // VDeck.h
33 //------------------------------------------------------------------------------
4 // $Id: VDeck.h,v 1.8 2006/08/30 12:22:36 vlg Exp $
4 // $Id: VDeck.h,v 1.9 2006/12/18 03:33:15 vlg Exp $
55 //
66 // Copyright (c) 2004,2006 by Vladislav Grinchenko
77 //
5959 virtual void erase (cardlist_iterator iter_) = 0;
6060 virtual bool erase (VCard* card_) = 0;
6161
62 virtual void play_card (VDeck::cardlist_iterator& iter_) = 0;
62 virtual void play_card (SideSelection side_,
63 VDeck::cardlist_iterator& iter_) = 0;
6364
6465 virtual const string& get_name (void) const = 0;
6566 virtual int get_index () const { return -1; }