misc/mc.ext.in: added 3gp video
[free-mc.git] / src / viewer / dialogs.c
blob9b96e323819c2921b08095d7d831363a713b50ff
1 /*
2 Internal file viewer for the Midnight Commander
3 Function for paint dialogs
5 Copyright (C) 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002, 2003,
6 2004, 2005, 2006, 2007, 2009 Free Software Foundation, Inc.
8 Written by: 1994, 1995, 1998 Miguel de Icaza
9 1994, 1995 Janne Kukonlehto
10 1995 Jakub Jelinek
11 1996 Joseph M. Hinkle
12 1997 Norbert Warmuth
13 1998 Pavel Machek
14 2004 Roland Illig <roland.illig@gmx.de>
15 2005 Roland Illig <roland.illig@gmx.de>
16 2009 Slava Zanko <slavazanko@google.com>
17 2009 Andrew Borodin <aborodin@vmail.ru>
18 2009 Ilia Maslakov <il.smind@gmail.com>
20 This file is part of the Midnight Commander.
22 The Midnight Commander is free software; you can redistribute it
23 and/or modify it under the terms of the GNU General Public License as
24 published by the Free Software Foundation; either version 2 of the
25 License, or (at your option) any later version.
27 The Midnight Commander is distributed in the hope that it will be
28 useful, but WITHOUT ANY WARRANTY; without even the implied warranty
29 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30 General Public License for more details.
32 You should have received a copy of the GNU General Public License
33 along with this program; if not, write to the Free Software
34 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
35 MA 02110-1301, USA.
38 #include <config.h>
40 #include <stdlib.h>
41 #include <sys/types.h>
43 #include "../src/search/search.h"
45 #include "../src/global.h"
46 #include "../src/wtools.h"
47 #include "../src/history.h"
48 #include "../src/charsets.h"
50 #include "internal.h"
52 /*** global variables ****************************************************************************/
54 /*** file scope macro definitions ****************************************************************/
56 /*** file scope type declarations ****************************************************************/
58 /*** file scope variables ************************************************************************/
60 /*** file scope functions ************************************************************************/
62 /*** public functions ****************************************************************************/
64 /* --------------------------------------------------------------------------------------------- */
66 gboolean
67 mcview_dialog_search (mcview_t * view)
69 int SEARCH_DLG_MIN_HEIGHT = 12;
70 int SEARCH_DLG_HEIGHT_SUPPLY = 3;
71 int SEARCH_DLG_WIDTH = 58;
73 char *exp = NULL;
74 int qd_result;
76 size_t num_of_types;
77 gchar **list_of_types = mc_search_get_types_strings_array (&num_of_types);
78 int SEARCH_DLG_HEIGHT = SEARCH_DLG_MIN_HEIGHT + num_of_types - SEARCH_DLG_HEIGHT_SUPPLY;
80 QuickWidget quick_widgets[] =
82 QUICK_BUTTON (6, 10, SEARCH_DLG_HEIGHT - 3, SEARCH_DLG_HEIGHT, N_("&Cancel"), B_CANCEL, NULL),
83 QUICK_BUTTON (2, 10, SEARCH_DLG_HEIGHT - 3, SEARCH_DLG_HEIGHT, N_("&OK"), B_ENTER, NULL),
84 #ifdef HAVE_CHARSET
85 QUICK_CHECKBOX (SEARCH_DLG_WIDTH / 2 + 3, SEARCH_DLG_WIDTH, 8, SEARCH_DLG_HEIGHT,
86 N_("All charsets"), &view->search_all_codepages),
87 #endif
88 QUICK_CHECKBOX (SEARCH_DLG_WIDTH / 2 + 3, SEARCH_DLG_WIDTH, 7, SEARCH_DLG_HEIGHT,
89 N_("&Whole words"), &view->whole_words),
90 QUICK_CHECKBOX (SEARCH_DLG_WIDTH / 2 + 3, SEARCH_DLG_WIDTH, 6, SEARCH_DLG_HEIGHT,
91 N_("&Backwards"), &view->search_backwards),
92 QUICK_CHECKBOX (SEARCH_DLG_WIDTH / 2 + 3, SEARCH_DLG_WIDTH, 5, SEARCH_DLG_HEIGHT,
93 N_("case &Sensitive"), &view->search_case),
94 QUICK_RADIO (3, SEARCH_DLG_WIDTH, 5, SEARCH_DLG_HEIGHT,
95 num_of_types, (const char **) list_of_types, (int *) &view->search_type),
96 QUICK_INPUT (3, SEARCH_DLG_WIDTH, 3, SEARCH_DLG_HEIGHT,
97 INPUT_LAST_TEXT, SEARCH_DLG_WIDTH - 6, 0, MC_HISTORY_SHARED_SEARCH, &exp),
98 QUICK_LABEL (2, SEARCH_DLG_WIDTH, 2, SEARCH_DLG_HEIGHT, N_(" Enter search string:")),
99 QUICK_END
102 QuickDialog Quick_input =
104 SEARCH_DLG_WIDTH, SEARCH_DLG_HEIGHT, -1, -1,
105 N_("Search"), "[Input Line Keys]",
106 quick_widgets, FALSE
109 qd_result = quick_dialog (&Quick_input);
110 g_strfreev (list_of_types);
112 if ((qd_result == B_CANCEL) ||(exp == NULL) || (exp[0] == '\0')) {
113 g_free (exp);
114 return FALSE;
117 #ifdef HAVE_CHARSET
119 GString *tmp = str_convert_to_input (exp);
121 if (tmp) {
122 g_free (exp);
123 exp = g_string_free (tmp, FALSE);
126 #endif
128 g_free (view->last_search_string);
129 view->last_search_string = exp;
130 exp = NULL;
132 if (view->search_nroff_seq)
133 mcview_nroff_seq_free (&(view->search_nroff_seq));
135 if (view->search)
136 mc_search_free (view->search);
138 view->search = mc_search_new (view->last_search_string, -1);
139 view->search_nroff_seq = mcview_nroff_seq_new (view);
140 if (!view->search) {
141 g_free (exp);
142 return FALSE;
145 view->search->search_type = view->search_type;
146 view->search->is_all_charsets = view->search_all_codepages;
147 view->search->is_case_sentitive = view->search_case;
148 view->search->search_fn = mcview_search_cmd_callback;
149 view->search->update_fn = mcview_search_update_cmd_callback;
150 view->search->whole_words = view->whole_words;
152 g_free (exp);
153 return TRUE;