use G_DEFINE_TYPE_WITH_CODE to replace g_type_class_add_private

gnc_main_window_get_type is being replaced by that provided by G_DEFINE_TYPE_WITH_PRIVATE

use GNC_DEFINE_TYPE_WITH_CODE to preserve 2nd init parameter
This commit is contained in:
Christoph Holtermann 2018-12-07 11:04:17 +01:00 committed by c-holtermann
parent 01de89383b
commit 71272548fb

View File

@ -129,7 +129,8 @@ static guint secs_to_save = 0;
/* Declarations *********************************************************/
static void gnc_main_window_class_init (GncMainWindowClass *klass);
static void gnc_main_window_init (GncMainWindow *window, GncMainWindowClass *klass);
static void gnc_main_window_init (GncMainWindow *window,
void *data);
static void gnc_main_window_finalize (GObject *object);
static void gnc_main_window_destroy (GtkWidget *widget);
@ -233,6 +234,11 @@ typedef struct GncMainWindowPrivate
GHashTable *merged_actions_table;
} GncMainWindowPrivate;
GNC_DEFINE_TYPE_WITH_CODE(GncMainWindow, gnc_main_window, GTK_TYPE_WINDOW,
G_ADD_PRIVATE (GncMainWindow)
G_IMPLEMENT_INTERFACE (GNC_TYPE_WINDOW,
gnc_window_main_window_init))
#define GNC_MAIN_WINDOW_GET_PRIVATE(o) \
(G_TYPE_INSTANCE_GET_PRIVATE ((o), GNC_TYPE_MAIN_WINDOW, GncMainWindowPrivate))
@ -2461,45 +2467,6 @@ gnc_main_window_tab_entry_key_press_event (GtkWidget *entry,
* Widget Implementation *
************************************************************/
/* Get the type of a gnc main window.
*/
GType
gnc_main_window_get_type (void)
{
static GType gnc_main_window_type = 0;
if (gnc_main_window_type == 0)
{
static const GTypeInfo our_info =
{
sizeof (GncMainWindowClass),
NULL,
NULL,
(GClassInitFunc) gnc_main_window_class_init,
NULL,
NULL,
sizeof (GncMainWindow),
0,
(GInstanceInitFunc) gnc_main_window_init
};
static const GInterfaceInfo plugin_info =
{
(GInterfaceInitFunc) gnc_window_main_window_init,
NULL,
NULL
};
gnc_main_window_type = g_type_register_static (GTK_TYPE_WINDOW,
GNC_MAIN_WINDOW_NAME,
&our_info, 0);
g_type_add_interface_static (gnc_main_window_type,
GNC_TYPE_WINDOW,
&plugin_info);
}
return gnc_main_window_type;
}
/** Initialize the class for a new gnucash main window. This will set
@ -2524,8 +2491,6 @@ gnc_main_window_class_init (GncMainWindowClass *klass)
/* GtkWidget signals */
gtkwidget_class->destroy = gnc_main_window_destroy;
g_type_class_add_private(klass, sizeof(GncMainWindowPrivate));
/**
* GncMainWindow::page_added:
* @param window: the #GncMainWindow
@ -2593,11 +2558,12 @@ gnc_main_window_class_init (GncMainWindowClass *klass)
* @param klass A pointer to the class data structure for this
* object. */
static void
gnc_main_window_init (GncMainWindow *window,
GncMainWindowClass *klass)
gnc_main_window_init (GncMainWindow *window, void *data)
{
GncMainWindowPrivate *priv;
GncMainWindowClass *klass = (GncMainWindowClass*)data;
priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
priv->merged_actions_table =
g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
@ -2619,7 +2585,7 @@ gnc_main_window_init (GncMainWindow *window,
gnc_main_window_setup_window (window);
gnc_gobject_tracking_remember(G_OBJECT(window),
G_OBJECT_CLASS(klass));
G_OBJECT_CLASS(klass));
}