Renamed TextFuncs and its members; removed workaround for bug 314335
This commit is contained in:
parent
adfe739a1a
commit
577b5e40a8
@ -245,19 +245,7 @@ _moo_file_entry_completion_init (MooFileEntryCompletion *cmpl)
|
||||
|
||||
cmpl->priv->case_sensitive = CASE_SENSITIVE_DEFAULT;
|
||||
cmpl->priv->visible_func = (MooFileVisibleFunc) completion_default_visible_func;
|
||||
|
||||
if (cmpl->priv->case_sensitive)
|
||||
{
|
||||
cmpl->priv->text_funcs.file_equals_func = file_equals_func;
|
||||
cmpl->priv->text_funcs.file_has_prefix_func = file_has_prefix_func;
|
||||
cmpl->priv->text_funcs.normalize_func = normalize_func;
|
||||
}
|
||||
else
|
||||
{
|
||||
cmpl->priv->text_funcs.file_equals_func = case_file_equals_func;
|
||||
cmpl->priv->text_funcs.file_has_prefix_func = case_file_has_prefix_func;
|
||||
cmpl->priv->text_funcs.normalize_func = case_normalize_func;
|
||||
}
|
||||
set_text_funcs(&cmpl->priv->text_funcs, cmpl->priv->case_sensitive);
|
||||
|
||||
model = _moo_folder_model_new (NULL);
|
||||
cmpl->priv->model = _moo_folder_filter_new (MOO_FOLDER_MODEL (model));
|
||||
@ -748,20 +736,7 @@ completion_set_case_sensitive (MooFileEntryCompletion *cmpl,
|
||||
if (case_sensitive != cmpl->priv->case_sensitive)
|
||||
{
|
||||
cmpl->priv->case_sensitive = case_sensitive;
|
||||
|
||||
if (case_sensitive)
|
||||
{
|
||||
cmpl->priv->text_funcs.file_equals_func = file_equals_func;
|
||||
cmpl->priv->text_funcs.file_has_prefix_func = file_has_prefix_func;
|
||||
cmpl->priv->text_funcs.normalize_func = normalize_func;
|
||||
}
|
||||
else
|
||||
{
|
||||
cmpl->priv->text_funcs.file_equals_func = case_file_equals_func;
|
||||
cmpl->priv->text_funcs.file_has_prefix_func = case_file_has_prefix_func;
|
||||
cmpl->priv->text_funcs.normalize_func = case_normalize_func;
|
||||
}
|
||||
|
||||
set_text_funcs (&cmpl->priv->text_funcs, case_sensitive);
|
||||
g_object_notify (G_OBJECT (cmpl), "case-sensitive");
|
||||
}
|
||||
}
|
||||
@ -1318,13 +1293,13 @@ completion_visible_func (GtkTreeModel *model,
|
||||
}
|
||||
else if (cmpl->priv->visible_func (file, cmpl->priv->visible_func_data))
|
||||
{
|
||||
visible = cmpl->priv->text_funcs.file_has_prefix_func (file,
|
||||
cmpl->priv->display_basename,
|
||||
cmpl->priv->display_basename_len);
|
||||
visible = cmpl->priv->text_funcs.file_has_prefix (file,
|
||||
cmpl->priv->display_basename,
|
||||
cmpl->priv->display_basename_len);
|
||||
}
|
||||
|
||||
_moo_file_unref (file);
|
||||
return visible ? TRUE : FALSE; /* #314335 */
|
||||
return visible;
|
||||
}
|
||||
|
||||
|
||||
|
@ -25,43 +25,43 @@
|
||||
|
||||
|
||||
/* TODO: strncmp should accept char len, not byte len? */
|
||||
typedef struct {
|
||||
gboolean (*file_equals_func) (MooFile *file,
|
||||
const char *str);
|
||||
gboolean (*file_has_prefix_func) (MooFile *file,
|
||||
const char *str,
|
||||
guint len);
|
||||
char* (*normalize_func) (const char *str,
|
||||
gssize len);
|
||||
typedef struct TextFuncs {
|
||||
gboolean (*file_equals) (MooFile *file,
|
||||
const char *str);
|
||||
gboolean (*file_has_prefix) (MooFile *file,
|
||||
const char *str,
|
||||
guint len);
|
||||
char* (*normalize) (const char *str,
|
||||
gssize len);
|
||||
} TextFuncs;
|
||||
|
||||
|
||||
static gboolean
|
||||
file_equals_func (MooFile *file,
|
||||
const char *str)
|
||||
file_equals (MooFile *file,
|
||||
const char *str)
|
||||
{
|
||||
return !strcmp (str, _moo_file_display_name (file));
|
||||
}
|
||||
|
||||
static gboolean
|
||||
file_has_prefix_func (MooFile *file,
|
||||
const char *str,
|
||||
guint len)
|
||||
file_has_prefix (MooFile *file,
|
||||
const char *str,
|
||||
guint len)
|
||||
{
|
||||
return !strncmp (str, _moo_file_display_name (file), len);
|
||||
}
|
||||
|
||||
static char *
|
||||
normalize_func (const char *str,
|
||||
gssize len)
|
||||
normalize (const char *str,
|
||||
gssize len)
|
||||
{
|
||||
return g_utf8_normalize (str, len, G_NORMALIZE_ALL);
|
||||
}
|
||||
|
||||
|
||||
static char *
|
||||
case_normalize_func (const char *str,
|
||||
gssize len)
|
||||
case_normalize (const char *str,
|
||||
gssize len)
|
||||
{
|
||||
char *norm = g_utf8_normalize (str, len, G_NORMALIZE_ALL);
|
||||
char *res = g_utf8_casefold (norm, -1);
|
||||
@ -70,24 +70,43 @@ case_normalize_func (const char *str,
|
||||
}
|
||||
|
||||
static gboolean
|
||||
case_file_equals_func (MooFile *file,
|
||||
const char *str)
|
||||
case_file_equals (MooFile *file,
|
||||
const char *str)
|
||||
{
|
||||
char *temp = case_normalize_func (str, -1);
|
||||
gboolean ret = !strcmp (temp, _moo_file_case_display_name (file));
|
||||
g_free (temp);
|
||||
return ret;
|
||||
char *temp = case_normalize (str, -1);
|
||||
gboolean ret = !strcmp (temp, _moo_file_case_display_name (file));
|
||||
g_free (temp);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
case_file_has_prefix_func (MooFile *file,
|
||||
const char *str,
|
||||
guint len)
|
||||
case_file_has_prefix (MooFile *file,
|
||||
const char *str,
|
||||
guint len)
|
||||
{
|
||||
char *temp = case_normalize_func (str, len);
|
||||
gboolean ret = g_str_has_prefix (_moo_file_case_display_name (file), temp);
|
||||
g_free (temp);
|
||||
return ret;
|
||||
char *temp = case_normalize (str, len);
|
||||
gboolean ret = g_str_has_prefix (_moo_file_case_display_name (file), temp);
|
||||
g_free (temp);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
set_text_funcs (TextFuncs *funcs,
|
||||
gboolean case_sensitive)
|
||||
{
|
||||
if (case_sensitive)
|
||||
{
|
||||
funcs->file_equals = file_equals;
|
||||
funcs->file_has_prefix = file_has_prefix;
|
||||
funcs->normalize = normalize;
|
||||
}
|
||||
else
|
||||
{
|
||||
funcs->file_equals = case_file_equals;
|
||||
funcs->file_has_prefix = case_file_has_prefix;
|
||||
funcs->normalize = case_normalize;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -104,7 +123,7 @@ model_find_next_match (GtkTreeModel *model,
|
||||
|
||||
g_return_val_if_fail (text != NULL, FALSE);
|
||||
|
||||
normalized_text = funcs->normalize_func (text, len);
|
||||
normalized_text = funcs->normalize (text, len);
|
||||
normalized_text_len = strlen (normalized_text);
|
||||
|
||||
while (TRUE)
|
||||
@ -117,12 +136,11 @@ model_find_next_match (GtkTreeModel *model,
|
||||
if (file)
|
||||
{
|
||||
if (exact_match)
|
||||
match = funcs->file_equals_func (file, normalized_text);
|
||||
match = funcs->file_equals (file, normalized_text);
|
||||
else
|
||||
match = funcs->file_has_prefix_func (file,
|
||||
normalized_text,
|
||||
normalized_text_len);
|
||||
|
||||
match = funcs->file_has_prefix (file,
|
||||
normalized_text,
|
||||
normalized_text_len);
|
||||
_moo_file_unref (file);
|
||||
|
||||
if (match)
|
||||
|
@ -4809,7 +4809,7 @@ typeahead_tab_key (MooFileView *fileview)
|
||||
name = _moo_file_display_name (file);
|
||||
|
||||
#if 0
|
||||
if (!file || !stuff->file_equals_func (file, stuff->matched_prefix->str))
|
||||
if (!file || !stuff->file_equals (file, stuff->matched_prefix->str))
|
||||
goto error;
|
||||
#endif
|
||||
|
||||
@ -4846,7 +4846,7 @@ typeahead_tab_key (MooFileView *fileview)
|
||||
goto error;
|
||||
|
||||
#if 0
|
||||
// if (!stuff->file_has_prefix_func (file, stuff->matched_prefix->str, stuff->matched_prefix->len))
|
||||
// if (!stuff->file_has_prefix (file, stuff->matched_prefix->str, stuff->matched_prefix->len))
|
||||
// goto error;
|
||||
#endif
|
||||
|
||||
@ -4895,19 +4895,7 @@ typeahead_create (MooFileView *fileview)
|
||||
stuff->fileview = fileview;
|
||||
stuff->entry = fileview->priv->entry;
|
||||
stuff->case_sensitive = fileview->priv->typeahead_case_sensitive;
|
||||
|
||||
if (stuff->case_sensitive)
|
||||
{
|
||||
stuff->text_funcs.file_equals_func = file_equals_func;
|
||||
stuff->text_funcs.file_has_prefix_func = file_has_prefix_func;
|
||||
stuff->text_funcs.normalize_func = normalize_func;
|
||||
}
|
||||
else
|
||||
{
|
||||
stuff->text_funcs.file_equals_func = case_file_equals_func;
|
||||
stuff->text_funcs.file_has_prefix_func = case_file_has_prefix_func;
|
||||
stuff->text_funcs.normalize_func = case_normalize_func;
|
||||
}
|
||||
set_text_funcs (&stuff->text_funcs, stuff->case_sensitive);
|
||||
|
||||
fileview->priv->typeahead = stuff;
|
||||
}
|
||||
@ -4936,19 +4924,7 @@ _moo_file_view_set_typeahead_case_sensitive (MooFileView *fileview,
|
||||
|
||||
fileview->priv->typeahead_case_sensitive = case_sensitive;
|
||||
stuff->case_sensitive = case_sensitive;
|
||||
|
||||
if (case_sensitive)
|
||||
{
|
||||
stuff->text_funcs.file_equals_func = file_equals_func;
|
||||
stuff->text_funcs.file_has_prefix_func = file_has_prefix_func;
|
||||
stuff->text_funcs.normalize_func = normalize_func;
|
||||
}
|
||||
else
|
||||
{
|
||||
stuff->text_funcs.file_equals_func = case_file_equals_func;
|
||||
stuff->text_funcs.file_has_prefix_func = case_file_has_prefix_func;
|
||||
stuff->text_funcs.normalize_func = case_normalize_func;
|
||||
}
|
||||
set_text_funcs (&stuff->text_funcs, case_sensitive);
|
||||
|
||||
g_object_notify (G_OBJECT (fileview), "typeahead-case-sensitive");
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user