mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
* gnc-html: convert URLType from enum to char*
* gw-gnome-utils-spec: wrap URLType type, #defines, and gnc_build_url() * get the rest of the C code to use URLTypes properly git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@7052 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
6cd1c16df0
commit
edc1a34ecc
@ -1,3 +1,9 @@
|
||||
2002-07-01 Derek Atkins <derek@ihtfp.com>
|
||||
|
||||
* gnc-html: convert URLType from enum to char*
|
||||
* gw-gnome-utils-spec: wrap URLType type, #defines, and gnc_build_url()
|
||||
* get the rest of the C code to use URLTypes properly
|
||||
|
||||
2002-06-29 David Hampton <hampton@employees.org>
|
||||
|
||||
* configure.in:
|
||||
|
@ -86,6 +86,10 @@ struct gnc_html_struct {
|
||||
/* indicates the debugging module that this .o belongs to. */
|
||||
static short module = MOD_HTML;
|
||||
|
||||
/* hashes for URLType -> protocol and protocol -> URLType */
|
||||
static GHashTable * gnc_html_type_to_proto_hash = NULL;
|
||||
static GHashTable * gnc_html_proto_to_type_hash = NULL;
|
||||
|
||||
/* hashes an HTML <object classid="ID"> classid to a handler function */
|
||||
static GHashTable * gnc_html_object_handlers = NULL;
|
||||
|
||||
@ -131,6 +135,27 @@ extract_machine_name(const gchar * path) {
|
||||
}
|
||||
|
||||
|
||||
/* Register the URLType if it doesn't already exist.
|
||||
* Returns TRUE if successful, FALSE if the type already exists.
|
||||
*/
|
||||
gboolean
|
||||
gnc_html_register_urltype (URLType type, const char *protocol)
|
||||
{
|
||||
if (!gnc_html_type_to_proto_hash) {
|
||||
gnc_html_type_to_proto_hash = g_hash_table_new (g_str_hash, g_str_equal);
|
||||
gnc_html_proto_to_type_hash = g_hash_table_new (g_str_hash, g_str_equal);
|
||||
}
|
||||
if (!protocol) return FALSE;
|
||||
if (g_hash_table_lookup (gnc_html_type_to_proto_hash, type))
|
||||
return FALSE;
|
||||
|
||||
g_hash_table_insert (gnc_html_type_to_proto_hash, type, (gpointer)protocol);
|
||||
if (*protocol)
|
||||
g_hash_table_insert (gnc_html_proto_to_type_hash, (gpointer)protocol, type);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/********************************************************************
|
||||
* gnc_html_parse_url
|
||||
* this takes a URL and determines the protocol type, location, and
|
||||
@ -176,43 +201,8 @@ gnc_html_parse_url(gnc_html * html, const gchar * url,
|
||||
regfree(&compiled);
|
||||
|
||||
if(found_protocol) {
|
||||
if(!strcmp(protocol, "file")) {
|
||||
retval = URL_TYPE_FILE;
|
||||
}
|
||||
else if(!strcmp(protocol, "http")) {
|
||||
retval = URL_TYPE_HTTP;
|
||||
}
|
||||
else if(!strcmp(protocol, "ftp")) {
|
||||
retval = URL_TYPE_FTP;
|
||||
}
|
||||
else if(!strcmp(protocol, "https")) {
|
||||
retval = URL_TYPE_SECURE;
|
||||
}
|
||||
else if(!strcmp(protocol, "gnc-action")) {
|
||||
retval = URL_TYPE_ACTION;
|
||||
}
|
||||
else if(!strcmp(protocol, "gnc-register")) {
|
||||
retval = URL_TYPE_REGISTER;
|
||||
}
|
||||
else if(!strcmp(protocol, "gnc-acct-tree")) {
|
||||
retval = URL_TYPE_ACCTTREE;
|
||||
}
|
||||
else if(!strcmp(protocol, "gnc-report")) {
|
||||
retval = URL_TYPE_REPORT;
|
||||
}
|
||||
else if(!strcmp(protocol, "gnc-options")) {
|
||||
retval = URL_TYPE_OPTIONS;
|
||||
}
|
||||
else if(!strcmp(protocol, "gnc-scm")) {
|
||||
retval = URL_TYPE_SCHEME;
|
||||
}
|
||||
else if(!strcmp(protocol, "gnc-help")) {
|
||||
retval = URL_TYPE_HELP;
|
||||
}
|
||||
else if(!strcmp(protocol, "gnc-price")) {
|
||||
retval = URL_TYPE_PRICE;
|
||||
}
|
||||
else {
|
||||
retval = g_hash_table_lookup (gnc_html_proto_to_type_hash, protocol);
|
||||
if (!retval) {
|
||||
PWARN("unhandled URL type for '%s'", url ? url : "(null)");
|
||||
retval = URL_TYPE_OTHER;
|
||||
}
|
||||
@ -231,8 +221,7 @@ gnc_html_parse_url(gnc_html * html, const gchar * url,
|
||||
|
||||
g_free(protocol);
|
||||
|
||||
switch(retval) {
|
||||
case URL_TYPE_FILE:
|
||||
if (!safe_strcmp (retval, URL_TYPE_FILE)) {
|
||||
if(!found_protocol && path && html && html->base_location) {
|
||||
if(path[0] == '/') {
|
||||
*url_location = g_strdup(path);
|
||||
@ -246,15 +235,14 @@ gnc_html_parse_url(gnc_html * html, const gchar * url,
|
||||
*url_location = g_strdup(path);
|
||||
g_free(path);
|
||||
}
|
||||
break;
|
||||
|
||||
case URL_TYPE_JUMP:
|
||||
|
||||
} else if (!safe_strcmp (retval, URL_TYPE_JUMP)) {
|
||||
*url_location = NULL;
|
||||
g_free(path);
|
||||
break;
|
||||
|
||||
case URL_TYPE_OTHER:
|
||||
default:
|
||||
} else {
|
||||
/* case URL_TYPE_OTHER: */
|
||||
|
||||
if(!found_protocol && path && html && html->base_location) {
|
||||
if(path[0] == '/') {
|
||||
*url_location =
|
||||
@ -270,7 +258,6 @@ gnc_html_parse_url(gnc_html * html, const gchar * url,
|
||||
*url_location = g_strdup(path);
|
||||
g_free(path);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
*url_label = label;
|
||||
@ -292,10 +279,10 @@ extract_base_name(URLType type, const gchar * path) {
|
||||
regcomp(&compiled_m, machine_rexp, REG_EXTENDED);
|
||||
regcomp(&compiled_p, path_rexp, REG_EXTENDED);
|
||||
|
||||
switch(type) {
|
||||
case URL_TYPE_HTTP:
|
||||
case URL_TYPE_SECURE:
|
||||
case URL_TYPE_FTP:
|
||||
if (!safe_strcmp (type, URL_TYPE_HTTP) ||
|
||||
!safe_strcmp (type, URL_TYPE_SECURE) ||
|
||||
!safe_strcmp (type, URL_TYPE_FTP)) {
|
||||
|
||||
/* step 1: split the machine name away from the path
|
||||
* components */
|
||||
if(!regexec(&compiled_m, path, 4, match, 0)) {
|
||||
@ -310,8 +297,8 @@ extract_base_name(URLType type, const gchar * path) {
|
||||
match[2].rm_eo - match[2].rm_so);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
||||
} else {
|
||||
location = g_strdup(path);
|
||||
}
|
||||
/* step 2: split up the path into prefix and file components */
|
||||
@ -353,22 +340,51 @@ extract_base_name(URLType type, const gchar * path) {
|
||||
return basename;
|
||||
}
|
||||
|
||||
static char * url_type_names[] = {
|
||||
"file:", "", "http:", "ftp:", "https:",
|
||||
"gnc-register:", "gnc-acct-tree:", "gnc-report:", "gnc-options:", "gnc-scm:",
|
||||
"gnc-help:", "gnc-xml:", "gnc-action:", "gnc-price:", ""
|
||||
};
|
||||
void
|
||||
gnc_html_initialize (void)
|
||||
{
|
||||
int i;
|
||||
static struct {
|
||||
URLType type;
|
||||
char * protocol;
|
||||
} types[] = {
|
||||
{ URL_TYPE_FILE, "file" },
|
||||
{ URL_TYPE_JUMP, "" },
|
||||
{ URL_TYPE_HTTP, "http" },
|
||||
{ URL_TYPE_FTP, "ftp" },
|
||||
{ URL_TYPE_SECURE, "https" },
|
||||
{ URL_TYPE_REGISTER, "gnc-register" },
|
||||
{ URL_TYPE_ACCTTREE, "gnc-acct-tree" },
|
||||
{ URL_TYPE_REPORT, "gnc-report" },
|
||||
{ URL_TYPE_OPTIONS, "gnc-options" },
|
||||
{ URL_TYPE_SCHEME, "gnc-scm" },
|
||||
{ URL_TYPE_HELP, "gnc-help" },
|
||||
{ URL_TYPE_XMLDATA, "gnc-xml" },
|
||||
{ URL_TYPE_ACTION, "gnc-action" },
|
||||
{ URL_TYPE_PRICE, "gnc-price" },
|
||||
{ URL_TYPE_OTHER, "" },
|
||||
{ NULL, NULL }};
|
||||
|
||||
for (i = 0; types[i].type; i++)
|
||||
gnc_html_register_urltype (types[i].type, types[i].protocol);
|
||||
}
|
||||
|
||||
|
||||
char *
|
||||
gnc_build_url (URLType type, const gchar * location, const gchar * label) {
|
||||
char * type_name;
|
||||
|
||||
type_name = g_hash_table_lookup (gnc_html_type_to_proto_hash, type);
|
||||
if (!type_name)
|
||||
type_name = "";
|
||||
|
||||
if(label) {
|
||||
return g_strdup_printf("%s%s#%s", url_type_names[type],
|
||||
return g_strdup_printf("%s%s%s#%s", type_name, (*type_name ? ":" : ""),
|
||||
(location ? location : ""),
|
||||
label ? label : "");
|
||||
}
|
||||
else {
|
||||
return g_strdup_printf("%s%s", url_type_names[type],
|
||||
return g_strdup_printf("%s%s%s", type_name, (*type_name ? ":" : ""),
|
||||
(location ? location : ""));
|
||||
}
|
||||
}
|
||||
@ -525,7 +541,7 @@ gnc_html_load_to_stream(gnc_html * html, GtkHTMLStream * handle,
|
||||
if (gnc_html_stream_handlers) {
|
||||
GncHTMLStreamCB stream_handler;
|
||||
|
||||
stream_handler = g_hash_table_lookup (gnc_html_stream_handlers, &type);
|
||||
stream_handler = g_hash_table_lookup (gnc_html_stream_handlers, type);
|
||||
if (stream_handler) {
|
||||
gboolean ok = stream_handler (location, &fdata);
|
||||
|
||||
@ -550,39 +566,42 @@ gnc_html_load_to_stream(gnc_html * html, GtkHTMLStream * handle,
|
||||
}
|
||||
}
|
||||
|
||||
switch(type) {
|
||||
case URL_TYPE_SECURE:
|
||||
if(!https_allowed()) {
|
||||
gnc_error_dialog(_("Secure HTTP access is disabled.\n"
|
||||
"You can enable it in the Network section of\n"
|
||||
"the Preferences dialog."));
|
||||
break;
|
||||
do {
|
||||
if (!safe_strcmp (type, URL_TYPE_SECURE) ||
|
||||
!safe_strcmp (type, URL_TYPE_HTTP)) {
|
||||
|
||||
if (!safe_strcmp (type, URL_TYPE_SECURE)) {
|
||||
if(!https_allowed()) {
|
||||
gnc_error_dialog(_("Secure HTTP access is disabled.\n"
|
||||
"You can enable it in the Network section of\n"
|
||||
"the Preferences dialog."));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(!http_allowed()) {
|
||||
gnc_error_dialog(_("Network HTTP access is disabled.\n"
|
||||
"You can enable it in the Network section of\n"
|
||||
"the Preferences dialog."));
|
||||
} else {
|
||||
char *fullurl;
|
||||
|
||||
fullurl = gnc_build_url(type, location, label);
|
||||
gnc_html_start_request(html, fullurl, handle);
|
||||
}
|
||||
|
||||
} else {
|
||||
PWARN("load_to_stream for inappropriate type\n"
|
||||
"\turl = '%s#%s'\n",
|
||||
location ? location : "(null)",
|
||||
label ? label : "(null)");
|
||||
fdata = _(error_404);
|
||||
gtk_html_write(GTK_HTML(html->html), handle, fdata, strlen (fdata));
|
||||
gtk_html_end(GTK_HTML(html->html), handle, GTK_HTML_STREAM_ERROR);
|
||||
}
|
||||
|
||||
case URL_TYPE_HTTP:
|
||||
if(!http_allowed()) {
|
||||
gnc_error_dialog(_("Network HTTP access is disabled.\n"
|
||||
"You can enable it in the Network section of\n"
|
||||
"the Preferences dialog."));
|
||||
}
|
||||
else {
|
||||
char *fullurl;
|
||||
} while (FALSE);
|
||||
|
||||
fullurl = gnc_build_url(type, location, label);
|
||||
gnc_html_start_request(html, fullurl, handle);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
PWARN("load_to_stream for inappropriate type\n"
|
||||
"\turl = '%s#%s'\n",
|
||||
location ? location : "(null)",
|
||||
label ? label : "(null)");
|
||||
fdata = _(error_404);
|
||||
gtk_html_write(GTK_HTML(html->html), handle, fdata, strlen (fdata));
|
||||
gtk_html_end(GTK_HTML(html->html), handle, GTK_HTML_STREAM_ERROR);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -815,7 +834,7 @@ gnc_html_submit_cb(GtkHTML * html, const gchar * method,
|
||||
|
||||
type = gnc_html_parse_url(gnchtml, action, &location, &label);
|
||||
|
||||
if(type == URL_TYPE_ACTION) {
|
||||
if(!safe_strcmp (type, URL_TYPE_ACTION)) {
|
||||
if(gnc_network_allowed()) {
|
||||
if(gnc_html_action_handlers) {
|
||||
action_parts = g_strsplit(location, "?", 2);
|
||||
@ -921,7 +940,7 @@ gnc_html_show_url(gnc_html * html, URLType type,
|
||||
}
|
||||
|
||||
if (gnc_html_url_handlers)
|
||||
url_handler = g_hash_table_lookup (gnc_html_url_handlers, &type);
|
||||
url_handler = g_hash_table_lookup (gnc_html_url_handlers, type);
|
||||
else
|
||||
url_handler = NULL;
|
||||
|
||||
@ -987,55 +1006,57 @@ gnc_html_show_url(gnc_html * html, URLType type,
|
||||
return;
|
||||
}
|
||||
|
||||
switch(type) {
|
||||
case URL_TYPE_SCHEME:
|
||||
if (!safe_strcmp (type, URL_TYPE_SCHEME)) {
|
||||
gnc_html_open_scm(html, location, label, new_window);
|
||||
break;
|
||||
|
||||
case URL_TYPE_JUMP:
|
||||
} else if (!safe_strcmp (type, URL_TYPE_JUMP)) {
|
||||
gtk_html_jump_to_anchor(GTK_HTML(html->html), label);
|
||||
break;
|
||||
|
||||
case URL_TYPE_SECURE:
|
||||
if(!https_allowed()) {
|
||||
gnc_error_dialog(_("Secure HTTP access is disabled.\n"
|
||||
"You can enable it in the Network section of\n"
|
||||
"the Preferences dialog."));
|
||||
break;
|
||||
}
|
||||
} else if (!safe_strcmp (type, URL_TYPE_SECURE) ||
|
||||
!safe_strcmp (type, URL_TYPE_HTTP) ||
|
||||
!safe_strcmp (type, URL_TYPE_FILE)) {
|
||||
|
||||
case URL_TYPE_HTTP:
|
||||
if(!http_allowed()) {
|
||||
gnc_error_dialog(_("Network HTTP access is disabled.\n"
|
||||
"You can enable it in the Network section of\n"
|
||||
"the Preferences dialog."));
|
||||
break;
|
||||
}
|
||||
do {
|
||||
if (!safe_strcmp (type, URL_TYPE_SECURE)) {
|
||||
if(!https_allowed()) {
|
||||
gnc_error_dialog(_("Secure HTTP access is disabled.\n"
|
||||
"You can enable it in the Network section of\n"
|
||||
"the Preferences dialog."));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
case URL_TYPE_FILE:
|
||||
html->base_type = type;
|
||||
|
||||
if(html->base_location) g_free(html->base_location);
|
||||
html->base_location = extract_base_name(type, location);
|
||||
if (safe_strcmp (type, URL_TYPE_FILE)) {
|
||||
if(!http_allowed()) {
|
||||
gnc_error_dialog(_("Network HTTP access is disabled.\n"
|
||||
"You can enable it in the Network section of\n"
|
||||
"the Preferences dialog."));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* FIXME : handle new_window = 1 */
|
||||
gnc_html_history_append(html->history,
|
||||
gnc_html_history_node_new(type, location, label));
|
||||
handle = gtk_html_begin(GTK_HTML(html->html));
|
||||
gnc_html_load_to_stream(html, handle, type, location, label);
|
||||
break;
|
||||
html->base_type = type;
|
||||
|
||||
if(html->base_location) g_free(html->base_location);
|
||||
html->base_location = extract_base_name(type, location);
|
||||
|
||||
case URL_TYPE_ACTION:
|
||||
/* FIXME : handle new_window = 1 */
|
||||
gnc_html_history_append(html->history,
|
||||
gnc_html_history_node_new(type, location, label));
|
||||
handle = gtk_html_begin(GTK_HTML(html->html));
|
||||
gnc_html_load_to_stream(html, handle, type, location, label);
|
||||
|
||||
} while (FALSE);
|
||||
|
||||
} else if (!safe_strcmp (type, URL_TYPE_ACTION)) {
|
||||
gnc_html_history_append(html->history,
|
||||
gnc_html_history_node_new(type, location, label));
|
||||
gnc_html_submit_cb(GTK_HTML(html->html), "get",
|
||||
gnc_build_url(type, location, label), NULL,
|
||||
(gpointer)html);
|
||||
break;
|
||||
|
||||
default:
|
||||
PERR ("URLType %d not supported.", type);
|
||||
break;
|
||||
} else {
|
||||
PERR ("URLType %s not supported.", type);
|
||||
}
|
||||
|
||||
if(html->load_cb) {
|
||||
@ -1319,75 +1340,45 @@ gnc_html_unregister_action_handler(const char * actionid) {
|
||||
void
|
||||
gnc_html_register_stream_handler(URLType url_type, GncHTMLStreamCB hand)
|
||||
{
|
||||
URLType *key;
|
||||
|
||||
g_return_if_fail (url_type >= 0);
|
||||
g_return_if_fail (url_type != NULL && *url_type != '\0');
|
||||
|
||||
if(!gnc_html_stream_handlers) {
|
||||
gnc_html_stream_handlers = g_hash_table_new(g_int_hash, g_int_equal);
|
||||
gnc_html_stream_handlers = g_hash_table_new(g_str_hash, g_str_equal);
|
||||
}
|
||||
|
||||
gnc_html_unregister_stream_handler (url_type);
|
||||
if (!hand)
|
||||
return;
|
||||
|
||||
key = g_new (URLType, 1);
|
||||
*key = url_type;
|
||||
|
||||
g_hash_table_insert (gnc_html_stream_handlers, key, hand);
|
||||
g_hash_table_insert (gnc_html_stream_handlers, url_type, hand);
|
||||
}
|
||||
|
||||
void
|
||||
gnc_html_unregister_stream_handler(URLType url_type)
|
||||
{
|
||||
gpointer keyptr;
|
||||
gpointer valptr;
|
||||
|
||||
if (!g_hash_table_lookup_extended(gnc_html_stream_handlers,
|
||||
&url_type,
|
||||
&keyptr,
|
||||
&valptr))
|
||||
return;
|
||||
|
||||
g_hash_table_remove (gnc_html_stream_handlers, &url_type);
|
||||
g_free (keyptr);
|
||||
g_hash_table_remove (gnc_html_stream_handlers, url_type);
|
||||
}
|
||||
|
||||
void
|
||||
gnc_html_register_url_handler (URLType url_type, GncHTMLUrlCB hand)
|
||||
{
|
||||
URLType *key;
|
||||
|
||||
g_return_if_fail (url_type >= 0);
|
||||
g_return_if_fail (url_type != NULL && *url_type != '\0');
|
||||
|
||||
if(!gnc_html_url_handlers) {
|
||||
gnc_html_url_handlers = g_hash_table_new (g_int_hash, g_int_equal);
|
||||
gnc_html_url_handlers = g_hash_table_new (g_str_hash, g_str_equal);
|
||||
}
|
||||
|
||||
gnc_html_unregister_url_handler (url_type);
|
||||
if (!hand)
|
||||
return;
|
||||
|
||||
key = g_new (URLType, 1);
|
||||
*key = url_type;
|
||||
|
||||
g_hash_table_insert (gnc_html_url_handlers, key, hand);
|
||||
g_hash_table_insert (gnc_html_url_handlers, url_type, hand);
|
||||
}
|
||||
|
||||
void
|
||||
gnc_html_unregister_url_handler (URLType url_type)
|
||||
{
|
||||
gpointer keyptr;
|
||||
gpointer valptr;
|
||||
|
||||
if (!g_hash_table_lookup_extended (gnc_html_url_handlers,
|
||||
&url_type,
|
||||
&keyptr,
|
||||
&valptr))
|
||||
return;
|
||||
|
||||
g_hash_table_remove (gnc_html_url_handlers, &url_type);
|
||||
g_free (keyptr);
|
||||
g_hash_table_remove (gnc_html_url_handlers, url_type);
|
||||
}
|
||||
|
||||
/********************************************************************
|
||||
|
@ -28,19 +28,23 @@
|
||||
#include <gdk/gdk.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
typedef enum { URL_TYPE_FILE, URL_TYPE_JUMP,
|
||||
URL_TYPE_HTTP, URL_TYPE_FTP,
|
||||
URL_TYPE_SECURE,
|
||||
URL_TYPE_REGISTER, /* for gnucash register popups */
|
||||
URL_TYPE_ACCTTREE, /* for account tree windows */
|
||||
URL_TYPE_REPORT, /* for gnucash report popups */
|
||||
URL_TYPE_OPTIONS, /* for editing report options */
|
||||
URL_TYPE_SCHEME, /* for scheme code evaluation */
|
||||
URL_TYPE_HELP, /* for a gnucash help window */
|
||||
URL_TYPE_XMLDATA, /* links to gnucash XML data files */
|
||||
URL_TYPE_ACTION, /* for special SUBMIT actions */
|
||||
URL_TYPE_PRICE, /* for price editor popups */
|
||||
URL_TYPE_OTHER } URLType;
|
||||
typedef char * URLType;
|
||||
|
||||
#define URL_TYPE_FILE "file"
|
||||
#define URL_TYPE_JUMP "jump"
|
||||
#define URL_TYPE_HTTP "http"
|
||||
#define URL_TYPE_FTP "ftp"
|
||||
#define URL_TYPE_SECURE "secure"
|
||||
#define URL_TYPE_REGISTER "register" /* for gnucash register popups */
|
||||
#define URL_TYPE_ACCTTREE "accttree" /* for account tree windows */
|
||||
#define URL_TYPE_REPORT "report" /* for gnucash report popups */
|
||||
#define URL_TYPE_OPTIONS "options" /* for editing report options */
|
||||
#define URL_TYPE_SCHEME "scheme" /* for scheme code evaluation */
|
||||
#define URL_TYPE_HELP "help" /* for a gnucash help window */
|
||||
#define URL_TYPE_XMLDATA "xmldata" /* links to gnucash XML data files */
|
||||
#define URL_TYPE_ACTION "action" /* for special SUBMIT actions */
|
||||
#define URL_TYPE_PRICE "price" /* for price editor popups */
|
||||
#define URL_TYPE_OTHER "other"
|
||||
|
||||
#include "gnc-html-history.h"
|
||||
|
||||
@ -102,6 +106,14 @@ void gnc_html_cancel(gnc_html * html);
|
||||
char * gnc_build_url (URLType type, const gchar * location,
|
||||
const gchar * label);
|
||||
|
||||
/* Register a new URLType.
|
||||
* returns TRUE if succesful, FALSE if type already exists.
|
||||
*
|
||||
* protocol should be an empty string if there is no corresponding protocol.
|
||||
* if protocol is NULL, this function returns FALSE.
|
||||
*/
|
||||
gboolean gnc_html_register_urltype (URLType type, const char *protocol);
|
||||
|
||||
/* object handlers deal with <object classid="foo"> objects in HTML.
|
||||
* the handlers are looked up at object load time. */
|
||||
void gnc_html_register_object_handler(const char * classid,
|
||||
@ -165,4 +177,7 @@ void gnc_html_set_button_cb(gnc_html * html, GncHTMLButtonCB button_cb,
|
||||
GtkWidget * gnc_html_get_container_widget(gnc_html * html);
|
||||
GtkWidget * gnc_html_get_html_widget(gnc_html * html);
|
||||
|
||||
/* Initialize the html subsystem */
|
||||
void gnc_html_initialize (void);
|
||||
|
||||
#endif
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "gnc-module-api.h"
|
||||
|
||||
#include "dialog-options.h"
|
||||
#include "gnc-html.h"
|
||||
|
||||
/* version of the gnc module system interface we require */
|
||||
int libgncmod_gnome_utils_LTX_gnc_module_system_interface = 0;
|
||||
@ -74,8 +75,10 @@ libgncmod_gnome_utils_LTX_gnc_module_init(int refcount) {
|
||||
lmod("(gnucash gnome-utils)");
|
||||
|
||||
/* Initialize the options-ui database */
|
||||
if (refcount == 0)
|
||||
if (refcount == 0) {
|
||||
gnc_options_ui_initialize ();
|
||||
gnc_html_initialize ();
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -62,6 +62,27 @@
|
||||
|
||||
(gw:wrap-as-wct ws '<gnc:UIWidget> "gncUIWidget" "const gncUIWidget")
|
||||
(gw:wrap-as-wct ws '<gnc:mdi-info*> "GNCMDIInfo*" "const GNCMDIInfo*")
|
||||
(gw:wrap-as-wct ws '<gnc:url-type> "URLType" "const URLType")
|
||||
|
||||
;;
|
||||
;; URLTypes
|
||||
;;
|
||||
(gw:wrap-value ws 'gnc:url-type-file '<gnc:url-type> "URL_TYPE_FILE")
|
||||
(gw:wrap-value ws 'gnc:url-type-jump '<gnc:url-type> "URL_TYPE_JUMP")
|
||||
(gw:wrap-value ws 'gnc:url-type-http '<gnc:url-type> "URL_TYPE_HTTP")
|
||||
(gw:wrap-value ws 'gnc:url-type-ftp '<gnc:url-type> "URL_TYPE_FTP")
|
||||
(gw:wrap-value ws 'gnc:url-type-secure '<gnc:url-type> "URL_TYPE_SECURE")
|
||||
(gw:wrap-value ws 'gnc:url-type-register '<gnc:url-type> "URL_TYPE_REGISTER")
|
||||
(gw:wrap-value ws 'gnc:url-type-accttree '<gnc:url-type> "URL_TYPE_ACCTTREE")
|
||||
(gw:wrap-value ws 'gnc:url-type-report '<gnc:url-type> "URL_TYPE_REPORT")
|
||||
(gw:wrap-value ws 'gnc:url-type-options '<gnc:url-type> "URL_TYPE_OPTIONS")
|
||||
(gw:wrap-value ws 'gnc:url-type-scheme '<gnc:url-type> "URL_TYPE_SCHEME")
|
||||
(gw:wrap-value ws 'gnc:url-type-help '<gnc:url-type> "URL_TYPE_HELP")
|
||||
(gw:wrap-value ws 'gnc:url-type-xmldata '<gnc:url-type> "URL_TYPE_XMLDATA")
|
||||
(gw:wrap-value ws 'gnc:url-type-action '<gnc:url-type> "URL_TYPE_ACTION")
|
||||
(gw:wrap-value ws 'gnc:url-type-price '<gnc:url-type> "URL_TYPE_PRICE")
|
||||
(gw:wrap-value ws 'gnc:url-type-other '<gnc:url-type> "URL_TYPE_OTHER")
|
||||
|
||||
|
||||
(gw:wrap-function
|
||||
ws
|
||||
@ -190,12 +211,6 @@
|
||||
'((<gw:scm> extension))
|
||||
"Add a menu extension.")
|
||||
|
||||
(gw:wrap-function
|
||||
ws
|
||||
'gnc:html-encode-string
|
||||
'(<gw:gchars> caller-owned)
|
||||
"gnc_html_encode_string" '(((<gw:mchars> caller-owned const) bookname)))
|
||||
|
||||
(gw:wrap-function
|
||||
ws
|
||||
'gnc:choose-radio-option-dialog-parented
|
||||
@ -209,6 +224,28 @@
|
||||
"Show a dialog offering different mutually exclusive choices
|
||||
in a radio list.")
|
||||
|
||||
;;
|
||||
;; gnc-html.h
|
||||
;;
|
||||
|
||||
(gw:wrap-function
|
||||
ws
|
||||
'gnc:html-encode-string
|
||||
'(<gw:gchars> caller-owned)
|
||||
"gnc_html_encode_string"
|
||||
'(((<gw:mchars> caller-owned const) bookname)))
|
||||
|
||||
(gw:wrap-function
|
||||
ws
|
||||
'gnc:html-build-url
|
||||
'(<gw:gchars> caller-owned)
|
||||
"gnc_build_url"
|
||||
'((<gnc:url-type> url-type) ((<gw:mchars> caller-owned const) location)
|
||||
((<gw:mchars> caller-owned const) label))
|
||||
"Build a GNC URL based on the URL Type and location. The label may
|
||||
be left empty")
|
||||
|
||||
|
||||
;; gnc-amount-edit.h
|
||||
(gw:wrap-as-wct ws
|
||||
'<gnc:GNCAmountEdit>
|
||||
|
@ -105,14 +105,13 @@ static gint last_height = 0;
|
||||
|
||||
static int
|
||||
gnc_help_window_check_urltype(URLType t) {
|
||||
switch (t) {
|
||||
case URL_TYPE_FILE:
|
||||
case URL_TYPE_HELP:
|
||||
case URL_TYPE_HTTP:
|
||||
case URL_TYPE_SECURE:
|
||||
if (!safe_strcmp (t, URL_TYPE_FILE) ||
|
||||
!safe_strcmp (t, URL_TYPE_HELP) ||
|
||||
!safe_strcmp (t, URL_TYPE_HTTP) ||
|
||||
!safe_strcmp (t, URL_TYPE_SECURE)) {
|
||||
return TRUE;
|
||||
break;
|
||||
default:
|
||||
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
@ -1084,9 +1084,9 @@ gnc_acct_tree_window_new(const gchar * url) {
|
||||
* gnc-acct-tree:id=17 . We want to get the number out,
|
||||
* then look up the options in the global DB. */
|
||||
type = gnc_html_parse_url(NULL, url, &location, &label);
|
||||
if((type == URL_TYPE_ACCTTREE) &&
|
||||
location && (strlen(location) > 3) &&
|
||||
!strncmp("id=", location, 3)) {
|
||||
if (!safe_strcmp (type, URL_TYPE_ACCTTREE) &&
|
||||
location && (strlen(location) > 3) &&
|
||||
!strncmp("id=", location, 3)) {
|
||||
sscanf(location+3, "%d", &options_id);
|
||||
temp = gh_call1(find_options, gh_int2scm(options_id));
|
||||
|
||||
|
@ -45,6 +45,7 @@
|
||||
#include "gfec.h"
|
||||
#include "global-options.h"
|
||||
#include "gnc-engine.h"
|
||||
#include "gnc-engine-util.h"
|
||||
#include "gnc-file-dialog.h"
|
||||
#include "gnc-file-history.h"
|
||||
#include "gnc-file-history-gnome.h"
|
||||
@ -225,16 +226,13 @@ gnc_main_window_create_child(const gchar * configstring)
|
||||
g_free(location);
|
||||
g_free(label);
|
||||
|
||||
switch(type) {
|
||||
case URL_TYPE_REPORT:
|
||||
if (!safe_strcmp (type, URL_TYPE_REPORT)) {
|
||||
child = gnc_report_window_create_child(configstring);
|
||||
break;
|
||||
|
||||
case URL_TYPE_ACCTTREE:
|
||||
|
||||
} else if (!safe_strcmp (type, URL_TYPE_ACCTTREE)) {
|
||||
child = gnc_acct_tree_window_create_child(configstring);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
} else {
|
||||
child = NULL;
|
||||
}
|
||||
|
||||
|
@ -264,13 +264,10 @@ gnc_main_window_open_report_url(const char * url, gint toplevel) {
|
||||
|
||||
static int
|
||||
gnc_report_window_check_urltype(URLType t) {
|
||||
switch (t) {
|
||||
case URL_TYPE_REPORT:
|
||||
if (!safe_strcmp (t, URL_TYPE_REPORT)) {
|
||||
return TRUE;
|
||||
break;
|
||||
default:
|
||||
} else {
|
||||
return FALSE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -601,11 +598,13 @@ gnc_report_window_load_cb(gnc_html * html, URLType type,
|
||||
/* we get this callback if a new report is requested to be loaded OR
|
||||
* if any URL is clicked. If an options URL is clicked, we want to
|
||||
* know about it */
|
||||
if((type == URL_TYPE_REPORT) && location && (strlen(location) > 3) &&
|
||||
if(!safe_strcmp (type, URL_TYPE_REPORT) &&
|
||||
location && (strlen(location) > 3) &&
|
||||
!strncmp("id=", location, 3)) {
|
||||
sscanf(location+3, "%d", &report_id);
|
||||
}
|
||||
else if((type == URL_TYPE_OPTIONS) && location && (strlen(location) > 10) &&
|
||||
else if(!safe_strcmp( type, URL_TYPE_OPTIONS)
|
||||
&& location && (strlen(location) > 10) &&
|
||||
!strncmp("report-id=", location, 10)) {
|
||||
sscanf(location+10, "%d", &report_id);
|
||||
inst_report = gh_call1(find_report, gh_int2scm(report_id));
|
||||
@ -709,7 +708,7 @@ gnc_report_window_history_destroy_cb(gnc_html_history_node * node,
|
||||
}
|
||||
|
||||
if(node &&
|
||||
(node->type == URL_TYPE_REPORT) &&
|
||||
!safe_strcmp (node->type, URL_TYPE_REPORT) &&
|
||||
!strncmp("id=", node->location, 3)) {
|
||||
sscanf(node->location+3, "%d", &report_id);
|
||||
/* printf("unreffing report %d and children\n", report_id);
|
||||
|
Loading…
Reference in New Issue
Block a user