const char *needle;
gint progress;
struct Client *next;
- gboolean zoomed, fullscreen, isinspecting;
+ gboolean zoomed, fullscreen;
} Client;
typedef struct {
static void responsereceived(WebKitDownload *d, GParamSpec *ps, Client *c);
static void download(Client *c, WebKitURIResponse *r);
-static void inspector(Client *c, const Arg *arg);
-static WebKitWebView *inspector_new(WebKitWebInspector *i, WebKitWebView *v,
- Client *c);
-static gboolean inspector_show(WebKitWebInspector *i, Client *c);
-static gboolean inspector_close(WebKitWebInspector *i, Client *c);
-static void inspector_finished(WebKitWebInspector *i, Client *c);
+static void toggleinspector(Client *c, const Arg *a);
static gboolean keypress(GtkAccelGroup *group, GObject *obj, guint key,
GdkModifierType mods, Client *c);
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);
static void linkopen(Client *c, const Arg *arg);
static void linkopenembed(Client *c, const Arg *arg);
static void reload(Client *c, const Arg *arg);
-static void scroll_h(Client *c, const Arg *arg);
-static void scroll_v(Client *c, const Arg *arg);
-static void scroll(GtkAdjustment *a, const Arg *arg);
+static void scroll_h(Client *c, const Arg *a);
+static void scroll_v(Client *c, const Arg *a);
static void setatom(Client *c, int a, const char *v);
static void setup(void);
static void sigchld(int unused);
}
void
-inspector(Client *c, const Arg *arg)
+toggleinspector(Client *c, const Arg *a)
{
if (enableinspector) {
- if (c->isinspecting)
+ if (webkit_web_inspector_is_attached(c->inspector))
webkit_web_inspector_close(c->inspector);
else
webkit_web_inspector_show(c->inspector);
}
}
-WebKitWebView *
-inspector_new(WebKitWebInspector *i, WebKitWebView *v, Client *c)
-{
- return WEBKIT_WEB_VIEW(webkit_web_view_new());
-}
-
-gboolean
-inspector_show(WebKitWebInspector *i, Client *c)
-{
- WebKitWebView *w;
-
- if (c->isinspecting)
- return false;
-
- w = webkit_web_inspector_get_web_view(i);
- gtk_paned_pack2(GTK_PANED(c->pane), GTK_WIDGET(w), TRUE, TRUE);
- gtk_widget_show(GTK_WIDGET(w));
- c->isinspecting = true;
-
- return true;
-}
-
-gboolean
-inspector_close(WebKitWebInspector *i, Client *c)
-{
- GtkWidget *w;
-
- if (!c->isinspecting)
- return false;
-
- w = GTK_WIDGET(webkit_web_inspector_get_web_view(i));
- gtk_widget_hide(w);
- gtk_widget_destroy(w);
- c->isinspecting = false;
-
- return true;
-}
-
-void
-inspector_finished(WebKitWebInspector *i, Client *c)
-{
- g_free(c->inspector);
-}
-
gboolean
keypress(GtkAccelGroup *group, GObject *obj, guint key, GdkModifierType mods,
Client *c)
c->win = createwindow(c);
+ if (enableinspector)
+ c->inspector = webkit_web_view_get_inspector(c->view);
+
if (!kioskmode)
addaccelgroup(c);
}
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
}
void
-scroll_h(Client *c, const Arg *arg)
-{
- scroll(gtk_scrolled_window_get_hadjustment(
- GTK_SCROLLED_WINDOW(c->scroll)), arg);
-}
-
-void
-scroll_v(Client *c, const Arg *arg)
+scroll_h(Client *c, const Arg *a)
{
- scroll(gtk_scrolled_window_get_vadjustment(
- GTK_SCROLLED_WINDOW(c->scroll)), arg);
+ evalscript(c, "window.scrollBy(%d * (window.innerWidth / 100), 0)",
+ a->i);
}
void
-scroll(GtkAdjustment *a, const Arg *arg)
+scroll_v(Client *c, const Arg *a)
{
- gdouble v;
-
- v = gtk_adjustment_get_value(a);
- switch (arg->i) {
- case +10000:
- case -10000:
- v += gtk_adjustment_get_page_increment(a) * (arg->i / 10000);
- break;
- case +20000:
- case -20000:
- default:
- v += gtk_adjustment_get_step_increment(a) * arg->i;
- }
-
- v = MAX(v, 0.0);
- v = MIN(v, gtk_adjustment_get_upper(a) -
- gtk_adjustment_get_page_size(a));
- gtk_adjustment_set_value(a, v);
+ evalscript(c, "window.scrollBy(0, %d * (window.innerHeight / 100))",
+ a->i);
}
void
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);
}
}