browse

browse.git
git clone git://git.lenczewski.org/browse.git
Log | Files | Refs | README | LICENSE

browse.h (2419B)


      1 #ifndef BROWSE_H
      2 #define BROWSE_H
      3 
      4 #ifdef _XOPEN_SOURCE
      5 #undef _XOPEN_SOURCE
      6 #endif /* _XOPEN_SOURCE */
      7 
      8 #define _XOPEN_SOURCE 700
      9 
     10 #include <assert.h>
     11 #include <inttypes.h>
     12 #include <limits.h>
     13 #include <signal.h>
     14 #include <stdatomic.h>
     15 #include <stdbool.h>
     16 #include <stdlib.h>
     17 #include <stdint.h>
     18 #include <stdio.h>
     19 #include <string.h>
     20 #include <time.h>
     21 #include <unistd.h>
     22 
     23 #include <gtk/gtk.h>
     24 #include <webkit/webkit.h>
     25 
     26 #define ARRLEN(arr) (sizeof (arr) / sizeof (arr)[0])
     27 
     28 #define BROWSE_WINDOW_TITLE_MAX 1024
     29 #define BROWSE_WINDOW_URL_MAX 512
     30 #define BROWSE_WINDOW_DOWNLOADS_MAX 8
     31 
     32 struct browse_ctx {
     33 	GtkSettings *gtk_settings;
     34 	WebKitSettings *webkit_settings;
     35 
     36 	atomic_uint clients;
     37 	atomic_bool shutdown;
     38 };
     39 
     40 extern struct browse_ctx browse;
     41 
     42 struct browse_client;
     43 
     44 extern struct browse_client *
     45 browse_new(char const *uri, struct browse_client *root);
     46 
     47 extern void
     48 browse_update_title(struct browse_client *self);
     49 
     50 extern void
     51 browse_load_uri(struct browse_client *self, char const *uri);
     52 
     53 extern void
     54 browse_download_uri(struct browse_client *self, char const *uri);
     55 
     56 enum browse_prop_type {
     57 	BROWSE_PROP_STRICT_TLS,
     58 	_BROWSE_PROP_TYPE_COUNT,
     59 };
     60 
     61 union browse_prop {
     62 	bool b;
     63 };
     64 
     65 struct browse_gtk_setting {
     66 	char const *name;
     67 	union { gboolean b; guint u; gchar const *s; } v;
     68 };
     69 
     70 struct browse_webkit_setting {
     71 	char const *name;
     72 	union { gboolean b; guint u; gchar const *s; } v;
     73 };
     74 
     75 union browse_keybind_arg {
     76 	int i;
     77 	char const *s;
     78 };
     79 
     80 typedef void (*browse_keybind_fn)(struct browse_client *client, union browse_keybind_arg const *arg);
     81 
     82 struct browse_keybind {
     83 	GdkModifierType mod;
     84 	guint key;
     85 	browse_keybind_fn handler;
     86 	union browse_keybind_arg arg;
     87 };
     88 
     89 extern void
     90 stopload(struct browse_client *client, union browse_keybind_arg const *arg);
     91 
     92 extern void
     93 reload(struct browse_client *client, union browse_keybind_arg const *arg);
     94 
     95 extern void
     96 navigate(struct browse_client *client, union browse_keybind_arg const *arg);
     97 
     98 extern void
     99 clipboard(struct browse_client *client, union browse_keybind_arg const *arg);
    100 
    101 extern void
    102 javascript(struct browse_client *client, union browse_keybind_arg const *arg);
    103 
    104 extern void
    105 search(struct browse_client *client, union browse_keybind_arg const *arg);
    106 
    107 extern void
    108 download(struct browse_client *client, union browse_keybind_arg const *arg);
    109 
    110 extern void
    111 toggle(struct browse_client *client, union browse_keybind_arg const *arg);
    112 
    113 #endif /* BROWSE_H */