shell_util_normalize_and_casefold: New utility function
Merge the duplicated copies into shell-util.
This commit is contained in:
parent
10dcc100e9
commit
c5de239e25
@ -15,6 +15,7 @@
|
|||||||
#include "shell-app-private.h"
|
#include "shell-app-private.h"
|
||||||
#include "shell-window-tracker-private.h"
|
#include "shell-window-tracker-private.h"
|
||||||
#include "shell-global.h"
|
#include "shell-global.h"
|
||||||
|
#include "shell-util.h"
|
||||||
#include "st.h"
|
#include "st.h"
|
||||||
|
|
||||||
/* Vendor prefixes are something that can be preprended to a .desktop
|
/* Vendor prefixes are something that can be preprended to a .desktop
|
||||||
@ -619,20 +620,6 @@ sort_and_concat_results (ShellAppSystem *system,
|
|||||||
return g_slist_concat (multiple_prefix_matches, g_slist_concat (prefix_matches, g_slist_concat (multiple_substring_matches, substring_matches)));
|
return g_slist_concat (multiple_prefix_matches, g_slist_concat (prefix_matches, g_slist_concat (multiple_substring_matches, substring_matches)));
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
|
||||||
normalize_and_casefold (const char *str)
|
|
||||||
{
|
|
||||||
char *normalized, *result;
|
|
||||||
|
|
||||||
if (str == NULL)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
normalized = g_utf8_normalize (str, -1, G_NORMALIZE_ALL);
|
|
||||||
result = g_utf8_casefold (normalized, -1);
|
|
||||||
g_free (normalized);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* normalize_terms:
|
* normalize_terms:
|
||||||
* @terms: (element-type utf8): Input search terms
|
* @terms: (element-type utf8): Input search terms
|
||||||
@ -647,7 +634,7 @@ normalize_terms (GSList *terms)
|
|||||||
for (iter = terms; iter; iter = iter->next)
|
for (iter = terms; iter; iter = iter->next)
|
||||||
{
|
{
|
||||||
const char *term = iter->data;
|
const char *term = iter->data;
|
||||||
normalized_terms = g_slist_prepend (normalized_terms, normalize_and_casefold (term));
|
normalized_terms = g_slist_prepend (normalized_terms, shell_util_normalize_and_casefold (term));
|
||||||
}
|
}
|
||||||
return normalized_terms;
|
return normalized_terms;
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#include "shell-app-private.h"
|
#include "shell-app-private.h"
|
||||||
#include "shell-enum-types.h"
|
#include "shell-enum-types.h"
|
||||||
#include "shell-global.h"
|
#include "shell-global.h"
|
||||||
|
#include "shell-util.h"
|
||||||
#include "shell-window-tracker-private.h"
|
#include "shell-window-tracker-private.h"
|
||||||
#include "st.h"
|
#include "st.h"
|
||||||
|
|
||||||
@ -1125,20 +1126,6 @@ unref_running_state (ShellAppRunningState *state)
|
|||||||
g_slice_free (ShellAppRunningState, state);
|
g_slice_free (ShellAppRunningState, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
|
||||||
normalize_and_casefold (const char *str)
|
|
||||||
{
|
|
||||||
char *normalized, *result;
|
|
||||||
|
|
||||||
if (str == NULL)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
normalized = g_utf8_normalize (str, -1, G_NORMALIZE_ALL);
|
|
||||||
result = g_utf8_casefold (normalized, -1);
|
|
||||||
g_free (normalized);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
trim_exec_line (const char *str)
|
trim_exec_line (const char *str)
|
||||||
{
|
{
|
||||||
@ -1166,13 +1153,13 @@ shell_app_init_search_data (ShellApp *app)
|
|||||||
|
|
||||||
appinfo = gmenu_tree_entry_get_app_info (app->entry);
|
appinfo = gmenu_tree_entry_get_app_info (app->entry);
|
||||||
name = g_app_info_get_name (G_APP_INFO (appinfo));
|
name = g_app_info_get_name (G_APP_INFO (appinfo));
|
||||||
app->casefolded_name = normalize_and_casefold (name);
|
app->casefolded_name = shell_util_normalize_and_casefold (name);
|
||||||
|
|
||||||
comment = g_app_info_get_description (G_APP_INFO (appinfo));
|
comment = g_app_info_get_description (G_APP_INFO (appinfo));
|
||||||
app->casefolded_description = normalize_and_casefold (comment);
|
app->casefolded_description = shell_util_normalize_and_casefold (comment);
|
||||||
|
|
||||||
exec = g_app_info_get_executable (G_APP_INFO (appinfo));
|
exec = g_app_info_get_executable (G_APP_INFO (appinfo));
|
||||||
normalized_exec = normalize_and_casefold (exec);
|
normalized_exec = shell_util_normalize_and_casefold (exec);
|
||||||
app->casefolded_exec = trim_exec_line (normalized_exec);
|
app->casefolded_exec = trim_exec_line (normalized_exec);
|
||||||
g_free (normalized_exec);
|
g_free (normalized_exec);
|
||||||
}
|
}
|
||||||
|
@ -506,6 +506,20 @@ shell_util_get_transformed_allocation (ClutterActor *actor,
|
|||||||
box->y2 = y_max;
|
box->y2 = y_max;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char *
|
||||||
|
shell_util_normalize_and_casefold (const char *str)
|
||||||
|
{
|
||||||
|
char *normalized, *result;
|
||||||
|
|
||||||
|
if (str == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
normalized = g_utf8_normalize (str, -1, G_NORMALIZE_ALL);
|
||||||
|
result = g_utf8_casefold (normalized, -1);
|
||||||
|
g_free (normalized);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* shell_util_format_date:
|
* shell_util_format_date:
|
||||||
* @format: a strftime-style string format, as parsed by
|
* @format: a strftime-style string format, as parsed by
|
||||||
|
@ -21,6 +21,9 @@ void shell_util_get_transformed_allocation (ClutterActor *actor,
|
|||||||
ClutterActorBox *box);
|
ClutterActorBox *box);
|
||||||
|
|
||||||
int shell_util_get_week_start (void);
|
int shell_util_get_week_start (void);
|
||||||
|
|
||||||
|
char *shell_util_normalize_and_casefold (const char *str);
|
||||||
|
|
||||||
char *shell_util_format_date (const char *format,
|
char *shell_util_format_date (const char *format,
|
||||||
gint64 time_ms);
|
gint64 time_ms);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user