Skip to content

Commit

Permalink
use G_DEFINE_TYPE_WITH_CODE to replace g_type_class_add_private
Browse files Browse the repository at this point in the history
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
  • Loading branch information
c-holtermann committed Jan 26, 2019
1 parent 01de893 commit 7127254
Showing 1 changed file with 11 additions and 45 deletions.
56 changes: 11 additions & 45 deletions gnucash/gnome-utils/gnc-main-window.c
Expand Up @@ -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);

Expand Down Expand Up @@ -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))

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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);
Expand All @@ -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));
}


Expand Down

0 comments on commit 7127254

Please sign in to comment.