granule 1.2.4
Eric Dorland
17 years ago
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 | ||
0 | 32 | 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) | |
2 | 34 | - Fixed multi-row selection in DeckView bug (when adding new cards). |
3 | 35 | - Make Front and Back fields in CardView high enough to fit two |
4 | 36 | complete rows of data. |
8 | 40 | - [maemo 2.0] Fixed application exit by closing window [x]. |
9 | 41 | |
10 | 42 | 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) | |
12 | 44 | - Port to Maemo 2.0 (Nokia770 IT2006). |
13 | 45 | - Port to libassa-3.4.2 (mingw32 networking code support). |
14 | 46 | - Memory management fix for gcc-4.0. |
23 | 55 | - Fixed crash when deleting the last card in DeckView (Bug #1554481). |
24 | 56 | |
25 | 57 | 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) | |
27 | 59 | - Native port to Hildon/ARM (nokia770 internet tablet). |
28 | 60 | - Add 'Paste' button to CardView dialog. |
29 | 61 | - Disable assa event handler. |
36 | 68 | - Add "Input font" configuration option to Preferences dialog. |
37 | 69 | |
38 | 70 | 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) | |
40 | 72 | - Fix CardFile Save option greyed out bug (bug #1261317). |
41 | 73 | - Add an option to disable keyboard shortcuts in DeckPlayer. |
42 | 74 | - Add hours/minutes scheduling resolution (rfe #1256643). |
47 | 79 | - Make CardView input dialog fully tabular. |
48 | 80 | - Add Pango markup shortcut controls to CardView dialog. |
49 | 81 | - Add Japanese translation by Jeff Ames |
50 | (jeffames-AT-users-DOT-sourceforge-DOT-net) | |
82 | (jeffames[AT]users.sourceforge.net) | |
51 | 83 | - Catch illegal pango markup and give the user a chance to fix it. |
52 | 84 | - Get rid of libxml++ dependency (uses basic libxml2 instead). |
53 | 85 | - Port to libassa-3.4.x. |
54 | 86 | - Port to cygwin32. |
55 | 87 | - Port to x86_ia64 - Konstantin Riabitsev |
56 | (graf25-AT-users-DOT-sourceforge-DOT-net) | |
88 | (graf25[AT]users.sourceforge.net) | |
57 | 89 | |
58 | 90 | 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) | |
60 | 92 | - Fix markup of multiple tildas in the Example field. |
61 | 93 | - Add colored comparison match feedback in DeckPlayer dialog. |
62 | 94 | - Location-independent DTD paths (taken from a port of granule |
76 | 108 | - Removed 'u' hot key. |
77 | 109 | |
78 | 110 | 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) | |
80 | 112 | - Full i18n support. |
81 | 113 | - Update DeckPlayer's confirmation icons. |
82 | 114 | - Add input verification control to DeckPlayer (rfe #1101697). |
103 | 135 | data members in CardBox c'tor. |
104 | 136 | |
105 | 137 | 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) | |
107 | 139 | - Fix core dumps on exit from libsigc-2.0 (bug #1068433). |
108 | 140 | - Add 'commit' option to shuffling the cards in a Deck. |
109 | 141 | When 'Shuffle' button is pressed, the user is asked if she wants |
112 | 144 | partition (for the duration of a session). |
113 | 145 | |
114 | 146 | 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) | |
116 | 148 | - Fixes moving cards up and down in the list in the DeckView dialog. |
117 | 149 | - Fixes viewing and deletion of the cards from sorted list |
118 | 150 | in DeckView (bugs #1057777 and #105775). |
131 | 163 | latter is empty (bug #1047324). |
132 | 164 | |
133 | 165 | 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) | |
135 | 167 | - Adds markup language for all text fields (bug #1022746). |
136 | 168 | - Fixes misleading error message when loading invalid Deck |
137 | 169 | file (bug #1022748). |
141 | 173 | - Fixes sound playback bug (sound wouldn't play). |
142 | 174 | |
143 | 175 | 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) | |
145 | 177 | - Fixes libxml++ dependency. Now we check for libxml++-2.6 |
146 | 178 | which covers both versions 2.6 and 2.7 of libxml++ (bug #976948). |
147 | 179 | |
148 | 180 | 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) | |
150 | 182 | - Port to gtkmm2-2.4.x |
151 | 183 | - DeckPlayer toolbar changes to UIManager/Action paradigm. |
152 | 184 | - Properly registers SayIt application icon with IconFactory. |
158 | 190 | - Adds right-click menu for a entry in a DeckList. |
159 | 191 | |
160 | 192 | 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) | |
162 | 194 | - Fixes scheduling count/lights. |
163 | 195 | - Fixes duplicate Decks in DeckList. |
164 | 196 | - Adds DeckView activation of a Deck from DeckList in the |
166 | 198 | - Sets expiration date for CardBox 1 to 4 days in default config file. |
167 | 199 | |
168 | 200 | 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) | |
170 | 202 | - Fixes tar.gz/rpm build from a wrong CVS tree. |
171 | 203 | - Changes XML DTD file location from $prefix/share/granule/xml |
172 | 204 | to /etc/xml/granule. This way no matter how package is built, |
181 | 213 | are expired. |
182 | 214 | |
183 | 215 | 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) | |
185 | 217 | - initial release. |
50 | 50 | bootstrap.debian \ |
51 | 51 | bootstrap.hildon \ |
52 | 52 | bootstrap.win32 \ |
53 | bootstrap.pda \ | |
53 | 54 | $(icon_DATA) \ |
54 | 55 | $(xml_DATA) \ |
55 | 56 | README-win32.txt \ |
56 | 57 | intltool-extract.in \ |
57 | 58 | intltool-merge.in \ |
58 | 59 | 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 \ | |
64 | 65 | debian/granule.install \ |
65 | debian/granule.xpm \ | |
66 | debian/menu \ | |
67 | debian/rules \ | |
66 | debian/granule.xpm \ | |
67 | debian/menu \ | |
68 | debian/rules \ | |
68 | 69 | debian.hildon/changelog \ |
69 | 70 | debian.hildon/compat \ |
70 | 71 | debian.hildon/control \ |
198 | 198 | USE_HILDON_FALSE = @USE_HILDON_FALSE@ |
199 | 199 | USE_HILDON_TRUE = @USE_HILDON_TRUE@ |
200 | 200 | USE_NLS = @USE_NLS@ |
201 | USE_PDA_FALSE = @USE_PDA_FALSE@ | |
202 | USE_PDA_TRUE = @USE_PDA_TRUE@ | |
201 | 203 | VERSION = @VERSION@ |
202 | 204 | WIN32_EXTRA_LIBADD = @WIN32_EXTRA_LIBADD@ |
203 | 205 | XGETTEXT = @XGETTEXT@ |
289 | 291 | bootstrap.debian \ |
290 | 292 | bootstrap.hildon \ |
291 | 293 | bootstrap.win32 \ |
294 | bootstrap.pda \ | |
292 | 295 | $(icon_DATA) \ |
293 | 296 | $(xml_DATA) \ |
294 | 297 | README-win32.txt \ |
295 | 298 | intltool-extract.in \ |
296 | 299 | intltool-merge.in \ |
297 | 300 | 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 \ | |
303 | 306 | debian/granule.install \ |
304 | debian/granule.xpm \ | |
305 | debian/menu \ | |
306 | debian/rules \ | |
307 | debian/granule.xpm \ | |
308 | debian/menu \ | |
309 | debian/rules \ | |
307 | 310 | debian.hildon/changelog \ |
308 | 311 | debian.hildon/compat \ |
309 | 312 | 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" |
308 | 308 | # include <unistd.h> |
309 | 309 | #endif" |
310 | 310 | |
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' | |
312 | 312 | ac_subst_files='' |
313 | 313 | |
314 | 314 | # Initialize some variables set by options. |
918 | 918 | --enable-dependency-tracking do not reject slow dependency extractors |
919 | 919 | --enable-mingw32 Compile with mingw32 |
920 | 920 | --enable-hildon Compile with hildon support |
921 | --enable-pda Compile with OpenEmbedded PDA support | |
921 | 922 | |
922 | 923 | Some influential environment variables: |
923 | 924 | CC C compiler command |
1391 | 1392 | |
1392 | 1393 | APP_MAJOR_VERSION=1 |
1393 | 1394 | APP_MINOR_VERSION=2 |
1394 | APP_MICRO_VERSION=3 | |
1395 | APP_MICRO_VERSION=4 | |
1395 | 1396 | |
1396 | 1397 | APP_VERSION=$APP_MAJOR_VERSION.$APP_MINOR_VERSION.$APP_MICRO_VERSION |
1397 | 1398 | APP_SUBVERSION=$APP_MAJOR_VERSION.$APP_MINOR_VERSION |
7357 | 7358 | pkg_cv_XMLCPP_CFLAGS="$XMLCPP_CFLAGS" |
7358 | 7359 | else |
7359 | 7360 | 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 | |
7362 | 7363 | ac_status=$? |
7363 | 7364 | echo "$as_me:$LINENO: \$? = $ac_status" >&5 |
7364 | 7365 | (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` | |
7366 | 7367 | else |
7367 | 7368 | pkg_failed=yes |
7368 | 7369 | fi |
7375 | 7376 | pkg_cv_XMLCPP_LIBS="$XMLCPP_LIBS" |
7376 | 7377 | else |
7377 | 7378 | 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 | |
7380 | 7381 | ac_status=$? |
7381 | 7382 | echo "$as_me:$LINENO: \$? = $ac_status" >&5 |
7382 | 7383 | (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` | |
7384 | 7385 | else |
7385 | 7386 | pkg_failed=yes |
7386 | 7387 | fi |
7399 | 7400 | _pkg_short_errors_supported=no |
7400 | 7401 | fi |
7401 | 7402 | 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"` | |
7403 | 7404 | 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"` | |
7405 | 7406 | fi |
7406 | 7407 | # Put the nasty error message in config.log where it belongs |
7407 | 7408 | echo "$XMLCPP_PKG_ERRORS" >&5 |
7408 | 7409 | |
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: | |
7410 | 7411 | |
7411 | 7412 | $XMLCPP_PKG_ERRORS |
7412 | 7413 | |
7417 | 7418 | and XMLCPP_LIBS to avoid the need to call pkg-config. |
7418 | 7419 | See the pkg-config man page for more details. |
7419 | 7420 | " >&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: | |
7421 | 7422 | |
7422 | 7423 | $XMLCPP_PKG_ERRORS |
7423 | 7424 | |
8745 | 8746 | |
8746 | 8747 | |
8747 | 8748 | |
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 | ||
8748 | 8772 | |
8749 | 8773 | |
8750 | 8774 | |
8756 | 8780 | |
8757 | 8781 | |
8758 | 8782 | |
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 | |
8761 | 8786 | |
8762 | 8787 | |
8763 | 8788 | |
8910 | 8935 | { { echo "$as_me:$LINENO: error: conditional \"USE_HILDON\" was never defined. |
8911 | 8936 | Usually this means the macro was only invoked conditionally." >&5 |
8912 | 8937 | 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. | |
8913 | 8945 | Usually this means the macro was only invoked conditionally." >&2;} |
8914 | 8946 | { (exit 1); exit 1; }; } |
8915 | 8947 | fi |
9586 | 9618 | s,@icon_40x40dir@,$icon_40x40dir,;t t |
9587 | 9619 | s,@icon_50x50dir@,$icon_50x50dir,;t t |
9588 | 9620 | 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 | |
9589 | 9623 | s,@runtime_root@,$runtime_root,;t t |
9590 | 9624 | s,@runtime_datadir@,$runtime_datadir,;t t |
9591 | 9625 | s,@runtime_xmldir@,$runtime_xmldir,;t t |
0 | 0 | dnl ---------------------------------------------------------------------------- |
1 | 1 | dnl configure.in |
2 | 2 | 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 $ | |
4 | 4 | dnl ---------------------------------------------------------------------------- |
5 | 5 | |
6 | 6 | dnl Process this file with autoconf to produce a configure script. |
21 | 21 | |
22 | 22 | APP_MAJOR_VERSION=1 |
23 | 23 | APP_MINOR_VERSION=2 |
24 | APP_MICRO_VERSION=3 | |
24 | APP_MICRO_VERSION=4 | |
25 | 25 | |
26 | 26 | APP_VERSION=$APP_MAJOR_VERSION.$APP_MINOR_VERSION.$APP_MICRO_VERSION |
27 | 27 | APP_SUBVERSION=$APP_MAJOR_VERSION.$APP_MINOR_VERSION |
97 | 97 | dnl Replace with the current version number |
98 | 98 | dnl ---------------------------------------------------------------------------- |
99 | 99 | |
100 | PKG_CHECK_MODULES(XMLCPP, libxml-2.0 >= 2.6.11) | |
100 | PKG_CHECK_MODULES(XMLCPP, libxml-2.0 >= 2.6.10) | |
101 | 101 | AC_SUBST(XMLCPP_CFLAGS) |
102 | 102 | AC_SUBST(XMLCPP_LIBS) |
103 | 103 | |
181 | 181 | runtime_root=$prefix |
182 | 182 | fi |
183 | 183 | ]) |
184 | ||
184 | ||
185 | 185 | AM_CONDITIONAL(USE_HILDON, $hildon) |
186 | 186 | |
187 | 187 | if test "$hildon" = true ; then |
221 | 221 | AC_SUBST(icon_50x50dir) |
222 | 222 | AC_SUBST(icon_scalabledir) |
223 | 223 | |
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 | ||
224 | 238 | dnl----------------------------------------------------------------------------- |
225 | 239 | dnl runtime_{}dir is where the executable looks for the data files at runtime. |
226 | 240 | dnl pkg_{}dir is where the data files are installed. |
238 | 252 | |
239 | 253 | dnl Points to where data files are installed, relative to --prefix=PATH |
240 | 254 | |
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 | |
243 | 262 | |
244 | 263 | AC_SUBST(pkg_datadir) |
245 | 264 | 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 | ||
0 | 6 | granule (1.2.3-1) unstable; urgency=medium |
1 | 7 | |
2 | 8 | * 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 | ||
0 | 32 | granule (1.2.3-1) stable; urgency=low |
1 | 33 | |
2 | 34 | * Fixed multi-row selection in DeckView bug (when adding new cards). |
8 | 8 | |
9 | 9 | [Default] |
10 | 10 | 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 | |
15 | 31 | mainwin_geometry=361x411 |
16 | 32 | cardview_geometry=396x543 |
17 | 33 | deckplayer_geometry=343x571 |
22 | 38 | snd_archive_path=/usr/share/WyabdcRealPeopleTTS/ |
23 | 39 | with_relative_paths=true |
24 | 40 | history_size=5 |
25 | root_x=521 | |
26 | root_y=164 | |
41 | root_x=91 | |
42 | root_y=30 | |
27 | 43 | disable_key_shortcuts=false |
44 | auto_pronounce=true | |
28 | 45 | |
29 | 46 | [Scheduling] |
30 | 47 | 1=1/0/0/0 |
0 | 0 | <?xml version="1.0" encoding="UTF-8"?> |
1 | 1 | |
2 | <!ELEMENT deck ((author, description, sound_path), (card)*)> | |
2 | <!ELEMENT deck ((author, description, sound_path, appearance*), (card)*)> | |
3 | 3 | <!ELEMENT author (#PCDATA)> |
4 | 4 | <!ELEMENT description (#PCDATA)> |
5 | 5 | <!ELEMENT sound_path (#PCDATA)> |
6 | 6 | |
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 | ||
7 | 41 | <!ELEMENT card (front, back, back_example)> |
8 | 42 | <!ATTLIST card |
9 | id CDATA #REQUIRED | |
10 | > | |
11 | <!ELEMENT front (#PCDATA)> | |
43 | id CDATA #REQUIRED> | |
44 | ||
45 | <!ELEMENT front (#PCDATA)> | |
12 | 46 | <!ATTLIST front |
13 | 47 | alt_spelling CDATA #IMPLIED> |
14 | <!ELEMENT back (#PCDATA)> | |
48 | ||
49 | <!ELEMENT back (#PCDATA)> | |
50 | <!ATTLIST back | |
51 | alt_spelling CDATA #IMPLIED> | |
52 | ||
15 | 53 | <!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 | |
10 | 12 | |
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 | |
34 | 20 | |
35 | 21 | %description |
36 | 22 | granule is a flashcard program that implements Leither cardfile |
37 | 23 | methodology for learing new words. It features both short-term and |
38 | 24 | long-term memory training capabilities with scheduling. |
39 | 25 | |
40 | #=============================================================================== | |
41 | # preparation section | |
42 | #=============================================================================== | |
43 | 26 | |
44 | 27 | %prep |
45 | %setup | |
28 | %setup -q | |
46 | 29 | |
47 | #=============================================================================== | |
48 | # build section | |
49 | #=============================================================================== | |
50 | 30 | |
51 | 31 | %build |
52 | ||
53 | 32 | glib-gettextize --copy --force |
54 | 33 | intltoolize --automake --copy --force |
34 | %configure | |
35 | make %{?_smp_mflags} | |
55 | 36 | |
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 | #=============================================================================== | |
66 | 37 | |
67 | 38 | %install |
68 | if [ -d $RPM_BUILD_ROOT ]; then rm -rf $RPM_BUILD_ROOT; fi | |
39 | rm -rf $RPM_BUILD_ROOT | |
69 | 40 | make DESTDIR=$RPM_BUILD_ROOT install |
70 | ||
71 | 41 | %find_lang %{name} --with-gnome |
72 | 42 | |
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 | ||
76 | 55 | |
77 | 56 | %clean |
78 | rm -rf $RPM_BUILD_ROOT | |
57 | %{__rm} -rf ${RPM_BUILD_ROOT} | |
79 | 58 | |
80 | #=============================================================================== | |
81 | # files that go into libassa package | |
82 | #=============================================================================== | |
83 | 59 | |
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}/ | |
86 | 67 | |
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 | #=============================================================================== | |
98 | 68 | |
99 | 69 | %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 | ||
100 | 76 | * Sun Nov 6 2005 Vladislav Grinchenko <vlg@users.sourceforge.net> |
101 | 77 | - Fixed License tag |
102 | 78 |
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 | |
10 | 12 | |
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 | |
34 | 20 | |
35 | 21 | %description |
36 | @PACKAGE@ is a flashcard program that implements Leither cardfile | |
22 | granule is a flashcard program that implements Leither cardfile | |
37 | 23 | methodology for learing new words. It features both short-term and |
38 | 24 | long-term memory training capabilities with scheduling. |
39 | 25 | |
40 | #=============================================================================== | |
41 | # preparation section | |
42 | #=============================================================================== | |
43 | 26 | |
44 | 27 | %prep |
45 | %setup | |
28 | %setup -q | |
46 | 29 | |
47 | #=============================================================================== | |
48 | # build section | |
49 | #=============================================================================== | |
50 | 30 | |
51 | 31 | %build |
52 | ||
53 | 32 | glib-gettextize --copy --force |
54 | 33 | intltoolize --automake --copy --force |
34 | %configure | |
35 | make %{?_smp_mflags} | |
55 | 36 | |
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 | #=============================================================================== | |
66 | 37 | |
67 | 38 | %install |
68 | if [ -d $RPM_BUILD_ROOT ]; then rm -rf $RPM_BUILD_ROOT; fi | |
39 | rm -rf $RPM_BUILD_ROOT | |
69 | 40 | make DESTDIR=$RPM_BUILD_ROOT install |
70 | ||
71 | 41 | %find_lang %{name} --with-gnome |
72 | 42 | |
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 | ||
76 | 55 | |
77 | 56 | %clean |
78 | rm -rf $RPM_BUILD_ROOT | |
57 | %{__rm} -rf ${RPM_BUILD_ROOT} | |
79 | 58 | |
80 | #=============================================================================== | |
81 | # files that go into libassa package | |
82 | #=============================================================================== | |
83 | 59 | |
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}/ | |
86 | 67 | |
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 | #=============================================================================== | |
98 | 68 | |
99 | 69 | %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 | ||
100 | 76 | * Sun Nov 6 2005 Vladislav Grinchenko <vlg@users.sourceforge.net> |
101 | 77 | - Fixed License tag |
102 | 78 |
177 | 177 | USE_HILDON_FALSE = @USE_HILDON_FALSE@ |
178 | 178 | USE_HILDON_TRUE = @USE_HILDON_TRUE@ |
179 | 179 | USE_NLS = @USE_NLS@ |
180 | USE_PDA_FALSE = @USE_PDA_FALSE@ | |
181 | USE_PDA_TRUE = @USE_PDA_TRUE@ | |
180 | 182 | VERSION = @VERSION@ |
181 | 183 | WIN32_EXTRA_LIBADD = @WIN32_EXTRA_LIBADD@ |
182 | 184 | 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 $ | |
1 | 1 | # |
2 | 2 | # src/pixmaps/Makefile.am |
3 | 3 | # |
18 | 18 | sched_red.png \ |
19 | 19 | sched_yellow.png \ |
20 | 20 | speaker_24.png \ |
21 | text_addindex.png \ | |
21 | 22 | text_big.png \ |
22 | 23 | text_block.png \ |
23 | 24 | text_bold.png \ |
29 | 30 | text_italic.png \ |
30 | 31 | text_left.png \ |
31 | 32 | text_monospaced.png \ |
33 | text_normalize.png \ | |
32 | 34 | text_paste.png \ |
33 | 35 | text_remove_tags.png \ |
34 | 36 | text_right.png \ |
37 | 39 | text_superscript.png \ |
38 | 40 | text_underlined.png \ |
39 | 41 | thumbdown.png \ |
40 | thumbup.png | |
42 | thumbup.png \ | |
43 | show_control.png \ | |
44 | hide_control.png | |
41 | 45 | |
42 | 46 | |
43 | 47 | EXTRA_DIST = $(pixmap_DATA) |
13 | 13 | |
14 | 14 | @SET_MAKE@ |
15 | 15 | |
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 $ | |
17 | 17 | # |
18 | 18 | # src/pixmaps/Makefile.am |
19 | 19 | # |
166 | 166 | USE_HILDON_FALSE = @USE_HILDON_FALSE@ |
167 | 167 | USE_HILDON_TRUE = @USE_HILDON_TRUE@ |
168 | 168 | USE_NLS = @USE_NLS@ |
169 | USE_PDA_FALSE = @USE_PDA_FALSE@ | |
170 | USE_PDA_TRUE = @USE_PDA_TRUE@ | |
169 | 171 | VERSION = @VERSION@ |
170 | 172 | WIN32_EXTRA_LIBADD = @WIN32_EXTRA_LIBADD@ |
171 | 173 | XGETTEXT = @XGETTEXT@ |
239 | 241 | sched_red.png \ |
240 | 242 | sched_yellow.png \ |
241 | 243 | speaker_24.png \ |
244 | text_addindex.png \ | |
242 | 245 | text_big.png \ |
243 | 246 | text_block.png \ |
244 | 247 | text_bold.png \ |
250 | 253 | text_italic.png \ |
251 | 254 | text_left.png \ |
252 | 255 | text_monospaced.png \ |
256 | text_normalize.png \ | |
253 | 257 | text_paste.png \ |
254 | 258 | text_remove_tags.png \ |
255 | 259 | text_right.png \ |
258 | 262 | text_superscript.png \ |
259 | 263 | text_underlined.png \ |
260 | 264 | thumbdown.png \ |
261 | thumbup.png | |
265 | thumbup.png \ | |
266 | show_control.png \ | |
267 | hide_control.png | |
262 | 268 | |
263 | 269 | EXTRA_DIST = $(pixmap_DATA) |
264 | 270 | all: all-am |
Binary diff not shown
Binary diff not shown
Binary diff not shown
Binary diff not shown
0 | 0 | // -*- c++ -*- |
1 | 1 | // generated by glade-- |
2 | 2 | //------------------------------------------------------------------------------ |
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 $ | |
4 | 4 | //------------------------------------------------------------------------------ |
5 | 5 | // AboutGRAPP.cpp |
6 | 6 | //------------------------------------------------------------------------------ |
19 | 19 | #include <gtkmm/image.h> |
20 | 20 | #include <gtkmm/label.h> |
21 | 21 | #include <gtkmm/alignment.h> |
22 | #include <gtkmm/scrolledwindow.h> | |
22 | 23 | |
23 | 24 | #ifdef HAVE_CONFIG_H |
24 | 25 | # include "config.h" |
25 | 26 | #endif |
26 | 27 | |
27 | 28 | #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 | |
28 | 35 | |
29 | 36 | AboutGRAPP:: |
30 | 37 | AboutGRAPP () : |
38 | 45 | |
39 | 46 | Gtk::Label* label; |
40 | 47 | |
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; | |
44 | 49 | |
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)); | |
46 | 54 | align->add (*contents); |
47 | 55 | |
48 | 56 | /** HBox holds Icon image and package name |
63 | 71 | /** Label is the rest of it |
64 | 72 | */ |
65 | 73 | 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"; | |
67 | 75 | label = manage (new Gtk::Label (info_msg)); |
68 | 76 | |
69 | 77 | contents->pack_start (*label); |
78 | 86 | close_b->signal_clicked ().connect ( |
79 | 87 | sigc::mem_fun (*this, &AboutGRAPP::on_close_clicked)); |
80 | 88 | |
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 | ||
81 | 116 | show_all_children (); |
82 | 117 | } |
83 | 118 |
0 | 0 | // -*- c++ -*- |
1 | 1 | // generated by glade-- |
2 | 2 | //------------------------------------------------------------------------------ |
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 $ | |
4 | 4 | //------------------------------------------------------------------------------ |
5 | 5 | // AppearancePrefs.cpp |
6 | 6 | //------------------------------------------------------------------------------ |
25 | 25 | #include "GrappConf.h" |
26 | 26 | #include "PrefWindow.h" |
27 | 27 | #include "AppearancePrefs.h" |
28 | #include "TextAlignment.h" | |
28 | 29 | |
29 | 30 | #include "Intern.h" // i18n macros |
30 | 31 | |
31 | 32 | using sigc::mem_fun; |
32 | 33 | using sigc::bind; |
33 | 34 | |
35 | //------------------------------------------------------------------------------ | |
34 | 36 | static const char* flabels[] = { |
35 | 37 | _("Question font: "), |
36 | 38 | _("Answer font: "), |
42 | 44 | enum { QFONT, AFONT, EFONT, IFONT, PFONT }; |
43 | 45 | |
44 | 46 | #define SET_FONTS_FRAME(f,l,w) \ |
47 | f->set_border_width (4); \ | |
45 | 48 | f->set_shadow_type (Gtk::SHADOW_ETCHED_IN); \ |
46 | f->set_border_width (4); \ | |
47 | 49 | f->set_label_align (Gtk::ALIGN_TOP, Gtk::ALIGN_CENTER); \ |
48 | 50 | f->set_label_widget (*l); \ |
49 | f->add (*w); | |
51 | f->add (*w); | |
50 | 52 | |
51 | 53 | #define SET_FONTS_LABEL(l) \ |
52 | 54 | l->set_padding (0,0); \ |
67 | 69 | trace_with_mask("AppearancePrefs::AppearancePrefs",GUITRACE); |
68 | 70 | |
69 | 71 | int i; |
72 | ||
73 | #if defined(IS_HILDON) || defined(IS_PDA) | |
74 | set_border_width(0); | |
75 | #else | |
70 | 76 | set_border_width(14); |
77 | #endif | |
71 | 78 | |
72 | 79 | m_font_table = Gtk::manage (new Gtk::Table (FONT_ENTRY_SZ, 3, false)); |
73 | 80 | |
132 | 139 | SET_FONTS_FRAME (fonts_frame, fonts_label, m_font_table); |
133 | 140 | |
134 | 141 | 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 | */ | |
135 | 151 | scrollw->add (*scrollw_vbox); |
136 | 152 | pack_start (*scrollw); |
137 | 153 | |
166 | 182 | m_fentry [EFONT].m_entry->set_text(CONFIG->get_example_font ().to_string()); |
167 | 183 | m_fentry [IFONT].m_entry->set_text(CONFIG->get_input_font ().to_string()); |
168 | 184 | 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)); | |
169 | 203 | } |
170 | 204 | |
171 | 205 | void |
179 | 213 | CONFIG->set_example_font (m_fentry [EFONT].m_entry->get_text ()); |
180 | 214 | CONFIG->set_input_font (m_fentry [IFONT].m_entry->get_text ()); |
181 | 215 | 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)); | |
182 | 234 | } |
183 | 235 | |
184 | 236 | void |
0 | 0 | // -*- c++ -*- |
1 | 1 | //------------------------------------------------------------------------------ |
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 $ | |
3 | 3 | //------------------------------------------------------------------------------ |
4 | 4 | // AppearancePrefs.h |
5 | 5 | //------------------------------------------------------------------------------ |
27 | 27 | #include <gtkmm/fontselection.h> |
28 | 28 | |
29 | 29 | class PrefWindow; |
30 | class TextAlignment; | |
30 | 31 | |
31 | 32 | /**----------------------------------------------------------------------------- |
32 | 33 | Compound Font Entry |
65 | 66 | |
66 | 67 | FontEntry m_fentry [FONT_ENTRY_SZ]; |
67 | 68 | Gtk::Table* m_font_table; |
69 | ||
70 | TextAlignment* m_text_alignment; | |
68 | 71 | }; |
69 | 72 | |
70 | 73 | /**----------------------------------------------------------------------------- |
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 |
1 | 1 | //------------------------------------------------------------------------------ |
2 | 2 | // CSVImportDialog.cpp |
3 | 3 | //------------------------------------------------------------------------------ |
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 | |
7 | 7 | // |
8 | 8 | // This program is free software; you can redistribute it and/or |
9 | 9 | // modify it under the terms of the GNU General Public License |
1 | 1 | //------------------------------------------------------------------------------ |
2 | 2 | // Card.h |
3 | 3 | //------------------------------------------------------------------------------ |
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 $ | |
5 | 5 | // |
6 | 6 | // Date: Jan 8, 2004 |
7 | 7 | //------------------------------------------------------------------------------ |
19 | 19 | virtual void set_question (const ustring& q_); |
20 | 20 | virtual void set_answer (const ustring& a_); |
21 | 21 | 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_); | |
23 | 23 | |
24 | 24 | void set_id (long id_); |
25 | 25 | |
26 | 26 | virtual ustring get_question () const { return m_question; } |
27 | 27 | virtual ustring get_answer () const { return m_answer; } |
28 | 28 | 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; | |
30 | 30 | virtual long get_id () const { return m_id; } |
31 | 31 | |
32 | 32 | virtual void dump () const; |
36 | 36 | virtual bool equal_expiration (const VCard& rhs_) { return true; } |
37 | 37 | |
38 | 38 | 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; | |
44 | 45 | }; |
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 | } | |
45 | 85 | |
46 | 86 | inline void |
47 | 87 | Card::set_question (const ustring& q_) |
65 | 105 | } |
66 | 106 | |
67 | 107 | inline void |
68 | Card::set_alt_spelling (const ustring& a_) | |
69 | { | |
70 | m_alt_spelling = a_; | |
71 | mark_dirty (); | |
72 | } | |
73 | ||
74 | inline void | |
75 | 108 | Card::set_id (long id_) |
76 | 109 | { |
77 | 110 | m_id = id_; |
0 | 0 | // -*- c++ -*- |
1 | 1 | //------------------------------------------------------------------------------ |
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 $ | |
3 | 3 | //------------------------------------------------------------------------------ |
4 | 4 | // CardBox.cpp |
5 | 5 | //------------------------------------------------------------------------------ |
240 | 240 | * CardBox class methods |
241 | 241 | *------------------------------------------------------------------------------ |
242 | 242 | */ |
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 | ||
243 | 249 | CardBox:: |
244 | 250 | CardBox () |
245 | 251 | { |
252 | 258 | m_cdplayers [i] = NULL; |
253 | 259 | } |
254 | 260 | |
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); | |
267 | 267 | |
268 | 268 | m_sched_green = |
269 | 269 | Gdk::Pixbuf::create_from_file(find_pixmap_path ("sched_green.png")); |
274 | 274 | m_sched_yellow = |
275 | 275 | Gdk::Pixbuf::create_from_file(find_pixmap_path ("sched_yellow.png")); |
276 | 276 | |
277 | DL ((GRAPP,"last icon ok\n")); | |
278 | ||
279 | 277 | for (i = 0; i < CARD_BOX_SIZE; i++) { |
280 | 278 | m_cbs.push_back (CardBoxIF ()); |
281 | 279 | m_cbs [i].m_sched_light = manage (new Gtk::Image); |
308 | 306 | m_cbs [i].m_total_count->set_padding (8,0); |
309 | 307 | m_cbs [i].m_total_count->set_justify (Gtk::JUSTIFY_RIGHT); |
310 | 308 | 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 | |
311 | 312 | m_cbs [i].m_total_count->set_text (_("0 cards")); |
313 | #endif | |
312 | 314 | } |
313 | 315 | |
314 | 316 | Gtk::Table* cbt = manage (new Gtk::Table (5, 3, false)); |
358 | 360 | update_count (int idx_) |
359 | 361 | { |
360 | 362 | std::ostringstream os; |
361 | ||
363 | ||
364 | #ifdef IS_PDA | |
365 | os << m_card_deck [idx_].size (); | |
366 | #else | |
362 | 367 | os << m_card_deck [idx_].size () << " cards"; |
368 | #endif | |
369 | ||
363 | 370 | m_cbs [idx_].m_total_count->set_text (os.str ()); |
364 | ||
365 | 371 | m_cbs [idx_].m_box_pic->clear (); |
372 | ||
366 | 373 | if (m_card_deck [idx_].size () == 0) { |
367 | 374 | m_cbs [idx_].m_box_pic->set (m_drawer_empty); |
368 | 375 | } |
0 | 0 | // -*- c++ -*- |
1 | 1 | //------------------------------------------------------------------------------ |
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 $ | |
3 | 3 | //------------------------------------------------------------------------------ |
4 | 4 | // CardBox.h |
5 | 5 | //------------------------------------------------------------------------------ |
103 | 103 | m_total_count (NULL), m_expired_count (0) |
104 | 104 | { /* no-op */ } |
105 | 105 | |
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 (); | |
112 | 107 | void add_one () { m_expired_count++; } |
113 | 108 | }; |
114 | 109 | |
165 | 160 | trace_with_mask("CardBox::~CardBox",GUITRACE); |
166 | 161 | } |
167 | 162 | |
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 | ||
168 | 178 | #endif /* CARD_BOX_H */ |
1 | 1 | //------------------------------------------------------------------------------ |
2 | 2 | // CardDeck.cpp |
3 | 3 | //------------------------------------------------------------------------------ |
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 $ | |
5 | 5 | // |
6 | 6 | // Copyright (c) 2004,2006 by Vladislav Grinchenko |
7 | 7 | // |
74 | 74 | |
75 | 75 | void |
76 | 76 | CardDeck:: |
77 | play_card (VDeck::cardlist_iterator& iter_) | |
77 | play_card (SideSelection side_, VDeck::cardlist_iterator& iter_) | |
78 | 78 | { |
79 | 79 | CardRef* cref = dynamic_cast<CardRef*>(*iter_); |
80 | 80 | Assure_exit (cref); |
81 | cref->get_deck ().play_card (iter_); | |
81 | cref->get_deck ().play_card (side_, iter_); | |
82 | 82 | } |
83 | 83 | |
84 | 84 | void |
1 | 1 | //------------------------------------------------------------------------------ |
2 | 2 | // CardDeck.h |
3 | 3 | //------------------------------------------------------------------------------ |
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 $ | |
5 | 5 | // |
6 | 6 | // Copyright (c) 2004,2006 by Vladislav Grinchenko |
7 | 7 | // |
95 | 95 | virtual SideSelection get_side_selection () { return m_side_selection; } |
96 | 96 | virtual void set_side_selection (SideSelection s_) { m_side_selection=s_; } |
97 | 97 | |
98 | virtual void play_card (VDeck::cardlist_iterator& iter_); | |
98 | virtual void play_card (SideSelection s_, VDeck::cardlist_iterator& iter_); | |
99 | 99 | |
100 | 100 | virtual const string& get_name () const { return m_cdname; } |
101 | 101 |
25 | 25 | virtual void set_question (const ustring& q_) { m_card.set_question (q_); } |
26 | 26 | virtual void set_answer (const ustring& a_) { m_card.set_answer (a_); } |
27 | 27 | 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_); | |
32 | 29 | |
33 | 30 | virtual ustring get_question () const { return m_card.get_question (); } |
34 | 31 | virtual ustring get_answer () const { return m_card.get_answer (); } |
35 | 32 | 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 (); } | |
41 | 36 | |
42 | 37 | virtual void set_expiration (const ASSA::TimeVal& e_); |
43 | 38 | virtual ASSA::TimeVal get_expiration () const { return m_exp_date; } |
57 | 52 | Card& m_card; |
58 | 53 | Deck& m_deck; |
59 | 54 | long m_exp_date; /**< Date this card is scheduled to be repeated */ |
55 | }; | |
60 | 56 | |
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 | } | |
63 | 69 | |
64 | 70 | inline bool |
65 | 71 | CardRef::less_then_expiration (const VCard& rhs_) |
1 | 1 | //------------------------------------------------------------------------------ |
2 | 2 | // CardView.cpp |
3 | 3 | //------------------------------------------------------------------------------ |
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 $ | |
5 | 5 | // |
6 | // Copyright (c) 2004-2005 by Vladislav Grinchenko | |
6 | // Copyright (c) 2004-2006 by Vladislav Grinchenko | |
7 | 7 | // |
8 | 8 | // This program is free software; you can redistribute it and/or |
9 | 9 | // modify it under the terms of the GNU General Public License |
13 | 13 | // Date: Feb 15, 2004 |
14 | 14 | //------------------------------------------------------------------------------ |
15 | 15 | |
16 | #include <gtkmmconfig.h> | |
16 | 17 | #include <gtkmm/image.h> |
17 | 18 | #include <gtkmm/label.h> |
18 | 19 | #include <gtkmm/box.h> |
22 | 23 | #include <gtkmm/scrolledwindow.h> |
23 | 24 | #include <gtkmm/table.h> |
24 | 25 | #include <gtkmm/messagedialog.h> |
26 | #include <gtkmm/paned.h> | |
25 | 27 | |
26 | 28 | #include "Granule.h" |
27 | 29 | #include "MainWindow.h" |
31 | 33 | #include "Card.h" |
32 | 34 | #include "CardRef.h" |
33 | 35 | #include "EditControls.h" |
34 | #include "Intern.h" | |
36 | #include "Intern.h" /* always last */ | |
35 | 37 | |
36 | 38 | #define SET_CV_LABEL(l) \ |
37 | 39 | l->set_alignment (0.5,0.5); \ |
56 | 58 | t->set_justification (Gtk::JUSTIFY_LEFT); \ |
57 | 59 | t->set_accepts_tab (false); |
58 | 60 | |
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 | */ | |
60 | 72 | CardView:: |
61 | 73 | CardView (VCard* card_) |
62 | 74 | : |
70 | 82 | m_keep_open (false), |
71 | 83 | |
72 | 84 | m_cancel_button (NULL), |
85 | m_count_button (NULL), | |
73 | 86 | m_add_n_close_button (NULL), |
74 | 87 | m_add_button (NULL), |
75 | 88 | m_help_button (NULL), |
77 | 90 | m_front_text (NULL), |
78 | 91 | m_back_text (NULL), |
79 | 92 | m_example_text (NULL), |
80 | m_altspell_text (NULL), | |
93 | m_asf_text (NULL), | |
94 | m_asb_text (NULL), | |
81 | 95 | |
82 | 96 | m_edit_controls (NULL), |
83 | 97 | m_help_dialog (*this) |
106 | 120 | Gtk::Alignment* alignment2; |
107 | 121 | Gtk::Alignment* alignment3; |
108 | 122 | 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; | |
114 | 130 | |
115 | 131 | Gtk::ScrolledWindow* front_scrollwin; |
116 | 132 | Gtk::ScrolledWindow* backtext_scrollwin; |
117 | 133 | Gtk::ScrolledWindow* example_scrollwin; |
118 | Gtk::ScrolledWindow* altspell_scrollwin; | |
134 | Gtk::ScrolledWindow* asf_scrollwin; | |
135 | Gtk::ScrolledWindow* asb_scrollwin; | |
119 | 136 | |
120 | 137 | Gtk::Label* back_label; |
121 | 138 | Gtk::Label* example_label; |
122 | 139 | Gtk::Label* front_label; |
123 | Gtk::Label* altspell_label; | |
140 | Gtk::Label* asf_label; | |
141 | Gtk::Label* asb_label; | |
124 | 142 | |
125 | 143 | Gtk::VBox* vbox_frontlabel; |
126 | 144 | Gtk::VBox* vbox_backlabel; |
127 | 145 | 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 | ||
131 | 156 | Gtk::VBox* vbox_all; |
132 | 157 | |
133 | #if defined (IS_HILDON) | |
158 | set_title ("Card View"); | |
159 | ||
160 | #ifdef IS_HILDON | |
134 | 161 | set_size_request (672, 396); |
135 | 162 | #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); | |
136 | 173 | set_icon_from_file (GRAPPDATDIR "/pixmaps/cardview_32x32.png"); |
137 | ||
138 | 174 | Gdk::Rectangle geom = CONFIG->get_card_view_geometry (); |
139 | 175 | 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 | |
144 | 176 | 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"), | |
151 | 184 | 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 ()); | |
155 | 189 | |
156 | 190 | /** <Cancel> Button |
157 | 191 | */ |
162 | 196 | alignment2 = Gtk::manage (new Gtk::Alignment (0.5, 0.5, 0, 0)); |
163 | 197 | m_cancel_button = Gtk::manage (new Gtk::Button ()); |
164 | 198 | |
199 | /** <Count> *Button* | |
200 | */ | |
201 | m_count_button = Gtk::manage (new Gtk::Button ()); | |
202 | ||
165 | 203 | /** <Add> Button |
166 | 204 | */ |
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)); | |
172 | 210 | m_add_button = Gtk::manage (new Gtk::Button ()); |
173 | 211 | |
174 | 212 | /** <Add'n'Close> Button |
180 | 218 | alignment4 = Gtk::manage (new Gtk::Alignment (0.5, 0.5, 0, 0)); |
181 | 219 | m_add_n_close_button = Gtk::manage (new Gtk::Button ()); |
182 | 220 | |
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 | ||
192 | 221 | /** Text |
193 | 222 | */ |
194 | 223 | m_front_text = Gtk::manage (new Gtk::TextView); |
195 | 224 | 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)); | |
198 | 227 | vbox_frontlabel = Gtk::manage (new Gtk::VBox (false, 0)); |
199 | 228 | |
200 | 229 | m_back_text = Gtk::manage (new Gtk::TextView); |
201 | 230 | 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)); | |
204 | 233 | vbox_backlabel = Gtk::manage (new Gtk::VBox (false, 0)); |
205 | 234 | |
206 | 235 | m_example_text = Gtk::manage (new Gtk::TextView); |
207 | 236 | 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)); | |
210 | 239 | vbox_examplelabel = Gtk::manage (new Gtk::VBox (false, 0)); |
211 | 240 | |
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)); | |
220 | 261 | |
221 | 262 | m_front_text ->modify_font (CONFIG->get_example_font ()); |
222 | 263 | m_back_text ->modify_font (CONFIG->get_example_font ()); |
223 | 264 | 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 | */ | |
226 | 284 | image1->set_alignment (0.5,0.5); |
227 | 285 | image1->set_padding (0,0); |
286 | ||
287 | #if !defined(IS_PDA) | |
228 | 288 | SET_CV_LABEL(label1); |
229 | ||
230 | 289 | hbox1->pack_start (*image1, Gtk::PACK_SHRINK, 0); |
231 | 290 | hbox1->pack_start (*label1, Gtk::PACK_SHRINK, 0); |
232 | 291 | 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 | */ | |
234 | 301 | image2->set_alignment (0.5,0.5); |
235 | 302 | image2->set_padding (0,0); |
303 | ||
236 | 304 | SET_CV_LABEL(label2); |
237 | 305 | hbox2->pack_start (*image2, Gtk::PACK_SHRINK, 0); |
238 | 306 | hbox2->pack_start (*label2, Gtk::PACK_SHRINK, 0); |
239 | 307 | alignment2->add (*hbox2); |
240 | ||
241 | m_cancel_button->set_flags (Gtk::CAN_FOCUS); | |
308 | m_cancel_button->unset_flags (Gtk::CAN_FOCUS); | |
242 | 309 | m_cancel_button->set_relief (Gtk::RELIEF_NORMAL); |
243 | 310 | m_cancel_button->add (*alignment2); |
244 | 311 | |
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 | */ | |
245 | 322 | image3->set_alignment (0.5,0.5); |
246 | 323 | image3->set_padding (0,0); |
247 | 324 | SET_CV_LABEL(label3); |
248 | 325 | hbox3->pack_start (*image3, Gtk::PACK_SHRINK, 0); |
249 | 326 | hbox3->pack_start (*label3, Gtk::PACK_SHRINK, 0); |
250 | 327 | alignment3->add (*hbox3); |
251 | ||
252 | 328 | m_add_button->set_flags (Gtk::CAN_FOCUS); |
253 | 329 | m_add_button->set_relief (Gtk::RELIEF_NORMAL); |
254 | 330 | m_add_button->add (*alignment3); |
255 | 331 | |
332 | /** [Add-n-Close] | |
333 | */ | |
256 | 334 | image4->set_alignment (0.5,0.5); |
257 | 335 | image4->set_padding (0,0); |
258 | 336 | SET_CV_LABEL(label4); |
264 | 342 | m_add_n_close_button->set_relief (Gtk::RELIEF_NORMAL); |
265 | 343 | m_add_n_close_button->add (*alignment4); |
266 | 344 | |
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 | ||
278 | 345 | /**--------------** |
279 | 346 | ** Front Text ** |
280 | 347 | **--------------** |
281 | 348 | */ |
282 | 349 | 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); | |
292 | 351 | 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); | |
295 | 361 | |
296 | ||
297 | 362 | /**--------------** |
298 | 363 | ** Back Text ** |
299 | 364 | **--------------** |
300 | 365 | */ |
301 | 366 | 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); | |
311 | 368 | 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); | |
314 | 378 | |
315 | 379 | /**----------------** |
316 | 380 | ** Example Text ** |
317 | 381 | **----------------** |
318 | 382 | */ |
319 | 383 | 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); | |
329 | 385 | 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 | |
330 | 393 | vbox_examplelabel->pack_start (*example_label, Gtk::PACK_SHRINK, 0); |
331 | 394 | |
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 | */ | |
356 | 417 | m_front_text->signal_grab_focus ().connect ( |
357 | 418 | bind<Gtk::TextView*> (mem_fun (*m_edit_controls, |
358 | 419 | &EditControls::on_focus_changed), |
368 | 429 | &EditControls::on_focus_changed), |
369 | 430 | m_example_text)); |
370 | 431 | |
371 | m_altspell_text->signal_grab_focus ().connect ( | |
432 | m_asf_text->signal_grab_focus ().connect ( | |
372 | 433 | bind<Gtk::TextView*> (mem_fun (*m_edit_controls, |
373 | 434 | &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)); | |
376 | 440 | #ifdef IS_HILDON |
377 | 441 | /** Trap 'on virtual keyboard close' event to restore |
378 | 442 | * original size of the dialog |
381 | 445 | mem_fun (*this, &CardView::hildon_im_close_cb)); |
382 | 446 | #endif |
383 | 447 | |
384 | /** | |
448 | /************************************************* | |
385 | 449 | * Table holds elements together: |
386 | 450 | * |
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"); | |
395 | 487 | |
396 | 488 | /*-----------------------------------------------------------*/ |
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 */ | |
403 | 490 | /*-----------------------------------------------------------*/ |
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); | |
409 | 496 | |
410 | 497 | /*-----------------------------------------------------------*/ |
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); | |
416 | 500 | |
417 | 501 | /*-----------------------------------------------------------*/ |
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); | |
423 | 507 | |
424 | 508 | /*-----------------------------------------------------------*/ |
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 | |
430 | 530 | * smart packing. |
431 | 531 | */ |
532 | #if defined(IS_HILDON) || defined (IS_PDA) | |
432 | 533 | 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); | |
439 | 535 | vbox_all->pack_start (*scrollw); |
440 | 536 | #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 | **--------------------------------------------------** | |
447 | 543 | */ |
448 | 544 | Gtk::HBox* hbbox = Gtk::manage(new Gtk::HBox(false, 0)); |
449 | 545 | Gtk::HSeparator* hseparator = manage (new Gtk::HSeparator); |
546 | ||
547 | #if !defined(IS_PDA) | |
450 | 548 | 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); | |
453 | 552 | hbuttonbox->set_layout (Gtk::BUTTONBOX_END); |
454 | 553 | hbuttonbox->set_name ("CardView_CtrlButtonBox"); |
455 | 554 | |
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); | |
461 | 561 | 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); | |
465 | 572 | |
466 | 573 | add (*vbox_all); |
467 | 574 | |
493 | 600 | m_front_text ->get_buffer ()->set_text (m_card->get_question ()); |
494 | 601 | m_back_text ->get_buffer ()->set_text (m_card->get_answer ()); |
495 | 602 | 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)); | |
497 | 605 | } |
498 | 606 | |
499 | 607 | /** Set Widget names - very helpful with debugging! |
500 | 608 | */ |
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"); | |
508 | 617 | m_add_n_close_button->set_name ("AddNCloseButton"); |
509 | 618 | |
510 | 619 | vbox_all->set_name ("CardView_VBoxAll"); |
555 | 664 | * - DeckView::on_add_clicked () |
556 | 665 | * |
557 | 666 | * Possible values returned by run(): |
667 | * | |
558 | 668 | * <Cancel> - Gtk::RESPONSE_CANCEL |
559 | 669 | * <Add> - Gtk::RESPONSE_APPLY |
560 | 670 | * <Ok> - Gtk::RESPONSE_OK |
567 | 677 | |
568 | 678 | m_syntax_error = false; |
569 | 679 | take_snapshot (); |
680 | set_cards_count (deckview_); | |
570 | 681 | |
571 | 682 | #ifdef IS_HILDON |
572 | 683 | GRANULE->register_appview (this); |
573 | 684 | Gtk::Main::run (*HILDONAPPWIN); |
574 | ||
575 | 685 | #else |
576 | 686 | Gtk::Main::run (*this); |
577 | 687 | #endif |
616 | 726 | break; |
617 | 727 | } |
618 | 728 | deckview_.add_new_card (dynamic_cast<Card*>(m_card)); |
729 | bump_cards_count (); | |
619 | 730 | } |
620 | 731 | |
621 | 732 | done: |
654 | 765 | DL((GEOM,"key_pressed = %d\n", event_->keyval)); |
655 | 766 | |
656 | 767 | /** 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 | */ | |
660 | 771 | if (event_->keyval == GDK_Escape) { |
661 | 772 | return false; |
662 | 773 | } |
676 | 787 | on_addnclose_clicked () |
677 | 788 | { |
678 | 789 | trace_with_mask("CardView::on_addnclose_clicked",GUITRACE); |
679 | ||
790 | ||
680 | 791 | m_response = Gtk::RESPONSE_OK; |
681 | 792 | |
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 | { | |
683 | 809 | Gtk::MessageDialog err1 ( |
684 | 810 | _("FRONT field contains illegal markup tag(s)."), |
685 | 811 | false, Gtk::MESSAGE_ERROR); |
688 | 814 | return; |
689 | 815 | } |
690 | 816 | |
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 | { | |
692 | 819 | Gtk::MessageDialog err2 ( |
693 | 820 | _("BACK field contains illegal markup tag(s)."), |
694 | 821 | false, Gtk::MESSAGE_ERROR); |
697 | 824 | return; |
698 | 825 | } |
699 | 826 | |
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 ( | |
702 | 830 | _("EXAMPLE field contains illegal markup tag(s)."), |
703 | 831 | false, Gtk::MESSAGE_ERROR); |
704 | err2.run (); | |
832 | err3.run (); | |
705 | 833 | m_syntax_error = true; |
706 | 834 | return; |
707 | 835 | } |
708 | 836 | |
709 | /** Transfer data from the widget to the card | |
837 | /** Transfer data from the widget to the Card object | |
710 | 838 | */ |
711 | 839 | if (m_card != NULL && text_modified ()) |
712 | 840 | { |
713 | 841 | m_card->set_question (m_front_text ->get_buffer ()->get_text ()); |
714 | 842 | m_card->set_answer (m_back_text ->get_buffer ()->get_text ()); |
715 | 843 | 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 ()); | |
717 | 847 | } |
718 | 848 | m_keep_open = false; |
719 | 849 | m_front_text->grab_focus (); |
726 | 856 | #else |
727 | 857 | Gtk::Main::quit (); |
728 | 858 | #endif |
859 | /* done */ | |
729 | 860 | } |
730 | 861 | |
731 | 862 | void |
737 | 868 | m_snapshot_front = m_front_text ->get_buffer ()->get_text (); |
738 | 869 | m_snapshot_back = m_back_text ->get_buffer ()->get_text (); |
739 | 870 | 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 (); | |
741 | 873 | } |
742 | 874 | |
743 | 875 | bool |
747 | 879 | return (m_snapshot_front != m_front_text ->get_buffer ()->get_text () || |
748 | 880 | m_snapshot_back != m_back_text ->get_buffer ()->get_text () || |
749 | 881 | 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 ()); | |
751 | 884 | } |
752 | 885 | |
753 | 886 | void |
778 | 911 | m_front_text ->get_buffer ()->set_text (""); |
779 | 912 | m_back_text ->get_buffer ()->set_text (""); |
780 | 913 | 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 (""); | |
782 | 916 | |
783 | 917 | m_snapshot_front = ""; |
784 | 918 | m_snapshot_back = ""; |
785 | 919 | m_snapshot_example = ""; |
786 | m_snapshot_altspell = ""; | |
920 | m_snapshot_asf = ""; | |
921 | m_snapshot_asb = ""; | |
787 | 922 | } |
788 | 923 | |
789 | 924 | void |
806 | 941 | set_size_request (672, 396); |
807 | 942 | } |
808 | 943 | #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 | } |
1 | 1 | //------------------------------------------------------------------------------ |
2 | 2 | // CardView.h |
3 | 3 | //------------------------------------------------------------------------------ |
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 $ | |
5 | 5 | // |
6 | 6 | // Copyright (c) 2004-2005 by Vladislav Grinchenko |
7 | 7 | // |
78 | 78 | void clear_dialog (); |
79 | 79 | |
80 | 80 | void take_snapshot (); |
81 | void set_cards_count (DeckView& deckview_); | |
82 | void bump_cards_count (); | |
81 | 83 | bool text_modified (); |
82 | 84 | |
83 | 85 | private: |
89 | 91 | // -*- GUI components -*- |
90 | 92 | // |
91 | 93 | Gtk::Button* m_cancel_button; |
94 | Gtk::Button* m_count_button; // functions as a label | |
92 | 95 | Gtk::Button* m_add_n_close_button; |
93 | 96 | Gtk::Button* m_add_button; |
94 | 97 | Gtk::Button* m_help_button; |
96 | 99 | Gtk::TextView* m_front_text; |
97 | 100 | Gtk::TextView* m_back_text; |
98 | 101 | 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 | |
100 | 104 | |
101 | 105 | // -*- Snapshot to detect true changes -*- |
102 | 106 | // |
103 | 107 | Glib::ustring m_snapshot_front; |
104 | 108 | Glib::ustring m_snapshot_back; |
105 | 109 | Glib::ustring m_snapshot_example; |
106 | Glib::ustring m_snapshot_altspell; | |
110 | Glib::ustring m_snapshot_asf; | |
111 | Glib::ustring m_snapshot_asb; | |
107 | 112 | |
108 | 113 | EditControls* m_edit_controls; |
109 | 114 | |
110 | 115 | CardViewHelpDialog m_help_dialog; |
116 | ||
117 | int m_cards_count; // tied up to m_count_button | |
111 | 118 | }; |
112 | 119 | |
113 | 120 |
1 | 1 | //------------------------------------------------------------------------------ |
2 | 2 | // Deck.cpp |
3 | 3 | //------------------------------------------------------------------------------ |
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 $ | |
5 | 5 | // |
6 | 6 | // Copyright (c) 2004-2006 by Vladislav Grinchenko |
7 | 7 | // |
36 | 36 | #include "MainWindow.h" |
37 | 37 | #include "GrappConf.h" |
38 | 38 | #include "CSVImportDialog.h" |
39 | #include "CSVExportDialog.h" | |
40 | ||
39 | 41 | #include "Intern.h" |
40 | 42 | |
41 | 43 | /** Compare real cards by their IDs |
52 | 54 | } |
53 | 55 | }; |
54 | 56 | |
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 | ||
55 | 73 | /** C'tor for the new deck |
56 | 74 | */ |
57 | 75 | Deck:: |
65 | 83 | trace_with_mask("Deck::Deck(untitled)",GUITRACE|DECK); |
66 | 84 | |
67 | 85 | 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 | ||
69 | 88 | { |
70 | 89 | ASSA::TimeVal today = ASSA::TimeVal::gettimeofday (); |
71 | 90 | m_desc += Glib::locale_to_utf8 (today.fmtString ("%c")); |
72 | 91 | } |
92 | init_appearance (); | |
73 | 93 | 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"; | |
74 | 117 | } |
75 | 118 | |
76 | 119 | int |
124 | 167 | } |
125 | 168 | |
126 | 169 | DL((GRAPP,"Parsing the deck ...\n")); |
170 | m_status = CLEAN_DECK; | |
127 | 171 | |
128 | 172 | ret = parse_xml_tree (parser, error_msg); |
129 | 173 | xmlFreeDoc (parser); |
142 | 186 | DECKMGR->on_deck_loaded (this, LOAD_OK); |
143 | 187 | } |
144 | 188 | |
145 | m_status = CLEAN_DECK; | |
146 | 189 | dump_deck_status (); |
147 | 190 | |
148 | 191 | return 0; |
154 | 197 | { |
155 | 198 | trace_with_mask("Deck::parse_xml_tree",GUITRACE|DECK); |
156 | 199 | |
200 | char buffer[128]; | |
157 | 201 | char xpath [64]; |
158 | 202 | xmlChar* result; |
159 | 203 | Card* card; |
160 | 204 | std::ostringstream os; |
205 | int illegal_count = 0; | |
161 | 206 | |
162 | 207 | result = Granule::get_node_by_xpath (parser_, "/deck/author"); |
163 | 208 | if (result) { |
173 | 218 | |
174 | 219 | result = Granule::get_node_by_xpath (parser_, "/deck/sound_path"); |
175 | 220 | 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 | } | |
177 | 226 | xmlFree (result); |
178 | 227 | } |
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: | |
186 | 385 | dump (); |
187 | 386 | |
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 | { | |
191 | 393 | sprintf (xpath, "/deck/card[%d]", cards_counter); |
192 | 394 | |
193 | 395 | result = Granule::get_node_by_xpath (parser_, xpath); |
198 | 400 | */ |
199 | 401 | card = new Card; |
200 | 402 | |
403 | //----------------------------------------------------- | |
201 | 404 | sprintf (xpath, "/deck/card[%d]/@id", cards_counter); |
202 | 405 | result = Granule::get_node_by_xpath (parser_, xpath); |
203 | 406 | if (result == NULL) { |
209 | 412 | card->set_id (::atol ((const char*) result+1)); |
210 | 413 | xmlFree (result); |
211 | 414 | |
415 | //----------------------------------------------------- | |
212 | 416 | sprintf (xpath, "/deck/card[%d]/front", cards_counter); |
213 | 417 | result = Granule::get_node_by_xpath (parser_, xpath); |
214 | 418 | 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 | } | |
222 | 430 | |
223 | 431 | sprintf (xpath, "/deck/card[%d]/front/@alt_spelling", cards_counter); |
224 | 432 | result = Granule::get_node_by_xpath (parser_, xpath); |
225 | 433 | 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 | //----------------------------------------------------- | |
230 | 439 | sprintf (xpath, "/deck/card[%d]/back", cards_counter); |
231 | 440 | result = Granule::get_node_by_xpath (parser_, xpath); |
232 | 441 | if (result != NULL) { /* can be empty */ |
234 | 443 | xmlFree (result); |
235 | 444 | } |
236 | 445 | |
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. | |
238 | 455 | */ |
239 | 456 | sprintf (xpath, "/deck/card[%d]/back_example", cards_counter); |
240 | 457 | result = Granule::get_node_by_xpath (parser_, xpath); |
290 | 507 | } |
291 | 508 | } |
292 | 509 | |
293 | /** | |
510 | /*------------------------------------------------------------------------------ | |
511 | * import_from_csv () | |
512 | * | |
294 | 513 | * Variations: |
295 | 514 | * |
296 | 515 | * 1: [ ] |
297 | 516 | * 2: [ ];[ ] |
298 | 517 | * 3: [ ];[ ];[_________] |
299 | 518 | * 4: [ ];[ ];[ ];[ ]; ... ;[______] |
519 | * | |
520 | * and much more | |
521 | *------------------------------------------------------------------------------ | |
300 | 522 | */ |
301 | 523 | bool |
302 | 524 | Deck:: |
304 | 526 | { |
305 | 527 | trace_with_mask("Deck::import_from_csv",GUITRACE|DECK); |
306 | 528 | |
307 | const int size = 1024; | |
529 | const int size = 1024; | |
308 | 530 | 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 ()); | |
314 | 550 | long card_id = t.sec (); |
315 | 551 | |
316 | 552 | CSVImportDialog impd; |
553 | ||
317 | 554 | if (impd.run () != Gtk::RESPONSE_APPLY) { |
318 | 555 | return false; |
319 | 556 | } |
320 | 557 | impd.hide (); |
321 | 558 | |
322 | ifstream source (file_.c_str (), std::ios::in); | |
559 | source.open (file_.c_str (), std::ios::in); | |
560 | ||
323 | 561 | if (!source.good ()) { |
324 | 562 | Gtk::MessageDialog emsg ( |
325 | 563 | _("Failed to open import file.\nCheck file permissions."), |
326 | MESSAGE_ERROR); | |
564 | Gtk::MESSAGE_ERROR); | |
327 | 565 | emsg.run (); |
328 | 566 | return false; |
329 | 567 | } |
568 | ||
569 | sprintf (failed_fname, "%s.failed", file_.c_str ()); | |
570 | ffailed.open (failed_fname, std::ios::out); | |
571 | ||
330 | 572 | DL ((GRAPP,"separator = %s\n", impd.get_separator ())); |
331 | 573 | DL ((GRAPP,"doubld_separator = %s\n", impd.get_double_separator ())); |
332 | 574 | |
575 | state = ST_BEGIN; | |
576 | bracket_flag = false; | |
577 | ||
333 | 578 | while (source) { |
334 | DL ((GRAPP,"-----------------------------------------\n")); | |
579 | DL ((GRAPP,"-------------- next line --------------------\n")); | |
335 | 580 | 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) { | |
339 | 584 | continue; |
340 | 585 | } |
586 | ||
587 | DL ((GRAPP, "state = %s\n", get_state_name (state))); | |
341 | 588 | |
342 | 589 | if (impd.is_windoz_linebreak () && inbuf [strlen (inbuf)-1] == 0x0D) { |
343 | 590 | inbuf [strlen (inbuf)-1] = '\0'; |
344 | 591 | } |
345 | 592 | |
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 | |
347 | 961 | */ |
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 | */ | |
393 | 1041 | bool |
394 | 1042 | Deck:: |
395 | 1043 | erase (VCard* vcard_) |
458 | 1106 | trace_with_mask("Deck::save",GUITRACE|DECK); |
459 | 1107 | |
460 | 1108 | static const char dtd_url [] = "http://granule.sourceforge.net/granule.dtd"; |
1109 | ||
461 | 1110 | int ret = 0; |
462 | 1111 | xmlTextWriterPtr writer; |
463 | 1112 | Glib::ustring alt_spell; |
1113 | cardlist_const_iterator citer; | |
1114 | ||
464 | 1115 | g_remove (m_fname.c_str ()); |
465 | 1116 | |
466 | 1117 | writer = xmlNewTextWriterFilename (m_fname.c_str (), 0); |
495 | 1146 | ret = xmlTextWriterWriteElement (writer, BAD_CAST "sound_path", |
496 | 1147 | BAD_CAST Glib::locale_to_utf8 (m_snd_path).c_str ()); |
497 | 1148 | |
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 (); | |
499 | 1213 | while (citer != m_cards.end ()) |
500 | 1214 | { |
1215 | //-------------------------------------------------------- | |
501 | 1216 | ret = xmlTextWriterStartElement (writer, BAD_CAST "card"); |
1217 | //-------------------------------------------------------- | |
502 | 1218 | ret = xmlTextWriterWriteAttribute (writer, BAD_CAST "id", |
503 | 1219 | BAD_CAST (*citer)->get_id_str ().c_str ()); |
504 | 1220 | |
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); | |
508 | 1225 | if (alt_spell.length () > 0) { |
509 | 1226 | ret = xmlTextWriterWriteAttribute (writer, BAD_CAST "alt_spelling", |
510 | 1227 | BAD_CAST alt_spell.c_str ()); |
513 | 1230 | BAD_CAST (*citer)->get_question ().c_str ()); |
514 | 1231 | ret = xmlTextWriterEndElement (writer); // @end front |
515 | 1232 | |
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, | |
517 | 1242 | BAD_CAST (*citer)->get_answer ().c_str ()); |
518 | ||
1243 | ret = xmlTextWriterEndElement (writer); // @end back | |
1244 | ||
1245 | //-------------------------------------------------------- | |
519 | 1246 | ret = xmlTextWriterWriteElement (writer, BAD_CAST "back_example", |
520 | 1247 | BAD_CAST (*citer)->get_example ().c_str ()); |
521 | 1248 | |
522 | 1249 | ret = xmlTextWriterEndElement (writer); // @end card |
523 | 1250 | citer++; |
524 | 1251 | } |
1252 | ||
525 | 1253 | /** Close <deck> and write out the file |
526 | 1254 | */ |
527 | 1255 | xmlTextWriterEndElement (writer); // @end deck |
567 | 1295 | Deck:: |
568 | 1296 | find_card_by_id (long id_) |
569 | 1297 | { |
570 | // trace_with_mask("Deck::find_card_by_id",GUITRACE|DECK); | |
571 | ||
572 | 1298 | cardlist_iterator iter = m_cards.begin (); |
573 | 1299 | while (iter != m_cards.end ()) { |
574 | 1300 | if ((*iter)->get_id () == id_) { |
592 | 1318 | */ |
593 | 1319 | void |
594 | 1320 | Deck:: |
595 | play_card (Deck::cardlist_iterator& iter_) | |
1321 | play_card (SideSelection side_, Deck::cardlist_iterator& iter_) | |
596 | 1322 | { |
597 | 1323 | trace_with_mask("Deck::play_card",GUITRACE|DECK); |
1324 | ||
598 | 1325 | static char execmdbuf [1024]; |
599 | ||
600 | if (! m_with_snd) { | |
601 | return; | |
602 | } | |
603 | 1326 | std::vector<string> v; |
604 | 1327 | string w; |
605 | 1328 | |
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 | { | |
608 | 1340 | w = Glib::locale_from_utf8 ((*iter_)->get_question ()); |
609 | 1341 | ASSA::Utils::split (w.c_str (), v); |
610 | if (v.size () > 1) { | |
1342 | if (v.size () > 1) | |
1343 | { | |
611 | 1344 | if (v[0] != "to") { |
612 | 1345 | return; |
613 | 1346 | } |
614 | 1347 | w = v[1]; |
615 | 1348 | } |
616 | 1349 | } |
617 | string sfn (m_snd_path + G_DIR_SEPARATOR_S); | |
1350 | string sfn (m_active_snd_path + G_DIR_SEPARATOR_S); | |
618 | 1351 | 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 ())); | |
628 | 1361 | |
629 | 1362 | #if defined (WIN32) |
630 | 1363 | |
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 | } | |
632 | 1376 | |
633 | 1377 | #elif defined (IS_HILDON) |
634 | 1378 | |
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); | |
636 | 1381 | |
637 | 1382 | #else /* POSIX */ |
638 | 1383 | |
639 | 1384 | snprintf (execmdbuf, 512, CONFIG->get_snd_player_args (), sfn.c_str ()); |
640 | DL((APP,"Playing \"%s %s\"\n", CONFIG->get_snd_player_cmd (), execmdbuf)); | |
641 | 1385 | |
642 | 1386 | /** |
643 | 1387 | * Better yet to route WAV playing through esd (if it is running): |
647 | 1391 | * We have to preserve it - otherwise, we would crash and burn. |
648 | 1392 | * COLLECT_STATUS option does that for us here. |
649 | 1393 | */ |
1394 | DL((APP,"POSIX: playing \"%s %s\"\n", | |
1395 | CONFIG->get_snd_player_cmd (), execmdbuf)); | |
1396 | ||
1397 | ||
650 | 1398 | ASSA::Fork::fork_exec (CONFIG->get_snd_player_cmd (), |
651 | execmdbuf, ASSA::Fork::COLLECT_STATUS); | |
1399 | execmdbuf, ASSA::Fork::IGNORE_STATUS); | |
652 | 1400 | #endif |
653 | 1401 | } |
654 | 1402 | |
739 | 1487 | } |
740 | 1488 | } |
741 | 1489 | |
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 | ||
742 | 1542 | //------------------------------------------------------------------------------ |
743 | // LEFTOVERS FOR HEAVY DEBUGGING | |
1543 | // LEFTOVERS FROM HEAVY DEBUGGING IN THE PAST | |
744 | 1544 | //------------------------------------------------------------------------------ |
745 | 1545 | #if 0 |
746 | 1546 | void |
1 | 1 | //------------------------------------------------------------------------------ |
2 | 2 | // Deck.h |
3 | 3 | //------------------------------------------------------------------------------ |
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 $ | |
5 | 5 | // |
6 | 6 | // Copyright (c) 2004 by Vladislav Grinchenko |
7 | 7 | // |
18 | 18 | #include "VDeck.h" |
19 | 19 | #include <libxml/tree.h> // xmlDocPtr |
20 | 20 | |
21 | typedef enum _ParserState { | |
22 | ST_BEGIN, | |
23 | ST_1ST_FIELD, | |
24 | ST_2ND_FIELD, | |
25 | ST_3RD_FIELD | |
26 | } ParserState; | |
27 | ||
21 | 28 | class Card; |
22 | 29 | |
23 | 30 | class Deck : public VDeck |
30 | 37 | virtual int load (const string& fname_, DeckAction = INSTALL_DECK); |
31 | 38 | void insert (const string& from_file_); |
32 | 39 | bool import_from_csv (const string& file_); |
40 | bool export_to_csv (const string& file_); | |
33 | 41 | virtual int save (); |
34 | 42 | virtual int save_as (const string& fname_); |
35 | 43 | |
51 | 59 | |
52 | 60 | virtual const string& get_name (void) const { return m_fname; } |
53 | 61 | 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_); | |
55 | 63 | |
56 | 64 | VCard* find_card_by_id (long id_); |
57 | 65 | DeckEditStatus get_status (); |
66 | ||
58 | 67 | const string& get_snd_path () const { return m_snd_path; } |
59 | 68 | const Glib::ustring& get_author () const { return m_author; } |
60 | 69 | const Glib::ustring& get_desc () const { return m_desc; } |
61 | 70 | |
62 | void set_snd_path (const string& spath_) { m_snd_path = spath_; } | |
71 | void set_snd_path (const string& spath_); | |
63 | 72 | void set_author (const Glib::ustring& s_) { m_author = s_; } |
64 | 73 | void set_desc (const Glib::ustring& s_) { m_desc = s_; } |
65 | 74 | |
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 | */ | |
66 | 100 | void mark_as_modified () { m_status = MODIFIED_DECK; } |
67 | 101 | bool needs_renaming () const { return m_needs_renaming; } |
68 | 102 | DeckEditStatus get_status () const { return m_status; } |
78 | 112 | |
79 | 113 | void reset_snd_setup (); |
80 | 114 | |
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 | ||
81 | 137 | private: |
82 | 138 | string m_fname; // full XML file path name |
83 | 139 | cardlist_type m_cards; |
84 | 140 | string m_indent; // for pretty printing |
85 | 141 | |
142 | DeckEditStatus m_status; | |
143 | bool m_needs_renaming; | |
144 | ||
86 | 145 | Glib::ustring m_author; |
87 | 146 | Glib::ustring m_desc; |
88 | 147 | SideSelection m_side_selection; // Tells which side to play next time |
89 | 148 | |
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; | |
95 | 189 | }; |
96 | 190 | |
97 | /** C'tor for existing deck which would be | |
98 | loaded later on. | |
99 | */ | |
100 | 191 | 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 () | |
115 | 193 | { |
116 | 194 | trace_with_mask("Deck::~Deck",GUITRACE|DECK); |
117 | 195 | dump_deck_status (); |
118 | 196 | } |
119 | 197 | |
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 | ||
120 | 320 | #endif /* DECK_H */ |
0 | 0 | // -*- c++ -*- |
1 | 1 | //------------------------------------------------------------------------------ |
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 $ | |
3 | 3 | //------------------------------------------------------------------------------ |
4 | 4 | // DeckInfo.cpp |
5 | 5 | //------------------------------------------------------------------------------ |
27 | 27 | #include <gtkmm/table.h> |
28 | 28 | #include <gtkmm/box.h> |
29 | 29 | #include <gtkmm/stock.h> |
30 | #include <gtkmm/filechooserdialog.h> | |
31 | 30 | #include <gtkmm/main.h> |
32 | 31 | |
33 | 32 | #include "Granule-main.h" |
34 | 33 | #include "Granule.h" |
35 | 34 | #include "DeckInfo.h" |
36 | 35 | #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 | : | |
40 | 170 | 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) | |
44 | 175 | { |
45 | 176 | trace_with_mask("DeckInfo::DeckInfo", GUITRACE); |
46 | 177 | |
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; | |
54 | 179 | |
55 | 180 | Gtk::Button* cancel_button; |
56 | 181 | 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); | |
87 | 322 | cancel_button->set_relief (Gtk::RELIEF_NORMAL); |
88 | 323 | |
89 | ok_button->set_flags (Gtk::CAN_FOCUS); | |
324 | ok_button->set_flags (Gtk::CAN_FOCUS); | |
90 | 325 | ok_button->set_relief (Gtk::RELIEF_NORMAL); |
91 | 326 | |
92 | 327 | get_action_area ()->property_layout_style ().set_value (Gtk::BUTTONBOX_END); |
93 | 328 | |
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); | |
160 | 397 | |
161 | 398 | get_vbox ()->set_homogeneous (false); |
162 | 399 | 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 | ************************/ | |
165 | 413 | add_action_widget (*cancel_button, -6); |
166 | 414 | add_action_widget (*ok_button, -5); |
167 | 415 | |
168 | /** Initialize callbacks | |
169 | */ | |
170 | 416 | ok_button->signal_clicked ().connect ( |
171 | 417 | sigc::mem_fun (*this, &DeckInfo::on_ok_clicked)); |
172 | snd_browse_button->signal_clicked ().connect ( | |
418 | ||
419 | m_snd_browse_button->signal_clicked ().connect ( | |
173 | 420 | sigc::mem_fun (*this, &DeckInfo::on_browse_clicked)); |
174 | 421 | |
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 | ||
175 | 428 | show_all (); |
176 | 429 | } |
177 | 430 | |
178 | 431 | void |
179 | 432 | 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:: | |
180 | 451 | on_browse_clicked () |
181 | 452 | { |
182 | 453 | trace_with_mask("DeckInfo::on_browse_clicked", GUITRACE); |
183 | 454 | |
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 | } | |
195 | 460 | |
196 | 461 | 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())); | |
199 | 463 | } |
200 | 464 | } |
201 | 465 | |
209 | 473 | m_deck.set_author (m_author_entry->get_text ()); |
210 | 474 | m_deck.mark_as_modified (); |
211 | 475 | } |
476 | ||
212 | 477 | if (m_deck.get_desc () != m_desc_entry->get_text ()) { |
213 | 478 | m_deck.set_desc (m_desc_entry->get_text ()); |
214 | 479 | m_deck.mark_as_modified (); |
215 | 480 | } |
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 (""); | |
218 | 487 | m_deck.mark_as_modified (); |
219 | 488 | } |
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 |
0 | 0 | // -*- c++ -*- |
1 | 1 | //------------------------------------------------------------------------------ |
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 $ | |
3 | 3 | //------------------------------------------------------------------------------ |
4 | 4 | // DeckInfo.h |
5 | 5 | //------------------------------------------------------------------------------ |
22 | 22 | #endif |
23 | 23 | |
24 | 24 | #include <gtkmm/dialog.h> |
25 | #include <gtkmm/checkbutton.h> | |
26 | #include <gtkmm/box.h> | |
25 | 27 | |
28 | class Gtk::Entry; | |
26 | 29 | class Deck; |
27 | class Gtk::Entry; | |
30 | class AppearancePrefs; | |
31 | class MyTextAlignmentsWidget; | |
28 | 32 | |
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 | //------------------------------------------------------------------------------ | |
29 | 78 | class DeckInfo : public Gtk::Dialog |
30 | 79 | { |
31 | 80 | public: |
33 | 82 | |
34 | 83 | void on_ok_clicked (); |
35 | 84 | 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; | |
36 | 108 | |
37 | 109 | private: |
38 | 110 | Deck& m_deck; |
111 | ||
112 | /** Origin | |
113 | */ | |
39 | 114 | Gtk::Entry* m_author_entry; |
40 | 115 | Gtk::Entry* m_desc_entry; |
41 | 116 | 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; | |
42 | 134 | }; |
43 | 135 | |
44 | 136 | #endif |
0 | 0 | // -*- c++ -*- |
1 | 1 | //------------------------------------------------------------------------------ |
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 $ | |
3 | 3 | //------------------------------------------------------------------------------ |
4 | 4 | // DeckList.cpp |
5 | 5 | //------------------------------------------------------------------------------ |
62 | 62 | int cnt = m_tree_view.append_column ("Decks", m_columns.m_name); |
63 | 63 | Gtk::TreeViewColumn* column = m_tree_view.get_column (cnt - 1); |
64 | 64 | column->set_sizing (Gtk::TREE_VIEW_COLUMN_FIXED); |
65 | column->set_fixed_width (140); | |
65 | // column->set_fixed_width (60); | |
66 | 66 | column->set_resizable (); |
67 | 67 | |
68 | 68 | /** Enable column sorting |
113 | 113 | /** Add Popup Menu dialog |
114 | 114 | */ |
115 | 115 | MenuList& d = m_popup_menu.items (); |
116 | ||
117 | d.push_back (MenuElem ("Insert", | |
116 | ||
117 | d.push_back (MenuElem ("Insert from Deck", | |
118 | 118 | mem_fun (*DECKMGR, &DeckManager::insert_deck_cb))); |
119 | ||
120 | d.push_back (SeparatorElem ()); /*-----------------------------------*/ | |
121 | ||
119 | 122 | d.push_back (MenuElem ("Import from CSV", |
120 | 123 | mem_fun (*DECKMGR, &DeckManager::import_deck_cb))); |
124 | d.push_back (MenuElem ("Export to CSV", | |
125 | mem_fun (*DECKMGR, &DeckManager::export_deck_cb))); | |
126 | ||
121 | 127 | d.push_back (SeparatorElem ()); /*-----------------------------------*/ |
128 | ||
122 | 129 | d.push_back (MenuElem ("Save", |
123 | 130 | mem_fun (*DECKMGR, &DeckManager::save_deck_cb))); |
124 | 131 | d.push_back (MenuElem ("Save As", |
125 | 132 | mem_fun (*DECKMGR, &DeckManager::save_as_deck_cb))); |
133 | ||
126 | 134 | d.push_back (SeparatorElem ()); /*-----------------------------------*/ |
135 | ||
127 | 136 | d.push_back (MenuElem ("Play/Edit", |
128 | 137 | mem_fun (*DECKMGR, &DeckManager::play_deck_cb))); |
138 | ||
129 | 139 | /**---------------------------- |
130 | 140 | * [Deck]->[Add2Box] SubMenu |
131 | 141 | */ |
0 | 0 | // -*- c++ -*- |
1 | 1 | // Generated by assa-genesis |
2 | 2 | //------------------------------------------------------------------------------ |
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 $ | |
4 | 4 | //------------------------------------------------------------------------------ |
5 | 5 | // DeckManager.cpp |
6 | 6 | //------------------------------------------------------------------------------ |
30 | 30 | #include "GrappConf.h" |
31 | 31 | #include "CardRef.h" |
32 | 32 | #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 | |
33 | 45 | |
34 | 46 | //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= |
35 | 47 | // Toolbar callbacks |
79 | 91 | } |
80 | 92 | } |
81 | 93 | 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); | |
84 | 95 | w.run (); |
85 | 96 | } |
86 | 97 | } |
137 | 148 | { |
138 | 149 | trace_with_mask("DeckManager::open_deck_cb", GUITRACE); |
139 | 150 | |
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 (); | |
159 | 154 | if (f.run () != Gtk::RESPONSE_OK) { |
160 | 155 | return; |
161 | 156 | } |
162 | 157 | f.hide (); |
163 | 158 | |
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++; | |
178 | 184 | } |
179 | 185 | } |
180 | 186 | |
187 | 193 | trace_with_mask("DeckManager::insert_deck_cb", GUITRACE); |
188 | 194 | |
189 | 195 | 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 | { | |
214 | 208 | selected->insert (f.get_filename ()); |
215 | 209 | CONFIG->set_filesel_path (f.get_filename ()); |
216 | 210 | DeckPlayerVectorIter iter = m_players.begin (); |
217 | while (iter != m_players.end ()) { | |
211 | ||
212 | while (iter != m_players.end ()) | |
213 | { | |
218 | 214 | if (selected == dynamic_cast<Deck*>((*iter)->get_deck ())) { |
219 | 215 | m_players.erase (iter); |
220 | 216 | break; |
236 | 232 | |
237 | 233 | Deck* selected = DECKLIST->get_selected (); |
238 | 234 | 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); | |
241 | 236 | w.run (); |
242 | 237 | return; |
243 | 238 | } |
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 | { | |
257 | 248 | f.hide (); |
258 | 249 | if (selected->import_from_csv (f.get_filename ()) == false) { |
259 | 250 | return; |
260 | 251 | } |
252 | ||
261 | 253 | CONFIG->set_filesel_path (f.get_filename ()); |
262 | 254 | DeckPlayerVectorIter iter = m_players.begin (); |
255 | ||
263 | 256 | while (iter != m_players.end ()) { |
264 | 257 | if (selected == dynamic_cast<Deck*>((*iter)->get_deck ())) { |
265 | 258 | m_players.erase (iter); |
268 | 261 | iter++; |
269 | 262 | } |
270 | 263 | 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 ()); | |
271 | 321 | } |
272 | 322 | } |
273 | 323 | |
276 | 326 | save_deck_cb () |
277 | 327 | { |
278 | 328 | trace_with_mask("DeckManager::save_deck_cb", GUITRACE); |
329 | ||
279 | 330 | Deck* selected = DECKLIST->get_selected (); |
280 | 331 | if (selected != NULL) { |
281 | 332 | if (selected->needs_renaming ()) { |
286 | 337 | } |
287 | 338 | } |
288 | 339 | 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); | |
291 | 341 | w.run (); |
292 | 342 | } |
293 | 343 | } |
301 | 351 | bool save_all = false; |
302 | 352 | DeckEditStatus dstat; |
303 | 353 | DeckList::iterator iter = DECKLIST->begin (); |
354 | string fname; | |
304 | 355 | |
305 | 356 | DL((GRAPP,"Number of Decks in DeckList=%d\n", DECKLIST->size ())); |
306 | 357 | |
315 | 366 | |
316 | 367 | if (DECKLIST->deck_needs_renaming (iter)) |
317 | 368 | { |
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); | |
335 | 374 | |
336 | 375 | if (f.run () == Gtk::RESPONSE_OK) |
337 | 376 | { |
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); | |
339 | 382 | CONFIG->set_filesel_path (f.get_filename ()); |
340 | 383 | } |
341 | 384 | } |
348 | 391 | } |
349 | 392 | Gtk::MessageDialog qm ( |
350 | 393 | "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?", | |
352 | 396 | false, |
353 | 397 | Gtk::MESSAGE_QUESTION, |
354 | 398 | Gtk::BUTTONS_NONE, |
378 | 422 | trace_with_mask("DeckManager::save_as_deck_cb", GUITRACE); |
379 | 423 | |
380 | 424 | 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); | |
394 | 441 | |
395 | 442 | 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); | |
397 | 448 | DECKLIST->refresh_selected_name (); |
398 | 449 | CONFIG->set_filesel_path (f.get_filename ()); |
399 | 450 | } |
400 | 451 | } |
401 | 452 | 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); | |
404 | 454 | w.run (); |
405 | 455 | } |
406 | 456 | } |
422 | 472 | CARDBOX->add_deck_to_box (idx_, selected); |
423 | 473 | } |
424 | 474 | 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); | |
428 | 476 | w.run (); |
429 | 477 | } |
430 | 478 | } |
0 | 0 | // -*- c++ -*- |
1 | 1 | // Generated by assa-genesis |
2 | 2 | //------------------------------------------------------------------------------ |
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 $ | |
4 | 4 | //------------------------------------------------------------------------------ |
5 | 5 | // DeckManager.h |
6 | 6 | //------------------------------------------------------------------------------ |
45 | 45 | void play_deck_cb (); |
46 | 46 | void insert_deck_cb (); |
47 | 47 | void import_deck_cb (); |
48 | void export_deck_cb (); | |
48 | 49 | void open_deck_cb (); |
49 | 50 | void save_deck_cb (); |
50 | 51 | void save_as_deck_cb (); |
0 | 0 | // -*- c++ -*- |
1 | 1 | //------------------------------------------------------------------------------ |
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 $ | |
3 | 3 | //------------------------------------------------------------------------------ |
4 | 4 | // DeckPlayer.cpp |
5 | 5 | //------------------------------------------------------------------------------ |
50 | 50 | " " |
51 | 51 | }; |
52 | 52 | |
53 | enum { CHECK_ANSWER, NEXT, CORRECT, INCORRECT, EMPTY }; | |
53 | enum { | |
54 | CHECK_ANSWER, | |
55 | NEXT, | |
56 | CORRECT, | |
57 | INCORRECT, | |
58 | EMPTY | |
59 | }; | |
54 | 60 | |
55 | 61 | 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 | } | |
56 | 232 | |
57 | 233 | /******************************************************************************* |
58 | 234 | * 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 | * * | |
59 | 249 | ******************************************************************************* |
60 | 250 | */ |
61 | 251 | VerifyControl:: |
77 | 267 | Gtk::Table* table = this; |
78 | 268 | |
79 | 269 | m_report = Gtk::manage (new Gtk::Label); |
270 | ||
80 | 271 | m_report->set_alignment (0, 0.5); |
81 | 272 | m_report->set_padding (0,0); |
82 | 273 | m_report->set_justify (Gtk::JUSTIFY_FILL); |
83 | 274 | m_report->set_line_wrap (false); |
84 | 275 | m_report->set_use_markup (false); |
85 | 276 | m_report->set_selectable (false); |
277 | #if !defined (IS_PDA) | |
86 | 278 | m_report->set_size_request (80, -1); // width, height |
279 | #endif | |
87 | 280 | m_report->set_text (clabels [EMPTY]); |
88 | 281 | m_report->set_sensitive (false); |
89 | 282 | |
100 | 293 | m_entry->set_activates_default (false); |
101 | 294 | m_entry->modify_font (CONFIG->get_input_font ()); |
102 | 295 | |
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 | ||
103 | 302 | for (int i = 0; i < LABELS_SZ; i++) { |
104 | 303 | m_label [i] = Gtk::manage (new Gtk::Label (clabels [i])); |
105 | 304 | m_label [i]->set_alignment (0, 0.5); |
125 | 324 | blank2->set_text (" "); |
126 | 325 | |
127 | 326 | 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) | |
129 | 331 | 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 | |
134 | 339 | |
135 | 340 | table->set_row_spacings (0); |
136 | 341 | 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); | |
141 | 352 | |
142 | 353 | m_entry->signal_changed ().connect ( |
143 | 354 | mem_fun (*this, &VerifyControl::on_entry_changed)); |
162 | 373 | |
163 | 374 | if (m_test_line != NULL) { |
164 | 375 | 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)); | |
166 | 377 | } |
167 | 378 | } |
168 | 379 | |
191 | 402 | the m_line_num > 1, then we fetch that line instead. |
192 | 403 | If we are short of lines, that's a failed match. |
193 | 404 | */ |
194 | if (m_parent.get_selected_size () == BACK && m_line_num > 1) | |
405 | if (m_line_num > 1) | |
195 | 406 | { |
407 | Glib::ustring::value_type end_of_line ('\n'); | |
196 | 408 | std::vector<Glib::ustring> vec; |
197 | std::istringstream input (tmp.c_str ()); | |
198 | 409 | 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 ()) { | |
200 | 422 | vec.push_back (token); |
201 | 423 | } |
424 | ||
202 | 425 | if (vec.size () >= m_line_num) { |
203 | 426 | tmp = vec [m_line_num-1]; |
204 | 427 | } |
320 | 543 | * DeckPlayer Member Functions * |
321 | 544 | ******************************************************************************* |
322 | 545 | */ |
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"); | |
326 | 551 | |
327 | 552 | DeckPlayer:: |
328 | 553 | DeckPlayer (VDeck& vdeck_) |
329 | 554 | : |
330 | ||
331 | 555 | #ifdef IS_HILDON |
332 | 556 | Hildon::AppView ("Deck Player"), |
333 | 557 | m_hildon_fullscreen (false), |
334 | 558 | #endif |
335 | ||
336 | 559 | m_close_button (manage (new ButtonWithImageLabel ( |
337 | 560 | 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 */ | |
338 | 569 | m_shuffle_button (manage (new ButtonWithImageLabel ( |
339 | 570 | Gtk::Stock::REFRESH, _("Shuffle")))), |
340 | 571 | m_edit_button (manage (new ButtonWithImageLabel ( |
342 | 573 | _("Edit Deck")))), |
343 | 574 | m_vcard_edit_button (manage (new ButtonWithImageLabel ( |
344 | 575 | Gtk::Stock::DND, _("Edit Card")))), |
576 | #endif | |
345 | 577 | m_selected_side (FRONT), |
346 | 578 | m_notebook (manage (new Gtk::Notebook)), |
347 | 579 | m_play_progress (manage (new Gtk::ProgressBar)), |
580 | m_question_box_width(0), | |
348 | 581 | m_answer_box_width (0), |
349 | 582 | m_verify_control (manage (new VerifyControl (*this))), |
350 | m_bg_white ("white"), | |
351 | m_bg_pink ("pink"), | |
352 | m_bg_black ("black"), | |
353 | 583 | m_deck (vdeck_), |
354 | 584 | m_deck_iter (m_deck.end ()), /* empty deck */ |
355 | 585 | m_is_lesson_learned (false), |
359 | 589 | { |
360 | 590 | trace_with_mask("DeckPlayer::DeckPlayer", GUITRACE); |
361 | 591 | |
592 | Gtk::Viewport *viewport; | |
593 | ||
362 | 594 | set_title ("DeckPlayer"); |
363 | 595 | |
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 | ||
365 | 600 | /** |
366 | 601 | * Not a dialog any more - it is a Bin (AppView) instead. |
367 | 602 | * We handle packaging ourselves and mute all attributes of a |
368 | 603 | * Dialog everywhere down the line. |
369 | 604 | */ |
370 | m_vbox = manage (new Gtk::VBox (false, 2)); | |
605 | m_vbox = manage (new Gtk::VBox (false, 0)); | |
371 | 606 | add (*m_vbox); |
372 | 607 | |
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. | |
376 | 629 | */ |
630 | set_modal (true); | |
631 | set_transient_for (*MAINWIN); | |
377 | 632 | set_resizable (true); |
378 | set_position (Gtk::WIN_POS_CENTER_ALWAYS); | |
379 | 633 | Gdk::Rectangle geom = CONFIG->get_deck_player_geometry (); |
380 | 634 | DL ((GRAPP,"Setting size to width=%d, height=%d\n", |
381 | 635 | 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; | |
415 | 643 | * these contain a width/height ratio as a floating point number. |
416 | 644 | * If a geometry widget is set, the aspect applies to the geometry |
417 | 645 | * widget rather than the entire window. The most common use of these |
422 | 650 | { |
423 | 651 | Gdk::Rectangle& rec = CONFIG->get_deck_player_aspect (); |
424 | 652 | gdouble aspect = rec.get_width () * 1.0 / rec.get_height (); |
425 | ||
426 | Gdk::Geometry answer_box_geometry = | |
427 | { | |
653 | Gdk::Geometry answer_box_geometry = { | |
428 | 654 | geom.get_width(),/*min_width*/ geom.get_height (), /* min_height */ |
429 | 655 | 10000, /* max_width; */ 10000, /* max_height */ |
430 | 656 | -1, /* base_width */ -1, /* base_height */ |
432 | 658 | aspect, /* min_aspect (width/height) */ |
433 | 659 | aspect /* max_aspect (width/height) */ |
434 | 660 | }; |
435 | ||
436 | 661 | set_geometry_hints (*this, answer_box_geometry, |
437 | 662 | Gdk::HINT_ASPECT | Gdk::HINT_MIN_SIZE); |
438 | 663 | } |
439 | #endif | |
440 | ||
441 | /*********************************************** | |
442 | * Fill up notebook with elements * | |
443 | *********************************************** | |
664 | #endif // !(IS_PDA) | |
665 | ||
666 | /** Are we dealing with CardDeck? | |
444 | 667 | */ |
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); | |
478 | 680 | |
479 | 681 | /******************** |
480 | * Back of the card * | |
682 | * Add the notebook * | |
481 | 683 | ******************** |
482 | 684 | */ |
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 | *************************************************************************** | |
485 | 706 | */ |
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); | |
488 | 773 | |
489 | 774 | /* -Back (the answer)- |
490 | 775 | */ |
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) | |
496 | 788 | m_back.set_selectable (); |
497 | 789 | #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); | |
506 | 790 | |
507 | 791 | /* -Separator- |
508 | 792 | */ |
509 | 793 | 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); | |
513 | 798 | |
514 | 799 | /* -Example- |
515 | 800 | */ |
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) | |
520 | 812 | m_example.set_selectable (); |
521 | 813 | #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)))); | |
538 | 827 | 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); | |
541 | 829 | viewport->add (*m_answer_box); |
542 | 830 | |
543 | 831 | /** Without horizontal AUTOMATIC policy, dialog's resizing |
545 | 833 | * keeps growing in size every time there is more text to fit then |
546 | 834 | * size allows. |
547 | 835 | */ |
548 | Gtk::ScrolledWindow* scrollw = Gtk::manage (new Gtk::ScrolledWindow); | |
549 | ||
836 | scrollw = Gtk::manage (new Gtk::ScrolledWindow); | |
550 | 837 | scrollw->set_flags (Gtk::CAN_FOCUS); |
551 | 838 | scrollw->set_shadow_type (Gtk::SHADOW_NONE); |
552 | 839 | scrollw->property_window_placement ().set_value (Gtk::CORNER_TOP_LEFT); |
553 | ||
554 | #ifdef IS_HILDON | |
555 | 840 | scrollw->set_policy (Gtk::POLICY_NEVER , Gtk::POLICY_AUTOMATIC); |
556 | #else | |
557 | scrollw->set_policy (Gtk::POLICY_AUTOMATIC , Gtk::POLICY_AUTOMATIC); | |
558 | #endif | |
559 | 841 | |
560 | 842 | scrollw->add (*viewport); |
561 | 843 | |
562 | 844 | m_notebook->pages ().push_back ( |
563 | 845 | Gtk::Notebook_Helpers::TabElem (*scrollw, _("Back"))); |
564 | 846 | |
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. | |
568 | 852 | */ |
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 | |
595 | 863 | */ |
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)); | |
608 | 870 | |
609 | 871 | /** Fetch out the side history and adjust accordingly |
610 | 872 | */ |
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] | |
621 | 924 | */ |
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 | ||
622 | 932 | m_shuffle_button->signal_clicked ().connect ( |
623 | 933 | mem_fun (*this, &DeckPlayer::on_shuffle_clicked)); |
624 | vbox->pack_start (*m_shuffle_button, false, false, 0); | |
625 | 934 | |
626 | 935 | m_edit_button->signal_clicked ().connect ( |
627 | 936 | mem_fun (*this, &DeckPlayer::on_edit_clicked)); |
628 | vbox->pack_start (*m_edit_button, false, false, 0); | |
629 | 937 | |
630 | 938 | m_vcard_edit_button->signal_clicked ().connect ( |
631 | 939 | 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 | */ | |
634 | 946 | m_count_label.set_alignment (0.5, 0.5); |
635 | 947 | m_count_label.set_padding (0, 0); |
636 | 948 | m_count_label.set_justify (Gtk::JUSTIFY_FILL); |
637 | 949 | |
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 | ||
642 | 959 | get_vbox ()->pack_start (*nb_box); |
960 | #endif | |
961 | ||
643 | 962 | nb_box->show_all (); |
644 | 963 | |
645 | 964 | /** Bottom playback controls toolbar panel |
965 | * -------------------------------------------------- | |
966 | * [spkr] [|<] [<] [>] [>|] [V] [A] [N/M] | |
967 | * -------------------------------------------------- | |
646 | 968 | */ |
647 | m_playit_xpm = Gdk::Pixbuf::create_from_file ( | |
648 | GRAPPDATDIR "/pixmaps/speaker_24.png"); | |
649 | ||
650 | 969 | Glib::RefPtr<Gtk::IconFactory> icon_factory = Gtk::IconFactory::create (); |
651 | 970 | |
971 | //------------------------------------------------------------------------ | |
972 | m_playit_xpm = | |
973 | Gdk::Pixbuf::create_from_file (GRAPPDATDIR "/pixmaps/speaker_24.png"); | |
652 | 974 | Gtk::IconSet spkr_set; |
653 | 975 | Gtk::IconSource spkr_source; |
654 | 976 | spkr_source.set_pixbuf (m_playit_xpm); |
705 | 1027 | m_uimanager = Gtk::UIManager::create (); |
706 | 1028 | m_uimanager->insert_action_group (m_actgroup); |
707 | 1029 | |
708 | #ifndef IS_HILDON | |
1030 | #if !defined(IS_HILDON) | |
709 | 1031 | add_accel_group (m_uimanager->get_accel_group ()); |
710 | 1032 | #endif |
711 | 1033 | |
712 | 1034 | try { |
1035 | #if !defined(IS_PDA) | |
713 | 1036 | Glib::ustring ui_info = |
714 | 1037 | "<ui>" |
715 | 1038 | " <toolbar name='Controls'>" |
724 | 1047 | " <toolitem action='NoClue'/>" |
725 | 1048 | " </toolbar>" |
726 | 1049 | "</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 | |
727 | 1064 | m_uimanager->add_ui_from_string (ui_info); |
728 | 1065 | } |
729 | 1066 | 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 ())); | |
732 | 1068 | } |
733 | 1069 | |
734 | 1070 | m_toolbar_go_first = m_uimanager->get_widget ("/Controls/First"); |
1071 | m_toolbar_go_last = m_uimanager->get_widget ("/Controls/Last"); | |
735 | 1072 | m_toolbar_go_prev = m_uimanager->get_widget ("/Controls/Prev"); |
736 | 1073 | m_toolbar_go_next = m_uimanager->get_widget ("/Controls/Next"); |
737 | m_toolbar_go_last = m_uimanager->get_widget ("/Controls/Last"); | |
738 | 1074 | m_toolbar_know_it = m_uimanager->get_widget ("/Controls/IKnowIt"); |
739 | 1075 | m_toolbar_no_clue = m_uimanager->get_widget ("/Controls/NoClue"); |
740 | 1076 | |
742 | 1078 | * Add input verification control |
743 | 1079 | */ |
744 | 1080 | Gtk::HSeparator* hsep = manage (new Gtk::HSeparator); |
1081 | #ifdef IS_PDA | |
1082 | get_vbox ()->pack_start (*hsep, Gtk::PACK_SHRINK, 0); | |
1083 | #else | |
745 | 1084 | 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 | ||
747 | 1088 | m_verify_control->show_all (); |
748 | 1089 | |
749 | 1090 | /** |
755 | 1096 | ctrl_toolbar->set_toolbar_style (Gtk::TOOLBAR_ICONS); |
756 | 1097 | ctrl_toolbar->set_tooltips (true); |
757 | 1098 | |
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 | */ | |
768 | 1121 | m_close_button->signal_clicked ().connect ( |
769 | 1122 | mem_fun (*this, &DeckPlayer::on_close_clicked)); |
770 | 1123 | |
772 | 1125 | * Setting resize callbacks. The answer box holds |
773 | 1126 | * Back/Separator/Example triplet trapped in the scrollwindow. |
774 | 1127 | */ |
1128 | m_question_box->signal_size_allocate ().connect ( | |
1129 | mem_fun (*this, &DeckPlayer::question_box_size_allocate_cb)); | |
1130 | ||
775 | 1131 | m_answer_box->signal_size_allocate ().connect ( |
776 | 1132 | mem_fun (*this, &DeckPlayer::answer_box_size_allocate_cb)); |
777 | 1133 | |
798 | 1154 | |
799 | 1155 | /** Grand finale |
800 | 1156 | */ |
801 | #ifndef IS_HILDON | |
1157 | #if !defined(IS_HILDON) | |
802 | 1158 | set_icon_from_file (GRAPPDATDIR "/pixmaps/deckplayer_32x32.png"); |
803 | 1159 | #endif |
804 | 1160 | set_sensitivity (); |
807 | 1163 | set_win_name (); |
808 | 1164 | show_deck (); |
809 | 1165 | switch_side (); |
1166 | ||
810 | 1167 | show_all_children (); |
811 | 1168 | |
812 | 1169 | m_initialized = true; |
816 | 1173 | // Utilities |
817 | 1174 | //============================================================================== |
818 | 1175 | // |
1176 | ||
1177 | ||
1178 | gint | |
1179 | DeckPlayer:: | |
1180 | run () | |
1181 | { | |
1182 | trace_with_mask("DeckPlayer::run",GUITRACE); | |
1183 | ||
819 | 1184 | #ifdef IS_HILDON |
820 | ||
821 | gint | |
822 | DeckPlayer:: | |
823 | run () | |
824 | { | |
825 | trace_with_mask("DeckPlayer::run",GUITRACE); | |
826 | ||
827 | 1185 | GRANULE->register_appview (this); |
1186 | m_verify_control->set_focus_on_entry (); | |
1187 | #endif | |
1188 | ||
828 | 1189 | show (); |
829 | m_verify_control->set_focus_on_entry (); | |
830 | ||
831 | 1190 | DL ((APP,"Enter Main::run()\n")); |
832 | 1191 | Gtk::Main::run (); |
833 | 1192 | |
834 | 1193 | DL ((APP,"Exit Main::run()\n")); |
835 | 1194 | return (Gtk::RESPONSE_NONE); |
836 | 1195 | } |
837 | #endif | |
1196 | ||
838 | 1197 | |
839 | 1198 | void |
840 | 1199 | DeckPlayer:: |
844 | 1203 | |
845 | 1204 | #ifdef IS_HILDON |
846 | 1205 | GRANULE->unregister_appview (this); |
1206 | #else | |
1207 | hide (); | |
1208 | #endif | |
847 | 1209 | |
848 | 1210 | DL ((GRAPP,"Call Main::quit()\n")); |
849 | 1211 | Gtk::Main::quit (); |
850 | #else | |
851 | hide (); | |
852 | #endif | |
853 | 1212 | } |
854 | 1213 | |
855 | 1214 | void |
893 | 1252 | |
894 | 1253 | clear_text (); |
895 | 1254 | |
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 | { | |
897 | 1257 | while (!markup_is_valid ((*m_deck_iter))) { |
898 | 1258 | Gtk::MessageDialog em ( |
899 | 1259 | _("The card you are about to see has invalid markup.\n" |
904 | 1264 | em.hide (); |
905 | 1265 | on_vcard_edit_clicked (true); |
906 | 1266 | } |
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 | } | |
910 | 1300 | |
911 | 1301 | if ((*m_deck_iter)->get_reversed ()) { |
912 | 1302 | m_notebook->set_current_page (BACK); |
917 | 1307 | adjust_count (); |
918 | 1308 | } |
919 | 1309 | |
920 | #ifndef IS_HILDON | |
1310 | #if !defined(IS_HILDON) | |
921 | 1311 | /** Calling set_focus_on_entry() causes crash with Maemo 2.0 when |
922 | 1312 | * you open CardFile twice in the row. |
923 | 1313 | * No clue - investigate later. |
925 | 1315 | m_verify_control->set_focus_on_entry (); |
926 | 1316 | #endif |
927 | 1317 | |
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 | */ | |
951 | 1318 | } |
952 | 1319 | |
953 | 1320 | void |
979 | 1346 | m_toolbar_no_clue ->set_sensitive (false); |
980 | 1347 | } |
981 | 1348 | else { |
1349 | #if !defined(IS_PDA) | |
982 | 1350 | m_toolbar_go_first->set_sensitive (false); |
1351 | m_toolbar_go_last ->set_sensitive (false); | |
1352 | #endif | |
983 | 1353 | m_toolbar_go_prev ->set_sensitive (false); |
984 | 1354 | m_toolbar_go_next ->set_sensitive (false); |
985 | m_toolbar_go_last ->set_sensitive (false); | |
986 | 1355 | } |
987 | 1356 | } |
988 | 1357 | |
997 | 1366 | } |
998 | 1367 | DL ((GRAPP,"Deck is empty\n")); |
999 | 1368 | |
1000 | if (m_deck.empty ()) { | |
1369 | if (m_deck.empty ()) | |
1370 | { | |
1001 | 1371 | m_shuffle_button ->set_sensitive (false); |
1002 | 1372 | m_vcard_edit_button ->set_sensitive (false); |
1003 | ||
1373 | #if !defined(IS_PDA) | |
1004 | 1374 | m_toolbar_go_first ->set_sensitive (false); |
1375 | m_toolbar_go_last ->set_sensitive (false); | |
1376 | #endif | |
1005 | 1377 | m_toolbar_go_prev ->set_sensitive (false); |
1006 | 1378 | m_toolbar_go_next ->set_sensitive (false); |
1007 | m_toolbar_go_last ->set_sensitive (false); | |
1008 | 1379 | } |
1009 | 1380 | else { |
1010 | 1381 | m_shuffle_button ->set_sensitive (true); |
1011 | 1382 | m_vcard_edit_button ->set_sensitive (true); |
1012 | ||
1383 | #if !defined(IS_PDA) | |
1013 | 1384 | m_toolbar_go_first ->set_sensitive (true); |
1385 | m_toolbar_go_last ->set_sensitive (true); | |
1386 | #endif | |
1014 | 1387 | m_toolbar_go_prev ->set_sensitive (true); |
1015 | 1388 | m_toolbar_go_next ->set_sensitive (true); |
1016 | m_toolbar_go_last ->set_sensitive (true); | |
1017 | 1389 | } |
1018 | 1390 | } |
1019 | 1391 | |
1164 | 1536 | trace_with_mask("DeckPlayer::on_radio_selected",GUITRACE); |
1165 | 1537 | |
1166 | 1538 | m_selected_side = selected_; |
1539 | DL ((GRAPP,"selected = %s\n",(m_selected_side == BACK ? "BACK" : "FRONT"))); | |
1540 | ||
1167 | 1541 | m_deck.set_side_selection (m_selected_side); |
1168 | 1542 | 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"))); | |
1173 | 1543 | } |
1174 | 1544 | |
1175 | 1545 | void |
1177 | 1547 | on_sayit_clicked () |
1178 | 1548 | { |
1179 | 1549 | trace_with_mask("DeckPlayer::on_sayit_clicked",GUITRACE); |
1550 | ||
1180 | 1551 | 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); | |
1182 | 1554 | } |
1183 | 1555 | } |
1184 | 1556 | |
1188 | 1560 | { |
1189 | 1561 | trace_with_mask("DeckPlayer::on_shuffle_clicked",GUITRACE); |
1190 | 1562 | |
1191 | if (m_is_real_deck) { | |
1563 | if (m_is_real_deck) | |
1564 | { | |
1192 | 1565 | random_shuffle (m_deck.begin (), m_deck.end ()); |
1193 | /* Gtk::MessageDialog qm (*this, */ | |
1194 | 1566 | Gtk::MessageDialog qm ( |
1195 | 1567 | _("Would you like to make cards\norder changes permanent?"), |
1196 | 1568 | false, |
1199 | 1571 | true); |
1200 | 1572 | qm.add_button (Gtk::Stock::NO, Gtk::RESPONSE_NO); |
1201 | 1573 | 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 | { | |
1203 | 1577 | Deck& real_deck = dynamic_cast<Deck&>(m_deck); |
1204 | 1578 | real_deck.mark_as_modified (); |
1205 | 1579 | } |
1234 | 1608 | DeckView dv (m_deck, idx); |
1235 | 1609 | dv.run (); |
1236 | 1610 | dv_modified = dv.is_modified (); |
1611 | if (dv.appearance_changed ()) { | |
1612 | repaint (); | |
1613 | } | |
1237 | 1614 | } |
1238 | 1615 | |
1239 | 1616 | DL((GRAPP,"Deck size after edit = %d cards (modified = %s)\n", |
1250 | 1627 | CARDBOX->mark_as_modified (); |
1251 | 1628 | show_card (); |
1252 | 1629 | |
1253 | #ifndef IS_HILDON | |
1630 | #if !defined(IS_HILDON) | |
1254 | 1631 | /** Under Hildon, this messes up return chain. |
1255 | 1632 | */ |
1256 | 1633 | on_close_clicked (); |
1279 | 1656 | trace_with_mask("DeckPlayer::on_vcard_edit_clicked",GUITRACE); |
1280 | 1657 | |
1281 | 1658 | if (m_deck_iter != m_deck.end () || m_deck.size () > 0) { |
1659 | hide (); | |
1282 | 1660 | VCard* vc = *m_deck_iter; |
1283 | 1661 | CardView cview (vc); |
1284 | 1662 | int ret = cview.run (disable_cancel_); |
1286 | 1664 | if (ret == Gtk::RESPONSE_OK) { |
1287 | 1665 | show_card (false); |
1288 | 1666 | } |
1667 | show (); | |
1289 | 1668 | } |
1290 | 1669 | else { |
1291 | 1670 | Gtk::MessageDialog em (_("The deck is empty!"), Gtk::MESSAGE_ERROR); |
1387 | 1766 | { |
1388 | 1767 | trace_with_mask("DeckPlayer::on_key_pressed",KEYIN); |
1389 | 1768 | |
1390 | #ifndef IS_HILDON | |
1769 | #if !defined(IS_HILDON) | |
1391 | 1770 | if (evt_->keyval == GDK_F1) { |
1392 | 1771 | MAINWIN->iconify (); |
1393 | 1772 | } |
1556 | 1935 | } |
1557 | 1936 | |
1558 | 1937 | /** |
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 | /** | |
1559 | 1957 | Adjust the size of the 'example' label when size of |
1560 | 1958 | the enclosing VBox is changed by the user via resize. |
1561 | 1959 | */ |
1579 | 1977 | repaint () |
1580 | 1978 | { |
1581 | 1979 | 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 | ||
1586 | 1995 | m_verify_control->repaint (); |
1587 | ||
1588 | 1996 | 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)); | |
1589 | 2007 | } |
1590 | 2008 | |
1591 | 2009 | /** Resize only if geometry stored in Configurator differs |
1595 | 2013 | DeckPlayer:: |
1596 | 2014 | update_geometry () |
1597 | 2015 | { |
1598 | #ifndef IS_HILDON | |
2016 | #if !defined(IS_HILDON) | |
1599 | 2017 | int actual_height = 0; |
1600 | int actual_width = 0; | |
2018 | int actual_width = 0; | |
1601 | 2019 | |
1602 | 2020 | Gdk::Rectangle geom = CONFIG->get_deck_player_geometry (); |
1603 | 2021 | get_size (actual_width, actual_height); |
1650 | 2068 | { |
1651 | 2069 | // trace_with_mask("DeckPlayer::markup_tildas", GUITRACE); |
1652 | 2070 | |
1653 | static const string tilda = "<span foreground=\"red\">~</span>"; | |
2071 | static Glib::ustring tilda ("<span foreground=\"red\">~</span>"); | |
1654 | 2072 | Glib::ustring ret; |
1655 | 2073 | |
1656 | 2074 | if (src_.size () == 0) { |
1672 | 2090 | } |
1673 | 2091 | } |
1674 | 2092 | ret += src_.substr (b); |
1675 | ||
1676 | 2093 | return ret; |
1677 | 2094 | } |
1678 | 2095 | |
1725 | 2142 | |
1726 | 2143 | if (m_selected_side == side_ && CONFIG->auto_pronounce ()) |
1727 | 2144 | { |
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); | |
1733 | 2146 | } |
1734 | 2147 | } |
1735 | 2148 | |
1747 | 2160 | } |
1748 | 2161 | } |
1749 | 2162 | |
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 | } |
0 | 0 | // -*- c++ -*- |
1 | 1 | //------------------------------------------------------------------------------ |
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 $ | |
3 | 3 | //------------------------------------------------------------------------------ |
4 | 4 | // DeckPlayer.h |
5 | 5 | //------------------------------------------------------------------------------ |
52 | 52 | VC_VALIDATED // Entry text validated |
53 | 53 | } VCState; |
54 | 54 | |
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 | **============================================================================= | |
60 | 114 | */ |
61 | 115 | class VerifyControl : public Gtk::Table |
62 | 116 | { |
75 | 129 | void on_entry_changed (); |
76 | 130 | void on_test_line_changed (); |
77 | 131 | |
78 | void attach (Gtk::SpinButton* tl_) { m_test_line = tl_; } | |
132 | void attach (TestLineEntry* tle_) { m_test_line = tle_; } | |
79 | 133 | void repaint () { m_entry->modify_font (CONFIG->get_input_font ()); } |
80 | 134 | |
81 | 135 | private: |
97 | 151 | Gdk::Color m_white; |
98 | 152 | Gdk::Color m_black; |
99 | 153 | |
100 | Gtk::SpinButton* m_test_line; // Which line to compare for answer. | |
154 | TestLineEntry* m_test_line; // Which line to compare for answer. | |
101 | 155 | int m_line_num; // Number of line to test |
102 | 156 | }; |
103 | 157 | |
108 | 162 | #ifdef IS_HILDON |
109 | 163 | class DeckPlayer : public Hildon::AppView |
110 | 164 | #else |
111 | class DeckPlayer : public Gtk::Dialog | |
165 | class DeckPlayer : public Gtk::Window | |
112 | 166 | #endif |
113 | 167 | { |
114 | 168 | public: |
115 | 169 | DeckPlayer (VDeck& vdeck_); |
116 | 170 | |
117 | #ifdef IS_HILDON | |
171 | //#ifdef IS_HILDON | |
118 | 172 | gint run (); |
119 | #endif | |
173 | //#endif | |
120 | 174 | |
121 | 175 | /** Called in response to pressing <Close> button |
122 | 176 | */ |
123 | 177 | 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_); | |
124 | 183 | |
125 | 184 | /** Called every time VBox that holds |
126 | 185 | the answer size of the card is resized. |
166 | 225 | // -*- Catch and process keyboard events -*- |
167 | 226 | bool on_key_pressed (GdkEventKey* evt_); |
168 | 227 | |
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 | ||
169 | 234 | /** Get the deck pointer for comparison |
170 | 235 | */ |
171 | 236 | VDeck* get_deck () const { return &m_deck; } |
201 | 266 | /// Auto-pronounce word on next/flip action |
202 | 267 | void auto_pronounce_card (SideSelection side_); |
203 | 268 | |
204 | SideSelection get_selected_size () const { return m_selected_side; } | |
269 | SideSelection get_selected_side () const { return m_selected_side; } | |
205 | 270 | |
206 | 271 | /** Remove all newlines and shrink all whitespace. |
207 | 272 | */ |
220 | 285 | void set_sensitivity (); // De-sensetize inappropriate controls |
221 | 286 | void set_win_name (); // Set tile name |
222 | 287 | |
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 | ||
223 | 295 | /** If deck is empty, paralize controls. Deck can be loaded empty, |
224 | 296 | * or become empty once the last card is removed. The reverse |
225 | 297 | * applies as soon as first card is added. |
235 | 307 | */ |
236 | 308 | Glib::ustring get_answer (); |
237 | 309 | |
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 | ||
243 | 310 | /** Pango-markup tildas in the string |
244 | 311 | */ |
245 | 312 | static Glib::ustring markup_tildas (const Glib::ustring& src_); |
252 | 319 | bool check_F7_key (gint keyval_); |
253 | 320 | bool check_F8_key (gint keyval_); |
254 | 321 | |
255 | #ifdef IS_HILDON | |
256 | 322 | Gtk::VBox* get_vbox () { return m_vbox; } |
257 | #endif | |
258 | 323 | |
259 | 324 | private: |
260 | 325 | |
266 | 331 | Gtk::Button* m_shuffle_button; |
267 | 332 | Gtk::Button* m_edit_button; // View/Edit a Deck |
268 | 333 | 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 | |
270 | 335 | Gtk::Label m_count_label; |
271 | 336 | SideSelection m_selected_side; |
272 | 337 | Gtk::Notebook* m_notebook; |
274 | 339 | Gtk::Label m_front; |
275 | 340 | Gtk::Label m_back; |
276 | 341 | 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 */ | |
281 | 348 | |
282 | 349 | VerifyControl* m_verify_control; // optional answer verification entry |
283 | 350 | |
291 | 358 | Glib::RefPtr<Gdk::Pixbuf> m_playit_xpm; // Sound icon |
292 | 359 | Gtk::Image* m_playit_icon; |
293 | 360 | |
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; | |
297 | 371 | |
298 | 372 | VDeck& m_deck; |
299 | 373 | VDeck::cardlist_iterator m_deck_iter; // Position in the Deck |
307 | 381 | bool m_tab_activated; // Leave Tab+Spacebar/Enter event to Dialog |
308 | 382 | bool m_initialized; // Has the object been fully constructed? |
309 | 383 | |
310 | #ifdef IS_HILDON | |
311 | 384 | Gtk::VBox* m_vbox; |
312 | #endif | |
385 | Gtk::HBox* m_navigation_controls_hbox; | |
313 | 386 | }; |
314 | 387 | |
315 | 388 | inline void |
0 | 0 | // -*- c++ -*- |
1 | 1 | //------------------------------------------------------------------------------ |
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 $ | |
3 | 3 | //------------------------------------------------------------------------------ |
4 | 4 | // DeckView.cpp |
5 | 5 | //------------------------------------------------------------------------------ |
37 | 37 | using sigc::bind; |
38 | 38 | using sigc::mem_fun; |
39 | 39 | |
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 | //------------------------------------------------------------------------------ | |
40 | 51 | DeckView:: |
41 | 52 | DeckView (VDeck& deck_, int selected_row_) |
42 | 53 | : |
43 | 54 | #ifdef IS_HILDON |
44 | 55 | Hildon::AppView ("Deck View"), |
45 | 56 | #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 "))), | |
58 | 57 | m_label_count (manage (new Gtk::Label ("0 cards"))), |
59 | 58 | m_deck (deck_), |
60 | 59 | m_row_idx (selected_row_), |
62 | 61 | { |
63 | 62 | trace_with_mask("DeckView::DeckView", GUITRACE); |
64 | 63 | |
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 | ********************************/ | |
65 | 129 | set_title("Deck View"); |
66 | set_border_width (2); | |
67 | 130 | |
68 | 131 | #ifdef IS_HILDON |
69 | 132 | /** |
75 | 138 | add (*m_vbox); |
76 | 139 | set_size_request (672, 396); |
77 | 140 | #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 | |
78 | 149 | 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); | |
82 | 152 | 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 | **************************/ | |
153 | 201 | m_scrollwin = manage (new Gtk::ScrolledWindow); |
154 | 202 | m_scrollwin->set_shadow_type (Gtk::SHADOW_ETCHED_OUT); |
155 | 203 | m_scrollwin->set_policy (Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); |
186 | 234 | m_list_store_ref->set_sort_func ( |
187 | 235 | 1, (mem_fun (*this, &DeckView::on_sort_compare_back))); |
188 | 236 | |
189 | /** Create TreeView | |
190 | */ | |
237 | /****************************** | |
238 | * Create TreeView | |
239 | ******************************/ | |
191 | 240 | DL((GRAPP,"Create TreeView\n")); |
192 | 241 | m_tree_view.set_model (m_list_store_ref); |
193 | 242 | m_tree_view.set_rules_hint (); |
195 | 244 | Gtk::TreeView::Column* column; |
196 | 245 | Gtk::CellRendererText* renderer; |
197 | 246 | |
198 | /** Front: Column | |
199 | */ | |
247 | /****************************** | |
248 | * Front: Column | |
249 | ******************************/ | |
200 | 250 | column = Gtk::manage (new Gtk::TreeView::Column ("Front")); |
201 | 251 | m_tree_view.append_column (*column); |
202 | 252 | renderer = Gtk::manage (new Gtk::CellRendererText); |
206 | 256 | m_columns.m_front_row); |
207 | 257 | |
208 | 258 | column->set_sizing (Gtk::TREE_VIEW_COLUMN_FIXED); |
209 | column->set_fixed_width (140); | |
210 | 259 | 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 | ******************************/ | |
214 | 269 | column->set_sort_column_id (m_columns.m_front_row); |
215 | 270 | column->set_sort_indicator (true); |
216 | 271 | column->signal_clicked ().connect ( |
217 | 272 | mem_fun (*this, &DeckView::on_column_sorted)); |
218 | 273 | |
219 | /** Back: Column | |
220 | */ | |
274 | /****************************** | |
275 | * Back: Column | |
276 | ******************************/ | |
221 | 277 | column = Gtk::manage (new Gtk::TreeView::Column ("Back")); |
222 | 278 | m_tree_view.append_column (*column); |
223 | 279 | renderer = Gtk::manage (new Gtk::CellRendererText); |
229 | 285 | column->set_sizing (Gtk::TREE_VIEW_COLUMN_FIXED); |
230 | 286 | column->set_fixed_width (140); |
231 | 287 | |
232 | /** Enable column sorting | |
233 | */ | |
288 | /**************************** | |
289 | * Enable column sorting | |
290 | ****************************/ | |
234 | 291 | column->set_sort_column_id (m_columns.m_back_row); |
235 | 292 | column->set_sort_indicator (true); |
236 | 293 | column->signal_clicked ().connect ( |
241 | 298 | m_tree_sel_ref->signal_changed ().connect ( |
242 | 299 | mem_fun (*this, &DeckView::on_card_selected)); |
243 | 300 | |
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 | ||
244 | 305 | m_scrollwin->add (m_tree_view); |
245 | 306 | |
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); | |
270 | 312 | 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 | ||
271 | 328 | 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)); | |
272 | 344 | |
273 | 345 | #ifdef IS_HILDON |
274 | 346 | /** |
281 | 353 | hbuttonbox->set_spacing (6); |
282 | 354 | hbuttonbox->set_border_width (6); |
283 | 355 | |
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 | ||
286 | 362 | #endif |
287 | 363 | |
288 | 364 | set_cards_count (); |
289 | ||
290 | 365 | show_all (); |
291 | 366 | |
292 | 367 | /** Select the same row (card) that the DeckPlayer has selected, |
310 | 385 | set_sensitivity (); |
311 | 386 | set_win_name (); |
312 | 387 | |
313 | #ifndef IS_HILDON | |
388 | #if !defined(IS_HILDON) && !defined (IS_PDA) | |
314 | 389 | set_icon_from_file (GRAPPDATDIR "/pixmaps/deckview_32x32.png"); |
315 | 390 | #endif |
316 | 391 | |
327 | 402 | set_cards_count () |
328 | 403 | { |
329 | 404 | std::ostringstream os; |
405 | ||
330 | 406 | os << m_deck.size () << " cards."; |
331 | 407 | m_label_count->set_text (os.str ()); |
332 | 408 | } |
335 | 411 | // Callbacks |
336 | 412 | //------------------------------------------------------------------------------ |
337 | 413 | |
414 | //#ifdef IS_HILDON | |
415 | gint | |
416 | DeckView:: | |
417 | run () | |
418 | { | |
419 | trace_with_mask("DeckView::run",GUITRACE); | |
420 | ||
338 | 421 | #ifdef IS_HILDON |
339 | gint | |
340 | DeckView:: | |
341 | run () | |
342 | { | |
343 | trace_with_mask("DeckView::run",GUITRACE); | |
344 | ||
345 | 422 | GRANULE->register_appview (this); |
423 | #endif | |
346 | 424 | Gtk::Main::run (); |
347 | 425 | return (Gtk::RESPONSE_NONE); |
348 | 426 | } |
349 | #endif | |
427 | //#endif | |
350 | 428 | |
351 | 429 | void |
352 | 430 | DeckView:: |
357 | 435 | #ifdef IS_HILDON |
358 | 436 | hide (); |
359 | 437 | GRANULE->unregister_appview (this); |
438 | #endif | |
360 | 439 | DL ((GRAPP,"Call Main::quit()\n")); |
361 | 440 | Gtk::Main::quit (); |
362 | #endif | |
363 | 441 | } |
364 | 442 | |
365 | 443 | void |
421 | 499 | { |
422 | 500 | trace_with_mask("DeckView::on_add_clicked", GUITRACE); |
423 | 501 | |
502 | hide (); | |
503 | ||
424 | 504 | CardView cview (new Card); |
425 | 505 | |
426 | 506 | int ret = cview.run (*this); |
439 | 519 | DL((GRAPP|ASSA::ASSAERR, "Unexpected response = %d, " |
440 | 520 | "see /path/to/gtkmm/dialog.h for details.\n", ret)); |
441 | 521 | } |
522 | show (); | |
442 | 523 | } |
443 | 524 | |
444 | 525 | void |
455 | 536 | Gtk::TreeModel::Row row = *m_list_store_ref->children ()[m_row_idx]; |
456 | 537 | VCard* card_iter = row [m_columns.m_card]; |
457 | 538 | |
458 | #ifdef IS_HILDON | |
539 | //#ifdef IS_HILDON | |
459 | 540 | hide (); |
460 | #endif | |
541 | //#endif | |
461 | 542 | |
462 | 543 | CardView cview (card_iter); |
463 | 544 | int ret = cview.run (); |
469 | 550 | Granule::trim_multiline(card_iter->get_answer ()); |
470 | 551 | } |
471 | 552 | |
472 | #ifdef IS_HILDON | |
553 | //#ifdef IS_HILDON | |
473 | 554 | show (); |
474 | #endif | |
555 | //#endif | |
475 | 556 | } |
476 | 557 | |
477 | 558 | void |
593 | 674 | #ifdef IS_HILDON |
594 | 675 | DeckInfo deck_info (*HILDONAPPWIN, dynamic_cast<Deck&>(m_deck)); |
595 | 676 | deck_info.run (); |
677 | m_repaint_player = deck_info.appearance_changed (); | |
596 | 678 | #else |
597 | 679 | DeckInfo deck_info (*this, dynamic_cast<Deck&>(m_deck)); |
598 | 680 | deck_info.run (); |
681 | m_repaint_player = deck_info.appearance_changed (); | |
599 | 682 | #endif |
600 | 683 | |
601 | 684 | } |
852 | 935 | |
853 | 936 | DECKMGR->save_deck_cb (); |
854 | 937 | } |
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 | } |
0 | 0 | // -*- c++ -*- |
1 | 1 | //------------------------------------------------------------------------------ |
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 $ | |
3 | 3 | //------------------------------------------------------------------------------ |
4 | 4 | // DeckView.h |
5 | 5 | //------------------------------------------------------------------------------ |
30 | 30 | #include <gtkmm/treeview.h> |
31 | 31 | #include <gtkmm/liststore.h> |
32 | 32 | #include <gtkmm/scrolledwindow.h> |
33 | #include <gtkmm/uimanager.h> | |
34 | #include <gtkmm/toolbar.h> | |
33 | 35 | |
34 | 36 | #ifdef IS_HILDON |
35 | 37 | #include <hildon-widgetsmm/appview.h> |
47 | 49 | DeckView (VDeck& deck_, int selected_row_); |
48 | 50 | ~DeckView (); |
49 | 51 | |
50 | #ifdef IS_HILDON | |
52 | //#ifdef IS_HILDON | |
51 | 53 | gint run (); |
52 | #endif | |
54 | //#endif | |
53 | 55 | |
54 | 56 | /** Has the Deck been modified so that it might invalidate |
55 | 57 | the iterators? Deleting a card and moving card(s) up/down |
58 | 60 | */ |
59 | 61 | bool is_modified () const { return m_modified; } |
60 | 62 | |
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. | |
62 | 69 | */ |
63 | 70 | 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_); | |
64 | 75 | |
65 | 76 | /** Called in response to pressing <Close> button |
66 | 77 | */ |
99 | 110 | |
100 | 111 | void add_new_card (Card* card_); |
101 | 112 | |
113 | /// Return number of cards in the view | |
114 | int get_deck_size () const; | |
115 | ||
102 | 116 | private: |
103 | 117 | /** Column sorting implementation |
104 | 118 | */ |
134 | 148 | Gtk::TreeModelColumn<Glib::ustring> m_back_row; |
135 | 149 | Gtk::TreeModelColumn<VCard*> m_card; // Hidden Card reference. |
136 | 150 | |
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); } | |
141 | 152 | }; |
142 | 153 | |
143 | 154 | const ModelColumns m_columns; |
151 | 162 | Glib::RefPtr<Gtk::TreeSelection> m_tree_sel_ref; |
152 | 163 | |
153 | 164 | 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 | ||
158 | 179 | 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; | |
163 | 180 | |
164 | 181 | Gtk::Label* m_label_count; |
165 | 182 | |
166 | 183 | VDeck& m_deck; |
167 | 184 | 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? | |
169 | 187 | |
170 | 188 | #ifdef IS_HILDON |
171 | 189 | Gtk::VBox* m_vbox; |
173 | 191 | |
174 | 192 | }; |
175 | 193 | |
194 | inline int | |
195 | DeckView:: | |
196 | get_deck_size () const | |
197 | { | |
198 | return (m_deck.size ()); | |
199 | } | |
200 | ||
176 | 201 | #endif /* DECK_VIEWER_H */ |
0 | 0 | // -*- c++ -*- |
1 | 1 | //------------------------------------------------------------------------------ |
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 $ | |
3 | 3 | //------------------------------------------------------------------------------ |
4 | 4 | // EditControls.cpp |
5 | 5 | //------------------------------------------------------------------------------ |
15 | 15 | // |
16 | 16 | //------------------------------------------------------------------------------ |
17 | 17 | |
18 | #include <gtkmm/table.h> | |
18 | #include <sstream> | |
19 | ||
20 | #include <gtkmm/stock.h> | |
21 | #include <gtkmm/iconfactory.h> | |
19 | 22 | |
20 | 23 | #include "Granule-main.h" |
21 | 24 | #include "EditControls.h" |
25 | #include "MyInputDialog.h" | |
26 | ||
27 | #include "Intern.h" | |
22 | 28 | |
23 | 29 | using Gtk::Image; |
24 | 30 | |
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 | */ | |
25 | 63 | EditControls:: |
26 | 64 | 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) | |
29 | 68 | { |
30 | 69 | trace_with_mask("EditControls::EditControls", GUITRACE); |
31 | 70 | |
71 | Gtk::Button* button; | |
32 | 72 | 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 (); | |
45 | 74 | |
46 | 75 | pixbuf_ref = Gdk::Pixbuf::create_from_file ( |
47 | 76 | 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 | ||
51 | 82 | pixbuf_ref = Gdk::Pixbuf::create_from_file ( |
52 | 83 | 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")); | |
55 | 88 | |
56 | 89 | pixbuf_ref = Gdk::Pixbuf::create_from_file ( |
57 | 90 | 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")); | |
60 | 95 | |
61 | 96 | pixbuf_ref = Gdk::Pixbuf::create_from_file ( |
62 | 97 | 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")); | |
65 | 102 | |
66 | 103 | pixbuf_ref = Gdk::Pixbuf::create_from_file ( |
67 | 104 | 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")); | |
70 | 109 | |
71 | 110 | pixbuf_ref = Gdk::Pixbuf::create_from_file ( |
72 | 111 | 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")); | |
75 | 116 | |
76 | 117 | pixbuf_ref = Gdk::Pixbuf::create_from_file ( |
77 | 118 | 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")); | |
80 | 123 | |
81 | 124 | pixbuf_ref = Gdk::Pixbuf::create_from_file ( |
82 | 125 | 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")); | |
85 | 130 | |
86 | 131 | pixbuf_ref = Gdk::Pixbuf::create_from_file ( |
87 | 132 | 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")); | |
90 | 137 | |
91 | 138 | pixbuf_ref = Gdk::Pixbuf::create_from_file ( |
92 | 139 | 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 (); | |
108 | 167 | |
109 | 168 | /** unset_flags () takes buttons out of the dialog's focus chain. |
110 | 169 | There is no other way it can be achieved with set_focus_chain() |
111 | 170 | in CardView dialog. I tried it and it doesn't work. |
112 | 171 | */ |
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 | { | |
115 | 175 | button = manage (new Gtk::Button ()); |
116 | 176 | 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 ())); | |
127 | 186 | iter++; |
128 | 187 | } |
129 | 188 | |
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); | |
131 | 224 | } |
132 | 225 | |
133 | 226 | void |
135 | 228 | on_edit_button_clicked (const string& action_) |
136 | 229 | { |
137 | 230 | 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 | } | |
140 | 238 | |
141 | 239 | Gtk::TextBuffer::iterator iter; |
142 | 240 | Gtk::TextBuffer::iterator start_iter; |
148 | 246 | Comparing the marks, however, turned out to be useless - |
149 | 247 | you ought to compares iterators only. |
150 | 248 | */ |
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")); | |
153 | 252 | if (action_ == "paste") { |
154 | 253 | Glib::RefPtr<Gtk::Clipboard> ref_clipboard = Gtk::Clipboard::get (); |
155 | 254 | ref_clipboard->request_text ( |
156 | 255 | sigc::mem_fun(*this,&EditControls::on_clipboard_text_received)); |
157 | 256 | } |
158 | return; | |
159 | } | |
160 | ||
161 | if (start_iter == end_iter) { | |
162 | DL ((GRAPP,"Selection size is 0.\n")); | |
163 | 257 | return; |
164 | 258 | } |
165 | 259 | |
215 | 309 | else if (action_ == "remove_tags") { |
216 | 310 | remove_tags (mb, me); |
217 | 311 | } |
312 | else if (action_ == "add_index") { | |
313 | add_index (mb, me); | |
314 | } | |
218 | 315 | else { |
219 | 316 | DL ((GRAPP,"Unexpected action!\n")); |
220 | 317 | } |
236 | 333 | { |
237 | 334 | trace_with_mask("EditControls::remove_tags",GUITRACE); |
238 | 335 | |
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; | |
242 | 340 | Gtk::TextBuffer::iterator next_ch = begin_mark_->get_iter (); |
243 | 341 | Gtk::TextBuffer::iterator last_ch = end_mark_->get_iter (); |
244 | 342 | |
246 | 344 | display_unichar_at (next_ch), |
247 | 345 | display_unichar_at (last_ch))); |
248 | 346 | |
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 | { | |
252 | 351 | start_mark = m_textbuf->create_mark ("start", next_ch); |
253 | 352 | next_ch++; |
254 | 353 | |
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))); | |
258 | 355 | |
259 | 356 | while (next_ch && next_ch != last_ch) { |
260 | 357 | if (next_ch.get_char () == close_brace) { |
267 | 364 | |
268 | 365 | next_ch = start_mark->get_iter (); |
269 | 366 | 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))); | |
274 | 367 | break; |
275 | 368 | } |
276 | 369 | next_ch++; |
277 | 370 | |
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))); | |
281 | 373 | } |
282 | 374 | m_textbuf->delete_mark (start_mark); |
283 | 375 | } |
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++; | |
290 | 486 | } |
291 | 487 | |
292 | 488 | /** |
322 | 518 | if (m_textbuf != text_view_->get_buffer ()) { |
323 | 519 | m_textbuf->place_cursor (m_textbuf->begin ()); // cancel old select |
324 | 520 | 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 |
0 | 0 | // -*- c++ -*- |
1 | 1 | //------------------------------------------------------------------------------ |
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 $ | |
3 | 3 | //------------------------------------------------------------------------------ |
4 | 4 | // EditControls.h |
5 | 5 | //------------------------------------------------------------------------------ |
19 | 19 | |
20 | 20 | #include <gtkmm/box.h> |
21 | 21 | #include <gtkmm/textview.h> |
22 | #include <gtkmm/box.h> | |
23 | 22 | #include <gdkmm/pixbuf.h> |
24 | 23 | #include <gtkmm/image.h> |
25 | 24 | #include <gtkmm/clipboard.h> |
25 | #include <gtkmm/uimanager.h> | |
26 | #include <gtkmm/toolbar.h> | |
26 | 27 | |
27 | 28 | using sigc::bind; |
28 | 29 | using sigc::mem_fun; |
33 | 34 | using std::vector; |
34 | 35 | using std::string; |
35 | 36 | |
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 | */ | |
40 | 67 | class EditControls : public Gtk::HBox |
41 | 68 | { |
42 | 69 | public: |
45 | 72 | void on_focus_changed (Gtk::TextView* text_view_); |
46 | 73 | void on_clipboard_text_received (const Glib::ustring& text_); |
47 | 74 | |
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 | ||
48 | 80 | private: |
49 | 81 | void on_edit_button_clicked (const string& action_); |
50 | 82 | |
51 | 83 | void remove_tags (Glib::RefPtr<Gtk::TextBuffer::Mark> begin_mark_, |
52 | 84 | Glib::RefPtr<Gtk::TextBuffer::Mark> end_mark_); |
53 | 85 | |
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_); | |
60 | 92 | |
61 | 93 | 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; | |
63 | 109 | typedef vector<icon_t> icon_list_t; |
64 | 110 | |
65 | 111 | 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 | |
67 | 123 | }; |
68 | 124 | |
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 | ||
69 | 134 | #endif /* EDIT_CONTROLS_H */ |
0 | 0 | // -*- c++ -*- |
1 | 1 | // generated by glade-- |
2 | 2 | //------------------------------------------------------------------------------ |
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 $ | |
4 | 4 | //------------------------------------------------------------------------------ |
5 | 5 | // GeneralPref.cpp |
6 | 6 | //------------------------------------------------------------------------------ |
89 | 89 | { |
90 | 90 | trace_with_mask("GeneralPref::GeneralPref",GUITRACE); |
91 | 91 | |
92 | #if defined(IS_HILDON) || defined(IS_PDA) | |
93 | set_border_width(0); | |
94 | #else | |
92 | 95 | set_border_width(14); |
96 | #endif | |
93 | 97 | |
94 | 98 | Gtk::Label* empty_label; |
95 | 99 | |
161 | 165 | |
162 | 166 | Gtk::VBox* scrollw_vbox = Gtk::manage (new Gtk::VBox (false, 0)); |
163 | 167 | |
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 | */ | |
164 | 178 | scrollw_vbox->pack_start (*frame1, Gtk::PACK_SHRINK, 0); |
179 | ||
180 | /** [] Record all dynamic links in CardFile as relative paths | |
181 | */ | |
165 | 182 | scrollw_vbox->pack_start (*frame2, Gtk::PACK_SHRINK, 0); |
183 | ||
184 | /** [] Disable all shortcuts in DeckPlayer dialog | |
185 | */ | |
166 | 186 | 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); | |
172 | 187 | |
173 | 188 | scrollw->add (*scrollw_vbox); |
174 | 189 | pack_start (*scrollw); |
0 | 0 | // -*- c++ -*- |
1 | 1 | // generated by glade-- |
2 | 2 | //------------------------------------------------------------------------------ |
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 $ | |
4 | 4 | //------------------------------------------------------------------------------ |
5 | 5 | // GeneralPref.h |
6 | 6 | //------------------------------------------------------------------------------ |
30 | 30 | class PrefWindow; |
31 | 31 | |
32 | 32 | /**----------------------------------------------------------------------------- |
33 | Compound history size option | |
34 | -------------------------------------------------------------------------------- | |
35 | */ | |
33 | ** Compound history size option | |
34 | **----------------------------------------------------------------------------- | |
35 | */ | |
36 | 36 | class HistSizeBox : public Gtk::HBox |
37 | 37 | { |
38 | 38 | public: |
0 | 0 | // -*- c++ -*- |
1 | 1 | //------------------------------------------------------------------------------ |
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 $ | |
3 | 3 | //------------------------------------------------------------------------------ |
4 | 4 | // GeometryPrefs.cpp |
5 | 5 | //------------------------------------------------------------------------------ |
46 | 46 | Gtk::Label* hidden_label; |
47 | 47 | Gtk::Adjustment* spin_button_adj; |
48 | 48 | |
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)); | |
63 | 61 | |
64 | 62 | m_label->set_alignment(Gtk::ALIGN_RIGHT, Gtk::ALIGN_CENTER); |
65 | 63 | m_label->set_padding(0,0); |
81 | 79 | m_wspin_button->set_digits(0); |
82 | 80 | m_wspin_button->set_wrap(false); |
83 | 81 | |
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); | |
86 | 84 | |
87 | 85 | m_hlabel->set_alignment(0.5,0.5); |
88 | 86 | m_hlabel->set_padding(0,0); |
217 | 215 | } |
218 | 216 | |
219 | 217 | /**----------------------------------------------------------------------------- |
220 | GeometryPrefs methods | |
221 | -------------------------------------------------------------------------------- | |
222 | */ | |
218 | ** GeometryPrefs methods | |
219 | **----------------------------------------------------------------------------- | |
220 | **/ | |
223 | 221 | GeometryPrefs:: |
224 | GeometryPrefs (PrefWindow& pwin_) : | |
222 | GeometryPrefs (PrefWindow& pwin_) | |
223 | : | |
225 | 224 | Gtk::VBox (false, 0), |
226 | 225 | m_pref_window (pwin_), |
227 | 226 | m_change_in_progress (false) |
229 | 228 | int i; |
230 | 229 | trace_with_mask("GeometryPrefs::GeometryPrefs",GUITRACE); |
231 | 230 | |
231 | #ifdef IS_HILDON | |
232 | set_border_width(0); | |
233 | #else | |
234 | set_border_width(14); | |
235 | #endif | |
236 | ||
232 | 237 | m_table = Gtk::manage (new Gtk::Table (3, 3, false)); |
233 | 238 | |
234 | 239 | for (i = 0; i < WIN_ENTRY_SZ; i++) { |
238 | 243 | |
239 | 244 | m_aspect = Gtk::manage (new AspectBox); |
240 | 245 | 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 ("")); | |
245 | 250 | |
246 | 251 | hidden_label->set_alignment (0.5,0.5); |
247 | 252 | hidden_label->set_padding (0,0); |
254 | 259 | options_frame->set_border_width (0); |
255 | 260 | options_frame->set_label_align (1, 1); |
256 | 261 | 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); | |
260 | 263 | |
261 | 264 | /** Pack everything. Center the table in the middle |
262 | with two hidden buttons. | |
265 | ** with two hidden buttons. | |
266 | ** Update: left-align GeometryBox. | |
263 | 267 | */ |
264 | 268 | 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 ("")); | |
266 | 271 | Gtk::Label* post_hidden = manage (new Gtk::Label ("")); |
267 | hbox->pack_start (*pre_hidden, Gtk::PACK_EXPAND_WIDGET); | |
272 | ||
268 | 273 | hbox->pack_start (*m_table, Gtk::PACK_SHRINK, 4); |
269 | 274 | hbox->pack_start (*post_hidden, Gtk::PACK_EXPAND_WIDGET); |
270 | 275 | |
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 | |
273 | 278 | * smart packing. |
274 | 279 | */ |
275 | #ifdef IS_HILDON | |
276 | ||
277 | 280 | Gtk::ScrolledWindow* scrollw = Gtk::manage (new Gtk::ScrolledWindow); |
278 | 281 | scrollw->set_flags (Gtk::CAN_FOCUS); |
279 | 282 | scrollw->set_shadow_type (Gtk::SHADOW_NONE); |
0 | 0 | // -*- c++ -*- |
1 | 1 | // Generated by assa-genesis |
2 | 2 | //------------------------------------------------------------------------------ |
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 $ | |
4 | 4 | //------------------------------------------------------------------------------ |
5 | 5 | // Granule-main.cpp |
6 | 6 | //------------------------------------------------------------------------------ |
37 | 37 | " -D, --log-file=NAME - Write debug to NAME file \n" |
38 | 38 | " -z, --log-size=NUM - Maximum size debug file can reach (dfl: is 10Mb) \n" |
39 | 39 | " \n" |
40 | " --config-file=NAME - Specify a fully-qualified path to the \n" | |
41 | " alternative configuration file. \n" | |
42 | " \n" | |
40 | 43 | " -d, --log-stdout=YESNO - Write debug to standard output \n" |
41 | 44 | " \n" |
42 | 45 | " --with-log-server=YESNO - Redirect log messages to the log server \n" |
51 | 54 | " 0x00000010 - (GEOM) Log geometry changes \n" |
52 | 55 | " 0x02000000 - (KEYIN) Log keyboard input activitiy \n" |
53 | 56 | " \n" |
54 | " -h, --help - Print this messag \n" | |
55 | " -v, --version - Print version number \n" | |
56 | " \n" | |
57 | 57 | " --secs-in-day=NUM - Number of seconds in a day (used for debugging) \n" |
58 | 58 | " --secs-in-week=NUM - Number of seconds in a week (used for debugging) \n" |
59 | 59 | " --dump-cardboxes=YESNO - Dump content of each cardbox to a file, \n" |
64 | 64 | " o --disable-crash-dialog - when application crashes \n" |
65 | 65 | " suppress GNOME crash \n" |
66 | 66 | " dialog. \n" |
67 | " \n" | |
68 | " -h, --help - Print this messag \n" | |
69 | " -v, --version - Print version number \n" | |
70 | " \n" | |
67 | 71 | " \n"; |
68 | 72 | //------------------------------------------------------------------------------ |
69 | 73 |
0 | 0 | // -*- c++ -*- |
1 | 1 | // Generated by assa-genesis |
2 | 2 | //------------------------------------------------------------------------------ |
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 $ | |
4 | 4 | //------------------------------------------------------------------------------ |
5 | 5 | // Granule-main.h |
6 | 6 | //------------------------------------------------------------------------------ |
25 | 25 | using ASSA::TRACE; |
26 | 26 | using ASSA::ALL; |
27 | 27 | |
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 | |
33 | 34 | }; |
34 | 35 | |
35 | 36 | typedef enum { |
41 | 42 | |
42 | 43 | typedef enum { |
43 | 44 | FRONT, |
44 | BACK | |
45 | BACK, | |
46 | EXAMPLE | |
45 | 47 | } SideSelection; |
46 | 48 | |
47 | 49 | typedef enum { |
74 | 76 | COMMA_SEP, |
75 | 77 | } CSVSeparator; |
76 | 78 | |
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 | ||
77 | 102 | /*------------------------------------------------------------------------------ |
78 | 103 | * Some useful defines and define macros |
79 | 104 | *------------------------------------------------------------------------------ |
0 | 0 | // -*- c++ -*- |
1 | 1 | // Generated by assa-genesis |
2 | 2 | //------------------------------------------------------------------------------ |
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 $ | |
4 | 4 | //------------------------------------------------------------------------------ |
5 | 5 | // Granule.cpp |
6 | 6 | //------------------------------------------------------------------------------ |
25 | 25 | #include <unistd.h> // access(2) |
26 | 26 | #include <stdlib.h> // system(3) |
27 | 27 | |
28 | ||
29 | #include <gtk/gtklabel.h> | |
28 | 30 | #include <glibmm/ustring.h> |
29 | 31 | #include <gtkmm/main.h> |
30 | 32 | #include <gtkmm/rc.h> |
82 | 84 | */ |
83 | 85 | /* m_mask = GRAPP | DECK | GUITRACE | ASSA::ASSAERR; */ |
84 | 86 | m_mask = 0; |
85 | ||
86 | 87 | m_log_file = "granule.log"; |
87 | 88 | } |
88 | 89 | |
106 | 107 | std::string v; |
107 | 108 | bool parse_default_rc = true; |
108 | 109 | |
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 { | |
120 | 131 | parse_default_rc = false; |
121 | 132 | } |
122 | 133 | } |
123 | else { | |
124 | parse_default_rc = false; | |
125 | } | |
126 | } | |
127 | ||
134 | } | |
128 | 135 | #else /* WIN32 */ |
129 | ||
130 | 136 | rcfile = "granule.ini"; // same place where the binary is. |
131 | ||
132 | #endif | |
133 | ||
137 | #endif | |
138 | ||
134 | 139 | /** |
135 | 140 | * Load [options] section of the configuration file. |
136 | 141 | */ |
149 | 154 | |
150 | 155 | ASSA::GenServer::init (argc_, argv_, help_info_); |
151 | 156 | |
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 | ||
152 | 165 | /* |
153 | 166 | TRACE = 0x00001 |
154 | 167 | APP = 0x00002 (GRAPP) |
160 | 173 | FORK = 0x40000 |
161 | 174 | */ |
162 | 175 | |
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 | |
172 | 188 | } |
173 | 189 | } |
174 | ||
175 | 190 | LOGGER->enable_groups (m_mask); |
176 | 191 | |
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. | |
179 | 194 | */ |
180 | 195 | m_default_entity_loader = xmlGetExternalEntityLoader(); |
181 | 196 | xmlSetExternalEntityLoader (my_xml_entity_loader); |
211 | 226 | Granule:: |
212 | 227 | dump_package_envs () |
213 | 228 | { |
214 | DL((APP,"\n= Environment variables set by Autoconfig: =\n" | |
229 | DL((APP,"\n= Environment variables set by automake: =\n" | |
215 | 230 | "\n" |
216 | 231 | "\tGRAPPDATDIR..: \"%s\"\n" |
217 | 232 | "\tGRAPPXMLDIR...: \"%s\"\n" |
223 | 238 | "\tIS_HILDON.....: \"yes\"\n" |
224 | 239 | #else |
225 | 240 | "\tIS_HILDON.....: \"no\"\n" |
241 | #endif | |
242 | #ifdef IS_PDA | |
243 | "\tIS_PDA........: \"yes\"\n" | |
244 | #else | |
245 | "\tIS_PDA........: \"no\"\n" | |
226 | 246 | #endif |
227 | 247 | "\n", |
228 | 248 | GRAPPDATDIR, GRAPPXMLDIR, DATDIR, LOCALEDIR, PACKAGE, VERSION)); |
522 | 542 | |
523 | 543 | #endif // IS_HILDON |
524 | 544 | |
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 | } |
0 | 0 | // -*- c++ -*- |
1 | 1 | // Generated by assa-genesis |
2 | 2 | //------------------------------------------------------------------------------ |
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 $ | |
4 | 4 | //------------------------------------------------------------------------------ |
5 | 5 | // Granule.h |
6 | 6 | //------------------------------------------------------------------------------ |
29 | 29 | using std::string; |
30 | 30 | #include <stack> |
31 | 31 | |
32 | #include <gtk/gtkcontainer.h> | |
32 | 33 | #include <gtkmm.h> |
33 | 34 | |
34 | 35 | #ifdef IS_HILDON |
83 | 84 | void unregister_appview (Hildon::AppView* view_); |
84 | 85 | #endif |
85 | 86 | |
86 | public: /** Common utilities used everywhere | |
87 | */ | |
87 | public: | |
88 | /** Common utilities used everywhere | |
89 | * | |
90 | * @{ start | |
91 | */ | |
88 | 92 | static gchar* strip_pango_markup (const char* src_); |
89 | 93 | static void remove_common_prefixes (gchar*& src_); |
90 | 94 | static Glib::ustring trim_multiline (const Glib::ustring& text_); |
98 | 102 | @return true on success; false if entry is invalid |
99 | 103 | */ |
100 | 104 | 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 | **/ | |
101 | 118 | |
102 | 119 | private: |
103 | 120 | void dump_package_envs (); |
1 | 1 | //------------------------------------------------------------------------------ |
2 | 2 | // GrappConf.cpp |
3 | 3 | //------------------------------------------------------------------------------ |
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 $ | |
5 | 5 | //------------------------------------------------------------------------------ |
6 | 6 | // Copyright (c) 2004-2006 by Vladislav Grinchenko |
7 | 7 | // |
26 | 26 | |
27 | 27 | |
28 | 28 | #if !defined(WIN32) |
29 | # include <libgen.h> // basename(3), dirname(3) | |
29 | # include <libgen.h> // basename(3), dirname(3) | |
30 | 30 | # include <pwd.h> // getpwnam(2), getlogin(2) |
31 | 31 | #endif |
32 | 32 | |
53 | 53 | */ |
54 | 54 | #if defined(WIN32) |
55 | 55 | |
56 | char *dirname (char *path_) | |
56 | extern char *dirname (const char *path_) | |
57 | 57 | { |
58 | 58 | static char path [MAX_PATH]; |
59 | 59 | |
64 | 64 | return path; |
65 | 65 | } |
66 | 66 | |
67 | char *basename (char* path_) | |
67 | extern char *basename (const char* path_) | |
68 | 68 | { |
69 | 69 | static char path [MAX_PATH]; |
70 | 70 | |
117 | 117 | /******************************************************************************/ |
118 | 118 | GrappConf:: |
119 | 119 | 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), | |
131 | 149 | 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), | |
135 | 153 | m_disable_key_shortcuts (false), |
136 | m_auto_pronounce (false) | |
154 | m_auto_pronounce (false) | |
137 | 155 | { |
138 | 156 | trace_with_mask("GrappConf::GrappConf",GUITRACE); |
139 | 157 | |
327 | 345 | * |
328 | 346 | * [Default] |
329 | 347 | * filesel_path=/path/to/ |
348 | * text_bgcolor="white" | |
349 | * text_fgcolor="black" | |
350 | * sep_color="pink" | |
330 | 351 | * question_font_desc="Sans 14" |
331 | 352 | * answer_font_desc="Sans 14" |
332 | 353 | * example_font_desc="Sans 14" |
333 | 354 | * input_font_desc="Sans 14" |
334 | 355 | * 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" | |
335 | 371 | * mainwin_geometry=430x350 |
336 | 372 | * cardview_geometry_height=643x386 |
337 | 373 | * deckplayer_geometry=583x350 |
353 | 389 | { |
354 | 390 | trace_with_mask("GrappConf::load_config",GUITRACE); |
355 | 391 | |
356 | Glib::ustring usfont; | |
357 | std::string s; | |
392 | Glib::ustring ustr; | |
393 | string s; | |
358 | 394 | int idx; |
359 | 395 | IniFile::const_config_iterator section; |
360 | 396 | |
361 | 397 | if (m_config == NULL) { |
362 | 398 | s = GRANULE->get_config_file (); |
363 | if (s.size () == 0) { | |
399 | if (s.size () == 0 || s == "none") { | |
364 | 400 | s = GRANULE->get_default_config_file (); |
365 | 401 | } |
366 | 402 | m_config = new IniFile (s); |
367 | 403 | if (m_config->load () < 0) { |
368 | DL((APP, "Failed to load configuration file!\n")); | |
404 | DL((GRAPP, "Failed to load configuration file!\n")); | |
369 | 405 | return; |
370 | 406 | } |
407 | DL ((GRAPP,"Loaded configuration from \"%s\"\n", s.c_str ())); | |
371 | 408 | s = ""; |
372 | 409 | } |
373 | 410 | /** Load [History] section |
423 | 460 | if (section != m_config->sect_end ()) { |
424 | 461 | DL((APP,"Scanning [History] section ...\n")); |
425 | 462 | IniFile::const_tuple_iterator k = (*section).second.begin (); |
426 | std::string lhs; | |
427 | std::string rhs; | |
463 | string lhs; | |
464 | string rhs; | |
428 | 465 | |
429 | 466 | while (k != (*section).second.end ()) { |
430 | 467 | idx = ::atoi ((*k).first.c_str ()) - 1; |
483 | 520 | } |
484 | 521 | |
485 | 522 | 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 ())); | |
487 | 524 | DL((APP,"m_snd_player_cmd = \"%s\"\n", m_snd_player_cmd.c_str ())); |
488 | 525 | DL((APP,"m_snd_player_args = \"%s\"\n", m_snd_player_args.c_str ())); |
489 | 526 | DL((APP,"m_snd_archive_path = \"%s\"\n", m_snd_archive_path.c_str ())); |
490 | 527 | |
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; | |
514 | 642 | } |
515 | 643 | |
516 | 644 | s = m_config->get_value ("Default", "mainwin_geometry"); |
567 | 695 | { |
568 | 696 | trace_with_mask("GrappConf::save_config",GUITRACE); |
569 | 697 | |
570 | std::string s; | |
698 | string s; | |
571 | 699 | const char* fname; |
572 | 700 | |
573 | 701 | if (m_config == NULL) { |
651 | 779 | iter++, position++; |
652 | 780 | } |
653 | 781 | |
654 | Glib::ustring usfont; | |
782 | Glib::ustring ustr; | |
655 | 783 | m_config->set_pair ("Default", |
656 | 784 | 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)); | |
658 | 793 | /** Fonts |
659 | 794 | */ |
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)); | |
676 | 857 | /** Geometry |
677 | 858 | */ |
678 | 859 | m_config->set_pair ("Default", |
745 | 926 | { |
746 | 927 | trace_with_mask("GrappConf::get_flipside_history",GUITRACE); |
747 | 928 | |
748 | if (fname_.find ("Untitled") != std::string::npos) { | |
929 | if (fname_.find ("Untitled") != string::npos) { | |
749 | 930 | return (FRONT); |
750 | 931 | } |
751 | 932 | flipside_iter_t iter = m_flipside_history.begin (); |
816 | 997 | */ |
817 | 998 | void |
818 | 999 | GrappConf:: |
819 | str_to_geometry (const std::string& src_, Gdk::Rectangle& aspect_) | |
1000 | str_to_geometry (const string& src_, Gdk::Rectangle& aspect_) | |
820 | 1001 | { |
821 | 1002 | trace_with_mask("GrappConf::str_to_geometry",GUITRACE); |
822 | 1003 | |
842 | 1023 | sprintf (buf, "%dx%d", aspect_.get_height (), aspect_.get_width ()); |
843 | 1024 | return buf; |
844 | 1025 | } |
1026 |
1 | 1 | //------------------------------------------------------------------------------ |
2 | 2 | // GrappConf.h |
3 | 3 | //------------------------------------------------------------------------------ |
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 $ | |
5 | 5 | //------------------------------------------------------------------------------ |
6 | 6 | // Copyright (c) 2004-2006 by Vladislav Grinchenko |
7 | 7 | // |
21 | 21 | using std::string; |
22 | 22 | |
23 | 23 | #include <pangomm/fontdescription.h> |
24 | ||
24 | 25 | #include <gdkmm/rectangle.h> |
26 | #include <gdkmm/color.h> | |
25 | 27 | |
26 | 28 | #include <assa/Singleton.h> |
27 | 29 | #include <assa/TimeVal.h> |
126 | 128 | SideSelection get_flipside_history (const string& fname_); |
127 | 129 | void set_flipside_history (const string& fname_, SideSelection side_); |
128 | 130 | |
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 | ||
129 | 141 | /** Text fonts settings |
130 | 142 | */ |
131 | 143 | Pango::FontDescription& get_question_font () { return m_question_font_desc;} |
140 | 152 | void set_input_font (const Glib::ustring& font_); |
141 | 153 | void set_app_font (const Glib::ustring& font_); |
142 | 154 | |
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 | ||
143 | 169 | /** Windows geometry |
144 | 170 | */ |
145 | 171 | Gdk::Rectangle get_main_window_geometry () { return m_mwin_geometry; } |
203 | 229 | typedef std::vector<sidesel_t> flipside_t; |
204 | 230 | typedef flipside_t::iterator flipside_iter_t; |
205 | 231 | |
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_); | |
208 | 234 | const char* geometry_to_str (const Gdk::Rectangle& allocation_); |
209 | 235 | |
210 | 236 | private: |
213 | 239 | string m_filesel_path; // Path of the last FileSelection dialog |
214 | 240 | bool m_dont_save_project; // Don't save project file |
215 | 241 | |
242 | Glib::ustring m_text_fgcolor; | |
243 | Glib::ustring m_text_bgcolor; | |
244 | Glib::ustring m_sep_color; | |
245 | ||
216 | 246 | Pango::FontDescription m_question_font_desc; |
217 | 247 | Pango::FontDescription m_answer_font_desc; |
218 | 248 | Pango::FontDescription m_example_font_desc; |
219 | 249 | Pango::FontDescription m_input_font_desc; |
220 | 250 | 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; | |
221 | 269 | |
222 | 270 | Gdk::Rectangle m_mwin_geometry; |
223 | 271 | Gdk::Rectangle m_dplyr_geometry; |
379 | 427 | { |
380 | 428 | m_sched [idx_].mins (s_); |
381 | 429 | } |
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 | ||
382 | 519 | |
383 | 520 | #endif /* CONFIG_H */ |
0 | 0 | // -*- c++ -*- |
1 | 1 | // Generated by assa-genesis |
2 | 2 | //------------------------------------------------------------------------------ |
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 $ | |
4 | 4 | //------------------------------------------------------------------------------ |
5 | 5 | // MainWindow.cpp |
6 | 6 | //------------------------------------------------------------------------------ |
22 | 22 | #include <gtkmm/filechooserdialog.h> |
23 | 23 | #include <gdkmm/pixbuf.h> |
24 | 24 | #include <gdkmm/image.h> |
25 | #include <gtkmm/scrolledwindow.h> | |
25 | 26 | |
26 | 27 | #ifdef IS_HILDON |
27 | #include <libosso.h> | |
28 | # include <libosso.h> | |
28 | 29 | #endif |
29 | 30 | |
30 | 31 | #include "Granule-main.h" |
35 | 36 | #include "CardBox.h" |
36 | 37 | #include "PrefWindow.h" |
37 | 38 | #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" | |
39 | 45 | |
40 | 46 | //============================================================================== |
41 | 47 | // Static locals |
61 | 67 | MainWindow:: |
62 | 68 | MainWindow () : |
63 | 69 | #ifdef IS_HILDON |
64 | Hildon::AppView ("Granule"), | |
70 | Hildon::AppView ("Granule"), | |
65 | 71 | #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) | |
72 | 78 | { |
73 | 79 | trace_with_mask("MainWindow::MainWindow",GUITRACE); |
74 | 80 | |
75 | int x = 0; | |
76 | int y = 0; | |
81 | int x = 0; | |
82 | int y = 0; | |
77 | 83 | |
78 | 84 | m_app_title += "-" + string (VERSION); |
79 | 85 | |
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 | |
80 | 96 | add (m_contents); |
97 | #endif | |
98 | ||
81 | 99 | set_title (_(m_app_title.c_str ())); |
82 | 100 | set_border_width (2); |
83 | 101 | |
84 | 102 | #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); | |
95 | 113 | move (x, y); |
96 | 114 | #endif |
97 | 115 | |
98 | /** Menu & Toolbar | |
99 | */ | |
116 | /** Menu & Toolbar | |
117 | */ | |
100 | 118 | install_menus_and_toolbar (); |
101 | 119 | |
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); | |
121 | 139 | |
122 | 140 | #if !defined (IS_HILDON) && !defined (WIN32) |
123 | set_icon_from_file (DATDIR "/pixmaps/granule.png"); | |
141 | set_icon_from_file (DATDIR "/pixmaps/granule.png"); | |
124 | 142 | #endif |
125 | 143 | |
126 | DL ((GRAPP,"Set Application icon\n")); | |
144 | DL ((GRAPP,"Set Application icon\n")); | |
127 | 145 | |
128 | 146 | signal_size_allocate ().connect ( |
129 | sigc::mem_fun (*this, &MainWindow::size_allocate_cb)); | |
147 | sigc::mem_fun (*this, &MainWindow::size_allocate_cb)); | |
130 | 148 | |
131 | 149 | show_all (); |
132 | 150 | } |
137 | 155 | { |
138 | 156 | trace_with_mask("MainWindow::~MainWindow",GUITRACE); |
139 | 157 | |
140 | if (m_pref_window != NULL) { | |
158 | if (m_pref_window != NULL) { | |
141 | 159 | delete m_pref_window; |
142 | 160 | m_pref_window = NULL; |
143 | } | |
144 | ||
161 | } | |
162 | ||
145 | 163 | if (m_about != NULL) { |
146 | 164 | delete m_about; |
147 | 165 | m_about = NULL; |
178 | 196 | { |
179 | 197 | trace_with_mask("MainWindow::size_allocate_cb",GUITRACE); |
180 | 198 | |
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 ()); | |
183 | 201 | } |
184 | 202 | |
185 | 203 | void |
188 | 206 | { |
189 | 207 | trace_with_mask("MainWindow::install_menus_and_toolbar",GUITRACE); |
190 | 208 | |
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 (); | |
197 | 215 | m_contents.pack_start (*m_top_menu_bar.get_menu_bar (), Gtk::PACK_SHRINK); |
198 | 216 | } |
199 | 217 | |
203 | 221 | { |
204 | 222 | trace_with_mask("MainWindow::on_delete_event",GUITRACE); |
205 | 223 | |
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; | |
211 | 229 | } |
212 | 230 | |
213 | 231 | //============================================================================== |
523 | 541 | { |
524 | 542 | trace_with_mask("MainWindow::open_file",GUITRACE); |
525 | 543 | |
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) { | |
545 | 548 | return -1; |
546 | } | |
549 | } | |
547 | 550 | |
548 | return (m_cardbox->load (f.get_filename ())); | |
551 | return (m_cardbox->load (f.get_filename ())); | |
549 | 552 | } |
550 | 553 | |
551 | 554 | int |
558 | 561 | |
559 | 562 | if (projname == UNKNOWN_FNAME) |
560 | 563 | { |
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"); | |
572 | 568 | |
573 | 569 | if (f.run () != Gtk::RESPONSE_OK) { |
574 | 570 | return -1; |
605 | 601 | { |
606 | 602 | trace_with_mask("MainWindow::save_file_as",GUITRACE); |
607 | 603 | |
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); | |
624 | 606 | |
625 | 607 | if (f.run () != Gtk::RESPONSE_OK) { |
626 | 608 | return -1; |
644 | 626 | |
645 | 627 | #else |
646 | 628 | |
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); | |
662 | 630 | |
663 | 631 | if (f.run () != Gtk::RESPONSE_OK) { |
664 | 632 | return -1; |
674 | 642 | m_cardbox->export_sound_bits (f.get_filename ()); |
675 | 643 | |
676 | 644 | #endif |
645 | ||
677 | 646 | return 0; |
678 | 647 | } |
679 | 648 |
0 | 0 | // -*- c++ -*- |
1 | 1 | // Generated by assa-genesis |
2 | 2 | //------------------------------------------------------------------------------ |
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 $ | |
4 | 4 | //------------------------------------------------------------------------------ |
5 | 5 | // MainWindow.h |
6 | 6 | //------------------------------------------------------------------------------ |
49 | 49 | MainWindow (); |
50 | 50 | ~MainWindow (); |
51 | 51 | |
52 | /** Post-c'tor initialization | |
53 | */ | |
54 | void init (); | |
52 | /** Post-c'tor initialization | |
53 | */ | |
54 | void init (); | |
55 | 55 | |
56 | // -*- Toolbar Callbacks -*- | |
57 | void about_cb (); | |
56 | // -*- Toolbar Callbacks -*- | |
57 | void about_cb (); | |
58 | 58 | |
59 | // [File] Menu | |
60 | void pref_cb (); | |
59 | // [File] Menu | |
60 | void pref_cb (); | |
61 | 61 | void exit_cb (); |
62 | 62 | |
63 | 63 | // [CardFile] Menu |
66 | 66 | void open_recent_cb (guint index_); // set in TopMenuBar |
67 | 67 | void save_cb (); |
68 | 68 | void save_as_cb (); |
69 | void export_sound_cb (); | |
69 | void export_sound_cb (); | |
70 | 70 | void close_cb (); |
71 | void play_in_box (int idx_); | |
71 | void play_in_box (int idx_); | |
72 | 72 | |
73 | // [Deck] Menu | |
74 | void unselect_deck_cb (); | |
73 | // [Deck] Menu | |
74 | void unselect_deck_cb (); | |
75 | 75 | |
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_); | |
79 | 79 | |
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_); | |
83 | 83 | |
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; } | |
89 | 88 | |
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_); | |
92 | 91 | |
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_); | |
97 | 96 | |
98 | friend int CardBox::add_cards_to_box (std::vector<CardRef*>& cardlist_); | |
97 | friend int CardBox::add_cards_to_box (std::vector<CardRef*>& cardlist_); | |
99 | 98 | |
100 | friend void CardBox::mark_as_modified (); | |
99 | friend void CardBox::mark_as_modified (); | |
101 | 100 | |
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; } | |
104 | 103 | |
105 | 104 | private: |
106 | // -*- Utilities -*- | |
105 | // -*- Utilities -*- | |
107 | 106 | void install_menus_and_toolbar (); |
108 | 107 | void print_state (void) const; |
109 | 108 | |
111 | 110 | int open_file (); |
112 | 111 | int save_file (); |
113 | 112 | 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 (); | |
118 | 117 | |
119 | 118 | private: |
120 | static const char* states []; | |
119 | static const char* states []; | |
121 | 120 | |
122 | WMState m_state; | |
121 | WMState m_state; | |
123 | 122 | 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; | |
133 | 132 | }; |
134 | 133 | |
135 | 134 | #endif // MAIN_WINDOW_H |
1 | 1 | # ------------------------------------------------------------------------------ |
2 | 2 | # src/Makefile.am |
3 | 3 | # |
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 $ | |
5 | 5 | # ------------------------------------------------------------------------------ |
6 | 6 | |
7 | 7 | bin_PROGRAMS = granule |
10 | 10 | Intern.h \ |
11 | 11 | CSVImportDialog.h \ |
12 | 12 | CSVImportDialog.cpp \ |
13 | CSVExportDialog.h \ | |
14 | CSVExportDialog.cpp \ | |
13 | 15 | AboutGRAPP.h \ |
14 | 16 | AboutGRAPP.cpp \ |
15 | 17 | VDeck.h \ |
41 | 43 | CardView.cpp \ |
42 | 44 | CardViewHelpDialog.h \ |
43 | 45 | 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 \ | |
47 | 57 | GrappConf.h \ |
48 | 58 | GrappConf.cpp \ |
49 | 59 | TopMenuBar.h \ |
58 | 68 | GeometryPrefs.cpp \ |
59 | 69 | AppearancePrefs.h \ |
60 | 70 | AppearancePrefs.cpp \ |
71 | MyTextAlignmentsWidget.h \ | |
72 | MyTextAlignmentsWidget.cpp \ | |
73 | TextAlignment.h \ | |
74 | TextAlignment.cpp \ | |
61 | 75 | PrefWindow.h \ |
62 | 76 | PrefWindow.cpp \ |
63 | 77 | MyPropertyBox.h \ |
75 | 89 | |
76 | 90 | if USE_HILDON |
77 | 91 | DEP_CFLAGS = -DIS_HILDON |
92 | endif | |
93 | ||
94 | if USE_PDA | |
95 | DEP_CFLAGS = -DIS_PDA | |
78 | 96 | endif |
79 | 97 | |
80 | 98 | INCLUDES = \ |
17 | 17 | # ------------------------------------------------------------------------------ |
18 | 18 | # src/Makefile.am |
19 | 19 | # |
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 $ | |
21 | 21 | # ------------------------------------------------------------------------------ |
22 | 22 | |
23 | 23 | srcdir = @srcdir@ |
55 | 55 | am__installdirs = "$(DESTDIR)$(bindir)" |
56 | 56 | binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) |
57 | 57 | PROGRAMS = $(bin_PROGRAMS) |
58 | am_granule_OBJECTS = CSVImportDialog.$(OBJEXT) AboutGRAPP.$(OBJEXT) \ | |
58 | am_granule_OBJECTS = CSVImportDialog.$(OBJEXT) \ | |
59 | CSVExportDialog.$(OBJEXT) AboutGRAPP.$(OBJEXT) \ | |
59 | 60 | CardDeck.$(OBJEXT) Deck.$(OBJEXT) CardBox.$(OBJEXT) \ |
60 | 61 | DeckView.$(OBJEXT) DeckInfo.$(OBJEXT) DeckPlayer.$(OBJEXT) \ |
61 | 62 | DeckManager.$(OBJEXT) DeckList.$(OBJEXT) \ |
62 | 63 | MyDialogWithCheckbutton.$(OBJEXT) VCard.$(OBJEXT) \ |
63 | 64 | CardRef.$(OBJEXT) Card.$(OBJEXT) CardView.$(OBJEXT) \ |
64 | 65 | CardViewHelpDialog.$(OBJEXT) EditControls.$(OBJEXT) \ |
66 | MyFileOpenDialog.$(OBJEXT) MyFileSaveDialog.$(OBJEXT) \ | |
67 | MyFolderChooseDialog.$(OBJEXT) MyInputDialog.$(OBJEXT) \ | |
65 | 68 | GrappConf.$(OBJEXT) TopMenuBar.$(OBJEXT) GeneralPref.$(OBJEXT) \ |
66 | 69 | SchedulingPrefs.$(OBJEXT) SoundPrefs.$(OBJEXT) \ |
67 | 70 | GeometryPrefs.$(OBJEXT) AppearancePrefs.$(OBJEXT) \ |
71 | MyTextAlignmentsWidget.$(OBJEXT) TextAlignment.$(OBJEXT) \ | |
68 | 72 | PrefWindow.$(OBJEXT) MyPropertyBox.$(OBJEXT) \ |
69 | 73 | ButtonWithImageLabel.$(OBJEXT) MainWindow.$(OBJEXT) \ |
70 | 74 | Granule.$(OBJEXT) Granule-main.$(OBJEXT) |
194 | 198 | USE_HILDON_FALSE = @USE_HILDON_FALSE@ |
195 | 199 | USE_HILDON_TRUE = @USE_HILDON_TRUE@ |
196 | 200 | USE_NLS = @USE_NLS@ |
201 | USE_PDA_FALSE = @USE_PDA_FALSE@ | |
202 | USE_PDA_TRUE = @USE_PDA_TRUE@ | |
197 | 203 | VERSION = @VERSION@ |
198 | 204 | WIN32_EXTRA_LIBADD = @WIN32_EXTRA_LIBADD@ |
199 | 205 | XGETTEXT = @XGETTEXT@ |
256 | 262 | Intern.h \ |
257 | 263 | CSVImportDialog.h \ |
258 | 264 | CSVImportDialog.cpp \ |
265 | CSVExportDialog.h \ | |
266 | CSVExportDialog.cpp \ | |
259 | 267 | AboutGRAPP.h \ |
260 | 268 | AboutGRAPP.cpp \ |
261 | 269 | VDeck.h \ |
287 | 295 | CardView.cpp \ |
288 | 296 | CardViewHelpDialog.h \ |
289 | 297 | 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 \ | |
293 | 309 | GrappConf.h \ |
294 | 310 | GrappConf.cpp \ |
295 | 311 | TopMenuBar.h \ |
304 | 320 | GeometryPrefs.cpp \ |
305 | 321 | AppearancePrefs.h \ |
306 | 322 | AppearancePrefs.cpp \ |
323 | MyTextAlignmentsWidget.h \ | |
324 | MyTextAlignmentsWidget.cpp \ | |
325 | TextAlignment.h \ | |
326 | TextAlignment.cpp \ | |
307 | 327 | PrefWindow.h \ |
308 | 328 | PrefWindow.cpp \ |
309 | 329 | MyPropertyBox.h \ |
319 | 339 | |
320 | 340 | localedir = $(datadir)/locale |
321 | 341 | @USE_HILDON_TRUE@DEP_CFLAGS = -DIS_HILDON |
342 | @USE_PDA_TRUE@DEP_CFLAGS = -DIS_PDA | |
322 | 343 | INCLUDES = \ |
323 | 344 | -g \ |
324 | 345 | -I$(top_srcdir) \ |
418 | 439 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/AboutGRAPP.Po@am__quote@ |
419 | 440 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/AppearancePrefs.Po@am__quote@ |
420 | 441 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ButtonWithImageLabel.Po@am__quote@ |
442 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CSVExportDialog.Po@am__quote@ | |
421 | 443 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CSVImportDialog.Po@am__quote@ |
422 | 444 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Card.Po@am__quote@ |
423 | 445 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CardBox.Po@am__quote@ |
439 | 461 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GrappConf.Po@am__quote@ |
440 | 462 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MainWindow.Po@am__quote@ |
441 | 463 | @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@ | |
442 | 468 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MyPropertyBox.Po@am__quote@ |
469 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MyTextAlignmentsWidget.Po@am__quote@ | |
443 | 470 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PrefWindow.Po@am__quote@ |
444 | 471 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SchedulingPrefs.Po@am__quote@ |
445 | 472 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SoundPrefs.Po@am__quote@ |
473 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/TextAlignment.Po@am__quote@ | |
446 | 474 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/TopMenuBar.Po@am__quote@ |
447 | 475 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/VCard.Po@am__quote@ |
448 | 476 |
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 */ |
1 | 1 | //------------------------------------------------------------------------------ |
2 | 2 | // MyPropertyBox.cpp |
3 | 3 | //------------------------------------------------------------------------------ |
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 $ | |
5 | 5 | //------------------------------------------------------------------------------ |
6 | 6 | // Copyright (c) 2002-2004 by Vladislav Grinchenko |
7 | 7 | // |
74 | 74 | mem_fun (*this, &MyPropertyBox::hildon_im_close_cb)); |
75 | 75 | #endif |
76 | 76 | |
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 | ||
77 | 80 | get_vbox ()->pack_start (*m_notebook); |
78 | m_notebook->set_show_border (true); | |
79 | 81 | |
80 | 82 | show_all_children (); |
81 | 83 | } |
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 */ |
0 | 0 | // -*- c++ -*- |
1 | 1 | //------------------------------------------------------------------------------ |
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 $ | |
3 | 3 | //------------------------------------------------------------------------------ |
4 | 4 | // PrefWindow.h |
5 | 5 | //------------------------------------------------------------------------------ |
35 | 35 | #ifdef IS_HILDON |
36 | 36 | set_size_request (672, -1); |
37 | 37 | #else |
38 | set_size_request (520, 380); | |
38 | set_size_request (580, 380); | |
39 | 39 | set_transient_for (dynamic_cast<Gtk::Window&>(parent_)); |
40 | 40 | #endif |
41 | 41 | |
64 | 64 | |
65 | 65 | m_ignore_callbacks = true; |
66 | 66 | m_changed = false; |
67 | DL ((GRAPP,"m_changed set to false\n")); | |
68 | 67 | |
69 | 68 | /** Fill values of all pages with fresh values from Config |
70 | 69 | */ |
71 | m_general_pref.load_from_config (); | |
70 | m_general_pref. load_from_config (); | |
72 | 71 | m_appearance_pref.load_from_config (); |
73 | 72 | 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 (); | |
76 | 75 | |
77 | 76 | m_ignore_callbacks = false; |
78 | 77 | m_apply_button->set_sensitive (false); |
78 | ||
79 | 79 | show (); |
80 | 80 | |
81 | 81 | #ifdef IS_HILDON |
85 | 85 | Gtk::Main::run (); |
86 | 86 | #endif |
87 | 87 | |
88 | DL ((GRAPP,"m_changed = %s\n", (m_changed ? "true":"false"))); | |
89 | 88 | return m_changed; |
90 | 89 | } |
91 | 90 | |
95 | 94 | { |
96 | 95 | trace_with_mask("PrefWindow::apply_impl",GUITRACE); |
97 | 96 | |
98 | m_general_pref.save_to_config (); | |
97 | m_general_pref. save_to_config (); | |
99 | 98 | m_appearance_pref.save_to_config (); |
100 | 99 | 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 (); | |
103 | 102 | } |
0 | 0 | // -*- c++ -*- |
1 | 1 | // generated by glade-- |
2 | 2 | //------------------------------------------------------------------------------ |
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 $ | |
4 | 4 | //------------------------------------------------------------------------------ |
5 | 5 | // SchedulingPref.h |
6 | 6 | //------------------------------------------------------------------------------ |
47 | 47 | { |
48 | 48 | trace_with_mask("SchedulingPref::SchedulingPrefs",GUITRACE); |
49 | 49 | 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 | |
50 | 56 | |
51 | 57 | Gtk::Label* label_b01000 = Gtk::manage(new Gtk::Label(" weeks ")); |
52 | 58 | Gtk::Label* label_b02000 = Gtk::manage(new Gtk::Label(" weeks ")); |
209 | 215 | m_frame->set_label_align(0,0.5); |
210 | 216 | m_frame->set_label_widget(*frame_label); |
211 | 217 | |
212 | #ifdef IS_HILDON | |
218 | #if defined(IS_HILDON) || defined(IS_PDA) | |
213 | 219 | Gtk::ScrolledWindow* scrollw = Gtk::manage (new Gtk::ScrolledWindow); |
214 | 220 | scrollw->set_flags (Gtk::CAN_FOCUS); |
215 | 221 | scrollw->set_shadow_type (Gtk::SHADOW_NONE); |
217 | 223 | scrollw->property_window_placement ().set_value (Gtk::CORNER_TOP_LEFT); |
218 | 224 | |
219 | 225 | scrollw->add (*m_sched_table); |
220 | m_frame->add(*scrollw); | |
226 | m_frame->add (*scrollw); | |
221 | 227 | |
222 | 228 | #else // Desktop |
223 | m_frame->add(*m_sched_table); | |
229 | m_frame->add (*m_sched_table); | |
224 | 230 | #endif |
225 | 231 | |
226 | 232 | for (i = 0; i < CARD_BOX_SIZE; i++) { |
243 | 249 | |
244 | 250 | } |
245 | 251 | |
246 | set_border_width(18); | |
252 | ||
247 | 253 | m_frame->show_all(); |
248 | 254 | pack_start(*m_frame); |
249 | 255 | } |
0 | 0 | // -*- c++ -*- |
1 | 1 | // generated by glade-- |
2 | 2 | //------------------------------------------------------------------------------ |
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 $ | |
4 | 4 | //------------------------------------------------------------------------------ |
5 | 5 | // SoundPref.h |
6 | 6 | //------------------------------------------------------------------------------ |
17 | 17 | //------------------------------------------------------------------------------ |
18 | 18 | #include <gtkmm/label.h> |
19 | 19 | #include <gtkmm/stock.h> |
20 | #include <gtkmm/filechooserdialog.h> | |
21 | 20 | |
22 | 21 | #include "Granule-main.h" |
23 | 22 | #include "GrappConf.h" |
24 | 23 | #include "SoundPrefs.h" |
25 | 24 | #include "PrefWindow.h" |
26 | ||
25 | #include "MyFolderChooseDialog.h" | |
26 | ||
27 | // i18n macros - always last | |
28 | #include "Intern.h" | |
29 | ||
30 | //------------------------------------------------------------------------------ | |
27 | 31 | SoundPrefs:: |
28 | 32 | SoundPrefs (PrefWindow& pwin_) : |
29 | 33 | VBox(false, 0), |
31 | 35 | { |
32 | 36 | trace_with_mask("SoundPrefs::SoundPrefs",GUITRACE); |
33 | 37 | |
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()); | |
35 | 49 | |
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()); | |
39 | 53 | |
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 ..."))); | |
43 | 57 | |
44 | 58 | Gtk::HBox *snd_path_hbox = Gtk::manage(new Gtk::HBox(false, 0)); |
45 | 59 | m_table = Gtk::manage(new Gtk::Table(2, 2, false)); |
111 | 125 | m_table->attach(*snd_path_hbox, 1, 2, 2, 3, |
112 | 126 | Gtk::FILL, Gtk::FILL, 0, 0); |
113 | 127 | |
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 | */ | |
114 | 145 | m_sound_player->signal_changed().connect ( |
115 | 146 | sigc::mem_fun (m_pref_window, &PrefWindow::changed_cb)); |
116 | 147 | m_snd_args->signal_changed().connect ( |
121 | 152 | m_browse_button->signal_clicked ().connect ( |
122 | 153 | sigc::mem_fun (*this, &SoundPrefs::on_browse_clicked)); |
123 | 154 | |
124 | set_border_width(18); | |
125 | m_table->show_all (); | |
126 | pack_start(*m_table); | |
127 | 155 | } |
128 | 156 | |
129 | 157 | void |
161 | 189 | { |
162 | 190 | trace_with_mask("SoundPrefs::on_browse_clicked",GUITRACE); |
163 | 191 | |
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); | |
171 | 193 | |
172 | 194 | const char* snd_path = CONFIG->get_snd_archive_path (); |
173 | 195 | if (snd_path && strlen (snd_path)) { |
174 | 196 | f.set_current_folder (snd_path); |
175 | 197 | } |
176 | else { | |
177 | f.set_current_folder (CONFIG->get_filesel_path ()); | |
178 | } | |
179 | f.set_local_only (); | |
180 | 198 | |
181 | 199 | if (f.run () == Gtk::RESPONSE_OK) { |
182 | 200 | 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 */ |
1 | 1 | //------------------------------------------------------------------------------ |
2 | 2 | // TopMenuBar.cpp |
3 | 3 | //------------------------------------------------------------------------------ |
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 | |
7 | 7 | // |
8 | 8 | // This program is free software; you can redistribute it and/or |
9 | 9 | // modify it under the terms of the GNU General Public License |
140 | 140 | d.push_back (MenuElem ("_Open", |
141 | 141 | mem_fun (m_dm, &DeckManager::open_deck_cb))); |
142 | 142 | m_deck_open = &d.back (); |
143 | d.push_back (MenuElem ("_Insert", | |
143 | d.push_back (MenuElem ("_Insert from Deck", | |
144 | 144 | mem_fun (m_dm, &DeckManager::insert_deck_cb))); |
145 | 145 | m_deck_insert = &d.back (); |
146 | 146 | |
148 | 148 | mem_fun (m_dm, &DeckManager::import_deck_cb))); |
149 | 149 | m_deck_import = &d.back (); |
150 | 150 | |
151 | d.push_back (MenuElem ("Export to CSV", | |
152 | mem_fun (m_dm, &DeckManager::export_deck_cb))); | |
153 | m_deck_export = &d.back (); | |
154 | ||
151 | 155 | d.push_back (SeparatorElem ()); |
152 | 156 | |
153 | 157 | d.push_back (MenuElem ("_Save", |
161 | 165 | d.push_back (MenuElem ("Save All", |
162 | 166 | mem_fun(m_dm,&DeckManager::save_all_deck_cb))); |
163 | 167 | m_deck_save_all = &d.back (); |
164 | ||
168 | ||
165 | 169 | d.push_back (SeparatorElem ()); |
166 | 170 | |
167 | 171 | d.push_back (MenuElem ("_Play/Edit", |
342 | 346 | m_deck_open ->set_sensitive (false); |
343 | 347 | m_deck_insert ->set_sensitive (true ); |
344 | 348 | m_deck_import ->set_sensitive (true ); |
349 | m_deck_export ->set_sensitive (true ); | |
345 | 350 | m_deck_save ->set_sensitive (true ); |
346 | 351 | m_deck_save_as ->set_sensitive (true ); |
347 | 352 | m_deck_save_all ->set_sensitive (false); |
354 | 359 | m_deck_open ->set_sensitive (true ); |
355 | 360 | m_deck_insert ->set_sensitive (false); |
356 | 361 | m_deck_import ->set_sensitive (false); |
362 | m_deck_export ->set_sensitive (false); | |
357 | 363 | m_deck_save ->set_sensitive (false); |
358 | 364 | m_deck_save_as ->set_sensitive (false); |
359 | 365 | m_deck_save_all ->set_sensitive ((num_open_decks_ > 0)); |
1 | 1 | //------------------------------------------------------------------------------ |
2 | 2 | // TopMenuBar.h |
3 | 3 | //------------------------------------------------------------------------------ |
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 $ | |
5 | 5 | //------------------------------------------------------------------------------ |
6 | // Copyright (c) 2004 by Vladislav Grinchenko | |
6 | // Copyright (c) 2004,2006 by Vladislav Grinchenko | |
7 | 7 | // |
8 | 8 | // This program is free software; you can redistribute it and/or |
9 | 9 | // modify it under the terms of the GNU General Public License |
90 | 90 | MenuItem* m_deck_open; |
91 | 91 | MenuItem* m_deck_insert; |
92 | 92 | MenuItem* m_deck_import; |
93 | MenuItem* m_deck_export; | |
93 | 94 | MenuItem* m_deck_save; |
94 | 95 | MenuItem* m_deck_save_as; |
95 | 96 | MenuItem* m_deck_save_all; |
110 | 111 | m_export (NULL), m_close (NULL), |
111 | 112 | m_play_in (NULL), |
112 | 113 | 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), | |
114 | 116 | m_deck_save (NULL), m_deck_save_as (NULL), |
115 | 117 | m_deck_save_all (NULL), m_deck_play (NULL), |
116 | 118 | m_deck_unselect (NULL), m_add_to_box (NULL) |
1 | 1 | //------------------------------------------------------------------------------ |
2 | 2 | // VCard.h |
3 | 3 | //------------------------------------------------------------------------------ |
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 $ | |
5 | 5 | // |
6 | 6 | // Date: Apr 24 2004 |
7 | 7 | //------------------------------------------------------------------------------ |
16 | 16 | |
17 | 17 | #include <assa/TimeVal.h> |
18 | 18 | |
19 | #include "Granule-main.h" | |
20 | ||
19 | 21 | class VCard |
20 | 22 | { |
21 | 23 | public: |
25 | 27 | virtual void set_question (const ustring& q_) = 0; |
26 | 28 | virtual void set_answer (const ustring& a_) = 0; |
27 | 29 | 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; | |
29 | 32 | |
30 | 33 | virtual ustring get_question () const = 0; |
31 | 34 | virtual ustring get_answer () const = 0; |
32 | 35 | virtual ustring get_example () const = 0; |
33 | virtual ustring get_alt_spelling () const = 0; | |
36 | virtual ustring get_alt_spelling (SideSelection side_) const = 0; | |
34 | 37 | virtual long get_id () const = 0; |
35 | 38 | |
36 | 39 | void set_reversed (bool r_) { m_reversed = r_; } |
1 | 1 | //------------------------------------------------------------------------------ |
2 | 2 | // VDeck.h |
3 | 3 | //------------------------------------------------------------------------------ |
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 $ | |
5 | 5 | // |
6 | 6 | // Copyright (c) 2004,2006 by Vladislav Grinchenko |
7 | 7 | // |
59 | 59 | virtual void erase (cardlist_iterator iter_) = 0; |
60 | 60 | virtual bool erase (VCard* card_) = 0; |
61 | 61 | |
62 | virtual void play_card (VDeck::cardlist_iterator& iter_) = 0; | |
62 | virtual void play_card (SideSelection side_, | |
63 | VDeck::cardlist_iterator& iter_) = 0; | |
63 | 64 | |
64 | 65 | virtual const string& get_name (void) const = 0; |
65 | 66 | virtual int get_index () const { return -1; } |