NetSurf
Data Structures | Macros | Functions | Variables
cookies.c File Reference

Implementation of GTK cookie manager. More...

#include <stdint.h>
#include <stdlib.h>
#include <gtk/gtk.h>
#include "utils/log.h"
#include "netsurf/keypress.h"
#include "netsurf/plotters.h"
#include "desktop/cookie_manager.h"
#include "gtk/cookies.h"
#include "gtk/plotters.h"
#include "gtk/resources.h"
#include "gtk/corewindow.h"
Include dependency graph for cookies.c:

Go to the source code of this file.

Data Structures

struct  nsgtk_cookie_window
 
struct  menu_events
 

Macros

#define MENUPROTO(x)
 
#define MENUEVENT(x)   { #x, G_CALLBACK(nsgtk_on_##x##_activate) }
 
#define MENUHANDLER(x)
 

Functions

 MENUPROTO (delete_selected)
 
 MENUPROTO (delete_all)
 
 MENUPROTO (select_all)
 
 MENUPROTO (clear_selection)
 
 MENUPROTO (expand_all)
 
 MENUPROTO (expand_domains)
 
 MENUPROTO (expand_cookies)
 
 MENUPROTO (collapse_all)
 
 MENUPROTO (collapse_domains)
 
 MENUPROTO (collapse_cookies)
 
 MENUHANDLER (delete_selected)
 
 MENUHANDLER (delete_all)
 
 MENUHANDLER (select_all)
 
 MENUHANDLER (clear_selection)
 
 MENUHANDLER (expand_all)
 
 MENUHANDLER (expand_domains)
 
 MENUHANDLER (expand_cookies)
 
 MENUHANDLER (collapse_all)
 
 MENUHANDLER (collapse_domains)
 
 MENUHANDLER (collapse_cookies)
 
static void nsgtk_cookies_init_menu (struct nsgtk_cookie_window *ncwin)
 Connects menu events in the cookies window. More...
 
static nserror nsgtk_cookies_mouse (struct nsgtk_corewindow *nsgtk_cw, browser_mouse_state mouse_state, int x, int y)
 callback for mouse action on cookie window More...
 
static nserror nsgtk_cookies_key (struct nsgtk_corewindow *nsgtk_cw, uint32_t nskey)
 callback for keypress on cookie window More...
 
static nserror nsgtk_cookies_draw (struct nsgtk_corewindow *nsgtk_cw, struct rect *r)
 callback on draw event for cookie window More...
 
static nserror nsgtk_cookies_init (void)
 Creates the window for the cookies tree. More...
 
nserror nsgtk_cookies_present (const char *search_term)
 make the cookie window visible. More...
 
nserror nsgtk_cookies_destroy (void)
 Free any resources allocated for the cookie window. More...
 

Variables

static struct nsgtk_cookie_windowcookie_window = NULL
 
static struct menu_events menu_events []
 

Detailed Description

Implementation of GTK cookie manager.

Definition in file cookies.c.

Macro Definition Documentation

◆ MENUEVENT

#define MENUEVENT (   x)    { #x, G_CALLBACK(nsgtk_on_##x##_activate) }

Definition at line 48 of file cookies.c.

◆ MENUHANDLER

#define MENUHANDLER (   x)
Value:
gboolean nsgtk_on_##x##_activate(GtkMenuItem *widget, \
gpointer g)

Definition at line 49 of file cookies.c.

◆ MENUPROTO

#define MENUPROTO (   x)
Value:
static gboolean nsgtk_on_##x##_activate( \
GtkMenuItem *widget, gpointer g)

Definition at line 46 of file cookies.c.

Function Documentation

◆ MENUHANDLER() [1/10]

MENUHANDLER ( clear_selection  )

Definition at line 116 of file cookies.c.

References cookie_manager_keypress(), and NS_KEY_CLEAR_SELECTION.

Here is the call graph for this function:

◆ MENUHANDLER() [2/10]

MENUHANDLER ( collapse_all  )

Definition at line 141 of file cookies.c.

References cookie_manager_contract().

Here is the call graph for this function:

◆ MENUHANDLER() [3/10]

MENUHANDLER ( collapse_cookies  )

Definition at line 153 of file cookies.c.

References cookie_manager_contract().

Here is the call graph for this function:

◆ MENUHANDLER() [4/10]

MENUHANDLER ( collapse_domains  )

Definition at line 147 of file cookies.c.

References cookie_manager_contract().

Here is the call graph for this function:

◆ MENUHANDLER() [5/10]

MENUHANDLER ( delete_all  )

Definition at line 99 of file cookies.c.

References cookie_manager_keypress(), NS_KEY_DELETE_LEFT, NS_KEY_ESCAPE, and NS_KEY_SELECT_ALL.

Here is the call graph for this function:

◆ MENUHANDLER() [6/10]

MENUHANDLER ( delete_selected  )

Definition at line 93 of file cookies.c.

References cookie_manager_keypress(), and NS_KEY_DELETE_LEFT.

Here is the call graph for this function:

◆ MENUHANDLER() [7/10]

MENUHANDLER ( expand_all  )

Definition at line 123 of file cookies.c.

References cookie_manager_expand().

Here is the call graph for this function:

◆ MENUHANDLER() [8/10]

MENUHANDLER ( expand_cookies  )

Definition at line 135 of file cookies.c.

References cookie_manager_expand().

Here is the call graph for this function:

◆ MENUHANDLER() [9/10]

MENUHANDLER ( expand_domains  )

Definition at line 129 of file cookies.c.

References cookie_manager_expand().

Here is the call graph for this function:

◆ MENUHANDLER() [10/10]

MENUHANDLER ( select_all  )

Definition at line 108 of file cookies.c.

References cookie_manager_keypress(), NS_KEY_ESCAPE, and NS_KEY_SELECT_ALL.

Here is the call graph for this function:

◆ MENUPROTO() [1/10]

MENUPROTO ( clear_selection  )

◆ MENUPROTO() [2/10]

MENUPROTO ( collapse_all  )

◆ MENUPROTO() [3/10]

MENUPROTO ( collapse_cookies  )

◆ MENUPROTO() [4/10]

MENUPROTO ( collapse_domains  )

◆ MENUPROTO() [5/10]

MENUPROTO ( delete_all  )

◆ MENUPROTO() [6/10]

MENUPROTO ( delete_selected  )

◆ MENUPROTO() [7/10]

MENUPROTO ( expand_all  )

◆ MENUPROTO() [8/10]

MENUPROTO ( expand_cookies  )

◆ MENUPROTO() [9/10]

MENUPROTO ( expand_domains  )

◆ MENUPROTO() [10/10]

MENUPROTO ( select_all  )

◆ nsgtk_cookies_destroy()

nserror nsgtk_cookies_destroy ( void  )

Free any resources allocated for the cookie window.

Returns
NSERROR_OK on success else appropriate error code on faliure.

Definition at line 326 of file cookies.c.

References nsgtk_cookie_window::builder, cookie_manager_fini(), cookie_window, nsgtk_cookie_window::core, NSERROR_OK, nsgtk_corewindow_fini(), and nsgtk_cookie_window::wnd.

Referenced by nsgtk_finalise().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ nsgtk_cookies_draw()

static nserror nsgtk_cookies_draw ( struct nsgtk_corewindow nsgtk_cw,
struct rect r 
)
static

callback on draw event for cookie window

Parameters
nsgtk_cwThe nsgtk core window structure.
rThe rectangle of the window that needs updating.
Returns
NSERROR_OK on success otherwise appropriate error code

Definition at line 227 of file cookies.c.

References cookie_manager_redraw(), redraw_context::interactive, NSERROR_OK, and nsgtk_plotters.

Referenced by nsgtk_cookies_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ nsgtk_cookies_init()

static nserror nsgtk_cookies_init ( void  )
static

Creates the window for the cookies tree.

Returns
NSERROR_OK on success else appropriate error code on failure.

Definition at line 245 of file cookies.c.

References nsgtk_cookie_window::builder, nsgtk_corewindow::cb_table, cookie_manager_init(), cookie_window, nsgtk_cookie_window::core, nsgtk_corewindow::draw, nsgtk_corewindow::drawing_area, nsgtk_corewindow::key, nsgtk_corewindow::mouse, NSERROR_NOMEM, NSERROR_OK, nsgtk_builder_new_from_resname(), nsgtk_cookies_draw(), nsgtk_cookies_init_menu(), nsgtk_cookies_key(), nsgtk_cookies_mouse(), nsgtk_corewindow_init(), NSLOG, nsgtk_corewindow::scrolled, and nsgtk_cookie_window::wnd.

Referenced by nsgtk_cookies_present().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ nsgtk_cookies_init_menu()

static void nsgtk_cookies_init_menu ( struct nsgtk_cookie_window ncwin)
static

Connects menu events in the cookies window.

Definition at line 162 of file cookies.c.

References nsgtk_cookie_window::builder, menu_events, and NSLOG.

Referenced by nsgtk_cookies_init().

Here is the caller graph for this function:

◆ nsgtk_cookies_key()

static nserror nsgtk_cookies_key ( struct nsgtk_corewindow nsgtk_cw,
uint32_t  nskey 
)
static

callback for keypress on cookie window

Parameters
nsgtk_cwThe nsgtk core window structure.
nskeyThe netsurf key code
Returns
NSERROR_OK on success otherwise appropriate error code

Definition at line 211 of file cookies.c.

References cookie_manager_keypress(), NSERROR_NOT_IMPLEMENTED, and NSERROR_OK.

Referenced by nsgtk_cookies_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ nsgtk_cookies_mouse()

static nserror nsgtk_cookies_mouse ( struct nsgtk_corewindow nsgtk_cw,
browser_mouse_state  mouse_state,
int  x,
int  y 
)
static

callback for mouse action on cookie window

Parameters
nsgtk_cwThe nsgtk core window structure.
mouse_statenetsurf mouse state on event
xlocation of event
ylocation of event
Returns
NSERROR_OK on success otherwise appropriate error code

Definition at line 194 of file cookies.c.

References cookie_manager_mouse_action(), and NSERROR_OK.

Referenced by nsgtk_cookies_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ nsgtk_cookies_present()

nserror nsgtk_cookies_present ( const char *  search_term)

make the cookie window visible.

Returns
NSERROR_OK on success else appropriate error code on faliure.

Definition at line 312 of file cookies.c.

References cookie_manager_set_search_string(), cookie_window, NSERROR_OK, nsgtk_cookies_init(), and nsgtk_cookie_window::wnd.

Referenced by showcookies_button_clicked_cb().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ cookie_window

struct nsgtk_cookie_window* cookie_window = NULL
static

Definition at line 44 of file cookies.c.

Referenced by nsgtk_cookies_destroy(), nsgtk_cookies_init(), and nsgtk_cookies_present().

◆ menu_events

struct menu_events menu_events[]
static
Initial value:
= {
MENUEVENT(delete_selected),
MENUEVENT(delete_all),
MENUEVENT(select_all),
MENUEVENT(clear_selection),
MENUEVENT(expand_all),
MENUEVENT(expand_domains),
MENUEVENT(expand_cookies),
MENUEVENT(collapse_all),
MENUEVENT(collapse_domains),
MENUEVENT(collapse_cookies),
{NULL, NULL}
}
#define MENUEVENT(x)
Definition: cookies.c:48

Definition at line 72 of file cookies.c.

Referenced by nsgtk_cookies_init_menu().