|
@@ -36,13 +36,66 @@ struct _OupisWindow
|
|
|
|
|
|
|
|
G_DEFINE_FINAL_TYPE (OupisWindow, oupis_window, ADW_TYPE_APPLICATION_WINDOW)
|
|
G_DEFINE_FINAL_TYPE (OupisWindow, oupis_window, ADW_TYPE_APPLICATION_WINDOW)
|
|
|
|
|
|
|
|
|
|
+static gchar*
|
|
|
|
|
+str_to_lc_ascii (const gchar* string)
|
|
|
|
|
+{
|
|
|
|
|
+ gchar* str_lc_ascii;
|
|
|
|
|
+ str_lc_ascii = g_utf8_strdown (string, -1);
|
|
|
|
|
+ return g_str_to_ascii (str_lc_ascii, NULL);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
static void
|
|
static void
|
|
|
oupis_window__search_request (GtkSearchEntry *self,
|
|
oupis_window__search_request (GtkSearchEntry *self,
|
|
|
gpointer userdata)
|
|
gpointer userdata)
|
|
|
{
|
|
{
|
|
|
const char* request;
|
|
const char* request;
|
|
|
|
|
+ char* request_lc_ascii;
|
|
|
|
|
+ GFile * directory;
|
|
|
|
|
+ GFileEnumerator * direnum;
|
|
|
|
|
+ GError *error = NULL;
|
|
|
|
|
+ GFileInfo *info;
|
|
|
|
|
+ const gchar *infoname;
|
|
|
|
|
+ gchar *infoname_lc_ascii;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
request = gtk_editable_get_text (GTK_EDITABLE (self));
|
|
request = gtk_editable_get_text (GTK_EDITABLE (self));
|
|
|
- g_print ("%s\n", request);
|
|
|
|
|
|
|
+ g_print ("Request: %s\n", request);
|
|
|
|
|
+ request_lc_ascii = str_to_lc_ascii (request);
|
|
|
|
|
+ g_print (" R_l_a: %s\n", request_lc_ascii);
|
|
|
|
|
+
|
|
|
|
|
+ directory = g_file_new_for_path (".");
|
|
|
|
|
+
|
|
|
|
|
+ direnum = g_file_enumerate_children (directory,
|
|
|
|
|
+ "standard::name,standard::display-name",
|
|
|
|
|
+ G_FILE_QUERY_INFO_NONE,
|
|
|
|
|
+ NULL,
|
|
|
|
|
+ NULL);
|
|
|
|
|
+ g_object_unref (directory);
|
|
|
|
|
+
|
|
|
|
|
+ while (TRUE)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (!g_file_enumerator_iterate (direnum, &info, NULL, NULL, &error))
|
|
|
|
|
+ goto out;
|
|
|
|
|
+ if (!info)
|
|
|
|
|
+ break;
|
|
|
|
|
+ infoname = g_file_info_get_name (info);
|
|
|
|
|
+ infoname_lc_ascii = str_to_lc_ascii (infoname);
|
|
|
|
|
+
|
|
|
|
|
+ if (g_strrstr (infoname_lc_ascii, request_lc_ascii)) {
|
|
|
|
|
+ g_print ("%s\n", infoname);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ out:
|
|
|
|
|
+ if (error) {
|
|
|
|
|
+ g_print("%s\n", error->message);
|
|
|
|
|
+ g_error_free (error);
|
|
|
|
|
+ }
|
|
|
|
|
+ g_object_unref (direnum); // Note: frees the last @info
|
|
|
|
|
+
|
|
|
|
|
+ g_free (request_lc_ascii);
|
|
|
|
|
+ g_free (infoname_lc_ascii);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
static void
|