2 * Copyright (c) 2011 Conformal Systems LLC <info@conformal.com>
3 * Copyright (c) 2011 Marco Peereboom <marco@peereboom.us>
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
32 #include <sys/types.h>
34 #if defined(__linux__)
35 #include "linux/util.h"
36 #include "linux/tree.h"
37 #include <bsd/stdlib.h>
38 # if !defined(sane_libbsd_headers)
39 void arc4random_buf(void *, size_t);
41 #elif defined(__FreeBSD__)
43 #include "freebsd/util.h"
49 #include <sys/queue.h>
50 #include <sys/resource.h>
51 #include <sys/socket.h>
57 #include <gdk/gdkkeysyms.h>
59 #if GTK_CHECK_VERSION(3,0,0)
60 /* we still use GDK_* instead of GDK_KEY_* */
61 #include <gdk/gdkkeysyms-compat.h>
64 #include <webkit/webkit.h>
65 #include <libsoup/soup.h>
66 #include <JavaScriptCore/JavaScript.h>
67 #include <gnutls/gnutls.h>
68 #include <gnutls/x509.h>
70 /* comment if you don't want to use threads */
79 #include "javascript.h"
81 javascript.h borrowed from vimprobable2 under the following license:
83 Copyright (c) 2009 Leon Winter
84 Copyright (c) 2009-2011 Hannes Schueller
85 Copyright (c) 2009-2010 Matto Fransen
86 Copyright (c) 2010-2011 Hans-Peter Deifel
87 Copyright (c) 2010-2011 Thomas Adam
88 Copyright (c) 2011 Albert Kim
89 Copyright (c) 2011 Daniel Carl
91 Permission is hereby granted, free of charge, to any person obtaining a copy
92 of this software and associated documentation files (the "Software"), to deal
93 in the Software without restriction, including without limitation the rights
94 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
95 copies of the Software, and to permit persons to whom the Software is
96 furnished to do so, subject to the following conditions:
98 The above copyright notice and this permission notice shall be included in
99 all copies or substantial portions of the Software.
101 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
102 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
103 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
104 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
105 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
106 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
112 #define DPRINTF(x...) do { if (swm_debug) fprintf(stderr, x); } while (0)
113 #define DNPRINTF(n,x...) do { if (swm_debug & n) fprintf(stderr, x); } while (0)
114 #define XT_D_MOVE 0x0001
115 #define XT_D_KEY 0x0002
116 #define XT_D_TAB 0x0004
117 #define XT_D_URL 0x0008
118 #define XT_D_CMD 0x0010
119 #define XT_D_NAV 0x0020
120 #define XT_D_DOWNLOAD 0x0040
121 #define XT_D_CONFIG 0x0080
122 #define XT_D_JS 0x0100
123 #define XT_D_FAVORITE 0x0200
124 #define XT_D_PRINTING 0x0400
125 #define XT_D_COOKIE 0x0800
126 #define XT_D_KEYBINDING 0x1000
127 #define XT_D_CLIP 0x2000
128 #define XT_D_BUFFERCMD 0x4000
129 #define XT_D_INSPECTOR 0x8000
130 extern u_int32_t swm_debug
;
132 #define DPRINTF(x...)
133 #define DNPRINTF(n,x...)
136 #define LENGTH(x) (sizeof x / sizeof x[0])
137 #define CLEAN(mask) (mask & ~(GDK_MOD2_MASK) & \
138 ~(GDK_BUTTON1_MASK) & \
139 ~(GDK_BUTTON2_MASK) & \
140 ~(GDK_BUTTON3_MASK) & \
141 ~(GDK_BUTTON4_MASK) & \
144 #define XT_NOMARKS (('z' - 'a' + 1) * 2 + 10)
147 TAILQ_ENTRY(tab
) entry
;
149 GtkWidget
*tab_content
;
158 GtkWidget
*uri_entry
;
159 GtkWidget
*search_entry
;
161 GtkWidget
*browser_win
;
162 GtkWidget
*statusbar_box
;
164 GtkWidget
*statusbar
;
165 GtkWidget
*buffercmd
;
176 GtkWidget
*js_toggle
;
177 GtkEntryCompletion
*completion
;
181 WebKitWebHistoryItem
*item
;
182 WebKitWebBackForwardList
*bfl
;
185 WebKitNetworkRequest
*icon_request
;
186 WebKitDownload
*icon_download
;
187 gchar
*icon_dest_uri
;
189 /* adjustments for browser */
192 GtkAdjustment
*adjust_h
;
193 GtkAdjustment
*adjust_v
;
199 int xtp_meaning
; /* identifies dls/favorites */
201 int popup
; /* 1 if cmd_entry has popup visible */
203 /* https thread stuff */
211 /* custom stylesheet */
221 WebKitWebSettings
*settings
;
225 double mark
[XT_NOMARKS
];
227 TAILQ_HEAD(tab_list
, tab
);
229 GtkWidget
*create_window(const gchar
*);
232 WebKitWebView
* inspector_inspect_web_view_cb(WebKitWebInspector
*,
233 WebKitWebView
*, struct tab
*);
234 void setup_inspector(struct tab
*);