[Gnucash-changes] 2005-04-24 Joshua Sled <jsled@asynchronous.org> *

Joshua Sled jsled at cvs.gnucash.org
Mon Apr 25 00:00:44 EDT 2005


Log Message:
-----------
2005-04-24  Joshua Sled  <jsled at asynchronous.org>

	* src/gnome/window-main-summarybar.c: Switch from using a gtk_select
	with locally-defined widgets to a GtkListStore backing a standard
	combo box.  Re-define the layout a bit, but it's still ugly.
	* src/gnome-utils/gtkselect.[ch]: Dead.

Tags:
----
gnucash-gnome2-dev

Modified Files:
--------------
    gnucash:
        ChangeLog
        GNOME2_STATUS
    gnucash/src/gnome:
        window-main-summarybar.c

Removed Files:
-------------
    gnucash/src/gnome-utils:
        gtkselect.c
        gtkselect.h

Revision Data
-------------
Index: ChangeLog
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/ChangeLog,v
retrieving revision 1.1487.2.195
retrieving revision 1.1487.2.196
diff -LChangeLog -LChangeLog -u -r1.1487.2.195 -r1.1487.2.196
--- ChangeLog
+++ ChangeLog
@@ -1,3 +1,10 @@
+2005-04-24  Joshua Sled  <jsled at asynchronous.org>
+
+	* src/gnome/window-main-summarybar.c: Switch from using a gtk_select
+	with locally-defined widgets to a GtkListStore backing a standard
+	combo box.  Re-define the layout a bit, but it's still ugly.
+	* src/gnome-utils/gtkselect.[ch]: Dead.
+	
 2005-04-24  David Hampton  <hampton at employees.org>
 
 	* gnucash/src/core-utils/gnc-gconf-utils.[ch]:
Index: GNOME2_STATUS
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/Attic/GNOME2_STATUS,v
retrieving revision 1.1.2.47
retrieving revision 1.1.2.48
diff -LGNOME2_STATUS -LGNOME2_STATUS -u -r1.1.2.47 -r1.1.2.48
--- GNOME2_STATUS
+++ GNOME2_STATUS
@@ -1,5 +1,8 @@
 # -*- reStructuredText -*-
 
+Intro
+-----
+
 This is a ad-hoc list of list of what works and doesn't work in the g2
 port of gnucash.  The plan is to finish porting those parts of gnucash
 that have already been started (i.e. new windowing system, account
@@ -10,9 +13,9 @@
 release out the door and not stall it until all the deprecated
 functionality has been removed.
 
-========================================
-   Last sync with HEAD on 2005-04-02
-========================================
++--------------------------------------+
+|  Last sync with HEAD on 2005-04-02   |
++--------------------------------------+
 
 ========================================
               DONE
@@ -67,11 +70,30 @@
             General Notes
 ========================================
 
+Resources
+---------
+- Porting applications to the GNOME 2.0 Platform -- http://developer.gnome.org/dotplan/porting/
+  - Should switch from `gnome_config` to gconf...
+    - Introduction to GConf -- http://developer.gnome.org/feature/archive/gconf/gconf.html
+
 - General
+  - Startup CRITICAL errors...
+
+    [jsled at phoenix:~/stuff/proj/gnucash/src-g2/gnucash]$ /opt/gnc-g2-unstable/bin/gnucash
+    (gnucash:7823): GLib-GObject-CRITICAL **: file gvaluetypes.c: line 741 (g_value_set_string): assertion `G_VALUE_HOLDS_STRING (value)' failed
+    (gnucash:7823): GLib-GObject-CRITICAL **: file gobject.c: line 1239 (g_object_set_property): assertion `G_IS_VALUE (value)' failed
+    (gnucash:7823): GLib-GObject-CRITICAL **: file gvalue.c: line 149 (g_value_unset): assertion `G_IS_VALUE (value)' failed
+    (gnucash:7823): GLib-GObject-CRITICAL **: file gvaluetypes.c: line 741 (g_value_set_string): assertion `G_VALUE_HOLDS_STRING (value)' failed
+    (gnucash:7823): GLib-GObject-CRITICAL **: file gobject.c: line 1239 (g_object_set_property): assertion `G_IS_VALUE (value)' failed
+    (gnucash:7823): GLib-GObject-CRITICAL **: file gvalue.c: line 149 (g_value_unset): assertion `G_IS_VALUE (value)' failed
+    (gnucash:7823): GLib-GObject-CRITICAL **: file gvaluetypes.c: line 741 (g_value_set_string): assertion `G_VALUE_HOLDS_STRING (value)' failed
+    (gnucash:7823): GLib-GObject-CRITICAL **: file gobject.c: line 1239 (g_object_set_property): assertion `G_IS_VALUE (value)' failed
+    (gnucash:7823): GLib-GObject-CRITICAL **: file gvalue.c: line 149 (g_value_unset): assertion `G_IS_VALUE (value)' failed
+    Use of deprecated SAXv1 function getLineNumber
 
   - Window size/position not being saved or used.
 
-    - We used to do this via Gnome MDI support, but now we will need to
+    - Gnome MDI support used to handle this for us, but now we will need to
       manage it ourselves. :/
 
   - Weird pango_layout_set_text "string not UTF-8" issues reported by Neil Williams:
@@ -82,12 +104,6 @@
 
 - Main Window
 
-  - Summary Bar
-
-    - Summarybar restored into GncMainWindow UI; summary-select list does not
-      respond to button-pressing.  The problem is that the widget
-      never sees the button_press_event.
-
   - [low-priority] New registers should open in new top-level windows.
 
 - Register Core - mostly functional
@@ -126,10 +142,11 @@
         #11 0x40327076 in g_signal_emit_by_name () from /usr/lib/libgobject-2.0.so.0
         #12 0x40326047 in g_signal_emit_valist () from /usr/lib/libgobject-2.0.so.0
 
-- Find - mostly functional; creating a search creates a search results tab in
-  the main window, seemingly populated correctly.
+- Transfer
 
-  - There's no way to edit/refine a search.
+  - Top 5 fields and don't expand width-wise.
+
+  - Bottom 2 fields [Currency Transfer] don't expand width-wise.
 
 - View Lots
 
@@ -185,6 +202,8 @@
     in the new layout.  How would this work with the sub-tabs?  Have to think
     about this some more.
 
+    - The druid for 'New' is created underneath the Budget-list window.
+
   - Probably more TODO but these are the main points.
 
 - Preferences
@@ -249,9 +268,16 @@
   - Rename "New Account Tree" to "Display Account Tree" as "New" gives the
     impression that a creation of something will occur.  PJK
 
+- Find
+
+  - There's no way to edit/refine a search.
+    [There's no way to do so in 1.8, either...]
 
 -----------------------------------------
 <#GOG> ----------------------------------
+
+These are notes jsled was using during the GOG hack-porting effort.
+
 [dc:created 2004-12-17]
 
 gog-guru.c
Index: window-main-summarybar.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/gnome/window-main-summarybar.c,v
retrieving revision 1.12.4.4
retrieving revision 1.12.4.5
diff -Lsrc/gnome/window-main-summarybar.c -Lsrc/gnome/window-main-summarybar.c -u -r1.12.4.4 -r1.12.4.5
--- src/gnome/window-main-summarybar.c
+++ src/gnome/window-main-summarybar.c
@@ -3,6 +3,7 @@
  * Copyright (C) 1998,1999 Jeremy Collins	                    *
  * Copyright (C) 1998,1999,2000 Linas Vepstas                       *
  * Copyright (C) 2001 Bill Gribble                                  *
+ * Copyright (C) 2005 Joshua Sled <jsled at asynchronous.org>          *
  *                                                                  *
  * This program is free software; you can redistribute it and/or    *
  * modify it under the terms of the GNU General Public License as   *
@@ -36,7 +37,6 @@
 #include "gnc-euro.h"
 #include "gnc-ui-util.h"
 #include "gnc-ui.h"
-#include "gtkselect.h"
 #include "messages.h"
 #include "option-util.h"
 #include "top-level.h"
@@ -46,20 +46,24 @@
 typedef struct {
   GtkWidget * hbox;
   GtkWidget * totals_combo;
-  GList     * totals_list; 
+  GtkListStore *datamodel;
   int       component_id;
   SCM       callback_id;
 } GNCMainSummary;
 
 #define WINDOW_SUMMARYBAR_CM_CLASS "summary-bar"
 
-/* An accumulator for a given currency.
+/**
+ * An accumulator for a given currency.
  *
  * This is used during the update to the status bar to contain the
  * accumulation for a single currency. These are placed in a GList and
  * kept around for the duration of the calculation. There may, in fact
- * be better ways to do this, but none occurred. */
-
+ * be better ways to do this, but none occurred.
+ *
+ * @fixme This structure and the non-GUI code that computes it's values
+ * should move into the engine.
+ **/
 typedef struct {
   gnc_commodity * currency;
   gnc_numeric assets;
@@ -68,34 +72,14 @@
 } GNCCurrencyAcc;
 
 
-/* An item to appear in the selector box in the status bar.
- *
- * This is maintained for the duration, where there is one per
- * currency, plus (eventually) one for the default currency
- * accumulation (like the EURO) or grand total or non currency
- * commodities total. */
-
-typedef struct  {
-  char *namespace;
-  char *mnemonic;
-  GtkWidget *listitem;
-  GtkWidget *assets_label;
-  GtkWidget *profits_label;
-  gint touched : 1;
-  gint total_mode;
-} GNCCurrencyItem;
-
-
 /* defines for total_mode in GNCCurrencyAcc and GNCCurrencyItem */
-
 #define TOTAL_SINGLE           0
 #define TOTAL_CURR_TOTAL       1
 #define TOTAL_NON_CURR_TOTAL   2
 #define TOTAL_GRAND_TOTAL      3
 
 
-/* options for summarybar */
-
+/** options for summarybar **/
 typedef struct {
   gnc_commodity *default_currency;
   gboolean euro;
@@ -105,156 +89,20 @@
   time_t end_date;
 } GNCSummarybarOptions;
 
-
-/* Build a single currency item.
- *
- * This function handles the building of a single currency item for
- * the selector. It looks like the old code in the update function,
- * but now only handles a single currency.  */
-
-static GNCCurrencyItem *
-gnc_ui_build_currency_item(gnc_commodity * currency, gint total_mode)
-{
-  GtkWidget *label;
-  GtkWidget *topbox;
-  GtkWidget *hbox;
-  GtkWidget *listitem;
-  GNCCurrencyItem *item;
-  const char *mnemonic;
-  char *label_str;
-  struct lconv *lc;
-
-  lc = gnc_localeconv();
-
-  item = g_new0 (GNCCurrencyItem, 1);
-
-  item->namespace = g_strdup (gnc_commodity_get_namespace (currency));
-  item->mnemonic = g_strdup (gnc_commodity_get_mnemonic (currency));
-
-  item->total_mode = total_mode;
-
-  listitem = gtk_list_item_new();
-  item->listitem = listitem;
-
-  topbox = gtk_hbox_new(FALSE, 2);
-  gtk_widget_show(topbox);
-  gtk_container_add(GTK_CONTAINER(listitem), topbox);
-
-  if (gnc_commodity_equiv (currency, gnc_locale_default_currency ()))
-    mnemonic = lc->currency_symbol;
-  else
-    mnemonic = gnc_commodity_get_mnemonic (currency);
-
-  if (mnemonic == NULL)
-    mnemonic = "";
-
-  hbox = gtk_hbox_new(FALSE, 2);
-  gtk_widget_show(hbox);
-  gtk_box_pack_start(GTK_BOX(topbox), hbox, FALSE, FALSE, 5);
-
-  switch(total_mode)
-  {
-  case TOTAL_CURR_TOTAL:
-    label_str = g_strdup_printf ("%s (%s):", _("Net Assets total"),
-                                 mnemonic ? mnemonic : "");
-    break;
-  case TOTAL_NON_CURR_TOTAL:
-    label_str = g_strdup_printf ("%s (%s):", _("Net Assets non currency commodities total"),
-                                 mnemonic ? mnemonic : "");
-    break;
-  case TOTAL_GRAND_TOTAL:
-    label_str = g_strdup_printf ("%s (%s):", _("Net Assets grand total"),
-                                 mnemonic ? mnemonic : "");
-    break;
-  case TOTAL_SINGLE:
-  default:
-    label_str = g_strdup_printf ("%s (%s):", _("Net Assets"),
-                                 mnemonic ? mnemonic : "");
-    break;
-  }
-  label = gtk_label_new(label_str);
-  gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5);
-  gtk_widget_show(label);
-  gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
-  g_free (label_str);
-
-  label = gtk_label_new("");
-  gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5);
-  gtk_box_pack_end(GTK_BOX(hbox), label, FALSE, FALSE, 0);
-  gtk_widget_show(label);
-  item->assets_label = label;
-
-  hbox = gtk_hbox_new(FALSE, 2);
-  gtk_widget_show(hbox);
-  gtk_box_pack_start(GTK_BOX(topbox), hbox, FALSE, FALSE, 5);
-
-  switch(total_mode)
-  {
-  case TOTAL_CURR_TOTAL:
-    label_str = g_strdup_printf ("%s (%s):", _("Profits total"),
-				 mnemonic ? mnemonic : "");
-    break;
-  case TOTAL_NON_CURR_TOTAL:
-    label_str = g_strdup_printf ("%s (%s):", _("Profits non currency commodities total"),
-				 mnemonic ? mnemonic : "");
-    break;
-  case TOTAL_GRAND_TOTAL:
-    label_str = g_strdup_printf ("%s (%s):", _("Profits grand total"),
-				 mnemonic ? mnemonic : "");
-    break;
-  case TOTAL_SINGLE:
-  default:
-    label_str = g_strdup_printf ("%s (%s):", _("Profits"),
-				 mnemonic ? mnemonic : "");
-    break;
-  }
-  label = gtk_label_new(label_str);
-  gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5);
-  gtk_widget_show(label);
-  gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
-  g_free (label_str);
-
-  label = gtk_label_new("");
-  gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5);
-  gtk_widget_show(label);
-  gtk_box_pack_end(GTK_BOX(hbox), label, FALSE, FALSE, 0);
-  item->profits_label = label;
-
-  gtk_widget_show(item->listitem);
-
-  return item;
-}
-
-static void
-gnc_ui_currency_item_destroy (GNCCurrencyItem *item)
-{
-  if (!item) return;
-
-  g_free (item->namespace);
-  g_free (item->mnemonic);
-
-  item->namespace = NULL;
-  item->mnemonic = NULL;
-
-  g_free (item);
-}
-
-/* Get a currency accumulator.
- *
- * This will search the given list, and if no accumulator is found,
- * will allocate a fresh one. */
+/**
+ * Get the existing currency accumulator matching the given currency and
+ * total-mode, or create a new one.
+ **/
 static GNCCurrencyAcc *
-gnc_ui_get_currency_accumulator(GList **list, gnc_commodity * currency,
-				gint total_mode)
+gnc_ui_get_currency_accumulator(GList **list, gnc_commodity * currency, gint total_mode)
 {
   GList *current;
   GNCCurrencyAcc *found;
 
-  for (current = g_list_first(*list); current;
-       current = g_list_next(current)) {
+  for (current = g_list_first(*list); current; current = g_list_next(current)) {
     found = current->data;
-    if ((gnc_commodity_equiv(currency, found->currency)) &&
-        (found->total_mode == total_mode)) {
+    if ((gnc_commodity_equiv(currency, found->currency))
+        && (found->total_mode == total_mode)) {
       return found;
     }
   }
@@ -269,57 +117,9 @@
   return found;
 }
 
-static gboolean
-gnc_ui_currency_item_match (const GNCCurrencyItem *item,
-                            const gnc_commodity *commodity,
-			    gint total_mode)
-{
-  if (!item || !commodity) return FALSE;
-
-  return
-    (safe_strcmp (item->namespace,
-                  gnc_commodity_get_namespace (commodity)) == 0) &&
-    (safe_strcmp (item->mnemonic,
-                  gnc_commodity_get_mnemonic (commodity)) == 0) &&
-    (item->total_mode == total_mode);
-
-}
-
-/* Get a currency item.
- *
- * This will search the given list, and if no accumulator is found, will
- * create a fresh one.
- *
- * It looks just like the function above, with some extra stuff to get
- * the item into the list. */
-
-static GNCCurrencyItem *
-gnc_ui_get_currency_item (GList **list,
-                          gnc_commodity * currency,
-                          gint total_mode,
-                          GtkWidget *holder)
-{
-  GList *current;
-  GNCCurrencyItem *found;
-
-  for (current = g_list_first(*list); current;
-       current = g_list_next(current))
-  {
-    found = current->data;
-
-    if (gnc_ui_currency_item_match (found, currency, total_mode))
-      return found;
-  }
-
-  found = gnc_ui_build_currency_item(currency, total_mode);
-  *list = g_list_append(*list, found);
-
-  current = g_list_append(NULL, found->listitem);
-  gtk_select_append_items(GTK_SELECT(holder), current);
-
-  return found;
-}
-
+/**
+ * @fixme Move this non-GUI code into the engine.
+ **/
 static void
 gnc_ui_accounts_recurse (AccountGroup *group, GList **currency_list,
                          GNCSummarybarOptions options)
@@ -499,6 +299,39 @@
   }
 }
 
+static char*
+get_total_mode_label(const char *mnemonic, int total_mode)
+{
+  char *label_str;
+  // i.e., "$, grand total," [profits: $12,345.67, assets: $23,456.78]
+  switch(total_mode)
+  {
+  case TOTAL_CURR_TOTAL:
+    label_str = g_strdup_printf( _("%s, total:"), mnemonic );
+    break;
+  case TOTAL_NON_CURR_TOTAL:
+    label_str = g_strdup_printf( _("%s, non currency commodities total:"), mnemonic );
+    break;
+  case TOTAL_GRAND_TOTAL:
+    label_str = g_strdup_printf( _("%s, grand total:"), mnemonic );
+    break;
+  case TOTAL_SINGLE:
+  default:
+    label_str = g_strdup_printf( _("%s:"), mnemonic );
+    break;
+  }
+  return label_str;
+}
+
+enum {
+  COLUMN_MNEMONIC_TYPE,
+  COLUMN_ASSETS,
+  COLUMN_ASSETS_VALUE,
+  COLUMN_PROFITS,
+  COLUMN_PROFITS_VALUE,
+  N_COLUMNS,
+};
+
 /* The gnc_main_window_summary_refresh() subroutine redraws summary
  * information. The statusbar includes two fields, titled 'profits'
  * and 'assets'. The total assets equal the sum of all of the
@@ -523,12 +356,10 @@
   char asset_string[256];
   char profit_string[256];
   GNCCurrencyAcc *currency_accum;
-  GNCCurrencyItem *currency_item;
   GList *currency_list;
   GList *current;
   GNCSummarybarOptions options;
 
-
   options.default_currency = gnc_default_report_currency ();
 
   options.euro = gnc_lookup_boolean_option("International",
@@ -539,6 +370,7 @@
 						  TRUE);
   options.non_currency = gnc_lookup_boolean_option("Summarybar",
 						   "Show non currency commodities",
+
 						   TRUE);
   /* we will need the balance of the last transaction before the start
      date, so subtract 1 from start date */
@@ -561,63 +393,48 @@
   group = gnc_get_current_group ();
   gnc_ui_accounts_recurse(group, &currency_list, options);
 
-  for (current = g_list_first(summary->totals_list); current;
-       current = g_list_next(current)) {
-    currency_item = current->data;
-    currency_item->touched = 0;
-  }
-  
-  for (current = g_list_first(currency_list); current;
-       current = g_list_next(current)) {
-    currency_accum = current->data;
-    currency_item = gnc_ui_get_currency_item(&summary->totals_list,
-       					     currency_accum->currency,
-					     currency_accum->total_mode,
-					     summary->totals_combo);
-    currency_item->touched = 1;
-    
-    *asset_string= '\0';
-    xaccSPrintAmount(asset_string, currency_accum->assets,
-                     gnc_commodity_print_info(currency_accum->currency, TRUE));
-    gtk_label_set_text(GTK_LABEL(currency_item->assets_label), asset_string);
-    gnc_set_label_color(currency_item->assets_label, currency_accum->assets);
-
-    *profit_string= '\0';
-    xaccSPrintAmount(profit_string, currency_accum->profits,
-                     gnc_commodity_print_info(currency_accum->currency, TRUE));
-    gtk_label_set_text(GTK_LABEL(currency_item->profits_label), profit_string);
-    gnc_set_label_color(currency_item->profits_label, currency_accum->profits);
-
-    g_free(currency_accum);
-    current->data = NULL;
-  }
-
-  g_list_free(currency_list);
-  currency_list = NULL;
-  
-  current = g_list_first(summary->totals_list);
-  while (current) {
-    GList *next = current->next;
-    
-    currency_item = current->data;
-    if (currency_item->touched == 0 &&
-        !gnc_ui_currency_item_match(currency_item, options.default_currency,
-				    TOTAL_SINGLE)) {
-      currency_list = g_list_prepend(currency_list, currency_item->listitem);
-      summary->totals_list = g_list_remove_link(summary->totals_list,
-                                                current);
-      gnc_ui_currency_item_destroy(currency_item);
-      current->data = NULL;
-      g_list_free_1(current);
+  {
+    GtkTreeIter iter;
+    char asset_amount_string[256], profit_amount_string[256];
+    struct lconv *lc;
+
+    lc = gnc_localeconv();
+
+    gtk_list_store_clear(summary->datamodel);
+    for (current = g_list_first(currency_list); current; current = g_list_next(current)) {
+      const char *mnemonic;
+
+      currency_accum = current->data;
+
+      if (gnc_commodity_equiv (currency_accum->currency, gnc_locale_default_currency ()))
+        mnemonic = lc->currency_symbol;
+      else
+        mnemonic = gnc_commodity_get_mnemonic (currency_accum->currency);
+      
+      if (mnemonic == NULL)
+        mnemonic = "";
+
+      *asset_string= '\0';
+      xaccSPrintAmount(asset_amount_string,
+                       currency_accum->assets,
+                       gnc_commodity_print_info(currency_accum->currency, TRUE));
+
+      *profit_string= '\0';
+      xaccSPrintAmount(profit_amount_string,
+                       currency_accum->profits,
+                       gnc_commodity_print_info(currency_accum->currency, TRUE));
+
+      gtk_list_store_append(summary->datamodel, &iter);
+      gtk_list_store_set(summary->datamodel, &iter,
+                         COLUMN_MNEMONIC_TYPE, get_total_mode_label(mnemonic, currency_accum->total_mode),
+                         COLUMN_ASSETS,        _("Assets:"),
+                         COLUMN_ASSETS_VALUE,  asset_amount_string,
+                         COLUMN_PROFITS,       _("Profits:"),
+                         COLUMN_PROFITS_VALUE, profit_amount_string,
+                         -1);
     }
-    
-    current = next;
-  }
-  
-  if (currency_list) {
-    gtk_select_remove_items(GTK_SELECT(summary->totals_combo),
-                            currency_list);
-    g_list_free(currency_list);
+
+    gtk_combo_box_set_active( GTK_COMBO_BOX(summary->totals_combo), 0 );
   }
 }
 
@@ -627,7 +444,6 @@
   GNCMainSummary * summary = data;
   gnc_unregister_option_change_callback_id(summary->callback_id);
   gnc_unregister_gui_component(summary->component_id);
-  g_list_free(summary->totals_list);
   g_free(summary);
 }
 
@@ -649,12 +465,18 @@
 gnc_main_window_summary_new (void)
 {
   GNCMainSummary  * retval = g_new0(GNCMainSummary, 1);
-  GNCCurrencyItem * def_item;
-  gnc_commodity   * default_currency = gnc_default_report_currency ();
+  GtkCellRenderer *textRenderer;
+  int i;
   
-  retval->hbox         = gtk_hbox_new (FALSE, 5);  
-  retval->totals_combo = gtk_select_new ();
-  retval->totals_list  = NULL;
+  retval->datamodel = gtk_list_store_new( N_COLUMNS,
+                                          G_TYPE_STRING,
+                                          G_TYPE_STRING,
+                                          G_TYPE_STRING,
+                                          G_TYPE_STRING,
+                                          G_TYPE_STRING );
+
+  retval->hbox         = gtk_hbox_new (FALSE, 5);
+  retval->totals_combo = gtk_combo_box_new_with_model( GTK_TREE_MODEL(retval->datamodel) );
   retval->component_id = gnc_register_gui_component(WINDOW_SUMMARYBAR_CM_CLASS,
                                                     summarybar_refresh_handler,
                                                     NULL, retval);
@@ -666,17 +488,15 @@
                                        GNC_ID_ACCOUNT,
                                        GNC_EVENT_MODIFY | GNC_EVENT_DESTROY);
 
-  def_item = gnc_ui_get_currency_item (&retval->totals_list,
-                                       default_currency,
-				       TOTAL_SINGLE,
-                                       retval->totals_combo);
-  
-  
+  for ( i = 0; i < N_COLUMNS; i++ )
+  {
+    textRenderer = GTK_CELL_RENDERER(gtk_cell_renderer_text_new());
+    gtk_cell_layout_pack_start( GTK_CELL_LAYOUT(retval->totals_combo), textRenderer, TRUE );
+    gtk_cell_layout_add_attribute(GTK_CELL_LAYOUT(retval->totals_combo), textRenderer, "text", i );
+  }
+
   gtk_container_set_border_width (GTK_CONTAINER (retval->hbox), 2);
-  gtk_select_select_child (GTK_SELECT(retval->totals_combo), 
-                           def_item->listitem);
-  gtk_box_pack_start (GTK_BOX(retval->hbox), retval->totals_combo, 
-                      FALSE, FALSE, 5);
+  gtk_box_pack_start (GTK_BOX(retval->hbox), retval->totals_combo, TRUE, TRUE, 5);
   gtk_widget_show (retval->totals_combo);
   gtk_widget_show (retval->hbox);
 
--- src/gnome-utils/gtkselect.h
+++ /dev/null
@@ -1,115 +0,0 @@
-/* gtkselect.h - select widget for gtk+
- * Copyright 1997 Paolo Molaro (from gtkcombo, where this was copied from)
- * Copyright 2000 Gordon Oliver
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-/*
- * Modified by the GTK+ Team and others 1997-1999.  See the AUTHORS
- * file for a list of people on the GTK+ Team.  See the ChangeLog
- * files for a list of changes.  These files are distributed with
- * GTK+ at ftp://ftp.gtk.org/pub/gtk/. 
- */
-
-#ifndef GTK_SMART_SELECT_H
-#define GTK_SMART_SELECT_H
-
-#include <gtk/gtkhbox.h>
-#include <gtk/gtkitem.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-#define GTK_SELECT(obj)		GTK_CHECK_CAST (obj, gtk_select_get_type (), GtkSelect)
-#define GTK_SELECT_CLASS(klass)	GTK_CHECK_CLASS_CAST (klass, gtk_select_get_type (), GtkSelectClass)
-#define GTK_IS_SELECT(obj)       GTK_CHECK_TYPE (obj, gtk_select_get_type ())
-
-typedef struct _GtkSelect		GtkSelect;
-typedef struct _GtkSelectClass	GtkSelectClass;
-
-/* you should access only the selected field directly */
-struct _GtkSelect {
-	GtkHBox hbox;
-	GtkWidget *selected;
-
-	GtkWidget *entry;
-	GtkWidget *button;
-	GtkWidget *popup;
-	GtkWidget *popwin;
-	GtkWidget *list;
-	GtkWidget *empty;
-
-	GList *entries;
-
-	guint entry_change_id;
-	guint list_change_id;
-
-	guint use_arrows:1;
-
-        guint16 current_button;
-	guint activate_id;
-};
-
-struct _GtkSelectClass {
-	GtkHBoxClass parent_class;
-};
-
-guint      gtk_select_get_type              (void);
-
-GtkWidget *gtk_select_new                   (void);
-
-/* set/unset arrows working for changing the value (can be annoying */
-void       gtk_select_set_use_arrows        (GtkSelect*    select, 
-                                            gint         val);
-
-void       gtk_select_disable_activate      (GtkSelect*    select);
-
-void	   gtk_select_insert_items	  (GtkSelect	    *select,
-					   GList	    *items,
-					   gint		     position);
-
-void	   gtk_select_append_items	  (GtkSelect	    *select,
-					   GList	    *items);
-
-void	   gtk_select_prepend_items	  (GtkSelect	    *select,
-					   GList	    *items);
-
-void	   gtk_select_remove_items	  (GtkSelect	    *list,
-					   GList	    *items);
-
-void	   gtk_select_remove_items_no_unref (GtkSelect	    *list,
-					   GList	    *items);
-
-void	   gtk_select_clear_items	  (GtkSelect	    *list,
-					   gint		     start,
-					   gint		     end);
-
-void	   gtk_select_select_item	  (GtkSelect	    *list,
-					   gint		     item);
-
-void	   gtk_select_select_child	  (GtkSelect	    *list,
-					   GtkWidget	    *child);
-
-gint	   gtk_select_child_position	  (GtkSelect	    *list,
-					   GtkWidget	    *child);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* GTK_SMART_SELECT_H */
--- src/gnome-utils/gtkselect.c
+++ /dev/null
@@ -1,860 +0,0 @@
-/* gtkselect.c - select widget for gtk+
- * Copyright 1997 Paolo Molaro (from gtkcombo, where this was copied from)
- * Copyright 2000 Gordon Oliver
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-/*
- * Modified by the GTK+ Team and others 1997-1999.  See the AUTHORS
- * file for a list of people on the GTK+ Team.  See the ChangeLog
- * files for a list of changes.  These files are distributed with
- * GTK+ at ftp://ftp.gtk.org/pub/gtk/. 
- */
-
-#include <string.h>
-
-#include "gtk/gtkarrow.h"
-#include "gtk/gtklabel.h"
-#include "gtk/gtklist.h"
-#include "gtk/gtkeventbox.h"
-#include "gtk/gtkbutton.h"
-#include "gtk/gtklistitem.h"
-#include "gtk/gtkscrolledwindow.h"
-#include "gtk/gtkmain.h"
-#include "gtk/gtksignal.h"
-#include "gtk/gtkwindow.h"
-#include "gdk/gdkkeysyms.h"
-#include "gtkselect.h"
-#include "gtk/gtkframe.h"
-#include "gtk/gtkbin.h"
-
-#define SELECT_LIST_MAX_HEIGHT	(400)
-#define	EMPTY_LIST_HEIGHT	(15)
-
-static void         gtk_select_class_init      (GtkSelectClass *klass);
-static void         gtk_select_init            (GtkSelect      *select);
-static void         gtk_select_destroy         (GtkObject     *select);
-static void         gtk_select_get_pos         (GtkSelect      *select, 
-                                               gint          *x, 
-                                               gint          *y, 
-                                               gint          *height, 
-                                               gint          *width);
-static void         gtk_select_popup_list      (GtkSelect      *select);
-static void         gtk_select_popup_button_press (GtkWidget        *button,
-						  GdkEventButton   *event,
-						  GtkSelect         *select);
-static void         gtk_select_popup_button_leave (GtkWidget        *button,
-						  GdkEventCrossing *event,
-						  GtkSelect         *select);
-static void         gtk_select_update_entry    (GtkList       *list, 
-                                               GtkSelect      *select);
-static gint         gtk_select_button_press    (GtkWidget     *widget,
-				               GdkEvent      *event,
-				               GtkSelect      *select);
-static gint         gtk_select_button_release  (GtkWidget     *widget,
-				               GdkEvent      *event,
-				               GtkSelect      *select);
-static gint         gtk_select_list_enter      (GtkWidget        *widget,
-				               GdkEventCrossing *event,
-				               GtkSelect         *select);
-static gint         gtk_select_list_key_press  (GtkWidget     *widget, 
-                                               GdkEventKey   *event, 
-                                               GtkSelect      *select);
-#if 0
-static gint         gtk_select_entry_key_press (GtkEntry      *widget, 
-                                               GdkEventKey   *event, 
-                                               GtkSelect      *select);
-#endif
-static void         gtk_select_size_allocate   (GtkWidget     *widget,
-					       GtkAllocation *allocation);
-
-static GtkHBoxClass *parent_class = NULL;
-
-static void
-gtk_select_class_init (GtkSelectClass * klass)
-{
-  GtkObjectClass *oclass;
-  GtkWidgetClass *widget_class;
-
-  parent_class = gtk_type_class (gtk_hbox_get_type ());
-  oclass = (GtkObjectClass *) klass;
-  widget_class = (GtkWidgetClass *) klass;
-
-  oclass->destroy = gtk_select_destroy;
-  
-  widget_class->size_allocate = gtk_select_size_allocate;
-}
-
-static void
-gtk_select_destroy (GtkObject * object)
-{
-  GtkSelect *select = GTK_SELECT (object);
-
-  if (select->popwin) {
-    gtk_widget_destroy (select->popwin);
-    g_object_unref (select->popwin);
-    select->popwin = NULL;
-  }
-  if (select->empty) {
-    g_object_unref (GTK_SELECT (select)->empty);
-    select->empty = NULL;
-  }
-
-  if (GTK_OBJECT_CLASS (parent_class)->destroy)
-    (*GTK_OBJECT_CLASS (parent_class)->destroy) (object);
-}
-
-#if 0
-static int
-gtk_select_entry_key_press (GtkEntry * entry, GdkEventKey * event, GtkSelect * select)
-{
-  GList *li;
-
-  return FALSE;
-  if (!select->use_arrows || !GTK_LIST (select->list)->children)
-    return FALSE;
-
-  li = NULL;
-  //li = g_list_find (GTK_LIST (select->list)->children, gtk_select_find (select));
-
-  if ((event->keyval == GDK_Up)
-      || (event->keyval == GDK_KP_Up)
-      || ((event->state & GDK_MOD1_MASK) && ((event->keyval == 'p') || (event->keyval == 'P'))))
-    {
-      if (li)
-	li = li->prev;
-      if (!li && select->use_arrows_always)
-	{
-	  li = g_list_last (GTK_LIST (select->list)->children);
-	}
-      if (li)
-	{
-	  gtk_list_select_child (GTK_LIST (select->list), GTK_WIDGET (li->data));
-	  gtk_signal_emit_stop_by_name (GTK_OBJECT (entry), "key_press_event");
-	  return TRUE;
-	}
-    }
-  else if ((event->keyval == GDK_Down)
-	   || (event->keyval == GDK_KP_Down)
-	   || ((event->state & GDK_MOD1_MASK) && ((event->keyval == 'n') || (event->keyval == 'N'))))
-    {
-      if (li)
-	li = li->next;
-      if (!li && select->use_arrows_always)
-	{
-	  li = GTK_LIST (select->list)->children;
-	}
-      if (li)
-	{
-	  gtk_list_select_child (GTK_LIST (select->list), GTK_WIDGET (li->data));
-	  gtk_signal_emit_stop_by_name (GTK_OBJECT (entry), "key_press_event");
-	  return TRUE;
-	}
-    }
-  return FALSE;
-}
-#endif
-
-static void
-gtk_select_get_pos (GtkSelect * select, gint * x, gint * y, gint * height, gint * width)
-{
-  GtkBin *popwin;
-  GtkWidget *widget;
-  GtkScrolledWindow *popup;
-  
-  gint real_height;
-  GtkRequisition list_requisition;
-  gboolean show_hscroll = FALSE;
-  gboolean show_vscroll = FALSE;
-  gint avail_height;
-  gint min_height;
-  gint alloc_width;
-  gint work_height;
-  gint old_height;
-  gint old_width;
-  gint scrollbar_spacing;
-  
-  widget = GTK_WIDGET(select);
-  popup  = GTK_SCROLLED_WINDOW (select->popup);
-  popwin = GTK_BIN (select->popwin);
-  
-  gdk_window_get_origin (select->entry->window, x, y);
-  real_height = MIN (select->entry->requisition.height, 
-		     select->entry->allocation.height);
-  *y += real_height;
-  avail_height = gdk_screen_height () - *y;
-  
-  gtk_widget_size_request (select->list, &list_requisition);
-  min_height = MIN (list_requisition.height, 
-		    popup->vscrollbar->requisition.height);
-  if (!GTK_LIST (select->list)->children)
-    list_requisition.height += EMPTY_LIST_HEIGHT;
-  
-  alloc_width = (widget->allocation.width -
-		 2 * popwin->child->style->xthickness -
-		 2 * GTK_CONTAINER (popwin->child)->border_width -
-		 2 * GTK_CONTAINER (select->popup)->border_width -
-		 2 * GTK_CONTAINER (GTK_BIN (popup)->child)->border_width - 
-		 2 * GTK_BIN (popup)->child->style->xthickness);
-  
-  work_height = (2 * popwin->child->style->ythickness +
-		 2 * GTK_CONTAINER (popwin->child)->border_width +
-		 2 * GTK_CONTAINER (select->popup)->border_width +
-		 2 * GTK_CONTAINER (GTK_BIN (popup)->child)->border_width +
-		 2 * GTK_BIN (popup)->child->style->xthickness);
-  
-  do 
-    {
-      old_width = alloc_width;
-      old_height = work_height;
-      
-      if (!show_hscroll &&
-	  alloc_width < list_requisition.width)
-	{
-	  g_object_get (G_OBJECT (select->popup),
-			"scrollbar_spacing", &scrollbar_spacing,
-		       	NULL);
-	  work_height += popup->hscrollbar->requisition.height + scrollbar_spacing;
-	  show_hscroll = TRUE;
-	}
-      if (!show_vscroll && 
-	  work_height + list_requisition.height > avail_height)
-	{
-	  if (work_height + min_height > avail_height && 
-	      *y - real_height > avail_height)
-	    {
-	      *y -= (work_height + list_requisition.height + real_height);
-	      break;
-	    }
-	  g_object_get (G_OBJECT (select->popup),
-			"scrollbar_spacing", &scrollbar_spacing,
-		       	NULL);
-	  alloc_width -= 
-	    popup->vscrollbar->requisition.width + scrollbar_spacing;
-	  show_vscroll = TRUE;
-	}
-    } while (old_width != alloc_width || old_height != work_height);
-  
-  *width = widget->allocation.width;
-  if (show_vscroll)
-    *height = avail_height;
-  else
-    *height = work_height + list_requisition.height;
-  
-  if (*x < 0)
-    *x = 0;
-}
-
-static void
-gtk_select_popup_list (GtkSelect * select)
-{
-  gint height, width, x, y;
-  gint old_width, old_height;
-
-  old_width = select->popwin->allocation.width;
-  old_height  = select->popwin->allocation.height;
-
-  gtk_select_get_pos (select, &x, &y, &height, &width);
-
-  /* workaround for gtk_scrolled_window_size_allocate bug */
-  if (old_width != width || old_height != height)
-    {
-      gtk_widget_hide (GTK_SCROLLED_WINDOW (select->popup)->hscrollbar);
-      gtk_widget_hide (GTK_SCROLLED_WINDOW (select->popup)->vscrollbar);
-    }
-
-  gtk_widget_set_uposition (select->popwin, x, y);
-  gtk_widget_set_usize (select->popwin, width, height);
-  gtk_widget_realize (select->popwin);
-  gdk_window_resize (select->popwin->window, width, height);
-  gtk_widget_show (select->popwin);
-
-  gtk_widget_grab_focus (select->popwin);
-}
-
-static void        
-gtk_select_popup_button_press (GtkWidget        *button,
-			      GdkEventButton   *event,
-			      GtkSelect         *select)
-{
-  if (!GTK_WIDGET_HAS_FOCUS (select->entry))
-    gtk_widget_grab_focus (select->entry);
-  if (!select->current_button && (event->button == 1))
-    gtk_select_popup_list (select);
-
-  select->current_button = event->button;
-  
-  GTK_LIST (select->list)->drag_selection = TRUE;
-  gdk_pointer_grab (select->list->window, TRUE,
-		    GDK_POINTER_MOTION_HINT_MASK |
-		    GDK_BUTTON1_MOTION_MASK |
-		    GDK_BUTTON_RELEASE_MASK,
-		    NULL, NULL, event->time);
-  gtk_grab_add (select->list);
-}
-
-static void         
-gtk_select_popup_button_leave (GtkWidget        *button,
-			      GdkEventCrossing *event,
-			      GtkSelect         *select)
-{
-  if (select->current_button)
-    gtk_signal_emit_stop_by_name (GTK_OBJECT (button), "leave_notify_event");
-}
-
-static void
-gtk_select_update_button (GtkSelect *select)
-{
-  if (g_list_length (select->entries) > 1)
-    gtk_widget_show (select->button);
-  else if (g_list_length (select->entries) == 1 &&
-           select->selected == NULL)
-    gtk_widget_show (select->button);
-  else
-    gtk_widget_hide (select->button);
-}
-
-static void
-gtk_select_update_entry (GtkList * list, GtkSelect * select)
-{
-  GtkWidget *selected;
-  GtkWidget *old_selected;
-  GList *items;
-  int posn;
-
-  gtk_grab_remove (GTK_WIDGET (select));
-  gtk_signal_handler_block (GTK_OBJECT (list), select->list_change_id);
-  if (list->selection) {
-    selected = list->selection->data;
-    old_selected = select->selected;
-    if (old_selected) {
-      items = g_list_append(NULL, old_selected);
-      posn = g_list_index(select->entries, old_selected);
-      g_object_ref(old_selected);
-      gtk_container_remove(GTK_CONTAINER(select->entry), old_selected);
-      if (old_selected != select->empty)
-	gtk_list_insert_items(list, items, posn);
-      g_object_unref(old_selected);
-    } else {
-      gtk_container_remove(GTK_CONTAINER(select->entry), select->empty);
-    }
-    if (selected) {
-      select->selected = selected;
-      items = g_list_append(NULL, selected);
-      g_object_ref(selected);
-      gtk_list_remove_items(list, items);
-      gtk_container_add(GTK_CONTAINER(select->entry), selected);
-      g_object_unref(selected);
-    } else {
-      gtk_container_add(GTK_CONTAINER(select->entry), select->empty);
-      select->selected = NULL;
-    }
-  }
-
-  gtk_select_update_button (select);
-
-  gtk_signal_handler_unblock (GTK_OBJECT (list), select->list_change_id);
-}
-
-static gint
-gtk_select_button_press (GtkWidget * widget, GdkEvent * event, GtkSelect * select)
-{
-  GtkWidget *child;
-
-  child = gtk_get_event_widget (event);
-
-  /* We don't ask for button press events on the grab widget, so
-   *  if an event is reported directly to the grab widget, it must
-   *  be on a window outside the application (and thus we remove
-   *  the popup window). Otherwise, we check if the widget is a child
-   *  of the grab widget, and only remove the popup window if it
-   *  is not.
-   */
-  if (child != widget)
-    {
-      while (child)
-	{
-	  if (child == widget)
-	    return FALSE;
-	  child = child->parent;
-	}
-    }
-
-  gtk_widget_hide (select->popwin);
-  gtk_grab_remove (select->popwin);
-  gdk_pointer_ungrab (event->button.time);
-
-  return TRUE;
-}
-
-static gint
-gtk_select_button_release (GtkWidget * widget, GdkEvent * event, GtkSelect * select)
-{
-  GtkWidget *child;
-
-  if ((select->current_button != 0) && (event->button.button == 1))
-    {
-      /* This was the initial button press */
-
-      GdkEventCrossing tmp_event;
-
-      select->current_button = 0;
-
-      if (widget != select->button)
-	gtk_widget_event (select->button, event);
-
-      /* Un-pre-hightlight */
-      
-      tmp_event.type = GDK_LEAVE_NOTIFY;
-      tmp_event.window = select->button->window;
-      tmp_event.send_event = TRUE;
-      tmp_event.subwindow = NULL;
-      tmp_event.detail = GDK_NOTIFY_ANCESTOR;
-      
-      gtk_widget_event (select->button, (GdkEvent *)&tmp_event);
-
-      /* Check to see if we released inside the button */
-      child = gtk_get_event_widget ((GdkEvent*) event);
-
-      while (child && child != (select->button))
-	child = child->parent;
-
-      if (child == select->button)
-	{
-	  gtk_grab_add (select->popwin);
-	  gdk_pointer_grab (select->popwin->window, TRUE,
-			    GDK_BUTTON_PRESS_MASK | 
-			    GDK_BUTTON_RELEASE_MASK |
-			    GDK_POINTER_MOTION_MASK, 
-			    NULL, NULL, GDK_CURRENT_TIME);
-	  return FALSE;
-	}
-    }
-  else
-    {
-      /* The user has clicked inside the popwin and released */
-
-      if (GTK_WIDGET_HAS_GRAB (select->popwin))
-	{
-	  gtk_grab_remove (select->popwin);
-	  gdk_pointer_ungrab (event->button.time);
-	}
-    }
-  
-  gtk_widget_hide (select->popwin);
-
-  return TRUE;
-}
-
-static gint         
-gtk_select_list_enter (GtkWidget        *widget,
-		      GdkEventCrossing *event,
-		      GtkSelect         *select)
-{
-  GtkWidget *event_widget;
-
-  event_widget = gtk_get_event_widget ((GdkEvent*) event);
-  
-  if ((event_widget == select->list) &&
-      (select->current_button != 0) && 
-      (!GTK_WIDGET_HAS_GRAB (select->list)))
-    {
-      GdkEvent tmp_event;
-      gint x, y;
-      GdkModifierType mask;
-
-      gtk_grab_remove (select->popwin);
-
-      /* Transfer the grab over to the list by synthesizing
-       * a button press event
-       */
-      gdk_window_get_pointer (select->list->window, &x, &y, &mask);
-
-      tmp_event.button.type = GDK_BUTTON_PRESS;
-      tmp_event.button.window = select->list->window;
-      tmp_event.button.send_event = TRUE;
-      tmp_event.button.time = GDK_CURRENT_TIME; /* bad */
-      tmp_event.button.x = x;
-      tmp_event.button.y = y;
-      /* We leave all the XInput fields unfilled here, in the expectation
-       * that GtkList doesn't care.
-       */
-      tmp_event.button.button = select->current_button;
-      tmp_event.button.state = mask;
-
-      gtk_widget_event (select->list, &tmp_event);
-    }
-
-  return FALSE;
-}
-
-static int
-gtk_select_list_key_press (GtkWidget * widget, GdkEventKey * event, GtkSelect * select)
-{
-  if (event->keyval == GDK_Escape)
-    {
-      if (GTK_WIDGET_HAS_GRAB (select->popwin))
-	{
-	  gtk_grab_remove (select->popwin);
-	  gdk_pointer_ungrab (GDK_CURRENT_TIME);
-	}
-      else if (GTK_WIDGET_HAS_GRAB (select->list))
-	gtk_list_end_drag_selection (GTK_LIST (select->list));
-      gtk_widget_hide (select->popwin);
-      if (GTK_WIDGET_HAS_GRAB (select->button))
-	{
-	  select->current_button = 0;
-	  GTK_BUTTON (select->button)->in_button = FALSE;
-	  gtk_button_released (GTK_BUTTON (select->button));
-	  gtk_grab_remove (select->button);
-	}
-      return TRUE;
-    }
-  return FALSE;
-}
-
-static void
-gtk_select_init (GtkSelect * select)
-{
-  GtkWidget *arrow;
-  GtkWidget *frame;
-  GtkWidget *event_box;
-  GdkCursor *cursor;
-
-  select->use_arrows = 1;
-  select->entry = gtk_event_box_new ();
-  select->button = gtk_button_new ();
-  select->current_button = 0;
-  select->empty = gtk_label_new ("");
-  select->entries = NULL;
-  select->selected = NULL;
-  arrow = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_OUT);
-  gtk_widget_show (arrow);
-  g_object_ref(select->empty);
-  gtk_widget_show (select->empty);
-  gtk_container_add(GTK_CONTAINER(select->entry), select->empty);
-  gtk_container_add (GTK_CONTAINER (select->button), arrow);
-  gtk_box_pack_start (GTK_BOX (select), select->button, FALSE, FALSE, 0);
-  gtk_box_pack_start (GTK_BOX (select), select->entry, TRUE, TRUE, 0);
-  GTK_WIDGET_UNSET_FLAGS (select->button, GTK_CAN_FOCUS);
-  gtk_widget_show (select->entry);
-//  gtk_signal_connect (GTK_OBJECT (select->entry), "key_press_event",
-//		      (GtkSignalFunc) gtk_select_entry_key_press, select);
-  gtk_signal_connect_after (GTK_OBJECT (select->button), "button_press_event",
-			    (GtkSignalFunc) gtk_select_popup_button_press, select);
-  /*gtk_signal_connect_after (GTK_OBJECT (select->button), "button_release_event",
-    (GtkSignalFunc) gtk_select_button_release, select);*/
-  gtk_signal_connect (GTK_OBJECT (select->button), "leave_notify_event",
-		      (GtkSignalFunc) gtk_select_popup_button_leave, select);
-  /*gtk_signal_connect(GTK_OBJECT(select->button), "clicked",
-     (GtkSignalFunc)prelight_bug, select); */
-
-  select->popwin = gtk_window_new (GTK_WINDOW_POPUP);
-  g_object_ref (select->popwin);
-  gtk_window_set_policy (GTK_WINDOW (select->popwin), 1, 1, 0);
-  
-  gtk_widget_set_events (select->popwin, GDK_KEY_PRESS_MASK);
-
-  event_box = gtk_event_box_new ();
-  gtk_container_add (GTK_CONTAINER (select->popwin), event_box);
-  gtk_widget_show (event_box);
-
-  gtk_widget_realize (event_box);
-  cursor = gdk_cursor_new (GDK_TOP_LEFT_ARROW);
-  gdk_window_set_cursor (event_box->window, cursor);
-  gdk_cursor_destroy (cursor);
-
-  frame = gtk_frame_new (NULL);
-  gtk_container_add (GTK_CONTAINER (event_box), frame);
-  gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT);
-  gtk_widget_show (frame);
-
-  select->popup = gtk_scrolled_window_new (NULL, NULL);
-  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (select->popup),
-				  GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
-  GTK_WIDGET_UNSET_FLAGS (GTK_SCROLLED_WINDOW (select->popup)->hscrollbar, GTK_CAN_FOCUS);
-  GTK_WIDGET_UNSET_FLAGS (GTK_SCROLLED_WINDOW (select->popup)->vscrollbar, GTK_CAN_FOCUS);
-  gtk_container_add (GTK_CONTAINER (frame), select->popup);
-  gtk_widget_show (select->popup);
-
-  select->list = gtk_list_new ();
-  /* We'll use enter notify events to figure out when to transfer
-   * the grab to the list
-   */
-  gtk_widget_set_events (select->list, GDK_ENTER_NOTIFY_MASK);
-
-  gtk_list_set_selection_mode(GTK_LIST(select->list), GTK_SELECTION_SINGLE);
-  gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (select->popup), select->list);
-  gtk_container_set_focus_vadjustment (GTK_CONTAINER (select->list),
-				       gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (select->popup)));
-  gtk_container_set_focus_hadjustment (GTK_CONTAINER (select->list),
-				       gtk_scrolled_window_get_hadjustment (GTK_SCROLLED_WINDOW (select->popup)));
-  gtk_widget_show (select->list);
-
-  select->list_change_id = gtk_signal_connect (GTK_OBJECT (select->list),
-     					       "selection_changed",
-			     (GtkSignalFunc) gtk_select_update_entry, select);
-  gtk_signal_connect (GTK_OBJECT (select->popwin), "key_press_event",
-		      (GtkSignalFunc) gtk_select_list_key_press, select);
-  gtk_signal_connect (GTK_OBJECT (select->popwin), "button_press_event",
-		      GTK_SIGNAL_FUNC (gtk_select_button_press), select);
-
-  gtk_signal_connect_after (GTK_OBJECT (select->list), "button_release_event",
-			    GTK_SIGNAL_FUNC (gtk_select_button_release), select);
-  /* We connect here on the button, because we'll have a grab on it
-   * when the event occurs. But we are actually interested in enters
-   * for the select->list.
-   */
-  gtk_signal_connect (GTK_OBJECT (select->button), "enter_notify_event",
-		      GTK_SIGNAL_FUNC (gtk_select_list_enter), select);
-}
-
-guint
-gtk_select_get_type (void)
-{
-  static guint select_type = 0;
-
-  if (!select_type)
-    {
-      static const GtkTypeInfo select_info =
-      {
-	"GtkSelect",
-	sizeof (GtkSelect),
-	sizeof (GtkSelectClass),
-	(GtkClassInitFunc) gtk_select_class_init,
-	(GtkObjectInitFunc) gtk_select_init,
-	/* reserved_1 */ NULL,
-	/* reserved_2 */ NULL,
-        (GtkClassInitFunc) NULL,
-      };
-      select_type = gtk_type_unique (gtk_hbox_get_type (), &select_info);
-    }
-  return select_type;
-}
-
-GtkWidget *
-gtk_select_new (void)
-{
-  return GTK_WIDGET (gtk_type_new (gtk_select_get_type ()));
-}
-
-void
-gtk_select_set_use_arrows (GtkSelect * select, gint val)
-{
-  g_return_if_fail (select != NULL);
-  g_return_if_fail (GTK_IS_SELECT (select));
-
-  select->use_arrows = val;
-}
-
-static void
-gtk_select_size_allocate (GtkWidget     *widget,
-			  GtkAllocation *allocation)
-{
-  GtkSelect *select;
-
-  g_return_if_fail (widget != NULL);
-  g_return_if_fail (GTK_IS_SELECT (widget));
-  g_return_if_fail (allocation != NULL);
-
-  GTK_WIDGET_CLASS (parent_class)->size_allocate (widget, allocation);
-  
-  select = GTK_SELECT (widget);
-
-  if (select->entry->allocation.height > select->entry->requisition.height)
-    {
-      GtkAllocation button_allocation;
-
-      button_allocation = select->button->allocation;
-      button_allocation.height = select->entry->requisition.height;
-      button_allocation.y = select->entry->allocation.y + 
-	(select->entry->allocation.height - select->entry->requisition.height) 
-	/ 2;
-      gtk_widget_size_allocate (select->button, &button_allocation);
-    }
-}
-
-void
-gtk_select_disable_activate (GtkSelect* select)
-{
-  g_return_if_fail (select != NULL);
-  g_return_if_fail (GTK_IS_SELECT (select));
-}
-
-static GList *
-g_list_insert_list(GList *list, GList *items, gint position)
-{
-	GList *at;
-	GList *last;
-	int ll;
-
-	if (!items) {
-		return list;
-	}
-	ll = g_list_length(list);
-	if (ll <= position) {
-		return g_list_concat(list, items);
-	}
-	if (position == 0) {
-		return g_list_concat(items, list);
-	}
-	at = g_list_nth(list, position - 1);
-	last = g_list_last(items);
-	last->next = at->next;
-	if (at->next) {
-		at->next->prev = last;
-	}
-	at->next = items;
-	items->prev = at;
-	return list;
-}
-
-void
-gtk_select_insert_items (GtkSelect *select, GList *items, gint position)
-{
-  GList *copy;
-
-  g_return_if_fail (select != NULL);
-  g_return_if_fail (GTK_IS_SELECT (select));
-  copy = g_list_copy(items);
-  select->entries = g_list_insert_list(select->entries, items, position);
-  gtk_list_insert_items(GTK_LIST(select->list), copy, position);
-  gtk_select_update_button (select);
-}
-
-void
-gtk_select_append_items (GtkSelect *select, GList *items)
-{
-  GList *copy;
-
-  g_return_if_fail (select != NULL);
-  g_return_if_fail (GTK_IS_SELECT (select));
-  copy = g_list_copy(items);
-  select->entries = g_list_concat(select->entries, items);
-  gtk_list_append_items(GTK_LIST(select->list), copy);
-  gtk_select_update_button (select);
-}
-
-void
-gtk_select_prepend_items (GtkSelect *select, GList *items)
-{
-  GList *copy;
-
-  g_return_if_fail (select != NULL);
-  g_return_if_fail (GTK_IS_SELECT (select));
-  copy = g_list_copy(items);
-  select->entries = g_list_concat(items, select->entries);
-  gtk_list_prepend_items(GTK_LIST(select->list), copy);
-  gtk_select_update_button (select);
-}
-
-static void
-gtk_select_remove_items_internal (GtkSelect *select, GList *items,
-	       			  gboolean unref)
-{
-  GList *loop;
-  int do_free = 0;;
-
-  g_return_if_fail (select != NULL);
-  g_return_if_fail (GTK_IS_SELECT (select));
-  for (loop = items; loop; loop = loop->next) {
-    select->entries = g_list_remove(select->entries, loop->data);
-  }
-  if (select->selected && g_list_find(items, select->selected)) {
-    items = g_list_copy(items);
-    items = g_list_remove(items, select->selected);
-    do_free = 1;
-    if (!unref)
-      g_object_ref(select->selected);
-    gtk_container_remove(GTK_CONTAINER(select->entry), select->selected);
-    gtk_container_add(GTK_CONTAINER(select->entry), select->empty);
-    select->selected = NULL;
-  }
-  if (unref)
-    gtk_list_remove_items(GTK_LIST(select->list), items);
-  else
-    gtk_list_remove_items_no_unref(GTK_LIST(select->list), items);
-  if (do_free)
-    g_list_free(items);
-
-  gtk_select_update_button (select);
-}
-
-void
-gtk_select_remove_items (GtkSelect *select, GList *items)
-{
-  gtk_select_remove_items_internal(select, items, TRUE);
-}
-
-void
-gtk_select_clear_items (GtkSelect *select, gint start, gint end)
-{
-  GList *sptr, *eptr;
-  int len;
-
-  g_return_if_fail (select != NULL);
-  g_return_if_fail (GTK_IS_SELECT (select));
-  if (select->entries == NULL) {
-    return;
-  }
-  len = g_list_length(select->entries);
-  if (end > len)
-    end = len;
-  if (start > end)
-    return;
-  sptr = g_list_nth(select->entries, start);
-  eptr = g_list_nth(select->entries, end);
-  if (sptr->prev)
-    sptr->prev->next = eptr;
-  if (eptr && eptr->prev)
-    eptr->prev->next = NULL;
-  if (eptr)
-    eptr->prev = sptr->prev;
-  if (sptr == select->entries)
-    select->entries = eptr;
-  if (select->selected && g_list_find(sptr, select->selected)) {
-    gtk_container_remove(GTK_CONTAINER(select->entry), select->selected);
-    gtk_container_add(GTK_CONTAINER(select->entry), select->empty);
-    select->selected = NULL;
-  }
-  gtk_list_remove_items(GTK_LIST(select->list), sptr);
-  g_list_free(sptr);
-}
-
-void
-gtk_select_select_item (GtkSelect *select, gint item)
-{
-  g_return_if_fail (select != NULL);
-  g_return_if_fail (GTK_IS_SELECT (select));
-  gtk_list_select_item(GTK_LIST(select->list), item);
-}
-
-void
-gtk_select_select_child (GtkSelect *select, GtkWidget *child)
-{
-  g_return_if_fail (select != NULL);
-  g_return_if_fail (GTK_IS_SELECT (select));
-  gtk_list_select_child(GTK_LIST(select->list), child);
-}
-
-gint
-gtk_select_child_position (GtkSelect *select, GtkWidget *child)
-{
-  g_return_val_if_fail (select != NULL, -1);
-  g_return_val_if_fail (GTK_IS_SELECT (select), -1);
-  return g_list_index(select->entries, child);
-}


More information about the gnucash-changes mailing list