international/mule-cmds.el (select-safe-coding-system): Remove a superfluous conditio...
[emacs.git] / src / gtkutil.h
blob1c26d2aa44b3909a5d522cbe40aa4f3bca5a82b9
1 /* Definitions and headers for GTK widgets.
3 Copyright (C) 2003-2013 Free Software Foundation, Inc.
5 This file is part of GNU Emacs.
7 GNU Emacs is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
12 GNU Emacs is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
20 #ifndef GTKUTIL_H
21 #define GTKUTIL_H
24 #ifdef USE_GTK
26 #include <gtk/gtk.h>
27 #include "frame.h"
28 #include "xterm.h"
30 /* Minimum and maximum values used for GTK scroll bars */
32 #define XG_SB_MIN 1
33 #define XG_SB_MAX 10000000
34 #define XG_SB_RANGE (XG_SB_MAX-XG_SB_MIN)
36 /* Key for data that is valid for menus and scroll bars in a frame */
37 #define XG_FRAME_DATA "emacs_frame"
39 /* Key for data that menu items hold. */
40 #define XG_ITEM_DATA "emacs_menuitem"
42 /* This is a list node in a generic list implementation. */
43 typedef struct xg_list_node_
45 struct xg_list_node_ *prev;
46 struct xg_list_node_ *next;
47 } xg_list_node;
49 /* This structure is the callback data that is shared for menu items.
50 We need to keep it separate from the frame structure due to
51 detachable menus. The data in the frame structure is only valid while
52 the menu is popped up. This structure is kept around as long as
53 the menu is. */
54 typedef struct xg_menu_cb_data_
56 xg_list_node ptrs;
58 struct frame *f;
59 Lisp_Object menu_bar_vector;
60 int menu_bar_items_used;
61 GCallback highlight_cb;
62 int ref_count;
63 } xg_menu_cb_data;
65 /* This structure holds callback information for each individual menu item. */
66 typedef struct xg_menu_item_cb_data_
68 xg_list_node ptrs;
70 gulong select_id;
71 Lisp_Object help;
72 gpointer call_data;
73 xg_menu_cb_data *cl_data;
75 } xg_menu_item_cb_data;
77 extern struct _widget_value *malloc_widget_value (void);
78 extern void free_widget_value (struct _widget_value *);
80 extern bool xg_uses_old_file_dialog (void) ATTRIBUTE_CONST;
82 extern char *xg_get_file_name (struct frame *f,
83 char *prompt,
84 char *default_filename,
85 bool mustmatch_p,
86 bool only_dir_p);
88 extern Lisp_Object xg_get_font (struct frame *f, const char *);
90 extern GtkWidget *xg_create_widget (const char *type,
91 const char *name,
92 struct frame *f,
93 struct _widget_value *val,
94 GCallback select_cb,
95 GCallback deactivate_cb,
96 GCallback highlight_cb);
98 extern void xg_modify_menubar_widgets (GtkWidget *menubar,
99 struct frame *f,
100 struct _widget_value *val,
101 bool deep_p,
102 GCallback select_cb,
103 GCallback deactivate_cb,
104 GCallback highlight_cb);
106 extern void xg_update_frame_menubar (struct frame *f);
108 extern bool xg_event_is_for_menubar (struct frame *, const XEvent *);
110 extern bool xg_have_tear_offs (void);
112 extern ptrdiff_t xg_get_scroll_id_for_window (Display *dpy, Window wid);
114 extern void xg_create_scroll_bar (struct frame *f,
115 struct scroll_bar *bar,
116 GCallback scroll_callback,
117 GCallback end_callback,
118 const char *scroll_bar_name);
119 extern void xg_remove_scroll_bar (struct frame *f, ptrdiff_t scrollbar_id);
121 extern void xg_update_scrollbar_pos (struct frame *f,
122 ptrdiff_t scrollbar_id,
123 int top,
124 int left,
125 int width,
126 int height);
128 extern void xg_set_toolkit_scroll_bar_thumb (struct scroll_bar *bar,
129 int portion,
130 int position,
131 int whole);
132 extern bool xg_event_is_for_scrollbar (struct frame *, const XEvent *);
133 extern int xg_get_default_scrollbar_width (void);
135 extern void update_frame_tool_bar (struct frame *f);
136 extern void free_frame_tool_bar (struct frame *f);
137 extern void xg_change_toolbar_position (struct frame *f, Lisp_Object pos);
139 extern void xg_frame_resized (struct frame *f,
140 int pixelwidth,
141 int pixelheight);
142 extern void xg_frame_set_char_size (struct frame *f, int cols, int rows);
143 extern GtkWidget * xg_win_to_widget (Display *dpy, Window wdesc);
145 extern void xg_display_open (char *display_name, Display **dpy);
146 extern void xg_display_close (Display *dpy);
147 extern GdkCursor * xg_create_default_cursor (Display *dpy);
149 extern bool xg_create_frame_widgets (struct frame *f);
150 extern void xg_free_frame_widgets (struct frame *f);
151 extern void xg_set_background_color (struct frame *f, unsigned long bg);
152 extern bool xg_check_special_colors (struct frame *f,
153 const char *color_name,
154 XColor *color);
156 extern void xg_set_frame_icon (struct frame *f,
157 Pixmap icon_pixmap,
158 Pixmap icon_mask);
160 extern bool xg_prepare_tooltip (struct frame *f,
161 Lisp_Object string,
162 int *width,
163 int *height);
164 extern void xg_show_tooltip (struct frame *f, int root_x, int root_y);
165 extern bool xg_hide_tooltip (struct frame *f);
168 /* Mark all callback data that are Lisp_object:s during GC. */
169 extern void xg_mark_data (void);
171 /* Initialize GTK specific parts. */
172 extern void xg_initialize (void);
174 /* Setting scrollbar values invokes the callback. Use this variable
175 to indicate that the callback should do nothing. */
176 extern bool xg_ignore_gtk_scrollbar;
178 #endif /* USE_GTK */
179 #endif /* GTKUTIL_H */