2005-04-23 06:56:14 +04:00
|
|
|
/*
|
|
|
|
* Copyright 2005 Adrian Lees <adrianl@users.sourceforge.net>
|
2007-08-08 20:16:03 +04:00
|
|
|
*
|
|
|
|
* 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/>.
|
2005-04-23 06:56:14 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
2006-02-07 19:16:23 +03:00
|
|
|
#include <string.h>
|
2008-07-27 02:29:15 +04:00
|
|
|
#include <stdbool.h>
|
2010-04-25 01:25:08 +04:00
|
|
|
|
2007-05-31 02:39:54 +04:00
|
|
|
#include "utils/log.h"
|
|
|
|
#include "utils/messages.h"
|
|
|
|
#include "utils/utf8.h"
|
|
|
|
#include "utils/utils.h"
|
2014-06-05 18:14:49 +04:00
|
|
|
|
2014-06-06 02:01:37 +04:00
|
|
|
#include "riscos/gui.h"
|
2014-06-05 18:14:49 +04:00
|
|
|
#include "riscos/query.h"
|
|
|
|
#include "riscos/wimp.h"
|
|
|
|
#include "riscos/wimp_event.h"
|
2014-02-02 02:17:36 +04:00
|
|
|
#include "riscos/ucstables.h"
|
2014-06-06 02:01:37 +04:00
|
|
|
#include "riscos/dialog.h"
|
2005-04-23 06:56:14 +04:00
|
|
|
|
2006-09-06 18:44:42 +04:00
|
|
|
#define ICON_QUERY_MESSAGE 0
|
|
|
|
#define ICON_QUERY_YES 1
|
|
|
|
#define ICON_QUERY_NO 2
|
|
|
|
#define ICON_QUERY_HELP 3
|
2005-04-23 06:56:14 +04:00
|
|
|
|
|
|
|
/** Data for a query window */
|
|
|
|
struct gui_query_window
|
|
|
|
{
|
|
|
|
struct gui_query_window *prev; /** Previous query in list */
|
|
|
|
struct gui_query_window *next; /** Next query in list */
|
|
|
|
|
|
|
|
query_id id; /** unique ID number for this query */
|
|
|
|
wimp_w window; /** RISC OS window handle */
|
|
|
|
|
|
|
|
const query_callback *cb; /** Table of callback functions */
|
|
|
|
void *pw; /** Handle passed to callback functions */
|
|
|
|
|
|
|
|
bool default_confirm; /** Default action is to confirm */
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/** Next unallocated query id */
|
|
|
|
static query_id next_id = (query_id)1;
|
|
|
|
|
|
|
|
/** List of all query windows. */
|
|
|
|
static struct gui_query_window *gui_query_window_list = 0;
|
|
|
|
|
|
|
|
/** Template for a query window. */
|
|
|
|
static struct wimp_window *query_template;
|
|
|
|
|
2006-02-07 19:16:23 +03:00
|
|
|
/** Widths of Yes and No buttons */
|
|
|
|
static int query_yes_width = 0;
|
|
|
|
static int query_no_width = 0;
|
|
|
|
|
2005-04-23 06:56:14 +04:00
|
|
|
static struct gui_query_window *ro_gui_query_window_lookup_id(query_id id);
|
|
|
|
|
2006-09-06 18:44:42 +04:00
|
|
|
static bool ro_gui_query_click(wimp_pointer *pointer);
|
|
|
|
static void ro_gui_query_close(wimp_w w);
|
|
|
|
static bool ro_gui_query_apply(wimp_w w);
|
|
|
|
|
2005-04-23 06:56:14 +04:00
|
|
|
|
|
|
|
void ro_gui_query_init(void)
|
|
|
|
{
|
|
|
|
query_template = ro_gui_dialog_load_template("query");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Lookup a query window using its ID number
|
|
|
|
*
|
|
|
|
* \param id id to search for
|
|
|
|
* \return pointer to query window or NULL
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct gui_query_window *ro_gui_query_window_lookup_id(query_id id)
|
|
|
|
{
|
|
|
|
struct gui_query_window *qw = gui_query_window_list;
|
|
|
|
while (qw && qw->id != id)
|
|
|
|
qw = qw->next;
|
|
|
|
return qw;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2009-01-10 03:18:34 +03:00
|
|
|
* Display a query to the user, requesting a response, near the current
|
|
|
|
* pointer position to keep the required mouse travel small, but also
|
|
|
|
* protecting against spurious mouse clicks.
|
2005-04-23 06:56:14 +04:00
|
|
|
*
|
|
|
|
* \param query message token of query
|
|
|
|
* \param detail parameter used in expanding tokenised message
|
|
|
|
* \param cb table of callback functions to be called when user responds
|
|
|
|
* \param pw handle to be passed to callback functions
|
2006-02-07 19:16:23 +03:00
|
|
|
* \param yes text to use for 'Yes' button' (or NULL for default)
|
|
|
|
* \param no text to use for 'No' button (or NULL for default)
|
2005-04-23 06:56:14 +04:00
|
|
|
* \return id number of the query (or QUERY_INVALID if it failed)
|
|
|
|
*/
|
|
|
|
|
2006-02-07 19:16:23 +03:00
|
|
|
query_id query_user(const char *query, const char *detail,
|
|
|
|
const query_callback *cb, void *pw,
|
|
|
|
const char *yes, const char *no)
|
2009-01-10 03:18:34 +03:00
|
|
|
{
|
|
|
|
wimp_pointer pointer;
|
|
|
|
if (xwimp_get_pointer_info(&pointer))
|
|
|
|
pointer.pos.y = pointer.pos.x = -1;
|
|
|
|
|
|
|
|
return query_user_xy(query, detail, cb, pw, yes, no,
|
|
|
|
pointer.pos.x, pointer.pos.y);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Display a query to the user, requesting a response, at a specified
|
|
|
|
* screen position (x,y). The window is positioned relative to the given
|
|
|
|
* location such that the required mouse travel is small, but non-zero
|
|
|
|
* for protection spurious double-clicks.
|
|
|
|
*
|
|
|
|
* \param query message token of query
|
|
|
|
* \param detail parameter used in expanding tokenised message
|
|
|
|
* \param cb table of callback functions to be called when user responds
|
|
|
|
* \param pw handle to be passed to callback functions
|
|
|
|
* \param yes text to use for 'Yes' button' (or NULL for default)
|
|
|
|
* \param no text to use for 'No' button (or NULL for default)
|
|
|
|
* \param x x position in screen coordinates (-1 = centred on screen)
|
|
|
|
* \param y y position in screen coordinates (-1 = centred on screen)
|
|
|
|
* \return id number of the query (or QUERY_INVALID if it failed)
|
|
|
|
*/
|
|
|
|
|
|
|
|
query_id query_user_xy(const char *query, const char *detail,
|
|
|
|
const query_callback *cb, void *pw,
|
|
|
|
const char *yes, const char *no,
|
|
|
|
int x, int y)
|
2005-04-23 06:56:14 +04:00
|
|
|
{
|
|
|
|
struct gui_query_window *qw;
|
|
|
|
char query_buffer[300];
|
|
|
|
os_error *error;
|
2006-02-07 19:16:23 +03:00
|
|
|
wimp_icon *icn;
|
|
|
|
int width;
|
|
|
|
int len;
|
2009-01-10 03:18:34 +03:00
|
|
|
int tx;
|
2006-11-04 15:38:24 +03:00
|
|
|
char *local_text = NULL;
|
2014-01-29 01:40:13 +04:00
|
|
|
nserror err;
|
2005-04-23 06:56:14 +04:00
|
|
|
|
|
|
|
qw = malloc(sizeof(struct gui_query_window));
|
|
|
|
if (!qw) {
|
2016-04-26 17:16:33 +03:00
|
|
|
ro_warn_user("NoMemory", NULL);
|
2005-04-23 06:56:14 +04:00
|
|
|
return QUERY_INVALID;
|
|
|
|
}
|
|
|
|
|
|
|
|
qw->cb = cb;
|
|
|
|
qw->pw = pw;
|
|
|
|
qw->id = next_id++;
|
|
|
|
qw->default_confirm = false;
|
|
|
|
|
|
|
|
if (next_id == QUERY_INVALID)
|
|
|
|
next_id++;
|
|
|
|
|
2006-02-07 19:16:23 +03:00
|
|
|
if (!yes) yes = messages_get("Yes");
|
|
|
|
if (!no) no = messages_get("No");
|
|
|
|
|
2006-09-06 18:44:42 +04:00
|
|
|
/* set the text of the 'Yes' button and size accordingly */
|
2006-11-04 15:38:24 +03:00
|
|
|
err = utf8_to_local_encoding(yes, 0, &local_text);
|
2014-01-29 01:40:13 +04:00
|
|
|
if (err != NSERROR_OK) {
|
|
|
|
assert(err != NSERROR_BAD_ENCODING);
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "utf8_to_local_encoding_failed");
|
2006-11-04 15:38:24 +03:00
|
|
|
local_text = NULL;
|
|
|
|
}
|
|
|
|
|
2006-09-06 18:44:42 +04:00
|
|
|
icn = &query_template->icons[ICON_QUERY_YES];
|
2010-04-25 01:25:08 +04:00
|
|
|
len = strlen(local_text ? local_text : yes);
|
|
|
|
len = max(len, icn->data.indirected_text.size - 1);
|
2006-11-04 15:38:24 +03:00
|
|
|
memcpy(icn->data.indirected_text.text,
|
|
|
|
local_text ? local_text: yes, len);
|
2006-02-07 19:16:23 +03:00
|
|
|
icn->data.indirected_text.text[len] = '\0';
|
|
|
|
|
2006-11-04 15:38:24 +03:00
|
|
|
free(local_text);
|
|
|
|
local_text = NULL;
|
|
|
|
|
2006-02-07 19:16:23 +03:00
|
|
|
error = xwimptextop_string_width(icn->data.indirected_text.text, len, &width);
|
|
|
|
if (error) {
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "xwimptextop_string_width: 0x%x:%s",
|
|
|
|
error->errnum, error->errmess);
|
2006-02-07 19:16:23 +03:00
|
|
|
width = len * 16;
|
|
|
|
}
|
2006-09-06 18:44:42 +04:00
|
|
|
if (!query_yes_width) query_yes_width = icn->extent.x1 - icn->extent.x0;
|
2006-09-08 17:31:43 +04:00
|
|
|
width += 44;
|
2006-09-06 18:44:42 +04:00
|
|
|
if (width < query_yes_width)
|
|
|
|
width = query_yes_width;
|
2009-01-10 03:18:34 +03:00
|
|
|
icn->extent.x0 = tx = icn->extent.x1 - width;
|
2006-02-07 19:16:23 +03:00
|
|
|
|
2006-09-06 18:44:42 +04:00
|
|
|
/* set the text of the 'No' button and size accordingly */
|
2006-11-04 15:38:24 +03:00
|
|
|
err = utf8_to_local_encoding(no, 0, &local_text);
|
2014-01-29 01:40:13 +04:00
|
|
|
if (err != NSERROR_OK) {
|
|
|
|
assert(err != NSERROR_BAD_ENCODING);
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "utf8_to_local_encoding_failed");
|
2006-11-04 15:38:24 +03:00
|
|
|
local_text = NULL;
|
|
|
|
}
|
|
|
|
|
2006-09-06 18:44:42 +04:00
|
|
|
icn = &query_template->icons[ICON_QUERY_NO];
|
2010-04-25 01:25:08 +04:00
|
|
|
len = strlen(local_text ? local_text : no);
|
|
|
|
len = max(len, icn->data.indirected_text.size - 1);
|
2006-11-04 15:38:24 +03:00
|
|
|
memcpy(icn->data.indirected_text.text,
|
|
|
|
local_text ? local_text : no, len);
|
2006-02-07 19:16:23 +03:00
|
|
|
icn->data.indirected_text.text[len] = '\0';
|
|
|
|
|
2006-11-04 15:38:24 +03:00
|
|
|
free(local_text);
|
|
|
|
local_text = NULL;
|
|
|
|
|
2006-09-06 18:44:42 +04:00
|
|
|
if (!query_no_width) query_no_width = icn->extent.x1 - icn->extent.x0;
|
2009-01-10 03:18:34 +03:00
|
|
|
icn->extent.x1 = tx - 16;
|
2006-02-07 19:16:23 +03:00
|
|
|
error = xwimptextop_string_width(icn->data.indirected_text.text, len, &width);
|
|
|
|
if (error) {
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "xwimptextop_string_width: 0x%x:%s",
|
|
|
|
error->errnum, error->errmess);
|
2006-02-07 19:16:23 +03:00
|
|
|
width = len * 16;
|
|
|
|
}
|
2006-09-08 17:31:43 +04:00
|
|
|
width += 28;
|
2006-09-06 18:44:42 +04:00
|
|
|
if (width < query_no_width)
|
|
|
|
width = query_no_width;
|
2006-02-07 19:16:23 +03:00
|
|
|
icn->extent.x0 = icn->extent.x1 - width;
|
|
|
|
|
2005-04-23 06:56:14 +04:00
|
|
|
error = xwimp_create_window(query_template, &qw->window);
|
|
|
|
if (error) {
|
2016-04-26 17:16:33 +03:00
|
|
|
ro_warn_user("WimpError", error->errmess);
|
2006-02-07 19:16:23 +03:00
|
|
|
free(qw);
|
|
|
|
return QUERY_INVALID;
|
2005-04-23 06:56:14 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
snprintf(query_buffer, sizeof query_buffer, "%s %s",
|
|
|
|
messages_get(query), detail ? detail : "");
|
|
|
|
query_buffer[sizeof query_buffer - 1] = 0;
|
|
|
|
|
2008-08-05 05:23:04 +04:00
|
|
|
ro_gui_set_icon_string(qw->window, ICON_QUERY_MESSAGE,
|
|
|
|
query_buffer, true);
|
2005-04-23 06:56:14 +04:00
|
|
|
|
2005-04-30 18:38:43 +04:00
|
|
|
xwimp_set_icon_state(qw->window, ICON_QUERY_HELP,
|
|
|
|
wimp_ICON_DELETED, wimp_ICON_DELETED);
|
|
|
|
|
2009-01-10 03:18:34 +03:00
|
|
|
if (x >= 0 && y >= 0) {
|
|
|
|
x -= tx - 8;
|
|
|
|
y += (query_template->visible.y1 - query_template->visible.y0) / 2;
|
|
|
|
ro_gui_dialog_open_xy(qw->window, x, y);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ro_gui_dialog_open(qw->window);
|
2005-04-23 06:56:14 +04:00
|
|
|
|
2006-09-06 18:44:42 +04:00
|
|
|
ro_gui_wimp_event_set_user_data(qw->window, qw);
|
|
|
|
ro_gui_wimp_event_register_mouse_click(qw->window, ro_gui_query_click);
|
|
|
|
ro_gui_wimp_event_register_cancel(qw->window, ICON_QUERY_NO);
|
|
|
|
ro_gui_wimp_event_register_ok(qw->window, ICON_QUERY_YES, ro_gui_query_apply);
|
|
|
|
ro_gui_wimp_event_register_close_window(qw->window, ro_gui_query_close);
|
|
|
|
|
2005-04-23 06:56:14 +04:00
|
|
|
error = xwimp_set_caret_position(qw->window, (wimp_i)-1, 0, 0, 1 << 25, -1);
|
|
|
|
if (error) {
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "xwimp_get_caret_position: 0x%x : %s",
|
|
|
|
error->errnum, error->errmess);
|
2016-04-26 17:16:33 +03:00
|
|
|
ro_warn_user("WimpError", error->errmess);
|
2005-04-23 06:56:14 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* put this query window at the head of our list */
|
|
|
|
if (gui_query_window_list)
|
|
|
|
gui_query_window_list->prev = qw;
|
|
|
|
|
|
|
|
qw->prev = NULL;
|
|
|
|
qw->next = gui_query_window_list;
|
|
|
|
gui_query_window_list = qw;
|
|
|
|
|
|
|
|
return qw->id;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Close a query window without waiting for a response from the user.
|
|
|
|
* (should normally only be called if the user has responded in some other
|
|
|
|
* way of which the query window in unaware.)
|
|
|
|
*
|
|
|
|
* \param id id of query window to close
|
|
|
|
*/
|
|
|
|
|
|
|
|
void query_close(query_id id)
|
|
|
|
{
|
|
|
|
struct gui_query_window *qw = ro_gui_query_window_lookup_id(id);
|
2006-09-06 18:44:42 +04:00
|
|
|
if (!qw)
|
|
|
|
return;
|
|
|
|
ro_gui_query_close(qw->window);
|
|
|
|
|
2005-04-23 06:56:14 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ro_gui_query_window_bring_to_front(query_id id)
|
|
|
|
{
|
|
|
|
struct gui_query_window *qw = ro_gui_query_window_lookup_id(id);
|
|
|
|
if (qw) {
|
|
|
|
os_error *error;
|
|
|
|
|
2005-12-31 07:40:49 +03:00
|
|
|
ro_gui_dialog_open(qw->window);
|
2005-04-23 06:56:14 +04:00
|
|
|
|
|
|
|
error = xwimp_set_caret_position(qw->window, (wimp_i)-1, 0, 0, 1 << 25, -1);
|
|
|
|
if (error) {
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO,
|
|
|
|
"xwimp_get_caret_position: 0x%x : %s",
|
|
|
|
error->errnum,
|
|
|
|
error->errmess);
|
2016-04-26 17:16:33 +03:00
|
|
|
ro_warn_user("WimpError", error->errmess);
|
2005-04-23 06:56:14 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2006-09-06 18:44:42 +04:00
|
|
|
* Handle closing of query dialog
|
2005-04-23 06:56:14 +04:00
|
|
|
*/
|
2006-09-06 18:44:42 +04:00
|
|
|
void ro_gui_query_close(wimp_w w)
|
2005-04-23 06:56:14 +04:00
|
|
|
{
|
2006-09-06 18:44:42 +04:00
|
|
|
struct gui_query_window *qw;
|
|
|
|
os_error *error;
|
2005-04-23 06:56:14 +04:00
|
|
|
|
2006-09-06 18:44:42 +04:00
|
|
|
qw = (struct gui_query_window *)ro_gui_wimp_event_get_user_data(w);
|
2005-04-23 06:56:14 +04:00
|
|
|
|
2006-09-06 18:44:42 +04:00
|
|
|
ro_gui_dialog_close(w);
|
|
|
|
error = xwimp_delete_window(qw->window);
|
|
|
|
if (error) {
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "xwimp_delete_window: 0x%x:%s",
|
|
|
|
error->errnum, error->errmess);
|
2016-04-26 17:16:33 +03:00
|
|
|
ro_warn_user("WimpError", error->errmess);
|
2005-04-23 06:56:14 +04:00
|
|
|
}
|
2006-09-06 18:44:42 +04:00
|
|
|
ro_gui_wimp_event_finalise(w);
|
|
|
|
|
|
|
|
/* remove from linked-list of query windows and release memory */
|
|
|
|
if (qw->prev)
|
|
|
|
qw->prev->next = qw->next;
|
|
|
|
else
|
|
|
|
gui_query_window_list = qw->next;
|
|
|
|
|
|
|
|
if (qw->next)
|
|
|
|
qw->next->prev = qw->prev;
|
|
|
|
free(qw);
|
2005-04-23 06:56:14 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2006-09-06 18:44:42 +04:00
|
|
|
* Handle acceptance of query dialog
|
2005-04-23 06:56:14 +04:00
|
|
|
*/
|
2006-09-06 18:44:42 +04:00
|
|
|
bool ro_gui_query_apply(wimp_w w)
|
|
|
|
{
|
|
|
|
struct gui_query_window *qw;
|
|
|
|
const query_callback *cb;
|
2006-09-08 20:05:36 +04:00
|
|
|
|
2006-09-06 18:44:42 +04:00
|
|
|
qw = (struct gui_query_window *)ro_gui_wimp_event_get_user_data(w);
|
|
|
|
cb = qw->cb;
|
|
|
|
cb->confirm(qw->id, QUERY_YES, qw->pw);
|
|
|
|
return true;
|
|
|
|
}
|
2005-04-23 06:56:14 +04:00
|
|
|
|
2006-09-06 18:44:42 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle clicks in query dialog
|
|
|
|
*/
|
|
|
|
bool ro_gui_query_click(wimp_pointer *pointer)
|
2005-04-23 06:56:14 +04:00
|
|
|
{
|
2006-09-06 18:44:42 +04:00
|
|
|
struct gui_query_window *qw;
|
|
|
|
const query_callback *cb;
|
2006-09-08 20:05:36 +04:00
|
|
|
|
2006-09-06 18:44:42 +04:00
|
|
|
qw = (struct gui_query_window *)ro_gui_wimp_event_get_user_data(pointer->w);
|
|
|
|
cb = qw->cb;
|
2005-04-23 06:56:14 +04:00
|
|
|
|
2006-09-06 18:44:42 +04:00
|
|
|
switch (pointer->i) {
|
|
|
|
case ICON_QUERY_NO:
|
|
|
|
cb->cancel(qw->id, QUERY_NO, qw->pw);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return false;
|
2005-04-23 06:56:14 +04:00
|
|
|
}
|