Re: Commit: GDA work

From: Rodrigo Moya (rodrigo@gnome-db.org)
Date: Wed Jul 09 2003 - 08:03:11 EDT

  • Next message: Dom Lachowicz: "Re: Commit: GDA work"

    On Wed, 2003-07-09 at 04:22, Dom Lachowicz wrote:
    > Bump required version up to 0.90.0 for GDA and
    > LibGnomeDB
    >
    > Also do a bunch of work toward importing GdaDataModels
    > as tables. Once there's a standard for .connection
    > files being used as queries, we should be able to
    > import a result set as a table.
    >
    > Right now, we have the ability to "paste" a result set
    > in as a table, in theory.
    >
    wow, that's nice, although I haven't been able to test it, since I've
    got my local copy with modifications to add the Tools->Data Sources menu
    item, and it displays:

    DEBUG: DOM: loading plugin
    /opt/gnome/lib/AbiWord-2.0/plugins/libAbiGDA.so
     
    **** (1) Assert ****
    **** (1) UT_SHOULD_NOT_HAPPEN at ap_Menu_Layouts.cpp:334 ****
    **** (1) Continue ? (y/n) [y] :

    see the attached patch to check what I'm doing.

    cheers


    ? acinclude.m4
    ? autom4te.cache
    ? install-sh
    ? missing
    ? mkinstalldirs
    ? plugin.status
    ? tools/gda/unix/.libs
    ? tools/gda/unix/AbiGDA.lo
    ? tools/gda/unix/libAbiGDA.la
    ? tools/google/GNUmakefile
    ? tools/ots/GNUmakefile
    ? tools/ots/xp/GNUmakefile
    ? wp/impexp/OpenWriter/xp/.libs
    ? wp/impexp/OpenWriter/xp/ie_exp_OpenWriter.lo
    ? wp/impexp/OpenWriter/xp/ie_imp_OpenWriter.lo
    ? wp/impexp/OpenWriter/xp/ie_impexp_OpenWriter.lo
    ? wp/impexp/OpenWriter/xp/libAbiOpenWriter.la
    ? wp/impexp/docbook/xp/.libs
    ? wp/impexp/docbook/xp/ie_exp_DocBook.lo
    ? wp/impexp/docbook/xp/ie_imp_DocBook.lo
    ? wp/impexp/docbook/xp/ie_impexp_DocBook.lo
    ? wp/impexp/docbook/xp/libAbiDocBook.la
    Index: tools/gda/unix/AbiGDA.cpp
    ===================================================================
    RCS file: /cvsroot/abiword-plugins/tools/gda/unix/AbiGDA.cpp,v
    retrieving revision 1.8
    diff -u -p -r1.8 AbiGDA.cpp
    --- tools/gda/unix/AbiGDA.cpp 9 Jul 2003 02:34:43 -0000 1.8
    +++ tools/gda/unix/AbiGDA.cpp 9 Jul 2003 12:02:00 -0000
    @@ -54,8 +54,6 @@
     #include <libgnomedb/gnome-db-login.h>
     #include <libgnomedb/gnome-db-util.h>
     
    -static const char* GDA_MenuLabel = "G&DA Database";
    -static const char* GDA_MenuTooltip = "Mailmerge using a database";
     static GdaClient* connection_pool = NULL;
     
     // -----------------------------------------------------------------------
    @@ -352,6 +350,33 @@ GDA_execSQL(AV_View* v, EV_EditMethodCal
             return ret;
     }
     
    +//
    +// GDA_viewDataSources
    +// -------------------
    +static bool
    +GDA_viewDataSources(AV_View* v, EV_EditMethodCallData *d)
    +{
    + char *argv[2];
    +
    + /* run gnome-database-properties config tool */
    + argv[0] = (char *) "gnome-database-properties";
    + argv[1] = NULL;
    +
    + return g_spawn_async (NULL, argv, NULL, G_SPAWN_SEARCH_PATH,
    + NULL, NULL, NULL, NULL);
    +}
    +
    +const static struct {
    + const char * methodName;
    + EV_EditMethod_pFn method;
    + const char * label;
    + const char * description;
    + EV_Menu_LayoutFlags flags; // usually EV_MLF_Normal
    +} gda_menus [] = {
    + { "GDA_execSQL", GDA_execSQL, "G&DA Database", "Mailmerge using a database", EV_MLF_Normal },
    + { "GDA_viewDataSources", GDA_viewDataSources, "Data Sources", "Configure and admin data sources", EV_MLF_Normal }
    +};
    +
     static void
     GDA_removeFromMenus()
     {
    @@ -368,40 +393,30 @@ GDA_removeFromMenus()
             int frameCount = pApp->getFrameCount();
             XAP_Menu_Factory * pFact = pApp->getMenuFactory();
             
    - pFact->removeMenuItem("Main",NULL,GDA_MenuLabel);
    - for(int i = 0; i < frameCount; ++i)
    - {
    - // Get the current frame that we're iterating through.
    - XAP_Frame* pFrame = pApp->getFrame(i);
    - pFrame->rebuildMenus();
    - }
    + UT_uint32 i;
    + for (i = 0; i < G_N_ELEMENTS (gda_menus); i++) {
    + pFact->removeMenuItem("Main",NULL,gda_menus[i].label);
    + }
    +
    + for(int i = 0; i < frameCount; ++i) {
    + // Get the current frame that we're iterating through.
    + XAP_Frame* pFrame = pApp->getFrame(i);
    + pFrame->rebuildMenus();
    + }
     }
     
     static void
     GDA_addToMenus()
     {
    + UT_uint32 i;
    +
             // First we need to get a pointer to the application itself.
             XAP_App *pApp = XAP_App::getApp();
             
    - // Create an EditMethod that will link our method's name with
    - // it's callback function. This is used to link the name to
    - // the callback.
    - EV_EditMethod *myEditMethod = new EV_EditMethod("GDA_execSQL", // name of callback function
    - GDA_execSQL, // callback function itself.
    - 0, // no additional data required.
    - "" // description -- allegedly never used for anything
    - );
    -
             // Now we need to get the EditMethod container for the application.
             // This holds a series of Edit Methods and links names to callbacks.
             EV_EditMethodContainer* pEMC = pApp->getEditMethodContainer();
    -
    - // We have to add our EditMethod to the application's EditMethodList
    - // so that the application will know what callback to call when a call
    - // to "AiksaurusABI_invoke" is received.
    - pEMC->addEditMethod(myEditMethod);
    -
    -
    +
             // Now we need to grab an ActionSet. This is going to be used later
             // on in our for loop. Take a look near the bottom.
             EV_Menu_ActionSet* pActionSet = pApp->getMenuActionSet();
    @@ -414,37 +429,50 @@ GDA_addToMenus()
             
             int frameCount = pApp->getFrameCount();
             XAP_Menu_Factory * pFact = pApp->getMenuFactory();
    -
    - //
    - // Put it in the main menu.
    - //
    - XAP_Menu_Id newID = pFact->addNewMenuAfter("Main",NULL,"&Mail Merge",EV_MLF_Normal);
    - pFact->addNewLabel(NULL,newID,GDA_MenuLabel, GDA_MenuTooltip);
    -
    - // Create the Action that will be called.
    - EV_Menu_Action* myAction = new EV_Menu_Action(newID, // id that the layout said we could use
    - 0, // no, we don't have a sub menu.
    - 1, // yes, we raise a dialog.
    - 0, // no, we don't have a checkbox.
    - 0,
    - "GDA_execSQL", // name of callback function to call.
    - NULL, // don't know/care what this is for
    - NULL // don't know/care what this is for
    - );
    -
    - // Now what we need to do is add this particular action to the ActionSet
    - // of the application. This forms the link between our new ID that we
    - // got for this particular frame with the EditMethod that knows how to
    - // call our callback function.
    -
    - pActionSet->addAction(myAction);
    -
    - for(int i = 0; i < frameCount; ++i)
    - {
    - // Get the current frame that we're iterating through.
    - XAP_Frame* pFrame = pApp->getFrame(i);
    - pFrame->rebuildMenus();
    - }
    +
    + for (i = 0; i < G_N_ELEMENTS (gda_menus); i++) {
    + // Create an EditMethod that will link our method's name with
    + // it's callback function. This is used to link the name to
    + // the callback.
    + EV_EditMethod *myEditMethod = new EV_EditMethod(gda_menus[i].methodName,
    + gda_menus[i].method,
    + 0,
    + "");
    +
    + // We have to add our EditMethod to the application's EditMethodList
    + // so that the application will know what callback to call when a call
    + // to "AiksaurusABI_invoke" is received.
    + pEMC->addEditMethod(myEditMethod);
    +
    + //
    + // Put it in the main menu.
    + //
    + const char *prev = "S&cripts...";
    + if (i != 0)
    + prev = gda_menus[i - 1].label;
    + XAP_Menu_Id newID = pFact->addNewMenuAfter("Main",NULL,
    + prev,
    + gda_menus[i].flags);
    + pFact->addNewLabel(NULL,newID,gda_menus[i].label, gda_menus[i].description);
    +
    + // Create the Action that will be called.
    + EV_Menu_Action* myAction = new EV_Menu_Action(newID, 0, 1, 0, 0,
    + (const char *) gda_menus[i].methodName,
    + NULL, NULL);
    +
    + // Now what we need to do is add this particular action to the ActionSet
    + // of the application. This forms the link between our new ID that we
    + // got for this particular frame with the EditMethod that knows how to
    + // call our callback function.
    +
    + pActionSet->addAction(myAction);
    + }
    +
    + for(int i = 0; i < frameCount; ++i) {
    + // Get the current frame that we're iterating through.
    + XAP_Frame* pFrame = pApp->getFrame(i);
    + pFrame->rebuildMenus();
    + }
     }
     
     // -----------------------------------------------------------------------



    This archive was generated by hypermail 2.1.4 : Wed Jul 09 2003 - 08:16:15 EDT