[Gnucash-changes] Add code to allow the register colors to be set
by the system theme (i.e
David Hampton
hampton at cvs.gnucash.org
Mon Jul 11 17:02:53 EDT 2005
Log Message:
-----------
Add code to allow the register colors to be set by the system theme
(i.e from gtkrc files). Remove the preferences to set the register
colors. Add a gconf keys to 1) specify whether to use the gtkrc
colors or the default gnucash colors, 2) display the
horizontal/vertical lines in the register, and 3) set the alternate
coloring mode.
Tags:
----
gnucash-gnome2-dev
Modified Files:
--------------
gnucash:
ChangeLog
gnucash/doc:
gtkrc-2.0.gnucash
gnucash/src/app-utils:
prefs.scm
gnucash/src/business/business-gnome:
dialog-invoice.c
dialog-order.c
gnc-plugin-page-invoice.c
gnucash/src/business/business-ledger:
gncEntryLedger.h
gncEntryLedgerModel.c
gnucash/src/gnome:
gnc-plugin-page-register.c
gnc-plugin-register.c
top-level.c
gnucash/src/gnome/schemas:
Makefile.am
gnucash/src/register/ledger-core:
Makefile.am
split-register-model.c
split-register-model.h
split-register.h
gnucash/src/register/register-core:
table-allgui.c
table-allgui.h
gnucash/src/register/register-gnome:
gnucash-grid.c
gnucash-header.c
gnucash-item-edit.c
gnucash-sheet.c
gnucash-sheet.h
gnucash-style.c
gnucash-style.h
Added Files:
-----------
gnucash/src/gnome/schemas:
apps_gnucash_general.schemas
Revision Data
-------------
Index: ChangeLog
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/ChangeLog,v
retrieving revision 1.1487.2.238
retrieving revision 1.1487.2.239
diff -LChangeLog -LChangeLog -u -r1.1487.2.238 -r1.1487.2.239
--- ChangeLog
+++ ChangeLog
@@ -1,3 +1,35 @@
+2005-07-11 David Hampton <hampton at employees.org>
+
+ * src/business/business-gnome/gnc-plugin-page-invoice.c:
+ * src/gnome/gnc-plugin-page-register.c:
+ * src/gnome/gnc-plugin-register.c: Add a hook to catch changes to
+ register configuration keys and update any registers. This gives
+ live updating when changes are made.
+
+ * doc/gtkrc-2.0.gnucash:
+ * src/app-utils/prefs.scm:
+ * src/business/business-gnome/dialog-invoice.c:
+ * src/business/business-gnome/dialog-order.c:
+ * src/business/business-ledger/gncEntryLedger.h:
+ * src/business/business-ledger/gncEntryLedgerModel.c:
+ * src/gnome/top-level.c:
+ * src/gnome/schemas/Makefile.am:
+ * src/gnome/schemas/apps_gnucash_general.schemas:
+ * src/register/ledger-core/Makefile.am:
+ * src/register/ledger-core/split-register-model.[ch]:
+ * src/register/ledger-core/split-register.h:
+ * src/register/register-core/table-allgui.[ch]:
+ * src/register/register-gnome/gnucash-grid.c:
+ * src/register/register-gnome/gnucash-header.c:
+ * src/register/register-gnome/gnucash-item-edit.c:
+ * src/register/register-gnome/gnucash-sheet.[ch]:
+ * src/register/register-gnome/gnucash-style.[ch]: Add code to
+ allow the register colors to be set by the system theme (i.e from
+ gtkrc files). Remove the preferences to set the register colors.
+ Add a gconf keys to 1) specify whether to use the gtkrc colors or
+ the default gnucash colors, 2) display the horizontal/vertical
+ lines in the register, and 3) set the alternate coloring mode.
+
2005-07-07 David Hampton <hampton at employees.org>
* src/business/business-gnome/Makefile.am:
Index: prefs.scm
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/app-utils/prefs.scm,v
retrieving revision 1.28.4.7
retrieving revision 1.28.4.8
diff -Lsrc/app-utils/prefs.scm -Lsrc/app-utils/prefs.scm -u -r1.28.4.7 -r1.28.4.8
--- src/app-utils/prefs.scm
+++ src/app-utils/prefs.scm
@@ -221,87 +221,6 @@
"h" (N_ "If selected, use a dialog to confirm a change to a reconciled \
transaction.") #t))
-(define (string-take-n string n)
- (substring string n (string-length string)))
-
-(gnc:register-configuration-option
- (gnc:make-font-option
- (N_ "Register") (N_ "Register font")
- "i" (N_ "The font to use in the register")
- (string-take-n (_ "register-default-font:-adobe-helvetica-medium-r-normal--*-120-*-*-*-*-*-*") 22)))
-
-(gnc:register-configuration-option
- (gnc:make-font-option
- (N_ "Register") (N_ "Register hint font")
- "j" (N_ "The font used to show hints in the register")
- (string-take-n (_ "register-hint-font:-adobe-helvetica-medium-o-normal--*-120-*-*-*-*-*-*") 19)))
-
-
-;; Register Color options
-
-(gnc:register-configuration-option
- (gnc:make-color-option
- (N_ "Register Colors") (N_ "Header color")
- "a" (N_ "The header background color")
- (list #x96 #xb2 #x84 0)
- 255
- #f))
-
-(gnc:register-configuration-option
- (gnc:make-color-option
- (N_ "Register Colors") (N_ "Primary color")
- "b" (N_ "The default background color for register rows")
- (list #xbf #xde #xba 0)
- 255
- #f))
-
-(gnc:register-configuration-option
- (gnc:make-color-option
- (N_ "Register Colors") (N_ "Secondary color")
- "c" (N_ "The default secondary background color for register rows")
- (list #xf6 #xff #xdb 0)
- 255
- #f))
-
-(gnc:register-configuration-option
- (gnc:make-color-option
- (N_ "Register Colors") (N_ "Primary active color")
- "d" (N_ "The background color for the current register row")
- (list #xff #xf0 #x99 0)
- 255
- #f))
-
-(gnc:register-configuration-option
- (gnc:make-color-option
- (N_ "Register Colors") (N_ "Secondary active color")
- "e" (N_ "The secondary background color for the current register row")
- (list #xff #xf0 #x99 0)
- 255
- #f))
-
-(gnc:register-configuration-option
- (gnc:make-color-option
- (N_ "Register Colors") (N_ "Split color")
- "f" (N_ "The default background color for split rows in the register")
- (list #xed #xe8 #xd4 0)
- 255
- #f))
-
-(gnc:register-configuration-option
- (gnc:make-color-option
- (N_ "Register Colors") (N_ "Split active color")
- "g" (N_ "The background color for the current split row in the register")
- (list #xff #xf0 #x99 0)
- 255
- #f))
-
-(gnc:register-configuration-option
- (gnc:make-simple-boolean-option
- (N_ "Register Colors") (N_ "Double mode colors alternate with transactions")
- "h" (N_ "Alternate the primary and secondary colors with each transaction, \
-not each row")
- #f))
-
;;; Summarybar Options
@@ -620,16 +539,6 @@
(N_ "Default MDI mode can be set in the GNOME \
Control Center"))))))
-(gnc:register-configuration-option
- (gnc:make-simple-boolean-option
- (N_ "_+Advanced") (N_ "Show Vertical Borders")
- "c" (N_ "By default, show vertical borders on the cells.") #f))
-
-(gnc:register-configuration-option
- (gnc:make-simple-boolean-option
- (N_ "_+Advanced") (N_ "Show Horizontal Borders")
- "d" (N_ "By default, show horizontal borders on the cells.") #f))
-
(gnc:register-configuration-option
(gnc:make-simple-boolean-option
(N_ "_+Advanced") (N_ "Auto-Raise Lists")
Index: dialog-order.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/business/business-gnome/dialog-order.c,v
retrieving revision 1.53.4.8
retrieving revision 1.53.4.9
diff -Lsrc/business/business-gnome/dialog-order.c -Lsrc/business/business-gnome/dialog-order.c -u -r1.53.4.8 -r1.53.4.9
--- src/business/business-gnome/dialog-order.c
+++ src/business/business-gnome/dialog-order.c
@@ -404,39 +404,6 @@
}
static void
-gnc_configure_register_colors (void)
-{
- GncEntryLedgerColors reg_colors;
-
- reg_colors.header_bg_color =
- gnc_lookup_color_option_argb("Register Colors",
- "Header color",
- 0xffffff);
-
- reg_colors.primary_bg_color =
- gnc_lookup_color_option_argb("Register Colors",
- "Primary color",
- 0xffffff);
-
- reg_colors.secondary_bg_color =
- gnc_lookup_color_option_argb("Register Colors",
- "Secondary color",
- 0xffffff);
-
- reg_colors.primary_active_bg_color =
- gnc_lookup_color_option_argb("Register Colors",
- "Primary active color",
- 0xffffff);
-
- reg_colors.secondary_active_bg_color =
- gnc_lookup_color_option_argb("Register Colors",
- "Secondary active color",
- 0xffffff);
-
- gnc_entry_ledger_set_colors (reg_colors);
-}
-
-static void
gnc_order_update_window (OrderWindow *ow)
{
GncOrder *order;
@@ -593,8 +560,6 @@
/*
* No existing order window found. Build a new one.
*/
- gnc_configure_register_colors ();
-
ow = g_new0 (OrderWindow, 1);
ow->book = bookp;
ow->dialog_type = type;
Index: dialog-invoice.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/business/business-gnome/dialog-invoice.c,v
retrieving revision 1.81.4.18
retrieving revision 1.81.4.19
diff -Lsrc/business/business-gnome/dialog-invoice.c -Lsrc/business/business-gnome/dialog-invoice.c -u -r1.81.4.18 -r1.81.4.19
--- src/business/business-gnome/dialog-invoice.c
+++ src/business/business-gnome/dialog-invoice.c
@@ -1303,39 +1303,6 @@
gnc_invoice_update_window (iw, NULL);
}
-static void
-gnc_configure_register_colors (void)
-{
- GncEntryLedgerColors reg_colors;
-
- reg_colors.header_bg_color =
- gnc_lookup_color_option_argb("Register Colors",
- "Header color",
- 0xffffff);
-
- reg_colors.primary_bg_color =
- gnc_lookup_color_option_argb("Register Colors",
- "Primary color",
- 0xffffff);
-
- reg_colors.secondary_bg_color =
- gnc_lookup_color_option_argb("Register Colors",
- "Secondary color",
- 0xffffff);
-
- reg_colors.primary_active_bg_color =
- gnc_lookup_color_option_argb("Register Colors",
- "Primary active color",
- 0xffffff);
-
- reg_colors.secondary_active_bg_color =
- gnc_lookup_color_option_argb("Register Colors",
- "Secondary active color",
- 0xffffff);
-
- gnc_entry_ledger_set_colors (reg_colors);
-}
-
/** Update the various widgets in the window/page vased upon the data
* in the InvoiceWindow data structure.
*
@@ -1670,8 +1637,6 @@
/*
* No existing invoice window found. Build a new one.
*/
- gnc_configure_register_colors ();
-
iw = g_new0 (InvoiceWindow, 1);
iw->book = bookp;
iw->dialog_type = type;
Index: gnc-plugin-page-invoice.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/business/business-gnome/Attic/gnc-plugin-page-invoice.c,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -Lsrc/business/business-gnome/gnc-plugin-page-invoice.c -Lsrc/business/business-gnome/gnc-plugin-page-invoice.c -u -r1.1.2.1 -r1.1.2.2
--- src/business/business-gnome/gnc-plugin-page-invoice.c
+++ src/business/business-gnome/gnc-plugin-page-invoice.c
@@ -29,6 +29,7 @@
#include "gnc-plugin-page-invoice.h"
#include "dialog-account.h"
+#include "gnc-component-manager.h"
#include "gnc-gobject-utils.h"
#include "gnc-gnome-utils.h"
#include "gnc-icons.h"
@@ -83,6 +84,7 @@
static void gnc_plugin_page_invoice_cmd_company_report (GtkAction *action, GncPluginPageInvoice *plugin_page);
static void gnc_plugin_page_redraw_help_cb( GnucashRegister *gsr, GncPluginPageInvoice *invoice_page );
+static void gnc_plugin_page_invoice_refresh_cb (GHashTable *changes, gpointer user_data);
/************************************************************
* Actions *
@@ -214,6 +216,8 @@
InvoiceWindow *iw;
GtkWidget *widget;
+
+ gint component_manager_id;
};
static GObjectClass *parent_class = NULL;
@@ -270,6 +274,7 @@
gnc_plugin_page_invoice_update_title(plugin_page);
gnc_plugin_page_set_uri(plugin_page, "default:");
+ invoice_page->priv->component_manager_id = 0;
return plugin_page;
}
@@ -391,6 +396,11 @@
G_CALLBACK (gnc_plugin_page_invoice_button_press_cb), page);
}
+ priv->component_manager_id =
+ gnc_register_gui_component(GNC_PLUGIN_PAGE_INVOICE_NAME,
+ gnc_plugin_page_invoice_refresh_cb,
+ NULL, page);
+
return priv->widget;
}
@@ -407,6 +417,11 @@
if (priv->widget == NULL)
return;
+ if (priv->component_manager_id) {
+ gnc_unregister_gui_component(priv->component_manager_id);
+ priv->component_manager_id = 0;
+ }
+
gtk_widget_hide(priv->widget);
gnc_invoice_window_destroy_cb(priv->widget, priv->iw);
priv->widget = NULL;
@@ -747,3 +762,20 @@
gnc_plugin_page_set_title(plugin_page, title);
g_free(title);
}
+
+static void
+gnc_plugin_page_invoice_refresh_cb (GHashTable *changes, gpointer user_data)
+{
+ GncPluginPageInvoice *page = user_data;
+ GtkWidget *reg;
+
+ g_return_if_fail(GNC_IS_PLUGIN_PAGE_INVOICE(page));
+
+ /* We're only looking for forced updates here. */
+ if (changes)
+ return;
+
+ reg = gnc_invoice_get_register(page->priv->iw);
+ gnucash_register_refresh_from_gconf(GNUCASH_REGISTER(reg));
+ gtk_widget_queue_draw(page->priv->widget);
+}
Index: gncEntryLedgerModel.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/business/business-ledger/gncEntryLedgerModel.c,v
retrieving revision 1.32.4.2
retrieving revision 1.32.4.3
diff -Lsrc/business/business-ledger/gncEntryLedgerModel.c -Lsrc/business/business-ledger/gncEntryLedgerModel.c -u -r1.32.4.2 -r1.32.4.3
--- src/business/business-ledger/gncEntryLedgerModel.c
+++ src/business/business-ledger/gncEntryLedgerModel.c
@@ -40,12 +40,12 @@
static GncEntryLedgerColors reg_colors =
{
- 0xffffff, /* white */
- 0xffffff,
- 0xffffff,
+ 0x96B183,
+ 0xBFDEB9,
+ 0xF6FFDA,
- 0xffffff,
- 0xffffff
+ 0xFFEF98,
+ 0xFFEF98,
};
/** Private Interfaces ***********************************************/
@@ -1197,8 +1197,3 @@
return model;
}
-
-void gnc_entry_ledger_set_colors (GncEntryLedgerColors reg_colors_new)
-{
- reg_colors = reg_colors_new;
-}
Index: gncEntryLedger.h
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/business/business-ledger/gncEntryLedger.h,v
retrieving revision 1.22.4.3
retrieving revision 1.22.4.4
diff -Lsrc/business/business-ledger/gncEntryLedger.h -Lsrc/business/business-ledger/gncEntryLedger.h -u -r1.22.4.3 -r1.22.4.4
--- src/business/business-ledger/gncEntryLedger.h
+++ src/business/business-ledger/gncEntryLedger.h
@@ -103,8 +103,6 @@
/* Get the Table */
Table * gnc_entry_ledger_get_table (GncEntryLedger *ledger);
-void gnc_entry_ledger_set_colors (GncEntryLedgerColors reg_colors_new);
-
void gnc_entry_ledger_set_parent (GncEntryLedger *ledger, gncUIWidget parent);
void gnc_entry_ledger_set_readonly (GncEntryLedger *ledger, gboolean readonly);
Index: gnc-plugin-page-register.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/gnome/Attic/gnc-plugin-page-register.c,v
retrieving revision 1.1.2.29
retrieving revision 1.1.2.30
diff -Lsrc/gnome/gnc-plugin-page-register.c -Lsrc/gnome/gnc-plugin-page-register.c -u -r1.1.2.29 -r1.1.2.30
--- src/gnome/gnc-plugin-page-register.c
+++ src/gnome/gnc-plugin-page-register.c
@@ -39,6 +39,7 @@
#include "druid-stock-split.h"
#include "global-options.h"
#include "gnc-book.h"
+#include "gnc-component-manager.h"
#include "gnc-date.h"
#include "gnc-date-edit.h"
#include "gnc-gnome-utils.h"
@@ -129,6 +130,7 @@
static void gnc_plugin_page_register_cmd_transaction_report (GtkAction *action, GncPluginPageRegister *plugin_page);
static void gnc_plugin_page_help_changed_cb( GNCSplitReg *gsr, GncPluginPageRegister *register_page );
+static void gnc_plugin_page_register_refresh_cb (GHashTable *changes, gpointer user_data);
/************************************************************/
/* Actions */
@@ -295,6 +297,8 @@
char *ui_description;
+ gint component_manager_id;
+
const char *lines_opt_page;
const char *lines_opt_name;
gint lines_default;
@@ -389,6 +393,7 @@
GNC_PLUGIN_HIDE_MENU_ADDITIONS_NAME,
GINT_TO_POINTER(1));
+ register_page->priv->component_manager_id = 0;
return plugin_page;
}
@@ -600,6 +605,11 @@
if (plugin_page->summarybar)
gtk_widget_show_all(plugin_page->summarybar);
+ priv->component_manager_id =
+ gnc_register_gui_component(GNC_PLUGIN_PAGE_REGISTER_NAME,
+ gnc_plugin_page_register_refresh_cb,
+ NULL, page);
+
/* DRH - Probably lots of other stuff from regWindowLedger should end up here. */
LEAVE(" ");
return priv->widget;
@@ -618,6 +628,11 @@
if (priv->widget == NULL)
return;
+ if (priv->component_manager_id) {
+ gnc_unregister_gui_component(priv->component_manager_id);
+ priv->component_manager_id = 0;
+ }
+
if (page->priv->sd.dialog) {
gtk_widget_destroy(page->priv->sd.dialog);
memset(&page->priv->sd, 0, sizeof(page->priv->sd));
@@ -2255,3 +2270,17 @@
g_free(help);
}
+static void
+gnc_plugin_page_register_refresh_cb (GHashTable *changes, gpointer user_data)
+{
+ GncPluginPageRegister *page = user_data;
+
+ g_return_if_fail(GNC_IS_PLUGIN_PAGE_REGISTER(page));
+
+ /* We're only looking for forced updates here. */
+ if (changes)
+ return;
+
+ gnucash_register_refresh_from_gconf(page->priv->gsr->reg);
+ gtk_widget_queue_draw(page->priv->widget);
+}
Index: top-level.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/gnome/top-level.c,v
retrieving revision 1.140.4.22
retrieving revision 1.140.4.23
diff -Lsrc/gnome/top-level.c -Lsrc/gnome/top-level.c -u -r1.140.4.22 -r1.140.4.23
--- src/gnome/top-level.c
+++ src/gnome/top-level.c
@@ -81,10 +81,6 @@
static void gnc_configure_date_format_cb(gpointer);
static void gnc_configure_date_format(void);
static void gnc_configure_account_separator_cb(gpointer);
-static void gnc_configure_register_colors_cb(gpointer);
-static void gnc_configure_register_colors(void);
-static void gnc_configure_register_borders_cb(gpointer);
-static void gnc_configure_register_borders(void);
static void gnc_configure_auto_raise_cb(gpointer);
static void gnc_configure_auto_raise(void);
static void gnc_configure_negative_color_cb(gpointer);
@@ -110,8 +106,6 @@
static SCM date_callback_id = SCM_UNDEFINED;
static SCM account_separator_callback_id = SCM_UNDEFINED;
-static SCM register_colors_callback_id = SCM_UNDEFINED;
-static SCM register_borders_callback_id = SCM_UNDEFINED;
static SCM auto_raise_callback_id = SCM_UNDEFINED;
static SCM negative_color_callback_id = SCM_UNDEFINED;
static SCM auto_decimal_callback_id = SCM_UNDEFINED;
@@ -321,16 +315,6 @@
NULL, "Accounts",
"Account Separator");
- gnc_configure_register_colors();
- register_colors_callback_id =
- gnc_register_option_change_callback(gnc_configure_register_colors_cb,
- NULL, "Register Colors", NULL);
-
- gnc_configure_register_borders();
- register_borders_callback_id =
- gnc_register_option_change_callback(gnc_configure_register_borders_cb,
- NULL, "Register", NULL);
-
gnc_configure_auto_raise();
auto_raise_callback_id =
gnc_register_option_change_callback(gnc_configure_auto_raise_cb,
@@ -439,8 +423,6 @@
gnc_unregister_option_change_callback_id(date_callback_id);
gnc_unregister_option_change_callback_id(account_separator_callback_id);
- gnc_unregister_option_change_callback_id(register_colors_callback_id);
- gnc_unregister_option_change_callback_id(register_borders_callback_id);
gnc_unregister_option_change_callback_id(auto_raise_callback_id);
gnc_unregister_option_change_callback_id(negative_color_callback_id);
gnc_unregister_option_change_callback_id(register_font_callback_id);
@@ -587,114 +569,6 @@
gnc_gui_refresh_all ();
}
-/* gnc_configure_register_colors_cb
- * Callback called when options change - sets
- * register colors to their guile values
- *
- * Args: Nothing
- * Returns: Nothing
- */
-static void
-gnc_configure_register_colors_cb (gpointer data)
-{
- gnc_configure_register_colors ();
- gnc_gui_refresh_all ();
-}
-
-/* gnc_configure_register_colors_cb
- * sets register colors to their guile values
- *
- * Args: Nothing
- * Returns: Nothing
- */
-static void
-gnc_configure_register_colors (void)
-{
- SplitRegisterColors reg_colors;
-
- reg_colors.header_bg_color =
- gnc_lookup_color_option_argb("Register Colors",
- "Header color",
- 0xffffff);
-
- reg_colors.primary_bg_color =
- gnc_lookup_color_option_argb("Register Colors",
- "Primary color",
- 0xffffff);
-
- reg_colors.secondary_bg_color =
- gnc_lookup_color_option_argb("Register Colors",
- "Secondary color",
- 0xffffff);
-
- reg_colors.primary_active_bg_color =
- gnc_lookup_color_option_argb("Register Colors",
- "Primary active color",
- 0xffffff);
-
- reg_colors.secondary_active_bg_color =
- gnc_lookup_color_option_argb("Register Colors",
- "Secondary active color",
- 0xffffff);
-
- reg_colors.split_bg_color =
- gnc_lookup_color_option_argb("Register Colors",
- "Split color",
- 0xffffff);
-
- reg_colors.split_active_bg_color =
- gnc_lookup_color_option_argb("Register Colors",
- "Split active color",
- 0xffffff);
-
- reg_colors.double_alternate_virt =
- gnc_lookup_boolean_option("Register Colors",
- "Double mode colors alternate with transactions",
- FALSE);
-
- gnc_split_register_set_colors (reg_colors);
-}
-
-
-/* gnc_configure_register_borders_cb
- * Callback called when options change - sets
- * register borders to their guile values
- *
- * Args: Nothing
- * Returns: Nothing
- */
-static void
-gnc_configure_register_borders_cb (gpointer data)
-{
- gnc_configure_register_borders ();
- gnc_gui_refresh_all ();
-}
-
-/* gnc_configure_register_border
- * sets register borders to their guile values
- *
- * Args: Nothing
- * Returns: Nothing
- */
-static void
-gnc_configure_register_borders (void)
-{
- gboolean use_vertical_lines;
- gboolean use_horizontal_lines;
-
- use_vertical_lines = gnc_lookup_boolean_option("_+Advanced",
- "Show Vertical Borders",
- FALSE);
-
-
- use_horizontal_lines = gnc_lookup_boolean_option("_+Advanced",
- "Show Horizontal Borders",
- FALSE);
-
- gnucash_style_config_register_borders (use_vertical_lines,
- use_horizontal_lines);
-}
-
/* gnc_configure_auto_raise_cb
* Callback called when options change - sets
* auto-raise status of combocell class
Index: gnc-plugin-register.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/gnome/Attic/gnc-plugin-register.c,v
retrieving revision 1.1.2.11
retrieving revision 1.1.2.12
diff -Lsrc/gnome/gnc-plugin-register.c -Lsrc/gnome/gnc-plugin-register.c -u -r1.1.2.11 -r1.1.2.12
--- src/gnome/gnc-plugin-register.c
+++ src/gnome/gnc-plugin-register.c
@@ -26,6 +26,7 @@
#include <string.h>
+#include "gnc-component-manager.h"
#include "gnc-plugin-register.h"
#include "gnc-plugin-page-register.h"
@@ -43,6 +44,7 @@
#define PLUGIN_ACTIONS_NAME "gnc-plugin-register-actions"
#define PLUGIN_UI_FILENAME "gnc-plugin-register-ui.xml"
+#define GCONF_REGISTER_SECTION "general/register"
static GtkActionEntry gnc_plugin_actions [] = {
{ "ToolsGeneralLedgerAction", NULL, N_("_General Ledger"), NULL,
@@ -57,6 +59,40 @@
};
static GObjectClass *parent_class = NULL;
+static short module = MOD_GUI;
+
+/************************************************************
+ * Other Functions *
+ ************************************************************/
+
+/** This function is called whenever an entry in the general register
+ * section of gconf is changed. It does nothing more than kick off a
+ * gui refresh which should be delivered to any open register page.
+ * The register pages will then reread their settings from gconf and
+ * update the screen.
+ *
+ * @client Unused.
+ *
+ * @cnxn_id Unused.
+ *
+ * @entry Unused.
+ *
+ * @user_data Unused.
+ */
+static void
+gnc_plugin_register_gconf_changed (GConfClient *client,
+ guint cnxn_id,
+ GConfEntry *entry,
+ gpointer user_data)
+{
+ ENTER("");
+ gnc_gui_refresh_all ();
+ LEAVE("");
+}
+
+/************************************************************
+ * Object Implementation *
+ ************************************************************/
GType
gnc_plugin_register_get_type (void)
@@ -116,6 +152,9 @@
plugin_class->actions = gnc_plugin_actions;
plugin_class->n_actions = gnc_plugin_n_actions;
plugin_class->ui_filename = PLUGIN_UI_FILENAME;
+
+ plugin_class->gconf_section = GCONF_REGISTER_SECTION;
+ plugin_class->gconf_notifications = gnc_plugin_register_gconf_changed;
}
static void
--- /dev/null
+++ src/gnome/schemas/apps_gnucash_general.schemas
@@ -0,0 +1,72 @@
+<?xml version="1.0"?>
+<gconfschemafile>
+ <schemalist>
+
+ <schema>
+ <key>/schemas/apps/gnucash/general/register/use_theme_colors</key>
+ <applyto>/apps/gnucash/general/register/use_theme_colors</applyto>
+ <owner>gnucash</owner>
+ <type>bool</type>
+ <default>FALSE</default>
+ <locale name="C">
+ <short>Color the register as specified by the system theme</short>
+ <long>
+ A value of TRUE says to color the register as specified by
+ the system theme. This can be overridden to provide custom
+ colors by editing the gtkrc file in the users home
+ directory. A value of FALSE says to show the standard
+ register colors that GnuCash has always used.
+ </long>
+ </locale>
+ </schema>
+
+ <schema>
+ <key>/schemas/apps/gnucash/general/register/alternate_color_by_transaction</key>
+ <applyto>/apps/gnucash/general/register/alternate_color_by_transaction</applyto>
+ <owner>gnucash</owner>
+ <type>bool</type>
+ <default>FALSE</default>
+ <locale name="C">
+ <short>Color all lines of a transaction the same.</short>
+ <long>
+ If TRUE all lines that make up a single transaction will use
+ the same color for their background. If FALSE, the
+ background colors are alternated on each line.
+ </long>
+ </locale>
+ </schema>
+
+ <schema>
+ <key>/schemas/apps/gnucash/general/register/use_horizontal_lines</key>
+ <applyto>/apps/gnucash/general/register/use_horizontal_lines</applyto>
+ <owner>gnucash</owner>
+ <type>bool</type>
+ <default>TRUE</default>
+ <locale name="C">
+ <short>Show horizontal borders in a register.</short>
+ <long>
+ Show horizontal borders between cells in a register. If TRUE
+ the border between cells will be indicated with a heavy line.
+ If FALSE, the border between cells will not be marked.
+ </long>
+ </locale>
+ </schema>
+
+ <schema>
+ <key>/schemas/apps/gnucash/general/register/use_vertical_lines</key>
+ <applyto>/apps/gnucash/general/register/use_vertical_lines</applyto>
+ <owner>gnucash</owner>
+ <type>bool</type>
+ <default>TRUE</default>
+ <locale name="C">
+ <short>Show vertical borders in a register.</short>
+ <long>
+ Show vertical borders between cells in a register. If TRUE
+ the border between cells will be indicated with a heavy line.
+ If FALSE, the border between cells will not be marked.
+ </long>
+ </locale>
+ </schema>
+
+ </schemalist>
+</gconfschemafile>
Index: Makefile.am
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/gnome/schemas/Attic/Makefile.am,v
retrieving revision 1.1.2.5
retrieving revision 1.1.2.6
diff -Lsrc/gnome/schemas/Makefile.am -Lsrc/gnome/schemas/Makefile.am -u -r1.1.2.5 -r1.1.2.6
--- src/gnome/schemas/Makefile.am
+++ src/gnome/schemas/Makefile.am
@@ -3,8 +3,9 @@
apps_gnucash_dialog_common.schemas \
apps_gnucash_dialog_commodities.schemas \
apps_gnucash_dialog_prices.schemas \
- apps_gnucash_window_pages_register.schemas \
- apps_gnucash_dialog_totd.schemas
+ apps_gnucash_dialog_totd.schemas \
+ apps_gnucash_general.schemas \
+ apps_gnucash_window_pages_register.schemas
install-data-local:
if GCONF_SCHEMAS_INSTALL
Index: Makefile.am
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/register/ledger-core/Makefile.am,v
retrieving revision 1.25.4.1
retrieving revision 1.25.4.2
diff -Lsrc/register/ledger-core/Makefile.am -Lsrc/register/ledger-core/Makefile.am -u -r1.25.4.1 -r1.25.4.2
--- src/register/ledger-core/Makefile.am
+++ src/register/ledger-core/Makefile.am
@@ -25,6 +25,7 @@
libgncmod_ledger_core_la_LDFLAGS = -module
libgncmod_ledger_core_la_LIBADD = \
+ ${top_builddir}/src/core-utils/libcore-utils.la \
${top_builddir}/src/gnome-utils/libgncmod-gnome-utils.la \
${top_builddir}/src/app-utils/libgncmod-app-utils.la \
${top_builddir}/src/register/register-core/libgncmod-register-core.la \
@@ -34,6 +35,7 @@
-I${top_srcdir}/src \
-I${top_srcdir}/src/engine \
-I${top_srcdir}/src/gnc-module \
+ -I${top_srcdir}/src/core-utils \
-I${top_srcdir}/src/app-utils \
-I${top_srcdir}/src/gnome-utils \
-I${top_srcdir}/src/register/register-core \
Index: split-register.h
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/register/ledger-core/split-register.h,v
retrieving revision 1.16.4.4
retrieving revision 1.16.4.5
diff -Lsrc/register/ledger-core/split-register.h -Lsrc/register/ledger-core/split-register.h -u -r1.16.4.4 -r1.16.4.5
--- src/register/ledger-core/split-register.h
+++ src/register/ledger-core/split-register.h
@@ -229,8 +229,6 @@
guint32 split_bg_color;
guint32 split_active_bg_color;
-
- gboolean double_alternate_virt;
} SplitRegisterColors;
@@ -403,9 +401,6 @@
void gnc_split_register_show_present_divider (SplitRegister *reg,
gboolean show_present);
-/** Set the colors used by SplitRegisters */
-void gnc_split_register_set_colors (SplitRegisterColors reg_colors);
-
/** If use_red is TRUE, negative amounts will be printed in red. */
void gnc_split_register_colorize_negative (gboolean use_red);
Index: split-register-model.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/register/ledger-core/split-register-model.c,v
retrieving revision 1.50.2.3
retrieving revision 1.50.2.4
diff -Lsrc/register/ledger-core/split-register-model.c -Lsrc/register/ledger-core/split-register-model.c -u -r1.50.2.3 -r1.50.2.4
--- src/register/ledger-core/split-register-model.c
+++ src/register/ledger-core/split-register-model.c
@@ -29,6 +29,7 @@
#include "datecell.h"
#include "global-options.h"
#include "gnc-engine-util.h"
+#include "gnc-gconf-utils.h"
#include "gnc-err-popup.h"
#include "gnc-ui.h"
#include "gnc-ui-util.h"
@@ -43,16 +44,13 @@
static SplitRegisterColors reg_colors =
{
- 0xffffff, /* white */
- 0xffffff,
- 0xffffff,
-
- 0xffffff,
- 0xffffff,
- 0xffffff,
- 0xffffff,
-
- FALSE /* double mode alternate by physical row */
+ 0x96B183,
+ 0xBFDEB9,
+ 0xF6FFDA,
+ 0xFFEF98,
+ 0xFFEF98,
+ 0xEDE7D3,
+ 0xFFEF98,
};
/* This static indicates the debugging module that this .o belongs to. */
@@ -498,6 +496,7 @@
VirtualCell *vcell;
guint32 bg_color;
gboolean is_current;
+ gboolean double_alternate_virt;
if (hatching)
*hatching = FALSE;
@@ -538,9 +537,12 @@
if (safe_strcmp (cursor_name, CURSOR_DOUBLE_JOURNAL) == 0 ||
safe_strcmp (cursor_name, CURSOR_DOUBLE_LEDGER) == 0)
{
+ double_alternate_virt = gnc_gconf_get_bool(GCONF_GENERAL_REGISTER,
+ "alternate_color_by_transaction",
+ NULL);
if (is_current)
{
- if (reg_colors.double_alternate_virt)
+ if (double_alternate_virt)
return vcell->start_primary_color ?
reg_colors.primary_active_bg_color :
reg_colors.secondary_active_bg_color;
@@ -550,7 +552,7 @@
reg_colors.secondary_active_bg_color;
}
- if (reg_colors.double_alternate_virt)
+ if (double_alternate_virt)
return vcell->start_primary_color ?
reg_colors.primary_bg_color :
reg_colors.secondary_bg_color;
@@ -573,6 +575,89 @@
return bg_color;
}
+static RegisterColor
+gnc_split_register_get_gtkrc_bg_color (VirtualLocation virt_loc,
+ gboolean *hatching,
+ gpointer user_data)
+{
+ SplitRegister *reg = user_data;
+ const char *cursor_name;
+ VirtualCell *vcell;
+ gboolean is_current;
+ gboolean double_alternate_virt;
+
+ if (!reg)
+ return COLOR_UNKNOWN;
+
+ if (gnc_table_virtual_location_in_header (reg->table, virt_loc))
+ return COLOR_HEADER;
+
+ vcell = gnc_table_get_virtual_cell (reg->table, virt_loc.vcell_loc);
+ if (!vcell || !vcell->cellblock)
+ return COLOR_UNKNOWN;
+
+ if ((virt_loc.phys_col_offset < vcell->cellblock->start_col) ||
+ (virt_loc.phys_col_offset > vcell->cellblock->stop_col))
+ return COLOR_UNKNOWN;
+
+ is_current = virt_cell_loc_equal (reg->table->current_cursor_loc.vcell_loc,
+ virt_loc.vcell_loc);
+
+ cursor_name = vcell->cellblock->cursor_name;
+
+ if (safe_strcmp (cursor_name, CURSOR_SINGLE_JOURNAL) == 0 ||
+ safe_strcmp (cursor_name, CURSOR_SINGLE_LEDGER) == 0)
+ {
+ if (is_current)
+ return vcell->start_primary_color ?
+ COLOR_PRIMARY_ACTIVE :
+ COLOR_SECONDARY_ACTIVE;
+
+ return vcell->start_primary_color ?
+ COLOR_PRIMARY : COLOR_SECONDARY;
+ }
+
+ if (safe_strcmp (cursor_name, CURSOR_DOUBLE_JOURNAL) == 0 ||
+ safe_strcmp (cursor_name, CURSOR_DOUBLE_LEDGER) == 0)
+ {
+ double_alternate_virt = gnc_gconf_get_bool(GCONF_GENERAL_REGISTER,
+ "alternate_color_by_transaction",
+ NULL);
+ if (is_current)
+ {
+ if (double_alternate_virt)
+ return vcell->start_primary_color ?
+ COLOR_PRIMARY_ACTIVE :
+ COLOR_SECONDARY_ACTIVE;
+
+ return (virt_loc.phys_row_offset % 2 == 0) ?
+ COLOR_PRIMARY_ACTIVE :
+ COLOR_SECONDARY_ACTIVE;
+ }
+
+ if (double_alternate_virt)
+ return vcell->start_primary_color ?
+ COLOR_PRIMARY :
+ COLOR_SECONDARY;
+
+ return (virt_loc.phys_row_offset % 2 == 0) ?
+ COLOR_PRIMARY :
+ COLOR_SECONDARY;
+ }
+
+ if (safe_strcmp (cursor_name, CURSOR_SPLIT) == 0)
+ {
+ if (is_current)
+ return COLOR_SPLIT_ACTIVE;
+
+ return COLOR_SPLIT;
+ }
+
+ PWARN ("Unexpected cursor: %s\n", cursor_name);
+
+ return COLOR_UNKNOWN;
+}
+
static guint32
gnc_split_register_get_debcred_bg_color (VirtualLocation virt_loc,
gboolean *hatching,
@@ -2339,6 +2424,11 @@
gnc_table_model_set_bg_color_handler
(model,
+ gnc_split_register_get_gtkrc_bg_color,
+ "gtkrc");
+
+ gnc_table_model_set_bg_color_handler
+ (model,
gnc_split_register_get_debcred_bg_color,
DEBT_CELL);
@@ -2448,9 +2538,3 @@
{
use_red_for_negative = use_red;
}
-
-void
-gnc_split_register_set_colors (SplitRegisterColors reg_colors_new)
-{
- reg_colors = reg_colors_new;
-}
Index: split-register-model.h
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/register/ledger-core/split-register-model.h,v
retrieving revision 1.1
retrieving revision 1.1.6.1
diff -Lsrc/register/ledger-core/split-register-model.h -Lsrc/register/ledger-core/split-register-model.h -u -r1.1 -r1.1.6.1
--- src/register/ledger-core/split-register-model.h
+++ src/register/ledger-core/split-register-model.h
@@ -28,4 +28,15 @@
TableModel * gnc_split_register_model_new (void);
TableModel * gnc_template_register_model_new (void);
+typedef enum {
+ COLOR_UNKNOWN,
+ COLOR_HEADER,
+ COLOR_PRIMARY,
+ COLOR_PRIMARY_ACTIVE,
+ COLOR_SECONDARY,
+ COLOR_SECONDARY_ACTIVE,
+ COLOR_SPLIT,
+ COLOR_SPLIT_ACTIVE,
+} RegisterColor;
+
#endif
Index: table-allgui.h
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/register/register-core/table-allgui.h,v
retrieving revision 1.15.4.1
retrieving revision 1.15.4.2
diff -Lsrc/register/register-core/table-allgui.h -Lsrc/register/register-core/table-allgui.h -u -r1.15.4.1 -r1.15.4.2
--- src/register/register-core/table-allgui.h
+++ src/register/register-core/table-allgui.h
@@ -99,6 +99,7 @@
#include "table-layout.h"
#include "table-model.h"
+#define GCONF_GENERAL_REGISTER "general/register"
/* The VirtualCell structure holds information about each virtual cell. */
typedef struct
@@ -205,6 +206,8 @@
guint32 gnc_table_get_bg_color (Table *table, VirtualLocation virt_loc,
gboolean *hatching);
+guint32 gnc_table_get_gtkrc_bg_color (Table *table, VirtualLocation virt_loc,
+ gboolean *hatching);
void gnc_table_get_borders (Table *table, VirtualLocation virt_loc,
PhysicalCellBorders *borders);
Index: table-allgui.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/register/register-core/table-allgui.c,v
retrieving revision 1.35.4.1
retrieving revision 1.35.4.2
diff -Lsrc/register/register-core/table-allgui.c -Lsrc/register/register-core/table-allgui.c -u -r1.35.4.1 -r1.35.4.2
--- src/register/register-core/table-allgui.c
+++ src/register/register-core/table-allgui.c
@@ -390,6 +390,30 @@
table->model->handler_user_data);
}
+guint32
+gnc_table_get_gtkrc_bg_color (Table *table, VirtualLocation virt_loc,
+ gboolean *hatching)
+{
+ TableGetBGColorHandler bg_color_handler;
+ const char *cell_name;
+
+ if (hatching)
+ *hatching = FALSE;
+
+ if (!table || !table->model)
+ return 0xffffff; /* white */
+
+ cell_name = gnc_table_get_cell_name (table, virt_loc);
+
+ bg_color_handler = gnc_table_model_get_bg_color_handler (table->model,
+ "gtkrc");
+ if (!bg_color_handler)
+ return 0xffffff;
+
+ return bg_color_handler (virt_loc, hatching,
+ table->model->handler_user_data);
+}
+
void
gnc_table_get_borders (Table *table, VirtualLocation virt_loc,
PhysicalCellBorders *borders)
Index: gtkrc-2.0.gnucash
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/doc/Attic/gtkrc-2.0.gnucash,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -Ldoc/gtkrc-2.0.gnucash -Ldoc/gtkrc-2.0.gnucash -u -r1.1.2.2 -r1.1.2.3
--- doc/gtkrc-2.0.gnucash
+++ doc/gtkrc-2.0.gnucash
@@ -126,11 +126,46 @@
#
-# Register
+# Register - Font
#
style "gnc-register"
{
font_name = "Sans 10"
}
-
widget "*.GnucashSheet" style "gnc-register"
+
+
+#
+# Register Window - Colors
+#
+
+# The header lines at the top of a register.
+style "gnc-register-header"
+{
+ base[NORMAL] = "#B18396"
+}
+
+# The color of the first line/transaction in a register.
+style "gnc-register-primary"
+{
+ base[NORMAL] = "#DEB9BF"
+ base[SELECTED] = "#EF98FF"
+}
+
+# The color of the second line/transaction in a register.
+style "gnc-register-secondary"
+{
+ base[NORMAL] = "#FFDAF6"
+ base[SELECTED] = "#EF98FF"
+}
+
+# The color of any "split" lines in a register.
+style "gnc-register-split"
+{
+ base[NORMAL] = "#E7D3ED"
+ base[SELECTED] = "#EF98FF"
+}
+widget "GncMainWindow.*.header_color" style : highest "gnc-register-header"
+widget "GncMainWindow.*.primary_color" style : highest "gnc-register-primary"
+widget "GncMainWindow.*.secondary_color" style : highest "gnc-register-secondary"
+widget "GncMainWindow.*.split_color" style : highest "gnc-register-split"
Index: gnucash-sheet.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/register/register-gnome/gnucash-sheet.c,v
retrieving revision 1.19.4.13
retrieving revision 1.19.4.14
diff -Lsrc/register/register-gnome/gnucash-sheet.c -Lsrc/register/register-gnome/gnucash-sheet.c -u -r1.19.4.13 -r1.19.4.14
--- src/register/register-gnome/gnucash-sheet.c
+++ src/register/register-gnome/gnucash-sheet.c
@@ -33,6 +33,7 @@
#include "gnucash-sheet.h"
#include "dialog-utils.h"
+#include "gnc-gconf-utils.h"
#include "gnucash-color.h"
#include "gnucash-grid.h"
#include "gnucash-cursor.h"
@@ -1422,6 +1423,32 @@
gnc_item_edit_paste_clipboard(item_edit, GDK_CURRENT_TIME);
}
+static void
+gnucash_sheet_refresh_from_gconf (GnucashSheet *sheet)
+{
+ g_return_if_fail(sheet != NULL);
+ g_return_if_fail(GNUCASH_IS_SHEET(sheet));
+
+ sheet->use_theme_colors = gnc_gconf_get_bool(GCONF_GENERAL_REGISTER,
+ "use_theme_colors", NULL);
+ sheet->use_horizontal_lines = gnc_gconf_get_bool(GCONF_GENERAL_REGISTER,
+ "use_horizontal_lines", NULL);
+ sheet->use_vertical_lines = gnc_gconf_get_bool(GCONF_GENERAL_REGISTER,
+ "use_vertical_lines", NULL);
+}
+
+void
+gnucash_register_refresh_from_gconf (GnucashRegister *reg)
+{
+ GnucashSheet *sheet;
+
+ g_return_if_fail(reg != NULL);
+ g_return_if_fail(GNUCASH_IS_REGISTER(reg));
+
+ sheet = GNUCASH_SHEET(reg->sheet);
+ gnucash_sheet_refresh_from_gconf(sheet);
+}
+
static gboolean
gnucash_sheet_clipboard_event (GnucashSheet *sheet, GdkEventKey *event)
{
@@ -2188,6 +2215,115 @@
}
static void
+gnucash_sheet_realize_entry (GnucashSheet *sheet, GtkWidget *entry)
+{
+ gtk_widget_realize (entry);
+}
+
+/*************************************************************/
+
+/* This code is one big hack to use gtkrc to set cell colors in a
+ * register. Because the cells are just boxes drawn on a gnome
+ * canvas, there's no way to specify the individual cells in a gtkrc
+ * file. This code creates four hidden GtkEntry widgets and names
+ * them so that they *can* be specified in gtkrc. It then looks up
+ * the colors specified on these hidden widgets and uses it for the
+ * cells drawn on the canvas. This code should all go away whenever
+ * the register is rewritten.
+ */
+
+/** Map a cell type to a gtkrc specified color. */
+GdkColor *
+get_gtkrc_color (GnucashSheet *sheet,
+ RegisterColor field_type)
+{
+ GtkWidget *widget = NULL;
+ GtkStyle *style;
+ GdkColor *white;
+ GdkColor *color = NULL;
+
+ white = gnucash_color_argb_to_gdk (0xFFFFFF);
+ switch (field_type) {
+ default:
+ return white;
+
+ case COLOR_HEADER:
+ widget = sheet->header_color;
+ break;
+
+ case COLOR_PRIMARY:
+ case COLOR_PRIMARY_ACTIVE:
+ widget = sheet->primary_color;
+ break;
+
+ case COLOR_SECONDARY:
+ case COLOR_SECONDARY_ACTIVE:
+ widget = sheet->secondary_color;
+ break;
+
+ case COLOR_SPLIT:
+ case COLOR_SPLIT_ACTIVE:
+ widget = sheet->split_color;
+ break;
+ }
+
+ style = gtk_widget_get_style(widget);
+ if (!style)
+ return white;
+
+ switch (field_type) {
+ default:
+ return white;
+
+ case COLOR_HEADER:
+ case COLOR_PRIMARY:
+ case COLOR_SECONDARY:
+ case COLOR_SPLIT:
+ color = &style->base[GTK_STATE_NORMAL];
+ break;
+
+ case COLOR_PRIMARY_ACTIVE:
+ case COLOR_SECONDARY_ACTIVE:
+ case COLOR_SPLIT_ACTIVE:
+ color = &style->base[GTK_STATE_SELECTED];
+ break;
+ }
+
+ gnucash_color_alloc_gdk(color);
+ return color;
+}
+
+/** Create the entries used for nameing register colors in gtkrc. */
+static void
+gnucash_sheet_create_color_hack(GnucashSheet *sheet)
+{
+ sheet->header_color = gtk_entry_new();
+ sheet->primary_color = gtk_entry_new();
+ sheet->secondary_color = gtk_entry_new();
+ sheet->split_color = gtk_entry_new();
+
+ gtk_widget_set_name(sheet->header_color, "header_color");
+ gtk_widget_set_name(sheet->primary_color, "primary_color");
+ gtk_widget_set_name(sheet->secondary_color, "secondary_color");
+ gtk_widget_set_name(sheet->split_color, "split_color");
+
+ g_signal_connect_after(sheet, "realize",
+ G_CALLBACK(gnucash_sheet_realize_entry),
+ sheet->header_color);
+ g_signal_connect_after(sheet, "realize",
+ G_CALLBACK(gnucash_sheet_realize_entry),
+ sheet->primary_color);
+ g_signal_connect_after(sheet, "realize",
+ G_CALLBACK(gnucash_sheet_realize_entry),
+ sheet->secondary_color);
+ g_signal_connect_after(sheet, "realize",
+ G_CALLBACK(gnucash_sheet_realize_entry),
+ sheet->split_color);
+}
+
+/*************************************************************/
+
+static void
gnucash_sheet_class_init (GnucashSheetClass *class)
{
GObjectClass *gobject_class;
@@ -2285,12 +2421,6 @@
return gnucash_sheet_type;
}
-static void
-gnucash_sheet_realize_entry (GnucashSheet *sheet, GtkWidget *entry)
-{
- gtk_widget_realize (entry);
-}
-
GtkWidget *
gnucash_sheet_new (Table *table)
{
@@ -2343,6 +2473,10 @@
g_signal_connect_after(sheet, "realize",
G_CALLBACK(gnucash_sheet_realize_entry),
sheet->entry);
+
+ gnucash_sheet_refresh_from_gconf(sheet);
+ gnucash_sheet_create_color_hack(sheet);
+
return GTK_WIDGET(sheet);
}
@@ -2459,6 +2593,7 @@
GtkWidget *widget;
GtkWidget *sheet;
GtkWidget *scrollbar;
+ GtkWidget *box;
reg = g_object_new (GNUCASH_TYPE_REGISTER, NULL);
widget = GTK_WIDGET(reg);
@@ -2510,6 +2645,27 @@
reg->hscrollbar = scrollbar;
gtk_widget_show(scrollbar);
+ /* The gtkrc color helper widgets need to be part of a window
+ * hierarchy so they can be realized. Stick them in a box
+ * underneath the register, but don't show the box to the
+ * user. */
+ box = gtk_hbox_new(FALSE, 0);
+ gtk_widget_set_no_show_all(GTK_WIDGET(box), TRUE);
+ gtk_box_pack_start_defaults(GTK_BOX(box),
+ GNUCASH_SHEET(sheet)->header_color);
+ gtk_box_pack_start_defaults(GTK_BOX(box),
+ GNUCASH_SHEET(sheet)->primary_color);
+ gtk_box_pack_start_defaults(GTK_BOX(box),
+ GNUCASH_SHEET(sheet)->secondary_color);
+ gtk_box_pack_start_defaults(GTK_BOX(box),
+ GNUCASH_SHEET(sheet)->split_color);
+
+ gtk_table_attach (GTK_TABLE(widget), box,
+ 0, 1, 4, 5,
+ GTK_FILL | GTK_EXPAND | GTK_SHRINK,
+ GTK_FILL | GTK_EXPAND | GTK_SHRINK,
+ 0, 0);
+
return widget;
}
Index: gnucash-style.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/register/register-gnome/gnucash-style.c,v
retrieving revision 1.10.4.4
retrieving revision 1.10.4.5
diff -Lsrc/register/register-gnome/gnucash-style.c -Lsrc/register/register-gnome/gnucash-style.c -u -r1.10.4.4 -r1.10.4.5
--- src/register/register-gnome/gnucash-style.c
+++ src/register/register-gnome/gnucash-style.c
@@ -31,15 +31,13 @@
#include "gnucash-item-edit.h"
#include "gnucash-style.h"
#include "messages.h"
+#include "gnc-gconf-utils.h"
#include "gnc-engine-util.h"
/** GLOBALS *********************************************************/
/* This static indicates the debugging module that this .o belongs to. */
#define DEFAULT_STYLE_WIDTH 680
-static gboolean use_vertical_lines = TRUE;
-static gboolean use_horizontal_lines = TRUE;
-
static gpointer
style_get_key (SheetBlockStyle *style)
@@ -568,15 +566,6 @@
void
-gnucash_style_config_register_borders (gboolean use_vertical_lines_in,
- gboolean use_horizontal_lines_in)
-{
- use_vertical_lines = use_vertical_lines_in;
- use_horizontal_lines = use_horizontal_lines_in;
-}
-
-
-void
gnucash_sheet_get_borders (GnucashSheet *sheet, VirtualLocation virt_loc,
PhysicalCellBorders *borders)
{
@@ -586,13 +575,13 @@
g_return_if_fail (sheet != NULL);
g_return_if_fail (GNUCASH_IS_SHEET (sheet));
- line_style = use_horizontal_lines ?
+ line_style = sheet->use_horizontal_lines ?
CELL_BORDER_LINE_NORMAL : CELL_BORDER_LINE_NONE;
borders->top = line_style;
borders->bottom = line_style;
- line_style = use_vertical_lines ?
+ line_style = sheet->use_vertical_lines ?
CELL_BORDER_LINE_NORMAL : CELL_BORDER_LINE_NONE;
borders->left = line_style;
Index: gnucash-header.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/register/register-gnome/gnucash-header.c,v
retrieving revision 1.7.6.3
retrieving revision 1.7.6.4
diff -Lsrc/register/register-gnome/gnucash-header.c -Lsrc/register/register-gnome/gnucash-header.c -u -r1.7.6.3 -r1.7.6.4
--- src/register/register-gnome/gnucash-header.c
+++ src/register/register-gnome/gnucash-header.c
@@ -75,7 +75,7 @@
int xpaint, ypaint;
const char *text;
CellBlock *cb;
- guint32 argb;
+ guint32 argb, color_type;
int i, j;
int w, h;
PangoLayout *layout;
@@ -85,9 +85,14 @@
virt_loc.phys_row_offset = 0;
virt_loc.phys_col_offset = 0;
- argb = gnc_table_get_bg_color (table, virt_loc, NULL);
-
- bg_color = gnucash_color_argb_to_gdk (argb);
+ if (header->sheet->use_theme_colors) {
+ color_type = gnc_table_get_gtkrc_bg_color (table, virt_loc,
+ NULL);
+ bg_color = get_gtkrc_color(header->sheet, color_type);
+ } else {
+ argb = gnc_table_get_bg_color (table, virt_loc, NULL);
+ bg_color = gnucash_color_argb_to_gdk (argb);
+ }
h = style->dimensions->height;
h *= header->num_phys_rows;
Index: gnucash-grid.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/register/register-gnome/gnucash-grid.c,v
retrieving revision 1.2.6.7
retrieving revision 1.2.6.8
diff -Lsrc/register/register-gnome/gnucash-grid.c -Lsrc/register/register-gnome/gnucash-grid.c -u -r1.2.6.7 -r1.2.6.8
--- src/register/register-gnome/gnucash-grid.c
+++ src/register/register-gnome/gnucash-grid.c
@@ -369,12 +369,18 @@
/* gint x_offset, y_offset;*/
GdkRectangle rect;
gboolean hatching;
- guint32 argb;
+ guint32 argb, color_type;
gdk_gc_set_background (grid->gc, &gn_white);
- argb = gnc_table_get_bg_color (table, virt_loc, &hatching);
- bg_color = gnucash_color_argb_to_gdk (argb);
+ if (grid->sheet->use_theme_colors) {
+ color_type = gnc_table_get_gtkrc_bg_color (table, virt_loc,
+ &hatching);
+ bg_color = get_gtkrc_color(grid->sheet, color_type);
+ } else {
+ argb = gnc_table_get_bg_color (table, virt_loc, &hatching);
+ bg_color = gnucash_color_argb_to_gdk (argb);
+ }
gdk_gc_set_foreground (grid->gc, bg_color);
gdk_draw_rectangle (drawable, grid->gc, TRUE,
Index: gnucash-style.h
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/register/register-gnome/gnucash-style.h,v
retrieving revision 1.6.4.1
retrieving revision 1.6.4.2
diff -Lsrc/register/register-gnome/gnucash-style.h -Lsrc/register/register-gnome/gnucash-style.h -u -r1.6.4.1 -r1.6.4.2
--- src/register/register-gnome/gnucash-style.h
+++ src/register/register-gnome/gnucash-style.h
@@ -108,8 +108,6 @@
void gnucash_style_ref (SheetBlockStyle *style);
void gnucash_style_unref (SheetBlockStyle *style);
-void gnucash_style_config_register_borders (gboolean use_vertical_lines,
- gboolean use_horizontal_lines);
void gnucash_sheet_get_borders (GnucashSheet *sheet, VirtualLocation virt_loc,
PhysicalCellBorders *borders);
Index: gnucash-sheet.h
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/register/register-gnome/gnucash-sheet.h,v
retrieving revision 1.7.4.3
retrieving revision 1.7.4.4
diff -Lsrc/register/register-gnome/gnucash-sheet.h -Lsrc/register/register-gnome/gnucash-sheet.h -u -r1.7.4.3 -r1.7.4.4
--- src/register/register-gnome/gnucash-sheet.h
+++ src/register/register-gnome/gnucash-sheet.h
@@ -23,6 +23,8 @@
#include <gnome.h>
+#include "split-register-model.h"
+
#include "table-allgui.h"
#define CELL_VPADDING 3
@@ -85,6 +87,14 @@
GnomeCanvasItem *item_editor;
GtkWidget *entry;
+ gboolean use_theme_colors;
+ gboolean use_horizontal_lines;
+ gboolean use_vertical_lines;
+ GtkWidget *header_color;
+ GtkWidget *primary_color;
+ GtkWidget *secondary_color;
+ GtkWidget *split_color;
+
gboolean input_cancelled;
gint top_block; /* maybe not fully visible */
@@ -202,7 +212,7 @@
void gnucash_register_cut_clipboard (GnucashRegister *reg);
void gnucash_register_copy_clipboard (GnucashRegister *reg);
void gnucash_register_paste_clipboard (GnucashRegister *reg);
-
+void gnucash_register_refresh_from_gconf (GnucashRegister *reg);
typedef struct
{
@@ -219,6 +229,8 @@
void (*redraw_help) (GnucashRegister *reg);
} GnucashRegisterClass;
+GdkColor *get_gtkrc_color (GnucashSheet *sheet, RegisterColor field_type);
+
#endif
Index: gnucash-item-edit.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/register/register-gnome/gnucash-item-edit.c,v
retrieving revision 1.1.6.10
retrieving revision 1.1.6.11
diff -Lsrc/register/register-gnome/gnucash-item-edit.c -Lsrc/register/register-gnome/gnucash-item-edit.c -u -r1.1.6.10 -r1.1.6.11
--- src/register/register-gnome/gnucash-item-edit.c
+++ src/register/register-gnome/gnucash-item-edit.c
@@ -129,7 +129,7 @@
Table *table;
gboolean hatching;
- guint32 argb;
+ guint32 argb, color_type;
int xd, yd, wd, hd, dx, dy;
int start_pos, end_pos;
@@ -145,9 +145,17 @@
block = gnucash_sheet_get_block (item_edit->sheet,
item_edit->virt_loc.vcell_loc);
- argb = gnc_table_get_bg_color (table, item_edit->virt_loc, &hatching);
+ if (item_edit->sheet->use_theme_colors) {
+ color_type = gnc_table_get_gtkrc_bg_color (table,
+ item_edit->virt_loc,
+ &hatching);
+ info->bg_color = get_gtkrc_color(item_edit->sheet, color_type);
+ } else {
+ argb = gnc_table_get_bg_color (table, item_edit->virt_loc,
+ &hatching);
+ info->bg_color = gnucash_color_argb_to_gdk (argb);
+ }
- info->bg_color = gnucash_color_argb_to_gdk (argb);
info->hatching = hatching;
info->fg_color = &gn_black;
More information about the gnucash-changes
mailing list