unsigned int stopevent;
} Button;
+
+typedef struct {
+ char *token;
+ char *uri;
+} SearchEngine;
+
typedef struct {
const char *uri;
Parameter config[ParameterLast];
static void msgext(Client *c, char type, const Arg *a);
static void destroyclient(Client *c);
static void cleanup(void);
+static void updatehistory(const char *u, const char *t);
/* GTK/WebKit */
static WebKitWebView *newview(Client *c, WebKitWebView *rv);
Client *c);
static void closeview(WebKitWebView *v, Client *c);
static void destroywin(GtkWidget* w, Client *c);
+static gchar *parseuri(const gchar *uri);
/* Hotkeys */
static void pasteuri(GtkClipboard *clipboard, const char *text, gpointer d);
static void togglecookiepolicy(Client *c, const Arg *a);
static void toggleinspector(Client *c, const Arg *a);
static void find(Client *c, const Arg *a);
+static void playexternal(Client *c, const Arg *a);
/* Buttons */
static void clicknavigate(Client *c, const Arg *a, WebKitHitTestResult *h);
curconfig = defconfig;
/* dirs and files */
- cookiefile = buildfile(cookiefile);
- scriptfile = buildfile(scriptfile);
- cachedir = buildpath(cachedir);
- certdir = buildpath(certdir);
+ cookiefile = buildfile(cookiefile);
+ historyfile = buildfile(historyfile);
+ scriptfile = buildfile(scriptfile);
+ cachedir = buildpath(cachedir);
+ certdir = buildpath(certdir);
gdkkb = gdk_seat_get_keyboard(gdk_display_get_default_seat(gdpy));
url = g_strdup_printf("file://%s", path);
free(path);
} else {
- url = g_strdup_printf("http://%s", uri);
+ url = parseuri(uri);
}
if (apath != uri)
free(apath);
close(pipein[0]);
close(pipeout[1]);
g_free(cookiefile);
+ g_free(historyfile);
g_free(scriptfile);
g_free(stylefile);
g_free(cachedir);
XCloseDisplay(dpy);
}
+void
+updatehistory(const char *u, const char *t)
+{
+ FILE *f;
+ f = fopen(historyfile, "a+");
+
+ char b[20];
+ time_t now = time (0);
+ strftime (b, 20, "%Y-%m-%d %H:%M:%S", localtime (&now));
+ fputs(b, f);
+
+ fprintf(f, " %s %s\n", u, t);
+ fclose(f);
+}
+
WebKitWebView *
newview(Client *c, WebKitWebView *rv)
{
return TRUE;
}
+
void
loadchanged(WebKitWebView *v, WebKitLoadEvent e, Client *c)
{
break;
case WEBKIT_LOAD_FINISHED:
seturiparameters(c, uri, loadfinished);
+ updatehistory(uri, c->title);
/* Disabled until we write some WebKitWebExtension for
* manipulating the DOM directly.
evalscript(c, "document.documentElement.style.overflow = '%s'",
gtk_main_quit();
}
+gchar *
+parseuri(const gchar *uri) {
+ guint i;
+
+ for (i = 0; i < LENGTH(searchengines); i++) {
+ if (searchengines[i].token == NULL || searchengines[i].uri == NULL ||
+ *(uri + strlen(searchengines[i].token)) != ' ')
+ continue;
+ if (g_str_has_prefix(uri, searchengines[i].token))
+ return g_strdup_printf(searchengines[i].uri,
+ uri + strlen(searchengines[i].token) + 1);
+ }
+
+ return g_strdup_printf("http://%s", uri);
+}
+
void
pasteuri(GtkClipboard *clipboard, const char *text, gpointer d)
{
spawn(c, &arg);
}
+void
+playexternal(Client *c, const Arg *a)
+{
+ Arg arg;
+
+ arg = (Arg)VIDEOPLAY(geturi(c));
+ spawn(c, &arg);
+}
+
int
main(int argc, char *argv[])
{