Refactor: DEFINE_TYPE GncFrequency < GtkBox

- also
 - make gnc_frequency_init() private
 - rename gnc_frequency_class_destroy() to gnc_frequency_destroy()
This commit is contained in:
Richard Cohen 2023-05-22 10:35:42 +01:00
parent b669d2722b
commit faba15a4c7
2 changed files with 6 additions and 40 deletions

View File

@ -57,8 +57,7 @@ static guint gnc_frequency_signals[LAST_SIGNAL] = { 0 };
/** Private Prototypes ********************/ /** Private Prototypes ********************/
static void gnc_frequency_class_init( GncFrequencyClass *klass ); static void gnc_frequency_destroy( GtkWidget *widget );
static void gnc_frequency_class_destroy( GtkWidget *widget );
static void freq_combo_changed( GtkComboBox *b, gpointer d ); static void freq_combo_changed( GtkComboBox *b, gpointer d );
static void start_date_changed( GNCDateEdit *gde, gpointer d ); static void start_date_changed( GNCDateEdit *gde, gpointer d );
@ -71,8 +70,6 @@ static void semimonthly_sel_changed( GtkButton *b, gpointer d );
/** Static Inits ********************/ /** Static Inits ********************/
static GObjectClass *parent_class = NULL;
enum enum
{ {
PAGE_NONE = 0, PAGE_NONE = 0,
@ -97,33 +94,7 @@ static const char *CHECKBOX_NAMES[] =
/** Implementations ********************/ /** Implementations ********************/
GType G_DEFINE_TYPE (GncFrequency, gnc_frequency, GTK_TYPE_BOX)
gnc_frequency_get_type()
{
static GType gncfreq_type = 0;
if (gncfreq_type == 0)
{
static GTypeInfo gncfreq_info =
{
sizeof(GncFrequencyClass),
NULL,
NULL,
(GClassInitFunc)gnc_frequency_class_init,
NULL,
NULL,
sizeof(GncFrequency),
0,
(GInstanceInitFunc)gnc_frequency_init
};
gncfreq_type = g_type_register_static (GTK_TYPE_BOX,
"GncFrequency",
&gncfreq_info, 0);
}
return gncfreq_type;
}
static void static void
gnc_frequency_class_init( GncFrequencyClass *klass ) gnc_frequency_class_init( GncFrequencyClass *klass )
@ -131,8 +102,6 @@ gnc_frequency_class_init( GncFrequencyClass *klass )
GObjectClass *object_class; GObjectClass *object_class;
GtkWidgetClass *gtkwidget_class; GtkWidgetClass *gtkwidget_class;
parent_class = g_type_class_peek_parent (klass);
object_class = G_OBJECT_CLASS (klass); object_class = G_OBJECT_CLASS (klass);
gtkwidget_class = GTK_WIDGET_CLASS (klass); gtkwidget_class = GTK_WIDGET_CLASS (klass);
@ -148,11 +117,11 @@ gnc_frequency_class_init( GncFrequencyClass *klass )
0); 0);
/* GtkWidget signals */ /* GtkWidget signals */
gtkwidget_class->destroy = gnc_frequency_class_destroy; gtkwidget_class->destroy = gnc_frequency_destroy;
} }
void static void
gnc_frequency_init(GncFrequency *gf) gnc_frequency_init(GncFrequency *gf)
{ {
int i; int i;
@ -277,7 +246,7 @@ gnc_frequency_init(GncFrequency *gf)
* @internal * @internal
*/ */
static void static void
gnc_frequency_class_destroy (GtkWidget *widget) gnc_frequency_destroy (GtkWidget *widget)
{ {
GncFrequency *gf; GncFrequency *gf;
@ -294,8 +263,7 @@ gnc_frequency_class_destroy (GtkWidget *widget)
gf->builder = NULL; gf->builder = NULL;
} }
if (GTK_WIDGET_CLASS (parent_class)->destroy) GTK_WIDGET_CLASS (gnc_frequency_parent_class)->destroy (widget);
GTK_WIDGET_CLASS (parent_class)->destroy (widget);
LEAVE(" "); LEAVE(" ");
} }

View File

@ -76,8 +76,6 @@ GType gnc_frequency_get_type(void);
GtkWidget* gnc_frequency_new(GList *recurrences, const GDate *start_date); GtkWidget* gnc_frequency_new(GList *recurrences, const GDate *start_date);
GtkWidget* gnc_frequency_new_from_recurrence(GList *recurrences, const GDate *start_date); GtkWidget* gnc_frequency_new_from_recurrence(GList *recurrences, const GDate *start_date);
void gnc_frequency_init(GncFrequency *gf);
/** /**
* Change the given GncFrequency with the given FreqSpec and GDate. * Change the given GncFrequency with the given FreqSpec and GDate.
* If the FreqSpec is NULL, then no change is made to the widget menus. * If the FreqSpec is NULL, then no change is made to the widget menus.