browse

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

browse.h (2322B)


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