move teh final optional window operations into the table

This commit is contained in:
Vincent Sanders 2014-01-13 22:54:19 +00:00
parent e82d83f184
commit d18c8ed452
25 changed files with 150 additions and 294 deletions

View File

@ -107,17 +107,6 @@ void gui_start_selection(struct gui_window *g)
OnMenu(g->shared->win, AMI_MENU_CUT);
}
void gui_clear_selection(struct gui_window *g)
{
if(!g) return;
if(!g->shared->win) return;
if(nsoption_bool(kiosk_mode) == true) return;
OffMenu(g->shared->win, AMI_MENU_CLEAR);
OffMenu(g->shared->win, AMI_MENU_CUT);
OffMenu(g->shared->win, AMI_MENU_COPY);
}
char *ami_clipboard_cat_collection(struct CollectionItem *ci, LONG codeset, size_t *text_length)
{
struct CollectionItem *ci_new = NULL, *ci_next, *ci_curr = ci;

View File

@ -26,6 +26,8 @@ struct selection;
struct gui_window;
struct gui_window_2;
void gui_start_selection(struct gui_window *g);
void ami_clipboard_init(void);
void ami_clipboard_free(void);
void ami_drag_selection(struct gui_window *g);

View File

@ -50,8 +50,8 @@ ULONG drag_icon_width;
ULONG drag_icon_height;
BOOL drag_in_progress = FALSE;
void gui_drag_save_object(gui_save_type type, hlcache_handle *c,
struct gui_window *g)
void gui_drag_save_object(struct gui_window *g, hlcache_handle *c,
gui_save_type type)
{
const char *filetype = NULL;

View File

@ -26,6 +26,9 @@ int drag_save;
void *drag_save_data;
struct gui_window *drag_save_gui;
void gui_drag_save_selection(struct gui_window *g, const char *selection);
void gui_drag_save_object(struct gui_window *g, hlcache_handle *c, gui_save_type type);
void ami_drag_save(struct Window *win);
void ami_drag_icon_show(struct Window *win, const char *type);
void ami_drag_icon_close(struct Window *win);

View File

@ -5066,7 +5066,7 @@ void ami_gui_splash_close(Object *win_obj)
if(win_obj) DisposeObject(win_obj);
}
void gui_file_gadget_open(struct gui_window *g, hlcache_handle *hl,
static void gui_file_gadget_open(struct gui_window *g, hlcache_handle *hl,
struct form_control *gadget)
{
LOG(("File open dialog rquest for %p/%p", g, gadget));
@ -5103,6 +5103,10 @@ static struct gui_window_table ami_window_table = {
.remove_caret = gui_window_remove_caret,
.drag_start = gui_window_drag_start,
.new_content = gui_window_new_content,
.file_gadget_open = gui_file_gadget_open,
.drag_save_object = gui_drag_save_object,
.drag_save_selection =gui_drag_save_selection,
.start_selection = gui_start_selection,
/* from theme */
.set_pointer = gui_window_set_pointer,

View File

@ -445,13 +445,6 @@ static void gui_window_update_extent(struct gui_window *gw)
}
void gui_clear_selection(struct gui_window *g)
{
}
/**
* set the pointer shape
*/
@ -659,24 +652,6 @@ static void gui_window_new_content(struct gui_window *w)
gui_window_redraw_window(w);
}
void gui_drag_save_object(gui_save_type type, hlcache_handle *c,
struct gui_window *w)
{
LOG((""));
TODO();
}
void gui_drag_save_selection(struct gui_window *g, const char *selection)
{
LOG((""));
TODO();
}
void gui_start_selection(struct gui_window *w)
{
}
/**
* Core asks front end for clipboard contents.
@ -1064,13 +1039,6 @@ static void gui_init2(int argc, char** argv)
toolbar_init();
}
void gui_file_gadget_open(struct gui_window *g, hlcache_handle *hl,
struct form_control *gadget)
{
LOG(("File open dialog rquest for %p/%p", g, gadget));
/* browser_window_set_gadget_filename(bw, gadget, "filename"); */
}
static struct gui_window_table atari_window_table = {
.create = gui_window_create,
.destroy = gui_window_destroy,

View File

@ -1073,14 +1073,6 @@ bool path_add_part(char *path, int length, const char *newpart)
return true;
}
void gui_file_gadget_open(struct gui_window *g, hlcache_handle *hl,
struct form_control *gadget)
{
LOG(("File open dialog rquest for %p/%p", g, gadget));
/* browser_window_set_gadget_filename(bw, gadget, "filename"); */
}
static struct gui_table beos_gui_table = {
.poll = gui_poll,
.quit = gui_quit,

View File

@ -1268,18 +1268,7 @@ static void gui_window_new_content(struct gui_window *g)
g->view->UnlockLooper();
}
void gui_drag_save_object(gui_save_type type, hlcache_handle *c,
struct gui_window *g)
{
}
void gui_drag_save_selection(struct gui_window *g, const char *selection)
{
}
void gui_start_selection(struct gui_window *g)
static void gui_start_selection(struct gui_window *g)
{
if (!g->view->LockLooper())
return;
@ -1289,10 +1278,6 @@ void gui_start_selection(struct gui_window *g)
g->view->UnlockLooper();
}
void gui_clear_selection(struct gui_window *g)
{
}
void gui_get_clipboard(char **buffer, size_t *length)
{
BMessage *clip;
@ -1376,6 +1361,7 @@ static struct gui_window_table gui_window_table = {
.set_pointer = gui_window_set_pointer,
.place_caret = gui_window_place_caret,
.remove_caret = gui_window_remove_caret,
.start_selection = gui_start_selection,
/* from scaffold */
.set_icon = gui_window_set_icon,

View File

@ -250,15 +250,6 @@ static void gui_window_new_content(struct gui_window *g)
[(BrowserViewController *)g contentUpdated];
}
void gui_drag_save_object(gui_save_type type, hlcache_handle *c,
struct gui_window *g)
{
}
void gui_drag_save_selection(struct gui_window *g, const char *selection)
{
}
void gui_create_form_select_menu(struct browser_window *bw,
struct form_control *control)
@ -289,12 +280,6 @@ void gui_401login_open(nsurl *url, const char *realm,
cb( false, cbpw );
}
void gui_file_gadget_open(struct gui_window *g, hlcache_handle *hl,
struct form_control *gadget)
{
LOG(("File open dialog rquest for %p/%p", g, gadget));
/* browser_window_set_gadget_filename(bw, gadget, "filename"); */
}
static struct gui_window_table cocoa_window_table = {
.create = gui_window_create,

View File

@ -25,15 +25,6 @@
static NSMutableString *cocoa_clipboard_string;
void gui_start_selection(struct gui_window *g)
{
}
void gui_clear_selection(struct gui_window *g)
{
}
/**
* Core asks front end for clipboard contents.
*

View File

@ -1484,20 +1484,23 @@ static nserror browser_window_callback(hlcache_handle *c,
switch(event->data.dragsave.type) {
case CONTENT_SAVE_ORIG:
gui_drag_save_object(GUI_SAVE_OBJECT_ORIG, save,
root->window);
guit->window->drag_save_object(root->window, save,
GUI_SAVE_OBJECT_ORIG);
break;
case CONTENT_SAVE_NATIVE:
gui_drag_save_object(GUI_SAVE_OBJECT_NATIVE, save,
root->window);
guit->window->drag_save_object(root->window, save,
GUI_SAVE_OBJECT_NATIVE);
break;
case CONTENT_SAVE_COMPLETE:
gui_drag_save_object(GUI_SAVE_COMPLETE, save,
root->window);
guit->window->drag_save_object(root->window, save,
GUI_SAVE_COMPLETE);
break;
case CONTENT_SAVE_SOURCE:
gui_drag_save_object(GUI_SAVE_SOURCE, save,
root->window);
guit->window->drag_save_object(root->window, save,
GUI_SAVE_SOURCE);
break;
}
}
@ -1563,7 +1566,7 @@ static nserror browser_window_callback(hlcache_handle *c,
case CONTENT_MSG_GADGETCLICK:
if (event->data.gadget_click.gadget->type == GADGET_FILE) {
gui_file_gadget_open(bw->window, c,
guit->window->file_gadget_open(bw->window, c,
event->data.gadget_click.gadget);
}
@ -2893,14 +2896,14 @@ void browser_window_mouse_click(struct browser_window *bw,
break;
default:
if (mouse & BROWSER_MOUSE_MOD_2) {
if (mouse & BROWSER_MOUSE_DRAG_2)
gui_drag_save_object(GUI_SAVE_OBJECT_NATIVE, c,
bw->window);
else if (mouse & BROWSER_MOUSE_DRAG_1)
gui_drag_save_object(GUI_SAVE_OBJECT_ORIG, c,
bw->window);
}
else if (mouse & (BROWSER_MOUSE_DRAG_1 |
if (mouse & BROWSER_MOUSE_DRAG_2) {
guit->window->drag_save_object(bw->window, c,
GUI_SAVE_OBJECT_NATIVE);
} else if (mouse & BROWSER_MOUSE_DRAG_1) {
guit->window->drag_save_object(bw->window, c,
GUI_SAVE_OBJECT_ORIG);
}
} else if (mouse & (BROWSER_MOUSE_DRAG_1 |
BROWSER_MOUSE_DRAG_2)) {
browser_window_page_drag_start(bw, x, y);
browser_window_set_pointer(bw, BROWSER_POINTER_MOVE);

View File

@ -157,8 +157,6 @@ struct gui_window_table {
/** set favicon */
void (*set_icon)(struct gui_window *g, hlcache_handle *icon);
/**
* Set the status bar of a browser window.
*
@ -190,8 +188,6 @@ struct gui_window_table {
*/
void (*remove_caret)(struct gui_window *g);
/** start the navigation throbber. */
void (*start_throbber)(struct gui_window *g);
@ -233,6 +229,19 @@ struct gui_window_table {
*/
void (*new_content)(struct gui_window *g);
/**
* Called when file chooser gadget is activated
*/
void (*file_gadget_open)(struct gui_window *g, hlcache_handle *hl, struct form_control *gadget);
/** object dragged to window*/
void (*drag_save_object)(struct gui_window *g, hlcache_handle *c, gui_save_type type);
/** drag selection save */
void (*drag_save_selection)(struct gui_window *g, const char *selection);
/** selection started */
void (*start_selection)(struct gui_window *g);
};
/** Graphical user interface function table
@ -280,52 +289,7 @@ void gui_download_window_error(struct gui_download_window *dw,
const char *error_msg);
void gui_download_window_done(struct gui_download_window *dw);
void gui_drag_save_object(gui_save_type type, hlcache_handle *c,
struct gui_window *g);
void gui_drag_save_selection(struct gui_window *g, const char *selection);
void gui_start_selection(struct gui_window *g);
void gui_clear_selection(struct gui_window *g);
void gui_file_gadget_open(struct gui_window *g, hlcache_handle *hl,
struct form_control *gadget);
void gui_launch_url(const char *url);
/**
* Core asks front end for clipboard contents.
*
* \param buffer UTF-8 text, allocated by front end, ownership yeilded to core
* \param length Byte length of UTF-8 text in buffer
*/
void gui_get_clipboard(char **buffer, size_t *length);
typedef struct nsnsclipboard_styles {
size_t start; /**< Start of run */
plot_font_style_t style; /**< Style to give text run */
} nsclipboard_styles;
/**
* Core tells front end to put given text in clipboard
*
* \param buffer UTF-8 text, owned by core
* \param length Byte length of UTF-8 text in buffer
* \param styles Array of styles given to text runs, owned by core, or NULL
* \param n_styles Number of text run styles in array
*/
void gui_set_clipboard(const char *buffer, size_t length,
nsclipboard_styles styles[], int n_styles);
void gui_create_form_select_menu(struct browser_window *bw,
struct form_control *control);
struct ssl_cert_info;
void gui_cert_verify(nsurl *url, const struct ssl_cert_info *certs,
unsigned long num, nserror (*cb)(bool proceed, void *pw),
void *cbpw);
/**
* Callback to translate resource to full url.
@ -340,4 +304,44 @@ void gui_cert_verify(nsurl *url, const struct ssl_cert_info *certs,
*/
nsurl* gui_get_resource_url(const char *path);
void gui_launch_url(const char *url);
void gui_create_form_select_menu(struct browser_window *bw,
struct form_control *control);
/**
* Core asks front end for clipboard contents.
*
* \param buffer UTF-8 text, allocated by front end, ownership yeilded to core
* \param length Byte length of UTF-8 text in buffer
*/
void gui_get_clipboard(char **buffer, size_t *length);
typedef struct nsnsclipboard_styles {
size_t start; /**< Start of run */
plot_font_style_t style; /**< Style to give text run */
} nsclipboard_styles;
/**
* Core tells front end to put given text in clipboard
*
* \param buffer UTF-8 text, owned by core
* \param length Byte length of UTF-8 text in buffer
* \param styles Array of styles given to text runs, owned by core, or NULL
* \param n_styles Number of text run styles in array
*/
void gui_set_clipboard(const char *buffer, size_t length,
nsclipboard_styles styles[], int n_styles);
struct ssl_cert_info;
void gui_cert_verify(nsurl *url, const struct ssl_cert_info *certs,
unsigned long num, nserror (*cb)(bool proceed, void *pw),
void *cbpw);
#endif

View File

@ -85,6 +85,28 @@ static void gui_default_window_remove_caret(struct gui_window *g)
{
}
static void gui_default_window_file_gadget_open(struct gui_window *g,
hlcache_handle *hl,
struct form_control *gadget)
{
}
static void gui_default_window_drag_save_object(struct gui_window *g,
hlcache_handle *c,
gui_save_type type)
{
}
static void gui_default_window_drag_save_selection(struct gui_window *g,
const char *selection)
{
}
static void gui_default_window_start_selection(struct gui_window *g)
{
}
/** verify window table is valid */
static nserror verify_window_register(struct gui_window_table *gwt)
{
@ -163,6 +185,18 @@ static nserror verify_window_register(struct gui_window_table *gwt)
if (gwt->scroll_start == NULL) {
gwt->scroll_start = gui_default_window_scroll_start;
}
if (gwt->file_gadget_open == NULL) {
gwt->file_gadget_open = gui_default_window_file_gadget_open;
}
if (gwt->drag_save_object == NULL) {
gwt->drag_save_object = gui_default_window_drag_save_object;
}
if (gwt->drag_save_selection == NULL) {
gwt->drag_save_selection = gui_default_window_drag_save_selection;
}
if (gwt->start_selection == NULL) {
gwt->start_selection = gui_default_window_start_selection;
}
return NSERROR_OK;
}

View File

@ -274,7 +274,7 @@ bool selection_click(struct selection *s, browser_mouse_state mouse,
(modkeys && (mouse & BROWSER_MOUSE_DRAG_2)))) {
/* drag-saving selection */
char *sel = selection_get_copy(s);
gui_drag_save_selection(top->window, sel);
guit->window->drag_save_selection(top->window, sel);
free(sel);
}
else if (!modkeys) {
@ -293,7 +293,7 @@ bool selection_click(struct selection *s, browser_mouse_state mouse,
s->drag_state = DRAG_END;
gui_start_selection(top->window);
guit->window->start_selection(top->window);
}
else if (mouse & BROWSER_MOUSE_DRAG_2) {
@ -312,7 +312,7 @@ bool selection_click(struct selection *s, browser_mouse_state mouse,
s->drag_state = DRAG_START;
}
gui_start_selection(top->window);
guit->window->start_selection(top->window);
}
else if (mouse & BROWSER_MOUSE_CLICK_2) {

View File

@ -1791,28 +1791,6 @@ gui_download_window_done(struct gui_download_window *dw)
{
}
void
gui_drag_save_object(gui_save_type type,
hlcache_handle *c,
struct gui_window *w)
{
}
void
gui_drag_save_selection(struct gui_window *g, const char *selection)
{
}
void
gui_start_selection(struct gui_window *g)
{
}
void
gui_clear_selection(struct gui_window *g)
{
}
void
gui_create_form_select_menu(struct browser_window *bw,
struct form_control *control)
@ -1834,13 +1812,6 @@ gui_cert_verify(nsurl *url,
cb(false, cbpw);
}
void gui_file_gadget_open(struct gui_window *g, hlcache_handle *hl,
struct form_control *gadget)
{
LOG(("File open dialog rquest for %p/%p", g, gadget));
/* browser_window_set_gadget_filename(bw, gadget, "filename"); */
}
static struct gui_window_table framebuffer_gui_window_table = {
.create = gui_window_create,
.destroy = gui_window_destroy,

View File

@ -30,17 +30,6 @@ static GString *current_selection = NULL;
static GtkClipboard *clipboard;
void gui_start_selection(struct gui_window *g)
{
gtk_widget_grab_focus(GTK_WIDGET(nsgtk_window_get_layout(g)));
}
void gui_clear_selection(struct gui_window *g)
{
}
/**
* Core asks front end for clipboard contents.
*

View File

@ -28,6 +28,7 @@
#include "content/hlcache.h"
#include "gtk/window.h"
#include "gtk/selection.h"
#include "desktop/browser_private.h"
#include "desktop/mouse.h"
#include "utils/nsoption.h"
@ -1110,18 +1111,6 @@ static void gui_window_place_caret(struct gui_window *g, int x, int y, int heigh
}
void gui_drag_save_object(gui_save_type type, hlcache_handle *c,
struct gui_window *g)
{
}
void gui_drag_save_selection(struct gui_window *g, const char *selection)
{
}
static void gui_window_get_dimensions(struct gui_window *g, int *width, int *height,
bool scaled)
{
@ -1141,13 +1130,18 @@ static void gui_window_get_dimensions(struct gui_window *g, int *width, int *hei
LOG(("height: %i", *height));
}
void gui_file_gadget_open(struct gui_window *g, hlcache_handle *hl,
struct form_control *gadget)
static void gui_window_start_selection(struct gui_window *g)
{
gtk_widget_grab_focus(GTK_WIDGET(g->layout));
}
static void
gui_window_file_gadget_open(struct gui_window *g,
hlcache_handle *hl,
struct form_control *gadget)
{
GtkWidget *dialog;
LOG(("Awooga."));
dialog = gtk_file_chooser_dialog_new("Select File",
nsgtk_scaffolding_window(g->scaffold),
GTK_FILE_CHOOSER_ACTION_OPEN,
@ -1188,6 +1182,8 @@ static struct gui_window_table gui_window_table = {
.set_pointer = gui_window_set_pointer,
.place_caret = gui_window_place_caret,
.remove_caret = gui_window_remove_caret,
.file_gadget_open = gui_window_file_gadget_open,
.start_selection = gui_window_start_selection,
/* from scaffold */
.set_title = gui_window_set_title,

View File

@ -276,13 +276,6 @@ gui_window_set_url(struct gui_window *g, const char *url)
fprintf(stdout, "WINDOW SET_URL WIN %u URL %s\n", g->win_num, url);
}
void
gui_drag_save_object(gui_save_type type, hlcache_handle *c,
struct gui_window *g)
{
/* Ignore? */
}
static bool
gui_window_get_scroll(struct gui_window *g, int *sx, int *sy)
{
@ -309,21 +302,6 @@ gui_window_scroll_visible(struct gui_window *g, int x0, int y0,
g->win_num, x0, y0, x1, y1);
}
void
gui_drag_save_selection(struct gui_window *g, const char *selection)
{
}
void
gui_start_selection(struct gui_window *g)
{
}
void
gui_clear_selection(struct gui_window *g)
{
}
/**
* Core asks front end for clipboard contents.
*
@ -386,12 +364,6 @@ gui_window_save_link(struct gui_window *g, const char *url,
g->win_num, url, title);
}
void gui_file_gadget_open(struct gui_window *g, hlcache_handle *hl,
struct form_control *gadget)
{
LOG(("File open dialog rquest for %p/%p", g, gadget));
/* browser_window_set_gadget_filename(bw, gadget, "filename"); */
}
/**** Handlers ****/

View File

@ -2432,10 +2432,3 @@ bool path_add_part(char *path, int length, const char *newpart)
return true;
}
void gui_file_gadget_open(struct gui_window *g, hlcache_handle *hl,
struct form_control *gadget)
{
LOG(("File open dialog rquest for %p/%p", g, gadget));
/* browser_window_set_gadget_filename(bw, gadget, "filename"); */
}

View File

@ -357,8 +357,8 @@ bool ro_gui_save_ok(wimp_w w)
* \param g gui window
*/
void gui_drag_save_object(gui_save_type save_type, hlcache_handle *c,
struct gui_window *g)
void gui_drag_save_object(struct gui_window *g, hlcache_handle *c,
gui_save_type save_type)
{
wimp_pointer pointer;
char icon_buf[20];

View File

@ -27,6 +27,9 @@
#include "oslib/wimp.h"
#include "desktop/gui.h"
void gui_drag_save_object(struct gui_window *g, hlcache_handle *c, gui_save_type save_type);
void gui_drag_save_selection(struct gui_window *g, const char *selection);
wimp_w ro_gui_saveas_create(const char *template_name);
void ro_gui_saveas_quit(void);
void ro_gui_save_prepare(gui_save_type save_type, struct hlcache_handle *h,

View File

@ -186,20 +186,6 @@ static void ro_gui_selection_drag_end(wimp_dragged *drag, void *data)
browser_window_mouse_track(g->bw, 0, pos.x, pos.y);
}
/**
* Perform tasks after a selection has been cleared.
*
* \param g gui window
*/
void gui_clear_selection(struct gui_window *g)
{
/* Refresh any open menu, in case it's the browser window menu. */
ro_gui_menu_refresh(0);
}
/**
* Core tells front end to put given text in clipboard
*

View File

@ -26,6 +26,8 @@
#include "oslib/wimp.h"
#include "desktop/gui.h"
void gui_start_selection(struct gui_window *g);
typedef void (*ro_gui_selection_prepare_paste_cb)(void *pw);
void ro_gui_selection_prepare_paste(wimp_w w,

View File

@ -5265,6 +5265,13 @@ static struct gui_window_table gui_window_table = {
.new_content = gui_window_new_content,
.start_throbber = gui_window_start_throbber,
.stop_throbber = gui_window_stop_throbber,
/* from save */
.drag_save_object = gui_drag_save_object,
.drag_save_selection =gui_drag_save_selection,
/* from textselection */
.start_selection = gui_start_selection,
};
struct gui_window_table *riscos_gui_window_table = &gui_window_table;

View File

@ -76,12 +76,6 @@ static struct nsws_pointers nsws_pointer;
void gui_window_set_scroll(struct gui_window *w, int sx, int sy);
static bool gui_window_get_scroll(struct gui_window *w, int *sx, int *sy);
void gui_file_gadget_open(struct gui_window *g, hlcache_handle *hl,
struct form_control *gadget)
{
LOG(("File open dialog rquest for %p/%p", g, gadget));
/* browser_window_set_gadget_filename(bw, gadget, "filename"); */
}
static void gui_poll(bool active)
{
@ -1729,24 +1723,6 @@ static void gui_window_remove_caret(struct gui_window *w)
HideCaret(w->drawingarea);
}
void gui_drag_save_object(gui_save_type type, hlcache_handle *c,
struct gui_window *w)
{
}
void gui_drag_save_selection(struct gui_window *g, const char *selection)
{
}
void gui_start_selection(struct gui_window *w)
{
}
void gui_clear_selection(struct gui_window *w)
{
}
/**
* Core asks front end for clipboard contents.
*