mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-11-26 16:29:36 +03:00
Complete cookie manager corewindow interface
This commit is contained in:
parent
6e957396a9
commit
e98a05bb08
@ -25,7 +25,6 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <proto/gadtools.h>
|
||||
#include <proto/intuition.h>
|
||||
|
||||
#include <classes/window.h>
|
||||
@ -49,8 +48,25 @@
|
||||
enum {
|
||||
/* Project menu */
|
||||
AMI_COOKIE_M_PROJECT = 0,
|
||||
AMI_COOKIE_M_TEST,
|
||||
AMI_COOKIE_M_LAST
|
||||
AMI_COOKIE_M_EXPAND,
|
||||
AMI_COOKIE_M_EXPAND_ALL,
|
||||
AMI_COOKIE_M_EXPAND_DOMAINS,
|
||||
AMI_COOKIE_M_EXPAND_COOKIES,
|
||||
AMI_COOKIE_M_COLLAPSE,
|
||||
AMI_COOKIE_M_COLLAPSE_ALL,
|
||||
AMI_COOKIE_M_COLLAPSE_DOMAINS,
|
||||
AMI_COOKIE_M_COLLAPSE_COOKIES,
|
||||
AMI_COOKIE_M_BAR_P1,
|
||||
AMI_COOKIE_M_SNAPSHOT,
|
||||
AMI_COOKIE_M_BAR_P2,
|
||||
AMI_COOKIE_M_CLOSE,
|
||||
/* Edit menu */
|
||||
AMI_COOKIE_M_EDIT,
|
||||
AMI_COOKIE_M_SELECTALL,
|
||||
AMI_COOKIE_M_CLEAR,
|
||||
AMI_COOKIE_M_BAR_E1,
|
||||
AMI_COOKIE_M_DELETE,
|
||||
AMI_COOKIE_M_LAST
|
||||
};
|
||||
|
||||
/**
|
||||
@ -74,8 +90,7 @@ ami_cookies_menu_free(struct ami_cookie_window *cookie_win)
|
||||
WINDOW_MenuStrip, NULL,
|
||||
TAG_DONE);
|
||||
|
||||
ami_menu_free_labs(cookie_win->menu_data, AMI_COOKIE_M_LAST);
|
||||
FreeMenus(cookie_win->imenu);
|
||||
ami_menu_free_menu(cookie_win->menu_data, AMI_COOKIE_M_LAST, cookie_win->imenu);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -155,19 +170,106 @@ ami_cookies_draw(struct ami_corewindow *ami_cw, int x, int y, struct rect *r, st
|
||||
|
||||
/* menu hook functions */
|
||||
|
||||
HOOKF(void, ami_cookies_menu_item_project_test, APTR, window, struct IntuiMessage *)
|
||||
HOOKF(void, ami_cookies_menu_item_project_expand_all, APTR, window, struct IntuiMessage *)
|
||||
{
|
||||
|
||||
cookie_manager_expand(false);
|
||||
}
|
||||
|
||||
HOOKF(void, ami_cookies_menu_item_project_expand_domains, APTR, window, struct IntuiMessage *)
|
||||
{
|
||||
cookie_manager_expand(true);
|
||||
}
|
||||
|
||||
HOOKF(void, ami_cookies_menu_item_project_expand_cookies, APTR, window, struct IntuiMessage *)
|
||||
{
|
||||
cookie_manager_expand(false);
|
||||
}
|
||||
|
||||
HOOKF(void, ami_cookies_menu_item_project_collapse_all, APTR, window, struct IntuiMessage *)
|
||||
{
|
||||
cookie_manager_contract(true);
|
||||
}
|
||||
|
||||
HOOKF(void, ami_cookies_menu_item_project_collapse_domains, APTR, window, struct IntuiMessage *)
|
||||
{
|
||||
cookie_manager_contract(true);
|
||||
}
|
||||
|
||||
HOOKF(void, ami_cookies_menu_item_project_collapse_cookies, APTR, window, struct IntuiMessage *)
|
||||
{
|
||||
cookie_manager_contract(false);
|
||||
}
|
||||
|
||||
HOOKF(void, ami_cookies_menu_item_project_snapshot, APTR, window, struct IntuiMessage *)
|
||||
{
|
||||
struct ami_corewindow *ami_cw;
|
||||
GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&ami_cw);
|
||||
|
||||
nsoption_set_int(cookies_window_ypos, ami_cw->win->TopEdge);
|
||||
nsoption_set_int(cookies_window_xpos, ami_cw->win->LeftEdge);
|
||||
nsoption_set_int(cookies_window_xsize, ami_cw->win->Width);
|
||||
nsoption_set_int(cookies_window_ysize, ami_cw->win->Height);
|
||||
}
|
||||
|
||||
HOOKF(void, ami_cookies_menu_item_project_close, APTR, window, struct IntuiMessage *)
|
||||
{
|
||||
struct ami_corewindow *ami_cw;
|
||||
GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&ami_cw);
|
||||
|
||||
ami_cw->close_window = true;
|
||||
}
|
||||
|
||||
HOOKF(void, ami_cookies_menu_item_edit_select_all, APTR, window, struct IntuiMessage *)
|
||||
{
|
||||
cookie_manager_keypress(NS_KEY_SELECT_ALL);
|
||||
}
|
||||
|
||||
HOOKF(void, ami_cookies_menu_item_edit_clear, APTR, window, struct IntuiMessage *)
|
||||
{
|
||||
cookie_manager_keypress(NS_KEY_CLEAR_SELECTION);
|
||||
}
|
||||
|
||||
HOOKF(void, ami_cookies_menu_item_edit_delete, APTR, window, struct IntuiMessage *)
|
||||
{
|
||||
cookie_manager_keypress(NS_KEY_DELETE_LEFT);
|
||||
}
|
||||
|
||||
|
||||
/* menu setup */
|
||||
|
||||
static void ami_cookies_menulabs(struct ami_menu_data **md)
|
||||
{
|
||||
/* not real menu items */
|
||||
ami_menu_alloc_item(md, AMI_COOKIE_M_PROJECT, NM_TITLE, "Project", 0, NULL, NULL, NULL, 0);
|
||||
ami_menu_alloc_item(md, AMI_COOKIE_M_TEST, NM_ITEM, "TEST", 'N', "TBImages:list_app",
|
||||
ami_cookies_menu_item_project_test, NULL, 0);
|
||||
ami_menu_alloc_item(md, AMI_COOKIE_M_PROJECT, NM_TITLE, "Tree", 0, NULL, NULL, NULL, 0);
|
||||
ami_menu_alloc_item(md, AMI_COOKIE_M_EXPAND, NM_ITEM, "Expand", 0, "TBImages:list_folderunfold", NULL, NULL, 0);
|
||||
ami_menu_alloc_item(md, AMI_COOKIE_M_EXPAND_ALL, NM_SUB, "All", '+', NULL,
|
||||
ami_cookies_menu_item_project_expand_all, NULL, 0);
|
||||
ami_menu_alloc_item(md, AMI_COOKIE_M_EXPAND_DOMAINS, NM_SUB, "Domains", 0, NULL,
|
||||
ami_cookies_menu_item_project_expand_domains, NULL, 0);
|
||||
ami_menu_alloc_item(md, AMI_COOKIE_M_EXPAND_COOKIES, NM_SUB, "Cookies", 0, NULL,
|
||||
ami_cookies_menu_item_project_expand_cookies, NULL, 0);
|
||||
ami_menu_alloc_item(md, AMI_COOKIE_M_COLLAPSE, NM_ITEM, "Collapse", 0, "TBImages:list_folderfold", NULL, NULL, 0);
|
||||
ami_menu_alloc_item(md, AMI_COOKIE_M_COLLAPSE_ALL, NM_SUB, "All", '-', NULL,
|
||||
ami_cookies_menu_item_project_collapse_all, NULL, 0);
|
||||
ami_menu_alloc_item(md, AMI_COOKIE_M_COLLAPSE_DOMAINS, NM_SUB, "Domains", 0, NULL,
|
||||
ami_cookies_menu_item_project_collapse_domains, NULL, 0);
|
||||
ami_menu_alloc_item(md, AMI_COOKIE_M_COLLAPSE_COOKIES, NM_SUB, "Cookies", 0, NULL,
|
||||
ami_cookies_menu_item_project_collapse_cookies, NULL, 0);
|
||||
ami_menu_alloc_item(md, AMI_COOKIE_M_BAR_P1, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL, 0);
|
||||
ami_menu_alloc_item(md, AMI_COOKIE_M_SNAPSHOT, NM_ITEM, "SnapshotWindow", 0, "TBImages:list_hold",
|
||||
ami_cookies_menu_item_project_snapshot, NULL, 0);
|
||||
ami_menu_alloc_item(md, AMI_COOKIE_M_BAR_P2, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL, 0);
|
||||
ami_menu_alloc_item(md, AMI_COOKIE_M_CLOSE, NM_ITEM, "CloseWindow", 0, "TBImages:list_cancel",
|
||||
ami_cookies_menu_item_project_close, NULL, 0);
|
||||
|
||||
ami_menu_alloc_item(md, AMI_COOKIE_M_EDIT, NM_TITLE, "Edit", 0, NULL, NULL, NULL, 0);
|
||||
ami_menu_alloc_item(md, AMI_COOKIE_M_SELECTALL, NM_ITEM, "SelectAllNS", 'A', NSA_SPACE,
|
||||
ami_cookies_menu_item_edit_select_all, NULL, 0);
|
||||
ami_menu_alloc_item(md, AMI_COOKIE_M_CLEAR, NM_ITEM, "ClearNS", 0, NSA_SPACE,
|
||||
ami_cookies_menu_item_edit_clear, NULL, 0);
|
||||
ami_menu_alloc_item(md, AMI_COOKIE_M_BAR_E1, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL, 0);
|
||||
ami_menu_alloc_item(md, AMI_COOKIE_M_DELETE, NM_ITEM, "TreeDelete", 0, "TBImages:list_delete",
|
||||
ami_cookies_menu_item_edit_delete, NULL, 0);
|
||||
|
||||
ami_menu_alloc_item(md, AMI_COOKIE_M_LAST, NM_END, NULL, 0, NULL, NULL, NULL, 0);
|
||||
}
|
||||
|
||||
@ -212,6 +314,7 @@ ami_cookies_create_window(struct ami_cookie_window *cookie_win)
|
||||
WINDOW_VertProp, 1,
|
||||
WINDOW_UserData, cookie_win,
|
||||
WINDOW_MenuStrip, ami_cookies_menu_create(cookie_win),
|
||||
WINDOW_MenuUserData, WGUD_HOOK,
|
||||
WINDOW_IconifyGadget, FALSE,
|
||||
WINDOW_Position, WPOS_CENTERSCREEN,
|
||||
WINDOW_ParentGroup, ami_cw->objects[GID_CW_MAIN] = LayoutVObj,
|
||||
|
@ -472,6 +472,11 @@ ami_cw_event(void *w)
|
||||
int x = 0, y = 0;
|
||||
|
||||
while((result = RA_HandleInput(ami_cw->objects[GID_CW_WIN], &code)) != WMHI_LASTMSG) {
|
||||
if(ami_cw->close_window == true) {
|
||||
ami_cw_close(ami_cw);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
switch(result & WMHI_CLASSMASK) {
|
||||
case WMHI_MOUSEMOVE:
|
||||
if(ami_cw_mouse_pos(ami_cw, &x, &y)) {
|
||||
|
@ -58,6 +58,8 @@ struct ami_corewindow {
|
||||
int mouse_y_click;
|
||||
int mouse_state;
|
||||
|
||||
bool close_window; // set to true to close the window during event loop
|
||||
|
||||
APTR deferred_rects_pool;
|
||||
struct MinList *deferred_rects;
|
||||
|
||||
|
@ -77,7 +77,6 @@
|
||||
#include "amiga/utf8.h"
|
||||
#include "amiga/schedule.h"
|
||||
|
||||
#define NSA_SPACE "blankspace.png"
|
||||
#define NSA_MAX_HOTLIST_MENU_LEN 100
|
||||
|
||||
enum {
|
||||
@ -545,7 +544,7 @@ HOOKF(void, ami_menu_item_arexx_entries, APTR, window, struct IntuiMessage *)
|
||||
|
||||
|
||||
/* menu creation code */
|
||||
void ami_menu_free_labs(struct ami_menu_data **md, int max)
|
||||
static void ami_menu_free_labs(struct ami_menu_data **md, int max)
|
||||
{
|
||||
int i;
|
||||
|
||||
@ -984,6 +983,12 @@ void ami_menu_free(struct gui_window_2 *gwin)
|
||||
FreeMenus(gwin->imenu);
|
||||
}
|
||||
|
||||
void ami_menu_free_menu(struct ami_menu_data **md, int max, struct Menu *imenu)
|
||||
{
|
||||
ami_menu_free_labs(md, max);
|
||||
FreeMenus(imenu);
|
||||
}
|
||||
|
||||
struct Menu *ami_menu_create(struct gui_window_2 *gwin)
|
||||
{
|
||||
ami_init_menulabs(gwin->menu_data);
|
||||
|
@ -26,6 +26,9 @@
|
||||
struct hlcache_handle;
|
||||
struct ami_menu_data;
|
||||
|
||||
/** empty space */
|
||||
#define NSA_SPACE "blankspace.png"
|
||||
|
||||
/** Maximum number of hotlist items (somewhat arbitrary value) */
|
||||
#define AMI_HOTLIST_ITEMS 60
|
||||
|
||||
@ -133,18 +136,23 @@ enum {
|
||||
struct gui_window;
|
||||
struct gui_window_2;
|
||||
|
||||
void ami_free_menulabs(struct ami_menu_data **md); //specific to browser windows
|
||||
void ami_menu_free_labs(struct ami_menu_data **md, int max); // generic ver
|
||||
struct Menu *ami_menu_create(struct gui_window_2 *gwin);
|
||||
void ami_menu_refresh(struct gui_window_2 *gwin);
|
||||
void ami_menu_update_checked(struct gui_window_2 *gwin);
|
||||
void ami_menu_update_disabled(struct gui_window *g, struct hlcache_handle *c);
|
||||
/* cleanup */
|
||||
void ami_menu_free_glyphs(void);
|
||||
void ami_menu_free(struct gui_window_2 *gwin);
|
||||
|
||||
/* generic menu alloc/free/layout */
|
||||
void ami_menu_alloc_item(struct ami_menu_data **md, int num, UBYTE type,
|
||||
const char *restrict label, char key, const char *restrict icon,
|
||||
void *restrict func, void *restrict hookdata, UWORD flags);
|
||||
struct Menu *ami_menu_layout(struct ami_menu_data **md, int max);
|
||||
void ami_menu_free_menu(struct ami_menu_data **md, int max, struct Menu *imenu);
|
||||
|
||||
/* specific to browser windows */
|
||||
void ami_free_menulabs(struct ami_menu_data **md);
|
||||
struct Menu *ami_menu_create(struct gui_window_2 *gwin);
|
||||
void ami_menu_refresh(struct gui_window_2 *gwin);
|
||||
void ami_menu_update_checked(struct gui_window_2 *gwin);
|
||||
void ami_menu_update_disabled(struct gui_window *g, struct hlcache_handle *c);
|
||||
void ami_menu_free(struct gui_window_2 *gwin);
|
||||
|
||||
/**
|
||||
* Sets that an item linked to a toggle menu item has been changed.
|
||||
|
Loading…
Reference in New Issue
Block a user