static char *buildpath(const char *path);
static gboolean buttonreleased(GtkWidget *w, GdkEventKey *e, Client *c);
static void cleanup(void);
-static void clipboard(Client *c, const Arg *arg);
+static void clipboard(Client *c, const Arg *a);
static WebKitCookieAcceptPolicy cookiepolicy_get(void);
static char cookiepolicy_set(const WebKitCookieAcceptPolicy p);
static void getpagestat(Client *c);
static char *geturi(Client *c);
static const gchar *getstyle(const char *uri);
-static void setstyle(Client *c, const char *style);
+static void setstyle(Client *c, const char *stylefile);
static void handleplumb(Client *c, const gchar *uri);
static void newwindow(Client *c, const Arg *arg, gboolean noembed);
static GtkWidget *createwindow(Client *c);
static void pasteuri(GtkClipboard *clipboard, const char *text, gpointer d);
-static void print(Client *c, const Arg *arg);
+static void print(Client *c, const Arg *a);
static GdkFilterReturn processx(GdkXEvent *xevent, GdkEvent *event,
gpointer d);
static gboolean winevent(GtkWidget *w, GdkEvent *e, Client *c);
}
void
-clipboard(Client *c, const Arg *arg)
+clipboard(Client *c, const Arg *a)
{
- gboolean paste = *(gboolean *)arg;
-
- if (paste) {
+ if (a->b) { /* load clipboard uri */
gtk_clipboard_request_text(gtk_clipboard_get(
GDK_SELECTION_PRIMARY),
pasteuri, c);
- } else {
+ } else { /* copy uri */
gtk_clipboard_set_text(gtk_clipboard_get(
- GDK_SELECTION_PRIMARY), c->linkhover
- ? c->linkhover : geturi(c), -1);
+ GDK_SELECTION_PRIMARY), c->targeturi
+ ? c->targeturi : geturi(c), -1);
}
}
}
void
-setstyle(Client *c, const char *style)
+setstyle(Client *c, const char *stylefile)
{
- WebKitWebSettings *settings = webkit_web_view_get_settings(c->view);
+ gchar *style;
+
+ if (!g_file_get_contents(stylefile, &style, NULL, NULL)) {
+ fprintf(stderr, "Could not read style file: %s\n", stylefile);
+ return;
+ }
- g_object_set(G_OBJECT(settings), "user-stylesheet-uri", style, NULL);
+ webkit_user_content_manager_add_style_sheet(
+ webkit_web_view_get_user_content_manager(c->view),
+ webkit_user_style_sheet_new(style,
+ WEBKIT_USER_CONTENT_INJECT_ALL_FRAMES,
+ WEBKIT_USER_STYLE_LEVEL_USER,
+ NULL, NULL));
+
+ g_free(style);
}
void
}
void
-print(Client *c, const Arg *arg)
+print(Client *c, const Arg *a)
{
- webkit_web_frame_print(webkit_web_view_get_main_frame(c->view));
+ webkit_print_operation_run_dialog(webkit_print_operation_new(c->view),
+ GTK_WINDOW(c->win));
}
GdkFilterReturn
setup(void)
{
int i;
- char *styledirfile, *stylepath;
WebKitWebContext *context;
GError *error = NULL;
cookiefile = buildfile(cookiefile);
scriptfile = buildfile(scriptfile);
cachedir = buildpath(cachedir);
+
if (stylefile == NULL) {
styledir = buildpath(styledir);
for (i = 0; i < LENGTH(styles); i++) {
styles[i].regex);
styles[i].regex = NULL;
}
- styledirfile = g_strconcat(styledir, "/",
- styles[i].style, NULL);
- stylepath = buildfile(styledirfile);
- styles[i].style = g_strconcat("file://", stylepath,
- NULL);
- g_free(styledirfile);
- g_free(stylepath);
+ styles[i].style = g_strconcat(styledir, "/",
+ styles[i].style, NULL);
}
g_free(styledir);
} else {
- stylepath = buildfile(stylefile);
- stylefile = g_strconcat("file://", stylepath, NULL);
- g_free(stylepath);
+ stylefile = buildfile(stylefile);
}
}