diff --git a/ChangeLog b/ChangeLog index 713951b2da..21ba94e18c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2006-03-09 David Hampton + + * src/gnome/dialog-price-editor.c: + * src/gnome/top-level.c: + * src/gnc-ui.h: Restore clickable links for price quotes. + 2006-03-09 Neil Williams * src/optional/Makefile.am : Make xsl/ available diff --git a/src/gnc-ui.h b/src/gnc-ui.h index cd9aa011d2..648166ff1a 100644 --- a/src/gnc-ui.h +++ b/src/gnc-ui.h @@ -109,6 +109,7 @@ typedef enum GNCPrice* gnc_price_edit_dialog (gncUIWidget parent, QofSession *session, GNCPrice *price, GNCPriceEditType type); +GNCPrice* gnc_price_edit_by_guid (GtkWidget * parent, const GUID * guid); void gnc_prices_dialog (gncUIWidget parent); void gnc_commodities_dialog (gncUIWidget parent); diff --git a/src/gnome/dialog-price-editor.c b/src/gnome/dialog-price-editor.c index 574aeb09ef..b15411e735 100644 --- a/src/gnome/dialog-price-editor.c +++ b/src/gnome/dialog-price-editor.c @@ -37,6 +37,7 @@ #include "gnc-date-edit.h" #include "qof.h" #include "gnc-pricedb.h" +#include "gnc-session.h" #include "gnc-ui.h" #include "gnc-ui-util.h" #include "guile-util.h" @@ -484,3 +485,24 @@ gnc_price_edit_dialog (GtkWidget * parent, gtk_widget_show (pedit_dialog->dialog); return(price); } + +/********************************************************************\ + * gnc_price_edit_by_guid * + * opens up a window to edit price information * + * * + * Args: parent - the parent of the window to be created * + * Return: nothing * +\********************************************************************/ +GNCPrice * +gnc_price_edit_by_guid (GtkWidget * parent, const GUID * guid) +{ + GNCPrice *price; + QofSession *session; + + session = gnc_get_current_session (); + price = gnc_price_lookup (guid, qof_session_get_book(session)); + if (price == NULL) + return(NULL); + + return(gnc_price_edit_dialog(parent, session, price, GNC_PRICE_EDIT)); +} diff --git a/src/gnome/top-level.c b/src/gnome/top-level.c index e36cd59867..0f990f3ee3 100644 --- a/src/gnome/top-level.c +++ b/src/gnome/top-level.c @@ -167,6 +167,35 @@ gnc_html_register_url_cb (const char *location, const char *label, /* ============================================================== */ +static gboolean +gnc_html_price_url_cb (const char *location, const char *label, + gboolean new_window, GNCURLResult *result) +{ + QofBook * book = gnc_get_current_book(); + g_return_val_if_fail (location != NULL, FALSE); + g_return_val_if_fail (result != NULL, FALSE); + + result->load_to_stream = FALSE; + + /* href="gnc-register:guid=12345678901234567890123456789012" */ + IF_TYPE ("price-guid=", GNC_ID_PRICE) + if (!gnc_price_edit_by_guid (NULL, &guid)) + { + result->error_message = g_strdup_printf (_("No such price: %s"), + location); + return FALSE; + } + } + else + { + result->error_message = g_strdup_printf (_("Badly formed URL %s"), + location); + return FALSE; + } + + return TRUE; +} + /** Restore all persistent program state. This function finds the * "new" state file associated with a specific book guid. It then * iterates through this state information, calling a helper function @@ -360,6 +389,9 @@ gnc_main_gui_init (void) gnc_html_register_url_handler (URL_TYPE_REGISTER, gnc_html_register_url_cb); + gnc_html_register_url_handler (URL_TYPE_PRICE, + gnc_html_price_url_cb); + gnc_ui_sx_initialize(); /* FIXME Remove this test code */