Skip to content

Commit

Permalink
Refactor: DECLARE/DEFINE_INTERFACE GncWindow < GObject
Browse files Browse the repository at this point in the history
  • Loading branch information
richardcohen committed May 30, 2023
1 parent 8e360bb commit d3bf654
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 39 deletions.
4 changes: 2 additions & 2 deletions gnucash/gnome-utils/gnc-embedded-window.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions gnucash/gnome-utils/gnc-main-window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down
30 changes: 4 additions & 26 deletions gnucash/gnome-utils/gnc-window.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,33 +34,11 @@

static QofLogModule log_module = GNC_MOD_GUI;

GType
gnc_window_get_type (void)
{
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);
}
G_DEFINE_INTERFACE (GncWindow, gnc_window, G_TYPE_OBJECT)

return gnc_window_type;
static void
gnc_window_default_init (GncWindowInterface *klass)
{
}

/************************************************************
Expand Down
12 changes: 3 additions & 9 deletions gnucash/gnome-utils/gnc-window.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

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

0 comments on commit d3bf654

Please sign in to comment.