Replaced manual type macros with G_DECLARE_DERIVABLE_TYPE in GtkXText, CustomList, SexySpellEntry, and RemoteObject declarations while aligning parent instance naming.

Switched GtkXText and CustomList implementations to G_DEFINE_TYPE/G_DEFINE_TYPE_WITH_CODE and preserved parent chaining behavior
Added GTK3/GTK2 conditional type declarations for GtkXText while restoring the legacy macro block for GTK2 builds.
Restored GTK2-friendly typedefs/macros and parent field naming for CustomList alongside GTK3 G_DECLARE_DERIVABLE_TYPE usage.
Restored GTK2-friendly typedefs/macros and parent field naming for SexySpellEntry while keeping GTK3 declarations intact.
Restored legacy RemoteObject typedefs and GType macros in the D-Bus plugin to keep GTK2 builds from seeing incomplete types or missing fields/macros.
This commit is contained in:
2026-01-31 10:45:22 -07:00
parent e1b4e18153
commit 9e46407e89
6 changed files with 58 additions and 127 deletions

View File

@@ -40,12 +40,12 @@ static GList *contexts = NULL;
static GHashTable *clients = NULL;
static DBusGConnection *connection;
typedef struct RemoteObject RemoteObject;
typedef struct RemoteObjectClass RemoteObjectClass;
typedef struct _RemoteObject RemoteObject;
typedef struct _RemoteObjectClass RemoteObjectClass;
GType Remote_object_get_type (void);
GType remote_object_get_type (void);
struct RemoteObject
struct _RemoteObject
{
GObject parent;
@@ -59,9 +59,9 @@ struct RemoteObject
void *handle;
};
struct RemoteObjectClass
struct _RemoteObjectClass
{
GObjectClass parent;
GObjectClass parent_class;
};
typedef struct

View File

@@ -101,9 +101,13 @@ static void custom_list_sortable_set_default_sort_func (GtkTreeSortable *
static gboolean custom_list_sortable_has_default_sort_func (GtkTreeSortable *
sortable);
static void custom_list_sortable_init (GtkTreeSortableIface * iface);
static GObjectClass *parent_class = NULL; /* GObject stuff - nothing to worry about */
G_DEFINE_TYPE_WITH_CODE (CustomList, custom_list, G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (GTK_TYPE_TREE_MODEL, custom_list_tree_model_init)
G_IMPLEMENT_INTERFACE (GTK_TYPE_TREE_SORTABLE, custom_list_sortable_init))
static void
@@ -116,70 +120,6 @@ custom_list_sortable_init (GtkTreeSortableIface * iface)
iface->has_default_sort_func = custom_list_sortable_has_default_sort_func; /* NOT SUPPORTED */
}
/*****************************************************************************
*
* custom_list_get_type: here we register our new type and its interfaces
* with the type system. If you want to implement
* additional interfaces like GtkTreeSortable, you
* will need to do it here.
*
*****************************************************************************/
GType
custom_list_get_type (void)
{
static GType custom_list_type = 0;
if (custom_list_type)
return custom_list_type;
/* Some boilerplate type registration stuff */
{
static const GTypeInfo custom_list_info = {
sizeof (CustomListClass),
NULL, /* base_init */
NULL, /* base_finalize */
(GClassInitFunc) custom_list_class_init,
NULL, /* class finalize */
NULL, /* class_data */
sizeof (CustomList),
0, /* n_preallocs */
(GInstanceInitFunc) custom_list_init
};
custom_list_type =
g_type_register_static (G_TYPE_OBJECT, "CustomList",
&custom_list_info, (GTypeFlags) 0);
}
/* Here we register our GtkTreeModel interface with the type system */
{
static const GInterfaceInfo tree_model_info = {
(GInterfaceInitFunc) custom_list_tree_model_init,
NULL,
NULL
};
g_type_add_interface_static (custom_list_type, GTK_TYPE_TREE_MODEL,
&tree_model_info);
}
/* Add GtkTreeSortable interface */
{
static const GInterfaceInfo tree_sortable_info = {
(GInterfaceInitFunc) custom_list_sortable_init,
NULL,
NULL
};
g_type_add_interface_static (custom_list_type,
GTK_TYPE_TREE_SORTABLE,
&tree_sortable_info);
}
return custom_list_type;
}
/*****************************************************************************
*
* custom_list_class_init: more boilerplate GObject/GType stuff.
@@ -193,7 +133,6 @@ custom_list_class_init (CustomListClass * klass)
{
GObjectClass *object_class;
parent_class = (GObjectClass *) g_type_class_peek_parent (klass);
object_class = (GObjectClass *) klass;
object_class->finalize = custom_list_finalize;
@@ -265,7 +204,7 @@ custom_list_finalize (GObject * object)
custom_list_clear (CUSTOM_LIST (object));
/* must chain up - finalize parent */
(*parent_class->finalize) (object);
G_OBJECT_CLASS (custom_list_parent_class)->finalize (object);
}

View File

@@ -22,6 +22,12 @@
#include <gtk/gtk.h>
#if HAVE_GTK3
G_DECLARE_DERIVABLE_TYPE (CustomList, custom_list, CUSTOM, LIST, GObject)
#else
typedef struct _CustomList CustomList;
typedef struct _CustomListClass CustomListClass;
GType custom_list_get_type (void);
/* Some boilerplate GObject defines. 'klass' is used
@@ -33,6 +39,7 @@ GType custom_list_get_type (void);
#define CUSTOM_IS_LIST(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CUSTOM_TYPE_LIST))
#define CUSTOM_IS_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CUSTOM_TYPE_LIST))
#define CUSTOM_LIST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CUSTOM_TYPE_LIST, CustomListClass))
#endif
/* The data columns that we export via the tree model interface */
@@ -62,20 +69,19 @@ typedef struct
}
chanlistrow;
typedef struct _CustomList CustomList;
typedef struct _CustomListClass CustomListClass;
/* CustomList: this structure contains everything we need for our
* model implementation. You can add extra fields to
* this structure, e.g. hashtables to quickly lookup
* rows or whatever else you might need, but it is
* crucial that 'parent' is the first member of the
* crucial that 'parent_instance' is the first member of the
* structure. */
struct _CustomList
{
#if HAVE_GTK3
GObject parent_instance;
#else
GObject parent;
#endif
guint num_rows; /* number of rows that we have used */
guint num_alloc; /* number of rows allocated */

View File

@@ -18,11 +18,17 @@
#ifndef _SEXY_SPELL_ENTRY_H_
#define _SEXY_SPELL_ENTRY_H_
#include <gtk/gtk.h>
G_BEGIN_DECLS
#if HAVE_GTK3
G_DECLARE_DERIVABLE_TYPE (SexySpellEntry, sexy_spell_entry, SEXY, SPELL_ENTRY, GtkEntry)
#else
typedef struct _SexySpellEntry SexySpellEntry;
typedef struct _SexySpellEntryClass SexySpellEntryClass;
typedef struct _SexySpellEntryPriv SexySpellEntryPriv;
#include <gtk/gtk.h>
GType sexy_spell_entry_get_type(void);
#define SEXY_TYPE_SPELL_ENTRY (sexy_spell_entry_get_type())
#define SEXY_SPELL_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SEXY_TYPE_SPELL_ENTRY, SexySpellEntry))
@@ -30,6 +36,9 @@ typedef struct _SexySpellEntryPriv SexySpellEntryPriv;
#define SEXY_IS_SPELL_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SEXY_TYPE_SPELL_ENTRY))
#define SEXY_IS_SPELL_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SEXY_TYPE_SPELL_ENTRY))
#define SEXY_SPELL_ENTRY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), SEXY_TYPE_SPELL_ENTRY, SexySpellEntryClass))
#endif
typedef struct _SexySpellEntryPriv SexySpellEntryPriv;
#define SEXY_SPELL_ERROR (sexy_spell_error_quark())
@@ -39,7 +48,11 @@ typedef enum {
struct _SexySpellEntry
{
#if HAVE_GTK3
GtkEntry parent_instance;
#else
GtkEntry parent_object;
#endif
SexySpellEntryPriv *priv;
@@ -62,9 +75,6 @@ struct _SexySpellEntryClass
void (*gtk_reserved4)(void);
};
G_BEGIN_DECLS
GType sexy_spell_entry_get_type(void);
GtkWidget *sexy_spell_entry_new(void);
GQuark sexy_spell_error_quark(void);

View File

@@ -72,8 +72,6 @@
/* force scrolling off */
#define dontscroll(buf) (buf)->last_pixel_pos = 0x7fffffff
static GtkWidgetClass *parent_class = NULL;
struct textentry
{
struct textentry *next;
@@ -112,6 +110,8 @@ enum
static guint xtext_signals[LAST_SIGNAL];
G_DEFINE_TYPE (GtkXText, gtk_xtext, GTK_TYPE_WIDGET)
char *nocasestrstr (const char *text, const char *tofind); /* util.c */
int xtext_get_stamp_str (time_t, char **);
static void gtk_xtext_render_page (GtkXText * xtext);
@@ -865,8 +865,8 @@ gtk_xtext_destroy (GtkObject * object)
gtk_xtext_cleanup (xtext);
if (GTK_OBJECT_CLASS (parent_class)->destroy)
(*GTK_OBJECT_CLASS (parent_class)->destroy) (object);
if (GTK_OBJECT_CLASS (gtk_xtext_parent_class)->destroy)
(*GTK_OBJECT_CLASS (gtk_xtext_parent_class)->destroy) (object);
}
#endif
@@ -878,15 +878,15 @@ gtk_xtext_dispose (GObject *object)
gtk_xtext_cleanup (xtext);
if (G_OBJECT_CLASS (parent_class)->dispose)
(*G_OBJECT_CLASS (parent_class)->dispose) (object);
if (G_OBJECT_CLASS (gtk_xtext_parent_class)->dispose)
(*G_OBJECT_CLASS (gtk_xtext_parent_class)->dispose) (object);
}
static void
gtk_xtext_finalize (GObject *object)
{
if (G_OBJECT_CLASS (parent_class)->finalize)
(*G_OBJECT_CLASS (parent_class)->finalize) (object);
if (G_OBJECT_CLASS (gtk_xtext_parent_class)->finalize)
(*G_OBJECT_CLASS (gtk_xtext_parent_class)->finalize) (object);
}
#endif
@@ -907,8 +907,8 @@ gtk_xtext_unrealize (GtkWidget * widget)
gdk_window_set_user_data (widget->window, NULL);
#endif
if (parent_class->unrealize)
(* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget);
if (GTK_WIDGET_CLASS (gtk_xtext_parent_class)->unrealize)
(*GTK_WIDGET_CLASS (gtk_xtext_parent_class)->unrealize) (widget);
#if HAVE_GTK3
gtk_widget_set_window (widget, NULL);
@@ -2749,8 +2749,6 @@ gtk_xtext_class_init (GtkXTextClass * class)
widget_class = (GtkWidgetClass *) class;
xtext_class = (GtkXTextClass *) class;
parent_class = g_type_class_peek (gtk_widget_get_type ());
xtext_signals[WORD_CLICK] =
g_signal_new ("word_click",
G_TYPE_FROM_CLASS (object_class),
@@ -2795,33 +2793,6 @@ gtk_xtext_class_init (GtkXTextClass * class)
xtext_class->set_scroll_adjustments = gtk_xtext_scroll_adjustments;
}
GType
gtk_xtext_get_type (void)
{
static GType xtext_type = 0;
if (!xtext_type)
{
static const GTypeInfo xtext_info =
{
sizeof (GtkXTextClass),
NULL, /* base_init */
NULL, /* base_finalize */
(GClassInitFunc) gtk_xtext_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GtkXText),
0, /* n_preallocs */
(GInstanceInitFunc) gtk_xtext_init,
};
xtext_type = g_type_register_static (GTK_TYPE_WIDGET, "GtkXText",
&xtext_info, 0);
}
return xtext_type;
}
/* strip MIRC colors and other attribs. */
/* CL: needs to strip hidden when called by gtk_xtext_text_width, but not when copying text */

View File

@@ -27,6 +27,12 @@
#include <cairo.h>
#include "xtext-color.h"
#if HAVE_GTK3
G_DECLARE_DERIVABLE_TYPE (GtkXText, gtk_xtext, GTK, XTEXT, GtkWidget)
#else
typedef struct _GtkXText GtkXText;
typedef struct _GtkXTextClass GtkXTextClass;
#define GTK_TYPE_XTEXT (gtk_xtext_get_type ())
#define GTK_XTEXT(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GTK_TYPE_XTEXT, GtkXText))
#define GTK_XTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_XTEXT, GtkXTextClass))
@@ -34,6 +40,9 @@
#define GTK_IS_XTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_XTEXT))
#define GTK_XTEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_XTEXT, GtkXTextClass))
GType gtk_xtext_get_type (void);
#endif
#define ATTR_BOLD '\002'
#define ATTR_COLOR '\003'
#define ATTR_BLINK '\006'
@@ -55,9 +64,6 @@
#define XTEXT_BG 35
#define XTEXT_MARKER 36 /* for marker line */
#define XTEXT_MAX_COLOR 41
typedef struct _GtkXText GtkXText;
typedef struct _GtkXTextClass GtkXTextClass;
typedef struct textentry textentry;
/*
@@ -300,6 +306,5 @@ xtext_buffer *gtk_xtext_buffer_new (GtkXText *xtext);
void gtk_xtext_buffer_free (xtext_buffer *buf);
void gtk_xtext_buffer_show (GtkXText *xtext, xtext_buffer *buf, int render);
void gtk_xtext_copy_selection (GtkXText *xtext);
GType gtk_xtext_get_type (void);
#endif