diff --git a/plugins/dsx/gtkrecent/Makefile b/plugins/dsx/gtkrecent/Makefile new file mode 100644 index 00000000..b17d8b5b --- /dev/null +++ b/plugins/dsx/gtkrecent/Makefile @@ -0,0 +1,10 @@ +CC = gcc +CFLAGS = -shared -fPIC -Wl,--no-as-needed +INCLUDES = `pkg-config --cflags --libs gtk+-3.0` -I../../sdk +PLUGNAME = gtkrecent.dsx + +all: + $(CC) $(CFLAGS) $(INCLUDES) plugin.c -o $(PLUGNAME) + +clean: + $(RM) $(PLUGNAME) diff --git a/plugins/dsx/gtkrecent/plugin.c b/plugins/dsx/gtkrecent/plugin.c new file mode 100644 index 00000000..8d6a1c7e --- /dev/null +++ b/plugins/dsx/gtkrecent/plugin.c @@ -0,0 +1,70 @@ +#include +#include +#include +#include "dsxplugin.h" + +tSAddFileProc gAddFileProc; +tSUpdateStatusProc gUpdateStatus; + +gboolean stop_search; + + +int DCPCALL Init(tDsxDefaultParamStruct* dsp, tSAddFileProc pAddFileProc, tSUpdateStatusProc pUpdateStatus) +{ + gAddFileProc = pAddFileProc; + gUpdateStatus = pUpdateStatus; + return 0; +} + +void DCPCALL StartSearch(int PluginNr, tDsxSearchRecord* pSearchRec) +{ + GList *list; + gsize i = 1; + GPatternSpec *pattern; + GtkRecentManager *manager; + stop_search = FALSE; + + gUpdateStatus(PluginNr, "not found", 0); + manager = gtk_recent_manager_get_default(); + list = gtk_recent_manager_get_items(manager); + pattern = g_pattern_spec_new(pSearchRec->FileMask); + + while (!stop_search && list != NULL) + { + const gchar *uri = gtk_recent_info_get_uri(list->data); + + if (uri) + { + gchar *fname = g_filename_from_uri(uri, NULL, NULL); + + if (fname && strncmp(fname, pSearchRec->StartPath, strlen(pSearchRec->StartPath)) == 0) + { + if (g_pattern_match_string(pattern, g_path_get_basename(fname))) + { + gAddFileProc(PluginNr, fname); + gUpdateStatus(PluginNr, fname, i++); + } + } + + } + + gtk_recent_info_unref(list->data); + list = list->next; + } + + g_list_free(list); + g_pattern_spec_free(pattern); + + + gAddFileProc(PluginNr, ""); +} + +void DCPCALL StopSearch(int PluginNr) +{ + stop_search = TRUE; +} + +void DCPCALL Finalize(int PluginNr) +{ + +}