Re: Menu bar items without icon indent
- From: Peter Clifton <pcjc2 cam ac uk>
- To: GTK Devel List <gtk-devel-list gnome org>
- Subject: Re: Menu bar items without icon indent
- Date: Wed, 14 Jan 2009 11:56:14 +0000
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:
http://svn.gnome.org/viewvc/gnome-settings-daemon/trunk/plugins/xrandr/gsd-xrandr-manager.c?revision=629&view=markup
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);
751
752 g_signal_handlers_block_by_func (widget, title_item_size_allocate_cb, NULL);
753
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 */
759
760 allocation->width++;
761 gtk_widget_size_allocate (widget, allocation);
762
763 allocation->width--;
764 gtk_widget_size_allocate (widget, allocation);
765
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"
area.
This perfecty matches my use-case
--
Peter Clifton
Electrical Engineering Division,
Engineering Department,
University of Cambridge,
9, JJ Thomson Avenue,
Cambridge
CB3 0FA
Tel: +44 (0)7729 980173 - (No signal in the lab!)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]