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);
40static void atari_cookie_manager_finish(struct core_window *cw);
41static void atari_cookie_manager_keypress(struct core_window *cw,
42 uint32_t ucs4);
43static void atari_cookie_manager_mouse_action(struct core_window *cw,
45 int x, int y);
46static void atari_cookie_manager_draw(struct core_window *cw, int x,
47 int y, struct rect *clip,
48 const struct redraw_context *ctx);
49static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8]);
50
57 .gemtk_user_func = handle_event
58};
59
60
61static nserror
62atari_cookie_manager_init_phase2(struct core_window *cw)
63{
64 NSLOG(netsurf, INFO, "cw %p", cw);
65 return(cookie_manager_init(cw));
66}
67
68
69static void
70atari_cookie_manager_finish(struct core_window *cw)
71{
72 NSLOG(netsurf, INFO, "cw %p", cw);
74}
75
76
77static void
78atari_cookie_manager_draw(struct core_window *cw,
79 int x, int y,
80 struct rect *clip,
81 const struct redraw_context *ctx)
82{
83 cookie_manager_redraw(x, y, clip, ctx);
84}
85
86
87static void
88atari_cookie_manager_keypress(struct core_window *cw, uint32_t ucs4)
89{
90 NSLOG(netsurf, INFO, "ucs4: %"PRIu32, ucs4);
92}
93
94
95static void
96atari_cookie_manager_mouse_action(struct core_window *cw,
98 int x, int y)
99{
100 cookie_manager_mouse_action(mouse, x, y);
101}
102
103
104
105static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
106{
107 short retval = 0;
108
109 NSLOG(netsurf, INFO, "win %p", win);
110
111 if (ev_out->emo_events & MU_MESAG) {
112 switch (msg[0]) {
113
114 case WM_TOOLBAR:
115 NSLOG(netsurf, INFO, "WM_TOOLBAR");
116 break;
117
118 case WM_CLOSED:
120 retval = 1;
121 break;
122
123 default: break;
124 }
125 }
126
127 return(retval);
128}
129
131{
132 if (atari_cookie_manager.init == false) {
133
134 if (atari_cookie_manager.window == NULL) {
135 int flags = ATARI_TREEVIEW_WIDGETS;
136 short handle = -1;
137 OBJECT * tree = gemtk_obj_get_tree(TOOLBAR_COOKIES);
138 assert( tree );
139
140 handle = wind_create(flags, 0, 0, desk_area.g_w, desk_area.g_h);
141 atari_cookie_manager.window = gemtk_wm_add(handle,
142 GEMTK_WM_FLAG_DEFAULTS, NULL);
143 if( atari_cookie_manager.window == NULL ) {
144 gemtk_msg_box_show(GEMTK_MSG_BOX_ALERT,
145 "Failed to allocate Treeview:\nCookies");
146 return;
147 }
148 wind_set_str(handle, WF_NAME, (char*)messages_get("Cookies"));
149 gemtk_wm_set_toolbar(atari_cookie_manager.window, tree, 0, 0);
150 gemtk_wm_unlink(atari_cookie_manager.window);
151
155 NULL, flags);
156
157 if (atari_cookie_manager.tv == NULL) {
158 /* handle it properly, clean up previous allocs */
159 NSLOG(netsurf, INFO,
160 "Failed to allocate treeview");
161 return;
162 }
163
164 } else {
165
166 }
167 }
169}
170
172{
174
176
177 GRECT pos;
178 pos.g_x = desk_area.g_w - desk_area.g_w / 4;
179 pos.g_y = desk_area.g_y;
180 pos.g_w = desk_area.g_w / 4;
181 pos.g_h = desk_area.g_h;
182
184 } else {
185 wind_set(gemtk_wm_get_handle(atari_cookie_manager.window), WF_TOP, 1, 0,
186 0, 0);
187 }
188}
189
190
192{
194}
195
196
198{
199 if( atari_cookie_manager.init == false) {
200 return;
201 }
202 if( atari_cookie_manager.window != NULL ) {
205 wind_delete(gemtk_wm_get_handle(atari_cookie_manager.window));
206 gemtk_wm_remove(atari_cookie_manager.window);
210 }
211 NSLOG(netsurf, INFO, "done");
212
213}
214
215
217{
219}
void atari_cookie_manager_init(void)
Definition: cookies.c:130
void atari_cookie_manager_redraw(void)
Definition: cookies.c:216
struct atari_cookie_manager_s atari_cookie_manager
Definition: cookies.c:35
GRECT desk_area
Definition: gui.c:79
void atari_cookie_manager_destroy(void)
Definition: cookies.c:197
void atari_cookie_manager_open(void)
Definition: cookies.c:171
static nserror atari_cookie_manager_init_phase2(struct core_window *cw)
Definition: cookies.c:62
static void atari_cookie_manager_finish(struct core_window *cw)
Definition: cookies.c:70
static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
Definition: cookies.c:105
static struct atari_treeview_callbacks atari_cookie_manager_treeview_callbacks
Definition: cookies.c:51
static void atari_cookie_manager_mouse_action(struct core_window *cw, browser_mouse_state mouse, int x, int y)
Definition: cookies.c:96
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:78
static void atari_cookie_manager_keypress(struct core_window *cw, uint32_t ucs4)
Definition: cookies.c:88
void atari_cookie_manager_close(void)
Definition: cookies.c:191
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_init(void *core_window_handle)
Initialise the cookie manager.
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:740
bool atari_treeview_is_open(struct core_window *cw)
Returns the window "open" state.
Definition: treeview.c:780
void atari_treeview_redraw(struct core_window *cw)
Process all pending redraw requests for a single treeview.
Definition: treeview.c:627
void atari_treeview_close(struct core_window *cw)
Closes (hides) the treeview window.
Definition: treeview.c:804
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:547
void atari_treeview_open(struct core_window *cw, GRECT *pos)
Open the treeview window.
Definition: treeview.c:754
#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
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