mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Change plot-size-option to use a pair
This change allows the use of pair to specify plot sizes. They can be a fixed pixel amount or a percentage.
This commit is contained in:
committed by
Geert Janssens
parent
4e2b2049fc
commit
1f8c413d3f
@@ -111,6 +111,9 @@
|
|||||||
|
|
||||||
(export gnc:make-number-range-option)
|
(export gnc:make-number-range-option)
|
||||||
(export gnc:make-number-plot-size-option)
|
(export gnc:make-number-plot-size-option)
|
||||||
|
(export gnc:plot-size-option-value-type)
|
||||||
|
(export gnc:plot-size-option-value)
|
||||||
|
|
||||||
(export gnc:make-internal-option)
|
(export gnc:make-internal-option)
|
||||||
(export gnc:make-query-option)
|
(export gnc:make-query-option)
|
||||||
(export gnc:make-color-option)
|
(export gnc:make-color-option)
|
||||||
|
|||||||
@@ -108,6 +108,8 @@ struct _Getters
|
|||||||
SCM date_option_value_type;
|
SCM date_option_value_type;
|
||||||
SCM date_option_value_absolute;
|
SCM date_option_value_absolute;
|
||||||
SCM date_option_value_relative;
|
SCM date_option_value_relative;
|
||||||
|
SCM plot_size_option_value_type;
|
||||||
|
SCM plot_size_option_value;
|
||||||
SCM currency_accounting_option_currency_doc_string;
|
SCM currency_accounting_option_currency_doc_string;
|
||||||
SCM currency_accounting_option_default_currency;
|
SCM currency_accounting_option_default_currency;
|
||||||
SCM currency_accounting_option_policy_doc_string;
|
SCM currency_accounting_option_policy_doc_string;
|
||||||
@@ -596,6 +598,8 @@ initialize_getters(void)
|
|||||||
scm_c_eval_string("gnc:date-option-absolute-time");
|
scm_c_eval_string("gnc:date-option-absolute-time");
|
||||||
getters.date_option_value_relative =
|
getters.date_option_value_relative =
|
||||||
scm_c_eval_string("gnc:date-option-relative-time");
|
scm_c_eval_string("gnc:date-option-relative-time");
|
||||||
|
getters.plot_size_option_value_type = scm_c_eval_string ("gnc:plot-size-option-value-type");
|
||||||
|
getters.plot_size_option_value = scm_c_eval_string("gnc:plot-size-option-value");
|
||||||
getters.currency_accounting_option_currency_doc_string =
|
getters.currency_accounting_option_currency_doc_string =
|
||||||
scm_c_eval_string("gnc:currency-accounting-option-get-curr-doc-string");
|
scm_c_eval_string("gnc:currency-accounting-option-get-curr-doc-string");
|
||||||
getters.currency_accounting_option_default_currency =
|
getters.currency_accounting_option_default_currency =
|
||||||
@@ -2667,6 +2671,45 @@ gnc_date_option_value_get_relative (SCM option_value)
|
|||||||
return scm_call_1 (getters.date_option_value_relative, option_value);
|
return scm_call_1 (getters.date_option_value_relative, option_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*******************************************************************\
|
||||||
|
* gnc_plot_size_option_value_get_type *
|
||||||
|
* get the type of a plot size option value *
|
||||||
|
* *
|
||||||
|
* Args: option_value - option value to get type of *
|
||||||
|
* Return: newly allocated type string or NULL *
|
||||||
|
\*******************************************************************/
|
||||||
|
char *
|
||||||
|
gnc_plot_size_option_value_get_type (SCM option_value)
|
||||||
|
{
|
||||||
|
SCM value;
|
||||||
|
|
||||||
|
initialize_getters();
|
||||||
|
|
||||||
|
return gnc_scm_call_1_symbol_to_string (getters.plot_size_option_value_type, option_value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************************\
|
||||||
|
* gnc_plot_size_option_value_get_value *
|
||||||
|
* get the plot size option value *
|
||||||
|
* *
|
||||||
|
* Args: option_value - option value to get the plot size of *
|
||||||
|
* Return: double value *
|
||||||
|
\*******************************************************************/
|
||||||
|
gdouble
|
||||||
|
gnc_plot_size_option_value_get_value (SCM option_value)
|
||||||
|
{
|
||||||
|
SCM value;
|
||||||
|
|
||||||
|
initialize_getters();
|
||||||
|
|
||||||
|
value = scm_call_1 (getters.plot_size_option_value, option_value);
|
||||||
|
|
||||||
|
if (scm_is_number(value))
|
||||||
|
return scm_to_double (value);
|
||||||
|
else
|
||||||
|
return 1.0;
|
||||||
|
}
|
||||||
|
|
||||||
/********************************************************************\
|
/********************************************************************\
|
||||||
* gnc_currency_accounting_option_currency_documentation *
|
* gnc_currency_accounting_option_currency_documentation *
|
||||||
* returns the malloc'ed documentation string for currency *
|
* returns the malloc'ed documentation string for currency *
|
||||||
|
|||||||
@@ -251,6 +251,9 @@ char * gnc_date_option_value_get_type (SCM option_value);
|
|||||||
Timespec gnc_date_option_value_get_absolute (SCM option_value);
|
Timespec gnc_date_option_value_get_absolute (SCM option_value);
|
||||||
SCM gnc_date_option_value_get_relative (SCM option_value);
|
SCM gnc_date_option_value_get_relative (SCM option_value);
|
||||||
|
|
||||||
|
char * gnc_plot_size_option_value_get_type (SCM option_value);
|
||||||
|
gdouble gnc_plot_size_option_value_get_value (SCM option_value);
|
||||||
|
|
||||||
char * gnc_currency_accounting_option_currency_documentation(GNCOption *option);
|
char * gnc_currency_accounting_option_currency_documentation(GNCOption *option);
|
||||||
SCM gnc_currency_accounting_option_get_default_currency(GNCOption *option);
|
SCM gnc_currency_accounting_option_get_default_currency(GNCOption *option);
|
||||||
char * gnc_currency_accounting_option_policy_documentation(GNCOption *option);
|
char * gnc_currency_accounting_option_policy_documentation(GNCOption *option);
|
||||||
|
|||||||
@@ -1143,9 +1143,9 @@
|
|||||||
(list lower-bound upper-bound num-decimals step-size)
|
(list lower-bound upper-bound num-decimals step-size)
|
||||||
#f #f #f)))
|
#f #f #f)))
|
||||||
|
|
||||||
|
;; number plot size options use the option-data as a list whose
|
||||||
;; plot size options use the option-data as a list whose
|
|
||||||
;; elements are: (lower-bound upper-bound num-decimals step-size)
|
;; elements are: (lower-bound upper-bound num-decimals step-size)
|
||||||
|
;; which is used for the valid pixel range
|
||||||
(define (gnc:make-number-plot-size-option
|
(define (gnc:make-number-plot-size-option
|
||||||
section
|
section
|
||||||
name
|
name
|
||||||
@@ -1157,33 +1157,53 @@
|
|||||||
num-decimals
|
num-decimals
|
||||||
step-size)
|
step-size)
|
||||||
(let* ((value default-value)
|
(let* ((value default-value)
|
||||||
(value->string (lambda () (number->string value))))
|
(value->string (lambda ()
|
||||||
|
(string-append "'" (gnc:value->string value)))))
|
||||||
(gnc:make-option
|
(gnc:make-option
|
||||||
section name sort-tag 'number-range documentation-string
|
section name sort-tag 'plot-size documentation-string
|
||||||
(lambda () value)
|
(lambda () value) ;;getter
|
||||||
(lambda (x)
|
(lambda (x)
|
||||||
(cond ((and (pair? x) ;; new pair value
|
(if (number? x) ;; this is for old style plot size
|
||||||
(eq? 'pixels (car x)))
|
(set! value (cons 'pixels x))
|
||||||
(set! value (cdr x)))
|
(set! value x))) ;;setter
|
||||||
(else (set! value default-value)))
|
|
||||||
|
|
||||||
(if (number? x) ;; old single value
|
(lambda () default-value) ;;default-getter
|
||||||
(set! value x)))
|
(gnc:restore-form-generator value->string) ;;restore-form
|
||||||
(lambda () default-value)
|
(lambda (b p)
|
||||||
(gnc:restore-form-generator value->string)
|
(qof-book-set-option b (symbol->string (car value))
|
||||||
(lambda (f p) (kvp-frame-set-slot-path-gslist f value p))
|
(append p '("type")))
|
||||||
(lambda (f p)
|
(qof-book-set-option b (if (symbol? (cdr value))
|
||||||
(let ((v (kvp-frame-get-slot-path-gslist f p)))
|
(symbol->string (cdr value))
|
||||||
(if (and v (number? v))
|
(cdr value))
|
||||||
(set! value v))))
|
(append p '("value")))) ;;scm->kvp
|
||||||
|
(lambda (b p)
|
||||||
|
(let ((t (qof-book-get-option b (append p '("type"))))
|
||||||
|
(v (qof-book-get-option b (append p '("value")))))
|
||||||
|
(if (and t v (string? t))
|
||||||
|
(set! value (cons (string->symbol t)
|
||||||
|
(if (string? v) (string->number v) v)))))) ;;kvp->scm
|
||||||
(lambda (x)
|
(lambda (x)
|
||||||
(cond ((not (number? x)) (list #f "number-plot-size-option: not a number"))
|
(if (eq? 'pixels (car x))
|
||||||
((and (>= value lower-bound)
|
(cond ((not (number? (cdr x))) (list #f "number-plot-size-option-pixels: not a number"))
|
||||||
(<= value upper-bound))
|
((and (>= (cdr x) lower-bound)
|
||||||
(list #t x))
|
(<= (cdr x) upper-bound))
|
||||||
(else (list #f "number-plot-size-option: out of range"))))
|
(list #t x))
|
||||||
(list lower-bound upper-bound num-decimals step-size)
|
(else (list #f "number-plot-size-option-pixels: out of range")))
|
||||||
#f #f #f)))
|
(cond ((not (number? (cdr x))) (list #f "number-plot-size-option-percentage: not a number"))
|
||||||
|
((and (>= (cdr x) 10)
|
||||||
|
(<= (cdr x) 100))
|
||||||
|
(list #t x))
|
||||||
|
(else (list #f "number-plot-size-option-percentage: out of range")))
|
||||||
|
)
|
||||||
|
) ;;value-validator
|
||||||
|
(list lower-bound upper-bound num-decimals step-size) ;;option-data
|
||||||
|
#f #f #f))) ;;option-data-fns, strings-getter, option-widget-changed-proc
|
||||||
|
|
||||||
|
(define (gnc:plot-size-option-value-type option-value)
|
||||||
|
(car option-value))
|
||||||
|
|
||||||
|
(define (gnc:plot-size-option-value option-value)
|
||||||
|
(cdr option-value))
|
||||||
|
|
||||||
(define (gnc:make-internal-option
|
(define (gnc:make-internal-option
|
||||||
section
|
section
|
||||||
|
|||||||
@@ -2261,71 +2261,6 @@ gnc_option_set_ui_widget_number_range (GNCOption *option, GtkBox *page_box,
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GtkWidget *
|
|
||||||
gnc_option_set_ui_widget_plot_size (GNCOption *option, GtkBox *page_box,
|
|
||||||
char *name, char *documentation,
|
|
||||||
/* Return values */
|
|
||||||
GtkWidget **enclosing, gboolean *packed)
|
|
||||||
{
|
|
||||||
GtkWidget *value;
|
|
||||||
GtkWidget *label;
|
|
||||||
gchar *colon_name;
|
|
||||||
GtkAdjustment *adj;
|
|
||||||
gdouble lower_bound = G_MINDOUBLE;
|
|
||||||
gdouble upper_bound = G_MAXDOUBLE;
|
|
||||||
gdouble step_size = 1.0;
|
|
||||||
int num_decimals = 0;
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
gnc_option_get_range_info(option, &lower_bound, &upper_bound,
|
|
||||||
&num_decimals, &step_size);
|
|
||||||
adj = GTK_ADJUSTMENT(gtk_adjustment_new(lower_bound, lower_bound,
|
|
||||||
upper_bound, step_size,
|
|
||||||
step_size * 5.0,
|
|
||||||
0));
|
|
||||||
value = gtk_spin_button_new(adj, step_size, num_decimals);
|
|
||||||
gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(value), TRUE);
|
|
||||||
|
|
||||||
{
|
|
||||||
gdouble biggest;
|
|
||||||
gint num_digits;
|
|
||||||
|
|
||||||
biggest = ABS(lower_bound);
|
|
||||||
biggest = MAX(biggest, ABS(upper_bound));
|
|
||||||
|
|
||||||
num_digits = 0;
|
|
||||||
while (biggest >= 1)
|
|
||||||
{
|
|
||||||
num_digits++;
|
|
||||||
biggest = biggest / 10;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (num_digits == 0)
|
|
||||||
num_digits = 1;
|
|
||||||
|
|
||||||
num_digits += num_decimals;
|
|
||||||
|
|
||||||
gtk_entry_set_width_chars(GTK_ENTRY(value), num_digits);
|
|
||||||
}
|
|
||||||
|
|
||||||
gnc_option_set_widget (option, value);
|
|
||||||
gnc_option_set_ui_value(option, FALSE);
|
|
||||||
|
|
||||||
g_signal_connect(G_OBJECT(value), "changed",
|
|
||||||
G_CALLBACK(gnc_option_changed_widget_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_widget_show_all(*enclosing);
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
static GtkWidget *
|
static GtkWidget *
|
||||||
gnc_option_set_ui_widget_color (GNCOption *option, GtkBox *page_box,
|
gnc_option_set_ui_widget_color (GNCOption *option, GtkBox *page_box,
|
||||||
char *name, char *documentation,
|
char *name, char *documentation,
|
||||||
@@ -2485,6 +2420,149 @@ gnc_option_set_ui_widget_dateformat (GNCOption *option, GtkBox *page_box,
|
|||||||
return *enclosing;
|
return *enclosing;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
gnc_plot_size_option_set_select_method(GNCOption *option, gboolean set_buttons)
|
||||||
|
{
|
||||||
|
GList* widget_list;
|
||||||
|
GtkWidget *px_button, *p_button, *px_widget, *p_widget;
|
||||||
|
GtkWidget *widget;
|
||||||
|
|
||||||
|
widget = gnc_option_get_gtk_widget (option);
|
||||||
|
|
||||||
|
widget_list = gtk_container_get_children(GTK_CONTAINER(widget));
|
||||||
|
px_button = g_list_nth_data(widget_list, 0);
|
||||||
|
px_widget = g_list_nth_data(widget_list, 1);
|
||||||
|
p_button = g_list_nth_data(widget_list, 2);
|
||||||
|
p_widget = g_list_nth_data(widget_list, 3);
|
||||||
|
g_list_free(widget_list);
|
||||||
|
|
||||||
|
if (set_buttons)
|
||||||
|
{
|
||||||
|
gtk_widget_set_sensitive(px_widget, TRUE);
|
||||||
|
gtk_widget_set_sensitive(p_widget, FALSE);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gtk_widget_set_sensitive(p_widget, TRUE);
|
||||||
|
gtk_widget_set_sensitive(px_widget, FALSE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gnc_rd_option_px_set_cb(GtkWidget *widget, gpointer *raw_option)
|
||||||
|
{
|
||||||
|
GNCOption *option = (GNCOption *) raw_option;
|
||||||
|
gnc_plot_size_option_set_select_method(option, TRUE);
|
||||||
|
gnc_option_changed_option_cb(widget, option);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gnc_rd_option_p_set_cb(GtkWidget *widget, gpointer *raw_option)
|
||||||
|
{
|
||||||
|
GNCOption *option = (GNCOption *) raw_option;
|
||||||
|
gnc_plot_size_option_set_select_method(option, FALSE);
|
||||||
|
gnc_option_changed_option_cb(widget, option);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static GtkWidget *
|
||||||
|
gnc_option_set_ui_widget_plot_size (GNCOption *option, GtkBox *page_box,
|
||||||
|
char *name, char *documentation,
|
||||||
|
/* Return values */
|
||||||
|
GtkWidget **enclosing, gboolean *packed)
|
||||||
|
{
|
||||||
|
GtkWidget *value_px, *value_percent;
|
||||||
|
GtkWidget *label;
|
||||||
|
GtkWidget *px_butt, *p_butt;
|
||||||
|
GtkWidget *hbox;
|
||||||
|
gchar *colon_name;
|
||||||
|
GtkAdjustment *adj_px, *adj_percent;
|
||||||
|
gdouble lower_bound = G_MINDOUBLE;
|
||||||
|
gdouble upper_bound = G_MAXDOUBLE;
|
||||||
|
gdouble step_size = 1.0;
|
||||||
|
int num_decimals = 0;
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
hbox = gtk_hbox_new(FALSE, 5);
|
||||||
|
|
||||||
|
*enclosing = gtk_hbox_new(FALSE, 5);
|
||||||
|
|
||||||
|
gtk_box_pack_start(GTK_BOX(*enclosing), label, FALSE, FALSE, 0);
|
||||||
|
gtk_box_pack_start(GTK_BOX(*enclosing), hbox, FALSE, FALSE, 0);
|
||||||
|
|
||||||
|
gnc_option_get_range_info(option, &lower_bound, &upper_bound,
|
||||||
|
&num_decimals, &step_size);
|
||||||
|
adj_px = GTK_ADJUSTMENT(gtk_adjustment_new(lower_bound, lower_bound,
|
||||||
|
upper_bound, step_size,
|
||||||
|
step_size * 5.0,
|
||||||
|
0));
|
||||||
|
|
||||||
|
value_px = gtk_spin_button_new(adj_px, step_size, num_decimals);
|
||||||
|
gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(value_px), TRUE);
|
||||||
|
|
||||||
|
{
|
||||||
|
gdouble biggest;
|
||||||
|
gint num_digits;
|
||||||
|
|
||||||
|
biggest = ABS(lower_bound);
|
||||||
|
biggest = MAX(biggest, ABS(upper_bound));
|
||||||
|
|
||||||
|
num_digits = 0;
|
||||||
|
while (biggest >= 1)
|
||||||
|
{
|
||||||
|
num_digits++;
|
||||||
|
biggest = biggest / 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (num_digits == 0)
|
||||||
|
num_digits = 1;
|
||||||
|
|
||||||
|
num_digits += num_decimals;
|
||||||
|
|
||||||
|
gtk_entry_set_width_chars(GTK_ENTRY(value_px), num_digits);
|
||||||
|
}
|
||||||
|
gtk_spin_button_set_value(GTK_SPIN_BUTTON(value_px), (upper_bound / 2)); //default
|
||||||
|
g_signal_connect(G_OBJECT(value_px), "changed",
|
||||||
|
G_CALLBACK(gnc_option_changed_widget_cb), option);
|
||||||
|
|
||||||
|
adj_percent = GTK_ADJUSTMENT(gtk_adjustment_new(1, 10, 100, 1, 5.0, 0));
|
||||||
|
value_percent = gtk_spin_button_new(adj_percent, 1, 0);
|
||||||
|
gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(value_percent), TRUE);
|
||||||
|
gtk_spin_button_set_value(GTK_SPIN_BUTTON(value_percent), 100); //default
|
||||||
|
gtk_entry_set_width_chars(GTK_ENTRY(value_percent), 3);
|
||||||
|
gtk_widget_set_sensitive(value_percent, FALSE);
|
||||||
|
|
||||||
|
g_signal_connect(G_OBJECT(value_percent), "changed",
|
||||||
|
G_CALLBACK(gnc_option_changed_widget_cb), option);
|
||||||
|
|
||||||
|
px_butt = gtk_radio_button_new_with_label(NULL, _("Pixels"));
|
||||||
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(px_butt), TRUE);
|
||||||
|
|
||||||
|
g_signal_connect(G_OBJECT(px_butt), "toggled",
|
||||||
|
G_CALLBACK(gnc_rd_option_px_set_cb), option);
|
||||||
|
|
||||||
|
p_butt = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(px_butt), _("Percent"));
|
||||||
|
g_signal_connect(G_OBJECT(p_butt), "toggled",
|
||||||
|
G_CALLBACK(gnc_rd_option_p_set_cb), option);
|
||||||
|
|
||||||
|
gtk_box_pack_start(GTK_BOX(hbox), px_butt, FALSE, FALSE, 0);
|
||||||
|
gtk_box_pack_start(GTK_BOX(hbox), value_px, FALSE, FALSE, 0);
|
||||||
|
gtk_box_pack_start(GTK_BOX(hbox), p_butt, FALSE, FALSE, 0);
|
||||||
|
gtk_box_pack_start(GTK_BOX(hbox), value_percent, FALSE, FALSE, 0);
|
||||||
|
|
||||||
|
gnc_option_set_widget (option, hbox);
|
||||||
|
gnc_option_set_ui_value (option, FALSE);
|
||||||
|
|
||||||
|
gtk_widget_show_all(*enclosing);
|
||||||
|
return hbox;
|
||||||
|
}
|
||||||
|
|
||||||
static GtkWidget *
|
static GtkWidget *
|
||||||
gnc_option_set_ui_widget_budget (GNCOption *option, GtkBox *page_box,
|
gnc_option_set_ui_widget_budget (GNCOption *option, GtkBox *page_box,
|
||||||
char *name, char *documentation,
|
char *name, char *documentation,
|
||||||
@@ -2835,25 +2913,6 @@ gnc_option_set_ui_value_number_range (GNCOption *option, gboolean use_default,
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
|
||||||
gnc_option_set_ui_value_plot_size (GNCOption *option, gboolean use_default,
|
|
||||||
GtkWidget *widget, SCM value)
|
|
||||||
{
|
|
||||||
GtkSpinButton *spinner;
|
|
||||||
gdouble d_value;;
|
|
||||||
|
|
||||||
spinner = GTK_SPIN_BUTTON(widget);
|
|
||||||
|
|
||||||
if (scm_is_number(value))
|
|
||||||
{
|
|
||||||
d_value = scm_to_double(value);
|
|
||||||
gtk_spin_button_set_value(spinner, d_value);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gnc_option_set_ui_value_color (GNCOption *option, gboolean use_default,
|
gnc_option_set_ui_value_color (GNCOption *option, gboolean use_default,
|
||||||
GtkWidget *widget, SCM value)
|
GtkWidget *widget, SCM value)
|
||||||
@@ -3022,6 +3081,45 @@ gnc_option_set_ui_value_dateformat (GNCOption *option, gboolean use_default,
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
gnc_option_set_ui_value_plot_size (GNCOption *option, gboolean use_default,
|
||||||
|
GtkWidget *widget, SCM value)
|
||||||
|
{
|
||||||
|
GList* widget_list;
|
||||||
|
GtkWidget *px_button, *p_button, *px_widget, *p_widget;
|
||||||
|
char *symbol_str;
|
||||||
|
gdouble d_value;
|
||||||
|
|
||||||
|
widget_list = gtk_container_get_children(GTK_CONTAINER(widget));
|
||||||
|
px_button = g_list_nth_data(widget_list, 0);
|
||||||
|
px_widget = g_list_nth_data(widget_list, 1);
|
||||||
|
p_button = g_list_nth_data(widget_list, 2);
|
||||||
|
p_widget = g_list_nth_data(widget_list, 3);
|
||||||
|
g_list_free(widget_list);
|
||||||
|
|
||||||
|
if (scm_is_pair(value))
|
||||||
|
{
|
||||||
|
symbol_str = gnc_plot_size_option_value_get_type(value);
|
||||||
|
d_value = gnc_plot_size_option_value_get_value(value);
|
||||||
|
|
||||||
|
if (symbol_str)
|
||||||
|
{
|
||||||
|
if (g_strcmp0(symbol_str, "pixels") == 0) // pixel values
|
||||||
|
{
|
||||||
|
gtk_spin_button_set_value(GTK_SPIN_BUTTON(px_widget), d_value);
|
||||||
|
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(px_button), TRUE);
|
||||||
|
}
|
||||||
|
else // percent values
|
||||||
|
{
|
||||||
|
gtk_spin_button_set_value(GTK_SPIN_BUTTON(p_widget), (d_value));
|
||||||
|
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(p_button), TRUE);
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gnc_option_set_ui_value_currency_accounting (GNCOption *option,
|
gnc_option_set_ui_value_currency_accounting (GNCOption *option,
|
||||||
gboolean use_default,
|
gboolean use_default,
|
||||||
@@ -3386,19 +3484,6 @@ gnc_option_get_ui_value_number_range (GNCOption *option, GtkWidget *widget)
|
|||||||
return (scm_from_double (value));
|
return (scm_from_double (value));
|
||||||
}
|
}
|
||||||
|
|
||||||
static SCM
|
|
||||||
gnc_option_get_ui_value_plot_size (GNCOption *option, GtkWidget *widget)
|
|
||||||
{
|
|
||||||
GtkSpinButton *spinner;
|
|
||||||
gdouble value;
|
|
||||||
|
|
||||||
spinner = GTK_SPIN_BUTTON(widget);
|
|
||||||
|
|
||||||
value = gtk_spin_button_get_value(spinner);
|
|
||||||
|
|
||||||
return (scm_from_double (value));
|
|
||||||
}
|
|
||||||
|
|
||||||
static SCM
|
static SCM
|
||||||
gnc_option_get_ui_value_color (GNCOption *option, GtkWidget *widget)
|
gnc_option_get_ui_value_color (GNCOption *option, GtkWidget *widget)
|
||||||
{
|
{
|
||||||
@@ -3480,6 +3565,35 @@ gnc_option_get_ui_value_dateformat (GNCOption *option, GtkWidget *widget)
|
|||||||
return (gnc_dateformat_option_set_value(format, months, years, custom));
|
return (gnc_dateformat_option_set_value(format, months, years, custom));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static SCM
|
||||||
|
gnc_option_get_ui_value_plot_size (GNCOption *option, GtkWidget *widget)
|
||||||
|
{
|
||||||
|
GList* widget_list;
|
||||||
|
GtkWidget *px_button, *p_button, *px_widget, *p_widget;
|
||||||
|
gdouble d_value;
|
||||||
|
SCM type, val;
|
||||||
|
|
||||||
|
widget_list = gtk_container_get_children(GTK_CONTAINER(widget));
|
||||||
|
px_button = g_list_nth_data(widget_list, 0);
|
||||||
|
px_widget = g_list_nth_data(widget_list, 1);
|
||||||
|
p_button = g_list_nth_data(widget_list, 2);
|
||||||
|
p_widget = g_list_nth_data(widget_list, 3);
|
||||||
|
g_list_free(widget_list);
|
||||||
|
|
||||||
|
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(px_button)))
|
||||||
|
{
|
||||||
|
type = scm_from_locale_symbol("pixels");
|
||||||
|
d_value = gtk_spin_button_get_value(GTK_SPIN_BUTTON(px_widget));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
type = scm_from_locale_symbol("percent");
|
||||||
|
d_value = gtk_spin_button_get_value(GTK_SPIN_BUTTON(p_widget));
|
||||||
|
}
|
||||||
|
val = scm_from_double(d_value);
|
||||||
|
return scm_cons(type, val);
|
||||||
|
}
|
||||||
|
|
||||||
static SCM
|
static SCM
|
||||||
gnc_option_get_ui_value_currency_accounting (GNCOption *option, GtkWidget *widget)
|
gnc_option_get_ui_value_currency_accounting (GNCOption *option, GtkWidget *widget)
|
||||||
{
|
{
|
||||||
@@ -3602,10 +3716,6 @@ static void gnc_options_initialize_options (void)
|
|||||||
"number-range", gnc_option_set_ui_widget_number_range,
|
"number-range", gnc_option_set_ui_widget_number_range,
|
||||||
gnc_option_set_ui_value_number_range, gnc_option_get_ui_value_number_range
|
gnc_option_set_ui_value_number_range, gnc_option_get_ui_value_number_range
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"plot-size", gnc_option_set_ui_widget_plot_size,
|
|
||||||
gnc_option_set_ui_value_plot_size, gnc_option_get_ui_value_plot_size
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"color", gnc_option_set_ui_widget_color,
|
"color", gnc_option_set_ui_widget_color,
|
||||||
gnc_option_set_ui_value_color, gnc_option_get_ui_value_color
|
gnc_option_set_ui_value_color, gnc_option_get_ui_value_color
|
||||||
@@ -3626,6 +3736,10 @@ static void gnc_options_initialize_options (void)
|
|||||||
"dateformat", gnc_option_set_ui_widget_dateformat,
|
"dateformat", gnc_option_set_ui_widget_dateformat,
|
||||||
gnc_option_set_ui_value_dateformat, gnc_option_get_ui_value_dateformat
|
gnc_option_set_ui_value_dateformat, gnc_option_get_ui_value_dateformat
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"plot-size", gnc_option_set_ui_widget_plot_size,
|
||||||
|
gnc_option_set_ui_value_plot_size, gnc_option_get_ui_value_plot_size
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"budget", gnc_option_set_ui_widget_budget,
|
"budget", gnc_option_set_ui_widget_budget,
|
||||||
gnc_option_set_ui_value_budget, gnc_option_get_ui_value_budget
|
gnc_option_set_ui_value_budget, gnc_option_get_ui_value_budget
|
||||||
|
|||||||
Reference in New Issue
Block a user