todo
[uzbl-00z.git] / uzbl.h
blob99164fe9bda2512d95fe42ab2005d989b157b49d
1 /*
2 * See LICENSE for license details
4 * Changelog:
5 * ---------
7 * (c) 2009 by Robert Manea
8 * - introduced struct concept
9 * - statusbar template
13 /* statusbar symbols */
14 enum { SYM_TITLE, SYM_URI, SYM_NAME,
15 SYM_LOADPRGS, SYM_LOADPRGSBAR,
16 SYM_KEYCMD, SYM_MODE};
17 const struct {
18 gchar *symbol_name;
19 guint symbol_token;
20 } symbols[] = {
21 {"NAME", SYM_NAME},
22 {"URI", SYM_URI},
23 {"TITLE", SYM_TITLE},
24 {"KEYCMD", SYM_KEYCMD},
25 {"MODE", SYM_MODE},
26 {"LOAD_PROGRESS", SYM_LOADPRGS},
27 {"LOAD_PROGRESSBAR", SYM_LOADPRGSBAR},
28 {NULL, 0}
29 }, *symp = symbols;
31 /* status bar elements */
32 typedef struct {
33 gint load_progress;
34 } StatusBar;
37 /* gui elements */
38 typedef struct {
39 GtkWidget* main_window;
40 GtkWidget* mainbar;
41 GtkWidget* mainbar_label;
42 GtkScrollbar* scbar_v; // Horizontal and Vertical Scrollbar
43 GtkScrollbar* scbar_h; // (These are still hidden)
44 GtkAdjustment* bar_v; // Information about document length
45 GtkAdjustment* bar_h; // and scrolling position
46 WebKitWebView* web_view;
47 gchar* main_title;
49 StatusBar sbar;
50 } GUI;
53 /* external communication*/
54 enum { FIFO, SOCKET};
55 typedef struct {
56 char fifo_path[64];
57 char socket_path[108];
58 } Communication;
61 /* internal state */
62 typedef struct {
63 gchar *uri;
64 gchar *config_file;
65 gchar *instance_name;
66 gchar config_file_path[500];
67 gchar selected_url[500];
68 char executable_path[500];
69 GString* keycmd;
70 gchar searchtx[500];
71 struct utsname unameinfo; /* system info */
72 } State;
75 /* networking */
76 typedef struct {
77 SoupSession *soup_session;
78 SoupLogger *soup_logger;
79 char *proxy_url;
80 char *useragent;
81 gint max_conns;
82 gint max_conns_host;
83 } Network;
86 /* behaviour */
87 typedef struct {
88 gchar *status_format;
89 gchar* history_handler;
90 gchar* fifo_dir;
91 gchar* socket_dir;
92 gchar* download_handler;
93 gchar* cookie_handler;
94 gboolean always_insert_mode;
95 gboolean show_status;
96 gboolean insert_mode;
97 gboolean status_top;
98 gchar* modkey;
99 guint modmask;
100 guint http_debug;
102 /* command list: name -> Command */
103 GHashTable* commands;
104 } Behaviour;
107 /* main uzbl data structure */
108 typedef struct {
109 GUI gui;
110 State state;
111 Network net;
112 Behaviour behave;
113 Communication comm;
115 Window xwin;
116 GScanner *scan;
118 /* group bindings: key -> action */
119 GHashTable* bindings;
120 } Uzbl;
123 typedef struct {
124 char* name;
125 char* param;
126 } Action;
128 typedef void sigfunc(int);
130 /* Functions */
131 static void
132 setup_scanner();
134 char *
135 itos(int val);
137 static void
138 clean_up(void);
140 static void
141 catch_sigterm(int s);
143 static sigfunc *
144 setup_signal(int signe, sigfunc *shandler);
146 static gboolean
147 new_window_cb (WebKitWebView *web_view, WebKitWebFrame *frame, WebKitNetworkRequest *request, WebKitWebNavigationAction *navigation_action, WebKitWebPolicyDecision *policy_decision, gpointer user_data);
149 WebKitWebView*
150 create_web_view_cb (WebKitWebView *web_view, WebKitWebFrame *frame, gpointer user_data);
152 static gboolean
153 download_cb (WebKitWebView *web_view, GObject *download, gpointer user_data);
155 static void
156 toggle_status_cb (WebKitWebView* page, const char *param);
158 static void
159 link_hover_cb (WebKitWebView* page, const gchar* title, const gchar* link, gpointer data);
161 static void
162 title_change_cb (WebKitWebView* web_view, WebKitWebFrame* web_frame, const gchar* title, gpointer data);
164 static void
165 progress_change_cb (WebKitWebView* page, gint progress, gpointer data);
167 static void
168 load_commit_cb (WebKitWebView* page, WebKitWebFrame* frame, gpointer data);
170 static void
171 destroy_cb (GtkWidget* widget, gpointer data);
173 static void
174 log_history_cb ();
176 static void
177 commands_hash(void);
179 void
180 free_action(gpointer act);
182 Action*
183 new_action(const gchar *name, const gchar *param);
185 static bool
186 file_exists (const char * filename);
188 void
189 set_insert_mode(WebKitWebView *page, const gchar *param);
191 static void
192 load_uri (WebKitWebView * web_view, const gchar *param);
194 static void
195 new_window_load_uri (const gchar * uri);
197 static void
198 close_uzbl (WebKitWebView *page, const char *param);
200 static gboolean
201 run_command_async(const char *command, const char *args);
203 static gboolean
204 run_command_sync(const char *command, const char *args, char **stdout);
206 static void
207 spawn(WebKitWebView *web_view, const char *param);
209 static void
210 parse_command(const char *cmd, const char *param);
212 static void
213 parse_line(char *line);
215 void
216 build_stream_name(int type);
218 static void
219 control_fifo(GIOChannel *gio, GIOCondition condition);
221 static void
222 create_fifo();
224 static void
225 create_socket();
227 static void
228 control_socket(GIOChannel *chan);
231 static void
232 update_title (void);
234 static gboolean
235 key_press_cb (WebKitWebView* page, GdkEventKey* event);
237 static GtkWidget*
238 create_browser ();
240 static GtkWidget*
241 create_mainbar ();
243 static
244 GtkWidget* create_window ();
246 static void
247 add_binding (const gchar *key, const gchar *act);
249 static void
250 settings_init ();
252 static void
253 search_text (WebKitWebView *page, const char *param);
255 static void
256 run_js (WebKitWebView * web_view, const gchar *param);
258 static char *
259 str_replace (const char* search, const char* replace, const char* string);
261 static void handle_cookies (SoupSession *session,
262 SoupMessage *msg,
263 gpointer user_data);
264 static void
265 save_cookies (SoupMessage *msg,
266 gpointer user_data);
267 /* vi: set et ts=4: */