OSDN Git Service

Establish default preferences for GUI; (cf. MinGW-Feature #2036)
authorKeith Marshall <keithmarshall@users.sourceforge.net>
Fri, 20 Sep 2013 12:05:26 +0000 (13:05 +0100)
committerKeith Marshall <keithmarshall@users.sourceforge.net>
Fri, 20 Sep 2013 12:05:26 +0000 (13:05 +0100)
ChangeLog
src/climain.cpp
src/guiexec.cpp
src/pkgbase.h
src/pkgopts.cpp
xml/profile.xml

index 398cd21..9a689c0 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,23 @@
 2013-09-20  Keith Marshall  <keithmarshall@users.sourceforge.net>
 
+       Establish default preferences for GUI; (cf. MinGW-Feature #2036)
+
+       * src/pkgbase.h (pkgXmlDocument::EstablishPreferences): Adjust its
+       prototype; add argument identifying prospective client classification.
+
+       * src/pkgopts.cpp (client_key): New XML property keyword; define it.
+       (pkgXmlDocument::EstablishPreferences): Implement filter, based on new
+       client classification argument, to restrict preference selection to a
+       matching client class specification.
+
+       * src/climain.cpp (dbase.EstablishPreferences): Filter on class "cli".
+       * src/guiexec.cpp (pkgData->EstablishPreferences): Likewise, on "gui".
+
+       * xml/profile.xml (preferences): Add client="cli" attribute for the
+       existing specification; add another for client="gui".
+
+2013-09-20  Keith Marshall  <keithmarshall@users.sourceforge.net>
+
        Force canonical comparison of shell links; (cf. MinGW-Bug #2054)
 
        * scripts/libexec/unlink.js [FileExists(filename) && (chklink != "")]:
index c2f1f16..f87b9d4 100644 (file)
@@ -4,7 +4,7 @@
  * $Id$
  *
  * Written by Keith Marshall <keithmarshall@users.sourceforge.net>
- * Copyright (C) 2009, 2010, 2011, 2012, MinGW Project
+ * Copyright (C) 2009-2013, MinGW.org Project
  *
  *
  * Implementation of the main program function, which is invoked by
@@ -223,7 +223,7 @@ EXTERN_C int climain( int argc, char **argv )
        /* ...initialise any preferences which the user may
         * have specified within profile.xml...
         */
-       dbase.EstablishPreferences();
+       dbase.EstablishPreferences( "cli" );
 
        /* ...and invoke the appropriate action handler.
         */
index 733a9ed..a4ee329 100644 (file)
@@ -175,9 +175,14 @@ void AppWindowMaker::LoadPackageData( bool force_update )
     throw WTK::runtime_error( "Cannot read package catalogue" );
 
   /* Finally, load the installation records pertaining to
-   * the active system map.
+   * the active system map...
    */
   pkgData->LoadSystemMap();
+
+  /* ...and establish any preferences which the user may have
+   * specified within profile.xml
+   */
+  pkgData->EstablishPreferences( "gui" );
 }
 
 static void pkgInvokeInitDataLoad( void *window )
index 716829c..7c54f71 100644 (file)
@@ -5,7 +5,7 @@
  * $Id$
  *
  * Written by Keith Marshall <keithmarshall@users.sourceforge.net>
- * Copyright (C) 2009, 2010, 2011, 2012, 2013, MinGW.org Project
+ * Copyright (C) 2009-2013, MinGW.org Project
  *
  *
  * Public interface for the package directory management routines;
@@ -409,7 +409,7 @@ class pkgXmlDocument : public TiXmlDocument
      * options, which are specified within profile.xml rather than on
      * the command line.
      */
-    void EstablishPreferences();
+    void EstablishPreferences( const char* = NULL );
 
     /* Method to synchronise the state of the local package manifest
      * with the master copy held on the distribution server.
index 269db24..0412119 100644 (file)
@@ -4,7 +4,7 @@
  * $Id$
  *
  * Written by Keith Marshall <keithmarshall@users.sourceforge.net>
- * Copyright (C) 2012, MinGW Project
+ * Copyright (C) 2012, 2013, MinGW.org Project
  *
  *
  * Implementation of XML interpreter for configuation of preferences.
@@ -83,6 +83,7 @@ class pkgPreferenceEvaluator
 /* XML tag/attribute key names, used exclusively within this module.
  */
 static const char *prefs_key = "preferences";
+static const char *client_key = "client";
 static const char *option_key = "option";
 static const char *value_key = "value";
 
@@ -306,7 +307,7 @@ void pkgPreferenceEvaluator::SetScriptHook( const char *key, ... )
   }
 }
 
-void pkgXmlDocument::EstablishPreferences()
+void pkgXmlDocument::EstablishPreferences( const char *client )
 {
   /* Method to interpret the content of any "preferences" sections
    * appearing within the XML database.
@@ -325,37 +326,44 @@ void pkgXmlDocument::EstablishPreferences()
     pkgXmlNode *prefs = dbase_root->FindFirstAssociate( prefs_key );
     while( prefs != NULL )
     {
-      /* ...and interpret any contained "enable" specifications.
+      /* ...then, for it and any of its siblings which apply within
+       * the active application profile classification...
        */
-      pkgPreferenceEvaluator opt( prefs->FindFirstAssociate( option_key ));
-      while( opt.Current() != NULL )
+      if( (client == NULL)
+      ||  (strcasecmp( client, prefs->GetPropVal( client_key, client )) == 0)  )
       {
-       const char *optname;
-       if( (optname = opt.SetName()) != NULL )
+       /* ...interpret any contained "enable" specifications.
+        */
+       pkgPreferenceEvaluator opt( prefs->FindFirstAssociate( option_key ));
+       while( opt.Current() != NULL )
        {
-         if( opt_strcmp( optname, desktop_option ) == 0 )
-           /*
-            * Enable post-install hook for creation of desktop shortcuts;
-            * by default, these are defined for current user only, but may
-            * optionally be provided for all users.
-            */
-           opt.SetScriptHook( PKG_DESKTOP_HOOK, NULL );
+         const char *optname;
+         if( (optname = opt.SetName()) != NULL )
+         {
+           if( opt_strcmp( optname, desktop_option ) == 0 )
+             /*
+              * Enable post-install hook for creation of desktop shortcuts;
+              * by default, these are defined for current user only, but may
+              * optionally be provided for all users.
+              */
+             opt.SetScriptHook( PKG_DESKTOP_HOOK, NULL );
 
-         else if( opt_strcmp( optname, start_menu_option ) == 0 )
-           /*
-            * Similarly, enable hook for creation of start menu shortcuts.
-            */
-           opt.SetScriptHook( PKG_START_MENU_HOOK, NULL );
+           else if( opt_strcmp( optname, start_menu_option ) == 0 )
+             /*
+              * Similarly, enable hook for creation of start menu shortcuts.
+              */
+             opt.SetScriptHook( PKG_START_MENU_HOOK, NULL );
 
-         else
-           /* Any unrecognised option specification is simply ignored,
-            * after posting an appropriate diagnostic message.
-            */
-           dmh_notify( DMH_WARNING, "unknown option '%s' ignored\n", optname );
+           else
+             /* Any unrecognised option specification is simply ignored,
+              * after posting an appropriate diagnostic message.
+              */
+             dmh_notify( DMH_WARNING, "unknown option '%s' ignored\n", optname );
+         }
+         /* Repeat for any further "enable" specifations...
+          */
+         opt.GetNext( option_key );
        }
-       /* Repeat for any further "enable" specifations...
-        */
-       opt.GetNext( option_key );
       }
       /* ...and for any additional "preferences" sections.
        */
index e76b7e1..9d341b3 100644 (file)
@@ -4,7 +4,7 @@
     $Id$
 
     Written by Keith Marshall  <keithmarshall@users.sourceforge.net>
-    Copyright (C) 2009, 2010, 2012, MinGW Project
+    Copyright (C) 2009, 2010, 2012, 2013, MinGW.org Project
 
 
     Master configuration profile for mingw-get.
@@ -31,7 +31,7 @@
     arising from the use of this software.
   -->
 
-  <preferences>
+  <preferences client="cli">
     <!--
       "preferences" specifications provide a mechanism for defining
       user specified default attributes for command line options such
     <!--option name="start-menu" value="all-users" /-->
   </preferences>
 
+  <preferences client="gui">
+    <!--
+      The preceding "preferences" section applies exclusively to the
+      CLI client, (where command line options may be used); here, we
+      specify defaults for the GUI client, (which provides no support
+      for command line options), such that shortcuts will be created
+      on the desktop, and in the start menu, for the current user.
+
+      Note that matching of the "client" attribute will be performed
+      case-insensitively, against a keyword defined by the respective
+      client; any "preferences" section with no "client" assignment
+      will be matched for ALL clients.
+    -->
+
+    <option name="desktop" />
+    <option name="start-menu" />
+  </preferences>
+
   <repository uri="http://prdownloads.sourceforge.net/mingw/%F.xml.lzma?download">
     <!--
       The "repository" specification identifies the URI where package