Bag Listener Test Patch
- From: Mike Kestner <mkestner enteract com>
- To: gnome-components-list gnome org
- Subject: Bag Listener Test Patch
- Date: Mon, 18 Sep 2000 09:31:13 -0500
I'm attaching a patch to the sample-control-container that fixes a
couple of UIH compat bugs and adds some listener sample code for
PropertyBag listeners.
It adds a button that pauses and resumes the clock control and a
listener on the clock's "running" property that updates it's status in
the CList.
Let me know if I can commit.
Mike
Index: samples/controls/sample-control-container.c
===================================================================
RCS file: /cvs/gnome/bonobo/samples/controls/sample-control-container.c,v
retrieving revision 1.22
diff -u -r1.22 sample-control-container.c
--- samples/controls/sample-control-container.c 2000/09/11 11:46:41 1.22
+++ samples/controls/sample-control-container.c 2000/09/18 14:31:30
@@ -11,13 +11,46 @@
#include <gnome.h>
#include <liboaf/liboaf.h>
#include <bonobo.h>
+#include <bonobo-listener.h>
+#include <Bonobo.h>
Bonobo_PropertyBag pb = CORBA_OBJECT_NIL;
static void
+prop_changed (BonoboListener *listener, BonoboArg *arg, GtkCList *clist)
+{
+ gchar *value;
+
+ value = g_strdup_printf ("%s", BONOBO_ARG_GET_BOOLEAN (arg) ? "TRUE" :"FALSE");
+
+ gtk_clist_set_text (clist, 0, 1, value);
+
+ g_free (value);
+}
+
+static void
populate_property_list (GtkWidget *bw, GtkCList *clist)
{
GList *property_list, *l;
+ BonoboListener *listener;
+ Bonobo_Listener corba_listener;
+ CORBA_Environment ev;
+
+ free (malloc (8));
+ /* Set up the change listener */
+ listener = bonobo_listener_new ();
+ gtk_signal_connect (GTK_OBJECT (listener), "event_notify",
+ GTK_SIGNAL_FUNC (prop_changed), clist);
+
+ CORBA_exception_init (&ev);
+
+ corba_listener = bonobo_object_corba_objref (BONOBO_OBJECT (listener));
+
+ Bonobo_PropertyBag_add_change_listener (pb, "running", corba_listener, &ev);
+ if (ev._major != CORBA_NO_EXCEPTION) {
+ g_warning ("Listener exception: %s\n", ev._repo_id);
+ }
+ CORBA_exception_free (&ev);
property_list = bonobo_property_bag_client_get_property_names (pb, NULL);
@@ -131,6 +164,16 @@
}
static void
+toggle_clock (GtkButton *button, BonoboWidget *control)
+{
+ CORBA_boolean state;
+
+ bonobo_widget_get_property (control, "running", &state, NULL);
+
+ bonobo_widget_set_property (control, "running", !state, NULL);
+}
+
+static void
app_destroy_cb (GtkWidget *app, BonoboUIHandler *uih)
{
bonobo_object_unref (BONOBO_OBJECT (uih));
@@ -156,6 +199,7 @@
GtkWidget *proplist;
GtkWidget *box;
GtkWidget *button;
+ GtkWidget *clock_button;
BonoboUIHandler *uih;
BonoboControlFrame *cf;
GtkWindow *window;
@@ -186,7 +230,7 @@
control = bonobo_widget_new_control (
"OAFIID:bonobo_calculator:fab8c2a7-9576-437c-aa3a-a8617408970f",
- bonobo_object_corba_objref (BONOBO_OBJECT (uih)));
+ bonobo_ui_compat_get_container (uih));
gtk_box_pack_start (GTK_BOX (box), control, TRUE, TRUE, 0);
@@ -196,10 +240,16 @@
control = bonobo_widget_new_control (
"OAFIID:bonobo_clock:d42cc651-44ae-4f69-a10d-a0b6b2cc6ecc",
- bonobo_object_corba_objref (BONOBO_OBJECT (uih)));
+ bonobo_ui_compat_get_container (uih));
gtk_box_pack_start (GTK_BOX (box), control, TRUE, TRUE, 0);
+ clock_button = gtk_button_new_with_label ("Pause/Resume Clock");
+ gtk_signal_connect (GTK_OBJECT (clock_button), "clicked",
+ (GtkSignalFunc)toggle_clock, control);
+
+ gtk_box_pack_start (GTK_BOX (box), clock_button, TRUE, TRUE, 0);
+
cf = bonobo_widget_get_control_frame (BONOBO_WIDGET (control));
pb = bonobo_control_frame_get_control_property_bag (cf, NULL);
@@ -207,7 +257,7 @@
control = bonobo_widget_new_control (
"OAFIID:bonobo_entry_factory:ef3e3c33-43e2-4f7c-9ca9-9479104608d6",
- bonobo_object_corba_objref (BONOBO_OBJECT (uih)));
+ bonobo_ui_compat_get_container (uih));
gtk_box_pack_start (GTK_BOX (box), control, TRUE, TRUE, 0);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]