Skip to content

Commit

Permalink
Merge Richard Cohen's 'declare-type-gnc-plugin' into stable.
Browse files Browse the repository at this point in the history
  • Loading branch information
jralls committed Jun 16, 2023
2 parents 915e95e + e6a564d commit 827bfab
Show file tree
Hide file tree
Showing 35 changed files with 152 additions and 559 deletions.
15 changes: 5 additions & 10 deletions gnucash/gnome-utils/gnc-plugin-file-history.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,16 +99,11 @@ static const gchar *gnc_plugin_load_ui_items [] =
NULL,
};

/** The instance private data for a file history plugin. This data
* structure is unused. */
typedef struct GncPluginFileHistoryPrivate
/** The instance data structure for a file history plugin. */
struct _GncPluginFileHistory
{
gpointer dummy;
} GncPluginFileHistoryPrivate;


#define GNC_PLUGIN_FILE_HISTORY_GET_PRIVATE(o) \
((GncPluginFileHistoryPrivate*)gnc_plugin_file_history_get_instance_private((GncPluginFileHistory*)o))
GncPlugin gnc_plugin;
};

/************************************************************
* Other Functions *
Expand Down Expand Up @@ -546,7 +541,7 @@ gnc_plugin_history_list_changed (gpointer prefs,
* Object Implementation *
************************************************************/

G_DEFINE_TYPE_WITH_PRIVATE(GncPluginFileHistory, gnc_plugin_file_history, GNC_TYPE_PLUGIN)
G_DEFINE_TYPE(GncPluginFileHistory, gnc_plugin_file_history, GNC_TYPE_PLUGIN)

/** Initialize the file history plugin class. */
static void
Expand Down
28 changes: 1 addition & 27 deletions gnucash/gnome-utils/gnc-plugin-file-history.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,39 +41,13 @@ G_BEGIN_DECLS

/* type macros */
#define GNC_TYPE_PLUGIN_FILE_HISTORY (gnc_plugin_file_history_get_type ())
#define GNC_PLUGIN_FILE_HISTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNC_TYPE_PLUGIN_FILE_HISTORY, GncPluginFileHistory))
#define GNC_PLUGIN_FILE_HISTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GNC_TYPE_PLUGIN_FILE_HISTORY, GncPluginFileHistoryClass))
#define GNC_IS_PLUGIN_FILE_HISTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNC_TYPE_PLUGIN_FILE_HISTORY))
#define GNC_IS_PLUGIN_FILE_HISTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GNC_TYPE_PLUGIN_FILE_HISTORY))
#define GNC_PLUGIN_FILE_HISTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GNC_TYPE_PLUGIN_FILE_HISTORY, GncPluginFileHistoryClass))
G_DECLARE_FINAL_TYPE (GncPluginFileHistory, gnc_plugin_file_history, GNC, PLUGIN_FILE_HISTORY, GncPlugin)

#define GNC_PLUGIN_FILE_HISTORY_NAME "gnc-plugin-file-history"

/* typedefs & structures */

/** The instance data structure for a file history plugin. */
typedef struct
{
GncPlugin gnc_plugin;
} GncPluginFileHistory;


/** The class data structure for a file history plugin. */
typedef struct
{
GncPluginClass gnc_plugin;
} GncPluginFileHistoryClass;

/* function prototypes */


/** Get the type of a file history plugin.
*
* @return A GType.
*/
GType gnc_plugin_file_history_get_type (void);


/** Create a new file history plugin. This plugin attaches the file
* history menu to any window that is opened.
*
Expand Down
36 changes: 13 additions & 23 deletions gnucash/gnome-utils/gnc-plugin-menu-additions.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,12 @@ static QofLogModule log_module = GNC_MOD_GUI;

#define PLUGIN_ACTIONS_NAME "gnc-plugin-menu-additions-actions"

/** Private data for this plugin. This data structure is unused. */
typedef struct GncPluginMenuAdditionsPrivate
struct _GncPluginMenuAdditions
{
GHashTable *item_hash;
} GncPluginMenuAdditionsPrivate;

#define GNC_PLUGIN_MENU_ADDITIONS_GET_PRIVATE(o) \
((GncPluginMenuAdditionsPrivate*)gnc_plugin_menu_additions_get_instance_private((GncPluginMenuAdditions*)o))
GncPlugin gnc_plugin;

GHashTable *item_hash;
};

/** Per-window private data for this plugin. This plugin is unique in
* that it manages its own menu items. */
Expand Down Expand Up @@ -96,7 +93,7 @@ static guint gnc_plugin_n_actions = G_N_ELEMENTS(gnc_plugin_actions);
* Object Implementation *
************************************************************/

G_DEFINE_TYPE_WITH_PRIVATE(GncPluginMenuAdditions, gnc_plugin_menu_additions, GNC_TYPE_PLUGIN)
G_DEFINE_TYPE(GncPluginMenuAdditions, gnc_plugin_menu_additions, GNC_TYPE_PLUGIN)

static void
gnc_plugin_menu_additions_class_init (GncPluginMenuAdditionsClass *klass)
Expand Down Expand Up @@ -127,14 +124,11 @@ gnc_plugin_menu_additions_init (GncPluginMenuAdditions *plugin)
static void
gnc_plugin_menu_additions_finalize (GObject *object)
{
GncPluginMenuAdditionsPrivate *priv;
g_return_if_fail (GNC_IS_PLUGIN_MENU_ADDITIONS(object));

ENTER("plugin %p", object);

priv = GNC_PLUGIN_MENU_ADDITIONS_GET_PRIVATE(object);

g_hash_table_destroy (priv->item_hash);
g_hash_table_destroy (GNC_PLUGIN_MENU_ADDITIONS(object)->item_hash);

G_OBJECT_CLASS (gnc_plugin_menu_additions_parent_class)->finalize (object);
LEAVE("");
Expand Down Expand Up @@ -180,10 +174,6 @@ gnc_plugin_menu_additions_action_new_cb (GSimpleAction *simple,
GVariant *parameter,
gpointer user_data)
{
GncMainWindowActionData *cb_data = user_data;
GncPlugin *plugin = cb_data->data;
GncPluginMenuAdditionsPrivate *priv;

SCM extension;
gsize length;
const gchar *action_name;
Expand All @@ -192,13 +182,13 @@ gnc_plugin_menu_additions_action_new_cb (GSimpleAction *simple,

ENTER("");

priv = GNC_PLUGIN_MENU_ADDITIONS_GET_PRIVATE(plugin);

action_name = g_variant_get_string (parameter, &length);

PINFO("action name is '%s'", action_name);

extension = g_hash_table_lookup (priv->item_hash, action_name);
GncMainWindowActionData *cb_data = user_data;
GncPluginMenuAdditions *plugin = GNC_PLUGIN_MENU_ADDITIONS(cb_data->data);
extension = g_hash_table_lookup (plugin->item_hash, action_name);

if (extension)
{
Expand Down Expand Up @@ -477,7 +467,6 @@ gnc_plugin_menu_additions_add_to_window (GncPlugin *plugin,
GncMainWindow *window,
GQuark type)
{
GncPluginMenuAdditionsPrivate *priv = GNC_PLUGIN_MENU_ADDITIONS_GET_PRIVATE(plugin);
GncPluginMenuAdditionsPerWindow per_window;
static GOnce accel_table_init = G_ONCE_INIT;
static GHashTable *table;
Expand All @@ -487,10 +476,11 @@ gnc_plugin_menu_additions_add_to_window (GncPlugin *plugin,

ENTER(" ");

if (!priv->item_hash)
priv->item_hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
GncPluginMenuAdditions *menu_plugin = GNC_PLUGIN_MENU_ADDITIONS (plugin);
if (!menu_plugin->item_hash)
menu_plugin->item_hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);

per_window.item_hash = priv->item_hash;
per_window.item_hash = menu_plugin->item_hash;
per_window.build_menu_hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
per_window.report_menu = g_menu_new ();

Expand Down
25 changes: 1 addition & 24 deletions gnucash/gnome-utils/gnc-plugin-menu-additions.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,35 +44,12 @@ G_BEGIN_DECLS

/* type macros */
#define GNC_TYPE_PLUGIN_MENU_ADDITIONS (gnc_plugin_menu_additions_get_type ())
#define GNC_PLUGIN_MENU_ADDITIONS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNC_TYPE_PLUGIN_MENU_ADDITIONS, GncPluginMenuAdditions))
#define GNC_PLUGIN_MENU_ADDITIONS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GNC_TYPE_PLUGIN_MENU_ADDITIONS, GncPluginMenuAdditionsClass))
#define GNC_IS_PLUGIN_MENU_ADDITIONS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNC_TYPE_PLUGIN_MENU_ADDITIONS))
#define GNC_IS_PLUGIN_MENU_ADDITIONS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GNC_TYPE_PLUGIN_MENU_ADDITIONS))
#define GNC_PLUGIN_MENU_ADDITIONS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GNC_TYPE_PLUGIN_MENU_ADDITIONS, GncPluginMenuAdditionsClass))
G_DECLARE_FINAL_TYPE (GncPluginMenuAdditions, gnc_plugin_menu_additions, GNC, PLUGIN_MENU_ADDITIONS, GncPlugin)

#define GNC_PLUGIN_MENU_ADDITIONS_NAME "gnc-plugin-menu-additions"

/* typedefs & structures */
typedef struct
{
GncPlugin gnc_plugin;
} GncPluginMenuAdditions;

typedef struct
{
GncPluginClass gnc_plugin;
} GncPluginMenuAdditionsClass;

/* function prototypes */


/** Get the type of an extensions plugin.
*
* @return A GType.
*/
GType gnc_plugin_menu_additions_get_type (void);


/** Create a new menu_additions plugin. This plugin attaches the menu
* items from Scheme code to any window that is opened.
*
Expand Down
24 changes: 3 additions & 21 deletions gnucash/gnome-utils/gnc-plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,25 +86,14 @@ G_BEGIN_DECLS

/* type macros */
#define GNC_TYPE_PLUGIN (gnc_plugin_get_type ())
#define GNC_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_PLUGIN, GncPlugin))
#define GNC_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GNC_TYPE_PLUGIN, GncPluginClass))
#define GNC_IS_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_PLUGIN))
#define GNC_IS_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GNC_TYPE_PLUGIN))
#define GNC_PLUGIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GNC_PLUGIN, GncPluginClass))
G_DECLARE_DERIVABLE_TYPE (GncPlugin, gnc_plugin, GNC, PLUGIN, GObject)

#define GNC_PLUGIN_NAME "GncPlugin"

/* typedefs & structures */

/** The instance data structure for a menu-only plugin. */
typedef struct
{
/** The parent object for this widget */
GObject gobject;
} GncPlugin;

/** The class data structure for a menu-only plugin. */
typedef struct
struct _GncPluginClass
{
/** The parent class for this widget. */
GObjectClass gobject;
Expand Down Expand Up @@ -163,17 +152,10 @@ typedef struct
* window. */
void (* remove_from_window)
(GncPlugin *plugin, GncMainWindow *window, GQuark type);
} GncPluginClass;
};

/* function prototypes */

/** Get the type of a menu-only plugin.
*
* @return A GType.
*/
GType gnc_plugin_get_type (void);


/** Add the specified plugin to the specified window. This function
* will add the page's user interface from the window and call the
* plugin to perform any plugin specific actions.
Expand Down
14 changes: 6 additions & 8 deletions gnucash/gnome/gnc-plugin-account-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,14 @@ static const gchar *gnc_plugin_load_ui_items [] =
NULL,
};

/** The instance private data structure for an account tree plugin. */
typedef struct GncPluginAccountTreePrivate
/** The instance data structure for an account tree menu plugin. */
struct _GncPluginAccountTree
{
gpointer dummy;
} GncPluginAccountTreePrivate;

G_DEFINE_TYPE_WITH_PRIVATE(GncPluginAccountTree, gnc_plugin_account_tree, GNC_TYPE_PLUGIN)
/** The parent object for this widget */
GncPlugin gnc_plugin;
};

#define GNC_PLUGIN_ACCOUNT_TREE_GET_PRIVATE(o) \
((GncPluginAccountTreePrivate*)gnc_plugin_account_tree_get_instance_private((GncPluginAccountTree*)o))
G_DEFINE_TYPE(GncPluginAccountTree, gnc_plugin_account_tree, GNC_TYPE_PLUGIN)

/* Create a new account tree menu plugin. */
GncPlugin *
Expand Down
30 changes: 1 addition & 29 deletions gnucash/gnome/gnc-plugin-account-tree.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,38 +42,10 @@ G_BEGIN_DECLS

/* type macros */
#define GNC_TYPE_PLUGIN_ACCOUNT_TREE (gnc_plugin_account_tree_get_type ())
#define GNC_PLUGIN_ACCOUNT_TREE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNC_TYPE_PLUGIN_ACCOUNT_TREE, GncPluginAccountTree))
#define GNC_PLUGIN_ACCOUNT_TREE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GNC_TYPE_PLUGIN_ACCOUNT_TREE, GncPluginAccountTreeClass))
#define GNC_IS_PLUGIN_ACCOUNT_TREE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNC_TYPE_PLUGIN_ACCOUNT_TREE))
#define GNC_IS_PLUGIN_ACCOUNT_TREE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GNC_TYPE_PLUGIN_ACCOUNT_TREE))
#define GNC_PLUGIN_ACCOUNT_TREE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GNC_TYPE_PLUGIN_ACCOUNT_TREE, GncPluginAccountTreeClass))
G_DECLARE_FINAL_TYPE (GncPluginAccountTree, gnc_plugin_account_tree, GNC, PLUGIN_ACCOUNT_TREE, GncPlugin)

#define GNC_PLUGIN_ACCOUNT_TREE_NAME "gnc-plugin-account-tree"

/* typedefs & structures */

/** The instance data structure for an account tree menu plugin. */
typedef struct
{
/** The parent object for this widget */
GncPlugin gnc_plugin;
} GncPluginAccountTree;

/** The class data structure for an account tree menu plugin. */
typedef struct
{
/** The parent class for this widget. */
GncPluginClass gnc_plugin;
} GncPluginAccountTreeClass;


/** Get the type of the account tree menu plugin.
*
* @return A GType.
*/
GType gnc_plugin_account_tree_get_type (void);


/** Create a new account tree menu plugin.
*
* @return A pointer to the new object.
Expand Down
15 changes: 6 additions & 9 deletions gnucash/gnome/gnc-plugin-basic-commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -175,15 +175,12 @@ static const gchar *dirty_only_active_actions[] =
NULL
};

/** The instance private data structure for an basic commands
* plugin. */
typedef struct GncPluginBasicCommandsPrivate
/** The instance data structure for an basic commands menu plugin. */
struct _GncPluginBasicCommands
{
gpointer dummy;
} GncPluginBasicCommandsPrivate;

#define GNC_PLUGIN_BASIC_COMMANDS_GET_PRIVATE(o) \
((GncPluginBasicCommandsPrivate*)gnc_plugin_basic_commands_get_instance_private ((GncPluginBasicCommands*)o))
/** The parent object for this widget */
GncPlugin gnc_plugin;
};

/** Create a new basic commands menu plugin. */
GncPlugin *
Expand Down Expand Up @@ -271,7 +268,7 @@ gnc_plugin_basic_commands_main_window_page_changed (GncMainWindow *window,
}
}

G_DEFINE_TYPE_WITH_PRIVATE(GncPluginBasicCommands, gnc_plugin_basic_commands, GNC_TYPE_PLUGIN)
G_DEFINE_TYPE(GncPluginBasicCommands, gnc_plugin_basic_commands, GNC_TYPE_PLUGIN)

/** Initialize the class for a new basic commands plugin. This will
* set up any function pointers that override functions in the parent
Expand Down
31 changes: 1 addition & 30 deletions gnucash/gnome/gnc-plugin-basic-commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,39 +41,10 @@ G_BEGIN_DECLS

/* type macros */
#define GNC_TYPE_PLUGIN_BASIC_COMMANDS (gnc_plugin_basic_commands_get_type ())
#define GNC_PLUGIN_BASIC_COMMANDS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNC_TYPE_PLUGIN_BASIC_COMMANDS, GncPluginBasicCommands))
#define GNC_PLUGIN_BASIC_COMMANDS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GNC_TYPE_PLUGIN_BASIC_COMMANDS, GncPluginBasicCommandsClass))
#define GNC_IS_PLUGIN_BASIC_COMMANDS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNC_TYPE_PLUGIN_BASIC_COMMANDS))
#define GNC_IS_PLUGIN_BASIC_COMMANDS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GNC_TYPE_PLUGIN_BASIC_COMMANDS))
#define GNC_PLUGIN_BASIC_COMMANDS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GNC_TYPE_PLUGIN_BASIC_COMMANDS, GncPluginBasicCommandsClass))
G_DECLARE_FINAL_TYPE (GncPluginBasicCommands, gnc_plugin_basic_commands, GNC, PLUGIN_BASIC_COMMANDS, GncPlugin)

#define GNC_PLUGIN_BASIC_COMMANDS_NAME "gnc-plugin-basic-commands"

/* typedefs & structures */

/** The instance data structure for an basic commands menu plugin. */
typedef struct
{
/** The parent object for this widget */
GncPlugin gnc_plugin;
} GncPluginBasicCommands;


/** The class data structure for a basic commands menu plugin. */
typedef struct
{
/** The parent class for this widget. */
GncPluginClass gnc_plugin;
} GncPluginBasicCommandsClass;


/** Get the type of the basic commands menu plugin.
*
* @return A GType.
*/
GType gnc_plugin_basic_commands_get_type (void);


/** Create a new basic commands menu plugin.
*
* @return A pointer to the new object.
Expand Down

0 comments on commit 827bfab

Please sign in to comment.