* l3afpad-0.8.18.1.7

This commit is contained in:
Wen-Yen Chuang 2012-01-09 15:13:49 +08:00
parent 172fd07c35
commit 16130aacc7
10 changed files with 200 additions and 34 deletions

0
.gitignore vendored
View File

View File

@ -1,6 +1,8 @@
2011-12-27 2012-01-09
version UNRELEASED: version 0.8.18.1.7:
* Support search and replace history and
option: --disable-search-history
* Updated Japanese translation (Toshiharu Kudoh). * Updated Japanese translation (Toshiharu Kudoh).
* Updated Russian translation (Aleksej Perepyolkin). * Updated Russian translation (Aleksej Perepyolkin).
* Make everything compatible with gcc -std=c1x * Make everything compatible with gcc -std=c1x

View File

@ -2,15 +2,15 @@
Hash: SHA1,SHA512 Hash: SHA1,SHA512
634071380936e4893b0e8cacdfcd344638406575 171 AUTHORS 634071380936e4893b0e8cacdfcd344638406575 171 AUTHORS
41064a7f3d01661f5de5cfee2345e3e9c6a8136a 9961 ChangeLog 9ff029efada108641f205078add0829f44b861a7 10039 ChangeLog
0beb31ee37259edeb621d345db933f2c827b2a21 22 Makefile.am 0beb31ee37259edeb621d345db933f2c827b2a21 22 Makefile.am
32ae3f99a247e614dcad4cfb2156a8d992ab53d0 22228 Makefile.in 32ae3f99a247e614dcad4cfb2156a8d992ab53d0 22228 Makefile.in
04dc937708d52f3b9b6f9a096898c5e23fb80ace 2071 README 04dc937708d52f3b9b6f9a096898c5e23fb80ace 2071 README
2a4026c3eed929bfa5341fb5ea22a5e0f95a5fc4 66077 aclocal.m4 2a4026c3eed929bfa5341fb5ea22a5e0f95a5fc4 66077 aclocal.m4
08e7ff6a0bc9382beae57974c3ac95c9ac565faa 3769 compile 08e7ff6a0bc9382beae57974c3ac95c9ac565faa 3769 compile
9b95284d89fb2a7f4d32dfeb088573fc897192a0 2637 config.h.in 7c5c2a0e918489ebb5817d0035e087a4ddc6ca3d 2709 config.h.in
278bed4a56a4e09159a04f3b90c54007a309a9df 239424 configure ebaa7bea2f6acf203c53a9be0fa552a336b1e43e 239778 configure
97f4ed00fab00e320d42d63b884ce63308c0d842 1921 configure.ac 100d8aa7b504824ec5b269245e9d25d3e21dabf9 2160 configure.ac
cbd191104fbb3eda18bc12e1caa9e60db401a008 264 data/Makefile.am cbd191104fbb3eda18bc12e1caa9e60db401a008 264 data/Makefile.am
dd49d0ee0462718182658e33e8cb4aa8dddce9b8 19803 data/Makefile.in dd49d0ee0462718182658e33e8cb4aa8dddce9b8 19803 data/Makefile.in
d5f3d29e0f768e7a48a9ab7bb7903aa123a72280 99 data/icons/128x128/Makefile.am d5f3d29e0f768e7a48a9ab7bb7903aa123a72280 99 data/icons/128x128/Makefile.am
@ -140,38 +140,38 @@ f6b21adcfc00151deba02a4339ea5883a7b8f411 2486 src/hlight.c
828e51d43aaa64cbaa492baf761d053bba6b02dd 1019 src/hlight.h 828e51d43aaa64cbaa492baf761d053bba6b02dd 1019 src/hlight.h
65d41180e4ad4ffc8e15910f64cd1c659bc30aa2 6774 src/indent.c 65d41180e4ad4ffc8e15910f64cd1c659bc30aa2 6774 src/indent.c
bb2a52d5a1969da5a312b91bbba32d0489a48871 1334 src/indent.h bb2a52d5a1969da5a312b91bbba32d0489a48871 1334 src/indent.h
f218290b77b711f5e2946c299c333725268128ce 3643 src/l3afpad.h fee3226a54e807797560be5ee61cb8cd81a848c8 3699 src/l3afpad.h
5c7f1b15d14250641334d67af6768c6b66ae9450 7420 src/linenum.c 5c7f1b15d14250641334d67af6768c6b66ae9450 7420 src/linenum.c
6f63e2c07f844c7ba97c77d3e7234d30560a09f0 983 src/linenum.h 6f63e2c07f844c7ba97c77d3e7234d30560a09f0 983 src/linenum.h
5451aa9d991c54e57f2a23492830050320321f5a 8319 src/main.c 5451aa9d991c54e57f2a23492830050320321f5a 8319 src/main.c
3c0259eda7028cfa574c29674235f5109f90526a 8751 src/menu.c 3c0259eda7028cfa574c29674235f5109f90526a 8751 src/menu.c
cafed6cfdf79765fae8127d020d311c4842fdeba 1179 src/menu.h cafed6cfdf79765fae8127d020d311c4842fdeba 1179 src/menu.h
e258f45dbf8b72e62f4cad204aaa1245c2d1cf0a 14745 src/search.c 13f187180f999117bc24911c47e55e070e34cc88 17350 src/search.c
cee72ed3fd94d1637021e9c73602f109f7af06d1 1054 src/search.h cee72ed3fd94d1637021e9c73602f109f7af06d1 1054 src/search.h
65fce9c9880a5cf6e73592bb67ad057e7832e73c 12595 src/selector.c 65fce9c9880a5cf6e73592bb67ad057e7832e73c 12595 src/selector.c
5af4e5fa14e8ab0106b07f15a74777124df098a8 1019 src/selector.h 5af4e5fa14e8ab0106b07f15a74777124df098a8 1019 src/selector.h
609fd713cef54955274804dadd59d51fbc3e7aa4 10743 src/undo.c 609fd713cef54955274804dadd59d51fbc3e7aa4 10743 src/undo.c
13e3a08982c1aee8ea5bedb3e76ac33f3f161290 1211 src/undo.h 13e3a08982c1aee8ea5bedb3e76ac33f3f161290 1211 src/undo.h
db205a5a6aa876fd5764a3ee1e4bdef8d82c2433 2746 src/utils.c 26918883912f5f087e467d6ea8620db316cd9512 4155 src/utils.c
e700377b8a734da1fc62cde0e735ea3b0be3b3ff 1026 src/utils.h cd4f957aa8207021b04882574ecd1720b5069457 1166 src/utils.h
3e9703e4eee527e8db4b082aa4aa2eeb158e111b 11206 src/view.c 3e9703e4eee527e8db4b082aa4aa2eeb158e111b 11206 src/view.c
f9797a035a29fe5e6f1137d20fb916c573bd1bea 1276 src/view.h f9797a035a29fe5e6f1137d20fb916c573bd1bea 1276 src/view.h
bf524e4de2a68901495a91d181cf3573edd3027b 2532 src/window.c bf524e4de2a68901495a91d181cf3573edd3027b 2532 src/window.c
75d1c79bfdd24b7ae5450ead4aef3ab43267e85f 1068 src/window.h 75d1c79bfdd24b7ae5450ead4aef3ab43267e85f 1068 src/window.h
-----BEGIN PGP SIGNATURE----- -----BEGIN PGP SIGNATURE-----
iEYEARECAAYFAk75HM0ACgkQdEpXpumNYVnmpgCdHIOBWvLd5Bjb4DeocKpqabmW iEYEARECAAYFAk8KiMkACgkQdEpXpumNYVkrpACeJDwi3t9a+Hpdon+0fzl9wSq+
Zn4AoIfSil8IV+v06CTsj/4Rky3BYEt3iQIcBAEBCgAGBQJO+RzNAAoJELc3H0m+ 5ScAn2i28kW9VY50zT4AsIppEGO9OUQeiQIcBAEBCgAGBQJPCojJAAoJELc3H0m+
i6gZs1gP/iF1siVF/ROcK6NREqF8lkSXopLUnsP6E6QZR71Bb1G+PEKLblehe5Jf i6gZDOcQAI0AsfAplCvjDiiWe7cR8o7moE9k1ci6nTO5qgjdOv1XT/u5dVnKbm73
n/EOca+u56eGsJ0aPm+p8+Um9OJWb1/e/JP+4UdKQqKQGVGexQXlrOJ6ykHhOvWy GlAKcDna5i2HKbaDddlaFSC0Oqy90tduiyeW2gU7WjX03NuHDg/cypCKhI4Mj7Jf
ASK1g0FDN2dkGcmfidJzifhEIeVw7xuxqwDRw/NFaaMpMGM0sCQEz3AbOdFNr5T/ 0OVP2Xb/hYj5cntx2FdgtER/UqGoCnVRhDTwpYN+MbVHa6Aoiyg6Wk5EkI5XX3vD
IRuahpR6qRdZRQn3SdqjiJ6HK3o68TsyjBsTomk8IWvTreOiGdMNrXZnEvkILxUT wUefokJL8tJeKhRQnh7wwVltQixk2jDHjnAh0olLnUxnxqsDTNlSso3ytKbGMtRO
lDcf92/HQ15pCpSlIrCGjR8JDym7v9JUU2szzV5ArK3M69+oiXyx2ex1Y8M2+nfc fKx80cGkBo5VgrcT8wyf8qZR9qNbwL6aWEi/gD5ni96so7X/WdilfzLeCRmtZP6X
mqyjqS4roaaTf5v5ajx7q29WNq1aC+2PNhPhINQwzwSmBy4DwUgs8PpMtC7ZGGtj VIgEmzpyrX9wtouQRfJsW9jS4d5ppYn6Vf5Q0Z4MZsSNWvL2FFejoJTijvdRma80
VOhpQvM52RD16Ea0fbkYnHWo7WbEA1ByB+jE2jfKbd/5G1+d2vHE0+tJNEXvVgh1 oBSb7MLtay6Kr70CMpRK05doCsXIt9qr/tsjxxOPfkmojX2pJr3jXpNvcCP3ULvj
WLEKRV6fdWR4geHvI97Qj6hAIniXrbQr/2BdeayYbfVIRALxyClibqqIyR1RZmmQ Ks4cI0H4Pbf7l2zbqDvucXcq0o2gST8fG7gy2DH8GgkIvi0oZXd63v8ph0iQ9D5W
QbqPZAKzU3tcu3fwgg8cxCJ8+BoC43PyWqKl71zWc/WcdWELSgX4nQhxJmesNhrP A6/UsDBHyJgEBoY8bAoyIYDzgzZD2OHoF0+/dPlTe9khVTpI2aebzEP+WwobgjJ/
Yfd4iEy+pu26m9shR3wp63BrxeTeiqVsaej+tfpwzCqoCQCm+1w2MkWzOe94iw/J QxXylmDBnBZFBpHpmLbd8W/+9qiT9b8LDxzyB9mrz1tUbPLZ4PFQkxHYpOvg6ILr
BCuv+7dWFYwET5A/rAWEsA+elMjegHmYRv37kHTPwji7rDnPn9TQ kEA8lvL5K/uPaci+p37BGf7YdbWZTVx79V3rIZMhXhSLo/Yx5QYI
=zo73 =IRBy
-----END PGP SIGNATURE----- -----END PGP SIGNATURE-----

View File

@ -84,6 +84,9 @@
/* Define to the version of this package. */ /* Define to the version of this package. */
#undef PACKAGE_VERSION #undef PACKAGE_VERSION
/* Define to 0 if you disable search history. */
#undef SEARCH_HISTORY
/* Define to 1 if you have the ANSI C header files. */ /* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS #undef STDC_HEADERS

32
configure vendored
View File

@ -1,6 +1,6 @@
#! /bin/sh #! /bin/sh
# Guess values for system-dependent variables and create Makefiles. # Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.68 for L3afpad 0.8.18.1.6. # Generated by GNU Autoconf 2.68 for L3afpad 0.8.18.1.7.
# #
# Report bugs to <caleb@calno.com>. # Report bugs to <caleb@calno.com>.
# #
@ -560,8 +560,8 @@ MAKEFLAGS=
# Identity of this package. # Identity of this package.
PACKAGE_NAME='L3afpad' PACKAGE_NAME='L3afpad'
PACKAGE_TARNAME='l3afpad' PACKAGE_TARNAME='l3afpad'
PACKAGE_VERSION='0.8.18.1.6' PACKAGE_VERSION='0.8.18.1.7'
PACKAGE_STRING='L3afpad 0.8.18.1.6' PACKAGE_STRING='L3afpad 0.8.18.1.7'
PACKAGE_BUGREPORT='caleb@calno.com' PACKAGE_BUGREPORT='caleb@calno.com'
PACKAGE_URL='' PACKAGE_URL=''
@ -739,6 +739,7 @@ enable_largefile
enable_dependency_tracking enable_dependency_tracking
enable_nls enable_nls
enable_print enable_print
enable_search_history
enable_statistics enable_statistics
enable_xinput2 enable_xinput2
enable_emacs enable_emacs
@ -1300,7 +1301,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing. # Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh. # This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF cat <<_ACEOF
\`configure' configures L3afpad 0.8.18.1.6 to adapt to many kinds of systems. \`configure' configures L3afpad 0.8.18.1.7 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]... Usage: $0 [OPTION]... [VAR=VALUE]...
@ -1366,7 +1367,7 @@ fi
if test -n "$ac_init_help"; then if test -n "$ac_init_help"; then
case $ac_init_help in case $ac_init_help in
short | recursive ) echo "Configuration of L3afpad 0.8.18.1.6:";; short | recursive ) echo "Configuration of L3afpad 0.8.18.1.7:";;
esac esac
cat <<\_ACEOF cat <<\_ACEOF
@ -1379,6 +1380,8 @@ Optional Features:
--enable-dependency-tracking do not reject slow dependency extractors --enable-dependency-tracking do not reject slow dependency extractors
--disable-nls do not use Native Language Support --disable-nls do not use Native Language Support
--disable-print force to disable print feature --disable-print force to disable print feature
--disable-search-history
force to disable search history
--disable-statistics force to disable statistics --disable-statistics force to disable statistics
--disable-xinput2 force to disable Xinput2 --disable-xinput2 force to disable Xinput2
--enable-emacs implement Emacs key theme (experimental) --enable-emacs implement Emacs key theme (experimental)
@ -1467,7 +1470,7 @@ fi
test -n "$ac_init_help" && exit $ac_status test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then if $ac_init_version; then
cat <<\_ACEOF cat <<\_ACEOF
L3afpad configure 0.8.18.1.6 L3afpad configure 0.8.18.1.7
generated by GNU Autoconf 2.68 generated by GNU Autoconf 2.68
Copyright (C) 2010 Free Software Foundation, Inc. Copyright (C) 2010 Free Software Foundation, Inc.
@ -1836,7 +1839,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake. running configure, to aid debugging if configure makes a mistake.
It was created by L3afpad $as_me 0.8.18.1.6, which was It was created by L3afpad $as_me 0.8.18.1.7, which was
generated by GNU Autoconf 2.68. Invocation command line was generated by GNU Autoconf 2.68. Invocation command line was
$ $0 $@ $ $0 $@
@ -5449,6 +5452,17 @@ $as_echo "#define ENABLE_PRINT 0" >>confdefs.h
fi fi
# Check whether --enable-search-history was given.
if test "${enable_search_history+set}" = set; then :
enableval=$enable_search_history;
fi
if test "$enable_search_history" = "no"; then
$as_echo "#define SEARCH_HISTORY 0" >>confdefs.h
fi
# Check whether --enable-statistics was given. # Check whether --enable-statistics was given.
if test "${enable_statistics+set}" = set; then : if test "${enable_statistics+set}" = set; then :
enableval=$enable_statistics; enableval=$enable_statistics;
@ -7165,7 +7179,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their # report actual input values of CONFIG_FILES etc. instead of their
# values after options handling. # values after options handling.
ac_log=" ac_log="
This file was extended by L3afpad $as_me 0.8.18.1.6, which was This file was extended by L3afpad $as_me 0.8.18.1.7, which was
generated by GNU Autoconf 2.68. Invocation command line was generated by GNU Autoconf 2.68. Invocation command line was
CONFIG_FILES = $CONFIG_FILES CONFIG_FILES = $CONFIG_FILES
@ -7231,7 +7245,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\ ac_cs_version="\\
L3afpad config.status 0.8.18.1.6 L3afpad config.status 0.8.18.1.7
configured by $0, generated by GNU Autoconf 2.68, configured by $0, generated by GNU Autoconf 2.68,
with options \\"\$ac_cs_config\\" with options \\"\$ac_cs_config\\"

View File

@ -1,4 +1,4 @@
AC_INIT(L3afpad, 0.8.18.1.6, caleb@calno.com) AC_INIT(L3afpad, 0.8.18.1.7, caleb@calno.com)
AM_INIT_AUTOMAKE($PACKAGE_TARNAME, $PACKAGE_VERSION) AM_INIT_AUTOMAKE($PACKAGE_TARNAME, $PACKAGE_VERSION)
AM_CONFIG_HEADER(config.h) AM_CONFIG_HEADER(config.h)
AC_SYS_LARGEFILE AC_SYS_LARGEFILE
@ -17,6 +17,12 @@ AC_ARG_ENABLE(print,
AC_DEFINE(ENABLE_PRINT, 0, [Define to 0 if you disable print.]) AC_DEFINE(ENABLE_PRINT, 0, [Define to 0 if you disable print.])
fi fi
AC_ARG_ENABLE(search-history,
AC_HELP_STRING([--disable-search-history], [force to disable search history]))
if test "$enable_search_history" = "no"; then
AC_DEFINE(SEARCH_HISTORY, 0, [Define to 0 if you disable search history.])
fi
AC_ARG_ENABLE(statistics, AC_ARG_ENABLE(statistics,
AC_HELP_STRING([--disable-statistics], [force to disable statistics])) AC_HELP_STRING([--disable-statistics], [force to disable statistics]))
if test "$enable_statistics" = "no"; then if test "$enable_statistics" = "no"; then

View File

@ -31,6 +31,10 @@
#define ENABLE_PRINT 1 #define ENABLE_PRINT 1
#endif #endif
#ifndef SEARCH_HISTORY
#define SEARCH_HISTORY 1
#endif
#ifndef ENABLE_STATISTICS #ifndef ENABLE_STATISTICS
#define ENABLE_STATISTICS 1 #define ENABLE_STATISTICS 1
#endif #endif

View File

@ -22,6 +22,10 @@
#include "l3afpad.h" #include "l3afpad.h"
#include "gtksourceiter.h" #include "gtksourceiter.h"
#if SEARCH_HISTORY
static GList *find_history;
static GList *replace_history;
#endif
static gchar *string_find = NULL; static gchar *string_find = NULL;
static gchar *string_replace = NULL; static gchar *string_replace = NULL;
static gboolean match_case, replace_all;//, replace_mode = FALSE; static gboolean match_case, replace_all;//, replace_mode = FALSE;
@ -246,6 +250,7 @@ static gint document_replace_real(GtkWidget *textview)
} }
#if !SEARCH_HISTORY
static gint entry_len; static gint entry_len;
static void toggle_sensitivity(GtkWidget *w, gint pos1, gint pos2, gint *pos3) static void toggle_sensitivity(GtkWidget *w, gint pos1, gint pos2, gint *pos3)
@ -263,6 +268,17 @@ static void toggle_sensitivity(GtkWidget *w, gint pos1, gint pos2, gint *pos3)
GTK_RESPONSE_OK, FALSE); GTK_RESPONSE_OK, FALSE);
} }
} }
#endif /* !SEARCH_HISTORY */
#if SEARCH_HISTORY
static void toggle_sensitivity(GtkWidget *entry)
{
gboolean has_text = *(gtk_entry_get_text(GTK_ENTRY(entry))) != '\0';
gtk_dialog_set_response_sensitive(
GTK_DIALOG(gtk_widget_get_toplevel(entry)), GTK_RESPONSE_OK,
(has_text) ? TRUE : FALSE);
}
#endif
static void toggle_check_case(GtkWidget *widget) static void toggle_check_case(GtkWidget *widget)
{ {
@ -279,6 +295,11 @@ gint run_dialog_search(GtkWidget *textview, gint mode)
GtkWidget *dialog; GtkWidget *dialog;
GtkWidget *table; GtkWidget *table;
GtkWidget *label_find, *label_replace; GtkWidget *label_find, *label_replace;
#if SEARCH_HISTORY
GtkWidget *combo_find, *combo_replace = NULL;
GtkTextBuffer *buffer;
GtkTextIter start_iter, end_iter;
#endif
GtkWidget *entry_find, *entry_replace = NULL; GtkWidget *entry_find, *entry_replace = NULL;
GtkWidget *check_case, *check_all; GtkWidget *check_case, *check_all;
gint res; gint res;
@ -306,9 +327,16 @@ gint run_dialog_search(GtkWidget *textview, gint mode)
label_find = gtk_label_new_with_mnemonic(_("Fi_nd what:")); label_find = gtk_label_new_with_mnemonic(_("Fi_nd what:"));
gtk_misc_set_alignment(GTK_MISC(label_find), 0, 0.5); gtk_misc_set_alignment(GTK_MISC(label_find), 0, 0.5);
gtk_table_attach_defaults(GTK_TABLE(table), label_find, 0, 1, 0, 1); gtk_table_attach_defaults(GTK_TABLE(table), label_find, 0, 1, 0, 1);
#if SEARCH_HISTORY
combo_find = create_combo_with_history (&find_history);
gtk_table_attach_defaults(GTK_TABLE(table), combo_find, 1, 2, 0, 1);
entry_find = gtk_bin_get_child(GTK_BIN(combo_find));
#else
entry_find = gtk_entry_new(); entry_find = gtk_entry_new();
gtk_table_attach_defaults(GTK_TABLE(table), entry_find, 1, 2, 0, 1); gtk_table_attach_defaults(GTK_TABLE(table), entry_find, 1, 2, 0, 1);
#endif
gtk_label_set_mnemonic_widget(GTK_LABEL(label_find), entry_find); gtk_label_set_mnemonic_widget(GTK_LABEL(label_find), entry_find);
#if !SEARCH_HISTORY
gtk_dialog_set_response_sensitive(GTK_DIALOG(dialog), gtk_dialog_set_response_sensitive(GTK_DIALOG(dialog),
GTK_RESPONSE_OK, FALSE); GTK_RESPONSE_OK, FALSE);
entry_len = 0; entry_len = 0;
@ -321,10 +349,37 @@ gint run_dialog_search(GtkWidget *textview, gint mode)
gtk_dialog_set_response_sensitive(GTK_DIALOG(dialog), gtk_dialog_set_response_sensitive(GTK_DIALOG(dialog),
GTK_RESPONSE_OK, TRUE); GTK_RESPONSE_OK, TRUE);
} }
#endif
#if SEARCH_HISTORY
gtk_entry_set_activates_default(GTK_ENTRY(entry_find), TRUE);
g_signal_connect_after(G_OBJECT(entry_find), "insert-text",
G_CALLBACK(toggle_sensitivity), NULL);
g_signal_connect_after(G_OBJECT(entry_find), "delete-text",
G_CALLBACK(toggle_sensitivity), NULL);
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (textview));
if (gtk_text_buffer_get_selection_bounds (buffer, &start_iter, &end_iter)) {
if (string_find != NULL)
g_free(string_find);
string_find = gtk_text_buffer_get_text (buffer, &start_iter, &end_iter,
FALSE);
gtk_entry_set_text(GTK_ENTRY(entry_find), string_find);
gtk_dialog_set_response_sensitive(GTK_DIALOG(dialog),
GTK_RESPONSE_OK, TRUE);
}
else
gtk_entry_set_text(GTK_ENTRY(entry_find), "");
#endif
if (mode) { if (mode) {
label_replace = gtk_label_new_with_mnemonic(_("Re_place with:")); label_replace = gtk_label_new_with_mnemonic(_("Re_place with:"));
gtk_misc_set_alignment(GTK_MISC(label_replace), 0, 0.5); gtk_misc_set_alignment(GTK_MISC(label_replace), 0, 0.5);
gtk_table_attach_defaults(GTK_TABLE(table), label_replace, 0, 1, 1, 2); gtk_table_attach_defaults(GTK_TABLE(table), label_replace, 0, 1, 1, 2);
#if SEARCH_HISTORY
combo_replace = create_combo_with_history (&replace_history);
gtk_table_attach_defaults(GTK_TABLE(table), combo_replace, 1, 2, 1, 2);
entry_replace = gtk_bin_get_child(GTK_BIN(combo_replace));
gtk_label_set_mnemonic_widget(GTK_LABEL(label_replace), entry_replace);
gtk_entry_set_text(GTK_ENTRY(entry_replace), "");
#else
entry_replace = gtk_entry_new(); entry_replace = gtk_entry_new();
gtk_table_attach_defaults(GTK_TABLE(table), entry_replace, 1, 2, 1, 2); gtk_table_attach_defaults(GTK_TABLE(table), entry_replace, 1, 2, 1, 2);
gtk_label_set_mnemonic_widget(GTK_LABEL(label_replace), entry_replace); gtk_label_set_mnemonic_widget(GTK_LABEL(label_replace), entry_replace);
@ -334,26 +389,45 @@ gint run_dialog_search(GtkWidget *textview, gint mode)
gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_OK); gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_OK);
gtk_entry_set_activates_default(GTK_ENTRY(entry_find), TRUE); gtk_entry_set_activates_default(GTK_ENTRY(entry_find), TRUE);
if (mode) if (mode)
#endif
gtk_entry_set_activates_default(GTK_ENTRY(entry_replace), TRUE); gtk_entry_set_activates_default(GTK_ENTRY(entry_replace), TRUE);
#if !SEARCH_HISTORY
check_case = gtk_check_button_new_with_mnemonic(_("_Match case")); check_case = gtk_check_button_new_with_mnemonic(_("_Match case"));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_case), match_case); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_case), match_case);
g_signal_connect(check_case, "toggled", G_CALLBACK(toggle_check_case), NULL); g_signal_connect(check_case, "toggled", G_CALLBACK(toggle_check_case), NULL);
gtk_table_attach_defaults (GTK_TABLE(table), check_case, 0, 2, 1 + mode, 2 + mode); gtk_table_attach_defaults (GTK_TABLE(table), check_case, 0, 2, 1 + mode, 2 + mode);
if (mode) { if (mode) {
#endif
check_all = gtk_check_button_new_with_mnemonic(_("Replace _all at once")); check_all = gtk_check_button_new_with_mnemonic(_("Replace _all at once"));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_all), replace_all); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_all), replace_all);
g_signal_connect(check_all, "toggled", G_CALLBACK(toggle_check_all), NULL); g_signal_connect(check_all, "toggled", G_CALLBACK(toggle_check_all), NULL);
gtk_table_attach_defaults(GTK_TABLE(table), check_all, 0, 2, 2 + mode, 3 + mode); gtk_table_attach_defaults(GTK_TABLE(table), check_all, 0, 2, 2 + mode, 3 + mode);
} }
#if SEARCH_HISTORY
gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_OK);
toggle_sensitivity (entry_find);
check_case = gtk_check_button_new_with_mnemonic(_("_Match case"));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_case), match_case);
g_signal_connect(check_case, "toggled", G_CALLBACK(toggle_check_case), NULL);
gtk_table_attach_defaults (GTK_TABLE(table), check_case, 0, 2, 1 + mode, 2 + mode);
#endif
gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE); gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE);
gtk_widget_show_all(table); gtk_widget_show_all(table);
res = gtk_dialog_run(GTK_DIALOG(dialog)); res = gtk_dialog_run(GTK_DIALOG(dialog));
if (res == GTK_RESPONSE_OK) { if (res == GTK_RESPONSE_OK) {
#if SEARCH_HISTORY
update_combo_data (entry_find, &find_history);
if (string_find != NULL)
#endif
g_free(string_find); g_free(string_find);
string_find = g_strdup(gtk_entry_get_text(GTK_ENTRY(entry_find))); string_find = g_strdup(gtk_entry_get_text(GTK_ENTRY(entry_find)));
if (mode) { if (mode) {
#if SEARCH_HISTORY
update_combo_data (entry_replace, &replace_history);
if (string_replace != NULL)
#endif
g_free(string_replace); g_free(string_replace);
string_replace = g_strdup(gtk_entry_get_text(GTK_ENTRY(entry_replace))); string_replace = g_strdup(gtk_entry_get_text(GTK_ENTRY(entry_replace)));
} }

View File

@ -104,3 +104,62 @@ GtkWidget *create_button_with_stock_image(const gchar *text, const gchar *stock_
return button; return button;
} }
#if SEARCH_HISTORY
void update_combo_data (GtkWidget *entry, GList **history)
{
const gchar *text;
GList *node;
text = gtk_entry_get_text (GTK_ENTRY (entry));
if (*text == '\0')
return;
for (node = *history; node != NULL; node = g_list_next (node))
{
if (g_str_equal ((gchar *)node->data, text))
{
g_free (node->data);
*history = g_list_delete_link (*history, node);
break;
}
}
*history = g_list_prepend (*history, g_strdup (text));
}
GtkWidget *create_combo_with_history (GList **history)
{
GtkWidget *combo;
GList *node;
combo = gtk_combo_box_text_new_with_entry ();
//work around gtk silliness -
//'appears-as-list' is a read-only style property instead of a widget property
gtk_rc_parse_string (
"style \"list-style-style\" { GtkComboBox::appears-as-list = 1 } "
"widget \"*.list-style\" style \"list-style-style\"");
gtk_widget_set_name (combo, "list-style");
for (node = *history; node != NULL; node = g_list_next (node))
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), node->data);
gtk_widget_show (combo);
return combo;
}
#if 0 /* if we want to cleanup before exit ... */
void clear_combo_history (GList *history)
{
GList *node;
if (history != NULL)
{
for (node = history; node != NULL; node = g_list_next (node))
{
if (node->data != NULL)
g_free (node->data);
}
g_list_free (history);
history = NULL;
}
}
#endif
#endif

View File

@ -24,5 +24,9 @@
gchar *gedit_utils_get_stdin(void); gchar *gedit_utils_get_stdin(void);
#endif #endif
GtkWidget *create_button_with_stock_image(const gchar *text, const gchar *stock_id); GtkWidget *create_button_with_stock_image(const gchar *text, const gchar *stock_id);
#if SEARCH_HISTORY
void update_combo_data(GtkWidget *entry, GList **history);
GtkWidget *create_combo_with_history(GList **history);
#endif
#endif /* _UTILS_H */ #endif /* _UTILS_H */