Hi Michael,

> Added. Please try it out to make sure that it still works OK on Windows.

All looks good!
I did need to modify basename() [function doesn't seem to exist in the gcc
cygnus] to the wx equivalent path splitting function to get the doc_names to
load properly (-u diff is below).

Did some minor things too:
Always link and thumbonly reused in write configuration to keep them in
sync.
Only parse out the basename if it was a doc_file/db_file, so that don't lose
part of the channel name if have a dir character or period in a proper
doc_name key (I think that Mac separator is a ':' ).
A variable (foundSection) moved to lowercase (found_section).
Some comments as to why looking for db_ keys are (looking a ways down the
line, in case people are wondering what they are or why they are there).

> BTW, it might be a good idea to change the get_configuration_extension()
> to instead return the *filename* for the config file.

This makes good sense.

Here is the patch:

--- main_dialog.cpp     14 Nov 2001 19:05:11 -0000      1.1.2.5
+++ main_dialog.cpp     15 Nov 2001 00:35:11 -0000
@@ -71,7 +71,7 @@
 // Easier code maintenance if want to add/rearrangement of listctrl's
columns.
 // SECTION_COLUMN needs to be 0 in current code as GetNextItem only seems
to look at
 // the zero column.
-#define SECTION_COLUMN        0   // Listctrol column: Directory stored in
+#define SECTION_COLUMN          0   // Listctrol column: Directory stored
in
 #define NAME_COLUMN             1   // Listctrl column: Channel's name
 #define DUE_COLUMN              2   // Listctrl column: When due

@@ -196,7 +196,7 @@
     wxString configuration_section;   // Section of channel in
configuration file
     int row_number           = 0;     // List row to insert channel
information
     long index               = 0;     // Index counter for looping through
the sections
-    bool foundSection        = FALSE; // To monitor success of getting
first/next group
+    bool found_section       = FALSE; // To monitor success of getting
first/next group
     wxFile file;                      // To make a home.html if missing.

     wxLogDebug( "Starting to load channel sections into listctrl rows" );
@@ -210,9 +210,9 @@

     // TODO: also make the default channel one, in case in is gone.

-    foundSection = the_configuration->GetFirstGroup( configuration_section,
+    found_section =
he_configuration->GetFirstGroup( configuration_section,
                                         index );
-    while ( foundSection ) {
+    while ( found_section ) {
         // Load up the each channel section (group) from the
         // plucker.ini/pluckerrc file
         wxLogDebug( "Configuration section is %s",
@@ -221,21 +221,26 @@
             // TODO: check for illegal characters (spaces, etc) in the
             // section name, and rename the section in the config file
             // as necessary before loading it into listctrl.
-
+
             wxString doc_name;

             doc_name = configuration_section + "/doc_name";
-
+
+            // If no doc_name key, then use the db_name key
+            // The db_name key is the depreciated equivalent of doc_name
key
             if ( ! the_configuration->Exists( doc_name ) )
                 doc_name = configuration_section + "/db_name";
-
-            if ( ! the_configuration->Exists( doc_name ) )
+
+            // If no db_name key either, the the doc_file key as the
doc_name also
+            if ( ! the_configuration->Exists( doc_name ) )
                 doc_name = configuration_section + "/doc_file";
-
-            if ( ! the_configuration->Exists( doc_name ) )
+
+            // The no db_name or doc_file key, then use the db_file key.
+            // The db_file key is the depreciated equivalent of doc_file
key
+            if ( ! the_configuration->Exists( doc_name ) )
                 doc_name = configuration_section + "/db_file";
-
-            // only include channels with an assigned document name
+
+            // Only include channels with an assigned document name
             if ( the_configuration->Exists( doc_name ) ) {
                 wxString channel_name;
                 wxString due_date;
@@ -250,9 +255,13 @@
                 // row. TODO: The 0 in 3rd argument of InsertItem put
                 // as the image index for a little glyph later on.
                 channel_name = the_configuration->Read( doc_name,
-                                                    _T( "Unnamed
Channel") );
-
-                channel_name = basename( channel_name.c_str() );
+                                                    _T( "Unnamed
Channel" ) );
+                // If it was a filename key, then strip off path and the
+                // extension, so only basename left
+                if ( doc_name == configuration_section + "/doc_file" ||
+                     doc_name == configuration_section + "/db_file" ) {
+                    wxSplitPath( channel_name.c_str(), NULL, &channel_name,
NULL );
+                }
                 MAIN_LISTCTRL->SetItem( row_number, NAME_COLUMN,
                                 channel_name, 0 );

@@ -278,7 +287,7 @@
                 // those too. TODO: Copy from the default home.html instead
                 // of making an empty one.
                 home_html = get_plkr_directory( CHANNELS ) + '/' +
-                         configuration_section + '/' + "home.html";
+                            configuration_section + '/' + "home.html";
                 if ( ! wxFileExists( home_html ) ) {
                     file.Create( home_html );
                     file.Close();
@@ -289,7 +298,7 @@
                 row_number++;
             }
         }
-        foundSection =
he_configuration->GetNextGroup( configuration_section,
+        found_section =
he_configuration->GetNextGroup( configuration_section,
                                             index );
     }
 }

--- channel_dialog.cpp  14 Nov 2001 19:05:11 -0000      1.1.2.4
+++ channel_dialog.cpp  15 Nov 2001 00:35:14 -0000
@@ -46,6 +46,8 @@

// -------------------------------------------------------------------------
--------------

 channel_dialog* the_channel_dialog = NULL;
+const long ONLY_THUMBNAIL   = 0;            // For
alt_maxwidth/alt_maxheight
+const long ALWAYS_LINK      = 1000000;      // For
alt_maxwidth/alt_maxheight


// -------------------------------------------------------------------------
--------------
 // Event table: connect the events to the handler functions to process them
@@ -114,8 +116,10 @@

     wxString key;
     wxString doc_name;
-
+
     key = "doc_name";
+
+    // See comments in main_dialog::listctrl_load_rows() about doc_name
     if ( ! the_configuration->Exists( key ) )
         key = "db_name";

@@ -125,8 +129,10 @@
     if ( ! the_configuration->Exists( key ) )
         key = "db_file";

-    doc_name = the_configuration->Read( key, _T( "Unnamed Channel" ) );
-    doc_name = basename( doc_name.c_str() );
+    doc_name = the_configuration->Read( key, _T( "Unnamed Channel" ) );
+    // If a file key, strip off the path and extension, leaving only the
basename
+    if ( key == "doc_file" || key == "db_file" )
+        wxSplitPath( doc_name.c_str(), NULL, &doc_name, NULL );

     XMLCTRL( *the_channel_dialog, "channel_dialog_textctrl", wxTextCtrl )
         ->SetValue( doc_name );
@@ -242,10 +248,9 @@
     wxLogDebug( "Initialized maxheight" );


-    // Some GUI tricks here. Always link by setting a very high number,
Never link by setting
-    // to zero. Else use the specified value.
-    const long ONLY_THUMBNAIL   = 0;
-    const long ALWAYS_LINK      = 1000000;
+    // Some GUI tricks here. Always link by setting a very high number
(ONLY_THUMBNAIL)
+    // Never link by setting to zero (ALWAYS_LINK) [Both defined above].
+    // Else use the specified value.

     long alt_maxwidth;

@@ -254,13 +259,13 @@
         case ALWAYS_LINK:
             XMLCTRL( *the_channel_dialog,
"channel_dialog_images_tab_always_link_radiobutton", wxRadioButton )
                 ->SetValue( TRUE );
-            wxLogDebug( "Initialized alt_maxwidth-height as 1000000" );
+            wxLogDebug( "Initialized alt_maxwidth-height as 1000000
(ALWAYS_LINK)" );
             break;

         case ONLY_THUMBNAIL:
             XMLCTRL( *the_channel_dialog,
"channel_dialog_images_tab_only_thumbnail_radiobutton", wxRadioButton )
                 ->SetValue( TRUE );
-            wxLogDebug( "Initialized alt_maxwidth-height as 0" );
+            wxLogDebug( "Initialized alt_maxwidth-height as 0
(ONLY_THUMBNAIL)" );
             break;

         default:
@@ -520,8 +525,8 @@
         lngy = XMLCTRL( *the_channel_dialog,
"channel_dialog_images_tab_only_link_height_spinctrl", wxSpinCtrl )
                 ->GetValue();
     } else {
-        lngx = 1000000;
-        lngy = 1000000;
+        lngx = ALWAYS_LINK;
+        lngy = ONLY_THUMBNAIL;
     }
     the_configuration->Write( "alt_maxwidth", lngx );
     the_configuration->Write( "alt_maxheight", lngy );

Reply via email to