setup project. initial import of uzbl
[uzbl-mobile] / uzbl.h
diff --git a/uzbl.h b/uzbl.h
index 3511b29..810076d 100644 (file)
--- a/uzbl.h
+++ b/uzbl.h
@@ -1,4 +1,5 @@
-/* 
+/* -*- c-basic-offset: 4; -*-
+
  * See LICENSE for license details
  *
  * Changelog:
@@ -7,40 +8,27 @@
  * (c) 2009 by Robert Manea
  *     - introduced struct concept
  *     - statusbar template
- *     
+ *
  */
 
-#define STATUS_DEFAULT "<span background=\"darkblue\" foreground=\"white\"> MODE </span> <span background=\"red\" foreground=\"white\">KEYCMD</span> (LOAD_PROGRESS%)  <b>TITLE</b>  - Uzbl browser"
-
-/* statusbar symbols */
-enum { SYM_TITLE, SYM_URI, SYM_NAME, 
-       SYM_LOADPRGS, SYM_LOADPRGSBAR,
-       SYM_KEYCMD, SYM_MODE, SYM_MSG};
-const struct {
-    gchar *symbol_name;
-    guint symbol_token;
-} symbols[] = {
-    {"NAME",                 SYM_NAME},
-    {"URI",                  SYM_URI},
-    {"TITLE",                SYM_TITLE},
-    {"KEYCMD",               SYM_KEYCMD},
-    {"MODE",                 SYM_MODE},
-    {"MSG",                  SYM_MSG},
-    {"LOAD_PROGRESS",        SYM_LOADPRGS},
-    {"LOAD_PROGRESSBAR",     SYM_LOADPRGSBAR},
-    {NULL,                   0}
-}, *symp = symbols;
-
 /* status bar elements */
 typedef struct {
     gint           load_progress;
     gchar          *msg;
+    gchar          *progress_s, *progress_u;
+    int            progress_w;
+    gchar          *progress_bar;
+    gchar          *mode_indicator;
 } StatusBar;
 
 
 /* gui elements */
 typedef struct {
     GtkWidget*     main_window;
+    gchar*         geometry;
+    GtkPlug*       plug;
+    GtkWidget*     scrolled_win;
+    GtkWidget*     vbox;
     GtkWidget*     mainbar;
     GtkWidget*     mainbar_label;
     GtkScrollbar*  scbar_v;   // Horizontal and Vertical Scrollbar
@@ -49,6 +37,11 @@ typedef struct {
     GtkAdjustment* bar_h; // and scrolling position
     WebKitWebView* web_view;
     gchar*         main_title;
+    gchar*         icon;
+
+    /* WebInspector */
+    GtkWidget *inspector_window;
+    WebKitWebInspector *inspector;
 
     StatusBar sbar;
 } GUI;
@@ -57,14 +50,12 @@ typedef struct {
 /* external communication*/
 enum { FIFO, SOCKET};
 typedef struct {
-    char           fifo_path[64];
-    char           socket_path[108];
+    gchar          *fifo_path;
+    gchar          *socket_path;
     /* stores (key)"variable name" -> (value)"pointer to this var*/
     GHashTable     *proto_var;
-    /* command parsing regexes */
-    GRegex         *set_regex; 
-    GRegex         *get_regex; 
-    GRegex         *bind_regex; 
+
+    gchar          *sync_stdout;
 } Communication;
 
 
@@ -72,13 +63,13 @@ typedef struct {
 typedef struct {
     gchar    *uri;
     gchar    *config_file;
-    char    *instance_name;
-    gchar    config_file_path[500];
-    gchar    selected_url[500];
-    char     executable_path[500];
-    GString* keycmd;
-    gchar    searchtx[500];
-    struct utsname unameinfo; /* system info */
+    int      socket_id;
+    char     *instance_name;
+    gchar    *selected_url;
+    gchar    *executable_path;
+    gchar*   keycmd;
+    gchar*   searchtx;
+    gboolean verbose;
 } State;
 
 
@@ -95,25 +86,77 @@ typedef struct {
 
 /* behaviour */
 typedef struct {
+    gchar*   load_finish_handler;
+    gchar*   load_start_handler;
+    gchar*   load_commit_handler;
     gchar*   status_format;
+    gchar*   title_format_short;
+    gchar*   title_format_long;
     gchar*   status_background;
-    gchar*   history_handler;
     gchar*   fifo_dir;
     gchar*   socket_dir;
     gchar*   download_handler;
     gchar*   cookie_handler;
+    gchar*   new_window;
+    gchar*   default_font_family;
+    gchar*   monospace_font_family;
+    gchar*   sans_serif_font_family;
+    gchar*   serif_font_family;
+    gchar*   fantasy_font_family;
+    gchar*   cursive_font_family;
+    gchar*   scheme_handler;
     gboolean always_insert_mode;
     gboolean show_status;
     gboolean insert_mode;
     gboolean status_top;
+    gboolean reset_command_mode;
     gchar*   modkey;
     guint    modmask;
     guint    http_debug;
+    gchar*   shell_cmd;
+    /* WebKitWebSettings exports */
+    guint    font_size;
+    guint    monospace_size;
+    guint    minimum_font_size;
+    gfloat   zoom_level;
+    guint    disable_plugins;
+    guint    disable_scripts;
+    guint    autoload_img;
+    guint    autoshrink_img;
+    guint    enable_spellcheck;
+    guint    enable_private;
+    guint    print_bg;
+    gchar*   style_uri;
+    guint    resizable_txt;
+    gchar*   default_encoding;
+    guint    enforce_96dpi;
+    gchar    *inject_html;
+    guint    caret_browsing;
+    guint    mode;
+    gchar*   base_url;
+    gchar*   insert_indicator;
+    gchar*   cmd_indicator;
+    gboolean print_version;
 
     /* command list: name -> Command  */
     GHashTable* commands;
 } Behaviour;
 
+/* javascript */
+typedef struct {
+    gboolean            initialized;
+    JSClassDefinition   classdef;
+    JSClassRef          classref;
+} Javascript;
+
+/* static information */
+typedef struct {
+    int   webkit_major;
+    int   webkit_minor;
+    int   webkit_micro;
+    gchar *arch;
+    gchar *commit;
+} Info;
 
 /* main uzbl data structure */
 typedef struct {
@@ -122,9 +165,10 @@ typedef struct {
     Network       net;
     Behaviour     behave;
     Communication comm;
+    Javascript    js;
+    Info          info;
 
     Window        xwin;
-    GScanner      *scan;
 
     /* group bindings: key -> action */
     GHashTable* bindings;
@@ -138,53 +182,93 @@ typedef struct {
 
 typedef void sigfunc(int);
 
-/* Functions */
-static void
-setup_scanner();
+/* XDG Stuff */
+
+typedef struct {
+    gchar* environmental;
+    gchar* default_value;
+} XDG_Var;
+
+XDG_Var XDG[] =
+{
+    { "XDG_CONFIG_HOME", "~/.config" },
+    { "XDG_DATA_HOME",   "~/.local/share" },
+    { "XDG_CACHE_HOME",  "~/.cache" },
+    { "XDG_CONFIG_DIRS", "/etc/xdg" },
+    { "XDG_DATA_DIRS",   "/usr/local/share/:/usr/share/" },
+};
 
+/* Functions */
 char *
 itos(int val);
 
-static void
+char *
+str_replace (const char* search, const char* replace, const char* string);
+
+GArray*
+read_file_by_line (const gchar *path);
+
+gchar*
+parseenv (char* string);
+
+void
 clean_up(void);
 
-static void
+void
 catch_sigterm(int s);
 
-static sigfunc *
+sigfunc *
 setup_signal(int signe, sigfunc *shandler);
 
-static gboolean
+gboolean
+set_var_value(const gchar *name, gchar *val);
+
+void
+print(WebKitWebView *page, GArray *argv, GString *result);
+
+gboolean
+navigation_decision_cb (WebKitWebView *web_view, WebKitWebFrame *frame, WebKitNetworkRequest *request, WebKitWebNavigationAction *navigation_action, WebKitWebPolicyDecision *policy_decision, gpointer user_data);
+
+gboolean
 new_window_cb (WebKitWebView *web_view, WebKitWebFrame *frame, WebKitNetworkRequest *request, WebKitWebNavigationAction *navigation_action, WebKitWebPolicyDecision *policy_decision, gpointer user_data);
 
-WebKitWebView*
+gboolean
+mime_policy_cb(WebKitWebView *web_view, WebKitWebFrame *frame, WebKitNetworkRequest *request, gchar *mime_type,  WebKitWebPolicyDecision *policy_decision, gpointer user_data);
+
+/*@null@*/ WebKitWebView*
 create_web_view_cb (WebKitWebView  *web_view, WebKitWebFrame *frame, gpointer user_data);
 
-static gboolean
+gboolean
 download_cb (WebKitWebView *web_view, GObject *download, gpointer user_data);
 
-static void
-toggle_status_cb (WebKitWebView* page, const char *param);
+void
+toggle_zoom_type (WebKitWebView* page, GArray *argv, GString *result);
 
-static void
+void
+toggle_status_cb (WebKitWebView* page, GArray *argv, GString *result);
+
+void
 link_hover_cb (WebKitWebView* page, const gchar* title, const gchar* link, gpointer data);
 
-static void
-title_change_cb (WebKitWebView* web_view, WebKitWebFrame* web_frame, const gchar* title, gpointer data);
+void
+title_change_cb (WebKitWebView* web_view, GParamSpec param_spec);
 
-static void
+void
 progress_change_cb (WebKitWebView* page, gint progress, gpointer data);
 
-static void
+void
 load_commit_cb (WebKitWebView* page, WebKitWebFrame* frame, gpointer data);
 
-static void
-destroy_cb (GtkWidget* widget, gpointer data);
+void
+load_start_cb (WebKitWebView* page, WebKitWebFrame* frame, gpointer data);
+
+void
+load_finish_cb (WebKitWebView* page, WebKitWebFrame* frame, gpointer data);
 
-static void
-log_history_cb ();
+void
+destroy_cb (GtkWidget* widget, gpointer data);
 
-static void
+void
 commands_hash(void);
 
 void
@@ -193,89 +277,315 @@ free_action(gpointer act);
 Action*
 new_action(const gchar *name, const gchar *param);
 
-static bool
+bool
 file_exists (const char * filename);
 
 void
-set_insert_mode(WebKitWebView *page, const gchar *param);
+set_keycmd();
+
+void
+set_mode_indicator();
+
+void
+update_indicator();
+
+void
+set_insert_mode(gboolean mode);
+
+void
+toggle_insert_mode(WebKitWebView *page, GArray *argv, GString *result);
 
-static void
-load_uri (WebKitWebView * web_view, const gchar *param);
+void
+load_uri (WebKitWebView * web_view, GArray *argv, GString *result);
 
-static void
+void
 new_window_load_uri (const gchar * uri);
 
-static void
-close_uzbl (WebKitWebView *page, const char *param);
+void
+chain (WebKitWebView *page, GArray *argv, GString *result);
+
+void
+keycmd (WebKitWebView *page, GArray *argv, GString *result);
 
-static gboolean
-run_command_async(const char *command, const char *args);
+void
+keycmd_nl (WebKitWebView *page, GArray *argv, GString *result);
 
-static gboolean
-run_command_sync(const char *command, const char *args, char **stdout);
+void
+keycmd_bs (WebKitWebView *page, GArray *argv, GString *result);
 
-static void
-spawn(WebKitWebView *web_view, const char *param);
+void
+close_uzbl (WebKitWebView *page, GArray *argv, GString *result);
+
+gboolean
+run_command(const gchar *command, const guint npre,
+            const gchar **args, const gboolean sync, char **output_stdout);
 
-static void
-parse_command(const char *cmd, const char *param);
+char*
+build_progressbar_ascii(int percent);
 
 void
-build_stream_name(int type);
+talk_to_socket(WebKitWebView *web_view, GArray *argv, GString *result);
 
-static void
+void
+spawn(WebKitWebView *web_view, GArray *argv, GString *result);
+
+void
+spawn_sh(WebKitWebView *web_view, GArray *argv, GString *result);
+
+void
+spawn_sync(WebKitWebView *web_view, GArray *argv, GString *result);
+
+void
+spawn_sh_sync(WebKitWebView *web_view, GArray *argv, GString *result);
+
+void
+parse_command(const char *cmd, const char *param, GString *result);
+
+void
+parse_cmd_line(const char *ctl_line, GString *result);
+
+/*@null@*/ gchar*
+build_stream_name(int type, const gchar *dir);
+
+gboolean
 control_fifo(GIOChannel *gio, GIOCondition condition);
 
-static void
-create_fifo();
+/*@null@*/ gchar*
+init_fifo(gchar *dir);
 
-static gboolean
+gboolean
 control_stdin(GIOChannel *gio, GIOCondition condition);
 
-static void
+void
 create_stdin();
 
-static void
-create_socket();
+/*@null@*/ gchar*
+init_socket(gchar *dir);
 
-static void
+gboolean
 control_socket(GIOChannel *chan);
 
-static void
+gboolean
+control_client_socket(GIOChannel *chan);
+
+void
 update_title (void);
-static gboolean
-key_press_cb (WebKitWebView* page, GdkEventKey* event);
 
-static GtkWidget*
+gboolean
+key_press_cb (GtkWidget* window, GdkEventKey* event);
+
+void
+run_keycmd(const gboolean key_ret);
+
+void
+exec_paramcmd(const Action* act, const guint i);
+
+void
+initialize (int argc, char *argv[]);
+
+void
 create_browser ();
 
-static GtkWidget*
+GtkWidget*
 create_mainbar ();
 
-static
-GtkWidget* create_window ();
+GtkWidget*
+create_window ();
+
+GtkPlug*
+create_plug ();
 
-static void
+void
+run_handler (const gchar *act, const gchar *args);
+
+void
 add_binding (const gchar *key, const gchar *act);
 
-static void
+/*@null@*/ gchar*
+get_xdg_var (XDG_Var xdg);
+
+/*@null@*/ gchar*
+find_xdg_file (int xdg_type, const char* filename);
+
+void
 settings_init ();
 
-static void
-search_text (WebKitWebView *page, const char *param);
+void
+search_text (WebKitWebView *page, GArray *argv, const gboolean forward);
 
-static void
-run_js (WebKitWebView * web_view, const gchar *param);
+void
+search_forward_text (WebKitWebView *page, GArray *argv, GString *result);
 
-static char *
-str_replace (const char* search, const char* replace, const char* string);
+void
+search_reverse_text (WebKitWebView *page, GArray *argv, GString *result);
+
+void
+dehilight (WebKitWebView *page, GArray *argv, GString *result);
+
+void
+run_js (WebKitWebView * web_view, GArray *argv, GString *result);
+
+void
+run_external_js (WebKitWebView * web_view, GArray *argv, GString *result);
+
+void
+eval_js(WebKitWebView * web_view, gchar *script, GString *result);
 
-static void handle_cookies (SoupSession *session,
-                                                       SoupMessage *msg,
-                                                       gpointer     user_data);
-static void
+void handle_cookies (SoupSession *session,
+                            SoupMessage *msg,
+                            gpointer     user_data);
+void
 save_cookies (SoupMessage *msg,
-                         gpointer     user_data);
+                gpointer     user_data);
+
+void
+set_var(WebKitWebView *page, GArray *argv, GString *result);
+
+void
+act_bind(WebKitWebView *page, GArray *argv, GString *result);
+
+void
+act_dump_config();
+
+void
+dump_var_hash(gpointer k, gpointer v, gpointer ud);
+
+void
+dump_key_hash(gpointer k, gpointer v, gpointer ud);
+
+void
+dump_config();
+
+void
+retrieve_geometry();
+
+void
+update_gui(WebKitWebView *page, GArray *argv, GString *result);
+
+gboolean
+configure_event_cb(GtkWidget* window, GdkEventConfigure* event);
+
+typedef void (*Command)(WebKitWebView*, GArray *argv, GString *result);
+typedef struct {
+    Command function;
+    gboolean no_split;
+} CommandInfo;
+
+/* Command callbacks */
+void
+cmd_load_uri();
+
+void
+cmd_set_status();
+
+void
+set_proxy_url();
+
+void
+set_icon();
+
+void
+cmd_cookie_handler();
+
+void
+cmd_scheme_handler();
+
+void
+move_statusbar();
+
+void
+cmd_always_insert_mode();
+
+void
+cmd_http_debug();
+
+void
+cmd_max_conns();
+
+void
+cmd_max_conns_host();
+
+/* exported WebKitWebSettings properties */
+
+void
+cmd_font_size();
+
+void
+cmd_default_font_family();
+
+void
+cmd_monospace_font_family();
+
+void
+cmd_sans_serif_font_family();
+
+void
+cmd_serif_font_family();
+
+void
+cmd_cursive_font_family();
+
+void
+cmd_fantasy_font_family();
+
+void
+cmd_zoom_level();
+
+void
+cmd_disable_plugins();
+
+void
+cmd_disable_scripts();
+
+void
+cmd_minimum_font_size();
+
+void
+cmd_fifo_dir();
+
+void
+cmd_socket_dir();
+
+void
+cmd_modkey();
+
+void
+cmd_useragent() ;
+
+void
+cmd_autoload_img();
+
+void
+cmd_autoshrink_img();
+
+void
+cmd_enable_spellcheck();
+
+void
+cmd_enable_private();
+
+void
+cmd_print_bg();
+
+void
+cmd_style_uri();
+
+void
+cmd_resizable_txt();
+
+void
+cmd_default_encoding();
+
+void
+cmd_enforce_96dpi();
+
+void
+cmd_inject_html();
+
+void
+cmd_caret_browsing();
+
+void
+cmd_set_geometry();
+
 /* vi: set et ts=4: */