[Gnucash-changes] Make hyperlinks in reports result in the appropriate window, not a

Joshua Sled jsled at cvs.gnucash.org
Mon May 31 11:20:48 EDT 2004


Log Message:
-----------
Make hyperlinks in reports result in the appropriate window, not a crash.

Tags:
----
gnucash-gnome2-dev

Modified Files:
--------------
    gnucash:
        ChangeLog
    gnucash/src/engine:
        qofbook.c
        qofbook.h
    gnucash/src/gnome:
        top-level.c

Revision Data
-------------
Index: ChangeLog
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/ChangeLog,v
retrieving revision 1.1487.2.129
retrieving revision 1.1487.2.130
diff -LChangeLog -LChangeLog -u -r1.1487.2.129 -r1.1487.2.130
--- ChangeLog
+++ ChangeLog
@@ -1,3 +1,12 @@
+2004-05-31  Joshua Sled  <jsled at asynchronous.org>
+
+	* src/gnome/top-level.c (gnc_html_register_url_cb): Modify to
+	handle hyperlinks better.
+
+	* src/engine/qofbook.c (qof_book_get_entity_by_guid): Add generic
+	GUID lookup [without entity-type being known] to handle historical
+	code.
+
 2004-05-30  Joshua Sled  <jsled at asynchronous.org>
 
 	* src/gnome-utils/gnc-mdi-utils.c (gnc_mdi_show_progress): Proxy
Index: qofbook.h
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/engine/qofbook.h,v
retrieving revision 1.5.2.2
retrieving revision 1.5.2.3
diff -Lsrc/engine/qofbook.h -Lsrc/engine/qofbook.h -u -r1.5.2.2 -r1.5.2.3
--- src/engine/qofbook.h
+++ src/engine/qofbook.h
@@ -134,7 +134,13 @@
 #define QOF_BOOK_KVP     "qof-kvp"
 
 /**@}*/
- 
+
+/**
+ * @return The releveant QofEntity for the given GUID across all collections
+ * in the book, or NULL if one cannot be found.
+ **/
+QofEntity* qof_book_get_entity_by_guid( QofBook *book, GUID *entity );
+
 /** deprecated */
 #define qof_book_get_guid(X) qof_entity_get_guid (QOF_ENTITY(X))
 
Index: qofbook.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/engine/qofbook.c,v
retrieving revision 1.10.2.3
retrieving revision 1.10.2.4
diff -Lsrc/engine/qofbook.c -Lsrc/engine/qofbook.c -u -r1.10.2.3 -r1.10.2.4
--- src/engine/qofbook.c
+++ src/engine/qofbook.c
@@ -50,6 +50,8 @@
 #include "qofid-p.h"
 #include "qofobject-p.h"
 
+#include "guid.h"
+
 static short module = MOD_ENGINE;
 
 /* ====================================================================== */
@@ -333,4 +335,41 @@
   return TRUE;
 }
 
+typedef struct _BookLookup {
+  GUID *guid;
+  QofEntity *toRet;
+} BookLookup;
+
+/// QofCollection 'foreach' function to find the QofEntity with the given GUID.
+static
+void
+_entity_by_guid( QofCollection *col, gpointer userData )
+{
+  BookLookup *lookup;
+
+  lookup = (BookLookup*)userData;
+
+  // save some instructions if we've already seen the value.
+  if ( lookup->toRet != NULL )
+    return;
+
+  lookup->toRet = qof_collection_lookup_entity( col, lookup->guid );
+}
+
+QofEntity*
+qof_book_get_entity_by_guid( QofBook *book, GUID *guid )
+{
+  BookLookup lookup;
+
+  if ( ! (guid && book) )
+    return NULL;
+
+  lookup.guid = guid;
+  lookup.toRet = NULL;
+  
+  qof_book_foreach_collection( book, _entity_by_guid, &lookup );
+
+  return lookup.toRet;
+}
+
 /* ========================== END OF FILE =============================== */
Index: top-level.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/gnome/top-level.c,v
retrieving revision 1.140.4.10
retrieving revision 1.140.4.11
diff -Lsrc/gnome/top-level.c -Lsrc/gnome/top-level.c -u -r1.140.4.10 -r1.140.4.11
--- src/gnome/top-level.c
+++ src/gnome/top-level.c
@@ -168,6 +168,7 @@
   {
     GUID guid;
     GNCIdType id_type;
+    QofEntity *qofEnt;
 
     if (!string_to_guid (location + 5, &guid))
     {
@@ -175,7 +176,10 @@
       return FALSE;
     }
 
-    id_type = xaccGUIDType (&guid, gnc_get_current_book ());
+    //id_type = xaccGUIDType (&guid, gnc_get_current_book ());
+    //id_type = 
+    qofEnt = qof_book_get_entity_by_guid( gnc_get_current_book(), &guid );
+    id_type = qofEnt->e_type;
     if (id_type == GNC_ID_NONE || !safe_strcmp (id_type, GNC_ID_NULL))
     {
         result->error_message = g_strdup_printf (_("No such entity: %s"),


More information about the gnucash-changes mailing list