On 27/06/10 17:32, Abderrahim Kitouni wrote:
> Hi,
> 
> 2010/6/27 Andrew <[email protected]>:
>> On 27/06/10 08:16, Andrew wrote:
>> Ignore that, I managed to do the APP_INDICATOR_TYPE correctly in the
>> vapi file, however I don't seem to have any success with the
>> APP_INDICATOR_TYPE_INDICATOR_CATEGORY.
>>
>> Attached is the vapi file, could you point me in the right direction?
> 
> in :
>       [CCode (cprefix = "APP_INDICATOR_CATEGORY_", cheader_filename =
> "libappindicator/app-indicator.h")]
>       public enum Category {
> 
> add type_id="APP_INDICATOR_TYPE_INDICATOR_CATEGORY" just like you did
> it with the class. I see no reason for it not working.
> 
> Abderrahim

Nope doesn't work, the error is:

/home/andrew/Software/Projects/wasiliana/src/indicator.vala.c: In
function ‘wapp_indicator_category_from_enum’:
/home/andrew/Software/Projects/wasiliana/src/indicator.vala.c:82: error:
‘APP_INDICATOR_TYPE_INDICATOR_CATEGORY’ undeclared (first use in this
function)
/home/andrew/Software/Projects/wasiliana/src/indicator.vala.c:82: error:
(Each undeclared identifier is reported only once
/home/andrew/Software/Projects/wasiliana/src/indicator.vala.c:82: error:
for each function it appears in.)
error: cc exited with status 256

The C and genie files are attached (if it helps)


-- 
Andrew
/* indicator.c generated by valac, the Vala compiler
 * generated from indicator.gs, do not modify */


#include <glib.h>
#include <glib-object.h>
#include <libappindicator/app-indicator.h>
#include <gtk/gtk.h>
#include <stdlib.h>
#include <string.h>


#define TYPE_WAPP_INDICATOR (wapp_indicator_get_type ())
#define WAPP_INDICATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_WAPP_INDICATOR, wAppIndicator))
#define WAPP_INDICATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_WAPP_INDICATOR, wAppIndicatorClass))
#define IS_WAPP_INDICATOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_WAPP_INDICATOR))
#define IS_WAPP_INDICATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_WAPP_INDICATOR))
#define WAPP_INDICATOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_WAPP_INDICATOR, wAppIndicatorClass))

typedef struct _wAppIndicator wAppIndicator;
typedef struct _wAppIndicatorClass wAppIndicatorClass;
typedef struct _wAppIndicatorPrivate wAppIndicatorPrivate;
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_type_class_unref0(var) ((var == NULL) ? NULL : (var = (g_type_class_unref (var), NULL)))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _wAppIndicator {
	AppIndicator parent_instance;
	wAppIndicatorPrivate * priv;
};

struct _wAppIndicatorClass {
	AppIndicatorClass parent_class;
};

struct _wAppIndicatorPrivate {
	GtkCheckMenuItem* _show_menuitem;
};


static gpointer wapp_indicator_parent_class = NULL;

GType wapp_indicator_get_type (void);
#define WAPP_INDICATOR_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_WAPP_INDICATOR, wAppIndicatorPrivate))
enum  {
	WAPP_INDICATOR_DUMMY_PROPERTY,
	WAPP_INDICATOR_SHOW_MENUITEM
};
char* wapp_indicator_category_from_enum (wAppIndicator* self, AppIndicatorCategory category);
wAppIndicator* wapp_indicator_new (const char* id, const char* icon, const char* attention_icon_name, AppIndicatorCategory category);
wAppIndicator* wapp_indicator_construct (GType object_type, const char* id, const char* icon, const char* attention_icon_name, AppIndicatorCategory category);
GtkCheckMenuItem* wapp_indicator_get_show_menuitem (wAppIndicator* self);
void wapp_indicator_set_show_menuitem (wAppIndicator* self, GtkCheckMenuItem* value);
static GObject * wapp_indicator_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties);
static void wapp_indicator_finalize (GObject* obj);
static void wapp_indicator_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec);
static void wapp_indicator_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec);



wAppIndicator* wapp_indicator_construct (GType object_type, const char* id, const char* icon, const char* attention_icon_name, AppIndicatorCategory category) {
	wAppIndicator * self;
	char* _tmp0_;
	g_return_val_if_fail (id != NULL, NULL);
	g_return_val_if_fail (icon != NULL, NULL);
	g_return_val_if_fail (attention_icon_name != NULL, NULL);
	self = (wAppIndicator*) g_object_new (object_type, "id", id, "icon-name", icon, "category", _tmp0_ = wapp_indicator_category_from_enum (self, category), NULL);
	_g_free0 (_tmp0_);
	return self;
}


wAppIndicator* wapp_indicator_new (const char* id, const char* icon, const char* attention_icon_name, AppIndicatorCategory category) {
	return wapp_indicator_construct (TYPE_WAPP_INDICATOR, id, icon, attention_icon_name, category);
}


char* wapp_indicator_category_from_enum (wAppIndicator* self, AppIndicatorCategory category) {
	char* result = NULL;
	GEnumClass* categ_class;
	g_return_val_if_fail (self != NULL, NULL);
	categ_class = (GEnumClass*) g_type_class_ref (APP_INDICATOR_TYPE_INDICATOR_CATEGORY);
	result = g_strdup (g_enum_get_value (categ_class, (gint) category)->value_nick);
	_g_type_class_unref0 (categ_class);
	return result;
}


GtkCheckMenuItem* wapp_indicator_get_show_menuitem (wAppIndicator* self) {
	GtkCheckMenuItem* result;
	g_return_val_if_fail (self != NULL, NULL);
	result = self->priv->_show_menuitem;
	return result;
}


void wapp_indicator_set_show_menuitem (wAppIndicator* self, GtkCheckMenuItem* value) {
	g_return_if_fail (self != NULL);
	self->priv->_show_menuitem = value;
	g_object_notify ((GObject *) self, "show-menuitem");
}


static GObject * wapp_indicator_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties) {
	GObject * obj;
	GObjectClass * parent_class;
	wAppIndicator * self;
	parent_class = G_OBJECT_CLASS (wapp_indicator_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = WAPP_INDICATOR (obj);
	{
		GtkMenu* menu;
		GtkCheckMenuItem* show_menuitem;
		GtkMenuItem* _tmp0_;
		GtkMenuItem* _tmp1_;
		menu = g_object_ref_sink ((GtkMenu*) gtk_menu_new ());
		show_menuitem = g_object_ref_sink ((GtkCheckMenuItem*) gtk_check_menu_item_new_with_label ("Show Wasiliana"));
		gtk_menu_shell_append ((GtkMenuShell*) menu, (GtkWidget*) ((GtkMenuItem*) show_menuitem));
		gtk_menu_shell_append ((GtkMenuShell*) menu, (GtkWidget*) (_tmp0_ = g_object_ref_sink ((GtkMenuItem*) gtk_menu_item_new_with_label ("Check for new mail"))));
		_g_object_unref0 (_tmp0_);
		gtk_menu_shell_append ((GtkMenuShell*) menu, (GtkWidget*) (_tmp1_ = g_object_ref_sink ((GtkMenuItem*) gtk_menu_item_new_with_label ("Close"))));
		_g_object_unref0 (_tmp1_);
		gtk_widget_show_all ((GtkWidget*) menu);
		app_indicator_set_menu ((AppIndicator*) self, menu);
		_g_object_unref0 (menu);
		_g_object_unref0 (show_menuitem);
	}
	return obj;
}


static void wapp_indicator_class_init (wAppIndicatorClass * klass) {
	wapp_indicator_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (wAppIndicatorPrivate));
	G_OBJECT_CLASS (klass)->get_property = wapp_indicator_get_property;
	G_OBJECT_CLASS (klass)->set_property = wapp_indicator_set_property;
	G_OBJECT_CLASS (klass)->constructor = wapp_indicator_constructor;
	G_OBJECT_CLASS (klass)->finalize = wapp_indicator_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), WAPP_INDICATOR_SHOW_MENUITEM, g_param_spec_object ("show-menuitem", "show-menuitem", "show-menuitem", GTK_TYPE_CHECK_MENU_ITEM, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
}


static void wapp_indicator_instance_init (wAppIndicator * self) {
	self->priv = WAPP_INDICATOR_GET_PRIVATE (self);
}


static void wapp_indicator_finalize (GObject* obj) {
	wAppIndicator * self;
	self = WAPP_INDICATOR (obj);
	G_OBJECT_CLASS (wapp_indicator_parent_class)->finalize (obj);
}


GType wapp_indicator_get_type (void) {
	static volatile gsize wapp_indicator_type_id__volatile = 0;
	if (g_once_init_enter (&wapp_indicator_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (wAppIndicatorClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) wapp_indicator_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (wAppIndicator), 0, (GInstanceInitFunc) wapp_indicator_instance_init, NULL };
		GType wapp_indicator_type_id;
		wapp_indicator_type_id = g_type_register_static (APP_INDICATOR_TYPE, "wAppIndicator", &g_define_type_info, 0);
		g_once_init_leave (&wapp_indicator_type_id__volatile, wapp_indicator_type_id);
	}
	return wapp_indicator_type_id__volatile;
}


static void wapp_indicator_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
	wAppIndicator * self;
	self = WAPP_INDICATOR (object);
	switch (property_id) {
		case WAPP_INDICATOR_SHOW_MENUITEM:
		g_value_set_object (value, wapp_indicator_get_show_menuitem (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}


static void wapp_indicator_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) {
	wAppIndicator * self;
	self = WAPP_INDICATOR (object);
	switch (property_id) {
		case WAPP_INDICATOR_SHOW_MENUITEM:
		wapp_indicator_set_show_menuitem (self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}




[indent=4]

uses
    AppIndicator
    Gtk
    Gee

class wAppIndicator : Indicator

    prop show_menuitem : CheckMenuItem
    
    construct (id:string, icon:string, attention_icon_name:string, 
category:AppIndicator.Category)
        GLib.Object(id:id, icon_name:icon, 
category:category_from_enum(category))
        
    def category_from_enum (category: AppIndicator.Category): string
        var categ_class = (EnumClass) typeof(AppIndicator.Category).class_ref()
        return categ_class.get_value(category).value_nick

    init
        var menu = new Menu()
        var show_menuitem = new CheckMenuItem.with_label("Show Wasiliana")
        menu.append(show_menuitem)
        menu.append(new MenuItem.with_label("Check for new mail"))
        menu.append(new MenuItem.with_label("Close"))
        menu.show_all()
        this.set_menu(menu)
    

    
_______________________________________________
vala-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/vala-list

Reply via email to