tAdapt inspector handling - surf - customized build of surf, the suckless webkit browser
 (HTM) git clone git://src.adamsgaard.dk/surf
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit c4f01cd18bf69dd24153f110be500ccc59eff498
 (DIR) parent 0b5b798eb24ee6978c3ae932942105bf53122fe1
 (HTM) Author: Quentin Rameau <quinq@fifth.space>
       Date:   Fri, 20 Nov 2015 00:44:29 +0100
       
       Adapt inspector handling
       
       The inspector is now easily manageable via API, there's no need for
       keeping its state in the Client.
       
       Diffstat:
         M config.def.h                        |       2 +-
         M surf.c                              |      60 ++++---------------------------
       
       2 files changed, 8 insertions(+), 54 deletions(-)
       ---
 (DIR) diff --git a/config.def.h b/config.def.h
       t@@ -109,7 +109,7 @@ static Key keys[] = {
        
                { 0,                     GDK_KEY_F11,    togglefullscreen, { 0 } },
                { 0,                     GDK_KEY_Escape, stop,       { 0 } },
       -        { MODKEY|GDK_SHIFT_MASK, GDK_KEY_o,      inspector,  { 0 } },
       +        { MODKEY|GDK_SHIFT_MASK, GDK_KEY_o,      toggleinspector, { 0 } },
        
                { MODKEY,                GDK_KEY_g,      spawn,      SETPROP("_SURF_URI", "_SURF_GO") },
                { MODKEY,                GDK_KEY_f,      spawn,      SETPROP("_SURF_FIND", "_SURF_FIND") },
 (DIR) diff --git a/surf.c b/surf.c
       t@@ -65,7 +65,7 @@ typedef struct Client {
                const char *needle;
                gint progress;
                struct Client *next;
       -        gboolean zoomed, fullscreen, isinspecting;
       +        gboolean zoomed, fullscreen;
        } Client;
        
        typedef struct {
       t@@ -144,12 +144,7 @@ static void downloadstarted(WebKitWebContext *wc, WebKitDownload *d,
        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);
       t@@ -722,60 +717,16 @@ download(Client *c, WebKitURIResponse *r)
        }
        
        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)
       t@@ -1025,6 +976,9 @@ showview(WebKitWebView *v, Client *c)
        
                c->win = createwindow(c);
        
       +        if (enableinspector)
       +                c->inspector = webkit_web_view_get_inspector(c->view);
       +
                if (!kioskmode)
                        addaccelgroup(c);