1 /* -*- c-basic-offset: 4; -*-
3 * See LICENSE for license details
8 * (c) 2009 by Robert Manea
9 * - introduced struct concept
10 * - statusbar template
14 #define STATUS_DEFAULT "<span background=\"darkblue\" foreground=\"white\"> MODE </span> <span background=\"red\" foreground=\"white\">KEYCMD</span> (LOAD_PROGRESS%) <b>TITLE</b> - Uzbl browser"
15 #define TITLE_LONG_DEFAULT "KEYCMD MODE TITLE - Uzbl browser <NAME> > SELECTED_URI"
16 #define TITLE_SHORT_DEFAULT "TITLE - Uzbl browser <NAME>"
20 /* statusbar symbols */
21 SYM_TITLE
, SYM_URI
, SYM_NAME
,
22 SYM_LOADPRGS
, SYM_LOADPRGSBAR
,
23 SYM_KEYCMD
, SYM_MODE
, SYM_MSG
,
25 /* useragent symbols */
26 SYM_WK_MAJ
, SYM_WK_MIN
, SYM_WK_MIC
,
27 SYM_SYSNAME
, SYM_NODENAME
,
28 SYM_KERNREL
, SYM_KERNVER
,
29 SYM_ARCHSYS
, SYM_ARCHUZBL
,
30 SYM_DOMAINNAME
, SYM_COMMIT
40 {"SELECTED_URI", SYM_SELECTED_URI
},
41 {"KEYCMD", SYM_KEYCMD
},
44 {"LOAD_PROGRESS", SYM_LOADPRGS
},
45 {"LOAD_PROGRESSBAR", SYM_LOADPRGSBAR
},
47 {"WEBKIT_MAJOR", SYM_WK_MAJ
},
48 {"WEBKIT_MINOR", SYM_WK_MIN
},
49 {"WEBKIT_MICRO", SYM_WK_MIC
},
50 {"SYSNAME", SYM_SYSNAME
},
51 {"NODENAME", SYM_NODENAME
},
52 {"KERNREL", SYM_KERNREL
},
53 {"KERNVER", SYM_KERNVER
},
54 {"ARCH_SYSTEM", SYM_ARCHSYS
},
55 {"ARCH_UZBL", SYM_ARCHUZBL
},
56 {"DOMAINNAME", SYM_DOMAINNAME
},
57 {"COMMIT", SYM_COMMIT
},
61 /* status bar elements */
70 GtkWidget
* main_window
;
71 GtkWidget
* scrolled_win
;
74 GtkWidget
* mainbar_label
;
75 GtkScrollbar
* scbar_v
; // Horizontal and Vertical Scrollbar
76 GtkScrollbar
* scbar_h
; // (These are still hidden)
77 GtkAdjustment
* bar_v
; // Information about document length
78 GtkAdjustment
* bar_h
; // and scrolling position
79 WebKitWebView
* web_view
;
86 /* external communication*/
91 /* stores (key)"variable name" -> (value)"pointer to this var*/
92 GHashTable
*proto_var
;
93 /* command parsing regexes */
107 gchar config_file_path
[500];
108 gchar selected_url
[500];
109 char executable_path
[500];
112 struct utsname unameinfo
; /* system info */
119 SoupSession
*soup_session
;
120 SoupLogger
*soup_logger
;
130 gchar
* load_finish_handler
;
131 gchar
* status_format
;
132 gchar
* title_format_short
;
133 gchar
* title_format_long
;
134 gchar
* status_background
;
135 gchar
* history_handler
;
138 gchar
* download_handler
;
139 gchar
* cookie_handler
;
140 gboolean always_insert_mode
;
141 gboolean show_status
;
142 gboolean insert_mode
;
144 gboolean reset_command_mode
;
148 guint default_font_size
;
149 guint minimum_font_size
;
152 /* command list: name -> Command */
153 GHashTable
* commands
;
157 /* main uzbl data structure */
168 /* group bindings: key -> action */
169 GHashTable
* bindings
;
178 typedef void sigfunc(int);
183 gchar
* environmental
;
184 gchar
* default_value
;
189 { "XDG_CONFIG_HOME", "~/.config" },
190 { "XDG_DATA_HOME", "~/.local/share" },
191 { "XDG_CACHE_HOME", "~/.cache" },
192 { "XDG_CONFIG_DIRS", "/etc/xdg" },
193 { "XDG_DATA_DIRS", "/usr/local/share/:/usr/share/" },
204 str_replace (const char* search
, const char* replace
, const char* string
);
210 catch_sigterm(int s
);
213 setup_signal(int signe
, sigfunc
*shandler
);
216 new_window_cb (WebKitWebView
*web_view
, WebKitWebFrame
*frame
, WebKitNetworkRequest
*request
, WebKitWebNavigationAction
*navigation_action
, WebKitWebPolicyDecision
*policy_decision
, gpointer user_data
);
219 create_web_view_cb (WebKitWebView
*web_view
, WebKitWebFrame
*frame
, gpointer user_data
);
222 download_cb (WebKitWebView
*web_view
, GObject
*download
, gpointer user_data
);
225 toggle_status_cb (WebKitWebView
* page
, const char *param
);
228 link_hover_cb (WebKitWebView
* page
, const gchar
* title
, const gchar
* link
, gpointer data
);
231 title_change_cb (WebKitWebView
* web_view
, WebKitWebFrame
* web_frame
, const gchar
* title
, gpointer data
);
234 progress_change_cb (WebKitWebView
* page
, gint progress
, gpointer data
);
237 load_commit_cb (WebKitWebView
* page
, WebKitWebFrame
* frame
, gpointer data
);
240 load_finish_cb (WebKitWebView
* page
, WebKitWebFrame
* frame
, gpointer data
);
243 destroy_cb (GtkWidget
* widget
, gpointer data
);
252 free_action(gpointer act
);
255 new_action(const gchar
*name
, const gchar
*param
);
258 file_exists (const char * filename
);
261 set_insert_mode(WebKitWebView
*page
, const gchar
*param
);
264 load_uri (WebKitWebView
* web_view
, const gchar
*param
);
267 new_window_load_uri (const gchar
* uri
);
270 close_uzbl (WebKitWebView
*page
, const char *param
);
273 run_command(const char *command
, const char *args
, const gboolean sync
, char **stdout
);
276 spawn(WebKitWebView
*web_view
, const char *param
);
279 spawn_sh(WebKitWebView
*web_view
, const char *param
);
282 parse_command(const char *cmd
, const char *param
);
285 runcmd(WebKitWebView
*page
, const char *param
);
288 parse_cmd_line(const char *ctl_line
);
291 build_stream_name(int type
, const gchar
*dir
);
294 var_is(const char *x
, const char *y
);
297 set_useragent(gchar
*val
);
300 control_fifo(GIOChannel
*gio
, GIOCondition condition
);
303 init_fifo(gchar
*dir
);
306 control_stdin(GIOChannel
*gio
, GIOCondition condition
);
312 init_socket(gchar
*dir
);
315 control_socket(GIOChannel
*chan
);
321 key_press_cb (WebKitWebView
* page
, GdkEventKey
* event
);
324 run_keycmd(const gboolean key_ret
);
333 GtkWidget
* create_window ();
336 add_binding (const gchar
*key
, const gchar
*act
);
339 get_xdg_var (XDG_Var xdg
);
342 find_xdg_file (int xdg_type
, char* filename
);
348 search_text (WebKitWebView
*page
, const char *param
);
351 run_js (WebKitWebView
* web_view
, const gchar
*param
);
353 static void handle_cookies (SoupSession
*session
,
357 save_cookies (SoupMessage
*msg
,
359 /* vi: set et ts=4: */