gnucash stable: Multiple changes pushed

John Ralls jralls at code.gnucash.org
Sun May 3 15:45:00 EDT 2026


Updated	 via  https://github.com/Gnucash/gnucash/commit/67374d45 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/61964312 (commit)
	from  https://github.com/Gnucash/gnucash/commit/6b3e1ea5 (commit)



commit 67374d45cbef52a905a9349867969a58f685751a
Merge: 6b3e1ea5d3 61964312bc
Author: John Ralls <jralls at ceridwen.us>
Date:   Sun May 3 12:44:06 2026 -0700

    Merge Joshua Austill's 'add-port-field-to-db-dialog' into stable.


commit 61964312bc4e6f1ca05d5babcaac677583e319fd
Author: Joshua Austill <jlaustill at gmail.com>
Date:   Wed Apr 22 20:02:57 2026 -0600

    Add port field to database connection dialog
    
    Adds a Port entry field to the database connection UI, positioned
    after Host. The field accepts only digits (enforced via insert-text
    handler), defaults to empty (placeholder shows the DB default), and
    passes the value to gnc_uri_create_uri.
    
    Co-Authored-By: Claude Sonnet 4.6 <noreply at anthropic.com>

diff --git a/gnucash/gnome-utils/dialog-file-access.c b/gnucash/gnome-utils/dialog-file-access.c
index 1db84d2be1..ac82233f56 100644
--- a/gnucash/gnome-utils/dialog-file-access.c
+++ b/gnucash/gnome-utils/dialog-file-access.c
@@ -64,12 +64,15 @@ typedef struct FileAccessWindow
     GtkEntry            *tf_database;
     GtkEntry            *tf_username;
     GtkEntry            *tf_password;
+    GtkEntry            *tf_port;
 } FileAccessWindow;
 
 void gnc_ui_file_access_file_activated_cb( GtkFileChooser *chooser,
         FileAccessWindow *faw );
 void gnc_ui_file_access_response_cb( GtkDialog *, gint, GtkDialog * );
 static void cb_uri_type_changed_cb( GtkComboBoxText* cb );
+static void port_insert_text_cb( GtkEditable *editable, const gchar *text,
+                                 gint length, gint *position, gpointer data );
 
 static gchar*
 geturl( FileAccessWindow* faw )
@@ -82,6 +85,8 @@ geturl( FileAccessWindow* faw )
     gchar* type = NULL;
     /* Not const as return value of gtk_file_chooser_get_filename must be freed */
     gchar* path = NULL;
+    gint32 port = 0;
+    const gchar* port_text = NULL;
 
     type = gtk_combo_box_text_get_active_text (faw->cb_uri_type);
     if (gnc_uri_is_file_scheme (type))
@@ -101,7 +106,12 @@ geturl( FileAccessWindow* faw )
         password = gtk_entry_get_text( faw->tf_password );
     }
 
-    url = gnc_uri_create_uri (type, host, 0, username, password, path);
+    g_assert (faw->tf_port != NULL);
+    port_text = gtk_entry_get_text (faw->tf_port);
+    if (port_text && *port_text)
+        port = atoi (port_text) & 0xffff;
+
+    url = gnc_uri_create_uri (type, host, port, username, password, path);
 
     g_free (type);
     g_free (path);
@@ -210,6 +220,8 @@ set_widget_sensitivity_for_uri_type( FileAccessWindow* faw, const gchar* uri_typ
     else if ( strcmp( uri_type, "mysql" ) == 0 || strcmp( uri_type, "postgres" ) == 0 )
     {
         set_widget_sensitivity( faw, /* is_file_based_uri */ FALSE );
+        gtk_entry_set_placeholder_text( faw->tf_port,
+            strcmp( uri_type, "mysql" ) == 0 ? _("Default: 3306") : _("Default: 5432") );
     }
     else
     {
@@ -217,6 +229,20 @@ set_widget_sensitivity_for_uri_type( FileAccessWindow* faw, const gchar* uri_typ
     }
 }
 
+static void
+port_insert_text_cb( GtkEditable *editable, const gchar *text, gint length,
+                     gint *position, gpointer data )
+{
+    for ( gint i = 0; i < length; i++ )
+    {
+        if ( !g_ascii_isdigit( text[i] ) )
+        {
+            g_signal_stop_emission_by_name( G_OBJECT(editable), "insert-text" );
+            return;
+        }
+    }
+}
+
 static void
 cb_uri_type_changed_cb( GtkComboBoxText* cb )
 {
@@ -308,6 +334,10 @@ gnc_ui_file_access (GtkWindow *parent, int type)
     gtk_entry_set_text( faw->tf_database, default_db );
     faw->tf_username = GTK_ENTRY(gtk_builder_get_object (builder, "tf_username" ));
     faw->tf_password = GTK_ENTRY(gtk_builder_get_object (builder, "tf_password" ));
+    faw->tf_port = GTK_ENTRY(gtk_builder_get_object (builder, "tf_port" ));
+    g_signal_connect( G_OBJECT(faw->tf_port), "insert-text",
+                      G_CALLBACK(port_insert_text_cb), NULL );
+    gtk_entry_set_max_length( faw->tf_port, 5 );
 
     switch ( type )
     {
diff --git a/gnucash/gtkbuilder/dialog-file-access.glade b/gnucash/gtkbuilder/dialog-file-access.glade
index 3cd7ae693f..0f9281eb52 100644
--- a/gnucash/gtkbuilder/dialog-file-access.glade
+++ b/gnucash/gtkbuilder/dialog-file-access.glade
@@ -162,7 +162,7 @@
             <property name="label-xalign">0</property>
             <property name="shadow-type">in</property>
             <child>
-              <!-- n-columns=2 n-rows=4 -->
+              <!-- n-columns=2 n-rows=5 rows: host, port, database, username, password -->
               <object class="GtkGrid">
                 <property name="visible">True</property>
                 <property name="can-focus">False</property>
@@ -192,7 +192,7 @@
                   </object>
                   <packing>
                     <property name="left-attach">0</property>
-                    <property name="top-attach">1</property>
+                    <property name="top-attach">2</property>
                   </packing>
                 </child>
                 <child>
@@ -205,7 +205,7 @@
                   </object>
                   <packing>
                     <property name="left-attach">0</property>
-                    <property name="top-attach">2</property>
+                    <property name="top-attach">3</property>
                   </packing>
                 </child>
                 <child>
@@ -218,7 +218,7 @@
                   </object>
                   <packing>
                     <property name="left-attach">0</property>
-                    <property name="top-attach">3</property>
+                    <property name="top-attach">4</property>
                   </packing>
                 </child>
                 <child>
@@ -233,7 +233,7 @@
                   </object>
                   <packing>
                     <property name="left-attach">1</property>
-                    <property name="top-attach">3</property>
+                    <property name="top-attach">4</property>
                   </packing>
                 </child>
                 <child>
@@ -247,7 +247,7 @@
                   </object>
                   <packing>
                     <property name="left-attach">1</property>
-                    <property name="top-attach">2</property>
+                    <property name="top-attach">3</property>
                   </packing>
                 </child>
                 <child>
@@ -261,7 +261,7 @@
                   </object>
                   <packing>
                     <property name="left-attach">1</property>
-                    <property name="top-attach">1</property>
+                    <property name="top-attach">2</property>
                   </packing>
                 </child>
                 <child>
@@ -278,6 +278,32 @@
                     <property name="top-attach">0</property>
                   </packing>
                 </child>
+                <child>
+                  <object class="GtkLabel" id="label7">
+                    <property name="visible">True</property>
+                    <property name="can-focus">False</property>
+                    <property name="halign">end</property>
+                    <property name="label" translatable="yes">Port</property>
+                    <property name="justify">right</property>
+                  </object>
+                  <packing>
+                    <property name="left-attach">0</property>
+                    <property name="top-attach">1</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkEntry" id="tf_port">
+                    <property name="visible">True</property>
+                    <property name="can-focus">True</property>
+                    <property name="activates-default">True</property>
+                    <property name="primary-icon-activatable">False</property>
+                    <property name="secondary-icon-activatable">False</property>
+                  </object>
+                  <packing>
+                    <property name="left-attach">1</property>
+                    <property name="top-attach">1</property>
+                  </packing>
+                </child>
               </object>
             </child>
             <child type="label">



Summary of changes:
 gnucash/gnome-utils/dialog-file-access.c    | 32 ++++++++++++++++++++++-
 gnucash/gtkbuilder/dialog-file-access.glade | 40 ++++++++++++++++++++++++-----
 2 files changed, 64 insertions(+), 8 deletions(-)



More information about the gnucash-changes mailing list