1576 |
GtkWidget *wcont; |
GtkWidget *wcont; |
1577 |
GList *list; |
GList *list; |
1578 |
{ |
{ |
|
/* We must copy list because gtk_container_remove changes it. */ |
|
|
GList *clist = g_list_copy (list); |
|
1579 |
GList *iter; |
GList *iter; |
1580 |
|
|
1581 |
for (iter = clist; iter; iter = g_list_next (iter)) |
for (iter = list; iter; iter = g_list_next (iter)) |
1582 |
{ |
{ |
1583 |
GtkWidget *w = GTK_WIDGET (iter->data); |
GtkWidget *w = GTK_WIDGET (iter->data); |
1584 |
|
|
1593 |
removing the detached window also if there was one. */ |
removing the detached window also if there was one. */ |
1594 |
gtk_widget_destroy (w); |
gtk_widget_destroy (w); |
1595 |
} |
} |
|
g_list_free (clist); |
|
1596 |
} |
} |
1597 |
|
|
1598 |
/* Update the top level names in MENUBAR (i.e. not submenus). |
/* Update the top level names in MENUBAR (i.e. not submenus). |
1599 |
F is the frame the menu bar belongs to. |
F is the frame the menu bar belongs to. |
1600 |
LIST is a list with the current menu bar names (menu item widgets). |
*LIST is a list with the current menu bar names (menu item widgets). |
1601 |
|
ITER is the item within *LIST that shall be updated. |
1602 |
|
POS is the numerical position, starting at 0, of ITER in *LIST. |
1603 |
VAL describes what the menu bar shall look like after the update. |
VAL describes what the menu bar shall look like after the update. |
1604 |
SELECT_CB is the callback to use when a menu item is selected. |
SELECT_CB is the callback to use when a menu item is selected. |
1605 |
HIGHLIGHT_CB is the callback to call when entering/leaving menu items. |
HIGHLIGHT_CB is the callback to call when entering/leaving menu items. |
1606 |
|
CL_DATA points to the callback data to be used for this menu bar. |
1607 |
|
|
1608 |
This function calls itself to walk through the menu bar names. */ |
This function calls itself to walk through the menu bar names. */ |
1609 |
static void |
static void |
1610 |
xg_update_menubar (menubar, f, list, val, select_cb, highlight_cb, cl_data) |
xg_update_menubar (menubar, f, list, iter, pos, val, |
1611 |
|
select_cb, highlight_cb, cl_data) |
1612 |
GtkWidget *menubar; |
GtkWidget *menubar; |
1613 |
FRAME_PTR f; |
FRAME_PTR f; |
1614 |
GList *list; |
GList **list; |
1615 |
|
GList *iter; |
1616 |
|
int pos; |
1617 |
widget_value *val; |
widget_value *val; |
1618 |
GCallback select_cb; |
GCallback select_cb; |
1619 |
GCallback highlight_cb; |
GCallback highlight_cb; |
1620 |
xg_menu_cb_data *cl_data; |
xg_menu_cb_data *cl_data; |
1621 |
{ |
{ |
1622 |
if (! list && ! val) |
if (! iter && ! val) |
1623 |
return; |
return; |
1624 |
else if (list && ! val) |
else if (iter && ! val) |
1625 |
{ |
{ |
1626 |
/* Item(s) have been removed. Remove all remaining items from list. */ |
/* Item(s) have been removed. Remove all remaining items. */ |
1627 |
remove_from_container (menubar, list); |
remove_from_container (menubar, iter); |
1628 |
|
|
1629 |
/* All updated. */ |
/* All updated. */ |
1630 |
val = 0; |
val = 0; |
1631 |
list = 0; |
iter = 0; |
1632 |
} |
} |
1633 |
else if (! list && val) |
else if (! iter && val) |
1634 |
{ |
{ |
1635 |
/* Item(s) added. Add all new items in one call. */ |
/* Item(s) added. Add all new items in one call. */ |
1636 |
create_menus (val, f, select_cb, 0, highlight_cb, |
create_menus (val, f, select_cb, 0, highlight_cb, |
1638 |
|
|
1639 |
/* All updated. */ |
/* All updated. */ |
1640 |
val = 0; |
val = 0; |
1641 |
list = 0; |
iter = 0; |
1642 |
} |
} |
1643 |
/* Below this neither list or val is NULL */ |
/* Below this neither iter or val is NULL */ |
1644 |
else if (xg_item_label_same_p (GTK_MENU_ITEM (list->data), val->name)) |
else if (xg_item_label_same_p (GTK_MENU_ITEM (iter->data), val->name)) |
1645 |
{ |
{ |
1646 |
/* This item is still the same, check next item. */ |
/* This item is still the same, check next item. */ |
1647 |
val = val->next; |
val = val->next; |
1648 |
list = g_list_next (list); |
iter = g_list_next (iter); |
1649 |
|
++pos; |
1650 |
} |
} |
1651 |
else /* This item is changed. */ |
else /* This item is changed. */ |
1652 |
{ |
{ |
1653 |
GtkMenuItem *witem = GTK_MENU_ITEM (list->data); |
GtkMenuItem *witem = GTK_MENU_ITEM (iter->data); |
1654 |
GtkMenuItem *witem2 = 0; |
GtkMenuItem *witem2 = 0; |
|
int pos = 0; |
|
1655 |
int val_in_menubar = 0; |
int val_in_menubar = 0; |
1656 |
int list_in_new_menubar = 0; |
int iter_in_new_menubar = 0; |
1657 |
GList *list2; |
GList *iter2; |
|
GList *iter; |
|
1658 |
widget_value *cur; |
widget_value *cur; |
1659 |
|
|
|
|
|
|
/* Get position number for witem. */ |
|
|
list2 = gtk_container_get_children (GTK_CONTAINER (menubar)); |
|
|
for (iter = list2; iter; iter = g_list_next (iter)) |
|
|
{ |
|
|
if (list->data == iter->data) break; |
|
|
++pos; |
|
|
} |
|
|
|
|
1660 |
/* See if the changed entry (val) is present later in the menu bar */ |
/* See if the changed entry (val) is present later in the menu bar */ |
1661 |
for (iter = g_list_next (list); |
for (iter2 = iter; |
1662 |
iter && ! val_in_menubar; |
iter2 && ! val_in_menubar; |
1663 |
iter = g_list_next (iter)) |
iter2 = g_list_next (iter2)) |
1664 |
{ |
{ |
1665 |
witem2 = GTK_MENU_ITEM (iter->data); |
witem2 = GTK_MENU_ITEM (iter2->data); |
1666 |
val_in_menubar = xg_item_label_same_p (witem2, val->name); |
val_in_menubar = xg_item_label_same_p (witem2, val->name); |
1667 |
} |
} |
1668 |
|
|
1669 |
/* See if the current entry (list) is present later in the |
/* See if the current entry (iter) is present later in the |
1670 |
specification for the new menu bar. */ |
specification for the new menu bar. */ |
1671 |
for (cur = val; cur && ! list_in_new_menubar; cur = cur->next) |
for (cur = val; cur && ! iter_in_new_menubar; cur = cur->next) |
1672 |
list_in_new_menubar = xg_item_label_same_p (witem, cur->name); |
iter_in_new_menubar = xg_item_label_same_p (witem, cur->name); |
1673 |
|
|
1674 |
if (val_in_menubar && ! list_in_new_menubar) |
if (val_in_menubar && ! iter_in_new_menubar) |
1675 |
{ |
{ |
1676 |
|
int nr = pos; |
1677 |
|
|
1678 |
/* This corresponds to: |
/* This corresponds to: |
1679 |
Current: A B C |
Current: A B C |
1680 |
New: A C |
New: A C |
1685 |
gtk_widget_destroy (GTK_WIDGET (witem)); |
gtk_widget_destroy (GTK_WIDGET (witem)); |
1686 |
|
|
1687 |
/* Must get new list since the old changed. */ |
/* Must get new list since the old changed. */ |
1688 |
list = gtk_container_get_children (GTK_CONTAINER (menubar)); |
g_list_free (*list); |
1689 |
while (pos-- > 0) list = g_list_next (list); |
*list = iter = gtk_container_get_children (GTK_CONTAINER (menubar)); |
1690 |
|
while (nr-- > 0) iter = g_list_next (iter); |
1691 |
} |
} |
1692 |
else if (! val_in_menubar && ! list_in_new_menubar) |
else if (! val_in_menubar && ! iter_in_new_menubar) |
1693 |
{ |
{ |
1694 |
/* This corresponds to: |
/* This corresponds to: |
1695 |
Current: A B C |
Current: A B C |
1710 |
|
|
1711 |
gtk_label_set_text_with_mnemonic (wlabel, utf8_label); |
gtk_label_set_text_with_mnemonic (wlabel, utf8_label); |
1712 |
|
|
1713 |
list = g_list_next (list); |
iter = g_list_next (iter); |
1714 |
val = val->next; |
val = val->next; |
1715 |
|
++pos; |
1716 |
} |
} |
1717 |
else if (! val_in_menubar && list_in_new_menubar) |
else if (! val_in_menubar && iter_in_new_menubar) |
1718 |
{ |
{ |
1719 |
/* This corresponds to: |
/* This corresponds to: |
1720 |
Current: A B C |
Current: A B C |
1721 |
New: A X B C |
New: A X B C |
1722 |
Insert X. */ |
Insert X. */ |
1723 |
|
|
1724 |
|
int nr = pos; |
1725 |
GList *group = 0; |
GList *group = 0; |
1726 |
GtkWidget *w = xg_create_one_menuitem (val, |
GtkWidget *w = xg_create_one_menuitem (val, |
1727 |
f, |
f, |
1733 |
gtk_widget_set_name (w, MENU_ITEM_NAME); |
gtk_widget_set_name (w, MENU_ITEM_NAME); |
1734 |
gtk_menu_shell_insert (GTK_MENU_SHELL (menubar), w, pos); |
gtk_menu_shell_insert (GTK_MENU_SHELL (menubar), w, pos); |
1735 |
|
|
1736 |
list = gtk_container_get_children (GTK_CONTAINER (menubar)); |
g_list_free (*list); |
1737 |
while (pos-- > 0) list = g_list_next (list); |
*list = iter = gtk_container_get_children (GTK_CONTAINER (menubar)); |
1738 |
list = g_list_next (list); |
while (nr-- > 0) iter = g_list_next (iter); |
1739 |
|
iter = g_list_next (iter); |
1740 |
val = val->next; |
val = val->next; |
1741 |
|
++pos; |
1742 |
} |
} |
1743 |
else /* if (val_in_menubar && list_in_new_menubar) */ |
else /* if (val_in_menubar && iter_in_new_menubar) */ |
1744 |
{ |
{ |
1745 |
|
int nr = pos; |
1746 |
/* This corresponds to: |
/* This corresponds to: |
1747 |
Current: A B C |
Current: A B C |
1748 |
New: A C B |
New: A C B |
1754 |
GTK_WIDGET (witem2), pos); |
GTK_WIDGET (witem2), pos); |
1755 |
gtk_widget_unref (GTK_WIDGET (witem2)); |
gtk_widget_unref (GTK_WIDGET (witem2)); |
1756 |
|
|
1757 |
|
g_list_free (*list); |
1758 |
|
*list = iter = gtk_container_get_children (GTK_CONTAINER (menubar)); |
1759 |
|
while (nr-- > 0) iter = g_list_next (iter); |
1760 |
val = val->next; |
val = val->next; |
1761 |
list = gtk_container_get_children (GTK_CONTAINER (menubar)); |
++pos; |
|
while (pos-- > 0) list = g_list_next (list); |
|
|
list = g_list_next (list); |
|
1762 |
} |
} |
|
|
|
1763 |
} |
} |
1764 |
|
|
1765 |
/* Update the rest of the menu bar. */ |
/* Update the rest of the menu bar. */ |
1766 |
xg_update_menubar (menubar, f, list, val, select_cb, highlight_cb, cl_data); |
xg_update_menubar (menubar, f, list, iter, pos, val, |
1767 |
|
select_cb, highlight_cb, cl_data); |
1768 |
} |
} |
1769 |
|
|
1770 |
/* Update the menu item W so it corresponds to VAL. |
/* Update the menu item W so it corresponds to VAL. |
1799 |
|
|
1800 |
wlbl = GTK_LABEL (list->data); |
wlbl = GTK_LABEL (list->data); |
1801 |
wkey = GTK_LABEL (list->next->data); |
wkey = GTK_LABEL (list->next->data); |
1802 |
|
g_list_free (list); |
1803 |
|
|
1804 |
if (! utf8_key) |
if (! utf8_key) |
1805 |
{ |
{ |
1806 |
/* Remove the key and keep just the label. */ |
/* Remove the key and keep just the label. */ |
1809 |
gtk_container_add (GTK_CONTAINER (w), GTK_WIDGET (wlbl)); |
gtk_container_add (GTK_CONTAINER (w), GTK_WIDGET (wlbl)); |
1810 |
wkey = 0; |
wkey = 0; |
1811 |
} |
} |
1812 |
|
|
1813 |
} |
} |
1814 |
else /* Just a label. */ |
else /* Just a label. */ |
1815 |
{ |
{ |
1820 |
{ |
{ |
1821 |
GtkWidget *wtoadd = make_widget_for_menu_item (utf8_label, utf8_key); |
GtkWidget *wtoadd = make_widget_for_menu_item (utf8_label, utf8_key); |
1822 |
GList *list = gtk_container_get_children (GTK_CONTAINER (wtoadd)); |
GList *list = gtk_container_get_children (GTK_CONTAINER (wtoadd)); |
1823 |
|
|
1824 |
wlbl = GTK_LABEL (list->data); |
wlbl = GTK_LABEL (list->data); |
1825 |
wkey = GTK_LABEL (list->next->data); |
wkey = GTK_LABEL (list->next->data); |
1826 |
|
g_list_free (list); |
1827 |
|
|
1828 |
gtk_container_remove (GTK_CONTAINER (w), wchild); |
gtk_container_remove (GTK_CONTAINER (w), wchild); |
1829 |
gtk_container_add (GTK_CONTAINER (w), wtoadd); |
gtk_container_add (GTK_CONTAINER (w), wtoadd); |
2063 |
0); |
0); |
2064 |
} |
} |
2065 |
|
|
2066 |
|
if (list) g_list_free (list); |
2067 |
|
|
2068 |
return newsub; |
return newsub; |
2069 |
} |
} |
2070 |
|
|
2089 |
{ |
{ |
2090 |
xg_menu_cb_data *cl_data; |
xg_menu_cb_data *cl_data; |
2091 |
GList *list = gtk_container_get_children (GTK_CONTAINER (menubar)); |
GList *list = gtk_container_get_children (GTK_CONTAINER (menubar)); |
|
GList *iter; |
|
2092 |
|
|
2093 |
if (! list) return; |
if (! list) return; |
2094 |
|
|
2098 |
if (! deep_p) |
if (! deep_p) |
2099 |
{ |
{ |
2100 |
widget_value *cur = val->contents; |
widget_value *cur = val->contents; |
2101 |
xg_update_menubar (menubar, f, list, cur, |
xg_update_menubar (menubar, f, &list, list, 0, cur, |
2102 |
select_cb, highlight_cb, cl_data); |
select_cb, highlight_cb, cl_data); |
2103 |
} |
} |
2104 |
else |
else |
2114 |
|
|
2115 |
for (cur = val->contents; cur; cur = cur->next) |
for (cur = val->contents; cur; cur = cur->next) |
2116 |
{ |
{ |
2117 |
|
GList *iter; |
2118 |
GtkWidget *sub = 0; |
GtkWidget *sub = 0; |
2119 |
GtkWidget *newsub; |
GtkWidget *newsub; |
2120 |
GtkMenuItem *witem; |
GtkMenuItem *witem; |
2146 |
} |
} |
2147 |
} |
} |
2148 |
|
|
2149 |
|
g_list_free (list); |
2150 |
gtk_widget_show_all (menubar); |
gtk_widget_show_all (menubar); |
2151 |
} |
} |
2152 |
|
|
2434 |
int width; |
int width; |
2435 |
int height; |
int height; |
2436 |
{ |
{ |
|
GtkWidget *wscroll = xg_get_widget_from_map (scrollbar_id); |
|
2437 |
|
|
2438 |
if (wscroll) |
GtkWidget *wscroll = xg_get_widget_from_map (scrollbar_id); |
|
{ |
|
|
int gheight = max (height, 1); |
|
2439 |
|
|
2440 |
gtk_fixed_move (GTK_FIXED (f->output_data.x->edit_widget), |
if (wscroll) |
2441 |
wscroll, left, top); |
{ |
2442 |
|
int gheight = max (height, 1); |
2443 |
|
|
2444 |
gtk_widget_set_size_request (wscroll, width, gheight); |
gtk_fixed_move (GTK_FIXED (f->output_data.x->edit_widget), |
2445 |
|
wscroll, left, top); |
2446 |
|
|
2447 |
/* Must force out update so wscroll gets the resize. |
gtk_widget_set_size_request (wscroll, width, gheight); |
|
Otherwise, the gdk_window_clear clears the old window size. */ |
|
|
gdk_window_process_all_updates (); |
|
2448 |
|
|
2449 |
/* The scroll bar doesn't explicitly redraw the whole window |
/* Must force out update so wscroll gets the resize. |
2450 |
when a resize occurs. Since the scroll bar seems to be fixed |
Otherwise, the gdk_window_clear clears the old window size. */ |
2451 |
in width it doesn't fill the space reserved, so we must clear |
gdk_window_process_all_updates (); |
|
the whole window. */ |
|
|
gdk_window_clear (wscroll->window); |
|
2452 |
|
|
2453 |
/* Since we are not using a pure gtk event loop, we must force out |
/* The scroll bar doesn't explicitly redraw the whole window |
2454 |
pending update events with this call. */ |
when a resize occurs. Since the scroll bar seems to be fixed |
2455 |
gdk_window_process_all_updates (); |
in width it doesn't fill the space reserved, so we must clear |
2456 |
|
the whole window. */ |
2457 |
|
gdk_window_clear (wscroll->window); |
2458 |
|
|
2459 |
SET_FRAME_GARBAGED (f); |
/* Since we are not using a pure gtk event loop, we must force out |
2460 |
cancel_mouse_face (f); |
pending update events with this call. */ |
2461 |
} |
gdk_window_process_all_updates (); |
2462 |
|
|
2463 |
|
SET_FRAME_GARBAGED (f); |
2464 |
|
cancel_mouse_face (f); |
2465 |
|
} |
2466 |
} |
} |
2467 |
|
|
2468 |
/* Set the thumb size and position of scroll bar BAR. We are currently |
/* Set the thumb size and position of scroll bar BAR. We are currently |
2709 |
int i; |
int i; |
2710 |
GtkRequisition old_req, new_req; |
GtkRequisition old_req, new_req; |
2711 |
GList *icon_list; |
GList *icon_list; |
2712 |
|
GList *iter; |
2713 |
struct x_output *x = f->output_data.x; |
struct x_output *x = f->output_data.x; |
2714 |
|
|
2715 |
if (! FRAME_GTK_WIDGET (f)) |
if (! FRAME_GTK_WIDGET (f)) |
2723 |
gtk_widget_size_request (x->toolbar_widget, &old_req); |
gtk_widget_size_request (x->toolbar_widget, &old_req); |
2724 |
|
|
2725 |
icon_list = gtk_container_get_children (GTK_CONTAINER (x->toolbar_widget)); |
icon_list = gtk_container_get_children (GTK_CONTAINER (x->toolbar_widget)); |
2726 |
|
iter = icon_list; |
2727 |
|
|
2728 |
for (i = 0; i < f->n_tool_bar_items; ++i) |
for (i = 0; i < f->n_tool_bar_items; ++i) |
2729 |
{ |
{ |
2730 |
#define PROP(IDX) AREF (f->tool_bar_items, i * TOOL_BAR_ITEM_NSLOTS + (IDX)) |
#define PROP(IDX) AREF (f->tool_bar_items, i * TOOL_BAR_ITEM_NSLOTS + (IDX)) |
2735 |
int img_id; |
int img_id; |
2736 |
struct image *img; |
struct image *img; |
2737 |
Lisp_Object image; |
Lisp_Object image; |
2738 |
GtkWidget *wicon = icon_list ? GTK_WIDGET (icon_list->data) : 0; |
GtkWidget *wicon = iter ? GTK_WIDGET (iter->data) : 0; |
2739 |
|
|
2740 |
if (icon_list) icon_list = g_list_next (icon_list); |
if (iter) iter = g_list_next (iter); |
2741 |
|
|
2742 |
/* If image is a vector, choose the image according to the |
/* If image is a vector, choose the image according to the |
2743 |
button state. */ |
button state. */ |
2825 |
/* The child of the tool bar is a button. Inside that button |
/* The child of the tool bar is a button. Inside that button |
2826 |
is a vbox. Inside that vbox is the GtkImage. */ |
is a vbox. Inside that vbox is the GtkImage. */ |
2827 |
GtkWidget *wvbox = gtk_bin_get_child (GTK_BIN (wicon)); |
GtkWidget *wvbox = gtk_bin_get_child (GTK_BIN (wicon)); |
2828 |
GList *ch = gtk_container_get_children (GTK_CONTAINER (wvbox)); |
GList *chlist = gtk_container_get_children (GTK_CONTAINER (wvbox)); |
2829 |
GtkImage *wimage = GTK_IMAGE (ch->data); |
GtkImage *wimage = GTK_IMAGE (chlist->data); |
2830 |
struct image *old_img = g_object_get_data (G_OBJECT (wimage), |
struct image *old_img = g_object_get_data (G_OBJECT (wimage), |
2831 |
XG_TOOL_BAR_IMAGE_DATA); |
XG_TOOL_BAR_IMAGE_DATA); |
2832 |
|
g_list_free (chlist); |
2833 |
|
|
2834 |
if (! old_img |
if (! old_img |
2835 |
|| old_img->pixmap != img->pixmap |
|| old_img->pixmap != img->pixmap |
2854 |
|
|
2855 |
/* Remove buttons not longer needed. We just hide them so they |
/* Remove buttons not longer needed. We just hide them so they |
2856 |
can be reused later on. */ |
can be reused later on. */ |
2857 |
while (icon_list) |
while (iter) |
2858 |
{ |
{ |
2859 |
GtkWidget *w = GTK_WIDGET (icon_list->data); |
GtkWidget *w = GTK_WIDGET (iter->data); |
2860 |
gtk_widget_hide (w); |
gtk_widget_hide (w); |
2861 |
icon_list = g_list_next (icon_list); |
iter = g_list_next (iter); |
2862 |
} |
} |
2863 |
|
|
2864 |
gtk_widget_size_request (x->toolbar_widget, &new_req); |
gtk_widget_size_request (x->toolbar_widget, &new_req); |
2871 |
/* Must force out update so changed images gets redrawn. */ |
/* Must force out update so changed images gets redrawn. */ |
2872 |
gdk_window_process_all_updates (); |
gdk_window_process_all_updates (); |
2873 |
|
|
2874 |
|
if (icon_list) g_list_free (icon_list); |
2875 |
|
|
2876 |
UNBLOCK_INPUT; |
UNBLOCK_INPUT; |
2877 |
} |
} |
2878 |
|
|