Ticket 1375: new design of 'Find File' dialog.
* src/find.c: + New design of 'Find File' dialog. + odification of search results dialog: listbox which contains search results is not scrolled now. New behavior avoids dialog blinking :) and allows the walk through the list during search. Added counter of found items. + Check regexp before search. + For glib >= 2.14.0, use GQueue for directory queue. + Fixed memory leak. + Some optimization. + More type accuracy. + Formatting. Fixed typo. Clean up. * src/widget.c: (listbox_select_by_number): don't operate with non-existing list. * src/search/*: + (mc_search_prepare): new function that allows check if regexp is valid before search (Slava Zanko). + Removed redundant chek for g_free (). Use g_free() instead of free(). Signed-off-by: Andrew Borodin <borodin@borodin.zarya>
Этот коммит содержится в:
родитель
9283c14213
Коммит
d5f1442438
620
src/find.c
620
src/find.c
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
@ -513,7 +513,7 @@ mc_search__cond_struct_new_init_regex (const char *charset, mc_search_t * mc_sea
|
||||
if (error) {
|
||||
mc_search->error = MC_SEARCH_E_REGEX_COMPILE;
|
||||
mc_search->error_str = g_strdup (error);
|
||||
free (mc_search_cond->regex_handle);
|
||||
g_free (mc_search_cond->regex_handle);
|
||||
mc_search_cond->regex_handle = NULL;
|
||||
return;
|
||||
}
|
||||
|
@ -84,51 +84,6 @@ mc_search__cond_struct_new (mc_search_t * mc_search, const char *str,
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static GPtrArray *
|
||||
mc_search__conditions_new (mc_search_t * mc_search)
|
||||
{
|
||||
GPtrArray *ret;
|
||||
ret = g_ptr_array_new ();
|
||||
#ifdef HAVE_CHARSET
|
||||
if (mc_search->is_all_charsets) {
|
||||
gsize loop1, recoded_str_len;
|
||||
gchar *buffer;
|
||||
for (loop1 = 0; loop1 < (gsize) n_codepages; loop1++) {
|
||||
if (!g_ascii_strcasecmp (codepages[loop1].id, cp_source)) {
|
||||
g_ptr_array_add (ret,
|
||||
mc_search__cond_struct_new (mc_search, mc_search->original,
|
||||
mc_search->original_len, cp_source));
|
||||
continue;
|
||||
}
|
||||
|
||||
buffer =
|
||||
mc_search__recode_str (mc_search->original, mc_search->original_len, cp_source,
|
||||
codepages[loop1].id, &recoded_str_len);
|
||||
if (buffer == NULL)
|
||||
continue;
|
||||
|
||||
g_ptr_array_add (ret,
|
||||
mc_search__cond_struct_new (mc_search, buffer,
|
||||
recoded_str_len, codepages[loop1].id));
|
||||
g_free (buffer);
|
||||
}
|
||||
} else {
|
||||
g_ptr_array_add (ret,
|
||||
(gpointer) mc_search__cond_struct_new (mc_search, mc_search->original,
|
||||
mc_search->original_len,
|
||||
cp_source));
|
||||
}
|
||||
#else
|
||||
g_ptr_array_add (ret,
|
||||
(gpointer) mc_search__cond_struct_new (mc_search, mc_search->original,
|
||||
mc_search->original_len,
|
||||
str_detect_termencoding ()));
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static void
|
||||
mc_search__cond_struct_free (mc_search_cond_t * mc_search_cond)
|
||||
{
|
||||
@ -145,8 +100,7 @@ mc_search__cond_struct_free (mc_search_cond_t * mc_search_cond)
|
||||
if (mc_search_cond->regex_handle)
|
||||
g_regex_unref (mc_search_cond->regex_handle);
|
||||
#else /* GLIB_CHECK_VERSION (2, 14, 0) */
|
||||
if (mc_search_cond->regex_handle)
|
||||
free (mc_search_cond->regex_handle);
|
||||
g_free (mc_search_cond->regex_handle);
|
||||
#endif /* GLIB_CHECK_VERSION (2, 14, 0) */
|
||||
|
||||
g_free (mc_search_cond);
|
||||
@ -201,9 +155,7 @@ mc_search_free (mc_search_t * mc_search)
|
||||
return;
|
||||
|
||||
g_free (mc_search->original);
|
||||
|
||||
if (mc_search->error_str)
|
||||
g_free (mc_search->error_str);
|
||||
g_free (mc_search->error_str);
|
||||
|
||||
if (mc_search->conditions)
|
||||
mc_search__conditions_free (mc_search->conditions);
|
||||
@ -212,8 +164,7 @@ mc_search_free (mc_search_t * mc_search)
|
||||
if (mc_search->regex_match_info)
|
||||
g_match_info_free (mc_search->regex_match_info);
|
||||
#else /* GLIB_CHECK_VERSION (2, 14, 0) */
|
||||
if (mc_search->regex_match_info)
|
||||
free (mc_search->regex_match_info);
|
||||
g_free (mc_search->regex_match_info);
|
||||
#endif /* GLIB_CHECK_VERSION (2, 14, 0) */
|
||||
|
||||
if (mc_search->regex_buffer != NULL)
|
||||
@ -224,6 +175,53 @@ mc_search_free (mc_search_t * mc_search)
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
gboolean
|
||||
mc_search_prepare (mc_search_t * mc_search)
|
||||
{
|
||||
GPtrArray *ret;
|
||||
ret = g_ptr_array_new ();
|
||||
#ifdef HAVE_CHARSET
|
||||
if (mc_search->is_all_charsets) {
|
||||
gsize loop1, recoded_str_len;
|
||||
gchar *buffer;
|
||||
for (loop1 = 0; loop1 < (gsize) n_codepages; loop1++) {
|
||||
if (!g_ascii_strcasecmp (codepages[loop1].id, cp_source)) {
|
||||
g_ptr_array_add (ret,
|
||||
mc_search__cond_struct_new (mc_search, mc_search->original,
|
||||
mc_search->original_len, cp_source));
|
||||
continue;
|
||||
}
|
||||
|
||||
buffer =
|
||||
mc_search__recode_str (mc_search->original, mc_search->original_len, cp_source,
|
||||
codepages[loop1].id, &recoded_str_len);
|
||||
if (buffer == NULL)
|
||||
continue;
|
||||
|
||||
g_ptr_array_add (ret,
|
||||
mc_search__cond_struct_new (mc_search, buffer,
|
||||
recoded_str_len, codepages[loop1].id));
|
||||
g_free (buffer);
|
||||
}
|
||||
} else {
|
||||
g_ptr_array_add (ret,
|
||||
(gpointer) mc_search__cond_struct_new (mc_search, mc_search->original,
|
||||
mc_search->original_len,
|
||||
cp_source));
|
||||
}
|
||||
#else
|
||||
g_ptr_array_add (ret,
|
||||
(gpointer) mc_search__cond_struct_new (mc_search, mc_search->original,
|
||||
mc_search->original_len,
|
||||
str_detect_termencoding ()));
|
||||
#endif
|
||||
mc_search->conditions = ret;
|
||||
|
||||
return (mc_search->error == MC_SEARCH_E_OK);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
gboolean
|
||||
mc_search_run (mc_search_t * mc_search, const void *user_data,
|
||||
gsize start_search, gsize end_search, gsize * found_len)
|
||||
@ -245,17 +243,12 @@ mc_search_run (mc_search_t * mc_search, const void *user_data,
|
||||
#endif /* GLIB_CHECK_VERSION (2, 14, 0) */
|
||||
|
||||
mc_search->error = MC_SEARCH_E_OK;
|
||||
if (mc_search->error_str) {
|
||||
g_free (mc_search->error_str);
|
||||
mc_search->error_str = NULL;
|
||||
}
|
||||
g_free (mc_search->error_str);
|
||||
mc_search->error_str = NULL;
|
||||
|
||||
if (!mc_search->conditions) {
|
||||
mc_search->conditions = mc_search__conditions_new (mc_search);
|
||||
if ((mc_search->conditions == NULL) && !mc_search_prepare (mc_search))
|
||||
return FALSE;
|
||||
|
||||
if (mc_search->error != MC_SEARCH_E_OK)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
switch (mc_search->search_type) {
|
||||
case MC_SEARCH_T_NORMAL:
|
||||
|
@ -106,6 +106,8 @@ mc_search_t *mc_search_new (const gchar * original, gsize original_len);
|
||||
|
||||
void mc_search_free (mc_search_t * mc_search);
|
||||
|
||||
gboolean mc_search_prepare (mc_search_t * mc_search);
|
||||
|
||||
gboolean mc_search_run (mc_search_t * mc_search, const void *user_data, gsize start_search,
|
||||
gsize end_search, gsize * founded_len);
|
||||
|
||||
|
@ -2376,7 +2376,8 @@ listbox_add_item (WListbox *l, enum append_pos pos, int hotkey,
|
||||
void
|
||||
listbox_select_by_number (WListbox *l, int n)
|
||||
{
|
||||
listbox_select_entry (l, listbox_select_pos (l, l->list, n));
|
||||
if (l->list != NULL)
|
||||
listbox_select_entry (l, listbox_select_pos (l, l->list, n));
|
||||
}
|
||||
|
||||
WLEntry *
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user