Continue making chars const
[surf.git] / surf.c
diff --git a/surf.c b/surf.c
index edfc3c3..faf712f 100644 (file)
--- a/surf.c
+++ b/surf.c
@@ -56,8 +56,8 @@ enum {
 };
 
 typedef union {
-       gboolean b;
-       gint i;
+       int b;
+       int i;
        const void *v;
 } Arg;
 
@@ -69,8 +69,7 @@ typedef struct Client {
        WebKitHitTestResult *mousepos;
        GTlsCertificateFlags tlsflags;
        Window xid;
-       gint progress;
-       gboolean fullscreen;
+       int progress, fullscreen;
        const char *title, *targeturi;
        const char *needle;
        struct Client *next;
@@ -108,7 +107,7 @@ static char *buildpath(const char *path);
 static Client *newclient(Client *c);
 static void addaccelgroup(Client *c);
 static void loaduri(Client *c, const Arg *a);
-static char *geturi(Client *c);
+static const char *geturi(Client *c);
 static void setatom(Client *c, int a, const char *v);
 static const char *getatom(Client *c, int a);
 static void updatetitle(Client *c);
@@ -116,13 +115,13 @@ static void gettogglestats(Client *c);
 static void getpagestats(Client *c);
 static WebKitCookieAcceptPolicy cookiepolicy_get(void);
 static char cookiepolicy_set(const WebKitCookieAcceptPolicy p);
-static const gchar *getstyle(const char *uri);
+static const char *getstyle(const char *uri);
 static void setstyle(Client *c, const char *stylefile);
 static void runscript(Client *c);
 static void evalscript(Client *c, const char *jsstr, ...);
 static void updatewinid(Client *c);
-static void handleplumb(Client *c, const gchar *uri);
-static void newwindow(Client *c, const Arg *a, gboolean noembed);
+static void handleplumb(Client *c, const char *uri);
+static void newwindow(Client *c, const Arg *a, int noembed);
 static void spawn(Client *c, const Arg *a);
 static void destroyclient(Client *c);
 static void cleanup(void);
@@ -131,7 +130,7 @@ static void cleanup(void);
 static WebKitWebView *newview(Client *c, WebKitWebView *rv);
 static GtkWidget *createview(WebKitWebView *v, WebKitNavigationAction *a,
                              Client *c);
-static gboolean buttonreleased(GtkWidget *w, GdkEventKey *e, Client *c);
+static gboolean buttonreleased(GtkWidget *w, GdkEvent *e, Client *c);
 static gboolean keypress(GtkAccelGroup *group, GObject *obj, guint key,
                          GdkModifierType mods, Client *c);
 static GdkFilterReturn processx(GdkXEvent *xevent, GdkEvent *event,
@@ -185,7 +184,7 @@ static char togglestats[10];
 static char pagestats[2];
 static Atom atoms[AtomLast];
 static Window embed;
-static gboolean showxid = FALSE;
+static int showxid;
 static int cookiepolicy;
 static Display *dpy;
 static Client *clients;
@@ -392,12 +391,12 @@ loaduri(Client *c, const Arg *a)
        g_free(url);
 }
 
-char *
+const char *
 geturi(Client *c)
 {
-       char *uri;
+       const char *uri;
 
-       if (!(uri = (char *)webkit_web_view_get_uri(c->view)))
+       if (!(uri = webkit_web_view_get_uri(c->view)))
                uri = "about:blank";
        return uri;
 }
@@ -513,7 +512,7 @@ cookiepolicy_set(const WebKitCookieAcceptPolicy p)
        return 'A';
 }
 
-const gchar *
+const char *
 getstyle(const char *uri)
 {
        int i;
@@ -582,7 +581,7 @@ updatewinid(Client *c)
 }
 
 void
-handleplumb(Client *c, const gchar *uri)
+handleplumb(Client *c, const char *uri)
 {
        Arg a = (Arg)PLUMB(uri);
        spawn(c, &a);
@@ -814,18 +813,17 @@ createview(WebKitWebView *v, WebKitNavigationAction *a, Client *c)
 }
 
 gboolean
-buttonreleased(GtkWidget *w, GdkEventKey *e, Client *c)
+buttonreleased(GtkWidget *w, GdkEvent *e, Client *c)
 {
        WebKitHitTestResultContext element;
-       GdkEventButton *eb = (GdkEventButton*)e;
        int i;
 
        element = webkit_hit_test_result_get_context(c->mousepos);
 
        for (i = 0; i < LENGTH(buttons); ++i) {
                if (element & buttons[i].target &&
-                   eb->button == buttons[i].button &&
-                   CLEANMASK(eb->state) == CLEANMASK(buttons[i].mask) &&
+                   e->button.button == buttons[i].button &&
+                   CLEANMASK(e->button.state) == CLEANMASK(buttons[i].mask) &&
                    buttons[i].func) {
                        buttons[i].func(c, &buttons[i].arg, c->mousepos);
                        return buttons[i].stopevent;
@@ -1235,8 +1233,7 @@ pasteuri(GtkClipboard *clipboard, const char *text, gpointer d)
 void
 reload(Client *c, const Arg *a)
 {
-       gboolean nocache = *(gboolean *)a;
-       if (nocache)
+       if (a->b)
                webkit_web_view_reload_bypass_cache(c->view);
        else
                webkit_web_view_reload(c->view);
@@ -1542,7 +1539,7 @@ main(int argc, char *argv[])
                die("surf-"VERSION", ©2009-2015 surf engineers, "
                    "see LICENSE for details\n");
        case 'x':
-               showxid = TRUE;
+               showxid = 1;
                break;
        case 'z':
                zoomlevel = strtof(EARGF(usage()), NULL);