![]() |
![]() |
![]() |
Libmatecomponent Reference Manual | ![]() |
---|---|---|---|---|
Top | Description | Object Hierarchy |
struct MateComponentItemHandler; MateComponentItemHandlerClass; MateComponentItemHandler * matecomponent_item_handler_new (MateComponentItemHandlerEnumObjectsFn enum_objects
,MateComponentItemHandlerGetObjectFn get_object
,gpointer user_data
); MateComponentItemHandler * matecomponent_item_handler_new_closure (GClosure *enum_objects
,GClosure *get_object
); MateComponentItemHandler * matecomponent_item_handler_construct (MateComponentItemHandler *handler
,GClosure *enum_objects
,GClosure *get_object
); MateComponentItemOption; GSList * matecomponent_item_option_parse (const char *option_string
); void matecomponent_item_options_free (GSList *options
);
Sometimes you want to pass "arguments" to a component. Consider the component with the following OAFIID:
OAFIID:MATE_FileSelector
You might want to be able to set configuration options from its moniker name, without having to ever use the property bag API. For example:
OAFIID:MATE_FileSelector!AcceptMimeTypes=image/*
Create a MateComponentItemHandler. This component will let you do argument parsing of any kind.
You have to provide two functions: enumObjects
(this can be empty) and getObject
.
The getObject function will be called when the moniker mechanism is trying to resolve a set of arguments to your function.
Like this:
1 2 3 4 5 6 7 8 9 10 11 12 |
MateComponent_Unknown getObject (MateComponentItemHandler *h, const char *item_name, gboolean only_if_exists, gpointer data, CORBA_Environment *ev) { MyData *m = data; if (strcmp (item_name, "friendly") == 0){ m->friendly = true; } /* we just return ourselves */ return matecomponent_object_dup_ref (matecomponent_object_corba_objref (h), NULL); } |
So basically during the `getObject' operation you will be given a chance to process the `item_name' string which is basically like a command line argument (for the sake of explaining this) and based on this information you can customize your component.
Sometimes you will want to specify a bunch of options to configure your component, like this:
OAFIID:MyComponent!visible=true;image=blah.png
So we are separating the various options with semi-colons here. To simplify your code, we have provided a couple of functions that given the following string:
visible=true;image=blah.png
Will return a GList split with MateComponentItemOptions:
1 2 3 4 5 6 7 |
GSList *l, *x; x = matecomponent_item_option_parse ("visible=true;image=blah.png"); for (l = x; l != NULL; l++){ MateComponentItemOption *io = l->data; printf ("Key=%s, Value=%s\n", io->key, io->value); } matecomponent_item_option_free (x); |
struct MateComponentItemHandler;
MateComponent::ItemHandler implementation
typedef struct { MateComponentObjectClass parent_class; POA_MateComponent_ItemContainer__epv epv; } MateComponentItemHandlerClass;
MateComponentItemHandler class
MateComponentItemHandler * matecomponent_item_handler_new (MateComponentItemHandlerEnumObjectsFn enum_objects
,MateComponentItemHandlerGetObjectFn get_object
,gpointer user_data
);
Creates a new MateComponentItemHandler object. These are used to hold client sites.
|
callback invoked for MateComponent::ItemContainer::enum_objects |
|
callback invoked for MateComponent::ItemContainer::get_objects |
|
extra data passed on the callbacks |
Returns : |
The newly created MateComponentItemHandler object |
MateComponentItemHandler * matecomponent_item_handler_new_closure (GClosure *enum_objects
,GClosure *get_object
);
Creates a new MateComponentItemHandler object. These are used to hold client sites.
|
closure invoked for MateComponent::ItemContainer::enum_objects |
|
closure invoked for MateComponent::ItemContainer::get_objects |
Returns : |
The newly created MateComponentItemHandler object |
MateComponentItemHandler * matecomponent_item_handler_construct (MateComponentItemHandler *handler
,GClosure *enum_objects
,GClosure *get_object
);
Constructs the container
MateComponentObject using the provided closures
for the actual implementation.
|
The handler object to construct |
|
The closure implementing enumObjects |
|
The closure implementing getObject |
Returns : |
The constructed MateComponentItemContainer object. |
typedef struct { char *key; char *value; } MateComponentItemOption;
A key-value pair.
GSList * matecomponent_item_option_parse (const char *option_string
);
void matecomponent_item_options_free (GSList *options
);
Use this to release a list returned by matecomponent_item_option_parse()
|
a GSList of MateComponentItemOption structures that was returned by matecomponent_item_option_parse()
|