Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 323 lines (248 sloc) 7.429 kb
9ac2796 @robm moved bindings to uzbl.bindings
robm authored
1 /*
2 * See LICENSE for license details
3 *
4 * Changelog:
5 * ---------
6 *
7 * (c) 2009 by Robert Manea
8 * - introduced struct concept
9 * - statusbar template
10 *
11 */
a7ffb38 @robm move globals to structs, another round.
robm authored
12
02710b3 @robm added default status_format
robm authored
13 #define STATUS_DEFAULT "<span background=\"darkblue\" foreground=\"white\"> MODE </span> <span background=\"red\" foreground=\"white\">KEYCMD</span> (LOAD_PROGRESS%) <b>TITLE</b> - Uzbl browser"
14
b329cac @DuClare Add SET handling for useragent.
DuClare authored
15 enum {
16 /* statusbar symbols */
17 SYM_TITLE, SYM_URI, SYM_NAME,
18 SYM_LOADPRGS, SYM_LOADPRGSBAR,
19 SYM_KEYCMD, SYM_MODE, SYM_MSG,
20 /* useragent symbols */
21 SYM_WK_MAJ, SYM_WK_MIN, SYM_WK_MIC,
22 SYM_SYSNAME, SYM_NODENAME,
23 SYM_KERNREL, SYM_KERNVER,
24 SYM_ARCHSYS, SYM_ARCHUZBL,
25 SYM_DOMAINNAME, SYM_COMMIT
26 };
27
ef4b3ca @robm refactored status bar template symbol definition and setup
robm authored
28 const struct {
29 gchar *symbol_name;
ba6aeb5 @DuClare Revert "Fix warnings caused by casts between ints and pointers on 64bit"
DuClare authored
30 guint symbol_token;
ef4b3ca @robm refactored status bar template symbol definition and setup
robm authored
31 } symbols[] = {
32 {"NAME", SYM_NAME},
33 {"URI", SYM_URI},
34 {"TITLE", SYM_TITLE},
448aa22 @robm added KEYCMD to statusbar template
robm authored
35 {"KEYCMD", SYM_KEYCMD},
f7abb5e @robm added MODE symbol to statusbar template
robm authored
36 {"MODE", SYM_MODE},
9e0d672 @robm added status_msg and MSG to status template
robm authored
37 {"MSG", SYM_MSG},
ef4b3ca @robm refactored status bar template symbol definition and setup
robm authored
38 {"LOAD_PROGRESS", SYM_LOADPRGS},
39 {"LOAD_PROGRESSBAR", SYM_LOADPRGSBAR},
b329cac @DuClare Add SET handling for useragent.
DuClare authored
40
41 {"WEBKIT_MAJOR", SYM_WK_MAJ},
42 {"WEBKIT_MINOR", SYM_WK_MIN},
43 {"WEBKIT_MICRO", SYM_WK_MIC},
44 {"SYSNAME", SYM_SYSNAME},
45 {"NODENAME", SYM_NODENAME},
46 {"KERNREL", SYM_KERNREL},
47 {"KERNVER", SYM_KERNVER},
48 {"ARCH_SYSTEM", SYM_ARCHSYS},
49 {"ARCH_UZBL", SYM_ARCHUZBL},
50 {"DOMAINNAME", SYM_DOMAINNAME},
51 {"COMMIT", SYM_COMMIT},
ef4b3ca @robm refactored status bar template symbol definition and setup
robm authored
52 {NULL, 0}
53 }, *symp = symbols;
54
96c22d0 @anydot Move global variables into structs, first round
anydot authored
55 /* status bar elements */
56 typedef struct {
57 gint load_progress;
9e0d672 @robm added status_msg and MSG to status template
robm authored
58 gchar *msg;
96c22d0 @anydot Move global variables into structs, first round
anydot authored
59 } StatusBar;
60
a7ffb38 @robm move globals to structs, another round.
robm authored
61
96c22d0 @anydot Move global variables into structs, first round
anydot authored
62 /* gui elements */
63 typedef struct {
64 GtkWidget* main_window;
d6edddd @robm added status_top to cmd parser
robm authored
65 GtkWidget* scrolled_win;
66 GtkWidget* vbox;
96c22d0 @anydot Move global variables into structs, first round
anydot authored
67 GtkWidget* mainbar;
68 GtkWidget* mainbar_label;
69 GtkScrollbar* scbar_v; // Horizontal and Vertical Scrollbar
70 GtkScrollbar* scbar_h; // (These are still hidden)
71 GtkAdjustment* bar_v; // Information about document length
72 GtkAdjustment* bar_h; // and scrolling position
73 WebKitWebView* web_view;
74 gchar* main_title;
75
76 StatusBar sbar;
77 } GUI;
78
a7ffb38 @robm move globals to structs, another round.
robm authored
79
96c22d0 @anydot Move global variables into structs, first round
anydot authored
80 /* external communication*/
8f3fa4d @robm Move globals to structs, one more round. introducing struct Behaviour
robm authored
81 enum { FIFO, SOCKET};
96c22d0 @anydot Move global variables into structs, first round
anydot authored
82 typedef struct {
6aa99a6 @DuClare Added functionality for (re)setting fifo_dir.
DuClare authored
83 gchar *fifo_path;
84 gchar *socket_path;
06decd1 @robm first partially working command parser
robm authored
85 /* stores (key)"variable name" -> (value)"pointer to this var*/
86 GHashTable *proto_var;
87 /* command parsing regexes */
f2c9054 @DuClare Added CMD <foo> for invoking core commands via stdin and scripts.
DuClare authored
88 GRegex *set_regex;
89 GRegex *cmd_regex;
fd4821b @DuClare Move execution from key_press_cb to its own function, run_keycmd.
DuClare authored
90 GRegex *keycmd_regex;
06decd1 @robm first partially working command parser
robm authored
91 GRegex *get_regex;
92 GRegex *bind_regex;
96c22d0 @anydot Move global variables into structs, first round
anydot authored
93 } Communication;
94
a7ffb38 @robm move globals to structs, another round.
robm authored
95
96c22d0 @anydot Move global variables into structs, first round
anydot authored
96 /* internal state */
97 typedef struct {
98 gchar *uri;
99 gchar *config_file;
06decd1 @robm first partially working command parser
robm authored
100 char *instance_name;
96c22d0 @anydot Move global variables into structs, first round
anydot authored
101 gchar config_file_path[500];
a7ffb38 @robm move globals to structs, another round.
robm authored
102 gchar selected_url[500];
103 char executable_path[500];
104 GString* keycmd;
105 gchar searchtx[500];
106 struct utsname unameinfo; /* system info */
96c22d0 @anydot Move global variables into structs, first round
anydot authored
107 } State;
108
a7ffb38 @robm move globals to structs, another round.
robm authored
109
8f3fa4d @robm Move globals to structs, one more round. introducing struct Behaviour
robm authored
110 /* networking */
0dc558f @robm Refactored networking variables to use the new struct concept
robm authored
111 typedef struct {
112 SoupSession *soup_session;
113 SoupLogger *soup_logger;
114 char *proxy_url;
115 char *useragent;
116 gint max_conns;
117 gint max_conns_host;
118 } Network;
119
a7ffb38 @robm move globals to structs, another round.
robm authored
120
8f3fa4d @robm Move globals to structs, one more round. introducing struct Behaviour
robm authored
121 /* behaviour */
122 typedef struct {
702868a @DuClare Added load_finish_handler, call when a page has finished loading.
DuClare authored
123 gchar* load_finish_handler;
9155f75 @Dieterbe support for changing the background color of the statusbar correctly
Dieterbe authored
124 gchar* status_format;
125 gchar* status_background;
8f3fa4d @robm Move globals to structs, one more round. introducing struct Behaviour
robm authored
126 gchar* history_handler;
127 gchar* fifo_dir;
128 gchar* socket_dir;
129 gchar* download_handler;
130 gchar* cookie_handler;
131 gboolean always_insert_mode;
132 gboolean show_status;
133 gboolean insert_mode;
134 gboolean status_top;
d5f76f3 @Dieterbe better name for resetting to command mode
Dieterbe authored
135 gboolean reset_command_mode;
8f3fa4d @robm Move globals to structs, one more round. introducing struct Behaviour
robm authored
136 gchar* modkey;
137 guint modmask;
138 guint http_debug;
a7ffb38 @robm move globals to structs, another round.
robm authored
139
140 /* command list: name -> Command */
141 GHashTable* commands;
8f3fa4d @robm Move globals to structs, one more round. introducing struct Behaviour
robm authored
142 } Behaviour;
143
0dc558f @robm Refactored networking variables to use the new struct concept
robm authored
144
96c22d0 @anydot Move global variables into structs, first round
anydot authored
145 /* main uzbl data structure */
146 typedef struct {
8f3fa4d @robm Move globals to structs, one more round. introducing struct Behaviour
robm authored
147 GUI gui;
148 State state;
149 Network net;
150 Behaviour behave;
96c22d0 @anydot Move global variables into structs, first round
anydot authored
151 Communication comm;
8f3fa4d @robm Move globals to structs, one more round. introducing struct Behaviour
robm authored
152
153 Window xwin;
154 GScanner *scan;
9ac2796 @robm moved bindings to uzbl.bindings
robm authored
155
156 /* group bindings: key -> action */
157 GHashTable* bindings;
96c22d0 @anydot Move global variables into structs, first round
anydot authored
158 } Uzbl;
159
a7ffb38 @robm move globals to structs, another round.
robm authored
160
8ba87ad @barrucadu Moved structs/function primitives to uzbl.h file, so we no longer need t...
barrucadu authored
161 typedef struct {
162 char* name;
163 char* param;
164 } Action;
165
fc2bff8 @robm added signal handling and a clean_up() function
robm authored
166 typedef void sigfunc(int);
50d7e59 @Dieterbe merge robm changes: instance naming + better socket code
Dieterbe authored
167
5247694 @robm removed eprint() and estrdup() from uzbl.h
robm authored
168 /* Functions */
fdb283b @robm Added a statusbar parser that allows using arbitrary templates for the s...
robm authored
169 static void
170 setup_scanner();
171
50d7e59 @Dieterbe merge robm changes: instance naming + better socket code
Dieterbe authored
172 char *
173 itos(int val);
174
fc2bff8 @robm added signal handling and a clean_up() function
robm authored
175 static void
176 clean_up(void);
177
178 static void
179 catch_sigterm(int s);
180
181 static sigfunc *
182 setup_signal(int signe, sigfunc *shandler);
183
8ba87ad @barrucadu Moved structs/function primitives to uzbl.h file, so we no longer need t...
barrucadu authored
184 static gboolean
185 new_window_cb (WebKitWebView *web_view, WebKitWebFrame *frame, WebKitNetworkRequest *request, WebKitWebNavigationAction *navigation_action, WebKitWebPolicyDecision *policy_decision, gpointer user_data);
186
187 WebKitWebView*
188 create_web_view_cb (WebKitWebView *web_view, WebKitWebFrame *frame, gpointer user_data);
189
190 static gboolean
191 download_cb (WebKitWebView *web_view, GObject *download, gpointer user_data);
192
193 static void
194 toggle_status_cb (WebKitWebView* page, const char *param);
195
196 static void
197 link_hover_cb (WebKitWebView* page, const gchar* title, const gchar* link, gpointer data);
198
199 static void
200 title_change_cb (WebKitWebView* web_view, WebKitWebFrame* web_frame, const gchar* title, gpointer data);
201
202 static void
203 progress_change_cb (WebKitWebView* page, gint progress, gpointer data);
204
205 static void
206 load_commit_cb (WebKitWebView* page, WebKitWebFrame* frame, gpointer data);
207
208 static void
702868a @DuClare Added load_finish_handler, call when a page has finished loading.
DuClare authored
209 load_finish_cb (WebKitWebView* page, WebKitWebFrame* frame, gpointer data);
210
211 static void
8ba87ad @barrucadu Moved structs/function primitives to uzbl.h file, so we no longer need t...
barrucadu authored
212 destroy_cb (GtkWidget* widget, gpointer data);
213
214 static void
215 log_history_cb ();
216
217 static void
218 commands_hash(void);
219
220 void
221 free_action(gpointer act);
222
223 Action*
224 new_action(const gchar *name, const gchar *param);
225
226 static bool
227 file_exists (const char * filename);
228
229 void
230 set_insert_mode(WebKitWebView *page, const gchar *param);
231
232 static void
233 load_uri (WebKitWebView * web_view, const gchar *param);
234
235 static void
236 new_window_load_uri (const gchar * uri);
237
238 static void
239 close_uzbl (WebKitWebView *page, const char *param);
240
241 static gboolean
63a46f2 @age Something's working
age authored
242 run_command_async(const char *command, const char *args);
243
244 static gboolean
245 run_command_sync(const char *command, const char *args, char **stdout);
8ba87ad @barrucadu Moved structs/function primitives to uzbl.h file, so we no longer need t...
barrucadu authored
246
247 static void
248 spawn(WebKitWebView *web_view, const char *param);
249
250 static void
251 parse_command(const char *cmd, const char *param);
252
5171e78 @DuClare Add missing declaration, add runcmd for running bind, etc. via gui
DuClare authored
253 static void
254 runcmd(WebKitWebView *page, const char *param);
255
256 static void
257 parse_cmd_line(const char *ctl_line);
258
44ec739 @DuClare Rename create_socket to init_socket, refactor init_*
DuClare authored
259 static gchar*
260 build_stream_name(int type, const gchar *dir);
50d7e59 @Dieterbe merge robm changes: instance naming + better socket code
Dieterbe authored
261
b329cac @DuClare Add SET handling for useragent.
DuClare authored
262 static gboolean
263 var_is(const char *x, const char *y);
264
265 static gchar*
266 set_useragent(gchar *val);
267
4cb5e65 @robm fixed control_fifo() to return a correct status
robm authored
268 static gboolean
0536ddb @Dieterbe somewhat improved fifo code. bug still not fixed
Dieterbe authored
269 control_fifo(GIOChannel *gio, GIOCondition condition);
8ba87ad @barrucadu Moved structs/function primitives to uzbl.h file, so we no longer need t...
barrucadu authored
270
44ec739 @DuClare Rename create_socket to init_socket, refactor init_*
DuClare authored
271 static gchar*
272 init_fifo(gchar *dir);
8ba87ad @barrucadu Moved structs/function primitives to uzbl.h file, so we no longer need t...
barrucadu authored
273
06decd1 @robm first partially working command parser
robm authored
274 static gboolean
4cd06fb @Dieterbe support getting commands from stdin
Dieterbe authored
275 control_stdin(GIOChannel *gio, GIOCondition condition);
276
277 static void
278 create_stdin();
279
44ec739 @DuClare Rename create_socket to init_socket, refactor init_*
DuClare authored
280 static gchar*
281 init_socket(gchar *dir);
50d7e59 @Dieterbe merge robm changes: instance naming + better socket code
Dieterbe authored
282
8ba87ad @barrucadu Moved structs/function primitives to uzbl.h file, so we no longer need t...
barrucadu authored
283 static void
50d7e59 @Dieterbe merge robm changes: instance naming + better socket code
Dieterbe authored
284 control_socket(GIOChannel *chan);
8ba87ad @barrucadu Moved structs/function primitives to uzbl.h file, so we no longer need t...
barrucadu authored
285
286 static void
287 update_title (void);
288
289 static gboolean
290 key_press_cb (WebKitWebView* page, GdkEventKey* event);
291
fd4821b @DuClare Move execution from key_press_cb to its own function, run_keycmd.
DuClare authored
292 static void
293 run_keycmd(const gboolean key_ret);
294
8ba87ad @barrucadu Moved structs/function primitives to uzbl.h file, so we no longer need t...
barrucadu authored
295 static GtkWidget*
296 create_browser ();
297
298 static GtkWidget*
299 create_mainbar ();
300
301 static
302 GtkWidget* create_window ();
303
304 static void
305 add_binding (const gchar *key, const gchar *act);
306
307 static void
308 settings_init ();
309
1825c5b @dusanx Search
dusanx authored
310 static void
311 search_text (WebKitWebView *page, const char *param);
312
01cfcff @barrucadu Added command "script" to run javascript on the current page.
barrucadu authored
313 static void
314 run_js (WebKitWebView * web_view, const gchar *param);
315
12b0591 @age Implement saving cookies
age authored
316 static void handle_cookies (SoupSession *session,
317 SoupMessage *msg,
318 gpointer user_data);
319 static void
320 save_cookies (SoupMessage *msg,
321 gpointer user_data);
8ba87ad @barrucadu Moved structs/function primitives to uzbl.h file, so we no longer need t...
barrucadu authored
322 /* vi: set et ts=4: */
Something went wrong with that request. Please try again.