4 Copyright (C) 1994, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
6 The Free Software Foundation, Inc.
8 This file is part of the Midnight Commander.
10 The Midnight Commander is free software: you can redistribute it
11 and/or modify it under the terms of the GNU General Public License as
12 published by the Free Software Foundation, either version 3 of the License,
13 or (at your option) any later version.
15 The Midnight Commander is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program. If not, see <http://www.gnu.org/licenses/>.
25 * \brief Source: pulldown menu code
33 #include <sys/types.h>
35 #include "lib/global.h"
37 #include "lib/tty/tty.h"
39 #include "lib/tty/mouse.h"
40 #include "lib/tty/key.h" /* key macros */
41 #include "lib/strutil.h"
42 #include "lib/widget.h"
43 #include "lib/event.h" /* mc_event_raise() */
45 /*** global variables ****************************************************************************/
47 /*** file scope macro definitions ****************************************************************/
49 #define RESIZABLE_MENUBAR 1
51 /*** file scope type declarations ****************************************************************/
53 /*** file scope variables ************************************************************************/
55 static cb_ret_t
menubar_callback (Widget
* w
, widget_msg_t msg
, int parm
);
57 /*** file scope functions ************************************************************************/
58 /* --------------------------------------------------------------------------------------------- */
61 menu_arrange (Menu
* menu
, dlg_shortcut_str get_shortcut
)
66 size_t max_shortcut_len
= 0;
68 menu
->max_entry_len
= 1;
69 menu
->max_hotkey_len
= 1;
71 for (i
= menu
->entries
; i
!= NULL
; i
= g_list_next (i
))
73 menu_entry_t
*entry
= i
->data
;
79 len
= (size_t) hotkey_width (entry
->text
);
80 menu
->max_hotkey_len
= max (menu
->max_hotkey_len
, len
);
82 if (get_shortcut
!= NULL
)
83 entry
->shortcut
= get_shortcut (entry
->command
);
85 if (entry
->shortcut
!= NULL
)
87 len
= (size_t) str_term_width1 (entry
->shortcut
);
88 max_shortcut_len
= max (max_shortcut_len
, len
);
93 menu
->max_entry_len
= menu
->max_hotkey_len
+ max_shortcut_len
;
97 /* --------------------------------------------------------------------------------------------- */
100 menubar_paint_idx (WMenuBar
* menubar
, unsigned int idx
, int color
)
102 const Menu
*menu
= g_list_nth_data (menubar
->menu
, menubar
->selected
);
103 const menu_entry_t
*entry
= g_list_nth_data (menu
->entries
, idx
);
104 const int y
= 2 + idx
;
105 int x
= menu
->start_x
;
107 if (x
+ menu
->max_entry_len
+ 4 > (gsize
) menubar
->widget
.cols
)
108 x
= menubar
->widget
.cols
- menu
->max_entry_len
- 4;
113 tty_setcolor (MENU_ENTRY_COLOR
);
115 widget_move (&menubar
->widget
, y
, x
- 1);
116 tty_print_alt_char (ACS_LTEE
, FALSE
);
118 tty_draw_hline (menubar
->widget
.y
+ y
, menubar
->widget
.x
+ x
,
119 ACS_HLINE
, menu
->max_entry_len
+ 3);
121 widget_move (&menubar
->widget
, y
, x
+ menu
->max_entry_len
+ 3);
122 tty_print_alt_char (ACS_RTEE
, FALSE
);
129 tty_setcolor (color
);
130 widget_move (&menubar
->widget
, y
, x
);
131 tty_print_char ((unsigned char) entry
->first_letter
);
132 tty_getyx (&yt
, &xt
);
133 tty_draw_hline (yt
, xt
, ' ', menu
->max_entry_len
+ 2); /* clear line */
134 tty_print_string (entry
->text
.start
);
136 if (entry
->text
.hotkey
!= NULL
)
138 tty_setcolor (color
== MENU_SELECTED_COLOR
? MENU_HOTSEL_COLOR
: MENU_HOT_COLOR
);
139 tty_print_string (entry
->text
.hotkey
);
140 tty_setcolor (color
);
143 if (entry
->text
.end
!= NULL
)
144 tty_print_string (entry
->text
.end
);
146 if (entry
->shortcut
!= NULL
)
148 widget_move (&menubar
->widget
, y
, x
+ menu
->max_hotkey_len
+ 3);
149 tty_print_string (entry
->shortcut
);
152 /* move cursor to the start of entry text */
153 widget_move (&menubar
->widget
, y
, x
+ 1);
157 /* --------------------------------------------------------------------------------------------- */
160 menubar_draw_drop (WMenuBar
* menubar
)
162 const Menu
*menu
= g_list_nth_data (menubar
->menu
, menubar
->selected
);
163 const unsigned int count
= g_list_length (menu
->entries
);
164 int column
= menu
->start_x
- 1;
167 if (column
+ menu
->max_entry_len
+ 5 > (gsize
) menubar
->widget
.cols
)
168 column
= menubar
->widget
.cols
- menu
->max_entry_len
- 5;
170 tty_setcolor (MENU_ENTRY_COLOR
);
171 draw_box (menubar
->widget
.owner
,
172 menubar
->widget
.y
+ 1, menubar
->widget
.x
+ column
,
173 count
+ 2, menu
->max_entry_len
+ 5, FALSE
);
175 for (i
= 0; i
< count
; i
++)
176 menubar_paint_idx (menubar
, i
,
177 i
== menu
->selected
? MENU_SELECTED_COLOR
: MENU_ENTRY_COLOR
);
180 /* --------------------------------------------------------------------------------------------- */
183 menubar_set_color (WMenuBar
* menubar
, gboolean current
, gboolean hotkey
)
185 if (!menubar
->is_active
)
186 tty_setcolor (MENU_INACTIVE_COLOR
);
188 tty_setcolor (hotkey
? MENU_HOTSEL_COLOR
: MENU_SELECTED_COLOR
);
190 tty_setcolor (hotkey
? MENU_HOT_COLOR
: MENU_ENTRY_COLOR
);
193 /* --------------------------------------------------------------------------------------------- */
196 menubar_draw (WMenuBar
* menubar
)
200 /* First draw the complete menubar */
201 tty_setcolor (menubar
->is_active
? MENU_ENTRY_COLOR
: MENU_INACTIVE_COLOR
);
202 tty_draw_hline (menubar
->widget
.y
, menubar
->widget
.x
, ' ', menubar
->widget
.cols
);
204 /* Now each one of the entries */
205 for (i
= menubar
->menu
; i
!= NULL
; i
= g_list_next (i
))
207 Menu
*menu
= i
->data
;
208 gboolean is_selected
= (menubar
->selected
== (gsize
) g_list_position (menubar
->menu
, i
));
210 menubar_set_color (menubar
, is_selected
, FALSE
);
211 widget_move (&menubar
->widget
, 0, menu
->start_x
);
213 tty_print_char (' ');
214 tty_print_string (menu
->text
.start
);
216 if (menu
->text
.hotkey
!= NULL
)
218 menubar_set_color (menubar
, is_selected
, TRUE
);
219 tty_print_string (menu
->text
.hotkey
);
220 menubar_set_color (menubar
, is_selected
, FALSE
);
223 if (menu
->text
.end
!= NULL
)
224 tty_print_string (menu
->text
.end
);
226 tty_print_char (' ');
229 if (menubar
->is_dropped
)
230 menubar_draw_drop (menubar
);
232 widget_move (&menubar
->widget
, 0,
233 ((Menu
*) g_list_nth_data (menubar
->menu
, menubar
->selected
))->start_x
);
236 /* --------------------------------------------------------------------------------------------- */
239 menubar_remove (WMenuBar
* menubar
)
243 if (!menubar
->is_dropped
)
246 /* HACK: before refresh the dialog, change the current widget to keep the order
247 of overlapped widgets. This is useful in multi-window editor.
248 In general, menubar should be a special object, not an ordinary widget
249 in the current dialog. */
250 h
= menubar
->widget
.owner
;
251 h
->current
= g_list_find (h
->widgets
, dlg_find_by_id (h
, menubar
->previous_widget
));
253 menubar
->is_dropped
= FALSE
;
255 menubar
->is_dropped
= TRUE
;
257 /* restore current widget */
258 h
->current
= g_list_find (h
->widgets
, menubar
);
261 /* --------------------------------------------------------------------------------------------- */
264 menubar_left (WMenuBar
* menubar
)
266 menubar_remove (menubar
);
267 if (menubar
->selected
== 0)
268 menubar
->selected
= g_list_length (menubar
->menu
) - 1;
271 menubar_draw (menubar
);
274 /* --------------------------------------------------------------------------------------------- */
277 menubar_right (WMenuBar
* menubar
)
279 menubar_remove (menubar
);
280 menubar
->selected
= (menubar
->selected
+ 1) % g_list_length (menubar
->menu
);
281 menubar_draw (menubar
);
284 /* --------------------------------------------------------------------------------------------- */
287 menubar_finish (WMenuBar
* menubar
)
289 menubar
->is_dropped
= FALSE
;
290 menubar
->is_active
= FALSE
;
291 menubar
->widget
.lines
= 1;
292 widget_want_hotkey (menubar
->widget
, 0);
294 dlg_select_by_id (menubar
->widget
.owner
, menubar
->previous_widget
);
298 /* --------------------------------------------------------------------------------------------- */
301 menubar_drop (WMenuBar
* menubar
, unsigned int selected
)
303 menubar
->is_dropped
= TRUE
;
304 menubar
->selected
= selected
;
305 menubar_draw (menubar
);
308 /* --------------------------------------------------------------------------------------------- */
311 menubar_execute (WMenuBar
* menubar
)
313 const Menu
*menu
= g_list_nth_data (menubar
->menu
, menubar
->selected
);
314 const menu_entry_t
*entry
= g_list_nth_data (menu
->entries
, menu
->selected
);
316 if ((entry
!= NULL
) && (entry
->command
!= CK_IgnoreKey
))
318 mc_global
.is_right
= (menubar
->selected
!= 0);
319 menubar_finish (menubar
);
320 menubar
->widget
.owner
->callback (menubar
->widget
.owner
, &menubar
->widget
,
321 DLG_ACTION
, entry
->command
, NULL
);
326 /* --------------------------------------------------------------------------------------------- */
329 menubar_down (WMenuBar
* menubar
)
331 Menu
*menu
= g_list_nth_data (menubar
->menu
, menubar
->selected
);
332 const unsigned int len
= g_list_length (menu
->entries
);
335 menubar_paint_idx (menubar
, menu
->selected
, MENU_ENTRY_COLOR
);
339 menu
->selected
= (menu
->selected
+ 1) % len
;
340 entry
= (menu_entry_t
*) g_list_nth_data (menu
->entries
, menu
->selected
);
342 while ((entry
== NULL
) || (entry
->command
== CK_IgnoreKey
));
344 menubar_paint_idx (menubar
, menu
->selected
, MENU_SELECTED_COLOR
);
347 /* --------------------------------------------------------------------------------------------- */
350 menubar_up (WMenuBar
* menubar
)
352 Menu
*menu
= g_list_nth_data (menubar
->menu
, menubar
->selected
);
353 const unsigned int len
= g_list_length (menu
->entries
);
356 menubar_paint_idx (menubar
, menu
->selected
, MENU_ENTRY_COLOR
);
360 if (menu
->selected
== 0)
361 menu
->selected
= len
- 1;
364 entry
= (menu_entry_t
*) g_list_nth_data (menu
->entries
, menu
->selected
);
366 while ((entry
== NULL
) || (entry
->command
== CK_IgnoreKey
));
368 menubar_paint_idx (menubar
, menu
->selected
, MENU_SELECTED_COLOR
);
371 /* --------------------------------------------------------------------------------------------- */
374 menubar_first (WMenuBar
* menubar
)
376 Menu
*menu
= g_list_nth_data (menubar
->menu
, menubar
->selected
);
379 if (menu
->selected
== 0)
382 menubar_paint_idx (menubar
, menu
->selected
, MENU_ENTRY_COLOR
);
388 entry
= (menu_entry_t
*) g_list_nth_data (menu
->entries
, menu
->selected
);
390 if ((entry
== NULL
) || (entry
->command
== CK_IgnoreKey
))
396 menubar_paint_idx (menubar
, menu
->selected
, MENU_SELECTED_COLOR
);
399 /* --------------------------------------------------------------------------------------------- */
402 menubar_last (WMenuBar
* menubar
)
404 Menu
*menu
= g_list_nth_data (menubar
->menu
, menubar
->selected
);
405 const unsigned int len
= g_list_length (menu
->entries
);
408 if (menu
->selected
== len
- 1)
411 menubar_paint_idx (menubar
, menu
->selected
, MENU_ENTRY_COLOR
);
413 menu
->selected
= len
;
418 entry
= (menu_entry_t
*) g_list_nth_data (menu
->entries
, menu
->selected
);
420 while ((entry
== NULL
) || (entry
->command
== CK_IgnoreKey
));
422 menubar_paint_idx (menubar
, menu
->selected
, MENU_SELECTED_COLOR
);
425 /* --------------------------------------------------------------------------------------------- */
428 menubar_handle_key (WMenuBar
* menubar
, int key
)
432 key
= g_ascii_tolower (key
);
434 if (is_abort_char (key
))
436 menubar_finish (menubar
);
440 /* menubar help or menubar navigation */
445 ev_help_t event_data
= { NULL
, NULL
};
447 if (menubar
->is_dropped
)
449 ((Menu
*) g_list_nth_data (menubar
->menu
, menubar
->selected
))->help_node
;
451 event_data
.node
= "[Menu Bar]";
453 mc_event_raise (MCEVENT_GROUP_CORE
, "help", &event_data
);
454 menubar_draw (menubar
);
459 menubar_left (menubar
);
464 menubar_right (menubar
);
468 if (!menubar
->is_dropped
)
472 /* drop menu by hotkey */
473 for (i
= menubar
->menu
; i
!= NULL
; i
= g_list_next (i
))
475 Menu
*menu
= i
->data
;
477 if ((menu
->text
.hotkey
!= NULL
) && (key
== g_ascii_tolower (menu
->text
.hotkey
[0])))
479 menubar_drop (menubar
, g_list_position (menubar
->menu
, i
));
484 /* drop menu by Enter or Dowwn key */
485 if (key
== KEY_ENTER
|| key
== XCTRL ('n') || key
== KEY_DOWN
|| key
== '\n')
486 menubar_drop (menubar
, menubar
->selected
);
492 Menu
*menu
= g_list_nth_data (menubar
->menu
, menubar
->selected
);
495 /* execute menu command by hotkey */
496 for (i
= menu
->entries
; i
!= NULL
; i
= g_list_next (i
))
498 const menu_entry_t
*entry
= i
->data
;
500 if ((entry
!= NULL
) && (entry
->command
!= CK_IgnoreKey
)
501 && (entry
->text
.hotkey
!= NULL
) && (key
== g_ascii_tolower (entry
->text
.hotkey
[0])))
503 menu
->selected
= g_list_position (menu
->entries
, i
);
504 menubar_execute (menubar
);
509 /* menu execute by Enter or menu navigation */
514 menubar_execute (menubar
);
519 menubar_first (menubar
);
524 menubar_last (menubar
);
529 menubar_down (menubar
);
534 menubar_up (menubar
);
542 /* --------------------------------------------------------------------------------------------- */
545 menubar_callback (Widget
* w
, widget_msg_t msg
, int parm
)
547 WMenuBar
*menubar
= (WMenuBar
*) w
;
551 /* We do not want the focus unless we have been activated */
553 if (!menubar
->is_active
)
554 return MSG_NOT_HANDLED
;
556 /* Trick to get all the mouse events */
557 menubar
->widget
.lines
= LINES
;
559 /* Trick to get all of the hotkeys */
560 widget_want_hotkey (menubar
->widget
, 1);
561 menubar_draw (menubar
);
564 /* We don't want the buttonbar to activate while using the menubar */
567 if (menubar
->is_active
)
569 menubar_handle_key (menubar
, parm
);
572 return MSG_NOT_HANDLED
;
575 /* Put the cursor in a suitable place */
576 return MSG_NOT_HANDLED
;
579 return menubar
->is_active
? MSG_NOT_HANDLED
: MSG_HANDLED
;
582 if (menubar
->is_visible
)
584 menubar_draw (menubar
);
590 /* try show menu after screen resize */
591 send_message (w
, WIDGET_FOCUS
, 0);
596 menubar_set_menu (menubar
, NULL
);
600 return default_proc (msg
, parm
);
604 /* --------------------------------------------------------------------------------------------- */
607 menubar_event (Gpm_Event
* event
, void *data
)
609 WMenuBar
*menubar
= (WMenuBar
*) data
;
610 Widget
*w
= (Widget
*) data
;
611 gboolean was_active
= TRUE
;
612 int left_x
, right_x
, bottom_y
;
616 if (!mouse_global_in_widget (event
, w
))
617 return MOU_UNHANDLED
;
619 /* ignore unsupported events */
620 if ((event
->type
& (GPM_UP
| GPM_DOWN
| GPM_DRAG
)) == 0)
623 /* ignore wheel events if menu is inactive */
624 if (!menubar
->is_active
&& ((event
->buttons
& (GPM_B_MIDDLE
| GPM_B_UP
| GPM_B_DOWN
)) != 0))
627 if (!menubar
->is_dropped
)
629 menubar
->previous_widget
= dlg_get_current_widget_id (w
->owner
);
630 menubar
->is_active
= TRUE
;
631 menubar
->is_dropped
= TRUE
;
635 local
= mouse_get_local (event
, w
);
637 /* Mouse operations on the menubar */
638 if (local
.y
== 1 || !was_active
)
640 if ((local
.type
& GPM_UP
) != 0)
643 /* wheel events on menubar */
644 if ((local
.buttons
& GPM_B_UP
) != 0)
645 menubar_left (menubar
);
646 else if ((local
.buttons
& GPM_B_DOWN
) != 0)
647 menubar_right (menubar
);
650 const unsigned int len
= g_list_length (menubar
->menu
);
651 unsigned int new_selection
= 0;
653 while ((new_selection
< len
)
654 && (local
.x
> ((Menu
*) g_list_nth_data (menubar
->menu
,
655 new_selection
))->start_x
))
658 if (new_selection
!= 0) /* Don't set the invalid value -1 */
663 menubar
->selected
= new_selection
;
664 dlg_select_widget (menubar
);
668 menubar_remove (menubar
);
669 menubar
->selected
= new_selection
;
671 menubar_draw (menubar
);
676 if (!menubar
->is_dropped
|| (local
.y
< 2))
679 /* middle click -- everywhere */
680 if (((local
.buttons
& GPM_B_MIDDLE
) != 0) && ((local
.type
& GPM_DOWN
) != 0))
682 menubar_execute (menubar
);
686 /* the mouse operation is on the menus or it is not */
687 menu
= (Menu
*) g_list_nth_data (menubar
->menu
, menubar
->selected
);
688 left_x
= menu
->start_x
;
689 right_x
= left_x
+ menu
->max_entry_len
+ 3;
690 if (right_x
> menubar
->widget
.cols
)
692 left_x
= menubar
->widget
.cols
- menu
->max_entry_len
- 3;
693 right_x
= menubar
->widget
.cols
;
696 bottom_y
= g_list_length (menu
->entries
) + 3;
698 if ((local
.x
>= left_x
) && (local
.x
<= right_x
) && (local
.y
<= bottom_y
))
700 int pos
= local
.y
- 3;
701 const menu_entry_t
*entry
= g_list_nth_data (menu
->entries
, pos
);
704 if ((local
.buttons
& GPM_B_UP
) != 0 && (local
.type
& GPM_DOWN
) != 0)
706 menubar_up (menubar
);
709 if ((local
.buttons
& GPM_B_DOWN
) != 0 && (local
.type
& GPM_DOWN
) != 0)
711 menubar_down (menubar
);
715 /* ignore events above and below dropped down menu */
716 if ((pos
< 0) || (pos
>= bottom_y
- 3))
719 if ((entry
!= NULL
) && (entry
->command
!= CK_IgnoreKey
))
721 menubar_paint_idx (menubar
, menu
->selected
, MENU_ENTRY_COLOR
);
722 menu
->selected
= pos
;
723 menubar_paint_idx (menubar
, menu
->selected
, MENU_SELECTED_COLOR
);
725 if ((event
->type
& GPM_UP
) != 0)
726 menubar_execute (menubar
);
729 else if (((local
.type
& GPM_DOWN
) != 0) && ((local
.buttons
& (GPM_B_UP
| GPM_B_DOWN
)) == 0))
731 /* use click not wheel to close menu */
732 menubar_finish (menubar
);
738 /* --------------------------------------------------------------------------------------------- */
739 /*** public functions ****************************************************************************/
740 /* --------------------------------------------------------------------------------------------- */
743 menu_entry_create (const char *name
, unsigned long command
)
747 entry
= g_new (menu_entry_t
, 1);
748 entry
->first_letter
= ' ';
749 entry
->text
= parse_hotkey (name
);
750 entry
->command
= command
;
751 entry
->shortcut
= NULL
;
756 /* --------------------------------------------------------------------------------------------- */
759 menu_entry_free (menu_entry_t
* entry
)
763 release_hotkey (entry
->text
);
764 g_free (entry
->shortcut
);
769 /* --------------------------------------------------------------------------------------------- */
772 create_menu (const char *name
, GList
* entries
, const char *help_node
)
776 menu
= g_new (Menu
, 1);
778 menu
->text
= parse_hotkey (name
);
779 menu
->entries
= entries
;
780 menu
->max_entry_len
= 1;
781 menu
->max_hotkey_len
= 0;
783 menu
->help_node
= g_strdup (help_node
);
788 /* --------------------------------------------------------------------------------------------- */
791 menu_set_name (Menu
* menu
, const char *name
)
793 release_hotkey (menu
->text
);
794 menu
->text
= parse_hotkey (name
);
797 /* --------------------------------------------------------------------------------------------- */
800 destroy_menu (Menu
* menu
)
802 release_hotkey (menu
->text
);
803 g_list_foreach (menu
->entries
, (GFunc
) menu_entry_free
, NULL
);
804 g_list_free (menu
->entries
);
805 g_free (menu
->help_node
);
809 /* --------------------------------------------------------------------------------------------- */
812 menubar_new (int y
, int x
, int cols
, GList
* menu
)
816 menubar
= g_new0 (WMenuBar
, 1);
817 init_widget (&menubar
->widget
, y
, x
, 1, cols
, menubar_callback
, menubar_event
);
818 widget_want_cursor (menubar
->widget
, FALSE
);
819 menubar
->is_visible
= TRUE
; /* by default */
820 menubar_set_menu (menubar
, menu
);
825 /* --------------------------------------------------------------------------------------------- */
828 menubar_set_menu (WMenuBar
* menubar
, GList
* menu
)
830 /* delete previous menu */
831 if (menubar
->menu
!= NULL
)
833 g_list_foreach (menubar
->menu
, (GFunc
) destroy_menu
, NULL
);
834 g_list_free (menubar
->menu
);
837 menubar
->is_active
= FALSE
;
838 menubar
->is_dropped
= FALSE
;
839 menubar
->menu
= menu
;
840 menubar
->selected
= 0;
841 menubar_arrange (menubar
);
844 /* --------------------------------------------------------------------------------------------- */
847 menubar_add_menu (WMenuBar
* menubar
, Menu
* menu
)
851 menu_arrange (menu
, menubar
->widget
.owner
->get_shortcut
);
852 menubar
->menu
= g_list_append (menubar
->menu
, menu
);
855 menubar_arrange (menubar
);
858 /* --------------------------------------------------------------------------------------------- */
860 * Properly space menubar items. Should be called when menubar is created
861 * and also when widget width is changed (i.e. upon xterm resize).
865 menubar_arrange (WMenuBar
* menubar
)
871 if (menubar
->menu
== NULL
)
874 #ifndef RESIZABLE_MENUBAR
877 for (i
= menubar
->menu
; i
!= NULL
; i
= g_list_next (i
))
879 Menu
*menu
= i
->data
;
880 int len
= hotkey_width (menu
->text
) + 2;
882 menu
->start_x
= start_x
;
883 start_x
+= len
+ gap
;
885 #else /* RESIZABLE_MENUBAR */
886 gap
= menubar
->widget
.cols
- 2;
888 /* First, calculate gap between items... */
889 for (i
= menubar
->menu
; i
!= NULL
; i
= g_list_next (i
))
891 Menu
*menu
= i
->data
;
892 /* preserve length here, to be used below */
893 menu
->start_x
= hotkey_width (menu
->text
) + 2;
894 gap
-= menu
->start_x
;
897 if (g_list_next (menubar
->menu
) == NULL
)
900 gap
/= (g_list_length (menubar
->menu
) - 1);
904 /* We are out of luck - window is too narrow... */
908 /* ...and now fix start positions of menubar items */
909 for (i
= menubar
->menu
; i
!= NULL
; i
= g_list_next (i
))
911 Menu
*menu
= i
->data
;
912 int len
= menu
->start_x
;
914 menu
->start_x
= start_x
;
915 start_x
+= len
+ gap
;
917 #endif /* RESIZABLE_MENUBAR */
920 /* --------------------------------------------------------------------------------------------- */
921 /** Find MenuBar widget in the dialog */
924 find_menubar (const Dlg_head
* h
)
926 return (WMenuBar
*) find_widget_type (h
, menubar_callback
);
929 /* --------------------------------------------------------------------------------------------- */