Re: how to remove the tear-off line in a menu (context-menu) in gtk1



Am Don, 2002-05-30 um 14.43 schrieb Joergen Scheibengruber:
Hi!

I have a little problem: What I have is a GtkClist with a contextmenu
created by libglade. I show the context_menu with gtk_menu_popup(), and
unfortunatly it has a tear-off line. (I don't think a context-menu
should have one). So my question is how to get rid of it. I did not find
anything in the properties of the menu in glade and there doesn't seem
to be a function in the gtk_menu doc either.

In case someone has the same problem, I'll post my solution here. It's a
little hack, but I think the only solution. However I think there should
be an option in glade, which allows you to specify if a menu has a
tearoff-item or not.
 
static void
context_menu_remove_tearoff(void)
{
    GtkWidget *context_menu;
    GList *tearoff, *children;

    context_menu = glade_xml_get_widget(MYPROJECT, "context_menu");
    g_assert(context_menu);
    children = GTK_MENU_SHELL(context_menu)->children;
    g_assert(children);
    tearoff = g_list_first(children);
    g_assert(GTK_IS_TEAROFF_MENU_ITEM(tearoff->data));
    
    /* I hide the tearoff-item instead of destroying
     * it, thats more simple
     */
    gtk_widget_hide(tearoff->data);
}

Jörgen




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