We've got our own host/gadget container which uses GGL to display
gadgets. It's a desktop type application which supports various
plugins, one of which is a GGL gadget container.
Desktop --> another_plugin
| \
V V
plugin gadget_plugin
|
V
some gadgets
There can be multiple gadgets per gadget_plugin and there can be
multiple gadget_plugins.
The problem we have is that we'd like the gadgets to be able to notify
the underlying desktop of changes in state to that it can make the
desktop behave differently under certain circumstances. For instance,
if the gadget is focused in option mode, we might want to make several
soft-keys change their appearance/function.
We've got a couple ideas so we were hoping someone might give some
guidance for the best way to accomplish this.
The first thought was to just use DBUS to let the gadget tell the
parent its status.
Problems:
- Identification. Each gadget needs to be uniquely identifiable so
that the dbus message will know which gadget we're talking about.
- DBus receiver. Who gets the dbus message? The gadget_plugin or the
desktop? Since there are potentially multiple gadget_plugins, it
might make more sense for the desktop to get the message but then we
have to pass it on to each plugin. Alternatively we could do a dbus
signal and then each the gadget_plugins can decide if they're
interested or not. Can the GGL dbus extension do a signal?
The next idea was to write an extension. I had the thought that we
could make something like a 'parent' object that the gadget could use
through javascript. Something like 'parent.tellState("grumpy")'.
This feels like a cleaner solution but I have a few questions about
whether it's practical.
Questions:
- Context. Does the gadget plugin have a way to know which gadget the
call comes from or do we still have the identification issue?
- Implementation. I really don't know quite where to start. Most of
the extensions seem to be self contained. I think this one would have
to expose some API on the C++ side. I imagine that when gadget_plugin
is instantiating gadgets, it would have to do something like pass a
callback handle into the extension for notifications.
Sorry the post is so long. Can anyone give me some ideas?
cheers,
Kris
--
You received this message because you are subscribed to the Google Groups "google-gadgets-for-linux-user" group.
To post to this group, send email to google-gadgets...@googlegroups.com.
To unsubscribe from this group, send email to google-gadgets-for-l...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-gadgets-for-linux-user?hl=en.
cheers,
Kris
On Jan 8, 12:59 am, James Su <james...@gmail.com> wrote:
> I think the extension approach would be feasible. You may create an
> extension and add a special object to the
> framework<http://code.google.com/apis/desktop/docs/gadget_apiref.html#framework>namespace.
> Just similar than framework.runtime or framework.audio.
> A framework extension will be loaded into each individual gadget, and a
> pointer to the Gadget object will be passed into the extension upon
> initialization. You can use that pointer to identify the gadget when your
> special object gets called.
> You may refer to
> extensions/default_framework/default_framework.cc<http://code.google.com/p/google-gadgets-for-linux/source/browse/trunk...>
> to
> see how to implement a framework extension and how to hook special objects
> or methods to the framework namespace.
>
> Regards
> James Su
>
> 2010/1/8 kewarken <kewar...@gmail.com>
> > google-gadgets-for-l...@googlegroups.com<google-gadgets-for-linux-user%2Bunsu...@googlegroups.com>
I was successful in creating the new object so from javascript I can
do:
framework.parent.tellState("test");
and the ggl-gtk host prints out:
got state: test
from the C++ code. The next question is how do I cause this to
actually do something in the host? Ideally I'd like to be able to
have the ggl extension call out to some function in our host code.
I looked at the Perfmon class and it seems to support something like
this but I'm not sure how you actually do it. I kind of imagined
something like:
PerfmonInterface *pmi = some_ggl_object.getExtension("Perfmon");
pmi.AddCounter("some_path", NewSlot(some_callback))
But I don't know how to do the first part.
The next question is header related. It doesn't seem like extensions
install their own headers. Does that mean I need to modify one of the
global headers like framework_interface.h or perhaps put my own into
the ggadget directory? I was kind of hoping to have the extension
completely self contained rather than having to modify common code.
cheers,
Kris
On Jan 8, 12:59 am, James Su <james...@gmail.com> wrote:
> I think the extension approach would be feasible. You may create an
> extension and add a special object to the
> framework<http://code.google.com/apis/desktop/docs/gadget_apiref.html#framework>namespace.
> Just similar than framework.runtime or framework.audio.
> A framework extension will be loaded into each individual gadget, and a
> pointer to the Gadget object will be passed into the extension upon
> initialization. You can use that pointer to identify the gadget when your
> special object gets called.
> You may refer to
> extensions/default_framework/default_framework.cc<http://code.google.com/p/google-gadgets-for-linux/source/browse/trunk...>
> to
> see how to implement a framework extension and how to hook special objects
> or methods to the framework namespace.
>
> Regards
> James Su
>
> 2010/1/8 kewarken <kewar...@gmail.com>
> > google-gadgets-for-l...@googlegroups.com<google-gadgets-for-linux-user%2Bunsu...@googlegroups.com>
To unsubscribe from this group, send email to google-gadgets-for-l...@googlegroups.com.
1. You can add a special global function in your extension, such as:void RegisterHostCallback(CallbackInterface* callback);The CallbackInterface is an interface class provided by your host.Then in your host, implement a special extension register (derived from ExtensionRegisterInterface) to find and call this symbol from the extension. Then calling ExtensionManager::RegisterLoadedExtensions() with this special extension register as soon as your extension is loaded. Then your extension can communicate with your host through the callback.