mirror of
https://github.com/Gnucash/gnucash.git
synced 2024-11-26 02:40:43 -06:00
Make the register fonts configurable.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@2523 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
cd29cf5d47
commit
4d99e3f671
10
ChangeLog
10
ChangeLog
@ -1,3 +1,13 @@
|
||||
2000-06-28 Dave Peticolas <dave@krondo.com>
|
||||
|
||||
* src/scm/prefs.scm: add options for the register fonts.
|
||||
|
||||
* src/gnome/top-level.c: configure the register fonts from
|
||||
callbacks.
|
||||
|
||||
* src/register/gnome/gnucash-style.c: make the register font and
|
||||
hint fonts configurable outside the register.
|
||||
|
||||
2000-06-28 Robert Graham Merkel <rgmerk@mira.net>
|
||||
|
||||
* src/gnome/dialog-totd.c: If somebody tries to open a second
|
||||
|
@ -207,6 +207,21 @@ gnc_option_set_ui_value(GNCOption *option, gboolean use_default)
|
||||
bad_value = TRUE;
|
||||
|
||||
}
|
||||
else if (safe_strcmp(type, "font") == 0)
|
||||
{
|
||||
if (gh_string_p(value))
|
||||
{
|
||||
char *string = gh_scm2newstr(value, NULL);
|
||||
if ((string != NULL) && (*string != '\0'))
|
||||
{
|
||||
GnomeFontPicker *picker = GNOME_FONT_PICKER(option->widget);
|
||||
gnome_font_picker_set_font_name(picker, string);
|
||||
free(string);
|
||||
}
|
||||
}
|
||||
else
|
||||
bad_value = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
PERR("Unknown type. Ignoring.\n");
|
||||
@ -345,6 +360,14 @@ gnc_option_get_ui_value(GNCOption *option)
|
||||
result = gh_cons(gh_double2scm(green * scale), result);
|
||||
result = gh_cons(gh_double2scm(red * scale), result);
|
||||
}
|
||||
else if (safe_strcmp(type, "font") == 0)
|
||||
{
|
||||
GnomeFontPicker *picker = GNOME_FONT_PICKER(option->widget);
|
||||
char * string;
|
||||
|
||||
string = gnome_font_picker_get_font_name(picker);
|
||||
result = gh_str02scm(string);
|
||||
}
|
||||
else
|
||||
{
|
||||
PERR("Unknown type for refresh. Ignoring.\n");
|
||||
@ -751,6 +774,19 @@ gnc_option_color_changed_cb(GnomeColorPicker *picker, guint arg1, guint arg2,
|
||||
gnome_property_box_changed(GNOME_PROPERTY_BOX(pbox));
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_option_font_changed_cb(GnomeFontPicker *picker, gchar *font_name,
|
||||
gpointer data)
|
||||
{
|
||||
GtkWidget *pbox;
|
||||
GNCOption *option = data;
|
||||
|
||||
option->changed = TRUE;
|
||||
|
||||
pbox = gtk_widget_get_toplevel(GTK_WIDGET(picker));
|
||||
gnome_property_box_changed(GNOME_PROPERTY_BOX(pbox));
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_option_set_ui_widget(GNCOption *option,
|
||||
GtkBox *page_box,
|
||||
@ -1070,6 +1106,34 @@ gnc_option_set_ui_widget(GNCOption *option,
|
||||
gnc_option_create_default_button(option, tooltips),
|
||||
FALSE, FALSE, 0);
|
||||
}
|
||||
else if (safe_strcmp(type, "font") == 0)
|
||||
{
|
||||
GtkWidget *label;
|
||||
gchar *colon_name;
|
||||
|
||||
colon_name = g_strconcat(name, ":", NULL);
|
||||
label = gtk_label_new(colon_name);
|
||||
gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5);
|
||||
g_free(colon_name);
|
||||
|
||||
enclosing = gtk_hbox_new(FALSE, 5);
|
||||
value = gnome_font_picker_new();
|
||||
gnome_font_picker_set_mode(GNOME_FONT_PICKER(value),
|
||||
GNOME_FONT_PICKER_MODE_FONT_INFO);
|
||||
|
||||
option->widget = value;
|
||||
|
||||
gnc_option_set_ui_value(option, FALSE);
|
||||
|
||||
gtk_signal_connect(GTK_OBJECT(value), "font-set",
|
||||
GTK_SIGNAL_FUNC(gnc_option_font_changed_cb), option);
|
||||
|
||||
gtk_box_pack_start(GTK_BOX(enclosing), label, FALSE, FALSE, 0);
|
||||
gtk_box_pack_start(GTK_BOX(enclosing), value, FALSE, FALSE, 0);
|
||||
gtk_box_pack_end(GTK_BOX(enclosing),
|
||||
gnc_option_create_default_button(option, tooltips),
|
||||
FALSE, FALSE, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
PERR("Unknown type. Ignoring.\n");
|
||||
|
@ -75,6 +75,11 @@ static void gnc_configure_auto_raise_cb(void *);
|
||||
static void gnc_configure_auto_raise(void);
|
||||
static void gnc_configure_auto_decimal_cb(void *);
|
||||
static void gnc_configure_auto_decimal(void);
|
||||
static void gnc_configure_register_font_cb(void *);
|
||||
static void gnc_configure_register_font(void);
|
||||
static void gnc_configure_register_hint_font_cb(void *);
|
||||
static void gnc_configure_register_hint_font(void);
|
||||
|
||||
|
||||
/** GLOBALS *********************************************************/
|
||||
/* This static indicates the debugging module that this .o belongs to. */
|
||||
@ -94,6 +99,8 @@ static SCM register_borders_callback_id = SCM_UNDEFINED;
|
||||
static SCM reverse_balance_callback_id = SCM_UNDEFINED;
|
||||
static SCM auto_raise_callback_id = SCM_UNDEFINED;
|
||||
static SCM auto_decimal_callback_id = SCM_UNDEFINED;
|
||||
static SCM register_font_callback_id = SCM_UNDEFINED;
|
||||
static SCM register_hint_font_callback_id = SCM_UNDEFINED;
|
||||
|
||||
|
||||
/* ============================================================== */
|
||||
@ -191,6 +198,17 @@ gnucash_ui_init()
|
||||
NULL, "General",
|
||||
"Automatic Decimal Point");
|
||||
|
||||
gnc_configure_register_font();
|
||||
register_font_callback_id =
|
||||
gnc_register_option_change_callback(gnc_configure_register_font_cb,
|
||||
NULL, "Register", "Register font");
|
||||
|
||||
gnc_configure_register_hint_font();
|
||||
register_hint_font_callback_id =
|
||||
gnc_register_option_change_callback(gnc_configure_register_hint_font_cb,
|
||||
NULL, "Register",
|
||||
"Register hint font");
|
||||
|
||||
gnc_configure_sr_label_callbacks();
|
||||
|
||||
xaccRecnCellSetStringGetter(gnc_get_reconcile_str);
|
||||
@ -244,9 +262,11 @@ gnc_ui_destroy (void)
|
||||
gnc_unregister_option_change_callback_id(currency_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(reverse_balance_callback_id);
|
||||
gnc_unregister_option_change_callback_id(auto_raise_callback_id);
|
||||
gnc_unregister_option_change_callback_id(register_borders_callback_id);
|
||||
gnc_unregister_option_change_callback_id(reverse_balance_callback_id);
|
||||
gnc_unregister_option_change_callback_id(auto_raise_callback_id);
|
||||
gnc_unregister_option_change_callback_id(register_font_callback_id);
|
||||
gnc_unregister_option_change_callback_id(register_hint_font_callback_id);
|
||||
|
||||
if (app != NULL)
|
||||
{
|
||||
@ -280,7 +300,6 @@ gnc_ui_main()
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* hack alert -- all we do below is rename some functions. fix this someday */
|
||||
/* ============================================================== */
|
||||
|
||||
int
|
||||
@ -301,6 +320,22 @@ gnucash_ui_select_file()
|
||||
|
||||
/* ============================================================== */
|
||||
|
||||
const char *
|
||||
gnc_register_default_font()
|
||||
{
|
||||
return gnucash_style_get_default_register_font_name();
|
||||
}
|
||||
|
||||
/* ============================================================== */
|
||||
|
||||
const char *
|
||||
gnc_register_default_hint_font()
|
||||
{
|
||||
return gnucash_style_get_default_register_hint_font_name();
|
||||
}
|
||||
|
||||
/* ============================================================== */
|
||||
|
||||
static GNCAccountType
|
||||
sr_type_to_account_type(SplitRegisterType sr_type)
|
||||
{
|
||||
@ -739,7 +774,6 @@ gnc_configure_reverse_balance(void)
|
||||
* Args: Nothing
|
||||
* Returns: Nothing
|
||||
*/
|
||||
|
||||
static void
|
||||
gnc_configure_auto_decimal_cb(void *not_used)
|
||||
{
|
||||
@ -762,6 +796,68 @@ gnc_configure_auto_decimal(void)
|
||||
GNC_F);
|
||||
}
|
||||
|
||||
/* gnc_configure_register_font_cb
|
||||
* Callback called when options change -
|
||||
* sets register font
|
||||
*
|
||||
* Args: unused data
|
||||
* Returns: Nothing
|
||||
*/
|
||||
static void
|
||||
gnc_configure_register_font_cb(void *not_used)
|
||||
{
|
||||
gnc_configure_register_font();
|
||||
}
|
||||
|
||||
/* gnc_configure_register_font
|
||||
* Set up the register font
|
||||
*
|
||||
* Args: Nothing
|
||||
* Returns: Nothing
|
||||
*/
|
||||
static void
|
||||
gnc_configure_register_font(void)
|
||||
{
|
||||
char *font_name;
|
||||
|
||||
font_name = gnc_lookup_font_option("Register", "Register font", NULL);
|
||||
|
||||
gnucash_style_set_register_font_name(font_name);
|
||||
|
||||
if (font_name != NULL)
|
||||
free(font_name);
|
||||
}
|
||||
|
||||
/* gnc_configure_register_hint_font_cb
|
||||
* Callback called when options change -
|
||||
* sets register hint font
|
||||
*
|
||||
* Args: unused data
|
||||
* Returns: Nothing
|
||||
*/
|
||||
static void
|
||||
gnc_configure_register_hint_font_cb(void *not_used)
|
||||
{
|
||||
gnc_configure_register_hint_font();
|
||||
}
|
||||
|
||||
/* gnc_configure_register_hint_font
|
||||
* Set up the register hint font
|
||||
*
|
||||
* Args: Nothing
|
||||
* Returns: Nothing
|
||||
*/
|
||||
static void
|
||||
gnc_configure_register_hint_font(void)
|
||||
{
|
||||
char *font_name;
|
||||
|
||||
font_name = gnc_lookup_font_option("Register", "Register hint font", NULL);
|
||||
|
||||
gnucash_style_set_register_hint_font_name(font_name);
|
||||
|
||||
if (font_name != NULL)
|
||||
free(font_name);
|
||||
}
|
||||
|
||||
/****************** END OF FILE **********************/
|
||||
|
@ -457,8 +457,8 @@ gnucash_grid_init (GnucashGrid *grid)
|
||||
grid->top_offset = 0;
|
||||
grid->left_offset = 0;
|
||||
|
||||
grid->normal_font = gnucash_default_font;
|
||||
grid->italic_font = gnucash_italic_font;
|
||||
grid->normal_font = gnucash_register_font;
|
||||
grid->italic_font = gnucash_register_hint_font;
|
||||
}
|
||||
|
||||
|
||||
|
@ -34,11 +34,15 @@
|
||||
|
||||
|
||||
#define DEFAULT_FONT "-adobe-helvetica-medium-r-normal--*-120-*-*-*-*-*-*"
|
||||
#define ITALIC_FONT "-adobe-helvetica-medium-o-normal--*-120-*-*-*-*-*-*"
|
||||
#define HINT_FONT "-adobe-helvetica-medium-o-normal--*-120-*-*-*-*-*-*"
|
||||
|
||||
#define DEFAULT_STYLE_WIDTH 680
|
||||
|
||||
GdkFont *gnucash_default_font = NULL;
|
||||
GdkFont *gnucash_italic_font = NULL;
|
||||
GdkFont *gnucash_register_font = NULL;
|
||||
GdkFont *gnucash_register_hint_font = NULL;
|
||||
|
||||
static char *register_font_name = NULL;
|
||||
static char *register_hint_font_name = NULL;
|
||||
|
||||
|
||||
/* layout info flags */
|
||||
@ -1279,7 +1283,7 @@ gnucash_sheet_style_recompile(SheetBlockStyle *style, CellBlock *cellblock,
|
||||
style->widths[i][j] = cellblock->widths[j];
|
||||
|
||||
style->fonts[i][j] = NULL;
|
||||
style->header_font = gnucash_default_font;
|
||||
style->header_font = gnucash_register_font;
|
||||
|
||||
gnucash_style_set_borders (style, reg_borders);
|
||||
|
||||
@ -1511,19 +1515,81 @@ gnucash_style_unref (SheetBlockStyle *style)
|
||||
g_warning ("Unbalanced Style ref/unref");
|
||||
}
|
||||
|
||||
void
|
||||
gnucash_style_set_register_font_name(const char *name)
|
||||
{
|
||||
g_free(register_font_name);
|
||||
register_font_name = g_strdup(name);
|
||||
|
||||
if (gnucash_register_font != NULL)
|
||||
{
|
||||
gdk_font_unref(gnucash_register_font);
|
||||
gnucash_register_font = NULL;
|
||||
}
|
||||
|
||||
if (register_font_name != NULL)
|
||||
gnucash_register_font = gdk_font_load(register_font_name);
|
||||
|
||||
if (gnucash_register_font == NULL)
|
||||
{
|
||||
g_free(register_font_name);
|
||||
register_font_name = NULL;
|
||||
gnucash_register_font = gdk_font_load(DEFAULT_FONT);
|
||||
}
|
||||
|
||||
g_assert(gnucash_register_font != NULL);
|
||||
|
||||
gdk_font_ref(gnucash_register_font);
|
||||
}
|
||||
|
||||
void
|
||||
gnucash_style_set_register_hint_font_name(const char *name)
|
||||
{
|
||||
g_free(register_hint_font_name);
|
||||
register_hint_font_name = g_strdup(name);
|
||||
|
||||
if (gnucash_register_hint_font != NULL)
|
||||
{
|
||||
gdk_font_unref(gnucash_register_hint_font);
|
||||
gnucash_register_hint_font = NULL;
|
||||
}
|
||||
|
||||
if (register_hint_font_name != NULL)
|
||||
gnucash_register_hint_font =
|
||||
gdk_font_load(register_hint_font_name);
|
||||
|
||||
if (gnucash_register_hint_font == NULL)
|
||||
{
|
||||
g_free(register_hint_font_name);
|
||||
register_hint_font_name = NULL;
|
||||
gnucash_register_hint_font = gdk_font_load(HINT_FONT);
|
||||
}
|
||||
|
||||
g_assert(gnucash_register_hint_font != NULL);
|
||||
|
||||
gdk_font_ref(gnucash_register_hint_font);
|
||||
}
|
||||
|
||||
const char *
|
||||
gnucash_style_get_default_register_font_name()
|
||||
{
|
||||
return DEFAULT_FONT;
|
||||
}
|
||||
|
||||
const char *
|
||||
gnucash_style_get_default_register_hint_font_name()
|
||||
{
|
||||
return HINT_FONT;
|
||||
}
|
||||
|
||||
void
|
||||
gnucash_style_init (void)
|
||||
{
|
||||
GtkStyle *style;
|
||||
if (gnucash_register_font == NULL)
|
||||
gnucash_style_set_register_font_name(NULL);
|
||||
|
||||
style = gtk_widget_get_default_style();
|
||||
|
||||
gnucash_default_font = style->font;
|
||||
gnucash_italic_font = style->font;
|
||||
|
||||
g_assert (gnucash_default_font);
|
||||
g_assert (gnucash_italic_font);
|
||||
if (gnucash_register_hint_font == NULL)
|
||||
gnucash_style_set_register_hint_font_name(NULL);
|
||||
}
|
||||
|
||||
|
||||
|
@ -37,6 +37,12 @@ void gnucash_style_init (void);
|
||||
|
||||
void gnucash_sheet_style_init(void);
|
||||
|
||||
void gnucash_style_set_register_font_name(const char *name);
|
||||
void gnucash_style_set_register_hint_font_name(const char *name);
|
||||
|
||||
const char * gnucash_style_get_default_register_font_name();
|
||||
const char * gnucash_style_get_default_register_hint_font_name();
|
||||
|
||||
gint gnucash_style_col_is_resizable (SheetBlockStyle *style, int col);
|
||||
|
||||
void gnucash_sheet_style_set_col_width (GnucashSheet *sheet,
|
||||
@ -82,8 +88,8 @@ void gnucash_sheet_set_borders (GnucashSheet *sheet, int border);
|
||||
|
||||
|
||||
|
||||
extern GdkFont *gnucash_default_font;
|
||||
extern GdkFont *gnucash_italic_font;
|
||||
extern GdkFont *gnucash_register_font;
|
||||
extern GdkFont *gnucash_register_hint_font;
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -129,9 +129,32 @@
|
||||
(else (list #f "string-option: not a string"))))
|
||||
#f #f )))
|
||||
|
||||
;; font options store fonts as strings a la the X Logical
|
||||
;; Font Description. You should always provide a default
|
||||
;; value, as currently there seems to be no way to go from
|
||||
;; an actual font to a logical font description, and thus
|
||||
;; there is no way for the gui to pick a default value.
|
||||
(define (gnc:make-font-option
|
||||
section
|
||||
name
|
||||
sort-tag
|
||||
documentation-string
|
||||
default-value)
|
||||
(let* ((value default-value)
|
||||
(value->string (lambda () (gnc:value->string value))))
|
||||
(gnc:make-option
|
||||
section name sort-tag 'font documentation-string
|
||||
(lambda () value)
|
||||
(lambda (x) (set! value x))
|
||||
(lambda () default-value)
|
||||
(gnc:restore-form-generator value->string)
|
||||
(lambda (x)
|
||||
(cond ((string? x)(list #t x))
|
||||
(else (list #f "font-option: not a string"))))
|
||||
#f #f )))
|
||||
|
||||
;; currency options use a specialized widget for entering currencies
|
||||
;; in the GUI implementation. Currencies must be 3-letter ISO codes
|
||||
;; represented as strings.
|
||||
;; in the GUI implementation.
|
||||
(define (gnc:make-currency-option
|
||||
section
|
||||
name
|
||||
|
@ -208,9 +208,12 @@ the account instead of opening a register." #f))
|
||||
(list #(single_line "Single Line" "Show transactions on single lines")
|
||||
#(double_line "Double Line"
|
||||
"Show transactions on two lines with more information")
|
||||
#(multi_line "Multi Line" "Show transactions on multiple lines with one line for each split in the transaction")
|
||||
#(auto_single "Auto Single" "Single line mode with a multi-line cursor")
|
||||
#(auto_double "Auto Double" "Double line mode with a multi-line cursor")
|
||||
#(multi_line "Multi Line"
|
||||
"Show transactions on multiple lines with one line for each split in the transaction")
|
||||
#(auto_single "Auto Single"
|
||||
"Single line mode with a multi-line cursor")
|
||||
#(auto_double "Auto Double"
|
||||
"Double line mode with a multi-line cursor")
|
||||
)))
|
||||
|
||||
(gnc:register-configuration-option
|
||||
@ -244,6 +247,17 @@ the account instead of opening a register." #f))
|
||||
"Register" "Show Horizontal Borders"
|
||||
"f" "By default, show horizontal borders on the cells." #t))
|
||||
|
||||
(gnc:register-configuration-option
|
||||
(gnc:make-font-option
|
||||
"Register" "Register font"
|
||||
"g" "The font to use in the register" (gnc:register-default-font)))
|
||||
|
||||
(gnc:register-configuration-option
|
||||
(gnc:make-font-option
|
||||
"Register" "Register hint font"
|
||||
"g" "The font used to show hints in the register"
|
||||
(gnc:register-default-hint-font)))
|
||||
|
||||
|
||||
;; Register Color options
|
||||
|
||||
|
@ -82,5 +82,8 @@ typedef struct _qifimportwindow QIFImportWindow;
|
||||
QIFImportWindow * gnc_ui_qif_import_dialog_make();
|
||||
void gnc_ui_qif_import_dialog_destroy(QIFImportWindow * window);
|
||||
|
||||
/* Register font information ****************************************/
|
||||
const char * gnc_register_default_font();
|
||||
const char * gnc_register_default_hint_font();
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user