mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-11-22 06:21:45 +03:00
Split up menu.c into generic and gui_window-specific files
This commit is contained in:
parent
52f98c9fb2
commit
606cc0c219
@ -46,7 +46,7 @@ S_FRONTEND := gui.c history.c hotlist.c schedule.c file.c \
|
||||
stringview/stringview.c stringview/urlhistory.c rtg.c \
|
||||
agclass/amigaguide_class.c os3support.c font_diskfont.c \
|
||||
selectmenu.c hash/xxhash.c font_cache.c font_bullet.c \
|
||||
nsoption.c corewindow.c
|
||||
nsoption.c corewindow.c gui_menu.c
|
||||
|
||||
# This is the final source build list
|
||||
# Note this is deliberately *not* expanded here as common and image
|
||||
|
@ -44,7 +44,7 @@
|
||||
#include "amiga/gui.h"
|
||||
#include "amiga/iff_cset.h"
|
||||
#include "amiga/iff_dr2d.h"
|
||||
#include "amiga/menu.h"
|
||||
#include "amiga/gui_menu.h"
|
||||
#include "amiga/utf8.h"
|
||||
|
||||
#define ID_UTF8 MAKE_ID('U','T','F','8')
|
||||
@ -89,11 +89,11 @@ void gui_start_selection(struct gui_window *g)
|
||||
if(!g->shared->win) return;
|
||||
if(nsoption_bool(kiosk_mode) == true) return;
|
||||
|
||||
ami_menu_set_disabled(g->shared->win, g->shared->imenu, M_COPY, false);
|
||||
ami_menu_set_disabled(g->shared->win, g->shared->imenu, M_CLEAR, false);
|
||||
ami_gui_menu_set_disabled(g->shared->win, g->shared->imenu, M_COPY, false);
|
||||
ami_gui_menu_set_disabled(g->shared->win, g->shared->imenu, M_CLEAR, false);
|
||||
|
||||
if (browser_window_get_editor_flags(g->bw) & BW_EDITOR_CAN_CUT)
|
||||
ami_menu_set_disabled(g->shared->win, g->shared->imenu, M_CUT, false);
|
||||
ami_gui_menu_set_disabled(g->shared->win, g->shared->imenu, M_CUT, false);
|
||||
}
|
||||
|
||||
static char *ami_clipboard_cat_collection(struct CollectionItem *ci, LONG codeset, size_t *text_length)
|
||||
|
@ -43,6 +43,7 @@
|
||||
#include "amiga/cookies.h"
|
||||
#include "amiga/corewindow.h"
|
||||
#include "amiga/libs.h"
|
||||
#include "amiga/menu.h"
|
||||
#include "amiga/utf8.h"
|
||||
|
||||
enum {
|
||||
|
@ -1209,9 +1209,9 @@ static void ami_update_buttons(struct gui_window_2 *gwin)
|
||||
if(nsoption_bool(kiosk_mode) == false) {
|
||||
if(gwin->tabs <= 1) {
|
||||
tabclose=TRUE;
|
||||
ami_menu_set_disabled(gwin->win, gwin->imenu, M_CLOSETAB, true);
|
||||
ami_gui_menu_set_disabled(gwin->win, gwin->imenu, M_CLOSETAB, true);
|
||||
} else {
|
||||
ami_menu_set_disabled(gwin->win, gwin->imenu, M_CLOSETAB, false);
|
||||
ami_gui_menu_set_disabled(gwin->win, gwin->imenu, M_CLOSETAB, false);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1637,7 +1637,7 @@ static void ami_gui_menu_update_all(void)
|
||||
|
||||
if(node->Type == AMINS_WINDOW)
|
||||
{
|
||||
ami_menu_update_checked(gwin);
|
||||
ami_gui_menu_update_checked(gwin);
|
||||
}
|
||||
} while((node = nnode));
|
||||
}
|
||||
@ -1964,11 +1964,11 @@ static BOOL ami_handle_msg(void)
|
||||
}
|
||||
} while((node = nnode));
|
||||
|
||||
if(ami_menu_quit_selected() == true) {
|
||||
if(ami_gui_menu_quit_selected() == true) {
|
||||
ami_quit_netsurf();
|
||||
}
|
||||
|
||||
if(ami_menu_get_check_toggled() == true) {
|
||||
if(ami_gui_menu_get_check_toggled() == true) {
|
||||
ami_gui_menu_update_all();
|
||||
}
|
||||
|
||||
@ -2903,7 +2903,7 @@ void ami_switch_tab(struct gui_window_2 *gwin, bool redraw)
|
||||
|
||||
ami_plot_release_pens(gwin->shared_pens);
|
||||
ami_update_buttons(gwin);
|
||||
ami_menu_update_disabled(gwin->gw, browser_window_get_content(gwin->gw->bw));
|
||||
ami_gui_menu_update_disabled(gwin->gw, browser_window_get_content(gwin->gw->bw));
|
||||
|
||||
if(redraw)
|
||||
{
|
||||
@ -3336,7 +3336,7 @@ void ami_gui_hotlist_update_all(void)
|
||||
if(node->Type == AMINS_WINDOW)
|
||||
{
|
||||
ami_gui_hotlist_toolbar_update(gwin);
|
||||
ami_menu_refresh(gwin);
|
||||
//ami_gui_menu_refresh_hotlist(gwin);
|
||||
}
|
||||
} while((node = nnode));
|
||||
}
|
||||
@ -3985,7 +3985,7 @@ gui_window_create(struct browser_window *bw,
|
||||
iconifygadget = TRUE;
|
||||
|
||||
LOG("Creating menu");
|
||||
struct Menu *menu = ami_menu_create(g->shared);
|
||||
struct Menu *menu = ami_gui_menu_create(g->shared);
|
||||
|
||||
NewList(&g->shared->tab_list);
|
||||
g->tab_node = AllocClickTabNode(TNA_Text,messages_get("NetSurf"),
|
||||
@ -4603,7 +4603,7 @@ static void gui_window_destroy(struct gui_window *g)
|
||||
DisposeObject((Object *)g->shared->history_ctxmenu[AMI_CTXMENU_HISTORY_BACK]);
|
||||
DisposeObject((Object *)g->shared->history_ctxmenu[AMI_CTXMENU_HISTORY_FORWARD]);
|
||||
ami_ctxmenu_release_hook(g->shared->ctxmenu_hook);
|
||||
ami_menu_free(g->shared);
|
||||
ami_gui_menu_free(g->shared);
|
||||
|
||||
free(g->shared->wintitle);
|
||||
ami_utf8_free(g->shared->status);
|
||||
@ -5257,7 +5257,7 @@ static void gui_window_place_caret(struct gui_window *g, int x, int y, int heigh
|
||||
g->c_h = height;
|
||||
|
||||
if((nsoption_bool(kiosk_mode) == false))
|
||||
ami_menu_set_disabled(g->shared->win, g->shared->imenu, M_PASTE, false);
|
||||
ami_gui_menu_set_disabled(g->shared->win, g->shared->imenu, M_PASTE, false);
|
||||
}
|
||||
|
||||
static void gui_window_remove_caret(struct gui_window *g)
|
||||
@ -5266,7 +5266,7 @@ static void gui_window_remove_caret(struct gui_window *g)
|
||||
if(g->c_h == 0) return;
|
||||
|
||||
if((nsoption_bool(kiosk_mode) == false))
|
||||
ami_menu_set_disabled(g->shared->win, g->shared->imenu, M_PASTE, true);
|
||||
ami_gui_menu_set_disabled(g->shared->win, g->shared->imenu, M_PASTE, true);
|
||||
|
||||
ami_do_redraw_limits(g, g->bw, false, g->c_x, g->c_y,
|
||||
g->c_x + g->c_w + 1, g->c_y + g->c_h + 1);
|
||||
@ -5290,7 +5290,7 @@ static void gui_window_new_content(struct gui_window *g)
|
||||
g->shared->oldv = 0;
|
||||
g->favicon = NULL;
|
||||
ami_plot_release_pens(g->shared->shared_pens);
|
||||
ami_menu_update_disabled(g, c);
|
||||
ami_gui_menu_update_disabled(g, c);
|
||||
ami_gui_update_hotlist_button(g->shared);
|
||||
ami_gui_scroller_update(g->shared);
|
||||
}
|
||||
|
@ -28,7 +28,7 @@
|
||||
#include "netsurf/window.h"
|
||||
#include "netsurf/mouse.h"
|
||||
|
||||
#include "amiga/menu.h"
|
||||
#include "amiga/gui_menu.h"
|
||||
#include "amiga/object.h"
|
||||
#include "amiga/os3support.h"
|
||||
|
||||
|
1084
frontends/amiga/gui_menu.c
Normal file
1084
frontends/amiga/gui_menu.c
Normal file
File diff suppressed because it is too large
Load Diff
153
frontends/amiga/gui_menu.h
Normal file
153
frontends/amiga/gui_menu.h
Normal file
@ -0,0 +1,153 @@
|
||||
/*
|
||||
* Copyright 2008-2017 Chris Young <chris@unsatisfactorysoftware.co.uk>
|
||||
*
|
||||
* This file is part of NetSurf, http://www.netsurf-browser.org/
|
||||
*
|
||||
* NetSurf is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; version 2 of the License.
|
||||
*
|
||||
* NetSurf is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef AMIGA_GUI_MENU_H
|
||||
#define AMIGA_GUI_MENU_H
|
||||
|
||||
/** Maximum number of hotlist items (somewhat arbitrary value) */
|
||||
#define AMI_HOTLIST_ITEMS 200
|
||||
|
||||
/** Maximum number of ARexx menu items (somewhat arbitrary value) */
|
||||
#define AMI_MENU_AREXX_ITEMS 20
|
||||
|
||||
/** enum menu structure, has to be here as we need it below. */
|
||||
enum {
|
||||
/* Project menu */
|
||||
M_PROJECT = 0,
|
||||
M_NEWWIN,
|
||||
M_NEWTAB,
|
||||
M_BAR_P1,
|
||||
M_OPEN,
|
||||
M_SAVEAS,
|
||||
M_SAVESRC,
|
||||
M_SAVETXT,
|
||||
M_SAVECOMP,
|
||||
M_SAVEIFF,
|
||||
#ifdef WITH_PDF_EXPORT
|
||||
M_SAVEPDF,
|
||||
#endif
|
||||
M_BAR_P2,
|
||||
M_PRINT,
|
||||
M_BAR_P3,
|
||||
M_CLOSETAB,
|
||||
M_CLOSEWIN,
|
||||
M_BAR_P4,
|
||||
M_ABOUT,
|
||||
M_BAR_P5,
|
||||
M_QUIT,
|
||||
/* Edit menu */
|
||||
M_EDIT,
|
||||
M_CUT,
|
||||
M_COPY,
|
||||
M_PASTE,
|
||||
M_BAR_E1,
|
||||
M_SELALL,
|
||||
M_CLEAR,
|
||||
M_BAR_E2,
|
||||
M_UNDO,
|
||||
M_REDO,
|
||||
/* Browser menu */
|
||||
M_BROWSER,
|
||||
M_FIND,
|
||||
M_BAR_B1,
|
||||
M_HISTLOCL,
|
||||
M_HISTGLBL,
|
||||
M_BAR_B2,
|
||||
M_COOKIES,
|
||||
M_BAR_B3,
|
||||
M_SCALE,
|
||||
M_SCALEDEC,
|
||||
M_SCALENRM,
|
||||
M_SCALEINC,
|
||||
M_IMAGES,
|
||||
M_IMGFORE,
|
||||
M_IMGBACK,
|
||||
M_JS,
|
||||
M_BAR_B4,
|
||||
M_REDRAW,
|
||||
/* Hotlist menu */
|
||||
M_HOTLIST,
|
||||
M_HLADD,
|
||||
M_HLSHOW,
|
||||
M_BAR_H1, // 47
|
||||
AMI_MENU_HOTLIST, /* Where the hotlist entries start */
|
||||
AMI_MENU_HOTLIST_MAX = AMI_MENU_HOTLIST + AMI_HOTLIST_ITEMS,
|
||||
/* Settings menu */
|
||||
M_PREFS,
|
||||
M_PREDIT,
|
||||
M_BAR_S1,
|
||||
M_SNAPSHOT,
|
||||
M_PRSAVE,
|
||||
/* ARexx menu */
|
||||
M_AREXX,
|
||||
M_AREXXEX,
|
||||
M_BAR_A1,
|
||||
AMI_MENU_AREXX,
|
||||
AMI_MENU_AREXX_MAX = AMI_MENU_AREXX + AMI_MENU_AREXX_ITEMS
|
||||
};
|
||||
|
||||
/* We can get away with AMI_MENU_MAX falling short as it is
|
||||
* only used for freeing the UTF-8 converted menu labels */
|
||||
#define AMI_MENU_MAX AMI_MENU_AREXX
|
||||
|
||||
struct gui_window;
|
||||
struct gui_window_2;
|
||||
struct hlcache_handle;
|
||||
|
||||
ULONG ami_gui_menu_number(int item);
|
||||
struct Menu *ami_gui_menu_create(struct gui_window_2 *gwin);
|
||||
void ami_gui_menu_free(struct gui_window_2 *gwin);
|
||||
|
||||
void ami_gui_menu_update_checked(struct gui_window_2 *gwin);
|
||||
void ami_gui_menu_update_disabled(struct gui_window *g, struct hlcache_handle *c);
|
||||
|
||||
/**
|
||||
* Sets that an item linked to a toggle menu item has been changed.
|
||||
*/
|
||||
void ami_gui_menu_set_check_toggled(void);
|
||||
|
||||
/**
|
||||
* Gets if the menu needs updating because an item linked
|
||||
* to a toggle menu item has been changed.
|
||||
* NB: This also *clears* the state
|
||||
*
|
||||
* \return true if the menus need refreshing
|
||||
*/
|
||||
bool ami_gui_menu_get_check_toggled(void);
|
||||
|
||||
/**
|
||||
* Set checked state of a menu item
|
||||
* almost generic, but not quite
|
||||
*/
|
||||
void ami_gui_menu_set_checked(struct Menu *menu, int item, bool check);
|
||||
|
||||
/**
|
||||
* Set disabled state of a menu item
|
||||
* almost generic, but not quite
|
||||
*/
|
||||
void ami_gui_menu_set_disabled(struct Window *win, struct Menu *menu, int item, bool disable);
|
||||
|
||||
|
||||
/**
|
||||
* Gets if NetSurf has been quit from the menu
|
||||
*
|
||||
* \return true if NetSurf has been quit
|
||||
*/
|
||||
bool ami_gui_menu_quit_selected(void);
|
||||
#endif
|
||||
|
@ -70,6 +70,7 @@
|
||||
#include "amiga/font.h"
|
||||
#include "amiga/font_bullet.h"
|
||||
#include "amiga/gui.h"
|
||||
#include "amiga/gui_menu.h"
|
||||
#include "amiga/gui_options.h"
|
||||
#include "amiga/help.h"
|
||||
#include "amiga/libs.h"
|
||||
@ -2066,7 +2067,7 @@ static void ami_gui_opts_use(bool save)
|
||||
ami_font_savescanner(); /* just in case it has changed and been used only */
|
||||
}
|
||||
|
||||
ami_menu_set_check_toggled();
|
||||
ami_gui_menu_set_check_toggled();
|
||||
ami_update_pointer(gow->win, GUI_POINTER_DEFAULT);
|
||||
}
|
||||
|
||||
|
@ -49,6 +49,7 @@
|
||||
#include "amiga/file.h"
|
||||
#include "amiga/history.h"
|
||||
#include "amiga/libs.h"
|
||||
#include "amiga/menu.h"
|
||||
#include "amiga/theme.h"
|
||||
#include "amiga/utf8.h"
|
||||
|
||||
|
@ -49,6 +49,7 @@
|
||||
#include "amiga/file.h"
|
||||
#include "amiga/hotlist.h"
|
||||
#include "amiga/libs.h"
|
||||
#include "amiga/menu.h"
|
||||
#include "amiga/theme.h"
|
||||
#include "amiga/utf8.h"
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008,2009,2013 Chris Young <chris@unsatisfactorysoftware.co.uk>
|
||||
* Copyright 2017 Chris Young <chris@unsatisfactorysoftware.co.uk>
|
||||
*
|
||||
* This file is part of NetSurf, http://www.netsurf-browser.org/
|
||||
*
|
||||
@ -23,101 +23,19 @@
|
||||
#include <intuition/intuition.h>
|
||||
#include <libraries/gadtools.h>
|
||||
|
||||
struct hlcache_handle;
|
||||
struct ami_menu_data;
|
||||
struct ami_menu_data {
|
||||
char *restrict menulab;
|
||||
Object *restrict menuobj;
|
||||
char *restrict menukey;
|
||||
char *restrict menuicon;
|
||||
struct Hook menu_hook;
|
||||
UBYTE menutype;
|
||||
UWORD flags;
|
||||
};
|
||||
|
||||
/** empty space */
|
||||
#define NSA_SPACE "blankspace.png"
|
||||
|
||||
/** Maximum number of hotlist items (somewhat arbitrary value) */
|
||||
#define AMI_HOTLIST_ITEMS 60
|
||||
|
||||
/** Maximum number of ARexx menu items (somewhat arbitrary value) */
|
||||
#define AMI_MENU_AREXX_ITEMS 20
|
||||
|
||||
/** enum menu structure, has to be here as we need it below. */
|
||||
enum {
|
||||
/* Project menu */
|
||||
M_PROJECT = 0,
|
||||
M_NEWWIN,
|
||||
M_NEWTAB,
|
||||
M_BAR_P1,
|
||||
M_OPEN,
|
||||
M_SAVEAS,
|
||||
M_SAVESRC,
|
||||
M_SAVETXT,
|
||||
M_SAVECOMP,
|
||||
M_SAVEIFF,
|
||||
#ifdef WITH_PDF_EXPORT
|
||||
M_SAVEPDF,
|
||||
#endif
|
||||
M_BAR_P2,
|
||||
M_PRINT,
|
||||
M_BAR_P3,
|
||||
M_CLOSETAB,
|
||||
M_CLOSEWIN,
|
||||
M_BAR_P4,
|
||||
M_ABOUT,
|
||||
M_BAR_P5,
|
||||
M_QUIT,
|
||||
/* Edit menu */
|
||||
M_EDIT,
|
||||
M_CUT,
|
||||
M_COPY,
|
||||
M_PASTE,
|
||||
M_BAR_E1,
|
||||
M_SELALL,
|
||||
M_CLEAR,
|
||||
M_BAR_E2,
|
||||
M_UNDO,
|
||||
M_REDO,
|
||||
/* Browser menu */
|
||||
M_BROWSER,
|
||||
M_FIND,
|
||||
M_BAR_B1,
|
||||
M_HISTLOCL,
|
||||
M_HISTGLBL,
|
||||
M_BAR_B2,
|
||||
M_COOKIES,
|
||||
M_BAR_B3,
|
||||
M_SCALE,
|
||||
M_SCALEDEC,
|
||||
M_SCALENRM,
|
||||
M_SCALEINC,
|
||||
M_IMAGES,
|
||||
M_IMGFORE,
|
||||
M_IMGBACK,
|
||||
M_JS,
|
||||
M_BAR_B4,
|
||||
M_REDRAW,
|
||||
/* Hotlist menu */
|
||||
M_HOTLIST,
|
||||
M_HLADD,
|
||||
M_HLSHOW,
|
||||
M_BAR_H1, // 47
|
||||
AMI_MENU_HOTLIST, /* Where the hotlist entries start */
|
||||
AMI_MENU_HOTLIST_MAX = AMI_MENU_HOTLIST + AMI_HOTLIST_ITEMS,
|
||||
/* Settings menu */
|
||||
M_PREFS,
|
||||
M_PREDIT,
|
||||
M_BAR_S1,
|
||||
M_SNAPSHOT,
|
||||
M_PRSAVE,
|
||||
/* ARexx menu */
|
||||
M_AREXX,
|
||||
M_AREXXEX,
|
||||
M_BAR_A1,
|
||||
AMI_MENU_AREXX,
|
||||
AMI_MENU_AREXX_MAX = AMI_MENU_AREXX + AMI_MENU_AREXX_ITEMS
|
||||
};
|
||||
|
||||
/* We can get away with AMI_MENU_MAX falling short as it is
|
||||
* only used for freeing the UTF-8 converted menu labels */
|
||||
#define AMI_MENU_MAX AMI_MENU_AREXX
|
||||
|
||||
struct gui_window;
|
||||
struct gui_window_2;
|
||||
|
||||
/* cleanup */
|
||||
void ami_menu_free_glyphs(void);
|
||||
|
||||
@ -128,37 +46,9 @@ void ami_menu_alloc_item(struct ami_menu_data **md, int num, UBYTE type,
|
||||
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 */
|
||||
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);
|
||||
|
||||
/**
|
||||
* Set disabled state of a menu item
|
||||
* Get the selected state of a menu item
|
||||
*/
|
||||
void ami_menu_set_disabled(struct Window *win, struct Menu *menu, int item, bool disable);
|
||||
|
||||
/**
|
||||
* Sets that an item linked to a toggle menu item has been changed.
|
||||
*/
|
||||
void ami_menu_set_check_toggled(void);
|
||||
|
||||
/**
|
||||
* Gets if the menu needs updating because an item linked
|
||||
* to a toggle menu item has been changed.
|
||||
* NB: This also *clears* the state
|
||||
*
|
||||
* \return true if the menus need refreshing
|
||||
*/
|
||||
bool ami_menu_get_check_toggled(void);
|
||||
|
||||
/**
|
||||
* Gets if NetSurf has been quit from the menu
|
||||
*
|
||||
* \return true if NetSurf has been quit
|
||||
*/
|
||||
bool ami_menu_quit_selected(void);
|
||||
bool ami_menu_get_selected(struct Menu *menu, struct IntuiMessage *msg);
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user