diff options
| author | Chong Yidong | 2010-12-17 12:04:06 +0800 |
|---|---|---|
| committer | Chong Yidong | 2010-12-17 12:04:06 +0800 |
| commit | 4039c78625bb20cf57b434a7d395bf2473e45133 (patch) | |
| tree | 729b8ce725973a7e31d769e4ab1217b517738a21 /src | |
| parent | 8b358e9038806836c599da8233781b14c6bb53e7 (diff) | |
| download | emacs-4039c78625bb20cf57b434a7d395bf2473e45133.tar.gz emacs-4039c78625bb20cf57b434a7d395bf2473e45133.zip | |
Support for menu separators in the GTK tool-bar.
* src/gtkutil.c (XG_BIN_CHILD): New macro.
(xg_get_menu_item_label, xg_update_menubar)
(xg_update_menu_item, xg_tool_bar_menu_proxy)
(xg_show_toolbar_item, update_frame_tool_bar): Use it.
(separator_names, xg_separator_p): Move to keyboard.c.
(create_menus, xg_update_submenu, update_frame_tool_bar): Use
menu_separator_name_p.
* src/keyboard.c (parse_tool_bar_item): Allow menu separators in
tool-bar maps.
(menu_separator_name_p): New function, from gtkutil.c.
(separator_names): Move from gtkutil.c.
* src/keyboard.h (menu_separator_name_p): Add prototype.
* src/nsmenu.m (name_is_separator): Function deleted.
(addItemWithWidgetValue): Use menu_separator_name_p.
* src/w32menu.c (name_is_separator): Function deleted.
(add_menu_item): Use menu_separator_name_p.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 23 | ||||
| -rw-r--r-- | src/dispextern.h | 3 | ||||
| -rw-r--r-- | src/gtkutil.c | 118 | ||||
| -rw-r--r-- | src/keyboard.c | 76 | ||||
| -rw-r--r-- | src/keyboard.h | 1 | ||||
| -rw-r--r-- | src/nsmenu.m | 17 | ||||
| -rw-r--r-- | src/w32menu.c | 16 | ||||
| -rw-r--r-- | src/xdisp.c | 4 |
8 files changed, 144 insertions, 114 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index c6e0d92f1f5..f9287ea9c8f 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,26 @@ | |||
| 1 | 2010-12-17 Chong Yidong <cyd@stupidchicken.com> | ||
| 2 | |||
| 3 | * keyboard.c (parse_tool_bar_item): Allow menu separators in | ||
| 4 | tool-bar maps. | ||
| 5 | (menu_separator_name_p): New function, from gtkutil.c. | ||
| 6 | (separator_names): Move from gtkutil.c. | ||
| 7 | |||
| 8 | * keyboard.h (menu_separator_name_p): Add prototype. | ||
| 9 | |||
| 10 | * gtkutil.c (XG_BIN_CHILD): New macro. | ||
| 11 | (xg_get_menu_item_label, xg_update_menubar) | ||
| 12 | (xg_update_menu_item, xg_tool_bar_menu_proxy) | ||
| 13 | (xg_show_toolbar_item, update_frame_tool_bar): Use it. | ||
| 14 | (separator_names, xg_separator_p): Move to keyboard.c. | ||
| 15 | (create_menus, xg_update_submenu, update_frame_tool_bar): Use | ||
| 16 | menu_separator_name_p. | ||
| 17 | |||
| 18 | * nsmenu.m (name_is_separator): Function deleted. | ||
| 19 | (addItemWithWidgetValue): Use menu_separator_name_p. | ||
| 20 | |||
| 21 | * w32menu.c (name_is_separator): Function deleted. | ||
| 22 | (add_menu_item): Use menu_separator_name_p. | ||
| 23 | |||
| 1 | 2010-12-16 Jan Djärv <jan.h.d@swipnet.se> | 24 | 2010-12-16 Jan Djärv <jan.h.d@swipnet.se> |
| 2 | 25 | ||
| 3 | * nsterm.m (ns_draw_window_cursor): If the cursor color is the | 26 | * nsterm.m (ns_draw_window_cursor): If the cursor color is the |
diff --git a/src/dispextern.h b/src/dispextern.h index 27d3c1583ca..175dbe1975c 100644 --- a/src/dispextern.h +++ b/src/dispextern.h | |||
| @@ -2881,7 +2881,8 @@ enum tool_bar_item_idx | |||
| 2881 | /* The binding. */ | 2881 | /* The binding. */ |
| 2882 | TOOL_BAR_ITEM_BINDING, | 2882 | TOOL_BAR_ITEM_BINDING, |
| 2883 | 2883 | ||
| 2884 | /* Button type. One of nil, `:radio' or `:toggle'. */ | 2884 | /* Button type. One of nil (default button), t (a separator), |
| 2885 | `:radio', or `:toggle'. The latter two currently do nothing. */ | ||
| 2885 | TOOL_BAR_ITEM_TYPE, | 2886 | TOOL_BAR_ITEM_TYPE, |
| 2886 | 2887 | ||
| 2887 | /* Help string. */ | 2888 | /* Help string. */ |
diff --git a/src/gtkutil.c b/src/gtkutil.c index 6fd4b969819..a6cfbf002b3 100644 --- a/src/gtkutil.c +++ b/src/gtkutil.c | |||
| @@ -72,6 +72,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 72 | #define remove_submenu(w) gtk_menu_item_remove_submenu ((w)) | 72 | #define remove_submenu(w) gtk_menu_item_remove_submenu ((w)) |
| 73 | #endif | 73 | #endif |
| 74 | 74 | ||
| 75 | #define XG_BIN_CHILD(x) gtk_bin_get_child (GTK_BIN (x)) | ||
| 76 | |||
| 75 | 77 | ||
| 76 | /*********************************************************************** | 78 | /*********************************************************************** |
| 77 | Display handling functions | 79 | Display handling functions |
| @@ -2128,54 +2130,6 @@ make_menu_item (const char *utf8_label, | |||
| 2128 | return w; | 2130 | return w; |
| 2129 | } | 2131 | } |
| 2130 | 2132 | ||
| 2131 | /* Return non-zero if LABEL specifies a separator (GTK only has one | ||
| 2132 | separator type) */ | ||
| 2133 | |||
| 2134 | static const char* separator_names[] = { | ||
| 2135 | "space", | ||
| 2136 | "no-line", | ||
| 2137 | "single-line", | ||
| 2138 | "double-line", | ||
| 2139 | "single-dashed-line", | ||
| 2140 | "double-dashed-line", | ||
| 2141 | "shadow-etched-in", | ||
| 2142 | "shadow-etched-out", | ||
| 2143 | "shadow-etched-in-dash", | ||
| 2144 | "shadow-etched-out-dash", | ||
| 2145 | "shadow-double-etched-in", | ||
| 2146 | "shadow-double-etched-out", | ||
| 2147 | "shadow-double-etched-in-dash", | ||
| 2148 | "shadow-double-etched-out-dash", | ||
| 2149 | 0, | ||
| 2150 | }; | ||
| 2151 | |||
| 2152 | static int | ||
| 2153 | xg_separator_p (const char *label) | ||
| 2154 | { | ||
| 2155 | if (! label) return 0; | ||
| 2156 | else if (strlen (label) > 3 | ||
| 2157 | && strncmp (label, "--", 2) == 0 | ||
| 2158 | && label[2] != '-') | ||
| 2159 | { | ||
| 2160 | int i; | ||
| 2161 | |||
| 2162 | label += 2; | ||
| 2163 | for (i = 0; separator_names[i]; ++i) | ||
| 2164 | if (strcmp (label, separator_names[i]) == 0) | ||
| 2165 | return 1; | ||
| 2166 | } | ||
| 2167 | else | ||
| 2168 | { | ||
| 2169 | /* Old-style separator, maybe. It's a separator if it contains | ||
| 2170 | only dashes. */ | ||
| 2171 | while (*label == '-') | ||
| 2172 | ++label; | ||
| 2173 | if (*label == 0) return 1; | ||
| 2174 | } | ||
| 2175 | |||
| 2176 | return 0; | ||
| 2177 | } | ||
| 2178 | |||
| 2179 | static int xg_detached_menus; | 2133 | static int xg_detached_menus; |
| 2180 | 2134 | ||
| 2181 | /* Returns non-zero if there are detached menus. */ | 2135 | /* Returns non-zero if there are detached menus. */ |
| @@ -2374,7 +2328,7 @@ create_menus (widget_value *data, | |||
| 2374 | GtkWidget *w; | 2328 | GtkWidget *w; |
| 2375 | 2329 | ||
| 2376 | if (pop_up_p && !item->contents && !item->call_data | 2330 | if (pop_up_p && !item->contents && !item->call_data |
| 2377 | && !xg_separator_p (item->name)) | 2331 | && !menu_separator_name_p (item->name)) |
| 2378 | { | 2332 | { |
| 2379 | char *utf8_label; | 2333 | char *utf8_label; |
| 2380 | /* A title for a popup. We do the same as GTK does when | 2334 | /* A title for a popup. We do the same as GTK does when |
| @@ -2387,7 +2341,7 @@ create_menus (widget_value *data, | |||
| 2387 | gtk_widget_set_sensitive (w, FALSE); | 2341 | gtk_widget_set_sensitive (w, FALSE); |
| 2388 | if (utf8_label) g_free (utf8_label); | 2342 | if (utf8_label) g_free (utf8_label); |
| 2389 | } | 2343 | } |
| 2390 | else if (xg_separator_p (item->name)) | 2344 | else if (menu_separator_name_p (item->name)) |
| 2391 | { | 2345 | { |
| 2392 | group = NULL; | 2346 | group = NULL; |
| 2393 | /* GTK only have one separator type. */ | 2347 | /* GTK only have one separator type. */ |
| @@ -2499,7 +2453,7 @@ xg_create_widget (const char *type, const char *name, FRAME_PTR f, widget_value | |||
| 2499 | static const char * | 2453 | static const char * |
| 2500 | xg_get_menu_item_label (GtkMenuItem *witem) | 2454 | xg_get_menu_item_label (GtkMenuItem *witem) |
| 2501 | { | 2455 | { |
| 2502 | GtkLabel *wlabel = GTK_LABEL (gtk_bin_get_child (GTK_BIN (witem))); | 2456 | GtkLabel *wlabel = GTK_LABEL (XG_BIN_CHILD (witem)); |
| 2503 | return gtk_label_get_label (wlabel); | 2457 | return gtk_label_get_label (wlabel); |
| 2504 | } | 2458 | } |
| 2505 | 2459 | ||
| @@ -2652,7 +2606,7 @@ xg_update_menubar (GtkWidget *menubar, | |||
| 2652 | Rename X to B (minibuf to C-mode menu). | 2606 | Rename X to B (minibuf to C-mode menu). |
| 2653 | If the X menu hasn't been invoked, the menu under B | 2607 | If the X menu hasn't been invoked, the menu under B |
| 2654 | is up to date when leaving the minibuffer. */ | 2608 | is up to date when leaving the minibuffer. */ |
| 2655 | GtkLabel *wlabel = GTK_LABEL (gtk_bin_get_child (GTK_BIN (witem))); | 2609 | GtkLabel *wlabel = GTK_LABEL (XG_BIN_CHILD (witem)); |
| 2656 | char *utf8_label = get_utf8_string (val->name); | 2610 | char *utf8_label = get_utf8_string (val->name); |
| 2657 | GtkWidget *submenu = gtk_menu_item_get_submenu (witem); | 2611 | GtkWidget *submenu = gtk_menu_item_get_submenu (witem); |
| 2658 | 2612 | ||
| @@ -2751,7 +2705,7 @@ xg_update_menu_item (widget_value *val, | |||
| 2751 | const char *old_key = 0; | 2705 | const char *old_key = 0; |
| 2752 | xg_menu_item_cb_data *cb_data; | 2706 | xg_menu_item_cb_data *cb_data; |
| 2753 | 2707 | ||
| 2754 | wchild = gtk_bin_get_child (GTK_BIN (w)); | 2708 | wchild = XG_BIN_CHILD (w); |
| 2755 | utf8_label = get_utf8_string (val->name); | 2709 | utf8_label = get_utf8_string (val->name); |
| 2756 | utf8_key = get_utf8_string (val->key); | 2710 | utf8_key = get_utf8_string (val->key); |
| 2757 | 2711 | ||
| @@ -2910,7 +2864,7 @@ xg_update_submenu (GtkWidget *submenu, | |||
| 2910 | 2864 | ||
| 2911 | if (GTK_IS_SEPARATOR_MENU_ITEM (w)) | 2865 | if (GTK_IS_SEPARATOR_MENU_ITEM (w)) |
| 2912 | { | 2866 | { |
| 2913 | if (! xg_separator_p (cur->name)) | 2867 | if (! menu_separator_name_p (cur->name)) |
| 2914 | break; | 2868 | break; |
| 2915 | } | 2869 | } |
| 2916 | else if (GTK_IS_CHECK_MENU_ITEM (w)) | 2870 | else if (GTK_IS_CHECK_MENU_ITEM (w)) |
| @@ -2933,7 +2887,7 @@ xg_update_submenu (GtkWidget *submenu, | |||
| 2933 | GtkWidget *sub; | 2887 | GtkWidget *sub; |
| 2934 | 2888 | ||
| 2935 | if (cur->button_type != BUTTON_TYPE_NONE || | 2889 | if (cur->button_type != BUTTON_TYPE_NONE || |
| 2936 | xg_separator_p (cur->name)) | 2890 | menu_separator_name_p (cur->name)) |
| 2937 | break; | 2891 | break; |
| 2938 | 2892 | ||
| 2939 | xg_update_menu_item (cur, w, select_cb, highlight_cb, cl_data); | 2893 | xg_update_menu_item (cur, w, select_cb, highlight_cb, cl_data); |
| @@ -3725,9 +3679,8 @@ xg_get_tool_bar_widgets (GtkWidget *vb, GtkWidget **wimage) | |||
| 3725 | static gboolean | 3679 | static gboolean |
| 3726 | xg_tool_bar_menu_proxy (GtkToolItem *toolitem, gpointer user_data) | 3680 | xg_tool_bar_menu_proxy (GtkToolItem *toolitem, gpointer user_data) |
| 3727 | { | 3681 | { |
| 3728 | GtkWidget *weventbox = gtk_bin_get_child (GTK_BIN (toolitem)); | 3682 | GtkButton *wbutton = GTK_BUTTON (XG_BIN_CHILD (XG_BIN_CHILD (toolitem))); |
| 3729 | GtkButton *wbutton = GTK_BUTTON (gtk_bin_get_child (GTK_BIN (weventbox))); | 3683 | GtkWidget *vb = XG_BIN_CHILD (wbutton); |
| 3730 | GtkWidget *vb = gtk_bin_get_child (GTK_BIN (wbutton)); | ||
| 3731 | GtkWidget *c1; | 3684 | GtkWidget *c1; |
| 3732 | GtkLabel *wlbl = GTK_LABEL (xg_get_tool_bar_widgets (vb, &c1)); | 3685 | GtkLabel *wlbl = GTK_LABEL (xg_get_tool_bar_widgets (vb, &c1)); |
| 3733 | GtkImage *wimage = GTK_IMAGE (c1); | 3686 | GtkImage *wimage = GTK_IMAGE (c1); |
| @@ -4180,9 +4133,9 @@ xg_show_toolbar_item (GtkToolItem *ti) | |||
| 4180 | int show_label = ! EQ (style, Qimage) && ! (vert_only && horiz); | 4133 | int show_label = ! EQ (style, Qimage) && ! (vert_only && horiz); |
| 4181 | int show_image = ! EQ (style, Qtext); | 4134 | int show_image = ! EQ (style, Qtext); |
| 4182 | 4135 | ||
| 4183 | GtkWidget *weventbox = gtk_bin_get_child (GTK_BIN (ti)); | 4136 | GtkWidget *weventbox = XG_BIN_CHILD (ti); |
| 4184 | GtkWidget *wbutton = gtk_bin_get_child (GTK_BIN (weventbox)); | 4137 | GtkWidget *wbutton = XG_BIN_CHILD (weventbox); |
| 4185 | GtkWidget *vb = gtk_bin_get_child (GTK_BIN (wbutton)); | 4138 | GtkWidget *vb = XG_BIN_CHILD (wbutton); |
| 4186 | GtkWidget *wimage; | 4139 | GtkWidget *wimage; |
| 4187 | GtkWidget *wlbl = xg_get_tool_bar_widgets (vb, &wimage); | 4140 | GtkWidget *wlbl = xg_get_tool_bar_widgets (vb, &wimage); |
| 4188 | GtkWidget *new_box = NULL; | 4141 | GtkWidget *new_box = NULL; |
| @@ -4330,7 +4283,6 @@ update_frame_tool_bar (FRAME_PTR f) | |||
| 4330 | char *icon_name = NULL; | 4283 | char *icon_name = NULL; |
| 4331 | Lisp_Object rtl; | 4284 | Lisp_Object rtl; |
| 4332 | GtkWidget *wbutton = NULL; | 4285 | GtkWidget *wbutton = NULL; |
| 4333 | GtkWidget *weventbox; | ||
| 4334 | Lisp_Object specified_file; | 4286 | Lisp_Object specified_file; |
| 4335 | const char *label = (STRINGP (PROP (TOOL_BAR_ITEM_LABEL)) | 4287 | const char *label = (STRINGP (PROP (TOOL_BAR_ITEM_LABEL)) |
| 4336 | ? SSDATA (PROP (TOOL_BAR_ITEM_LABEL)) : ""); | 4288 | ? SSDATA (PROP (TOOL_BAR_ITEM_LABEL)) : ""); |
| @@ -4338,16 +4290,34 @@ update_frame_tool_bar (FRAME_PTR f) | |||
| 4338 | 4290 | ||
| 4339 | ti = gtk_toolbar_get_nth_item (GTK_TOOLBAR (wtoolbar), i); | 4291 | ti = gtk_toolbar_get_nth_item (GTK_TOOLBAR (wtoolbar), i); |
| 4340 | 4292 | ||
| 4341 | if (ti) | 4293 | /* If this is a separator, use a gtk separator item. */ |
| 4342 | { | 4294 | if (EQ (PROP (TOOL_BAR_ITEM_TYPE), Qt)) |
| 4343 | weventbox = gtk_bin_get_child (GTK_BIN (ti)); | 4295 | { |
| 4344 | wbutton = gtk_bin_get_child (GTK_BIN (weventbox)); | 4296 | if (ti == NULL || !GTK_IS_SEPARATOR_TOOL_ITEM (ti)) |
| 4345 | } | 4297 | { |
| 4346 | 4298 | if (ti) | |
| 4299 | gtk_container_remove (GTK_CONTAINER (wtoolbar), | ||
| 4300 | GTK_WIDGET (ti)); | ||
| 4301 | ti = gtk_separator_tool_item_new (); | ||
| 4302 | gtk_toolbar_insert (GTK_TOOLBAR (wtoolbar), ti, i); | ||
| 4303 | } | ||
| 4304 | gtk_widget_show (GTK_WIDGET (ti)); | ||
| 4305 | continue; | ||
| 4306 | } | ||
| 4307 | |||
| 4308 | /* Otherwise, the tool-bar item is an ordinary button. */ | ||
| 4309 | |||
| 4310 | if (ti && GTK_IS_SEPARATOR_TOOL_ITEM (ti)) | ||
| 4311 | { | ||
| 4312 | gtk_container_remove (GTK_CONTAINER (wtoolbar), GTK_WIDGET (ti)); | ||
| 4313 | ti = NULL; | ||
| 4314 | } | ||
| 4347 | 4315 | ||
| 4348 | image = PROP (TOOL_BAR_ITEM_IMAGES); | 4316 | if (ti) |
| 4317 | wbutton = XG_BIN_CHILD (XG_BIN_CHILD (ti)); | ||
| 4349 | 4318 | ||
| 4350 | /* Ignore invalid image specifications. */ | 4319 | /* Ignore invalid image specifications. */ |
| 4320 | image = PROP (TOOL_BAR_ITEM_IMAGES); | ||
| 4351 | if (!valid_image_p (image)) | 4321 | if (!valid_image_p (image)) |
| 4352 | { | 4322 | { |
| 4353 | if (wbutton) gtk_widget_hide (wbutton); | 4323 | if (wbutton) gtk_widget_hide (wbutton); |
| @@ -4426,7 +4396,7 @@ update_frame_tool_bar (FRAME_PTR f) | |||
| 4426 | { | 4396 | { |
| 4427 | /* Insert an empty (non-image) button */ | 4397 | /* Insert an empty (non-image) button */ |
| 4428 | ti = xg_make_tool_item (f, NULL, NULL, "", i, 0); | 4398 | ti = xg_make_tool_item (f, NULL, NULL, "", i, 0); |
| 4429 | gtk_toolbar_insert (GTK_TOOLBAR (wtoolbar), ti, -1); | 4399 | gtk_toolbar_insert (GTK_TOOLBAR (wtoolbar), ti, i); |
| 4430 | } | 4400 | } |
| 4431 | continue; | 4401 | continue; |
| 4432 | } | 4402 | } |
| @@ -4460,17 +4430,17 @@ update_frame_tool_bar (FRAME_PTR f) | |||
| 4460 | 4430 | ||
| 4461 | gtk_misc_set_padding (GTK_MISC (w), hmargin, vmargin); | 4431 | gtk_misc_set_padding (GTK_MISC (w), hmargin, vmargin); |
| 4462 | ti = xg_make_tool_item (f, w, &wbutton, label, i, vert_only); | 4432 | ti = xg_make_tool_item (f, w, &wbutton, label, i, vert_only); |
| 4463 | gtk_toolbar_insert (GTK_TOOLBAR (wtoolbar), ti, -1); | 4433 | gtk_toolbar_insert (GTK_TOOLBAR (wtoolbar), ti, i); |
| 4464 | gtk_widget_set_sensitive (wbutton, enabled_p); | 4434 | gtk_widget_set_sensitive (wbutton, enabled_p); |
| 4465 | } | 4435 | } |
| 4466 | else | 4436 | else |
| 4467 | { | 4437 | { |
| 4468 | GtkWidget *vb = gtk_bin_get_child (GTK_BIN (wbutton)); | 4438 | GtkWidget *vb = XG_BIN_CHILD (wbutton); |
| 4469 | GtkWidget *wimage; | 4439 | GtkWidget *wimage; |
| 4470 | GtkWidget *wlbl = xg_get_tool_bar_widgets (vb, &wimage); | 4440 | GtkWidget *wlbl = xg_get_tool_bar_widgets (vb, &wimage); |
| 4471 | 4441 | ||
| 4472 | Pixmap old_img = (Pixmap)g_object_get_data (G_OBJECT (wimage), | 4442 | Pixmap old_img = (Pixmap) g_object_get_data (G_OBJECT (wimage), |
| 4473 | XG_TOOL_BAR_IMAGE_DATA); | 4443 | XG_TOOL_BAR_IMAGE_DATA); |
| 4474 | gpointer old_stock_name = g_object_get_data (G_OBJECT (wimage), | 4444 | gpointer old_stock_name = g_object_get_data (G_OBJECT (wimage), |
| 4475 | XG_TOOL_BAR_STOCK_NAME); | 4445 | XG_TOOL_BAR_STOCK_NAME); |
| 4476 | gpointer old_icon_name = g_object_get_data (G_OBJECT (wimage), | 4446 | gpointer old_icon_name = g_object_get_data (G_OBJECT (wimage), |
diff --git a/src/keyboard.c b/src/keyboard.c index 1023d34ca79..959c57a81e3 100644 --- a/src/keyboard.c +++ b/src/keyboard.c | |||
| @@ -7464,6 +7464,54 @@ static Lisp_Object menu_bar_one_keymap_changed_items; | |||
| 7464 | static Lisp_Object menu_bar_items_vector; | 7464 | static Lisp_Object menu_bar_items_vector; |
| 7465 | static int menu_bar_items_index; | 7465 | static int menu_bar_items_index; |
| 7466 | 7466 | ||
| 7467 | |||
| 7468 | static const char* separator_names[] = { | ||
| 7469 | "space", | ||
| 7470 | "no-line", | ||
| 7471 | "single-line", | ||
| 7472 | "double-line", | ||
| 7473 | "single-dashed-line", | ||
| 7474 | "double-dashed-line", | ||
| 7475 | "shadow-etched-in", | ||
| 7476 | "shadow-etched-out", | ||
| 7477 | "shadow-etched-in-dash", | ||
| 7478 | "shadow-etched-out-dash", | ||
| 7479 | "shadow-double-etched-in", | ||
| 7480 | "shadow-double-etched-out", | ||
| 7481 | "shadow-double-etched-in-dash", | ||
| 7482 | "shadow-double-etched-out-dash", | ||
| 7483 | 0, | ||
| 7484 | }; | ||
| 7485 | |||
| 7486 | /* Return non-zero if LABEL specifies a separator. */ | ||
| 7487 | |||
| 7488 | int | ||
| 7489 | menu_separator_name_p (const char *label) | ||
| 7490 | { | ||
| 7491 | if (!label) | ||
| 7492 | return 0; | ||
| 7493 | else if (strlen (label) > 3 | ||
| 7494 | && strncmp (label, "--", 2) == 0 | ||
| 7495 | && label[2] != '-') | ||
| 7496 | { | ||
| 7497 | int i; | ||
| 7498 | label += 2; | ||
| 7499 | for (i = 0; separator_names[i]; ++i) | ||
| 7500 | if (strcmp (label, separator_names[i]) == 0) | ||
| 7501 | return 1; | ||
| 7502 | } | ||
| 7503 | else | ||
| 7504 | { | ||
| 7505 | /* It's a separator if it contains only dashes. */ | ||
| 7506 | while (*label == '-') | ||
| 7507 | ++label; | ||
| 7508 | return (*label == 0); | ||
| 7509 | } | ||
| 7510 | |||
| 7511 | return 0; | ||
| 7512 | } | ||
| 7513 | |||
| 7514 | |||
| 7467 | /* Return a vector of menu items for a menu bar, appropriate | 7515 | /* Return a vector of menu items for a menu bar, appropriate |
| 7468 | to the current buffer. Each item has three elements in the vector: | 7516 | to the current buffer. Each item has three elements in the vector: |
| 7469 | KEY STRING MAPLIST. | 7517 | KEY STRING MAPLIST. |
| @@ -8201,10 +8249,14 @@ parse_tool_bar_item (Lisp_Object key, Lisp_Object item) | |||
| 8201 | Rule out items that aren't lists, don't start with | 8249 | Rule out items that aren't lists, don't start with |
| 8202 | `menu-item' or whose rest following `tool-bar-item' is not a | 8250 | `menu-item' or whose rest following `tool-bar-item' is not a |
| 8203 | list. */ | 8251 | list. */ |
| 8204 | if (!CONSP (item) | 8252 | if (!CONSP (item)) |
| 8205 | || !EQ (XCAR (item), Qmenu_item) | 8253 | return 0; |
| 8206 | || (item = XCDR (item), | 8254 | |
| 8207 | !CONSP (item))) | 8255 | /* As an exception, allow old-style menu separators. */ |
| 8256 | if (STRINGP (XCAR (item))) | ||
| 8257 | item = Fcons (XCAR (item), Qnil); | ||
| 8258 | else if (!EQ (XCAR (item), Qmenu_item) | ||
| 8259 | || (item = XCDR (item), !CONSP (item))) | ||
| 8208 | return 0; | 8260 | return 0; |
| 8209 | 8261 | ||
| 8210 | /* Create tool_bar_item_properties vector if necessary. Reset it to | 8262 | /* Create tool_bar_item_properties vector if necessary. Reset it to |
| @@ -8234,10 +8286,18 @@ parse_tool_bar_item (Lisp_Object key, Lisp_Object item) | |||
| 8234 | } | 8286 | } |
| 8235 | PROP (TOOL_BAR_ITEM_CAPTION) = caption; | 8287 | PROP (TOOL_BAR_ITEM_CAPTION) = caption; |
| 8236 | 8288 | ||
| 8237 | /* Give up if rest following the caption is not a list. */ | 8289 | /* If the rest following the caption is not a list, the menu item is |
| 8290 | either a separator, or invalid. */ | ||
| 8238 | item = XCDR (item); | 8291 | item = XCDR (item); |
| 8239 | if (!CONSP (item)) | 8292 | if (!CONSP (item)) |
| 8240 | return 0; | 8293 | { |
| 8294 | if (menu_separator_name_p (SDATA (caption))) | ||
| 8295 | { | ||
| 8296 | PROP (TOOL_BAR_ITEM_TYPE) = Qt; | ||
| 8297 | return 1; | ||
| 8298 | } | ||
| 8299 | return 0; | ||
| 8300 | } | ||
| 8241 | 8301 | ||
| 8242 | /* Store the binding. */ | 8302 | /* Store the binding. */ |
| 8243 | PROP (TOOL_BAR_ITEM_BINDING) = XCAR (item); | 8303 | PROP (TOOL_BAR_ITEM_BINDING) = XCAR (item); |
| @@ -8270,10 +8330,10 @@ parse_tool_bar_item (Lisp_Object key, Lisp_Object item) | |||
| 8270 | if (NILP (menu_item_eval_property (value))) | 8330 | if (NILP (menu_item_eval_property (value))) |
| 8271 | return 0; | 8331 | return 0; |
| 8272 | } | 8332 | } |
| 8273 | else if (EQ (key, QChelp)) | 8333 | else if (EQ (key, QChelp)) |
| 8274 | /* `:help HELP-STRING'. */ | 8334 | /* `:help HELP-STRING'. */ |
| 8275 | PROP (TOOL_BAR_ITEM_HELP) = value; | 8335 | PROP (TOOL_BAR_ITEM_HELP) = value; |
| 8276 | else if (EQ (key, QCvert_only)) | 8336 | else if (EQ (key, QCvert_only)) |
| 8277 | /* `:vert-only t/nil'. */ | 8337 | /* `:vert-only t/nil'. */ |
| 8278 | PROP (TOOL_BAR_ITEM_VERT_ONLY) = value; | 8338 | PROP (TOOL_BAR_ITEM_VERT_ONLY) = value; |
| 8279 | else if (EQ (key, QClabel)) | 8339 | else if (EQ (key, QClabel)) |
diff --git a/src/keyboard.h b/src/keyboard.h index 7f36691a5a3..d103950fb2b 100644 --- a/src/keyboard.h +++ b/src/keyboard.h | |||
| @@ -492,6 +492,7 @@ extern int quit_char; | |||
| 492 | 492 | ||
| 493 | extern int timers_run; | 493 | extern int timers_run; |
| 494 | 494 | ||
| 495 | extern int menu_separator_name_p (const char *); | ||
| 495 | extern int parse_menu_item (Lisp_Object, int); | 496 | extern int parse_menu_item (Lisp_Object, int); |
| 496 | 497 | ||
| 497 | extern void echo_now (void); | 498 | extern void echo_now (void); |
diff --git a/src/nsmenu.m b/src/nsmenu.m index 973f2c15e2f..95f651f6690 100644 --- a/src/nsmenu.m +++ b/src/nsmenu.m | |||
| @@ -507,21 +507,6 @@ set_frame_menubar (struct frame *f, int first_time, int deep_p) | |||
| 507 | } | 507 | } |
| 508 | 508 | ||
| 509 | 509 | ||
| 510 | /* Utility (from macmenu.c): is this item a separator? */ | ||
| 511 | static int | ||
| 512 | name_is_separator ( const char *name) | ||
| 513 | { | ||
| 514 | const char *start = name; | ||
| 515 | |||
| 516 | /* Check if name string consists of only dashes ('-'). */ | ||
| 517 | while (*name == '-') name++; | ||
| 518 | /* Separators can also be of the form "--:TripleSuperMegaEtched" | ||
| 519 | or "--deep-shadow". We don't implement them yet, se we just treat | ||
| 520 | them like normal separators. */ | ||
| 521 | return (*name == '\0' || start + 2 == name); | ||
| 522 | } | ||
| 523 | |||
| 524 | |||
| 525 | /* ========================================================================== | 510 | /* ========================================================================== |
| 526 | 511 | ||
| 527 | Menu: class implementation | 512 | Menu: class implementation |
| @@ -624,7 +609,7 @@ name_is_separator ( const char *name) | |||
| 624 | NSMenuItem *item; | 609 | NSMenuItem *item; |
| 625 | widget_value *wv = (widget_value *)wvptr; | 610 | widget_value *wv = (widget_value *)wvptr; |
| 626 | 611 | ||
| 627 | if (name_is_separator (wv->name)) | 612 | if (menu_separator_name_p (wv->name)) |
| 628 | { | 613 | { |
| 629 | item = [NSMenuItem separatorItem]; | 614 | item = [NSMenuItem separatorItem]; |
| 630 | [self addItem: item]; | 615 | [self addItem: item]; |
diff --git a/src/w32menu.c b/src/w32menu.c index ff6bd977bea..1e700201bf2 100644 --- a/src/w32menu.c +++ b/src/w32menu.c | |||
| @@ -1326,20 +1326,6 @@ simple_dialog_show (FRAME_PTR f, Lisp_Object contents, Lisp_Object header) | |||
| 1326 | #endif /* !HAVE_DIALOGS */ | 1326 | #endif /* !HAVE_DIALOGS */ |
| 1327 | 1327 | ||
| 1328 | 1328 | ||
| 1329 | /* Is this item a separator? */ | ||
| 1330 | static int | ||
| 1331 | name_is_separator (const char *name) | ||
| 1332 | { | ||
| 1333 | const char *start = name; | ||
| 1334 | |||
| 1335 | /* Check if name string consists of only dashes ('-'). */ | ||
| 1336 | while (*name == '-') name++; | ||
| 1337 | /* Separators can also be of the form "--:TripleSuperMegaEtched" | ||
| 1338 | or "--deep-shadow". We don't implement them yet, se we just treat | ||
| 1339 | them like normal separators. */ | ||
| 1340 | return (*name == '\0' || start + 2 == name); | ||
| 1341 | } | ||
| 1342 | |||
| 1343 | /* UTF8: 0xxxxxxx, 110xxxxx 10xxxxxx, 1110xxxx, 10xxxxxx, 10xxxxxx */ | 1329 | /* UTF8: 0xxxxxxx, 110xxxxx 10xxxxxx, 1110xxxx, 10xxxxxx, 10xxxxxx */ |
| 1344 | static void | 1330 | static void |
| 1345 | utf8to16 (unsigned char * src, int len, WCHAR * dest) | 1331 | utf8to16 (unsigned char * src, int len, WCHAR * dest) |
| @@ -1388,7 +1374,7 @@ add_menu_item (HMENU menu, widget_value *wv, HMENU item) | |||
| 1388 | int return_value; | 1374 | int return_value; |
| 1389 | size_t nlen, orig_len; | 1375 | size_t nlen, orig_len; |
| 1390 | 1376 | ||
| 1391 | if (name_is_separator (wv->name)) | 1377 | if (menu_separator_name_p (wv->name)) |
| 1392 | { | 1378 | { |
| 1393 | fuFlags = MF_SEPARATOR; | 1379 | fuFlags = MF_SEPARATOR; |
| 1394 | out_string = NULL; | 1380 | out_string = NULL; |
diff --git a/src/xdisp.c b/src/xdisp.c index 1c220647ba9..41204e0a5b4 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -10317,6 +10317,10 @@ build_desired_tool_bar_string (struct frame *f) | |||
| 10317 | int selected_p = !NILP (PROP (TOOL_BAR_ITEM_SELECTED_P)); | 10317 | int selected_p = !NILP (PROP (TOOL_BAR_ITEM_SELECTED_P)); |
| 10318 | int hmargin, vmargin, relief, idx, end; | 10318 | int hmargin, vmargin, relief, idx, end; |
| 10319 | 10319 | ||
| 10320 | /* Ignore separator items. */ | ||
| 10321 | if (EQ (PROP (TOOL_BAR_ITEM_TYPE), Qt)) | ||
| 10322 | continue; | ||
| 10323 | |||
| 10320 | /* If image is a vector, choose the image according to the | 10324 | /* If image is a vector, choose the image according to the |
| 10321 | button state. */ | 10325 | button state. */ |
| 10322 | image = PROP (TOOL_BAR_ITEM_IMAGES); | 10326 | image = PROP (TOOL_BAR_ITEM_IMAGES); |