diff options
-rw-r--r-- | .bzrignore | 3 | ||||
-rw-r--r-- | libdbusmenu-gtk/Makefile.am | 22 | ||||
-rw-r--r-- | libdbusmenu-gtk/genericmenuitem-enum-types.c.in | 116 | ||||
-rw-r--r-- | libdbusmenu-gtk/genericmenuitem-enum-types.h.in | 65 | ||||
-rw-r--r-- | libdbusmenu-gtk/genericmenuitem.h | 38 |
5 files changed, 231 insertions, 13 deletions
@@ -254,3 +254,6 @@ tests/test-gtk-submenu tests/test-gtk-submenu-client tests/test-gtk-submenu-server tests/test-json-01.output.json +genericmenuitem-enum-types.c +genericmenuitem-enum-types.h +libdbusmenu_gtk3_la-genericmenuitem-enum-types.lo diff --git a/libdbusmenu-gtk/Makefile.am b/libdbusmenu-gtk/Makefile.am index 9a979d7..4b3461e 100644 --- a/libdbusmenu-gtk/Makefile.am +++ b/libdbusmenu-gtk/Makefile.am @@ -1,6 +1,4 @@ -CLEANFILES = - if USE_GTK3 VER=3 GTKGIR=Gtk-3.0 @@ -13,10 +11,28 @@ GTKVALA=gtk+-2.0 lib_LTLIBRARIES = libdbusmenu-gtk.la endif +BUILT_SOURCES = +CLEANFILES = +DISTCLEANFILES = EXTRA_DIST = \ dbusmenu-gtk-0.4.pc.in \ dbusmenu-gtk3-0.4.pc.in +############## +# Enum Stuff +############## + +include $(top_srcdir)/Makefile.am.enum + +glib_enum_h = genericmenuitem-enum-types.h +glib_enum_c = genericmenuitem-enum-types.c +glib_enum_headers = $(srcdir)/genericmenuitem.h + + +##################### +# Include Directory +##################### + libdbusmenu_gtkincludedir=$(includedir)/libdbusmenu-0.4/libdbusmenu-gtk$(VER)/ libdbusmenu_gtkinclude_HEADERS = \ @@ -31,6 +47,8 @@ libdbusmenu_gtk_la_SOURCES = \ client.c \ genericmenuitem.h \ genericmenuitem.c \ + genericmenuitem-enum-types.h \ + genericmenuitem-enum-types.c \ menu.h \ menu.c \ menuitem.h \ diff --git a/libdbusmenu-gtk/genericmenuitem-enum-types.c.in b/libdbusmenu-gtk/genericmenuitem-enum-types.c.in new file mode 100644 index 0000000..8b2c046 --- /dev/null +++ b/libdbusmenu-gtk/genericmenuitem-enum-types.c.in @@ -0,0 +1,116 @@ +/*** BEGIN file-header ***/ +/* +Enums from the dbusmenu headers + +Copyright 2011 Canonical Ltd. + +Authors: + Ted Gould <ted@canonical.com> + +This program is free software: you can redistribute it and/or modify it +under the terms of either or both of the following licenses: + +1) the GNU Lesser General Public License version 3, as published by the + Free Software Foundation; and/or +2) the GNU Lesser General Public License version 2.1, as published by + the Free Software Foundation. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranties of +MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR +PURPOSE. See the applicable version of the GNU Lesser General Public +License for more details. + +You should have received a copy of both the GNU Lesser General Public +License version 3 and version 2.1 along with this program. If not, see +<http://www.gnu.org/licenses/> +*/ + +#include "genericmenuitem-enum-types.h" + +/*** END file-header ***/ + +/*** BEGIN file-production ***/ +#include "@basename@" +/*** END file-production ***/ + +/*** BEGIN value-header ***/ +/** + @enum_name@_get_type: + + Builds a GLib type for the #@EnumName@ enumeration. + + Return value: A unique #GType for the #@EnumName@ enum. +*/ +GType +@enum_name@_get_type (void) +{ + static GType etype = 0; + if (G_UNLIKELY(etype == 0)) { + static const G@Type@Value values[] = { +/*** END value-header ***/ + +/*** BEGIN value-production ***/ + { @VALUENAME@, "@VALUENAME@", "@valuenick@" }, +/*** END value-production ***/ + +/*** BEGIN value-tail ***/ + { 0, NULL, NULL} + }; + + etype = g_@type@_register_static (g_intern_static_string("@EnumName@"), values); + } + + return etype; +} + +/** + @enum_name@_get_nick: + @value: The value of @EnumName@ to get the nick of + + Looks up in the enum table for the nick of @value. + + Return value: The nick for the given value or #NULL on error +*/ +const gchar * +@enum_name@_get_nick (@EnumName@ value) +{ + GEnumClass * class = G_ENUM_CLASS(g_type_class_ref(@enum_name@_get_type())); + g_return_val_if_fail(class != NULL, NULL); + + const gchar * ret = NULL; + GEnumValue * val = g_enum_get_value(class, value); + if (val != NULL) { + ret = val->value_nick; + } + + g_type_class_unref(class); + return ret; +} + +/** + @enum_name@_get_value_from_nick: + @nick: The enum nick to lookup + + Looks up in the enum table for the value of @nick. + + Return value: The value for the given @nick +*/ +@EnumName@ +@enum_name@_get_value_from_nick (const gchar * nick) +{ + GEnumClass * class = G_ENUM_CLASS(g_type_class_ref(@enum_name@_get_type())); + g_return_val_if_fail(class != NULL, 0); + + @EnumName@ ret = 0; + GEnumValue * val = g_enum_get_value_by_nick(class, nick); + if (val != NULL) { + ret = val->value; + } + + g_type_class_unref(class); + return ret; +} + + +/*** END value-tail ***/ diff --git a/libdbusmenu-gtk/genericmenuitem-enum-types.h.in b/libdbusmenu-gtk/genericmenuitem-enum-types.h.in new file mode 100644 index 0000000..5758438 --- /dev/null +++ b/libdbusmenu-gtk/genericmenuitem-enum-types.h.in @@ -0,0 +1,65 @@ +/*** BEGIN file-header ***/ +/* +Enums from the dbusmenu headers + +Copyright 2011 Canonical Ltd. + +Authors: + Ted Gould <ted@canonical.com> + +This program is free software: you can redistribute it and/or modify it +under the terms of either or both of the following licenses: + +1) the GNU Lesser General Public License version 3, as published by the + Free Software Foundation; and/or +2) the GNU Lesser General Public License version 2.1, as published by + the Free Software Foundation. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranties of +MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR +PURPOSE. See the applicable version of the GNU Lesser General Public +License for more details. + +You should have received a copy of both the GNU Lesser General Public +License version 3 and version 2.1 along with this program. If not, see +<http://www.gnu.org/licenses/> +*/ + +#ifndef __DBUSMENU_ENUM_TYPES_H__ +#define __DBUSMENU_ENUM_TYPES_H__ + +#include <glib-object.h> + +G_BEGIN_DECLS + +/*** END file-header ***/ + +/*** BEGIN file-tail ***/ + +G_END_DECLS + +#endif /* __DBUSMENU_ENUM_TYPES_H__ */ +/*** END file-tail ***/ + +/*** BEGIN file-production ***/ +/* Enumerations from file: "@filename@" */ +#include "@basename@" + +/*** END file-production ***/ + +/*** BEGIN value-header ***/ + +GType @enum_name@_get_type (void) G_GNUC_CONST; +const gchar * @enum_name@_get_nick (@EnumName@ value) G_GNUC_CONST; +@EnumName@ @enum_name@_get_value_from_nick (const gchar * nick) G_GNUC_CONST; + +/** + DBUSMENU_TYPE_@ENUMSHORT@: + + Gets the #GType value for the type associated with the + #@EnumName@ enumerated type. +*/ +#define DBUSMENU_TYPE_@ENUMSHORT@ (@enum_name@_get_type()) + +/*** END value-header ***/ diff --git a/libdbusmenu-gtk/genericmenuitem.h b/libdbusmenu-gtk/genericmenuitem.h index 17759e3..74db2ae 100644 --- a/libdbusmenu-gtk/genericmenuitem.h +++ b/libdbusmenu-gtk/genericmenuitem.h @@ -45,9 +45,6 @@ G_BEGIN_DECLS typedef struct _Genericmenuitem Genericmenuitem; typedef struct _GenericmenuitemClass GenericmenuitemClass; typedef struct _GenericmenuitemPrivate GenericmenuitemPrivate; -typedef enum _GenericmenuitemCheckType GenericmenuitemCheckType; -typedef enum _GenericmenuitemState GenericmenuitemState; -typedef enum _GenericmenuitemDisposition GenericmenuitemDisposition; /* GenericmenuitemClass: @@ -66,24 +63,43 @@ struct _Genericmenuitem { GenericmenuitemPrivate * priv; }; -enum _GenericmenuitemCheckType { +/** + * GenericmenuitemCheckType: + * @GENERICMENUITEM_CHECK_TYPE_NONE: No check + * @GENERICMENUITEM_CHECK_TYPE_CHECKBOX: Nice little check + * @GENERICMENUITEM_CHECK_TYPE_RADIO: Radio button + */ +typedef enum { /*< prefix=GENERICMENUITEM_CHECK_TYPE >*/ GENERICMENUITEM_CHECK_TYPE_NONE, GENERICMENUITEM_CHECK_TYPE_CHECKBOX, GENERICMENUITEM_CHECK_TYPE_RADIO -}; - -enum _GenericmenuitemState { +} GenericmenuitemCheckType; + +/** + * GenericmenuitemState: + * @GENERICMENUITEM_STATE_UNCHECKED: No check visisble + * @GENERICMENUITEM_STATE_CHECKED: Check visible + * @GENERICMENUITEM_STATE_INDETERMINATE: We have no clue + */ +typedef enum { /*< prefix=GENERICMENUITEM_STATE >*/ GENERICMENUITEM_STATE_UNCHECKED, GENERICMENUITEM_STATE_CHECKED, GENERICMENUITEM_STATE_INDETERMINATE -}; - -enum _GenericmenuitemDisposition { +} GenericmenuitemState; + +/** + * GenericmenuitemDisposition: + * @GENERICMENUITEM_DISPOSITION_NORMAL: Normal state + * @GENERICMENUITEM_DISPOSITION_INFORMATIONAL: Item is informational + * @GENERICMENUITEM_DISPOSITION_WARNING: Oh, you should watch out for this one + * @GENERICMENUITEM_DISPOSITION_ALERT: Boom! + */ +typedef enum { /*< prefix=GENERICMENUITEM_DISPOSITION >*/ GENERICMENUITEM_DISPOSITION_NORMAL, GENERICMENUITEM_DISPOSITION_INFORMATIONAL, GENERICMENUITEM_DISPOSITION_WARNING, GENERICMENUITEM_DISPOSITION_ALERT -}; +} GenericmenuitemDisposition; GType genericmenuitem_get_type (void); void genericmenuitem_set_check_type (Genericmenuitem * item, |