[project @ 2004-07-08 17:28:56 by rjw]

Save window cancel button implementation. Persistant child window handling.

svn path=/import/netsurf/; revision=1056
This commit is contained in:
Richard Wilson 2004-07-08 17:28:56 +00:00
parent 70bc073f10
commit 6cc16835e0
10 changed files with 123 additions and 21 deletions

View File

@ -132,6 +132,7 @@ MiscError:An unexpected error occurred:
FileError:File does not exist:
HotlistSaveError:The hotlist was unable to be correctly saved.
HotlistLoadError:The hotlist was unable to be correctly loaded.
NoPathError:To save, drag the icon to a directory display
# Some general purpose words and phrases
Bytes: B

Binary file not shown.

View File

@ -132,6 +132,7 @@ MiscError:Une erreur inattendue s'est produite:
FileError:Le fichier n'existe pas:
HotlistSaveError:The hotlist was unable to be correctly saved.
HotlistLoadError:The hotlist was unable to be correctly loaded.
NoPathError:To save, drag the icon to a directory display
# Some general purpose words and phrases
Bytes: O

Binary file not shown.

View File

@ -26,6 +26,10 @@
#include "netsurf/utils/messages.h"
#include "netsurf/utils/utils.h"
/* The maximum number of persistant dialogues
*/
#define MAX_PERSISTANT 8
wimp_w dialog_info, dialog_saveas, dialog_config, dialog_config_br,
dialog_config_prox, dialog_config_th, download_template,
#ifdef WITH_AUTH
@ -40,6 +44,9 @@ static char *theme_choice = 0;
static struct theme_entry *theme_list = 0;
static unsigned int theme_list_entries = 0;
/* A simple mapping of parent and child
*/
static wimp_w persistant_dialog[MAX_PERSISTANT][1];
static void ro_gui_dialog_click_config(wimp_pointer *pointer);
static void ro_gui_dialog_click_config_br(wimp_pointer *pointer);
@ -183,7 +190,6 @@ wimp_window * ro_gui_dialog_load_template(const char *template_name)
/**
* Open a dialog box, centered on the screen.
*/
void ro_gui_dialog_open(wimp_w w)
{
int screen_x, screen_y, dx, dy;
@ -207,6 +213,79 @@ void ro_gui_dialog_open(wimp_w w)
wimp_open_window((wimp_open *) &open);
}
/**
* Open a persistant dialog box relative to the pointer.
*
* \param parent the owning window (NULL for no owner)
* \param w the dialog window
*/
void ro_gui_dialog_open_persistant(wimp_w parent, wimp_w w) {
int dx, dy, i;
wimp_pointer pointer;
wimp_window_state open;
os_error *error;
/* Get the pointer position
*/
error = xwimp_get_pointer_info(&pointer);
if (error) {
LOG(("xwimp_get_pointer_info: 0x%x: %s\n",
error->errnum, error->errmess));
warn_user("WimpError", error->errmess);
return;
}
/* Move and open
*/
open.w = w;
wimp_get_window_state(&open);
dx = (open.visible.x1 - open.visible.x0);
dy = (open.visible.y1 - open.visible.y0);
open.visible.x0 = pointer.pos.x - 64;
open.visible.x1 = pointer.pos.x - 64 + dx;
open.visible.y0 = pointer.pos.y - dy;
open.visible.y1 = pointer.pos.y;
open.next = wimp_TOP;
wimp_open_window((wimp_open *) &open);
/* Add a mapping
*/
if (parent == NULL) return;
for (i = 0; i < MAX_PERSISTANT; i++) {
if ((persistant_dialog[i][0] == NULL) || (persistant_dialog[i][0] == w)) {
persistant_dialog[i][0] = w;
persistant_dialog[i][1] = parent;
return;
}
}
/* Log that we failed to create a mapping
*/
LOG(("Unable to map persistant dialog to parent."));
}
/**
* Open a persistant dialog box relative to the pointer.
*
* \param parent the window to close children of
*/
void ro_gui_dialog_close_persistant(wimp_w parent) {
int i;
/* Check our mappings
*/
if (parent == NULL) return;
for (i = 0; i < MAX_PERSISTANT; i++) {
if (persistant_dialog[i][1] == parent) {
xwimp_close_window(persistant_dialog[i][0]);
persistant_dialog[i][0] = NULL;
}
}
}
/**
* Handle key presses in one of the dialog boxes.
*/

View File

@ -667,6 +667,10 @@ void ro_gui_close_window_request(wimp_close *close)
gui_window *g;
struct gui_download_window *dw;
/* Check for children
*/
ro_gui_dialog_close_persistant(close->w);
if (close->w == dialog_debug)
ro_gui_debugwin_close();
else if ((g = ro_gui_window_lookup(close->w)))

View File

@ -111,12 +111,15 @@ void ro_gui_menu_warning(wimp_message_menu_warning *warning);
void ro_gui_prepare_navigate(gui_window *gui);
void ro_gui_menu_prepare_save(struct content *c);
void ro_gui_menu_prepare_scale(void);
void ro_gui_menu_prepare_pageinfo(void);
/* in dialog.c */
void ro_gui_dialog_init(void);
wimp_w ro_gui_dialog_create(const char *template_name);
wimp_window * ro_gui_dialog_load_template(const char *template_name);
void ro_gui_dialog_open(wimp_w w);
void ro_gui_dialog_open_persistant(wimp_w parent, wimp_w w);
void ro_gui_dialog_close_persistant(wimp_w parent);
void ro_gui_dialog_click(wimp_pointer *pointer);
void ro_gui_save_options(void);
bool ro_gui_dialog_keypress(wimp_key *key);

View File

@ -45,7 +45,6 @@ static void ro_gui_menu_prepare_images(void);
static void ro_gui_menu_prepare_window(void);
static void ro_gui_menu_prepare_toolbars(void);
static void ro_gui_menu_prepare_help(int forced);
static void ro_gui_menu_pageinfo(wimp_message_menu_warning *warning);
static void ro_gui_menu_objectinfo(wimp_message_menu_warning *warning);
static struct box *ro_gui_menu_find_object_box(void);
static void ro_gui_menu_object_reload(void);
@ -867,7 +866,13 @@ void ro_gui_menu_warning(wimp_message_menu_warning *warning)
case 0: /* Page info */
ro_gui_menu_pageinfo(warning);
ro_gui_menu_prepare_pageinfo();
error = xwimp_create_sub_menu((wimp_menu *) dialog_pageinfo,
warning->pos.x, warning->pos.y);
if (error) {
LOG(("0x%x: %s\n", error->errnum, error->errmess));
warn_user("MenuError", error->errmess);
}
return;
case 1:
@ -1336,10 +1341,9 @@ void ro_gui_menu_prepare_help(int forced) {
}
}
void ro_gui_menu_pageinfo(wimp_message_menu_warning *warning)
void ro_gui_menu_prepare_pageinfo(void)
{
struct content *c = current_gui->data.browser.bw->current_content;
os_error *error;
char icon_buf[20] = "file_xxx";
const char *icon = icon_buf;
const char *title = "-";
@ -1353,6 +1357,12 @@ void ro_gui_menu_pageinfo(wimp_message_menu_warning *warning)
sprintf(icon_buf, "file_%x", ro_content_filetype(c));
/* Ensure the correct icon exists
*/
if (xwimpspriteop_read_sprite_info(icon_buf, 0, 0, 0, 0)) {
sprintf(icon_buf, "file_xxx");
}
if (c->type == CONTENT_HTML && c->data.html.encoding != NULL) {
enc = c->data.html.encoding;
}
@ -1362,13 +1372,6 @@ void ro_gui_menu_pageinfo(wimp_message_menu_warning *warning)
ro_gui_set_icon_string(dialog_pageinfo, ICON_PAGEINFO_URL, url);
ro_gui_set_icon_string(dialog_pageinfo, ICON_PAGEINFO_ENC, enc);
ro_gui_set_icon_string(dialog_pageinfo, ICON_PAGEINFO_TYPE, mime);
error = xwimp_create_sub_menu((wimp_menu *) dialog_pageinfo,
warning->pos.x, warning->pos.y);
if (error) {
LOG(("0x%x: %s\n", error->errnum, error->errmess));
warn_user("MenuError", error->errmess);
}
}
void ro_gui_menu_objectinfo(wimp_message_menu_warning *warning)

View File

@ -47,6 +47,17 @@ static bool ro_gui_save_link(struct content *c, link_format format, char *path);
void ro_gui_save_click(wimp_pointer *pointer)
{
switch (pointer->i) {
case ICON_SAVE_OK:
/* Todo: Try save, and report error NoPathError if needed */
break;
case ICON_SAVE_CANCEL:
if (pointer->buttons == wimp_CLICK_SELECT) {
xwimp_close_window(pointer->w);
xwimp_create_menu((wimp_menu *)-1, 0, 0);
} else if (pointer->buttons == wimp_CLICK_ADJUST) {
ro_gui_menu_prepare_save(save_content);
}
break;
case ICON_SAVE_ICON:
if (pointer->buttons == wimp_DRAG_SELECT) {
gui_current_drag_type = GUI_DRAG_SAVE;

View File

@ -949,6 +949,11 @@ bool ro_gui_window_keypress(gui_window *g, int key, bool toolbar)
}
switch (key) {
case wimp_KEY_CONTROL + wimp_KEY_F1:
current_gui = g;
ro_gui_menu_prepare_pageinfo();
ro_gui_dialog_open_persistant(g->window, dialog_pageinfo);
return true;
case wimp_KEY_F1: /* Help. */
ro_gui_open_help_page("docs");
return true;
@ -996,33 +1001,28 @@ bool ro_gui_window_keypress(gui_window *g, int key, bool toolbar)
current_gui = g;
gui_current_save_type = GUI_SAVE_SOURCE;
ro_gui_menu_prepare_save(content);
/** \todo make save window persistent */
xwimp_create_menu((wimp_menu *) dialog_saveas,
pointer.pos.x, pointer.pos.y);
ro_gui_dialog_open_persistant(g->window, dialog_saveas);
return true;
case wimp_KEY_CONTROL + wimp_KEY_F3:
current_gui = g;
gui_current_save_type = GUI_SAVE_TEXT;
ro_gui_menu_prepare_save(content);
xwimp_create_menu((wimp_menu *) dialog_saveas,
pointer.pos.x, pointer.pos.y);
ro_gui_dialog_open_persistant(g->window, dialog_saveas);
return true;
case wimp_KEY_SHIFT + wimp_KEY_F3:
current_gui = g;
gui_current_save_type = GUI_SAVE_COMPLETE;
ro_gui_menu_prepare_save(content);
xwimp_create_menu((wimp_menu *) dialog_saveas,
pointer.pos.x, pointer.pos.y);
ro_gui_dialog_open_persistant(g->window, dialog_saveas);
return true;
case wimp_KEY_CONTROL + wimp_KEY_SHIFT + wimp_KEY_F3:
current_gui = g;
gui_current_save_type = GUI_SAVE_DRAW;
ro_gui_menu_prepare_save(content);
xwimp_create_menu((wimp_menu *) dialog_saveas,
pointer.pos.x, pointer.pos.y);
ro_gui_dialog_open_persistant(g->window, dialog_saveas);
return true;
case wimp_KEY_RETURN: