diff options
author | Gary Kramlich <grim@reaperworld.com> | 2019-11-15 20:52:07 -0600 |
---|---|---|
committer | Gary Kramlich <grim@reaperworld.com> | 2019-11-15 20:52:07 -0600 |
commit | faad70283ccc73c9c4a585a310b7c7bd9f0e9ce4 (patch) | |
tree | c8dba55617ae98df7f376b37694a5bd238d73d45 | |
parent | 30951ce4c757ca248f27e34e5994fa412412d4ee (diff) | |
download | pidgin-faad70283ccc73c9c4a585a310b7c7bd9f0e9ce4.tar.gz |
Move PidginMenuTray to the gtype macros
-rw-r--r-- | pidgin/gtkmenutray.c | 70 | ||||
-rw-r--r-- | pidgin/gtkmenutray.h | 38 |
2 files changed, 28 insertions, 80 deletions
diff --git a/pidgin/gtkmenutray.c b/pidgin/gtkmenutray.c index f917af5e7f..490c128887 100644 --- a/pidgin/gtkmenutray.c +++ b/pidgin/gtkmenutray.c @@ -23,21 +23,22 @@ #include "gtkmenutray.h" -/****************************************************************************** - * Enums - *****************************************************************************/ +struct _PidginMenuTray { + GtkMenuItem parent; + + GtkWidget *tray; +}; + enum { PROP_ZERO = 0, - PROP_BOX + PROP_BOX, + N_PROPERTIES }; /****************************************************************************** * Globals *****************************************************************************/ -static GObjectClass *parent_class = NULL; -/****************************************************************************** - * Internal Stuff - *****************************************************************************/ +static GParamSpec *properties[N_PROPERTIES] = {NULL, }; /****************************************************************************** * Item Stuff @@ -58,8 +59,10 @@ pidgin_menu_tray_deselect(GtkMenuItem *widget) { } /****************************************************************************** - * Object Stuff + * GObject Implementation *****************************************************************************/ +G_DEFINE_TYPE(PidginMenuTray, pidgin_menu_tray, GTK_TYPE_MENU_ITEM); + static void pidgin_menu_tray_get_property(GObject *obj, guint param_id, GValue *value, GParamSpec *pspec) @@ -79,7 +82,7 @@ pidgin_menu_tray_get_property(GObject *obj, guint param_id, GValue *value, static void pidgin_menu_tray_map(GtkWidget *widget) { - GTK_WIDGET_CLASS(parent_class)->map(widget); + GTK_WIDGET_CLASS(pidgin_menu_tray_parent_class)->map(widget); gtk_container_add(GTK_CONTAINER(widget), PIDGIN_MENU_TRAY(widget)->tray); } @@ -100,31 +103,28 @@ pidgin_menu_tray_finalize(GObject *obj) gtk_widget_destroy(GTK_WIDGET(tray->tray)); #endif - G_OBJECT_CLASS(parent_class)->finalize(obj); + G_OBJECT_CLASS(pidgin_menu_tray_parent_class)->finalize(obj); } static void pidgin_menu_tray_class_init(PidginMenuTrayClass *klass) { - GObjectClass *object_class = G_OBJECT_CLASS(klass); + GObjectClass *obj_class = G_OBJECT_CLASS(klass); GtkMenuItemClass *menu_item_class = GTK_MENU_ITEM_CLASS(klass); GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass); - GParamSpec *pspec; - - parent_class = g_type_class_peek_parent(klass); - object_class->finalize = pidgin_menu_tray_finalize; - object_class->get_property = pidgin_menu_tray_get_property; + obj_class->finalize = pidgin_menu_tray_finalize; + obj_class->get_property = pidgin_menu_tray_get_property; menu_item_class->select = pidgin_menu_tray_select; menu_item_class->deselect = pidgin_menu_tray_deselect; widget_class->map = pidgin_menu_tray_map; - pspec = g_param_spec_object("box", "The box", - "The box", - GTK_TYPE_BOX, - G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); - g_object_class_install_property(object_class, PROP_BOX, pspec); + properties[PROP_BOX] = g_param_spec_object("box", "The box", "The box", + GTK_TYPE_BOX, + G_PARAM_READABLE); + + g_object_class_install_properties(obj_class, N_PROPERTIES, properties); } static void @@ -157,32 +157,6 @@ G_GNUC_END_IGNORE_DEPRECATIONS /****************************************************************************** * API *****************************************************************************/ -GType -pidgin_menu_tray_get_type(void) { - static GType type = 0; - - if(type == 0) { - static const GTypeInfo info = { - sizeof(PidginMenuTrayClass), - NULL, - NULL, - (GClassInitFunc)pidgin_menu_tray_class_init, - NULL, - NULL, - sizeof(PidginMenuTray), - 0, - (GInstanceInitFunc)pidgin_menu_tray_init, - NULL - }; - - type = g_type_register_static(GTK_TYPE_MENU_ITEM, - "PidginMenuTray", - &info, 0); - } - - return type; -} - GtkWidget * pidgin_menu_tray_new() { return g_object_new(PIDGIN_TYPE_MENU_TRAY, NULL); diff --git a/pidgin/gtkmenutray.h b/pidgin/gtkmenutray.h index a21c380497..fda01d6962 100644 --- a/pidgin/gtkmenutray.h +++ b/pidgin/gtkmenutray.h @@ -19,6 +19,7 @@ #ifndef PIDGIN_MENU_TRAY_H #define PIDGIN_MENU_TRAY_H + /** * SECTION:gtkmenutray * @section_id: pidgin-gtkmenutray @@ -28,44 +29,17 @@ #include <gtk/gtk.h> -#define PIDGIN_TYPE_MENU_TRAY (pidgin_menu_tray_get_type()) -#define PIDGIN_MENU_TRAY(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), PIDGIN_TYPE_MENU_TRAY, PidginMenuTray)) -#define PIDGIN_MENU_TRAY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), PIDGIN_TYPE_MENU_TRAY, PidginMenuTrayClass)) -#define PIDGIN_IS_MENU_TRAY(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), PIDGIN_TYPE_MENU_TRAY)) -#define PIDGIN_IS_MENU_TRAY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), PIDGIN_TYPE_MENU_TRAY)) -#define PIDGIN_MENU_TRAY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), PIDGIN_TYPE_MENU_TRAY, PidginMenuTrayClass)) +G_BEGIN_DECLS -typedef struct _PidginMenuTray PidginMenuTray; -typedef struct _PidginMenuTrayClass PidginMenuTrayClass; +#define PIDGIN_TYPE_MENU_TRAY (pidgin_menu_tray_get_type()) +G_DECLARE_FINAL_TYPE(PidginMenuTray, pidgin_menu_tray, PIDGIN, MENU_TRAY, GtkMenuItem) /** * PidginMenuTray: - * @tray: The tray - * - * A PidginMenuTray - */ -struct _PidginMenuTray { - GtkMenuItem gparent; - - /*< public >*/ - GtkWidget *tray; -}; - -struct _PidginMenuTrayClass { - GtkMenuItemClass gparent; -}; - -G_BEGIN_DECLS - -/** - * pidgin_menu_tray_get_type: - * - * Registers the PidginMenuTray class if necessary and returns the - * type ID assigned to it. * - * Returns: The PidginMenuTray type ID + * A PidginMenuTray is a #GtkMenuItem that allows you to pack icons into it + * similar to a system notification area but in a windows menu bar. */ -GType pidgin_menu_tray_get_type(void); /** * pidgin_menu_tray_new: |