Re: Help with retreiving children?



    Deborah> Could you give examples of the use of those functions?

Sure.  Below is a short routine that gives a few examples.  There are some
things I haven't quite figured out how to do without knowing the internals of
the GtkArg structure (i.e. set callbacks).

BTW, the only problem with this approach is that you have to know the names of
the arguments a widget has that can be retrieved or set.  It isn't clear how
well known these names are with the standard widget set.  In Xt, these names
are usually the core of the widget documentation.

static unsigned short array_of_stuff[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};

void
examples(GtkWidget *w)
{
    GtkArg one_arg;
    GtkArg args[2];

    /*
     * gtk_widget_setv() example.
     */
    args[0].name = "orientation";
    GTK_VALUE_ENUM(args[0]) = GTK_ORIENTATION_HORIZONTAL;

    args[1].name = "some_useful_data";
    GTK_VALUE_POINTER(args[1]) = array_of_stuff;

    gtk_widget_setv(w, 2, args);

    /*
     * gtk_widget_set() example.
     */
    gtk_widget_set(w,
                   "orientation", GTK_ORIENTATION_HORIZONTAL,
                   "some_useful_data", array_of_stuff,
                   0);

    /*
     * gtk_widget_get() example.
     */

    one_arg.name = "some_useful_data";
    gtk_widget_get(w, &one_arg);
    if (GTK_VALUE_ENUM(one_arg) == GTK_ORIENTATION_VERTICAL)
      printf("VERTICAL\n");
    else
      printf("HORIZONTAL\n");

    /*
     * gtk_widget_getv() example.
     */
    args[0].name = "some_useful_data";
    args[1].name = "orientation";
    gtk_widget_getv(w, 2, args);
}
-----------------------------------------------------------------------------
Mark Leisher
Computing Research Lab            Once you fully apprehend the vacuity of a
New Mexico State University       life without struggle, you are equipped
Box 30001, Dept. 3CRL             with the basic means of salvation.
Las Cruces, NM  88003                            -- Tennessee Williams





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]