aboutsummaryrefslogtreecommitdiffstats
path: root/src/web.h
blob: 61f7a76f3f5d408435518f40a786397816c64976 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#ifndef WEB_H
#define WEB_H

typedef struct _WebBackEnd WebBackEnd;
typedef struct _WebData WebData;
typedef struct _WebPages WebPages;

#include <glib.h>
#include <gmodule.h>
#include <gtk/gtk.h>
#include <glade/glade.h>
#include "web_history.h"
#include "web_request.h"
#include "web_bookmarks.h"
#include "config.h"

#ifdef WITH_HILDON
#include <hildon-widgets/hildon-app.h>
#define DATADIR "/var/lib/install" PKGDATADIR G_DIR_SEPARATOR_S
#else
#define DATADIR PKGDATADIR G_DIR_SEPARATOR_S
#endif

#define XML_FILE DATADIR "web.glade"

#ifndef MAX_REQUESTS
#	define MAX_REQUESTS 10
#endif
#ifndef BUFFER
#	define BUFFER 4096
#endif
#ifndef HISTORY
#	define HISTORY 10
#endif
#ifndef URL_LABEL_SIZE
#	define URL_LABEL_SIZE 16
#endif

#define MAG_STEP 1.1
#define BLANK_PAGE "<html></html>"
#define GCONF_PATH "/apps/web"
#define GCONF_KEY_ZOOM "/apps/web/last_zoom"
#define GCONF_KEY_BACKEND "/apps/web/backend"
#define GCONF_KEY_HOME "/apps/web/home"
#define GCONF_KEY_SSR "/apps/web/ssr"
#define GCONF_KEY_MEDIA "/apps/web/media"

#define WEB_API_VERSION 1

struct _WebBackEnd {
	guint	api_version;
	gchar	*name;
	
	void 		(*init)		(gpointer *backend_data,
					 WebPages *pages);
	void 		(*deinit)	(gpointer backend_data);
	GtkWidget*	(*new)		(gpointer backend_data,
					 gpointer *page_data, WebData *data);
	void 		(*destroy)	(gpointer backend_data,
					 gpointer page_data);
	void 		(*write)	(gpointer backend_data,
					 gpointer page_data,
					 WebRequest *request,
					 gchar *buffer, gint bytes_read);
	void		(*clear)	(gpointer backend_data,
					 gpointer page_data);
	void 		(*close)	(gpointer backend_data,
					 gpointer page_data,
					 WebRequest *request);
	gdouble 	(*get_zoom)	(gpointer backend_data,
					 gpointer page_data);
	void		(*set_zoom)	(gpointer backend_data,
					 gpointer page_data, gdouble zoom);
	gpointer	(*add_style)	(gpointer backend_data,
					 gpointer page_data,
					 const gchar *style,
					 const gchar *media);
	void		(*remove_style)	(gpointer backend_data,
					 gpointer page_data,
					 gpointer style);
	gpointer	(*add_script)	(gpointer backend_data,
					 gpointer page_data,
					 gchar *script);
	void		(*remove_script)(gpointer backend_data,
					 gpointer page_data,
					 gpointer script);
	void		(*set_media)	(gpointer backend_data,
					 gpointer page_data,
					 const gchar *media);
};

#define DECLARE_WEB_BACKEND(backend) \
	G_MODULE_EXPORT WebBackEnd* web_backend_get() { \
		return &backend; \
	}

struct _WebData {
	gchar *base_url;
	gchar *url;
	gpointer page_data;
	GList *requests;
	guint max_requests;
	WebPages *parent;
	GtkWidget *url_label;
	GtkWidget *vbox;
	GtkWidget *vpaned;
	GList *history;
	GList *history_forward;
	gpointer ssr_style;
	gpointer ssr_script;
};

struct _WebPages {
	GladeXML *xml;
	GtkWidget *window;
#ifdef WITH_HILDON
	HildonAppView *appview;
#endif
	WebBackEnd *backend;
	gpointer backend_data;
	GtkNotebook *book;
	GList *pages;
	GtkWidget *history;
	GtkWidget *history_forward;
	WebData *current_page;
	gdouble last_zoom;
	gchar *home;
	gboolean ssr;
	gchar *media;
	WebBookmarks *bookmarks;
};


void web_go (WebData *data, const gchar *url, gboolean preserve_history);
void web_title_change (WebData *data, const gchar *title);

#endif