comparison src/xmenu.c @ 56846:5817080daeba

* xmenu.c (digest_single_submenu): Set lname and lkey in widget_value instead of name and key. (update_submenu_strings): New function. (set_frame_menubar): Remove call to inhibit_garbage_collection, call update_submenu_strings. Call ENCODE_MENU_STRING for top level menu names. * gtkutil.h (_widget_value): Added lname and lkey.
author Jan Djärv <jan.h.d@swipnet.se>
date Mon, 30 Aug 2004 19:42:53 +0000
parents 27ebdb6b3098
children 6079dd23b546
comparison
equal deleted inserted replaced
56845:8a28788cef84 56846:5817080daeba
1699 wv = xmalloc_widget_value (); 1699 wv = xmalloc_widget_value ();
1700 if (save_wv) 1700 if (save_wv)
1701 save_wv->next = wv; 1701 save_wv->next = wv;
1702 else 1702 else
1703 first_wv->contents = wv; 1703 first_wv->contents = wv;
1704 wv->name = pane_string; 1704 wv->lname = pane_name;
1705 /* Ignore the @ that means "separate pane". 1705 /* Set value to 1 so update_submenu_strings can handle '@' */
1706 This is a kludge, but this isn't worth more time. */ 1706 wv->value = (char *)1;
1707 if (!NILP (prefix) && wv->name[0] == '@')
1708 wv->name++;
1709 wv->value = 0;
1710 wv->enabled = 1; 1707 wv->enabled = 1;
1711 wv->button_type = BUTTON_TYPE_NONE; 1708 wv->button_type = BUTTON_TYPE_NONE;
1712 wv->help = Qnil; 1709 wv->help = Qnil;
1713 } 1710 }
1714 save_wv = wv; 1711 save_wv = wv;
1747 if (prev_wv) 1744 if (prev_wv)
1748 prev_wv->next = wv; 1745 prev_wv->next = wv;
1749 else 1746 else
1750 save_wv->contents = wv; 1747 save_wv->contents = wv;
1751 1748
1752 wv->name = (char *) SDATA (item_name); 1749 wv->lname = item_name;
1753 if (!NILP (descrip)) 1750 if (!NILP (descrip))
1754 wv->key = (char *) SDATA (descrip); 1751 wv->lkey = descrip;
1755 wv->value = 0; 1752 wv->value = 0;
1756 /* The EMACS_INT cast avoids a warning. There's no problem 1753 /* The EMACS_INT cast avoids a warning. There's no problem
1757 as long as pointers have enough bits to hold small integers. */ 1754 as long as pointers have enough bits to hold small integers. */
1758 wv->call_data = (!NILP (def) ? (void *) (EMACS_INT) i : 0); 1755 wv->call_data = (!NILP (def) ? (void *) (EMACS_INT) i : 0);
1759 wv->enabled = !NILP (enable); 1756 wv->enabled = !NILP (enable);
1788 return wv; 1785 return wv;
1789 } 1786 }
1790 1787
1791 return first_wv; 1788 return first_wv;
1792 } 1789 }
1790
1791 /* Walk through thw widget_value tree starting at FIRST_WV and update
1792 the char * pointers from the corresponding lisp values.
1793 We do this after building the whole tree, since GC may happen while the
1794 tree is constructed, and small strings are relocated. So we must wait
1795 until no GC can happen before storing pointers into lisp values. */
1796 static void
1797 update_submenu_strings (first_wv)
1798 widget_value *first_wv;
1799 {
1800 widget_value *wv;
1801
1802 for (wv = first_wv; wv; wv = wv->next)
1803 {
1804 if (wv->lname && ! NILP (wv->lname))
1805 {
1806 wv->name = SDATA (wv->lname);
1807
1808 /* Ignore the @ that means "separate pane".
1809 This is a kludge, but this isn't worth more time. */
1810 if (wv->value == (char *)1)
1811 {
1812 if (wv->name[0] == '@')
1813 wv->name++;
1814 wv->value = 0;
1815 }
1816 }
1817
1818 if (wv->lkey && ! NILP (wv->lkey))
1819 wv->key = SDATA (wv->lkey);
1820
1821 if (wv->contents)
1822 update_submenu_strings (wv->contents);
1823 }
1824 }
1825
1793 1826
1794 /* Recompute all the widgets of frame F, when the menu bar has been 1827 /* Recompute all the widgets of frame F, when the menu bar has been
1795 changed. Value is non-zero if widgets were updated. */ 1828 changed. Value is non-zero if widgets were updated. */
1796 1829
1797 static int 1830 static int
1928 call0 (Qrecompute_lucid_menubar); 1961 call0 (Qrecompute_lucid_menubar);
1929 safe_run_hooks (Qmenu_bar_update_hook); 1962 safe_run_hooks (Qmenu_bar_update_hook);
1930 FRAME_MENU_BAR_ITEMS (f) = menu_bar_items (FRAME_MENU_BAR_ITEMS (f)); 1963 FRAME_MENU_BAR_ITEMS (f) = menu_bar_items (FRAME_MENU_BAR_ITEMS (f));
1931 1964
1932 items = FRAME_MENU_BAR_ITEMS (f); 1965 items = FRAME_MENU_BAR_ITEMS (f);
1933 inhibit_garbage_collection ();
1934 1966
1935 /* Save the frame's previous menu bar contents data. */ 1967 /* Save the frame's previous menu bar contents data. */
1936 if (previous_menu_items_used) 1968 if (previous_menu_items_used)
1937 bcopy (XVECTOR (f->menu_bar_vector)->contents, previous_items, 1969 bcopy (XVECTOR (f->menu_bar_vector)->contents, previous_items,
1938 previous_menu_items_used * sizeof (Lisp_Object)); 1970 previous_menu_items_used * sizeof (Lisp_Object));
2021 for (i = 0; i < XVECTOR (items)->size; i += 4) 2053 for (i = 0; i < XVECTOR (items)->size; i += 4)
2022 { 2054 {
2023 Lisp_Object string; 2055 Lisp_Object string;
2024 string = XVECTOR (items)->contents[i + 1]; 2056 string = XVECTOR (items)->contents[i + 1];
2025 if (NILP (string)) 2057 if (NILP (string))
2026 break; 2058 break;
2027 wv->name = (char *) SDATA (string); 2059 wv->name = (char *) SDATA (ENCODE_MENU_STRING (string));
2028 wv = wv->next; 2060 update_submenu_strings (wv->contents);
2061 wv = wv->next;
2029 } 2062 }
2030 2063
2031 f->menu_bar_vector = menu_items; 2064 f->menu_bar_vector = menu_items;
2032 f->menu_bar_items_used = menu_items_used; 2065 f->menu_bar_items_used = menu_items_used;
2033 discard_menu_items (); 2066 discard_menu_items ();
2053 string = XVECTOR (items)->contents[i + 1]; 2086 string = XVECTOR (items)->contents[i + 1];
2054 if (NILP (string)) 2087 if (NILP (string))
2055 break; 2088 break;
2056 2089
2057 wv = xmalloc_widget_value (); 2090 wv = xmalloc_widget_value ();
2058 wv->name = (char *) SDATA (string); 2091 wv->name = (char *) SDATA (ENCODE_MENU_STRING (string));
2059 wv->value = 0; 2092 wv->value = 0;
2060 wv->enabled = 1; 2093 wv->enabled = 1;
2061 wv->button_type = BUTTON_TYPE_NONE; 2094 wv->button_type = BUTTON_TYPE_NONE;
2062 wv->help = Qnil; 2095 wv->help = Qnil;
2063 /* This prevents lwlib from assuming this 2096 /* This prevents lwlib from assuming this