48 |
#ifdef HAVE_GTK_MULTIDISPLAY |
#ifdef HAVE_GTK_MULTIDISPLAY |
49 |
|
|
50 |
/* Return the GdkDisplay that corresponds to the X display DPY. */ |
/* Return the GdkDisplay that corresponds to the X display DPY. */ |
51 |
|
|
52 |
static GdkDisplay * |
static GdkDisplay * |
53 |
xg_get_gdk_display (dpy) |
xg_get_gdk_display (dpy) |
54 |
Display *dpy; |
Display *dpy; |
59 |
/* When the GTK widget W is to be created on a display for F that |
/* When the GTK widget W is to be created on a display for F that |
60 |
is not the default display, set the display for W. |
is not the default display, set the display for W. |
61 |
W can be a GtkMenu or a GtkWindow widget. */ |
W can be a GtkMenu or a GtkWindow widget. */ |
62 |
|
|
63 |
static void |
static void |
64 |
xg_set_screen (w, f) |
xg_set_screen (w, f) |
65 |
GtkWidget *w; |
GtkWidget *w; |
82 |
|
|
83 |
/* Make some defines so we can use the GTK 2.2 functions when |
/* Make some defines so we can use the GTK 2.2 functions when |
84 |
compiling with GTK 2.0. */ |
compiling with GTK 2.0. */ |
85 |
|
|
86 |
#define xg_set_screen(w, f) |
#define xg_set_screen(w, f) |
87 |
#define gdk_xid_table_lookup_for_display(dpy, w) gdk_xid_table_lookup (w) |
#define gdk_xid_table_lookup_for_display(dpy, w) gdk_xid_table_lookup (w) |
88 |
#define gdk_pixmap_foreign_new_for_display(dpy, p) gdk_pixmap_foreign_new (p) |
#define gdk_pixmap_foreign_new_for_display(dpy, p) gdk_pixmap_foreign_new (p) |
98 |
Returns non-zero if display could be opened, zero if display could not |
Returns non-zero if display could be opened, zero if display could not |
99 |
be opened, and less than zero if the GTK version doesn't support |
be opened, and less than zero if the GTK version doesn't support |
100 |
multipe displays. */ |
multipe displays. */ |
101 |
|
|
102 |
int |
int |
103 |
xg_display_open (display_name, dpy) |
xg_display_open (display_name, dpy) |
104 |
char *display_name; |
char *display_name; |
119 |
} |
} |
120 |
|
|
121 |
|
|
122 |
|
/* Close display DPY. */ |
123 |
|
|
124 |
void |
void |
125 |
xg_display_close (Display *dpy) |
xg_display_close (Display *dpy) |
126 |
{ |
{ |
182 |
widget_value_free_list or by malloc:ing a new one. |
widget_value_free_list or by malloc:ing a new one. |
183 |
|
|
184 |
Return a pointer to the allocated structure. */ |
Return a pointer to the allocated structure. */ |
185 |
|
|
186 |
widget_value * |
widget_value * |
187 |
malloc_widget_value () |
malloc_widget_value () |
188 |
{ |
{ |
204 |
|
|
205 |
/* This is analogous to free. It frees only what was allocated |
/* This is analogous to free. It frees only what was allocated |
206 |
by malloc_widget_value, and no substructures. */ |
by malloc_widget_value, and no substructures. */ |
207 |
|
|
208 |
void |
void |
209 |
free_widget_value (wv) |
free_widget_value (wv) |
210 |
widget_value *wv; |
widget_value *wv; |
229 |
|
|
230 |
/* Create and return the cursor to be used for popup menus and |
/* Create and return the cursor to be used for popup menus and |
231 |
scroll bars on display DPY. */ |
scroll bars on display DPY. */ |
232 |
|
|
233 |
GdkCursor * |
GdkCursor * |
234 |
xg_create_default_cursor (dpy) |
xg_create_default_cursor (dpy) |
235 |
Display *dpy; |
Display *dpy; |
248 |
WIDGET is used to find the GdkColormap to use for the GdkPixbuf. |
WIDGET is used to find the GdkColormap to use for the GdkPixbuf. |
249 |
If OLD_WIDGET is NULL, a new widget is constructed and returned. |
If OLD_WIDGET is NULL, a new widget is constructed and returned. |
250 |
If OLD_WIDGET is not NULL, that widget is modified. */ |
If OLD_WIDGET is not NULL, that widget is modified. */ |
251 |
|
|
252 |
static GtkWidget * |
static GtkWidget * |
253 |
xg_get_image_for_pixmap (f, img, widget, old_widget) |
xg_get_image_for_pixmap (f, img, widget, old_widget) |
254 |
FRAME_PTR f; |
FRAME_PTR f; |
383 |
/* Set CURSOR on W and all widgets W contain. We must do like this |
/* Set CURSOR on W and all widgets W contain. We must do like this |
384 |
for scroll bars and menu because they create widgets internally, |
for scroll bars and menu because they create widgets internally, |
385 |
and it is those widgets that are visible. */ |
and it is those widgets that are visible. */ |
386 |
|
|
387 |
static void |
static void |
388 |
xg_set_cursor (w, cursor) |
xg_set_cursor (w, cursor) |
389 |
GtkWidget *w; |
GtkWidget *w; |
411 |
has expired by calling the GTK event loop. |
has expired by calling the GTK event loop. |
412 |
Also, when a menu is active, it has a small timeout before it |
Also, when a menu is active, it has a small timeout before it |
413 |
pops down the sub menu under it. */ |
pops down the sub menu under it. */ |
414 |
|
|
415 |
static void |
static void |
416 |
xg_process_timeouts (timer) |
xg_process_timeouts (timer) |
417 |
struct atimer *timer; |
struct atimer *timer; |
427 |
/* Start the xg_timer with an interval of 0.1 seconds, if not already started. |
/* Start the xg_timer with an interval of 0.1 seconds, if not already started. |
428 |
xg_process_timeouts is called when the timer expires. The timer |
xg_process_timeouts is called when the timer expires. The timer |
429 |
started is continuous, i.e. runs until xg_stop_timer is called. */ |
started is continuous, i.e. runs until xg_stop_timer is called. */ |
430 |
|
|
431 |
static void |
static void |
432 |
xg_start_timer () |
xg_start_timer () |
433 |
{ |
{ |
443 |
} |
} |
444 |
|
|
445 |
/* Stop the xg_timer if started. */ |
/* Stop the xg_timer if started. */ |
446 |
|
|
447 |
static void |
static void |
448 |
xg_stop_timer () |
xg_stop_timer () |
449 |
{ |
{ |
455 |
} |
} |
456 |
|
|
457 |
/* Insert NODE into linked LIST. */ |
/* Insert NODE into linked LIST. */ |
458 |
|
|
459 |
static void |
static void |
460 |
xg_list_insert (xg_list_node *list, xg_list_node *node) |
xg_list_insert (xg_list_node *list, xg_list_node *node) |
461 |
{ |
{ |
468 |
} |
} |
469 |
|
|
470 |
/* Remove NODE from linked LIST. */ |
/* Remove NODE from linked LIST. */ |
471 |
|
|
472 |
static void |
static void |
473 |
xg_list_remove (xg_list_node *list, xg_list_node *node) |
xg_list_remove (xg_list_node *list, xg_list_node *node) |
474 |
{ |
{ |
489 |
utf8 or NULL, just return STR. |
utf8 or NULL, just return STR. |
490 |
If not, a new string is allocated and the caller must free the result |
If not, a new string is allocated and the caller must free the result |
491 |
with g_free. */ |
with g_free. */ |
492 |
|
|
493 |
static char * |
static char * |
494 |
get_utf8_string (str) |
get_utf8_string (str) |
495 |
char *str; |
char *str; |
513 |
only way to get geometry position right if the user explicitly |
only way to get geometry position right if the user explicitly |
514 |
asked for a position when starting Emacs. |
asked for a position when starting Emacs. |
515 |
F is the frame we shall set geometry for. */ |
F is the frame we shall set geometry for. */ |
516 |
|
|
517 |
static void |
static void |
518 |
xg_set_geometry (f) |
xg_set_geometry (f) |
519 |
FRAME_PTR f; |
FRAME_PTR f; |
547 |
/* Resize the outer window of frame F after chainging the height. |
/* Resize the outer window of frame F after chainging the height. |
548 |
This happend when the menu bar or the tool bar is added or removed. |
This happend when the menu bar or the tool bar is added or removed. |
549 |
COLUMNS/ROWS is the size the edit area shall have after the resize. */ |
COLUMNS/ROWS is the size the edit area shall have after the resize. */ |
550 |
|
|
551 |
static void |
static void |
552 |
xg_resize_outer_widget (f, columns, rows) |
xg_resize_outer_widget (f, columns, rows) |
553 |
FRAME_PTR f; |
FRAME_PTR f; |
574 |
manually. |
manually. |
575 |
F is the frame to resize. |
F is the frame to resize. |
576 |
PIXELWIDTH, PIXELHEIGHT is the new size in pixels. */ |
PIXELWIDTH, PIXELHEIGHT is the new size in pixels. */ |
577 |
|
|
578 |
void |
void |
579 |
xg_resize_widgets (f, pixelwidth, pixelheight) |
xg_resize_widgets (f, pixelwidth, pixelheight) |
580 |
FRAME_PTR f; |
FRAME_PTR f; |
611 |
|
|
612 |
|
|
613 |
/* Update our widget size to be COLS/ROWS characters for frame F. */ |
/* Update our widget size to be COLS/ROWS characters for frame F. */ |
614 |
|
|
615 |
void |
void |
616 |
xg_frame_set_char_size (f, cols, rows) |
xg_frame_set_char_size (f, cols, rows) |
617 |
FRAME_PTR f; |
FRAME_PTR f; |
651 |
X Window that aren't accessible. |
X Window that aren't accessible. |
652 |
|
|
653 |
Return 0 if no widget match WDESC. */ |
Return 0 if no widget match WDESC. */ |
654 |
|
|
655 |
GtkWidget * |
GtkWidget * |
656 |
xg_win_to_widget (dpy, wdesc) |
xg_win_to_widget (dpy, wdesc) |
657 |
Display *dpy; |
Display *dpy; |
677 |
|
|
678 |
/* Fill in the GdkColor C so that it represents PIXEL. |
/* Fill in the GdkColor C so that it represents PIXEL. |
679 |
W is the widget that color will be used for. Used to find colormap. */ |
W is the widget that color will be used for. Used to find colormap. */ |
680 |
|
|
681 |
static void |
static void |
682 |
xg_pix_to_gcolor (w, pixel, c) |
xg_pix_to_gcolor (w, pixel, c) |
683 |
GtkWidget *w; |
GtkWidget *w; |
690 |
|
|
691 |
/* Create and set up the GTK widgets for frame F. |
/* Create and set up the GTK widgets for frame F. |
692 |
Return 0 if creation failed, non-zero otherwise. */ |
Return 0 if creation failed, non-zero otherwise. */ |
693 |
|
|
694 |
int |
int |
695 |
xg_create_frame_widgets (f) |
xg_create_frame_widgets (f) |
696 |
FRAME_PTR f; |
FRAME_PTR f; |
826 |
that the window now has. |
that the window now has. |
827 |
If USER_POSITION is nonzero, we set the User Position |
If USER_POSITION is nonzero, we set the User Position |
828 |
flag (this is useful when FLAGS is 0). */ |
flag (this is useful when FLAGS is 0). */ |
829 |
|
|
830 |
void |
void |
831 |
x_wm_set_size_hint (f, flags, user_position) |
x_wm_set_size_hint (f, flags, user_position) |
832 |
FRAME_PTR f; |
FRAME_PTR f; |
925 |
keep the GTK and X colors in sync. |
keep the GTK and X colors in sync. |
926 |
F is the frame to change, |
F is the frame to change, |
927 |
BG is the pixel value to change to. */ |
BG is the pixel value to change to. */ |
928 |
|
|
929 |
void |
void |
930 |
xg_set_background_color (f, bg) |
xg_set_background_color (f, bg) |
931 |
FRAME_PTR f; |
FRAME_PTR f; |
949 |
***********************************************************************/ |
***********************************************************************/ |
950 |
/* Return the dialog title to use for a dialog of type KEY. |
/* Return the dialog title to use for a dialog of type KEY. |
951 |
This is the encoding used by lwlib. We use the same for GTK. */ |
This is the encoding used by lwlib. We use the same for GTK. */ |
952 |
|
|
953 |
static char * |
static char * |
954 |
get_dialog_title (char key) |
get_dialog_title (char key) |
955 |
{ |
{ |
990 |
user_data is NULL (not used). |
user_data is NULL (not used). |
991 |
|
|
992 |
Returns TRUE to end propagation of event. */ |
Returns TRUE to end propagation of event. */ |
993 |
|
|
994 |
static gboolean |
static gboolean |
995 |
dialog_delete_callback (w, event, user_data) |
dialog_delete_callback (w, event, user_data) |
996 |
GtkWidget *w; |
GtkWidget *w; |
1007 |
DEACTIVATE_CB is the callback to use when the dialog pops down. |
DEACTIVATE_CB is the callback to use when the dialog pops down. |
1008 |
|
|
1009 |
Returns the GTK dialog widget. */ |
Returns the GTK dialog widget. */ |
1010 |
|
|
1011 |
static GtkWidget * |
static GtkWidget * |
1012 |
create_dialog (wv, select_cb, deactivate_cb) |
create_dialog (wv, select_cb, deactivate_cb) |
1013 |
widget_value *wv; |
widget_value *wv; |
1130 |
a file dialog. |
a file dialog. |
1131 |
W is the file dialog widget, |
W is the file dialog widget, |
1132 |
ARG points to an integer where we record what has happend. */ |
ARG points to an integer where we record what has happend. */ |
1133 |
|
|
1134 |
static void |
static void |
1135 |
xg_file_sel_ok (w, arg) |
xg_file_sel_ok (w, arg) |
1136 |
GtkWidget *w; |
GtkWidget *w; |
1143 |
a file dialog. |
a file dialog. |
1144 |
W is the file dialog widget, |
W is the file dialog widget, |
1145 |
ARG points to an integer where we record what has happend. */ |
ARG points to an integer where we record what has happend. */ |
1146 |
|
|
1147 |
static void |
static void |
1148 |
xg_file_sel_cancel (w, arg) |
xg_file_sel_cancel (w, arg) |
1149 |
GtkWidget *w; |
GtkWidget *w; |
1158 |
the dialog is popped down, but the dialog widget is not destroyed. |
the dialog is popped down, but the dialog widget is not destroyed. |
1159 |
W is the file dialog widget, |
W is the file dialog widget, |
1160 |
ARG points to an integer where we record what has happend. */ |
ARG points to an integer where we record what has happend. */ |
1161 |
|
|
1162 |
static void |
static void |
1163 |
xg_file_sel_destroy (w, arg) |
xg_file_sel_destroy (w, arg) |
1164 |
GtkWidget *w; |
GtkWidget *w; |
1176 |
|
|
1177 |
Returns a file name or NULL if no file was selected. |
Returns a file name or NULL if no file was selected. |
1178 |
The returned string must be freed by the caller. */ |
The returned string must be freed by the caller. */ |
1179 |
|
|
1180 |
char * |
char * |
1181 |
xg_get_file_name (f, prompt, default_filename, mustmatch_p) |
xg_get_file_name (f, prompt, default_filename, mustmatch_p) |
1182 |
FRAME_PTR f; |
FRAME_PTR f; |
1267 |
|
|
1268 |
Returns CL_DATA if CL_DATA is not NULL, or a pointer to a newly |
Returns CL_DATA if CL_DATA is not NULL, or a pointer to a newly |
1269 |
allocated xg_menu_cb_data if CL_DATA is NULL. */ |
allocated xg_menu_cb_data if CL_DATA is NULL. */ |
1270 |
|
|
1271 |
static xg_menu_cb_data * |
static xg_menu_cb_data * |
1272 |
make_cl_data (cl_data, f, highlight_cb) |
make_cl_data (cl_data, f, highlight_cb) |
1273 |
xg_menu_cb_data *cl_data; |
xg_menu_cb_data *cl_data; |
1301 |
HIGHLIGHT_CB could change, there is no check that the same |
HIGHLIGHT_CB could change, there is no check that the same |
1302 |
function is given when modifying a menu bar as was given when |
function is given when modifying a menu bar as was given when |
1303 |
creating the menu bar. */ |
creating the menu bar. */ |
1304 |
|
|
1305 |
static void |
static void |
1306 |
update_cl_data (cl_data, f, highlight_cb) |
update_cl_data (cl_data, f, highlight_cb) |
1307 |
xg_menu_cb_data *cl_data; |
xg_menu_cb_data *cl_data; |
1319 |
|
|
1320 |
/* Decrease reference count for CL_DATA. |
/* Decrease reference count for CL_DATA. |
1321 |
If reference count is zero, free CL_DATA. */ |
If reference count is zero, free CL_DATA. */ |
1322 |
|
|
1323 |
static void |
static void |
1324 |
unref_cl_data (cl_data) |
unref_cl_data (cl_data) |
1325 |
xg_menu_cb_data *cl_data; |
xg_menu_cb_data *cl_data; |
1336 |
} |
} |
1337 |
|
|
1338 |
/* Function that marks all lisp data during GC. */ |
/* Function that marks all lisp data during GC. */ |
1339 |
|
|
1340 |
void |
void |
1341 |
xg_mark_data () |
xg_mark_data () |
1342 |
{ |
{ |
1358 |
/* Callback called when a menu item is destroyed. Used to free data. |
/* Callback called when a menu item is destroyed. Used to free data. |
1359 |
W is the widget that is being destroyed (not used). |
W is the widget that is being destroyed (not used). |
1360 |
CLIENT_DATA points to the xg_menu_item_cb_data associated with the W. */ |
CLIENT_DATA points to the xg_menu_item_cb_data associated with the W. */ |
1361 |
|
|
1362 |
static void |
static void |
1363 |
menuitem_destroy_callback (w, client_data) |
menuitem_destroy_callback (w, client_data) |
1364 |
GtkWidget *w; |
GtkWidget *w; |
1378 |
CLIENT_DATA points to the xg_menu_item_cb_data associated with the W. |
CLIENT_DATA points to the xg_menu_item_cb_data associated with the W. |
1379 |
|
|
1380 |
Returns FALSE to tell GTK to keep processing this event. */ |
Returns FALSE to tell GTK to keep processing this event. */ |
1381 |
|
|
1382 |
static gboolean |
static gboolean |
1383 |
menuitem_highlight_callback (w, event, client_data) |
menuitem_highlight_callback (w, event, client_data) |
1384 |
GtkWidget *w; |
GtkWidget *w; |
1403 |
/* Callback called when a menu is destroyed. Used to free data. |
/* Callback called when a menu is destroyed. Used to free data. |
1404 |
W is the widget that is being destroyed (not used). |
W is the widget that is being destroyed (not used). |
1405 |
CLIENT_DATA points to the xg_menu_cb_data associated with W. */ |
CLIENT_DATA points to the xg_menu_cb_data associated with W. */ |
1406 |
|
|
1407 |
static void |
static void |
1408 |
menu_destroy_callback (w, client_data) |
menu_destroy_callback (w, client_data) |
1409 |
GtkWidget *w; |
GtkWidget *w; |
1419 |
W is the widget that does the grab (not used). |
W is the widget that does the grab (not used). |
1420 |
UNGRAB_P is TRUE if this is an ungrab, FALSE if it is a grab. |
UNGRAB_P is TRUE if this is an ungrab, FALSE if it is a grab. |
1421 |
CLIENT_DATA is NULL (not used). */ |
CLIENT_DATA is NULL (not used). */ |
1422 |
|
|
1423 |
static void |
static void |
1424 |
menu_grab_callback (GtkWidget *widget, |
menu_grab_callback (GtkWidget *widget, |
1425 |
gboolean ungrab_p, |
gboolean ungrab_p, |
1439 |
must be non-NULL) and can be inserted into a menu item. |
must be non-NULL) and can be inserted into a menu item. |
1440 |
|
|
1441 |
Returns the GtkHBox. */ |
Returns the GtkHBox. */ |
1442 |
|
|
1443 |
static GtkWidget * |
static GtkWidget * |
1444 |
make_widget_for_menu_item (utf8_label, utf8_key) |
make_widget_for_menu_item (utf8_label, utf8_key) |
1445 |
char *utf8_label; |
char *utf8_label; |
1479 |
|
|
1480 |
Unfortunately, keys don't line up as nicely as in Motif, |
Unfortunately, keys don't line up as nicely as in Motif, |
1481 |
but the MacOS X version doesn't either, so I guess that is OK. */ |
but the MacOS X version doesn't either, so I guess that is OK. */ |
1482 |
|
|
1483 |
static GtkWidget * |
static GtkWidget * |
1484 |
make_menu_item (utf8_label, utf8_key, item, group) |
make_menu_item (utf8_label, utf8_key, item, group) |
1485 |
char *utf8_label; |
char *utf8_label; |
1529 |
|
|
1530 |
/* Return non-zero if LABEL specifies a separator (GTK only has one |
/* Return non-zero if LABEL specifies a separator (GTK only has one |
1531 |
separator type) */ |
separator type) */ |
1532 |
|
|
1533 |
static int |
static int |
1534 |
xg_separator_p (char *label) |
xg_separator_p (char *label) |
1535 |
{ |
{ |
1578 |
static int xg_detached_menus; |
static int xg_detached_menus; |
1579 |
|
|
1580 |
/* Returns non-zero if there are detached menus. */ |
/* Returns non-zero if there are detached menus. */ |
1581 |
|
|
1582 |
int |
int |
1583 |
xg_have_tear_offs () |
xg_have_tear_offs () |
1584 |
{ |
{ |
1589 |
decrease the xg_detached_menus count. |
decrease the xg_detached_menus count. |
1590 |
WIDGET is the top level window that is removed (the parent of the menu). |
WIDGET is the top level window that is removed (the parent of the menu). |
1591 |
CLIENT_DATA is not used. */ |
CLIENT_DATA is not used. */ |
1592 |
|
|
1593 |
static void |
static void |
1594 |
tearoff_remove (widget, client_data) |
tearoff_remove (widget, client_data) |
1595 |
GtkWidget *widget; |
GtkWidget *widget; |
1602 |
xg_detached_menus count. |
xg_detached_menus count. |
1603 |
WIDGET is the GtkTearoffMenuItem. |
WIDGET is the GtkTearoffMenuItem. |
1604 |
CLIENT_DATA is not used. */ |
CLIENT_DATA is not used. */ |
1605 |
|
|
1606 |
static void |
static void |
1607 |
tearoff_activate (widget, client_data) |
tearoff_activate (widget, client_data) |
1608 |
GtkWidget *widget; |
GtkWidget *widget; |
1632 |
in the group. On exit, *GROUP contains the radio item group. |
in the group. On exit, *GROUP contains the radio item group. |
1633 |
|
|
1634 |
Returns the created GtkWidget. */ |
Returns the created GtkWidget. */ |
1635 |
|
|
1636 |
static GtkWidget * |
static GtkWidget * |
1637 |
xg_create_one_menuitem (item, f, select_cb, highlight_cb, cl_data, group) |
xg_create_one_menuitem (item, f, select_cb, highlight_cb, cl_data, group) |
1638 |
widget_value *item; |
widget_value *item; |
1850 |
HIGHLIGHT_CB is the callback to call when entering/leaving menu items. |
HIGHLIGHT_CB is the callback to call when entering/leaving menu items. |
1851 |
|
|
1852 |
Returns the widget created. */ |
Returns the widget created. */ |
1853 |
|
|
1854 |
GtkWidget * |
GtkWidget * |
1855 |
xg_create_widget (type, name, f, val, |
xg_create_widget (type, name, f, val, |
1856 |
select_cb, deactivate_cb, highlight_cb) |
select_cb, deactivate_cb, highlight_cb) |
1908 |
} |
} |
1909 |
|
|
1910 |
/* Return the label for menu item WITEM. */ |
/* Return the label for menu item WITEM. */ |
1911 |
|
|
1912 |
static const char * |
static const char * |
1913 |
xg_get_menu_item_label (witem) |
xg_get_menu_item_label (witem) |
1914 |
GtkMenuItem *witem; |
GtkMenuItem *witem; |
1918 |
} |
} |
1919 |
|
|
1920 |
/* Return non-zero if the menu item WITEM has the text LABEL. */ |
/* Return non-zero if the menu item WITEM has the text LABEL. */ |
1921 |
|
|
1922 |
static int |
static int |
1923 |
xg_item_label_same_p (witem, label) |
xg_item_label_same_p (witem, label) |
1924 |
GtkMenuItem *witem; |
GtkMenuItem *witem; |
1938 |
return is_same; |
return is_same; |
1939 |
} |
} |
1940 |
|
|
1941 |
/* Remove widgets in LIST from container WCONT. */ |
/* Destroy widgets in LIST. */ |
1942 |
|
|
1943 |
static void |
static void |
1944 |
remove_from_container (wcont, list) |
xg_destroy_widgets (list) |
|
GtkWidget *wcont; |
|
1945 |
GList *list; |
GList *list; |
1946 |
{ |
{ |
1947 |
GList *iter; |
GList *iter; |
1950 |
{ |
{ |
1951 |
GtkWidget *w = GTK_WIDGET (iter->data); |
GtkWidget *w = GTK_WIDGET (iter->data); |
1952 |
|
|
1953 |
/* Add a ref to w so we can explicitly destroy it later. */ |
/* Destroying the widget will remove it from the container it is in. */ |
|
gtk_widget_ref (w); |
|
|
gtk_container_remove (GTK_CONTAINER (wcont), w); |
|
|
|
|
|
/* If there is a menu under this widget that has been detached, |
|
|
there is a reference to it, and just removing w from the |
|
|
container does not destroy the submenu. By explicitly |
|
|
destroying w we make sure the submenu is destroyed, thus |
|
|
removing the detached window also if there was one. */ |
|
1954 |
gtk_widget_destroy (w); |
gtk_widget_destroy (w); |
1955 |
} |
} |
1956 |
} |
} |
1966 |
CL_DATA points to the callback data to be used for this menu bar. |
CL_DATA points to the callback data to be used for this menu bar. |
1967 |
|
|
1968 |
This function calls itself to walk through the menu bar names. */ |
This function calls itself to walk through the menu bar names. */ |
1969 |
|
|
1970 |
static void |
static void |
1971 |
xg_update_menubar (menubar, f, list, iter, pos, val, |
xg_update_menubar (menubar, f, list, iter, pos, val, |
1972 |
select_cb, highlight_cb, cl_data) |
select_cb, highlight_cb, cl_data) |
1985 |
else if (iter && ! val) |
else if (iter && ! val) |
1986 |
{ |
{ |
1987 |
/* Item(s) have been removed. Remove all remaining items. */ |
/* Item(s) have been removed. Remove all remaining items. */ |
1988 |
remove_from_container (menubar, iter); |
xg_destroy_widgets (iter); |
1989 |
|
|
1990 |
/* All updated. */ |
/* All updated. */ |
1991 |
val = 0; |
val = 0; |
2139 |
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. |
2140 |
HIGHLIGHT_CB is the callback to call when entering/leaving menu items. |
HIGHLIGHT_CB is the callback to call when entering/leaving menu items. |
2141 |
CL_DATA is the data to set in the widget for menu invokation. */ |
CL_DATA is the data to set in the widget for menu invokation. */ |
2142 |
|
|
2143 |
static void |
static void |
2144 |
xg_update_menu_item (val, w, select_cb, highlight_cb, cl_data) |
xg_update_menu_item (val, w, select_cb, highlight_cb, cl_data) |
2145 |
widget_value *val; |
widget_value *val; |
2274 |
} |
} |
2275 |
|
|
2276 |
/* Update the toggle menu item W so it corresponds to VAL. */ |
/* Update the toggle menu item W so it corresponds to VAL. */ |
2277 |
|
|
2278 |
static void |
static void |
2279 |
xg_update_toggle_item (val, w) |
xg_update_toggle_item (val, w) |
2280 |
widget_value *val; |
widget_value *val; |
2284 |
} |
} |
2285 |
|
|
2286 |
/* Update the radio menu item W so it corresponds to VAL. */ |
/* Update the radio menu item W so it corresponds to VAL. */ |
2287 |
|
|
2288 |
static void |
static void |
2289 |
xg_update_radio_item (val, w) |
xg_update_radio_item (val, w) |
2290 |
widget_value *val; |
widget_value *val; |
2414 |
{ |
{ |
2415 |
/* If we are adding new menu items below, we must remove from |
/* If we are adding new menu items below, we must remove from |
2416 |
first radio button so that radio groups become correct. */ |
first radio button so that radio groups become correct. */ |
2417 |
if (cur && first_radio) remove_from_container (submenu, first_radio); |
if (cur && first_radio) xg_destroy_widgets (first_radio); |
2418 |
else remove_from_container (submenu, iter); |
else xg_destroy_widgets (iter); |
2419 |
} |
} |
2420 |
|
|
2421 |
if (cur) |
if (cur) |
2447 |
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. |
2448 |
DEACTIVATE_CB is the callback to use when a sub menu is not shown anymore. |
DEACTIVATE_CB is the callback to use when a sub menu is not shown anymore. |
2449 |
HIGHLIGHT_CB is the callback to call when entering/leaving menu items. */ |
HIGHLIGHT_CB is the callback to call when entering/leaving menu items. */ |
2450 |
|
|
2451 |
void |
void |
2452 |
xg_modify_menubar_widgets (menubar, f, val, deep_p, |
xg_modify_menubar_widgets (menubar, f, val, deep_p, |
2453 |
select_cb, deactivate_cb, highlight_cb) |
select_cb, deactivate_cb, highlight_cb) |
2592 |
|
|
2593 |
/* Setting scroll bar values invokes the callback. Use this variable |
/* Setting scroll bar values invokes the callback. Use this variable |
2594 |
to indicate that callback should do nothing. */ |
to indicate that callback should do nothing. */ |
2595 |
|
|
2596 |
int xg_ignore_gtk_scrollbar; |
int xg_ignore_gtk_scrollbar; |
2597 |
|
|
2598 |
/* SET_SCROLL_BAR_X_WINDOW assumes the second argument fits in |
/* SET_SCROLL_BAR_X_WINDOW assumes the second argument fits in |
2599 |
32 bits. But we want to store pointers, and they may be larger |
32 bits. But we want to store pointers, and they may be larger |
2600 |
than 32 bits. Keep a mapping from integer index to widget pointers |
than 32 bits. Keep a mapping from integer index to widget pointers |
2601 |
to get around the 32 bit limitation. */ |
to get around the 32 bit limitation. */ |
2602 |
|
|
2603 |
static struct |
static struct |
2604 |
{ |
{ |
2605 |
GtkWidget **widgets; |
GtkWidget **widgets; |
2608 |
} id_to_widget; |
} id_to_widget; |
2609 |
|
|
2610 |
/* Grow this much every time we need to allocate more */ |
/* Grow this much every time we need to allocate more */ |
2611 |
|
|
2612 |
#define ID_TO_WIDGET_INCR 32 |
#define ID_TO_WIDGET_INCR 32 |
2613 |
|
|
2614 |
/* Store the widget pointer W in id_to_widget and return the integer index. */ |
/* Store the widget pointer W in id_to_widget and return the integer index. */ |
2615 |
|
|
2616 |
static int |
static int |
2617 |
xg_store_widget_in_map (w) |
xg_store_widget_in_map (w) |
2618 |
GtkWidget *w; |
GtkWidget *w; |
2651 |
|
|
2652 |
/* Remove pointer at IDX from id_to_widget. |
/* Remove pointer at IDX from id_to_widget. |
2653 |
Called when scroll bar is destroyed. */ |
Called when scroll bar is destroyed. */ |
2654 |
|
|
2655 |
static void |
static void |
2656 |
xg_remove_widget_from_map (idx) |
xg_remove_widget_from_map (idx) |
2657 |
int idx; |
int idx; |
2664 |
} |
} |
2665 |
|
|
2666 |
/* Get the widget pointer at IDX from id_to_widget. */ |
/* Get the widget pointer at IDX from id_to_widget. */ |
2667 |
|
|
2668 |
static GtkWidget * |
static GtkWidget * |
2669 |
xg_get_widget_from_map (idx) |
xg_get_widget_from_map (idx) |
2670 |
int idx; |
int idx; |
2677 |
|
|
2678 |
/* Return the scrollbar id for X Window WID on display DPY. |
/* Return the scrollbar id for X Window WID on display DPY. |
2679 |
Return -1 if WID not in id_to_widget. */ |
Return -1 if WID not in id_to_widget. */ |
2680 |
|
|
2681 |
int |
int |
2682 |
xg_get_scroll_id_for_window (dpy, wid) |
xg_get_scroll_id_for_window (dpy, wid) |
2683 |
Display *dpy; |
Display *dpy; |
2701 |
/* Callback invoked when scroll bar WIDGET is destroyed. |
/* Callback invoked when scroll bar WIDGET is destroyed. |
2702 |
DATA is the index into id_to_widget for WIDGET. |
DATA is the index into id_to_widget for WIDGET. |
2703 |
We free pointer to last scroll bar values here and remove the index. */ |
We free pointer to last scroll bar values here and remove the index. */ |
2704 |
|
|
2705 |
static void |
static void |
2706 |
xg_gtk_scroll_destroy (widget, data) |
xg_gtk_scroll_destroy (widget, data) |
2707 |
GtkWidget *widget; |
GtkWidget *widget; |
2724 |
|
|
2725 |
Returns FALSE to tell GTK that it shall continue propagate the event |
Returns FALSE to tell GTK that it shall continue propagate the event |
2726 |
to widgets. */ |
to widgets. */ |
2727 |
|
|
2728 |
static gboolean |
static gboolean |
2729 |
scroll_bar_button_cb (widget, event, user_data) |
scroll_bar_button_cb (widget, event, user_data) |
2730 |
GtkWidget *widget; |
GtkWidget *widget; |
2749 |
bar changes. |
bar changes. |
2750 |
SCROLL_BAR_NAME is the name we use for the scroll bar. Can be used |
SCROLL_BAR_NAME is the name we use for the scroll bar. Can be used |
2751 |
to set resources for the widget. */ |
to set resources for the widget. */ |
2752 |
|
|
2753 |
void |
void |
2754 |
xg_create_scroll_bar (f, bar, scroll_callback, scroll_bar_name) |
xg_create_scroll_bar (f, bar, scroll_callback, scroll_bar_name) |
2755 |
FRAME_PTR f; |
FRAME_PTR f; |
2811 |
} |
} |
2812 |
|
|
2813 |
/* Make the scroll bar represented by SCROLLBAR_ID visible. */ |
/* Make the scroll bar represented by SCROLLBAR_ID visible. */ |
2814 |
|
|
2815 |
void |
void |
2816 |
xg_show_scroll_bar (scrollbar_id) |
xg_show_scroll_bar (scrollbar_id) |
2817 |
int scrollbar_id; |
int scrollbar_id; |
2822 |
} |
} |
2823 |
|
|
2824 |
/* Remove the scroll bar represented by SCROLLBAR_ID from the frame F. */ |
/* Remove the scroll bar represented by SCROLLBAR_ID from the frame F. */ |
2825 |
|
|
2826 |
void |
void |
2827 |
xg_remove_scroll_bar (f, scrollbar_id) |
xg_remove_scroll_bar (f, scrollbar_id) |
2828 |
FRAME_PTR f; |
FRAME_PTR f; |
2842 |
in frame F. |
in frame F. |
2843 |
TOP/LEFT are the new pixel positions where the bar shall appear. |
TOP/LEFT are the new pixel positions where the bar shall appear. |
2844 |
WIDTH, HEIGHT is the size in pixels the bar shall have. */ |
WIDTH, HEIGHT is the size in pixels the bar shall have. */ |
2845 |
|
|
2846 |
void |
void |
2847 |
xg_update_scrollbar_pos (f, scrollbar_id, top, left, width, height) |
xg_update_scrollbar_pos (f, scrollbar_id, top, left, width, height) |
2848 |
FRAME_PTR f; |
FRAME_PTR f; |
2871 |
|
|
2872 |
/* 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 |
2873 |
displaying PORTION out of a whole WHOLE, and our position POSITION. */ |
displaying PORTION out of a whole WHOLE, and our position POSITION. */ |
2874 |
|
|
2875 |
void |
void |
2876 |
xg_set_toolkit_scroll_bar_thumb (bar, portion, position, whole) |
xg_set_toolkit_scroll_bar_thumb (bar, portion, position, whole) |
2877 |
struct scroll_bar *bar; |
struct scroll_bar *bar; |
2964 |
W is the button widget in the tool bar that got pressed, |
W is the button widget in the tool bar that got pressed, |
2965 |
CLIENT_DATA is an integer that is the index of the button in the |
CLIENT_DATA is an integer that is the index of the button in the |
2966 |
tool bar. 0 is the first button. */ |
tool bar. 0 is the first button. */ |
2967 |
|
|
2968 |
static void |
static void |
2969 |
xg_tool_bar_callback (w, client_data) |
xg_tool_bar_callback (w, client_data) |
2970 |
GtkWidget *w; |
GtkWidget *w; |
3001 |
WBOX is the handle box widget that enables detach/attach of the tool bar. |
WBOX is the handle box widget that enables detach/attach of the tool bar. |
3002 |
W is the tool bar widget. |
W is the tool bar widget. |
3003 |
CLIENT_DATA is a pointer to the frame the tool bar belongs to. */ |
CLIENT_DATA is a pointer to the frame the tool bar belongs to. */ |
3004 |
|
|
3005 |
static void |
static void |
3006 |
xg_tool_bar_detach_callback (wbox, w, client_data) |
xg_tool_bar_detach_callback (wbox, w, client_data) |
3007 |
GtkHandleBox *wbox; |
GtkHandleBox *wbox; |
3030 |
WBOX is the handle box widget that enables detach/attach of the tool bar. |
WBOX is the handle box widget that enables detach/attach of the tool bar. |
3031 |
W is the tool bar widget. |
W is the tool bar widget. |
3032 |
CLIENT_DATA is a pointer to the frame the tool bar belongs to. */ |
CLIENT_DATA is a pointer to the frame the tool bar belongs to. */ |
3033 |
|
|
3034 |
static void |
static void |
3035 |
xg_tool_bar_attach_callback (wbox, w, client_data) |
xg_tool_bar_attach_callback (wbox, w, client_data) |
3036 |
GtkHandleBox *wbox; |
GtkHandleBox *wbox; |
3060 |
tool bar. 0 is the first button. |
tool bar. 0 is the first button. |
3061 |
|
|
3062 |
Returns FALSE to tell GTK to keep processing this event. */ |
Returns FALSE to tell GTK to keep processing this event. */ |
3063 |
|
|
3064 |
static gboolean |
static gboolean |
3065 |
xg_tool_bar_help_callback (w, event, client_data) |
xg_tool_bar_help_callback (w, event, client_data) |
3066 |
GtkWidget *w; |
GtkWidget *w; |
3106 |
CLIENT_DATA is unused. |
CLIENT_DATA is unused. |
3107 |
|
|
3108 |
Returns FALSE to tell GTK to keep processing this event. */ |
Returns FALSE to tell GTK to keep processing this event. */ |
3109 |
|
|
3110 |
static gboolean |
static gboolean |
3111 |
xg_tool_bar_item_expose_callback (w, event, client_data) |
xg_tool_bar_item_expose_callback (w, event, client_data) |
3112 |
GtkWidget *w; |
GtkWidget *w; |
3137 |
CLIENT_DATA is pointing to the frame for this tool bar. |
CLIENT_DATA is pointing to the frame for this tool bar. |
3138 |
|
|
3139 |
Returns FALSE to tell GTK to keep processing this event. */ |
Returns FALSE to tell GTK to keep processing this event. */ |
3140 |
|
|
3141 |
static gboolean |
static gboolean |
3142 |
xg_tool_bar_expose_callback (w, event, client_data) |
xg_tool_bar_expose_callback (w, event, client_data) |
3143 |
GtkWidget *w; |
GtkWidget *w; |
3148 |
return FALSE; |
return FALSE; |
3149 |
} |
} |
3150 |
|
|
3151 |
|
/* Create a tool bar for frame F. */ |
3152 |
|
|
3153 |
static void |
static void |
3154 |
xg_create_tool_bar (f) |
xg_create_tool_bar (f) |
3155 |
FRAME_PTR f; |
FRAME_PTR f; |
3203 |
SET_FRAME_GARBAGED (f); |
SET_FRAME_GARBAGED (f); |
3204 |
} |
} |
3205 |
|
|
3206 |
|
/* Update the tool bar for frame F. Add new buttons and remove old. */ |
3207 |
|
|
3208 |
void |
void |
3209 |
update_frame_tool_bar (f) |
update_frame_tool_bar (f) |
3210 |
FRAME_PTR f; |
FRAME_PTR f; |
3372 |
UNBLOCK_INPUT; |
UNBLOCK_INPUT; |
3373 |
} |
} |
3374 |
|
|
3375 |
|
/* Deallocate all resources for the tool bar on frame F. |
3376 |
|
Remove the tool bar. */ |
3377 |
|
|
3378 |
void |
void |
3379 |
free_frame_tool_bar (f) |
free_frame_tool_bar (f) |
3380 |
FRAME_PTR f; |
FRAME_PTR f; |