Re: Getting widgets object data from its parent.



Rick Stewart wrote:

        One thing I've been attempting to do is get a widget by knowing its
parent.  I'll give you a c example;

GtkWidget*
lookup_widget                          (GtkWidget       *widget,
                                        const gchar     *widget_name)
{
  GtkWidget *parent, *found_widget;

  for (;;)
    {
      if (GTK_IS_MENU (widget))
        parent = gtk_menu_get_attach_widget (GTK_MENU (widget));
      else
        parent = widget->parent;
      if (parent == NULL)
        break;
      widget = parent;
    }

  found_widget = (GtkWidget*) gtk_object_get_data (GTK_OBJECT (widget),
                                                   widget_name);
  if (!found_widget)
    g_warning ("Widget not found: %s", widget_name);
  return found_widget;
}

This goodie when given the parent widget and the name of the child one is
looking for, it returns a GtkWidget.  How can I acomplish this in perl?

gtk_object_get_data isnt avaible in Gtk-Perl.  Any Ideas?

Well it may be avaiable soon. I have a trivial patch that expose set_data and
get_data from perl. But lupus pointed out that it is sligthly too trivial. So
maybe tomorrow.

However, in this case just using get_name should work just fine (as far as I
can tell).

./borup





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