mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
GncPeriodSelect: add gobject property active
That will allow a one on one mapping between a widget property and a preference in the preferences backend in a future commit. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@23231 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
dd0a9b1564
commit
336d3cb6fd
@ -45,6 +45,7 @@ enum
|
|||||||
PROP_FY_END,
|
PROP_FY_END,
|
||||||
PROP_SHOW_DATE,
|
PROP_SHOW_DATE,
|
||||||
PROP_DATE_BASE,
|
PROP_DATE_BASE,
|
||||||
|
PROP_PS_ACTIVE,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum
|
enum
|
||||||
@ -121,7 +122,7 @@ struct _GncPeriodSelectPrivate
|
|||||||
|
|
||||||
/* Tells a GncPeriodSelect object to emit a "changed" signal.
|
/* Tells a GncPeriodSelect object to emit a "changed" signal.
|
||||||
*/
|
*/
|
||||||
void
|
static void
|
||||||
gnc_period_select_changed (GncPeriodSelect *period)
|
gnc_period_select_changed (GncPeriodSelect *period)
|
||||||
{
|
{
|
||||||
g_return_if_fail(GNC_IS_PERIOD_SELECT(period));
|
g_return_if_fail(GNC_IS_PERIOD_SELECT(period));
|
||||||
@ -165,9 +166,8 @@ gnc_period_sample_update_date_label (GncPeriodSelect *period)
|
|||||||
|
|
||||||
/** Handle the "changed" signal from the GtkComboBox that is embedded
|
/** Handle the "changed" signal from the GtkComboBox that is embedded
|
||||||
* in this GncPeriodSelect object. When called, this function
|
* in this GncPeriodSelect object. When called, this function
|
||||||
* updates the feedback label embedded in the object, then generates
|
* will delegate the actual update work to the GncPeriodSelect widget
|
||||||
* another "changed" signal so that a developer can see that
|
* to do the necessary updates of internal widgets and state.
|
||||||
* something in the object changed.
|
|
||||||
*
|
*
|
||||||
* @param box The combo box that changed.
|
* @param box The combo box that changed.
|
||||||
*
|
*
|
||||||
@ -178,11 +178,10 @@ gnc_period_sample_combobox_changed (GtkComboBox *box, GncPeriodSelect *period)
|
|||||||
{
|
{
|
||||||
g_return_if_fail(GNC_IS_PERIOD_SELECT(period));
|
g_return_if_fail(GNC_IS_PERIOD_SELECT(period));
|
||||||
|
|
||||||
/* Update this widget */
|
g_object_set (G_OBJECT (period),
|
||||||
gnc_period_sample_update_date_label(period);
|
"active",
|
||||||
|
gtk_combo_box_get_active (box),
|
||||||
/* Pass it on... */
|
NULL);
|
||||||
gnc_period_select_changed(period);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -208,6 +207,40 @@ gnc_period_sample_new_date_format (GConfEntry *unused,
|
|||||||
/* Property Functions */
|
/* Property Functions */
|
||||||
/************************************************************/
|
/************************************************************/
|
||||||
|
|
||||||
|
/* Set an item in the GncPeriodSelect to be the active one.
|
||||||
|
* This will first update the internal GtkCombobox (blocking
|
||||||
|
* its "changed" callback to prevent an infinite loop).
|
||||||
|
* Then it will update the sample label and finally it will
|
||||||
|
* emit a "changed" signal of it's own for other objects
|
||||||
|
* listening for this signal.
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
gnc_period_select_set_active_internal (GncPeriodSelect *period,
|
||||||
|
GncAccountingPeriod which)
|
||||||
|
{
|
||||||
|
GncPeriodSelectPrivate *priv;
|
||||||
|
|
||||||
|
g_return_if_fail(period != NULL);
|
||||||
|
g_return_if_fail(GNC_IS_PERIOD_SELECT(period));
|
||||||
|
g_return_if_fail(which >= 0);
|
||||||
|
g_return_if_fail(which < GNC_ACCOUNTING_PERIOD_LAST);
|
||||||
|
|
||||||
|
priv = GNC_PERIOD_SELECT_GET_PRIVATE(period);
|
||||||
|
|
||||||
|
g_signal_handlers_block_by_func(G_OBJECT(period),
|
||||||
|
G_CALLBACK(gnc_period_sample_combobox_changed), period);
|
||||||
|
gtk_combo_box_set_active(GTK_COMBO_BOX(priv->selector), which);
|
||||||
|
g_signal_handlers_unblock_by_func(G_OBJECT(period),
|
||||||
|
G_CALLBACK(gnc_period_sample_combobox_changed), period);
|
||||||
|
|
||||||
|
/* Update this widget */
|
||||||
|
gnc_period_sample_update_date_label(period);
|
||||||
|
|
||||||
|
/* Pass it on... */
|
||||||
|
gnc_period_select_changed(period);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/** @name GncPeriodSelect Properties
|
/** @name GncPeriodSelect Properties
|
||||||
@{ */
|
@{ */
|
||||||
|
|
||||||
@ -413,6 +446,9 @@ gnc_period_select_get_property (GObject *object,
|
|||||||
case PROP_DATE_BASE:
|
case PROP_DATE_BASE:
|
||||||
g_value_set_pointer(value, gnc_period_select_get_date_base(period));
|
g_value_set_pointer(value, gnc_period_select_get_date_base(period));
|
||||||
break;
|
break;
|
||||||
|
case PROP_PS_ACTIVE:
|
||||||
|
g_value_set_int(value, gnc_period_select_get_active(period));
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
|
||||||
break;
|
break;
|
||||||
@ -447,6 +483,9 @@ gnc_period_select_set_property (GObject *object,
|
|||||||
case PROP_DATE_BASE:
|
case PROP_DATE_BASE:
|
||||||
gnc_period_select_set_date_base(period, g_value_get_pointer(value));
|
gnc_period_select_set_date_base(period, g_value_get_pointer(value));
|
||||||
break;
|
break;
|
||||||
|
case PROP_PS_ACTIVE:
|
||||||
|
gnc_period_select_set_active_internal(period, g_value_get_int(value));
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
|
||||||
break;
|
break;
|
||||||
@ -536,7 +575,7 @@ gnc_period_select_class_init (GncPeriodSelectClass *klass)
|
|||||||
PROP_SHOW_DATE,
|
PROP_SHOW_DATE,
|
||||||
g_param_spec_boolean("show-date",
|
g_param_spec_boolean("show-date",
|
||||||
"Show Date",
|
"Show Date",
|
||||||
"Show the start/end date of the accouting period in this widget",
|
"Show the start/end date of the accounting period in this widget",
|
||||||
FALSE,
|
FALSE,
|
||||||
G_PARAM_READWRITE));
|
G_PARAM_READWRITE));
|
||||||
g_object_class_install_property(gobject_class,
|
g_object_class_install_property(gobject_class,
|
||||||
@ -545,6 +584,15 @@ gnc_period_select_class_init (GncPeriodSelectClass *klass)
|
|||||||
"Date Base",
|
"Date Base",
|
||||||
"The starting date to use for display calculations",
|
"The starting date to use for display calculations",
|
||||||
G_PARAM_READWRITE));
|
G_PARAM_READWRITE));
|
||||||
|
g_object_class_install_property(gobject_class,
|
||||||
|
PROP_PS_ACTIVE,
|
||||||
|
g_param_spec_int("active",
|
||||||
|
"Active period",
|
||||||
|
"The currently selected period in the list of periods",
|
||||||
|
-1,
|
||||||
|
G_MAXINT,
|
||||||
|
0,
|
||||||
|
G_PARAM_READWRITE));
|
||||||
|
|
||||||
g_type_class_add_private(klass, sizeof(GncPeriodSelectPrivate));
|
g_type_class_add_private(klass, sizeof(GncPeriodSelectPrivate));
|
||||||
}
|
}
|
||||||
@ -689,15 +737,12 @@ void
|
|||||||
gnc_period_select_set_active (GncPeriodSelect *period,
|
gnc_period_select_set_active (GncPeriodSelect *period,
|
||||||
GncAccountingPeriod which)
|
GncAccountingPeriod which)
|
||||||
{
|
{
|
||||||
GncPeriodSelectPrivate *priv;
|
|
||||||
|
|
||||||
g_return_if_fail(period != NULL);
|
g_return_if_fail(period != NULL);
|
||||||
g_return_if_fail(GNC_IS_PERIOD_SELECT(period));
|
g_return_if_fail(GNC_IS_PERIOD_SELECT(period));
|
||||||
g_return_if_fail(which >= 0);
|
g_return_if_fail(which >= 0);
|
||||||
g_return_if_fail(which < GNC_ACCOUNTING_PERIOD_LAST);
|
g_return_if_fail(which < GNC_ACCOUNTING_PERIOD_LAST);
|
||||||
|
|
||||||
priv = GNC_PERIOD_SELECT_GET_PRIVATE(period);
|
g_object_set (G_OBJECT (period), "active", which, NULL);
|
||||||
gtk_combo_box_set_active(GTK_COMBO_BOX(priv->selector), which);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -65,14 +65,6 @@ typedef struct
|
|||||||
GType gnc_period_select_get_type (void);
|
GType gnc_period_select_get_type (void);
|
||||||
|
|
||||||
|
|
||||||
/** Tells a GncPeriodSelect object to emit a "changed" signal.
|
|
||||||
*
|
|
||||||
* @param period The GncPeriodSelect object that should emit the
|
|
||||||
* signal.
|
|
||||||
*/
|
|
||||||
void gnc_period_select_changed (GncPeriodSelect *period);
|
|
||||||
|
|
||||||
|
|
||||||
/** Create a new GncPeriodSelect widget which is used to select a
|
/** Create a new GncPeriodSelect widget which is used to select a
|
||||||
* accounting period like "previous month" or "this year".
|
* accounting period like "previous month" or "this year".
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user