Esempio n. 1
0
/**
 * peacock_file_control_add_property_bag:
 * @control: 
 * @widget: 
 * 
 * Map the GObject's properties to a BonoboPropertyBag for our BonoboObject.
 **/
static void
peacock_file_control_add_property_bag (BonoboControl *control,
				       GtkWidget *widget)
{
	BonoboPropertyBag *pb;
	GParamSpec **pspecs;
	guint	     n_props;

	pb = bonobo_property_bag_new (peacock_file_control_get_prop,
				      peacock_file_control_set_prop,
				      (gpointer) control);
	bonobo_control_set_properties (control, BONOBO_OBJREF (pb), NULL);
	bonobo_object_unref (BONOBO_OBJECT (pb));

	pspecs = g_object_class_list_properties (G_OBJECT_GET_CLASS (widget),
						 &n_props);
	bonobo_property_bag_map_params (pb, G_OBJECT (widget),
					(const GParamSpec **) pspecs, n_props);
	g_free (pspecs);

	return;
}
Esempio n. 2
0
BonoboObject *
circle_control_new (CommonData *com)
{
        BonoboPropertyBag  *pb;
        BonoboControl      *control;
        GParamSpec        **pspecs;
        guint               n_pspecs;
        GtkWidget *button, *frame, *spin, *hbox, *spin_label;
        GtkObject *adj;
        GSList **list = &com->list;
        GSList *li;
        ObjectData *object = NULL;

        frame = gtk_frame_new("Circle");
        hbox = gtk_hbox_new(FALSE, 2);
        gtk_container_add(GTK_CONTAINER(frame), hbox);
        button = gtk_button_new();
        gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
        spin_label = gtk_label_new ("Speed:");
        gtk_box_pack_start (GTK_BOX (hbox), spin_label, FALSE, FALSE, 0);
        adj = gtk_adjustment_new(100.0, 0.0, 1000.0, 1.0, 10.0, 0.0);
        g_signal_connect(adj, "value_changed", G_CALLBACK(set_speed), com);
        spin = gtk_spin_button_new(GTK_ADJUSTMENT(adj), 0.0, 0);
        gtk_box_pack_start (GTK_BOX (hbox), spin, FALSE, FALSE, 0);

        gtk_widget_show_all(frame);
        control = bonobo_control_new (frame);

        pb = bonobo_property_bag_new (NULL, NULL, NULL);
        bonobo_control_set_properties (control, BONOBO_OBJREF (pb), NULL);
        bonobo_object_unref (BONOBO_OBJECT (pb));

        g_signal_connect(button, "clicked", G_CALLBACK(on_press), com);

        pspecs = g_object_class_list_properties (
                G_OBJECT_GET_CLASS (button), &n_pspecs);

        bonobo_property_bag_map_params (
                pb, G_OBJECT (button), (const GParamSpec **)pspecs, n_pspecs);

        g_free (pspecs);

        bonobo_control_life_instrument (control);

        li = g_slist_last(*list);
        if (li)
        {
               object = li->data;
        }
        if (!object || object->button)
        {
                object = g_new0(ObjectData, 1);
                *list = g_slist_append(*list, object);
        }

        object->button = button;
        object->adj = GTK_ADJUSTMENT(adj);

        update_button(object, com);
        set_speed(GTK_ADJUSTMENT(adj), com);

        return BONOBO_OBJECT (control);
}