Can't connect control to activate signal
- From: Matthew J Hicks <mhicks us ibm com>
- To: gnome-components-list gnome org
- Subject: Can't connect control to activate signal
- Date: Mon, 13 Oct 2003 09:06:24 -0400
I have been trying to create a control with a menu structure that will
merge into my container's menu (and hopefully Nautilus's menu) with no
luck. So far, I have been able to create a very simple container (source
not included to keep the email shorter) that can merge controls with menus
such as the GNOME_EOG_Control. I have also created my own
GNOME_Test_Control but unfortunately, it's menu does not merge with my
container's menus. The widget label is displayed in the container - only
the menu merging doesn't take place. I have looked through the
documentation, but haven't found any simple examples of menu merging.
I think that the problem is that my activate callback is not being called.
I put some debug statements in the libbonoboui package and the "activate"
signal is being emitted, but just not received in my control. I have tried
the gtk_signal_connect and the g_signal_connect methods, but neither appear
to work. If someone could help me out, I would really appreciate it.
Thanks
My UI File (/usr/share/gnome-2.0/ui/test-ui.xml):
**************************************************
<Root>
<commands>
<cmd name="Test" label="_Test" />
</commands>
<menu>
<submenu name="File">
<placeholder name="File Items Placeholder">
<menuitem name="Test" />
</placeholder>
</submenu>
</menu>
</Root>
****************************************************
My .server File
(/usr/lib/bonobo/servers/GNOME_Test_Control.server)
*******************************************************************
<oaf_info>
<oaf_server iid="OAFIID:GNOME_Test_ControlFactory"
type="exe"
location="/home/mjh/workspace/Bonobo/test-control-factory">
<oaf_attribute name="repo_ids" type="stringv">
<item value="IDL:Bonobo/GenericFactory:1.0"/>
</oaf_attribute>
<oaf_attribute name="name" type="string" value="Test
control factory"/>
<oaf_attribute name="description" type="string"
value="Factory for my test control "/>
</oaf_server>
<oaf_server iid="OAFIID:GNOME_Test_Control"
type="factory"
location="OAFIID:GNOME_Test_ControlFactory">
<oaf_attribute name="repo_ids" type="stringv">
<item value="IDL:Bonobo/Unknown:1.0"/>
<item value="IDL:Bonobo/Control:1.0"/>
</oaf_attribute>
<oaf_attribute name="name" type="string" value="a
basic entry control"/>
<oaf_attribute name="description" type="string"
value="A sample bonobo control wrapping a Gtk Entry
widget."/>
</oaf_server>
</oaf_info>
*********************************************************************
Below is my control class. I used the
bonobo-sample-controls.c and the menu merging
explanations at
http://developer.gnome.org/doc/API/2.0/libbonoboui/libbonoboui-bonobo-ui-component.html#id2899316
****************************************************
#include <config.h>
#include <string.h>
#include <libbonoboui.h>
#include <libgnomecanvas/gnome-canvas-widget.h>
#define UI_XML "test-ui.xml"
static void
verb_test_cb (BonoboUIComponent *ui_container,
gpointer user_data,
const char *cname) {
BonoboControl *control = user_data;
g_print ("Test Successful !\n");
}
static BonoboUIVerb my_ui_verbs[] = {
BONOBO_UI_VERB ("Test", verb_test_cb),
BONOBO_UI_VERB_END
};
static void
control_activate_cb (BonoboControl *control,
gboolean state,
gpointer user_data) {
BonoboUIComponent *ui_component;
/* Get UIComponent from control */
ui_component = bonobo_control_get_ui_component(control);
if (state) /* Activate */
{
/*
* Use a helper function to setup your UI from a file:
*/
bonobo_ui_util_set_ui (ui_component, "", UI_XML, "Test_Control",
NULL);
}
else /* De-activate */
{
bonobo_ui_component_unset_container(ui_component, NULL);
}
}
BonoboObject *
test_control_new (void) {
BonoboControl *control;
BonoboUIComponent *ui_component;
Bonobo_UIContainer ui_container;
GtkWidget *widget;
control = bonobo_control_new ((widget = gtk_label_new ("My Test
Control")));
/* Automatically associate the remote UIContainer for us on activate */
bonobo_control_set_automerge (control, TRUE);
ui_component = bonobo_control_get_ui_component (control);
/* Register the verbs with the UI Component */
bonobo_ui_component_add_verb_list_with_data (
ui_component, my_ui_verbs, control);
gtk_signal_connect (GTK_OBJECT (control), "activate", GTK_SIGNAL_FUNC
(control_activate_cb), NULL);
gtk_widget_show (widget);
return BONOBO_OBJECT (control);
}
static BonoboObject *
control_factory (BonoboGenericFactory *this,
const char *object_id,
void *data) {
BonoboObject *object = NULL;
g_return_val_if_fail (object_id != NULL, NULL);
if (!strcmp (object_id,"OAFIID:GNOME_Test_Control"))
object = test_control_new ();
return object;
}
int
main (int argc, char *argv []) {
int retval;
if (!bonobo_ui_init ("Test_Control",
VERSION, &argc, argv))
g_error (_("Could not initialize Bonobo UI"));
retval = bonobo_generic_factory_main
("OAFIID:GNOME_Test_ControlFactory",
control_factory, NULL);
return retval;
}
***************************************************************
Thanks in advance
-Matt
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]