Frustration with GtkActions



I am running into incredible frustration (as a GTK newbie)
trying to use GtkAction's. This is in Redhat Linux, using
GTK 2.4.13. The application is meant to be portable to
Windows XP (where it will be compiled with GTK 2.6).

For administrative reasons, Linux/GTK 2.4 is fixed as our development
environment. If this is a 2.4 bug that is addressed in 2.6,
that would be more or less OK for the time being, but I'd
prefer a workaround if possible.

We have an application layout created with Glade, so there
are a bunch of toolbar icons and menu items predefined with
labels, icons, etc. I am trying to define actions and
attach them to menuitem/toolbar icon pairs so that they can
be manipulated (made sensitive or not) together.

This works great for stock menuitems with stock icons. Not
so great with most of our menuitems, which use stock icons
but non-standard labels. I have two choices when I call
gtk_action_new followed by gtk_action_connect_proxy:

   1. Use a NULL stock_id argument. GTK complains with the
following errors:
  Gtk-CRITICAL **: file gtkstock.c: line 145 (gtk_stock_lookup):
assertion `stock_id != NULL'failed

  Gtk-CRITICAL **: file gtklabel.c: line 1018 (gtk_label_set_label):
assertion `str != NULL' failed

   and the icon that was there gets deleted from my menuitem.

or

   2. Use a non-NULL stock_id argument, and then my
*label* gets deleted from my menuitem and replaced with the
stock label.

I'm guessing that there must be some low-level way
to attach the proxy while preserving existing image and
label, but I haven't figured it out yet. I tried this:
    icon = gtk_image_menu_item_get_image( btn );
    gtk_action_connect_proxy( action, btn );
    if (!stock_id)
      gtk_image_menu_item_set_image( btn, icon );

but that did not succeed in restoring the icon, i.e.,
I get a menuitem with no icon.

Any suggestions?


-- 
Randall Poe (rpoe atl lmco com)
Senior Member Engineering Staff
Lockheed Martin Advanced Technology Laboratory
Sixth Floor, 3 Executive Campus
Cherry Hill, NJ 08002
Phone: (856)792-9894
Fax: (856)792-9930




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