[Gnucash-changes] r13470 - gnucash/trunk - Update the preferences dialog to allow any unicode character as the

David Hampton hampton at cvs.gnucash.org
Sat Mar 4 01:49:24 EST 2006


Author: hampton
Date: 2006-03-04 01:49:23 -0500 (Sat, 04 Mar 2006)
New Revision: 13470
Trac: http://svn.gnucash.org/trac/changeset/13470

Modified:
   gnucash/trunk/ChangeLog
   gnucash/trunk/src/app-utils/gnc-ui-util.c
   gnucash/trunk/src/engine/Account.c
   gnucash/trunk/src/gnome-utils/dialog-preferences.c
   gnucash/trunk/src/gnome-utils/glade/preferences.glade
   gnucash/trunk/src/gnome/schemas/apps_gnucash_general.schemas.in
Log:
Update the preferences dialog to allow any unicode character as the
separator.


Modified: gnucash/trunk/ChangeLog
===================================================================
--- gnucash/trunk/ChangeLog	2006-03-04 05:10:15 UTC (rev 13469)
+++ gnucash/trunk/ChangeLog	2006-03-04 06:49:23 UTC (rev 13470)
@@ -1,3 +1,12 @@
+2006-03-04  David Hampton  <hampton at employees.org>
+
+	* src/gnome-utils/dialog-preferences.c:
+	* src/gnome-utils/glade/preferences.glade:
+	* src/gnome/schemas/apps_gnucash_general.schemas.in:
+	* src/engine/Account.c:
+	* src/app-utils/gnc-ui-util.c: Update the preferences dialog to
+	allow any unicode character as the separator.
+
 2006-03-03  David Hampton  <hampton at employees.org>
 
 	* numerous: Convert the account separator from a single character

Modified: gnucash/trunk/src/app-utils/gnc-ui-util.c
===================================================================
--- gnucash/trunk/src/app-utils/gnc-ui-util.c	2006-03-04 05:10:15 UTC (rev 13469)
+++ gnucash/trunk/src/app-utils/gnc-ui-util.c	2006-03-04 06:49:23 UTC (rev 13470)
@@ -74,7 +74,7 @@
 
   string = gnc_gconf_get_string(GCONF_GENERAL, KEY_ACCOUNT_SEPARATOR, NULL);
 
-  if (!string || safe_strcmp(string, "colon") == 0)
+  if (!string || !*string || safe_strcmp(string, "colon") == 0)
     separator = ":";
   else if (safe_strcmp(string, "slash") == 0)
     separator = "/";

Modified: gnucash/trunk/src/engine/Account.c
===================================================================
--- gnucash/trunk/src/engine/Account.c	2006-03-04 05:10:15 UTC (rev 13469)
+++ gnucash/trunk/src/engine/Account.c	2006-03-04 06:49:23 UTC (rev 13470)
@@ -80,7 +80,8 @@
   gint count;
 
   uc = g_utf8_get_char_validated(separator, -1);
-  if ((uc == (gunichar)-2) || (uc == (gunichar)-1)) {
+  if ((uc == (gunichar)-2) || (uc == (gunichar)-1) || g_unichar_isalnum(uc)) {
+    account_uc_separator = ':';
     strcpy(account_separator, ":");
     return;
   }

Modified: gnucash/trunk/src/gnome/schemas/apps_gnucash_general.schemas.in
===================================================================
--- gnucash/trunk/src/gnome/schemas/apps_gnucash_general.schemas.in	2006-03-04 05:10:15 UTC (rev 13469)
+++ gnucash/trunk/src/gnome/schemas/apps_gnucash_general.schemas.in	2006-03-04 06:49:23 UTC (rev 13470)
@@ -27,11 +27,7 @@
       <default>colon</default>
       <locale name="C">
         <short>Character to use as separator between account names</short>
-        <long>
-	  This setting determines the character that will be used
-	  between components of an account name.  Possible choices are
-	  "colon" "slash", "backslash", "dash" and "period".
-	</long>
+        <long>This setting determines the character that will be used between components of an account name.  Possible values are any single non-alphanumeric unicode character, or any of the following strings: "colon" "slash", "backslash", "dash" and "period".</long>
       </locale>
     </schema>
 

Modified: gnucash/trunk/src/gnome-utils/dialog-preferences.c
===================================================================
--- gnucash/trunk/src/gnome-utils/dialog-preferences.c	2006-03-04 05:10:15 UTC (rev 13469)
+++ gnucash/trunk/src/gnome-utils/dialog-preferences.c	2006-03-04 06:49:23 UTC (rev 13470)
@@ -59,6 +59,7 @@
 #include "config.h"
 
 #include <gtk/gtk.h>
+#include <glib/gi18n.h>
 #include <glade/glade.h>
 
 #include "dialog-utils.h"
@@ -113,6 +114,31 @@
 GSList *add_ins = NULL;
 
 
+/** This function is called whenever the account separator is changed
+ *  in gconf.  It updates the label in the "Account" page of the
+ *  preferences dialog.
+ *
+ *  @internal
+ *
+ *  @param unused A pointer to the changed gconf entry.
+ *  
+ *  @param dialog A pointer to the preferences dialog.
+ */
+static void
+gnc_account_separator_prefs_cb (GConfEntry *unused, GtkWidget *dialog)
+{
+  GtkWidget *label;
+  gchar *sample;
+
+  label = gnc_glade_lookup_widget(dialog, "sample_account");
+  sample = g_strjoin(gnc_get_account_separator_string(),
+		     _("Income"), _("Salary"), _("Taxable"), NULL);
+  DEBUG(" Label set to '%s'", sample);
+  gtk_label_set_text(GTK_LABEL(label), sample);
+  g_free(sample);
+}
+
+
 /** This function compares two add-ins to see if they specify the same
  *  tab name.
  *
@@ -983,6 +1009,77 @@
 /**********/
 
 
+/** The user changed a gtk entry.  Update gconf.
+ *
+ *  @internal
+ *
+ *  @param entry A pointer to the entry that was changed.
+ *  
+ *  @param user_data Unused.
+ */
+static void
+gnc_prefs_entry_user_cb (GtkEntry *entry,
+			 gpointer user_data)
+{
+  const gchar *name, *text;
+
+  g_return_if_fail(GTK_IS_ENTRY(entry));
+  name = gtk_widget_get_name(GTK_WIDGET(entry)) + PREFIX_LEN;
+  text = gtk_entry_get_text(entry);
+  DEBUG("Entry %s set to '%s'", name, text);
+  gnc_gconf_set_string(name, NULL, text, NULL);
+}
+
+
+/** A gtk entry was updated in gconf.  Update the user visible dialog.
+ *
+ *  @internal
+ *
+ *  @param entry A pointer to the gtk entry that changed.
+ *
+ *  @param value The new value of the combo box.
+ */
+static void
+gnc_prefs_entry_gconf_cb (GtkEntry *entry,
+			  const gchar *value)
+{
+  g_return_if_fail(GTK_IS_ENTRY(entry));
+  ENTER("entry %p, value '%s'", entry, value);
+  g_signal_handlers_block_by_func(G_OBJECT(entry),
+				 G_CALLBACK(gnc_prefs_entry_user_cb),
+				 NULL);
+  gtk_entry_set_text(entry, value);
+  g_signal_handlers_unblock_by_func(G_OBJECT(entry),
+			   G_CALLBACK(gnc_prefs_entry_user_cb), NULL);
+  LEAVE(" ");
+}
+
+
+/** Connect a entry widget to the user callback function.  Set the
+ *  starting state of the entry from its value in gconf.
+ *
+ *  @internal
+ *
+ *  @param entry A pointer to the entry that should be connected.
+ */
+static void
+gnc_prefs_connect_entry (GtkEntry *entry)
+{
+  const gchar *name, *text;
+
+  g_return_if_fail(GTK_IS_ENTRY(entry));
+  name = gtk_widget_get_name(GTK_WIDGET(entry)) + PREFIX_LEN;
+  text = gnc_gconf_get_string(name, NULL, NULL);
+  gtk_entry_set_text(GTK_ENTRY(entry), text ? text : "");
+  DEBUG(" Entry %s set to '%s'", name, text);
+  g_signal_connect(G_OBJECT(entry), "changed",
+		   G_CALLBACK(gnc_prefs_entry_user_cb), NULL);
+}
+
+
+/**********/
+
+
 /** The user changed a GncPeriodSelect widget.  Update gconf.
  *  GncPeriodSelect choices are stored as an int.
  *
@@ -1235,6 +1332,9 @@
   } else if (GTK_IS_COMBO_BOX(widget)) {
     DEBUG("  %s - combo box", name);
     gnc_prefs_connect_combo_box(GTK_COMBO_BOX(widget));
+  } else if (GTK_IS_ENTRY(widget)) {
+    DEBUG("  %s - entry", name);
+    gnc_prefs_connect_entry(GTK_ENTRY(widget));
   } else {
     DEBUG("  %s - unsupported %s", name,
 	  G_OBJECT_TYPE_NAME(G_OBJECT(widget)));
@@ -1306,6 +1406,8 @@
   label = glade_xml_get_widget(xml, "locale_currency2");
   gtk_label_set_label(GTK_LABEL(label), currency_name);
 
+  gnc_account_separator_prefs_cb(NULL, dialog);
+
   LEAVE("dialog %p", dialog);
   return dialog;
 }
@@ -1442,6 +1544,10 @@
       DEBUG("widget %p - combo_box", widget);
       gnc_prefs_combo_box_gconf_cb(GTK_COMBO_BOX(widget),
 				   gconf_value_get_int(entry->value));
+    } else if (GTK_IS_ENTRY(widget)) {
+      DEBUG("widget %p - entry", widget);
+      gnc_prefs_entry_gconf_cb(GTK_ENTRY(widget),
+			       gconf_value_get_string(entry->value));
     } else {
       DEBUG("widget %p - unsupported %s", widget,
 	    G_OBJECT_TYPE_NAME(G_OBJECT(widget)));
@@ -1523,8 +1629,12 @@
 
   gnc_gconf_add_notification(G_OBJECT(dialog), NULL,
 			     gnc_preferences_gconf_changed);
+  gnc_gconf_general_register_cb(KEY_ACCOUNT_SEPARATOR,
+				(GncGconfGeneralCb)gnc_account_separator_prefs_cb,
+				dialog);
   gnc_register_gui_component(DIALOG_PREFERENCES_CM_CLASS,
 			     NULL, close_handler, dialog);
+
   LEAVE(" ");
 }
 

Modified: gnucash/trunk/src/gnome-utils/glade/preferences.glade
===================================================================
--- gnucash/trunk/src/gnome-utils/glade/preferences.glade	2006-03-04 05:10:15 UTC (rev 13469)
+++ gnucash/trunk/src/gnome-utils/glade/preferences.glade	2006-03-04 06:49:23 UTC (rev 13470)
@@ -439,127 +439,6 @@
 	      </child>
 
 	      <child>
-		<widget class="GtkRadioButton" id="gconf/general/account_separator/dash">
-		  <property name="visible">True</property>
-		  <property name="tooltip" translatable="yes">Income-Salary-Taxable</property>
-		  <property name="can_focus">True</property>
-		  <property name="label" translatable="yes">- (_Dash)</property>
-		  <property name="use_underline">True</property>
-		  <property name="relief">GTK_RELIEF_NORMAL</property>
-		  <property name="focus_on_click">True</property>
-		  <property name="active">False</property>
-		  <property name="inconsistent">False</property>
-		  <property name="draw_indicator">True</property>
-		</widget>
-		<packing>
-		  <property name="left_attach">0</property>
-		  <property name="right_attach">1</property>
-		  <property name="top_attach">2</property>
-		  <property name="bottom_attach">3</property>
-		  <property name="x_padding">12</property>
-		  <property name="x_options">fill</property>
-		  <property name="y_options"></property>
-		</packing>
-	      </child>
-
-	      <child>
-		<widget class="GtkRadioButton" id="gconf/general/account_separator/period">
-		  <property name="visible">True</property>
-		  <property name="tooltip" translatable="yes">Income.Salary.Taxable</property>
-		  <property name="can_focus">True</property>
-		  <property name="label" translatable="yes">. (_Period)</property>
-		  <property name="use_underline">True</property>
-		  <property name="relief">GTK_RELIEF_NORMAL</property>
-		  <property name="focus_on_click">True</property>
-		  <property name="active">False</property>
-		  <property name="inconsistent">False</property>
-		  <property name="draw_indicator">True</property>
-		  <property name="group">gconf/general/account_separator/dash</property>
-		</widget>
-		<packing>
-		  <property name="left_attach">1</property>
-		  <property name="right_attach">2</property>
-		  <property name="top_attach">2</property>
-		  <property name="bottom_attach">3</property>
-		  <property name="x_options">fill</property>
-		  <property name="y_options"></property>
-		</packing>
-	      </child>
-
-	      <child>
-		<widget class="GtkRadioButton" id="gconf/general/account_separator/slash">
-		  <property name="visible">True</property>
-		  <property name="tooltip" translatable="yes">Income/Salary/Taxable</property>
-		  <property name="can_focus">True</property>
-		  <property name="label" translatable="yes">/ (_Slash)</property>
-		  <property name="use_underline">True</property>
-		  <property name="relief">GTK_RELIEF_NORMAL</property>
-		  <property name="focus_on_click">True</property>
-		  <property name="active">False</property>
-		  <property name="inconsistent">False</property>
-		  <property name="draw_indicator">True</property>
-		  <property name="group">gconf/general/account_separator/dash</property>
-		</widget>
-		<packing>
-		  <property name="left_attach">1</property>
-		  <property name="right_attach">2</property>
-		  <property name="top_attach">1</property>
-		  <property name="bottom_attach">2</property>
-		  <property name="x_options">fill</property>
-		  <property name="y_options"></property>
-		</packing>
-	      </child>
-
-	      <child>
-		<widget class="GtkRadioButton" id="gconf/general/account_separator/backslash">
-		  <property name="visible">True</property>
-		  <property name="tooltip" translatable="yes">Income\Salary\Taxable</property>
-		  <property name="can_focus">True</property>
-		  <property name="label" translatable="yes">\ (_Backslash)</property>
-		  <property name="use_underline">True</property>
-		  <property name="relief">GTK_RELIEF_NORMAL</property>
-		  <property name="focus_on_click">True</property>
-		  <property name="active">False</property>
-		  <property name="inconsistent">False</property>
-		  <property name="draw_indicator">True</property>
-		  <property name="group">gconf/general/account_separator/dash</property>
-		</widget>
-		<packing>
-		  <property name="left_attach">2</property>
-		  <property name="right_attach">3</property>
-		  <property name="top_attach">1</property>
-		  <property name="bottom_attach">2</property>
-		  <property name="x_options">fill</property>
-		  <property name="y_options"></property>
-		</packing>
-	      </child>
-
-	      <child>
-		<widget class="GtkRadioButton" id="gconf/general/account_separator/colon">
-		  <property name="visible">True</property>
-		  <property name="tooltip" translatable="yes">Income:Salary:Taxable</property>
-		  <property name="can_focus">True</property>
-		  <property name="label" translatable="yes">: (Co_lon)</property>
-		  <property name="use_underline">True</property>
-		  <property name="relief">GTK_RELIEF_NORMAL</property>
-		  <property name="focus_on_click">True</property>
-		  <property name="active">False</property>
-		  <property name="inconsistent">False</property>
-		  <property name="draw_indicator">True</property>
-		  <property name="group">gconf/general/account_separator/dash</property>
-		</widget>
-		<packing>
-		  <property name="left_attach">0</property>
-		  <property name="right_attach">1</property>
-		  <property name="top_attach">1</property>
-		  <property name="bottom_attach">2</property>
-		  <property name="x_padding">12</property>
-		  <property name="x_options">fill</property>
-		  <property name="y_options"></property>
-		</packing>
-	      </child>
-
-	      <child>
 		<widget class="GtkLabel" id="label79">
 		  <property name="visible">True</property>
 		  <property name="label" translatable="yes"></property>
@@ -723,6 +602,102 @@
 		  <property name="y_options">fill</property>
 		</packing>
 	      </child>
+
+	      <child>
+		<widget class="GtkEntry" id="gconf/general/account_separator">
+		  <property name="visible">True</property>
+		  <property name="tooltip" translatable="yes">The character that will be used between components of an account name.  Legal values are any single non-alphanumeric unicode character, or any of the following strings: &quot;colon&quot; &quot;slash&quot;, &quot;backslash&quot;, &quot;dash&quot; and &quot;period&quot;.</property>
+		  <property name="can_focus">True</property>
+		  <property name="editable">True</property>
+		  <property name="visibility">True</property>
+		  <property name="max_length">0</property>
+		  <property name="text" translatable="yes"></property>
+		  <property name="has_frame">True</property>
+		  <property name="invisible_char">*</property>
+		  <property name="activates_default">False</property>
+		</widget>
+		<packing>
+		  <property name="left_attach">1</property>
+		  <property name="right_attach">2</property>
+		  <property name="top_attach">1</property>
+		  <property name="bottom_attach">2</property>
+		  <property name="y_options"></property>
+		</packing>
+	      </child>
+
+	      <child>
+		<widget class="GtkLabel" id="sample_account">
+		  <property name="visible">True</property>
+		  <property name="label" translatable="yes"></property>
+		  <property name="use_underline">False</property>
+		  <property name="use_markup">False</property>
+		  <property name="justify">GTK_JUSTIFY_LEFT</property>
+		  <property name="wrap">False</property>
+		  <property name="selectable">False</property>
+		  <property name="xalign">0</property>
+		  <property name="yalign">0.5</property>
+		  <property name="xpad">0</property>
+		  <property name="ypad">0</property>
+		</widget>
+		<packing>
+		  <property name="left_attach">1</property>
+		  <property name="right_attach">2</property>
+		  <property name="top_attach">2</property>
+		  <property name="bottom_attach">3</property>
+		  <property name="x_options">fill</property>
+		  <property name="y_options"></property>
+		</packing>
+	      </child>
+
+	      <child>
+		<widget class="GtkLabel" id="label108">
+		  <property name="visible">True</property>
+		  <property name="label" translatable="yes">Character:</property>
+		  <property name="use_underline">False</property>
+		  <property name="use_markup">False</property>
+		  <property name="justify">GTK_JUSTIFY_LEFT</property>
+		  <property name="wrap">False</property>
+		  <property name="selectable">False</property>
+		  <property name="xalign">0</property>
+		  <property name="yalign">0.5</property>
+		  <property name="xpad">0</property>
+		  <property name="ypad">0</property>
+		</widget>
+		<packing>
+		  <property name="left_attach">0</property>
+		  <property name="right_attach">1</property>
+		  <property name="top_attach">1</property>
+		  <property name="bottom_attach">2</property>
+		  <property name="x_padding">12</property>
+		  <property name="x_options">fill</property>
+		  <property name="y_options"></property>
+		</packing>
+	      </child>
+
+	      <child>
+		<widget class="GtkLabel" id="label109">
+		  <property name="visible">True</property>
+		  <property name="label" translatable="yes">Sample:</property>
+		  <property name="use_underline">False</property>
+		  <property name="use_markup">False</property>
+		  <property name="justify">GTK_JUSTIFY_LEFT</property>
+		  <property name="wrap">False</property>
+		  <property name="selectable">False</property>
+		  <property name="xalign">0</property>
+		  <property name="yalign">0.5</property>
+		  <property name="xpad">0</property>
+		  <property name="ypad">0</property>
+		</widget>
+		<packing>
+		  <property name="left_attach">0</property>
+		  <property name="right_attach">1</property>
+		  <property name="top_attach">2</property>
+		  <property name="bottom_attach">3</property>
+		  <property name="x_padding">12</property>
+		  <property name="x_options">fill</property>
+		  <property name="y_options"></property>
+		</packing>
+	      </child>
 	    </widget>
 	    <packing>
 	      <property name="tab_expand">False</property>



More information about the gnucash-changes mailing list