-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
80 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
#include <glib.h> | ||
#include <gtk/gtk.h> | ||
#include <string.h> | ||
#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) | ||
{ | ||
|
||
} |