[balsa] sendmsg-window: Use modern macros
- From: Peter Bloomfield <peterb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [balsa] sendmsg-window: Use modern macros
- Date: Tue, 30 Jul 2019 22:58:38 +0000 (UTC)
commit 1ee7a7370e0bdf8ebd551ca1de08d2c7d98c3748
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date: Tue Jul 30 18:57:32 2019 -0400
sendmsg-window: Use modern macros
Use modern macros to declare and define BalsaAttachInfo
* src/sendmsg-window.c (balsa_attach_info_class_init),
(balsa_attach_info_init), (balsa_attach_info_new),
(balsa_attach_info_finalize), (sw_attachment_list):
ChangeLog | 9 +++++++
src/sendmsg-window.c | 70 +++++++++++-----------------------------------------
2 files changed, 24 insertions(+), 55 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 272579f77..272173ece 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2019-07-30 Peter Bloomfield <pbloomfield bellsouth net>
+
+ sendmsg-window: Use modern macros to declare and define
+ BalsaAttachInfo
+
+ * src/sendmsg-window.c (balsa_attach_info_class_init),
+ (balsa_attach_info_init), (balsa_attach_info_new),
+ (balsa_attach_info_finalize), (sw_attachment_list):
+
2019-07-29 Peter Bloomfield <pbloomfield bellsouth net>
Use parent-class set by G_DEFINE_TYPE instead of our own
diff --git a/src/sendmsg-window.c b/src/sendmsg-window.c
index 9b7fee353..db7c07533 100644
--- a/src/sendmsg-window.c
+++ b/src/sendmsg-window.c
@@ -263,12 +263,16 @@ enum {
ATTACH_NUM_COLUMNS
};
-typedef struct _BalsaAttachInfo BalsaAttachInfo;
-typedef struct _BalsaAttachInfoClass BalsaAttachInfoClass;
-
static const gchar * const attach_modes[] =
{NULL, N_("Attachment"), N_("Inline"), N_("Reference") };
+#define BALSA_TYPE_ATTACH_INFO (balsa_attach_info_get_type())
+G_DECLARE_FINAL_TYPE(BalsaAttachInfo,
+ balsa_attach_info,
+ BALSA,
+ ATTACH_INFO,
+ GObject)
+
struct _BalsaAttachInfo {
GObject parent_object;
@@ -284,65 +288,25 @@ struct _BalsaAttachInfo {
LibBalsaMessageHeaders *headers; /* information about a forwarded message */
};
-struct _BalsaAttachInfoClass {
- GObjectClass parent_class;
-};
-
-
-static GType balsa_attach_info_get_type();
-static void balsa_attach_info_init(GObject *object, gpointer data);
static BalsaAttachInfo* balsa_attach_info_new();
-static void balsa_attach_info_destroy(GObject * object);
+static void balsa_attach_info_finalize(GObject * object);
#define BALSA_MSG_ATTACH_MODEL(x) gtk_tree_view_get_model(GTK_TREE_VIEW((x)->tree_view))
-
-#define TYPE_BALSA_ATTACH_INFO \
- (balsa_attach_info_get_type ())
-#define BALSA_ATTACH_INFO(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_BALSA_ATTACH_INFO, BalsaAttachInfo))
-#define IS_BALSA_ATTACH_INFO(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_BALSA_ATTACH_INFO))
+G_DEFINE_TYPE(BalsaAttachInfo, balsa_attach_info, G_TYPE_OBJECT)
static void
balsa_attach_info_class_init(BalsaAttachInfoClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS(klass);
- object_class->finalize = balsa_attach_info_destroy;
-}
-
-static GType
-balsa_attach_info_get_type()
-{
- static GType balsa_attach_info_type = 0 ;
-
- if (!balsa_attach_info_type) {
- static const GTypeInfo balsa_attach_info_info =
- {
- sizeof (BalsaAttachInfoClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) balsa_attach_info_class_init,
- (GClassFinalizeFunc) NULL,
- NULL,
- sizeof(BalsaAttachInfo),
- 0,
- (GInstanceInitFunc) balsa_attach_info_init
- };
- balsa_attach_info_type =
- g_type_register_static (G_TYPE_OBJECT, "BalsaAttachInfo",
- &balsa_attach_info_info, 0);
- }
- return balsa_attach_info_type;
+ object_class->finalize = balsa_attach_info_finalize;
}
static void
-balsa_attach_info_init(GObject *object, gpointer data)
+balsa_attach_info_init(BalsaAttachInfo *info)
{
- BalsaAttachInfo * info = BALSA_ATTACH_INFO(object);
-
info->popup_menu = NULL;
info->file_uri = NULL;
info->force_mime_type = NULL;
@@ -355,20 +319,17 @@ balsa_attach_info_init(GObject *object, gpointer data)
static BalsaAttachInfo*
balsa_attach_info_new(BalsaSendmsg *bm)
{
- BalsaAttachInfo * info = g_object_new(TYPE_BALSA_ATTACH_INFO, NULL);
+ BalsaAttachInfo * info = g_object_new(BALSA_TYPE_ATTACH_INFO, NULL);
info->bm = bm;
return info;
}
static void
-balsa_attach_info_destroy(GObject * object)
+balsa_attach_info_finalize(GObject * object)
{
BalsaAttachInfo * info;
- GObjectClass *parent_class;
- g_return_if_fail(object != NULL);
- g_return_if_fail(IS_BALSA_ATTACH_INFO(object));
info = BALSA_ATTACH_INFO(object);
/* unlink the file if necessary */
@@ -402,8 +363,7 @@ balsa_attach_info_destroy(GObject * object)
g_free(info->charset);
libbalsa_message_headers_destroy(info->headers);
- parent_class = g_type_class_peek_parent(G_OBJECT_GET_CLASS(object));
- parent_class->finalize(object);
+ G_OBJECT_CLASS(balsa_attach_info_parent_class)->finalize(object);
}
/* ===================================================================
@@ -2657,7 +2617,7 @@ sw_attachment_list(BalsaSendmsg *bsmsg)
GTK_POLICY_AUTOMATIC);
store = gtk_list_store_new(ATTACH_NUM_COLUMNS,
- TYPE_BALSA_ATTACH_INFO,
+ BALSA_TYPE_ATTACH_INFO,
GDK_TYPE_PIXBUF,
G_TYPE_STRING,
G_TYPE_INT,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]