NetSurf
cookies.c
Go to the documentation of this file.
1/*
2 * Copyright 2013 Ole Loots <ole@monochrom.net>
3 *
4 * This file is part of NetSurf, http://www.netsurf-browser.org/
5 *
6 * NetSurf is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * NetSurf is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#include <assert.h>
20
21#include "netsurf/inttypes.h"
22#include "utils/log.h"
23#include "utils/messages.h"
24#include "netsurf/mouse.h"
25#include "netsurf/plotters.h"
27
28#include "atari/treeview.h"
29#include "atari/cookies.h"
30#include "atari/gemtk/gemtk.h"
31#include "atari/res/netsurf.rsh"
32
33extern GRECT desk_area;
34
36
37
38/* Setup Atari Treeview Callbacks: */
39static nserror atari_cookie_manager_init_phase2(struct core_window *cw,
40 struct core_window_callback_table * default_callbacks);
41static void atari_cookie_manager_finish(struct core_window *cw);
42static void atari_cookie_manager_keypress(struct core_window *cw,
43 uint32_t ucs4);
44static void atari_cookie_manager_mouse_action(struct core_window *cw,
46 int x, int y);
47static void atari_cookie_manager_draw(struct core_window *cw, int x,
48 int y, struct rect *clip,
49 const struct redraw_context *ctx);
50static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8]);
51
58 .gemtk_user_func = handle_event
59};
60
61
62static nserror
63atari_cookie_manager_init_phase2(struct core_window *cw,
64 struct core_window_callback_table *cb_t)
65{
66 NSLOG(netsurf, INFO, "cw %p", cw);
67 return(cookie_manager_init(cb_t, cw));
68}
69
70
71static void
72atari_cookie_manager_finish(struct core_window *cw)
73{
74 NSLOG(netsurf, INFO, "cw %p", cw);
76}
77
78
79static void
80atari_cookie_manager_draw(struct core_window *cw,
81 int x, int y,
82 struct rect *clip,
83 const struct redraw_context *ctx)
84{
85 cookie_manager_redraw(x, y, clip, ctx);
86}
87
88
89static void
90atari_cookie_manager_keypress(struct core_window *cw, uint32_t ucs4)
91{
92 NSLOG(netsurf, INFO, "ucs4: %"PRIu32, ucs4);
94}
95
96
97static void
98atari_cookie_manager_mouse_action(struct core_window *cw,
100 int x, int y)
101{
102 cookie_manager_mouse_action(mouse, x, y);
103}
104
105
106
107static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
108{
109 short retval = 0;
110
111 NSLOG(netsurf, INFO, "win %p", win);
112
113 if (ev_out->emo_events & MU_MESAG) {
114 switch (msg[0]) {
115
116 case WM_TOOLBAR:
117 NSLOG(netsurf, INFO, "WM_TOOLBAR");
118 break;
119
120 case WM_CLOSED:
122 retval = 1;
123 break;
124
125 default: break;
126 }
127 }
128
129 return(retval);
130}
131
133{
134 if (atari_cookie_manager.init == false) {
135
136 if (atari_cookie_manager.window == NULL) {
137 int flags = ATARI_TREEVIEW_WIDGETS;
138 short handle = -1;
139 OBJECT * tree = gemtk_obj_get_tree(TOOLBAR_COOKIES);
140 assert( tree );
141
142 handle = wind_create(flags, 0, 0, desk_area.g_w, desk_area.g_h);
143 atari_cookie_manager.window = gemtk_wm_add(handle,
144 GEMTK_WM_FLAG_DEFAULTS, NULL);
145 if( atari_cookie_manager.window == NULL ) {
146 gemtk_msg_box_show(GEMTK_MSG_BOX_ALERT,
147 "Failed to allocate Treeview:\nCookies");
148 return;
149 }
150 wind_set_str(handle, WF_NAME, (char*)messages_get("Cookies"));
151 gemtk_wm_set_toolbar(atari_cookie_manager.window, tree, 0, 0);
152 gemtk_wm_unlink(atari_cookie_manager.window);
153
157 NULL, flags);
158
159 if (atari_cookie_manager.tv == NULL) {
160 /* handle it properly, clean up previous allocs */
161 NSLOG(netsurf, INFO,
162 "Failed to allocate treeview");
163 return;
164 }
165
166 } else {
167
168 }
169 }
171}
172
174{
176
178
179 GRECT pos;
180 pos.g_x = desk_area.g_w - desk_area.g_w / 4;
181 pos.g_y = desk_area.g_y;
182 pos.g_w = desk_area.g_w / 4;
183 pos.g_h = desk_area.g_h;
184
186 } else {
187 wind_set(gemtk_wm_get_handle(atari_cookie_manager.window), WF_TOP, 1, 0,
188 0, 0);
189 }
190}
191
192
194{
196}
197
198
200{
201 if( atari_cookie_manager.init == false) {
202 return;
203 }
204 if( atari_cookie_manager.window != NULL ) {
207 wind_delete(gemtk_wm_get_handle(atari_cookie_manager.window));
208 gemtk_wm_remove(atari_cookie_manager.window);
212 }
213 NSLOG(netsurf, INFO, "done");
214
215}
216
217
219{
221}
void atari_cookie_manager_init(void)
Definition: cookies.c:132
void atari_cookie_manager_redraw(void)
Definition: cookies.c:218
struct atari_cookie_manager_s atari_cookie_manager
Definition: cookies.c:35
GRECT desk_area
Definition: gui.c:78
void atari_cookie_manager_destroy(void)
Definition: cookies.c:199
void atari_cookie_manager_open(void)
Definition: cookies.c:173
static void atari_cookie_manager_finish(struct core_window *cw)
Definition: cookies.c:72
static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
Definition: cookies.c:107
static struct atari_treeview_callbacks atari_cookie_manager_treeview_callbacks
Definition: cookies.c:52
static void atari_cookie_manager_mouse_action(struct core_window *cw, browser_mouse_state mouse, int x, int y)
Definition: cookies.c:98
static void atari_cookie_manager_draw(struct core_window *cw, int x, int y, struct rect *clip, const struct redraw_context *ctx)
Definition: cookies.c:80
static void atari_cookie_manager_keypress(struct core_window *cw, uint32_t ucs4)
Definition: cookies.c:90
void atari_cookie_manager_close(void)
Definition: cookies.c:193
static nserror atari_cookie_manager_init_phase2(struct core_window *cw, struct core_window_callback_table *default_callbacks)
Definition: cookies.c:63
nserror cookie_manager_init(struct core_window_callback_table *cw_t, void *core_window_handle)
Initialise the cookie manager.
void cookie_manager_redraw(int x, int y, struct rect *clip, const struct redraw_context *ctx)
Redraw the cookies manager.
void cookie_manager_mouse_action(enum browser_mouse_state mouse, int x, int y)
Handles all kinds of mouse action.
nserror cookie_manager_fini(void)
Finalise the cookie manager.
bool cookie_manager_keypress(uint32_t key)
Key press handling.
Cookie Manager (interface).
nserror
Enumeration of error codes.
Definition: errors.h:29
void atari_treeview_delete(struct core_window *cw)
Free the Treeview, but not the gemtk window used for the treeview.
Definition: treeview.c:739
bool atari_treeview_is_open(struct core_window *cw)
Returns the window "open" state.
Definition: treeview.c:779
void atari_treeview_redraw(struct core_window *cw)
Process all pending redraw requests for a single treeview.
Definition: treeview.c:626
void atari_treeview_close(struct core_window *cw)
Closes (hides) the treeview window.
Definition: treeview.c:803
struct core_window * atari_treeview_create(GUIWIN *win, struct atari_treeview_callbacks *callbacks, void *user_data, uint32_t flags)
Initalize an window to be an treeview window.
Definition: treeview.c:546
void atari_treeview_open(struct core_window *cw, GRECT *pos)
Open the treeview window.
Definition: treeview.c:753
#define ATARI_TREEVIEW_WIDGETS
Default AES Window widgets for a treeview window, can be passed to atari_treeview_create as the flags...
Definition: treeview.h:32
Core mouse and pointer states.
browser_mouse_state
Mouse state.
Definition: mouse.h:43
Target independent plotting interface.
Netsurf additional integer type formatting macros.
#define NSLOG(catname, level, logmsg, args...)
Definition: log.h:116
const char * messages_get(const char *key)
Fast lookup of a message by key from the standard Messages hash.
Definition: messages.c:241
Localised message support (interface).
atari_treeview_init2_callback init_phase2
Definition: treeview.h:60
Callbacks to achieve various core window functionality.
Definition: core_window.h:51
Rectangle coordinates.
Definition: types.h:40
Redraw context.
Definition: plotters.h:51
static nserror clip(const struct redraw_context *ctx, const struct rect *clip)
Sets a clip rectangle for subsequent plot operations.
Definition: plot.c:357