[gtkada] Underlined menu shortcuts
Larry Elmore
ljelmore at home.com
Fri May 25 07:23:13 CEST 2001
Larry Elmore wrote:
>
> I've got the underlined keyboard accelerators to work, but I still can't
> get underlined letters to display in the menus.
>
> Here's the C code generated by glade for the first menu item:
>
> kon_tiki1 = gtk_menu_item_new_with_label ("");
> tmp_key = gtk_label_parse_uline (GTK_LABEL (GTK_BIN
> (kon_tiki1)->child),
> _("_KonTiki"));
> gtk_widget_add_accelerator (kon_tiki1, "activate_item", accel_group,
> tmp_key, GDK_MOD1_MASK, (GtkAccelFlags)
> 0);
> gtk_widget_ref (kon_tiki1);
> gtk_object_set_data_full (GTK_OBJECT (window1), "kon_tiki1",
> kon_tiki1,
> (GtkDestroyNotify) gtk_widget_unref);
> gtk_widget_show (kon_tiki1);
> gtk_container_add (GTK_CONTAINER (menubar1), kon_tiki1);
>
> Here's the hand-modified Ada code generated by Glade:
>
> Gtk_New (Window1.Kon_Tiki1); -- Originally: Gtk_New
> (Window1.Kon_Tiki1, "_KonTiki");
> Set_Right_Justify (Window1.Kon_Tiki1, False);
> Parse_Uline (Gtk_Label (Gtk_Widget (Window1.Kon_Tiki1)),
> "_KonTiki"); -- This line added
> Gtk_New (The_Accel_Group);
> Add_Accel_Group (Window1, The_Accel_Group);
> Add_Accelerator (Window1.Kon_Tiki1, "activate_item",
> The_Accel_Group, GDK_K, Gdk.Types.Mod1_Mask, Accel_Visible);
> Add (Window1.Menubar1, Window1.Kon_Tiki1);
>
> This code compiles fine, but when run gives:
>
> raised STORAGE_ERROR : stack overflow (or erroneous memory access)
>
> It's definitely the Parse_Uline() that causes the crash -- take it out
> and it runs fine, but the menu has "_KonTiki" displayed.
>
> Does anyone have any ideas on what I'm doing wrong here? I'm about to
> give up on getting this feature to work at all...
I feel a little stupid looking at this tonight with a less tired brain.
Obviously, in the Parse_Uline(), what I want is not the menu item
itself, but its child, the label. What is not obvious, in GtkAda, is how
in the world I get that pointer. I've been around and around the GtkAda
reference manual, user guide, and source code trying to figure this
thing out. The only possibility I've found is in the package Gtk, either
function Get_Object (Object : access Root_Type'Class) return
System.Address;
or
function Get_User_Data (Obj : in System.Address; Stub : in
Root_Type'Class) return Root_Type_Access;
I can't get the compiler to accept either one (type errors) with any
arguments that seem reasonable.
What in the world is the GtkAda equivalent to C's "GTK_LABEL (GTK_BIN
(kon_tiki1)->child)"???
Larry
More information about the gtkada
mailing list