diff options
author | Ted Gould <ted@gould.cx> | 2009-12-15 16:49:07 -0600 |
---|---|---|
committer | Ted Gould <ted@gould.cx> | 2009-12-15 16:49:07 -0600 |
commit | 5e7b2cec7f0ffd4147d81470ca162fd14ed92836 (patch) | |
tree | b0878d1c30a144bb2b1b766083f383a46fab2d79 /libdbusmenu-gtk | |
parent | fcb8ac056eceee3ac25f28812cd9090177d91463 (diff) | |
download | libdbusmenu-5e7b2cec7f0ffd4147d81470ca162fd14ed92836.tar.gz libdbusmenu-5e7b2cec7f0ffd4147d81470ca162fd14ed92836.tar.bz2 libdbusmenu-5e7b2cec7f0ffd4147d81470ca162fd14ed92836.zip |
Better handling of the draw_indicator function, as in, this one will actually work.
Diffstat (limited to 'libdbusmenu-gtk')
-rw-r--r-- | libdbusmenu-gtk/genericmenuitem.c | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/libdbusmenu-gtk/genericmenuitem.c b/libdbusmenu-gtk/genericmenuitem.c index ee02a1c..b40a3f5 100644 --- a/libdbusmenu-gtk/genericmenuitem.c +++ b/libdbusmenu-gtk/genericmenuitem.c @@ -4,21 +4,33 @@ #include "genericmenuitem.h" +/** + GenericmenuitemPrivate: + @check_type: What type of check we have, or none at all. + @state: What the state of our check is. +*/ struct _GenericmenuitemPrivate { GenericmenuitemCheckType check_type; GenericmenuitemState state; }; +/* Private macro */ #define GENERICMENUITEM_GET_PRIVATE(o) \ (G_TYPE_INSTANCE_GET_PRIVATE ((o), GENERICMENUITEM_TYPE, GenericmenuitemPrivate)) +/* Prototypes */ static void genericmenuitem_class_init (GenericmenuitemClass *klass); static void genericmenuitem_init (Genericmenuitem *self); static void genericmenuitem_dispose (GObject *object); static void genericmenuitem_finalize (GObject *object); +static void draw_indicator (GtkCheckMenuItem *check_menu_item, GdkRectangle *area); +/* GObject stuff */ G_DEFINE_TYPE (Genericmenuitem, genericmenuitem, GTK_TYPE_CHECK_MENU_ITEM); +/* Globals */ +static void (*parent_draw_indicator) (GtkCheckMenuItem *check_menu_item, GdkRectangle *area) = NULL; + /* Initializing all of the classes. Most notably we're disabling the drawing of the check early. */ static void @@ -33,8 +45,8 @@ genericmenuitem_class_init (GenericmenuitemClass *klass) GtkCheckMenuItemClass * check_class = GTK_CHECK_MENU_ITEM_CLASS (klass); - /* We'll put this back if we get a type set */ - check_class->draw_indicator = NULL; + parent_draw_indicator = check_class->draw_indicator; + check_class->draw_indicator = draw_indicator; return; } @@ -69,3 +81,16 @@ genericmenuitem_finalize (GObject *object) G_OBJECT_CLASS (genericmenuitem_parent_class)->finalize (object); return; } + +/* Checks to see if we should be drawing a little box at + all. If we should be, let's do that, otherwise we're + going suppress the box drawing. */ +static void +draw_indicator (GtkCheckMenuItem *check_menu_item, GdkRectangle *area) +{ + Genericmenuitem * self = GENERICMENUITEM(check_menu_item); + if (self->priv->check_type != GENERICMENUITEM_CHECK_TYPE_NONE) { + parent_draw_indicator(check_menu_item, area); + } + return; +} |