Merge Richard Cohen's 'more-define-types' into stable.

This commit is contained in:
John Ralls 2023-06-06 21:27:36 -07:00
commit dda661cfd2
10 changed files with 28 additions and 159 deletions

View File

@ -41,14 +41,9 @@ enum { GDCM_ADDED, GDCM_UPDATE, GDCM_REMOVE, LAST_SIGNAL };
static guint gnc_dense_cal_model_signals[LAST_SIGNAL] = { 0 };
static void
gnc_dense_cal_model_base_init(gpointer g_class)
gnc_dense_cal_model_default_init(GncDenseCalModelInterface *g_class)
{
static gboolean initialized = FALSE;
if (!initialized)
{
gnc_dense_cal_model_signals[GDCM_ADDED]
= g_signal_new("added",
gnc_dense_cal_model_signals[GDCM_ADDED] = g_signal_new("added",
G_TYPE_FROM_CLASS(g_class),
G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS,
0 /* default offset */,
@ -60,8 +55,7 @@ gnc_dense_cal_model_base_init(gpointer g_class)
G_TYPE_UINT /* param types */
);
gnc_dense_cal_model_signals[GDCM_UPDATE]
= g_signal_new("update",
gnc_dense_cal_model_signals[GDCM_UPDATE] = g_signal_new("update",
G_TYPE_FROM_CLASS(g_class),
G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS,
0 /* default offset */,
@ -73,8 +67,7 @@ gnc_dense_cal_model_base_init(gpointer g_class)
G_TYPE_UINT /* param types */
);
gnc_dense_cal_model_signals[GDCM_REMOVE]
= g_signal_new("removing",
gnc_dense_cal_model_signals[GDCM_REMOVE] = g_signal_new("removing",
G_TYPE_FROM_CLASS(g_class),
G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS,
0 /* default offset */,
@ -85,60 +78,36 @@ gnc_dense_cal_model_base_init(gpointer g_class)
1 /* n_params */,
G_TYPE_UINT /* param types */
);
initialized = TRUE;
}
}
GType
gnc_dense_cal_model_get_type(void)
{
static GType type = 0;
if (type == 0)
{
static const GTypeInfo info =
{
sizeof(GncDenseCalModelIface),
gnc_dense_cal_model_base_init, /* base_init */
NULL, /* base_finalize */
NULL, /* class_init */
NULL, /* class_finalize */
NULL, /* class_data */
0,
0, /* n_preallocs */
NULL /* instance_init */
};
type = g_type_register_static(G_TYPE_INTERFACE, "GncDenseCalModel", &info, 0);
}
return type;
}
G_DEFINE_INTERFACE (GncDenseCalModel, gnc_dense_cal_model, G_TYPE_OBJECT)
GList*
gnc_dense_cal_model_get_contained(GncDenseCalModel *model)
{
return (*GNC_DENSE_CAL_MODEL_GET_INTERFACE(model)->get_contained)(model);
return (*GNC_DENSE_CAL_MODEL_GET_IFACE(model)->get_contained)(model);
}
gchar*
gnc_dense_cal_model_get_name(GncDenseCalModel *model, guint tag)
{
return (*GNC_DENSE_CAL_MODEL_GET_INTERFACE(model)->get_name)(model, tag);
return (*GNC_DENSE_CAL_MODEL_GET_IFACE(model)->get_name)(model, tag);
}
gchar*
gnc_dense_cal_model_get_info(GncDenseCalModel *model, guint tag)
{
return (*GNC_DENSE_CAL_MODEL_GET_INTERFACE(model)->get_info)(model, tag);
return (*GNC_DENSE_CAL_MODEL_GET_IFACE(model)->get_info)(model, tag);
}
gint
gnc_dense_cal_model_get_instance_count(GncDenseCalModel *model, guint tag)
{
return (*GNC_DENSE_CAL_MODEL_GET_INTERFACE(model)->get_instance_count)(model, tag);
return (*GNC_DENSE_CAL_MODEL_GET_IFACE(model)->get_instance_count)(model, tag);
}
void
gnc_dense_cal_model_get_instance(GncDenseCalModel *model, guint tag, gint instance_index, GDate *date)
{
(*GNC_DENSE_CAL_MODEL_GET_INTERFACE(model)->get_instance)(model, tag, instance_index, date);
(*GNC_DENSE_CAL_MODEL_GET_IFACE(model)->get_instance)(model, tag, instance_index, date);
}

View File

@ -30,29 +30,19 @@
G_BEGIN_DECLS
#define GNC_TYPE_DENSE_CAL_MODEL (gnc_dense_cal_model_get_type())
#define GNC_DENSE_CAL_MODEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNC_TYPE_DENSE_CAL_MODEL, GncDenseCalModel))
#define GNC_IS_DENSE_CAL_MODEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNC_TYPE_DENSE_CAL_MODEL))
#define GNC_DENSE_CAL_MODEL_GET_INTERFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), GNC_TYPE_DENSE_CAL_MODEL, GncDenseCalModelIface))
G_DECLARE_INTERFACE (GncDenseCalModel, gnc_dense_cal_model, GNC, DENSE_CAL_MODEL, GObject)
typedef struct _GncDenseCalModel GncDenseCalModel; /* non existent */
typedef struct _GncDenseCalModelIface
struct _GncDenseCalModelInterface
{
GTypeInterface parent;
/* signals */
void (*insert)(GncDenseCalModel *mdl, gint tag);
void (*update)(GncDenseCalModel *mdl, gint tag);
void (*remove)(GncDenseCalModel *mdl, gint tag);
/* virtual table */
GList* (*get_contained)(GncDenseCalModel *model);
gchar* (*get_name)(GncDenseCalModel *model, guint tag);
gchar* (*get_info)(GncDenseCalModel *model, guint tag);
gint (*get_instance_count)(GncDenseCalModel *model, guint tag);
void (*get_instance)(GncDenseCalModel *model, guint tag, gint instance_index, GDate *date);
} GncDenseCalModelIface;
GType gnc_dense_cal_model_get_type(void);
};
/** @return Caller-owned GList (but not elements). The Model-user will free. **/
GList* gnc_dense_cal_model_get_contained(GncDenseCalModel *model);

View File

@ -59,7 +59,7 @@ struct _GncDenseCalStoreClass
GObjectClass parent_class;
};
static void gnc_dense_cal_store_iface_init(GncDenseCalModelIface *iface);
static void gnc_dense_cal_store_iface_init(GncDenseCalModelInterface *iface);
static void gnc_dense_cal_store_finalize(GObject *obj);
static GList* gdcs_get_contained(GncDenseCalModel *model);
@ -85,7 +85,7 @@ gnc_dense_cal_store_init(GncDenseCalStore *self)
}
static void
gnc_dense_cal_store_iface_init(GncDenseCalModelIface *iface)
gnc_dense_cal_store_iface_init(GncDenseCalModelInterface *iface)
{
iface->get_contained = gdcs_get_contained;
iface->get_name = gdcs_get_name;

View File

@ -58,7 +58,7 @@ static QofLogModule log_module = GNC_MOD_GUI;
static void gnc_embedded_window_finalize (GObject *object);
static void gnc_embedded_window_dispose (GObject *object);
static void gnc_window_embedded_window_init (GncWindowIface *iface);
static void gnc_window_embedded_window_init (GncWindowInterface *iface);
static void gnc_embedded_window_setup_window (GncEmbeddedWindow *window);
@ -499,7 +499,7 @@ gnc_embedded_window_get_accel_group (GncWindow *window)
* @param iface A pointer to the interface data structure to
* populate. */
static void
gnc_window_embedded_window_init (GncWindowIface *iface)
gnc_window_embedded_window_init (GncWindowInterface *iface)
{
iface->get_gtk_window = gnc_embedded_window_get_gtk_window;
iface->get_statusbar = gnc_embedded_window_get_statusbar;

View File

@ -154,7 +154,7 @@ static void gnc_main_window_finalize (GObject *object);
static void gnc_main_window_destroy (GtkWidget *widget);
static void gnc_main_window_setup_window (GncMainWindow *window);
static void gnc_window_main_window_init (GncWindowIface *iface);
static void gnc_window_main_window_init (GncWindowInterface *iface);
#ifndef MAC_INTEGRATION
static void gnc_main_window_update_all_menu_items (void);
#endif
@ -5453,7 +5453,7 @@ gnc_main_window_get_accel_group (GncWindow *window)
* @param iface A pointer to the interface data structure to
* populate. */
static void
gnc_window_main_window_init (GncWindowIface *iface)
gnc_window_main_window_init (GncWindowInterface *iface)
{
iface->get_gtk_window = gnc_main_window_get_gtk_window;
iface->get_statusbar = gnc_main_window_get_statusbar;

View File

@ -40,7 +40,7 @@
#define G_LOG_DOMAIN "gnc.gui.sx.adapter.sx-dense-cal"
static const QofLogModule log_module = G_LOG_DOMAIN;
static void gnc_sx_instance_dense_cal_adapter_interface_init(GncDenseCalModelIface *iface);
static void gnc_sx_instance_dense_cal_adapter_interface_init(GncDenseCalModelInterface *iface);
static void gnc_sx_instance_dense_cal_adapter_dispose(GObject *obj);
static void gnc_sx_instance_dense_cal_adapter_finalize(GObject *obj);
@ -82,7 +82,7 @@ gnc_sx_instance_dense_cal_adapter_init(GncSxInstanceDenseCalAdapter *instance)
}
static void
gnc_sx_instance_dense_cal_adapter_interface_init(GncDenseCalModelIface *iface)
gnc_sx_instance_dense_cal_adapter_interface_init(GncDenseCalModelInterface *iface)
{
iface->get_contained = gsidca_get_contained;
iface->get_name = gsidca_get_name;

View File

@ -34,33 +34,11 @@
static QofLogModule log_module = GNC_MOD_GUI;
GType
gnc_window_get_type (void)
G_DEFINE_INTERFACE (GncWindow, gnc_window, G_TYPE_OBJECT)
static void
gnc_window_default_init (GncWindowInterface *klass)
{
static GType gnc_window_type = 0;
if (gnc_window_type == 0)
{
static const GTypeInfo our_info =
{
sizeof (GncWindowIface),
NULL,
NULL,
NULL,
NULL,
NULL,
0,
0,
NULL
};
gnc_window_type = g_type_register_static (G_TYPE_INTERFACE,
"GncWindow",
&our_info, 0);
g_type_interface_add_prerequisite (gnc_window_type, G_TYPE_OBJECT);
}
return gnc_window_type;
}
/************************************************************

View File

@ -48,14 +48,10 @@ G_BEGIN_DECLS
/* type macros */
#define GNC_TYPE_WINDOW (gnc_window_get_type ())
#define GNC_WINDOW(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_WINDOW, GncWindow))
#define GNC_IS_WINDOW(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_WINDOW))
#define GNC_WINDOW_GET_IFACE(o) (G_TYPE_INSTANCE_GET_INTERFACE ((o), GNC_TYPE_WINDOW, GncWindowIface))
G_DECLARE_INTERFACE (GncWindow, gnc_window, GNC, WINDOW, GObject)
/* typedefs & structures */
typedef struct GncWindow GncWindow; /* dummy typedef */
typedef struct
struct _GncWindowInterface
{
GTypeInterface parent;
@ -68,11 +64,9 @@ typedef struct
GMenuModel * (* get_menubar_model) (GncWindow *window);
GtkAccelGroup * (* get_accel_group) (GncWindow *window);
void (* ui_set_sensitive) (GncWindow *window, gboolean sensitive);
} GncWindowIface;
};
/* function prototypes */
GType gnc_window_get_type (void);
GtkWindow *gnc_window_get_gtk_window (GncWindow *window);
void gnc_window_update_status (GncWindow *window, GncPluginPage *page);

View File

@ -9,7 +9,6 @@ include (GncFindLibm)
set (app_utils_HEADERS
QuickFill.h
file-utils.h
gnc-basic-gobject.h
gnc-account-merge.h
gnc-addr-quickfill.h
gnc-entry-quickfill.h

View File

@ -1,61 +0,0 @@
/********************************************************************\
* gnc-basic-gobject.h *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation; either version 2 of *
* the License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License*
* along with this program; if not, write to the Free Software *
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
\********************************************************************/
#ifndef GNC_BASIC_GOBJECT_H
#define GNC_BASIC_GOBJECT_H
/* A simple macro to define simple gobjects */
#define GNC_BASIC_GOBJECT_TYPE(type_struct,klass_struct,parent,klass_init,inst_init,get_type_fcn) \
GType \
get_type_fcn (void) \
{ \
static GType type = 0; \
\
if (type == 0) { \
GTypeInfo type_info = { \
sizeof (klass_struct), \
NULL, \
NULL, \
(GClassInitFunc) klass_init, \
NULL, \
NULL, \
sizeof (type_struct), \
0, \
(GInstanceInitFunc) inst_init, \
}; \
\
type = g_type_register_static (parent, #type_struct, &type_info, 0); \
} \
\
return type; \
}
#define GNC_BASIC_GOBJECT_NEW(type_struct,new_fcn,get_type_fcn) \
type_struct * \
new_fcn (void) \
{ \
return (type_struct *) g_object_new(get_type_fcn (), NULL); \
}
#define GNC_BASIC_GOBJECT(type_struct,klass_struct,parent,klass_init,inst_init,get_type_fcn,new_fcn) \
GNC_BASIC_GOBJECT_TYPE(type_struct,klass_struct,parent,klass_init,inst_init,get_type_fcn) \
GNC_BASIC_GOBJECT_NEW(type_struct,new_fcn,get_type_fcn)
#endif /* GNC_BASIC_GOBJECT_H */