Re: Menu bar items without icon indent

On Wed, 2008-12-31 at 13:13 +0000, Peter Clifton wrote:
> On Mon, 2008-12-29 at 22:56 -0500, Yu Feng wrote:
> > I've just written a similar widget.
> > 
> > You should subclass GtkMenuItem,
> > override toggle_size_request, return zero to the *requistion parameter.
> > 
> > implement the creation methed
> > new_with_label(),
> > put a GtkLabel as the child of the bin in the creation method.
> > 
> > You may also need to override size_allocate and size_request method.
> Thanks!
> I've been away, but I will try to see if there is any interest in
> getting additional flexibility in the stock GtkMenuItems, along the
> lines of Tristan Van Berkom's suggestion.

An example I discovered of hacking around this problem in the wild is
seen in gnome-settings-daemon's Xrandr settings dialog:

It attaches a signal handler to the size allocate signal, resets the
toggle size, then does a dance to ensure its changes aren't ignored:

750   gtk_menu_item_toggle_size_allocate (GTK_MENU_ITEM (widget), 0);
752   g_signal_handlers_block_by_func (widget, title_item_size_allocate_cb, NULL);
754   /* Sigh. There is no way to turn on GTK_ALLOC_NEEDED outside of GTK+
755   * itself; also, since calling size_allocate on a widget with the same
756   * allcation is a no-op, we need to allocate with a "different" size
757   * first.
758   */
760   allocation->width++;
761   gtk_widget_size_allocate (widget, allocation);
763   allocation->width--;
764   gtk_widget_size_allocate (widget, allocation);
766   g_signal_handlers_unblock_by_func (widget, title_item_size_allocate_cb, NULL);

There is a comment in the above file regarding why they want this same
behaviour that I did, along the lines:

We want the "title" menu items for each RANDR output to span the *whole*
allocation of the menu item, not just the "allocation minus toggle"

This perfecty matches my use-case	

Peter Clifton

Electrical Engineering Division,
Engineering Department,
University of Cambridge,
9, JJ Thomson Avenue,

Tel: +44 (0)7729 980173 - (No signal in the lab!)

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