Introduce new data structure for handling settings

This commit is contained in:
Quentin Rameau 2015-11-29 17:16:48 +01:00
parent d04fb9bff3
commit 2aa1c38aed
1 changed files with 38 additions and 2 deletions

40
surf.c
View File

@ -31,18 +31,42 @@
#define LENGTH(x) (sizeof(x) / sizeof(x[0])) #define LENGTH(x) (sizeof(x) / sizeof(x[0]))
#define CLEANMASK(mask) (mask & (MODKEY|GDK_SHIFT_MASK)) #define CLEANMASK(mask) (mask & (MODKEY|GDK_SHIFT_MASK))
#define SETB(p, s) [p] = (Parameter){ { .b = s }, }
#define SETI(p, s) [p] = (Parameter){ { .i = s }, }
#define SETV(p, s) [p] = (Parameter){ { .v = s }, }
#define SETF(p, s) [p] = (Parameter){ { .f = s }, }
#define FSETB(p, s) [p] = (Parameter){ { .b = s }, 1 }
#define FSETI(p, s) [p] = (Parameter){ { .i = s }, 1 }
#define FSETV(p, s) [p] = (Parameter){ { .v = s }, 1 }
#define FSETF(p, s) [p] = (Parameter){ { .f = s }, 1 }
enum { AtomFind, AtomGo, AtomUri, AtomLast }; enum { AtomFind, AtomGo, AtomUri, AtomLast };
enum { typedef enum {
CaretBrowsing, CaretBrowsing,
CookiePolicies,
DiskCache,
DNSPrefetch,
FontSize,
FrameFlattening, FrameFlattening,
Geolocation, Geolocation,
HideBackground,
Inspector,
JavaScript, JavaScript,
KioskMode,
LoadImages, LoadImages,
Plugins, Plugins,
PreferredLanguages,
RunInFullscreen,
ScrollBars, ScrollBars,
}; ShowIndicators,
SpellChecking,
SpellLanguages,
StrictSSL,
Style,
ZoomLevel,
ParameterLast,
} ParamName;
enum { enum {
OnDoc = WEBKIT_HIT_TEST_RESULT_CONTEXT_DOCUMENT, OnDoc = WEBKIT_HIT_TEST_RESULT_CONTEXT_DOCUMENT,
@ -58,9 +82,15 @@ enum {
typedef union { typedef union {
int b; int b;
int i; int i;
float f;
const void *v; const void *v;
} Arg; } Arg;
typedef struct {
Arg val;
int force;
} Parameter;
typedef struct Client { typedef struct Client {
GtkWidget *win; GtkWidget *win;
WebKitWebView *view; WebKitWebView *view;
@ -91,6 +121,12 @@ typedef struct {
unsigned int stopevent; unsigned int stopevent;
} Button; } Button;
typedef struct {
const char *uri;
Parameter config[ParameterLast];
regex_t re;
} UriParameters;
typedef struct { typedef struct {
char *regex; char *regex;
char *style; char *style;