Refactor: DECLARE/DEFINE_INTERFACE GncWindow < GObject

This commit is contained in:
Richard Cohen 2023-05-04 17:31:57 +01:00
parent 8e360bbe84
commit d3bf654b11
4 changed files with 11 additions and 39 deletions

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_finalize (GObject *object);
static void gnc_embedded_window_dispose (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); 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 * @param iface A pointer to the interface data structure to
* populate. */ * populate. */
static void 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_gtk_window = gnc_embedded_window_get_gtk_window;
iface->get_statusbar = gnc_embedded_window_get_statusbar; 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_destroy (GtkWidget *widget);
static void gnc_main_window_setup_window (GncMainWindow *window); 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 #ifndef MAC_INTEGRATION
static void gnc_main_window_update_all_menu_items (void); static void gnc_main_window_update_all_menu_items (void);
#endif #endif
@ -5453,7 +5453,7 @@ gnc_main_window_get_accel_group (GncWindow *window)
* @param iface A pointer to the interface data structure to * @param iface A pointer to the interface data structure to
* populate. */ * populate. */
static void 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_gtk_window = gnc_main_window_get_gtk_window;
iface->get_statusbar = gnc_main_window_get_statusbar; iface->get_statusbar = gnc_main_window_get_statusbar;

View File

@ -34,33 +34,11 @@
static QofLogModule log_module = GNC_MOD_GUI; static QofLogModule log_module = GNC_MOD_GUI;
GType G_DEFINE_INTERFACE (GncWindow, gnc_window, G_TYPE_OBJECT)
gnc_window_get_type (void)
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 */ /* type macros */
#define GNC_TYPE_WINDOW (gnc_window_get_type ()) #define GNC_TYPE_WINDOW (gnc_window_get_type ())
#define GNC_WINDOW(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_WINDOW, GncWindow)) G_DECLARE_INTERFACE (GncWindow, gnc_window, GNC, WINDOW, GObject)
#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))
/* typedefs & structures */ /* typedefs & structures */
typedef struct GncWindow GncWindow; /* dummy typedef */ struct _GncWindowInterface
typedef struct
{ {
GTypeInterface parent; GTypeInterface parent;
@ -68,11 +64,9 @@ typedef struct
GMenuModel * (* get_menubar_model) (GncWindow *window); GMenuModel * (* get_menubar_model) (GncWindow *window);
GtkAccelGroup * (* get_accel_group) (GncWindow *window); GtkAccelGroup * (* get_accel_group) (GncWindow *window);
void (* ui_set_sensitive) (GncWindow *window, gboolean sensitive); void (* ui_set_sensitive) (GncWindow *window, gboolean sensitive);
} GncWindowIface; };
/* function prototypes */ /* function prototypes */
GType gnc_window_get_type (void);
GtkWindow *gnc_window_get_gtk_window (GncWindow *window); GtkWindow *gnc_window_get_gtk_window (GncWindow *window);
void gnc_window_update_status (GncWindow *window, GncPluginPage *page); void gnc_window_update_status (GncWindow *window, GncPluginPage *page);