Mercurial > emacs
annotate src/gtkutil.c @ 72730:c59eb8001eb6
(find_handler_clause): Give up on debugger if INPUT_BLOCKED_P.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Fri, 08 Sep 2006 12:11:49 +0000 |
parents | 9db8c9a68f0f |
children | ab6be05ddfb1 c358d0861b16 |
rev | line source |
---|---|
49323 | 1 /* Functions for creating and updating GTK widgets. |
68651
3bd95f4f2941
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
68500
diff
changeset
|
2 Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc. |
49323 | 3 |
4 This file is part of GNU Emacs. | |
5 | |
6 GNU Emacs is free software; you can redistribute it and/or modify | |
7 it under the terms of the GNU General Public License as published by | |
8 the Free Software Foundation; either version 2, or (at your option) | |
9 any later version. | |
10 | |
11 GNU Emacs is distributed in the hope that it will be useful, | |
12 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 GNU General Public License for more details. | |
15 | |
16 You should have received a copy of the GNU General Public License | |
17 along with GNU Emacs; see the file COPYING. If not, write to | |
64084 | 18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
19 Boston, MA 02110-1301, USA. */ | |
49323 | 20 |
21 #include "config.h" | |
22 | |
23 #ifdef USE_GTK | |
49359
14cf50ecf91a
gtkutil.c: Must include stdio.h before termhooks.h
Jan Djärv <jan.h.d@swipnet.se>
parents:
49325
diff
changeset
|
24 #include <string.h> |
58818
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58817
diff
changeset
|
25 #include <signal.h> |
49359
14cf50ecf91a
gtkutil.c: Must include stdio.h before termhooks.h
Jan Djärv <jan.h.d@swipnet.se>
parents:
49325
diff
changeset
|
26 #include <stdio.h> |
49323 | 27 #include "lisp.h" |
28 #include "xterm.h" | |
29 #include "blockinput.h" | |
58818
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58817
diff
changeset
|
30 #include "syssignal.h" |
49323 | 31 #include "window.h" |
32 #include "atimer.h" | |
33 #include "gtkutil.h" | |
34 #include "termhooks.h" | |
51408
8f1bed1dee3c
Include keyboard.h, charset.h, coding.h.
Dave Love <fx@gnu.org>
parents:
51211
diff
changeset
|
35 #include "keyboard.h" |
8f1bed1dee3c
Include keyboard.h, charset.h, coding.h.
Dave Love <fx@gnu.org>
parents:
51211
diff
changeset
|
36 #include "charset.h" |
8f1bed1dee3c
Include keyboard.h, charset.h, coding.h.
Dave Love <fx@gnu.org>
parents:
51211
diff
changeset
|
37 #include "coding.h" |
49323 | 38 #include <gdk/gdkkeysyms.h> |
39 | |
53069
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
40 |
49323 | 41 #define FRAME_TOTAL_PIXEL_HEIGHT(f) \ |
51211
28ea05de2dc5
Make (many) trivial substitutions for renamed and
Kim F. Storm <storm@cua.dk>
parents:
50778
diff
changeset
|
42 (FRAME_PIXEL_HEIGHT (f) + FRAME_MENUBAR_HEIGHT (f) + FRAME_TOOLBAR_HEIGHT (f)) |
50129
d0142038feaa
Reduce flicker in GTK scrollbars.
Jan Djärv <jan.h.d@swipnet.se>
parents:
50112
diff
changeset
|
43 |
67528
c5c00342184b
* gtkutil.c (SSDATA): New macro to remove compiler warnings.
Jan Djärv <jan.h.d@swipnet.se>
parents:
65628
diff
changeset
|
44 /* Avoid "differ in sign" warnings */ |
c5c00342184b
* gtkutil.c (SSDATA): New macro to remove compiler warnings.
Jan Djärv <jan.h.d@swipnet.se>
parents:
65628
diff
changeset
|
45 #define SSDATA(x) ((char *) SDATA (x)) |
c5c00342184b
* gtkutil.c (SSDATA): New macro to remove compiler warnings.
Jan Djärv <jan.h.d@swipnet.se>
parents:
65628
diff
changeset
|
46 |
53069
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
47 |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
48 /*********************************************************************** |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
49 Display handling functions |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
50 ***********************************************************************/ |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
51 |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
52 #ifdef HAVE_GTK_MULTIDISPLAY |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
53 |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
54 /* Return the GdkDisplay that corresponds to the X display DPY. */ |
57715
cdc48cdd5b0e
* gtkutil.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57597
diff
changeset
|
55 |
53069
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
56 static GdkDisplay * |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
57 xg_get_gdk_display (dpy) |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
58 Display *dpy; |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
59 { |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
60 return gdk_x11_lookup_xdisplay (dpy); |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
61 } |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
62 |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
63 /* When the GTK widget W is to be created on a display for F that |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
64 is not the default display, set the display for W. |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
65 W can be a GtkMenu or a GtkWindow widget. */ |
57715
cdc48cdd5b0e
* gtkutil.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57597
diff
changeset
|
66 |
53069
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
67 static void |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
68 xg_set_screen (w, f) |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
69 GtkWidget *w; |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
70 FRAME_PTR f; |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
71 { |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
72 if (FRAME_X_DISPLAY (f) != GDK_DISPLAY ()) |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
73 { |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
74 GdkDisplay *gdpy = gdk_x11_lookup_xdisplay (FRAME_X_DISPLAY (f)); |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
75 GdkScreen *gscreen = gdk_display_get_default_screen (gdpy); |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
76 |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
77 if (GTK_IS_MENU (w)) |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
78 gtk_menu_set_screen (GTK_MENU (w), gscreen); |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
79 else |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
80 gtk_window_set_screen (GTK_WINDOW (w), gscreen); |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
81 } |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
82 } |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
83 |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
84 |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
85 #else /* not HAVE_GTK_MULTIDISPLAY */ |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
86 |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
87 /* Make some defines so we can use the GTK 2.2 functions when |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
88 compiling with GTK 2.0. */ |
57715
cdc48cdd5b0e
* gtkutil.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57597
diff
changeset
|
89 |
53069
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
90 #define xg_set_screen(w, f) |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
91 #define gdk_xid_table_lookup_for_display(dpy, w) gdk_xid_table_lookup (w) |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
92 #define gdk_pixmap_foreign_new_for_display(dpy, p) gdk_pixmap_foreign_new (p) |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
93 #define gdk_cursor_new_for_display(dpy, c) gdk_cursor_new (c) |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
94 #define gdk_x11_lookup_xdisplay(dpy) 0 |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
95 #define GdkDisplay void |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
96 |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
97 #endif /* not HAVE_GTK_MULTIDISPLAY */ |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
98 |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
99 /* Open a display named by DISPLAY_NAME. The display is returned in *DPY. |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
100 *DPY is set to NULL if the display can't be opened. |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
101 |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
102 Returns non-zero if display could be opened, zero if display could not |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
103 be opened, and less than zero if the GTK version doesn't support |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
104 multipe displays. */ |
57715
cdc48cdd5b0e
* gtkutil.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57597
diff
changeset
|
105 |
53069
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
106 int |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
107 xg_display_open (display_name, dpy) |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
108 char *display_name; |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
109 Display **dpy; |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
110 { |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
111 #ifdef HAVE_GTK_MULTIDISPLAY |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
112 GdkDisplay *gdpy; |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
113 |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
114 gdpy = gdk_display_open (display_name); |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
115 *dpy = gdpy ? GDK_DISPLAY_XDISPLAY (gdpy) : NULL; |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
116 |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
117 return gdpy != NULL; |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
118 |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
119 #else /* not HAVE_GTK_MULTIDISPLAY */ |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
120 |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
121 return -1; |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
122 #endif /* not HAVE_GTK_MULTIDISPLAY */ |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
123 } |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
124 |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
125 |
57715
cdc48cdd5b0e
* gtkutil.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57597
diff
changeset
|
126 /* Close display DPY. */ |
cdc48cdd5b0e
* gtkutil.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57597
diff
changeset
|
127 |
53069
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
128 void |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
129 xg_display_close (Display *dpy) |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
130 { |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
131 #ifdef HAVE_GTK_MULTIDISPLAY |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
132 GdkDisplay *gdpy = gdk_x11_lookup_xdisplay (dpy); |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
133 |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
134 /* GTK 2.2 has a bug that makes gdk_display_close crash (bug |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
135 http://bugzilla.gnome.org/show_bug.cgi?id=85715). This way |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
136 we can continue running, but there will be memory leaks. */ |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
137 |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
138 #if GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION < 4 |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
139 |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
140 /* If this is the default display, we must change it before calling |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
141 dispose, otherwise it will crash. */ |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
142 if (gdk_display_get_default () == gdpy) |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
143 { |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
144 struct x_display_info *dpyinfo; |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
145 Display *new_dpy = 0; |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
146 GdkDisplay *gdpy_new; |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
147 |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
148 /* Find another display. */ |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
149 for (dpyinfo = x_display_list; dpyinfo; dpyinfo = dpyinfo->next) |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
150 if (dpyinfo->display != dpy) |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
151 { |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
152 new_dpy = dpyinfo->display; |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
153 break; |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
154 } |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
155 |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
156 if (! new_dpy) return; /* Emacs will exit anyway. */ |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
157 |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
158 gdpy_new = gdk_x11_lookup_xdisplay (new_dpy); |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
159 gdk_display_manager_set_default_display (gdk_display_manager_get (), |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
160 gdpy_new); |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
161 } |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
162 |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
163 g_object_run_dispose (G_OBJECT (gdpy)); |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
164 |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
165 #else |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
166 /* I hope this will be fixed in GTK 2.4. It is what bug 85715 says. */ |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
167 gdk_display_close (gdpy); |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
168 #endif |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
169 #endif /* HAVE_GTK_MULTIDISPLAY */ |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
170 } |
50129
d0142038feaa
Reduce flicker in GTK scrollbars.
Jan Djärv <jan.h.d@swipnet.se>
parents:
50112
diff
changeset
|
171 |
49323 | 172 |
173 /*********************************************************************** | |
174 Utility functions | |
175 ***********************************************************************/ | |
176 /* The timer for scroll bar repetition and menu bar timeouts. | |
177 NULL if no timer is started. */ | |
178 static struct atimer *xg_timer; | |
179 | |
180 | |
181 /* The next two variables and functions are taken from lwlib. */ | |
182 static widget_value *widget_value_free_list; | |
183 static int malloc_cpt; | |
184 | |
185 /* Allocate a widget_value structure, either by taking one from the | |
186 widget_value_free_list or by malloc:ing a new one. | |
187 | |
188 Return a pointer to the allocated structure. */ | |
57715
cdc48cdd5b0e
* gtkutil.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57597
diff
changeset
|
189 |
49323 | 190 widget_value * |
191 malloc_widget_value () | |
192 { | |
193 widget_value *wv; | |
194 if (widget_value_free_list) | |
195 { | |
196 wv = widget_value_free_list; | |
197 widget_value_free_list = wv->free_list; | |
198 wv->free_list = 0; | |
199 } | |
200 else | |
201 { | |
69025
5d9232b72d14
(malloc_widget_value): Use xmalloc.
Richard M. Stallman <rms@gnu.org>
parents:
68922
diff
changeset
|
202 wv = (widget_value *) xmalloc (sizeof (widget_value)); |
49323 | 203 malloc_cpt++; |
204 } | |
205 memset (wv, 0, sizeof (widget_value)); | |
206 return wv; | |
207 } | |
208 | |
209 /* This is analogous to free. It frees only what was allocated | |
210 by malloc_widget_value, and no substructures. */ | |
57715
cdc48cdd5b0e
* gtkutil.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57597
diff
changeset
|
211 |
49323 | 212 void |
213 free_widget_value (wv) | |
214 widget_value *wv; | |
215 { | |
216 if (wv->free_list) | |
217 abort (); | |
218 | |
219 if (malloc_cpt > 25) | |
220 { | |
221 /* When the number of already allocated cells is too big, | |
222 We free it. */ | |
223 free (wv); | |
224 malloc_cpt--; | |
225 } | |
226 else | |
227 { | |
228 wv->free_list = widget_value_free_list; | |
229 widget_value_free_list = wv; | |
230 } | |
231 } | |
232 | |
53069
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
233 |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
234 /* Create and return the cursor to be used for popup menus and |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
235 scroll bars on display DPY. */ |
57715
cdc48cdd5b0e
* gtkutil.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57597
diff
changeset
|
236 |
53069
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
237 GdkCursor * |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
238 xg_create_default_cursor (dpy) |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
239 Display *dpy; |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
240 { |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
241 GdkDisplay *gdpy = gdk_x11_lookup_xdisplay (dpy); |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
242 return gdk_cursor_new_for_display (gdpy, GDK_LEFT_PTR); |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
243 } |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
244 |
64936
d5e998f50c2d
* gtkutil.c (xg_get_pixbuf_from_pix_and_mask): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
64783
diff
changeset
|
245 /* Apply GMASK to GPIX and return a GdkPixbuf with an alpha channel. */ |
d5e998f50c2d
* gtkutil.c (xg_get_pixbuf_from_pix_and_mask): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
64783
diff
changeset
|
246 |
65006
ec2fa2e1d4ea
* gtkutil.c (xg_set_frame_icon): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
64936
diff
changeset
|
247 static GdkPixbuf * |
64936
d5e998f50c2d
* gtkutil.c (xg_get_pixbuf_from_pix_and_mask): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
64783
diff
changeset
|
248 xg_get_pixbuf_from_pix_and_mask (gpix, gmask, cmap) |
d5e998f50c2d
* gtkutil.c (xg_get_pixbuf_from_pix_and_mask): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
64783
diff
changeset
|
249 GdkPixmap *gpix; |
d5e998f50c2d
* gtkutil.c (xg_get_pixbuf_from_pix_and_mask): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
64783
diff
changeset
|
250 GdkPixmap *gmask; |
d5e998f50c2d
* gtkutil.c (xg_get_pixbuf_from_pix_and_mask): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
64783
diff
changeset
|
251 GdkColormap *cmap; |
d5e998f50c2d
* gtkutil.c (xg_get_pixbuf_from_pix_and_mask): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
64783
diff
changeset
|
252 { |
d5e998f50c2d
* gtkutil.c (xg_get_pixbuf_from_pix_and_mask): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
64783
diff
changeset
|
253 int x, y, width, height, rowstride, mask_rowstride; |
d5e998f50c2d
* gtkutil.c (xg_get_pixbuf_from_pix_and_mask): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
64783
diff
changeset
|
254 GdkPixbuf *icon_buf, *tmp_buf; |
d5e998f50c2d
* gtkutil.c (xg_get_pixbuf_from_pix_and_mask): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
64783
diff
changeset
|
255 guchar *pixels; |
d5e998f50c2d
* gtkutil.c (xg_get_pixbuf_from_pix_and_mask): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
64783
diff
changeset
|
256 guchar *mask_pixels; |
d5e998f50c2d
* gtkutil.c (xg_get_pixbuf_from_pix_and_mask): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
64783
diff
changeset
|
257 |
d5e998f50c2d
* gtkutil.c (xg_get_pixbuf_from_pix_and_mask): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
64783
diff
changeset
|
258 gdk_drawable_get_size (gpix, &width, &height); |
d5e998f50c2d
* gtkutil.c (xg_get_pixbuf_from_pix_and_mask): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
64783
diff
changeset
|
259 tmp_buf = gdk_pixbuf_get_from_drawable (NULL, gpix, cmap, |
d5e998f50c2d
* gtkutil.c (xg_get_pixbuf_from_pix_and_mask): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
64783
diff
changeset
|
260 0, 0, 0, 0, width, height); |
d5e998f50c2d
* gtkutil.c (xg_get_pixbuf_from_pix_and_mask): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
64783
diff
changeset
|
261 icon_buf = gdk_pixbuf_add_alpha (tmp_buf, FALSE, 0, 0, 0); |
d5e998f50c2d
* gtkutil.c (xg_get_pixbuf_from_pix_and_mask): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
64783
diff
changeset
|
262 g_object_unref (G_OBJECT (tmp_buf)); |
d5e998f50c2d
* gtkutil.c (xg_get_pixbuf_from_pix_and_mask): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
64783
diff
changeset
|
263 |
d5e998f50c2d
* gtkutil.c (xg_get_pixbuf_from_pix_and_mask): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
64783
diff
changeset
|
264 if (gmask) |
d5e998f50c2d
* gtkutil.c (xg_get_pixbuf_from_pix_and_mask): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
64783
diff
changeset
|
265 { |
d5e998f50c2d
* gtkutil.c (xg_get_pixbuf_from_pix_and_mask): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
64783
diff
changeset
|
266 GdkPixbuf *mask_buf = gdk_pixbuf_get_from_drawable (NULL, |
d5e998f50c2d
* gtkutil.c (xg_get_pixbuf_from_pix_and_mask): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
64783
diff
changeset
|
267 gmask, |
d5e998f50c2d
* gtkutil.c (xg_get_pixbuf_from_pix_and_mask): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
64783
diff
changeset
|
268 NULL, |
d5e998f50c2d
* gtkutil.c (xg_get_pixbuf_from_pix_and_mask): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
64783
diff
changeset
|
269 0, 0, 0, 0, |
d5e998f50c2d
* gtkutil.c (xg_get_pixbuf_from_pix_and_mask): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
64783
diff
changeset
|
270 width, height); |
d5e998f50c2d
* gtkutil.c (xg_get_pixbuf_from_pix_and_mask): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
64783
diff
changeset
|
271 guchar *pixels = gdk_pixbuf_get_pixels (icon_buf); |
d5e998f50c2d
* gtkutil.c (xg_get_pixbuf_from_pix_and_mask): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
64783
diff
changeset
|
272 guchar *mask_pixels = gdk_pixbuf_get_pixels (mask_buf); |
d5e998f50c2d
* gtkutil.c (xg_get_pixbuf_from_pix_and_mask): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
64783
diff
changeset
|
273 int rowstride = gdk_pixbuf_get_rowstride (icon_buf); |
d5e998f50c2d
* gtkutil.c (xg_get_pixbuf_from_pix_and_mask): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
64783
diff
changeset
|
274 int mask_rowstride = gdk_pixbuf_get_rowstride (mask_buf); |
d5e998f50c2d
* gtkutil.c (xg_get_pixbuf_from_pix_and_mask): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
64783
diff
changeset
|
275 int y; |
d5e998f50c2d
* gtkutil.c (xg_get_pixbuf_from_pix_and_mask): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
64783
diff
changeset
|
276 |
d5e998f50c2d
* gtkutil.c (xg_get_pixbuf_from_pix_and_mask): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
64783
diff
changeset
|
277 for (y = 0; y < height; ++y) |
d5e998f50c2d
* gtkutil.c (xg_get_pixbuf_from_pix_and_mask): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
64783
diff
changeset
|
278 { |
d5e998f50c2d
* gtkutil.c (xg_get_pixbuf_from_pix_and_mask): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
64783
diff
changeset
|
279 guchar *iconptr, *maskptr; |
d5e998f50c2d
* gtkutil.c (xg_get_pixbuf_from_pix_and_mask): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
64783
diff
changeset
|
280 int x; |
d5e998f50c2d
* gtkutil.c (xg_get_pixbuf_from_pix_and_mask): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
64783
diff
changeset
|
281 |
d5e998f50c2d
* gtkutil.c (xg_get_pixbuf_from_pix_and_mask): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
64783
diff
changeset
|
282 iconptr = pixels + y * rowstride; |
d5e998f50c2d
* gtkutil.c (xg_get_pixbuf_from_pix_and_mask): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
64783
diff
changeset
|
283 maskptr = mask_pixels + y * mask_rowstride; |
d5e998f50c2d
* gtkutil.c (xg_get_pixbuf_from_pix_and_mask): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
64783
diff
changeset
|
284 |
d5e998f50c2d
* gtkutil.c (xg_get_pixbuf_from_pix_and_mask): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
64783
diff
changeset
|
285 for (x = 0; x < width; ++x) |
d5e998f50c2d
* gtkutil.c (xg_get_pixbuf_from_pix_and_mask): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
64783
diff
changeset
|
286 { |
d5e998f50c2d
* gtkutil.c (xg_get_pixbuf_from_pix_and_mask): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
64783
diff
changeset
|
287 /* In a bitmap, RGB is either 255/255/255 or 0/0/0. Checking |
d5e998f50c2d
* gtkutil.c (xg_get_pixbuf_from_pix_and_mask): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
64783
diff
changeset
|
288 just R is sufficient. */ |
d5e998f50c2d
* gtkutil.c (xg_get_pixbuf_from_pix_and_mask): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
64783
diff
changeset
|
289 if (maskptr[0] == 0) |
d5e998f50c2d
* gtkutil.c (xg_get_pixbuf_from_pix_and_mask): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
64783
diff
changeset
|
290 iconptr[3] = 0; /* 0, 1, 2 is R, G, B. 3 is alpha. */ |
d5e998f50c2d
* gtkutil.c (xg_get_pixbuf_from_pix_and_mask): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
64783
diff
changeset
|
291 |
d5e998f50c2d
* gtkutil.c (xg_get_pixbuf_from_pix_and_mask): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
64783
diff
changeset
|
292 iconptr += rowstride/width; |
d5e998f50c2d
* gtkutil.c (xg_get_pixbuf_from_pix_and_mask): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
64783
diff
changeset
|
293 maskptr += mask_rowstride/width; |
d5e998f50c2d
* gtkutil.c (xg_get_pixbuf_from_pix_and_mask): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
64783
diff
changeset
|
294 } |
d5e998f50c2d
* gtkutil.c (xg_get_pixbuf_from_pix_and_mask): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
64783
diff
changeset
|
295 } |
d5e998f50c2d
* gtkutil.c (xg_get_pixbuf_from_pix_and_mask): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
64783
diff
changeset
|
296 |
d5e998f50c2d
* gtkutil.c (xg_get_pixbuf_from_pix_and_mask): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
64783
diff
changeset
|
297 g_object_unref (G_OBJECT (mask_buf)); |
d5e998f50c2d
* gtkutil.c (xg_get_pixbuf_from_pix_and_mask): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
64783
diff
changeset
|
298 } |
d5e998f50c2d
* gtkutil.c (xg_get_pixbuf_from_pix_and_mask): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
64783
diff
changeset
|
299 |
d5e998f50c2d
* gtkutil.c (xg_get_pixbuf_from_pix_and_mask): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
64783
diff
changeset
|
300 return icon_buf; |
d5e998f50c2d
* gtkutil.c (xg_get_pixbuf_from_pix_and_mask): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
64783
diff
changeset
|
301 } |
d5e998f50c2d
* gtkutil.c (xg_get_pixbuf_from_pix_and_mask): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
64783
diff
changeset
|
302 |
56112
e4cfda8330d5
* gtkutil.c (xg_get_image_for_pixmap): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
55342
diff
changeset
|
303 /* For the image defined in IMG, make and return a GtkImage. For displays with |
e4cfda8330d5
* gtkutil.c (xg_get_image_for_pixmap): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
55342
diff
changeset
|
304 8 planes or less we must make a GdkPixbuf and apply the mask manually. |
e4cfda8330d5
* gtkutil.c (xg_get_image_for_pixmap): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
55342
diff
changeset
|
305 Otherwise the highlightning and dimming the tool bar code in GTK does |
e4cfda8330d5
* gtkutil.c (xg_get_image_for_pixmap): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
55342
diff
changeset
|
306 will look bad. For display with more than 8 planes we just use the |
e4cfda8330d5
* gtkutil.c (xg_get_image_for_pixmap): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
55342
diff
changeset
|
307 pixmap and mask directly. For monochrome displays, GTK doesn't seem |
e4cfda8330d5
* gtkutil.c (xg_get_image_for_pixmap): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
55342
diff
changeset
|
308 able to use external pixmaps, it looks bad whatever we do. |
e4cfda8330d5
* gtkutil.c (xg_get_image_for_pixmap): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
55342
diff
changeset
|
309 The image is defined on the display where frame F is. |
e4cfda8330d5
* gtkutil.c (xg_get_image_for_pixmap): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
55342
diff
changeset
|
310 WIDGET is used to find the GdkColormap to use for the GdkPixbuf. |
e4cfda8330d5
* gtkutil.c (xg_get_image_for_pixmap): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
55342
diff
changeset
|
311 If OLD_WIDGET is NULL, a new widget is constructed and returned. |
e4cfda8330d5
* gtkutil.c (xg_get_image_for_pixmap): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
55342
diff
changeset
|
312 If OLD_WIDGET is not NULL, that widget is modified. */ |
57715
cdc48cdd5b0e
* gtkutil.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57597
diff
changeset
|
313 |
56112
e4cfda8330d5
* gtkutil.c (xg_get_image_for_pixmap): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
55342
diff
changeset
|
314 static GtkWidget * |
e4cfda8330d5
* gtkutil.c (xg_get_image_for_pixmap): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
55342
diff
changeset
|
315 xg_get_image_for_pixmap (f, img, widget, old_widget) |
53069
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
316 FRAME_PTR f; |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
317 struct image *img; |
56112
e4cfda8330d5
* gtkutil.c (xg_get_image_for_pixmap): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
55342
diff
changeset
|
318 GtkWidget *widget; |
e4cfda8330d5
* gtkutil.c (xg_get_image_for_pixmap): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
55342
diff
changeset
|
319 GtkImage *old_widget; |
53069
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
320 { |
56112
e4cfda8330d5
* gtkutil.c (xg_get_image_for_pixmap): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
55342
diff
changeset
|
321 GdkPixmap *gpix; |
e4cfda8330d5
* gtkutil.c (xg_get_image_for_pixmap): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
55342
diff
changeset
|
322 GdkPixmap *gmask; |
56269
4f8b4f60e748
(xg_get_image_for_pixmap): Add workaround for monochrome displays
Jan Djärv <jan.h.d@swipnet.se>
parents:
56268
diff
changeset
|
323 GdkDisplay *gdpy; |
4f8b4f60e748
(xg_get_image_for_pixmap): Add workaround for monochrome displays
Jan Djärv <jan.h.d@swipnet.se>
parents:
56268
diff
changeset
|
324 |
68027
606e8e24acfe
* gtkutil.c (xg_get_image_for_pixmap): If the image is from a file,
Jan Djärv <jan.h.d@swipnet.se>
parents:
67875
diff
changeset
|
325 /* If we have a file, let GTK do all the image handling. |
56269
4f8b4f60e748
(xg_get_image_for_pixmap): Add workaround for monochrome displays
Jan Djärv <jan.h.d@swipnet.se>
parents:
56268
diff
changeset
|
326 This seems to be the only way to make insensitive and activated icons |
68027
606e8e24acfe
* gtkutil.c (xg_get_image_for_pixmap): If the image is from a file,
Jan Djärv <jan.h.d@swipnet.se>
parents:
67875
diff
changeset
|
327 look good in all cases. */ |
606e8e24acfe
* gtkutil.c (xg_get_image_for_pixmap): If the image is from a file,
Jan Djärv <jan.h.d@swipnet.se>
parents:
67875
diff
changeset
|
328 Lisp_Object specified_file = Qnil; |
606e8e24acfe
* gtkutil.c (xg_get_image_for_pixmap): If the image is from a file,
Jan Djärv <jan.h.d@swipnet.se>
parents:
67875
diff
changeset
|
329 Lisp_Object tail; |
69141
6b335e9ea577
* gtkutil.c (xg_get_image_for_pixmap): If x_find_image_file returns
Jan Djärv <jan.h.d@swipnet.se>
parents:
69025
diff
changeset
|
330 Lisp_Object file; |
68027
606e8e24acfe
* gtkutil.c (xg_get_image_for_pixmap): If the image is from a file,
Jan Djärv <jan.h.d@swipnet.se>
parents:
67875
diff
changeset
|
331 extern Lisp_Object QCfile; |
606e8e24acfe
* gtkutil.c (xg_get_image_for_pixmap): If the image is from a file,
Jan Djärv <jan.h.d@swipnet.se>
parents:
67875
diff
changeset
|
332 |
606e8e24acfe
* gtkutil.c (xg_get_image_for_pixmap): If the image is from a file,
Jan Djärv <jan.h.d@swipnet.se>
parents:
67875
diff
changeset
|
333 for (tail = XCDR (img->spec); |
606e8e24acfe
* gtkutil.c (xg_get_image_for_pixmap): If the image is from a file,
Jan Djärv <jan.h.d@swipnet.se>
parents:
67875
diff
changeset
|
334 NILP (specified_file) && CONSP (tail) && CONSP (XCDR (tail)); |
606e8e24acfe
* gtkutil.c (xg_get_image_for_pixmap): If the image is from a file,
Jan Djärv <jan.h.d@swipnet.se>
parents:
67875
diff
changeset
|
335 tail = XCDR (XCDR (tail))) |
606e8e24acfe
* gtkutil.c (xg_get_image_for_pixmap): If the image is from a file,
Jan Djärv <jan.h.d@swipnet.se>
parents:
67875
diff
changeset
|
336 if (EQ (XCAR (tail), QCfile)) |
606e8e24acfe
* gtkutil.c (xg_get_image_for_pixmap): If the image is from a file,
Jan Djärv <jan.h.d@swipnet.se>
parents:
67875
diff
changeset
|
337 specified_file = XCAR (XCDR (tail)); |
606e8e24acfe
* gtkutil.c (xg_get_image_for_pixmap): If the image is from a file,
Jan Djärv <jan.h.d@swipnet.se>
parents:
67875
diff
changeset
|
338 |
69141
6b335e9ea577
* gtkutil.c (xg_get_image_for_pixmap): If x_find_image_file returns
Jan Djärv <jan.h.d@swipnet.se>
parents:
69025
diff
changeset
|
339 /* We already loaded the image once before calling this |
6b335e9ea577
* gtkutil.c (xg_get_image_for_pixmap): If x_find_image_file returns
Jan Djärv <jan.h.d@swipnet.se>
parents:
69025
diff
changeset
|
340 function, so this only fails if the image file has been removed. |
6b335e9ea577
* gtkutil.c (xg_get_image_for_pixmap): If x_find_image_file returns
Jan Djärv <jan.h.d@swipnet.se>
parents:
69025
diff
changeset
|
341 In that case, use the pixmap already loaded. */ |
6b335e9ea577
* gtkutil.c (xg_get_image_for_pixmap): If x_find_image_file returns
Jan Djärv <jan.h.d@swipnet.se>
parents:
69025
diff
changeset
|
342 |
6b335e9ea577
* gtkutil.c (xg_get_image_for_pixmap): If x_find_image_file returns
Jan Djärv <jan.h.d@swipnet.se>
parents:
69025
diff
changeset
|
343 if (STRINGP (specified_file) |
6b335e9ea577
* gtkutil.c (xg_get_image_for_pixmap): If x_find_image_file returns
Jan Djärv <jan.h.d@swipnet.se>
parents:
69025
diff
changeset
|
344 && STRINGP (file = x_find_image_file (specified_file))) |
56269
4f8b4f60e748
(xg_get_image_for_pixmap): Add workaround for monochrome displays
Jan Djärv <jan.h.d@swipnet.se>
parents:
56268
diff
changeset
|
345 { |
68027
606e8e24acfe
* gtkutil.c (xg_get_image_for_pixmap): If the image is from a file,
Jan Djärv <jan.h.d@swipnet.se>
parents:
67875
diff
changeset
|
346 if (! old_widget) |
606e8e24acfe
* gtkutil.c (xg_get_image_for_pixmap): If the image is from a file,
Jan Djärv <jan.h.d@swipnet.se>
parents:
67875
diff
changeset
|
347 old_widget = GTK_IMAGE (gtk_image_new_from_file (SSDATA (file))); |
606e8e24acfe
* gtkutil.c (xg_get_image_for_pixmap): If the image is from a file,
Jan Djärv <jan.h.d@swipnet.se>
parents:
67875
diff
changeset
|
348 else |
606e8e24acfe
* gtkutil.c (xg_get_image_for_pixmap): If the image is from a file,
Jan Djärv <jan.h.d@swipnet.se>
parents:
67875
diff
changeset
|
349 gtk_image_set_from_file (old_widget, SSDATA (file)); |
606e8e24acfe
* gtkutil.c (xg_get_image_for_pixmap): If the image is from a file,
Jan Djärv <jan.h.d@swipnet.se>
parents:
67875
diff
changeset
|
350 |
606e8e24acfe
* gtkutil.c (xg_get_image_for_pixmap): If the image is from a file,
Jan Djärv <jan.h.d@swipnet.se>
parents:
67875
diff
changeset
|
351 return GTK_WIDGET (old_widget); |
56269
4f8b4f60e748
(xg_get_image_for_pixmap): Add workaround for monochrome displays
Jan Djärv <jan.h.d@swipnet.se>
parents:
56268
diff
changeset
|
352 } |
4f8b4f60e748
(xg_get_image_for_pixmap): Add workaround for monochrome displays
Jan Djärv <jan.h.d@swipnet.se>
parents:
56268
diff
changeset
|
353 |
68027
606e8e24acfe
* gtkutil.c (xg_get_image_for_pixmap): If the image is from a file,
Jan Djärv <jan.h.d@swipnet.se>
parents:
67875
diff
changeset
|
354 /* No file, do the image handling ourselves. This will look very bad |
606e8e24acfe
* gtkutil.c (xg_get_image_for_pixmap): If the image is from a file,
Jan Djärv <jan.h.d@swipnet.se>
parents:
67875
diff
changeset
|
355 on a monochrome display, and sometimes bad on all displays with |
606e8e24acfe
* gtkutil.c (xg_get_image_for_pixmap): If the image is from a file,
Jan Djärv <jan.h.d@swipnet.se>
parents:
67875
diff
changeset
|
356 certain themes. */ |
606e8e24acfe
* gtkutil.c (xg_get_image_for_pixmap): If the image is from a file,
Jan Djärv <jan.h.d@swipnet.se>
parents:
67875
diff
changeset
|
357 |
56269
4f8b4f60e748
(xg_get_image_for_pixmap): Add workaround for monochrome displays
Jan Djärv <jan.h.d@swipnet.se>
parents:
56268
diff
changeset
|
358 gdpy = gdk_x11_lookup_xdisplay (FRAME_X_DISPLAY (f)); |
56112
e4cfda8330d5
* gtkutil.c (xg_get_image_for_pixmap): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
55342
diff
changeset
|
359 gpix = gdk_pixmap_foreign_new_for_display (gdpy, img->pixmap); |
e4cfda8330d5
* gtkutil.c (xg_get_image_for_pixmap): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
55342
diff
changeset
|
360 gmask = img->mask ? gdk_pixmap_foreign_new_for_display (gdpy, img->mask) : 0; |
e4cfda8330d5
* gtkutil.c (xg_get_image_for_pixmap): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
55342
diff
changeset
|
361 |
e4cfda8330d5
* gtkutil.c (xg_get_image_for_pixmap): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
55342
diff
changeset
|
362 if (x_screen_planes (f) > 8 || x_screen_planes (f) == 1) |
e4cfda8330d5
* gtkutil.c (xg_get_image_for_pixmap): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
55342
diff
changeset
|
363 { |
e4cfda8330d5
* gtkutil.c (xg_get_image_for_pixmap): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
55342
diff
changeset
|
364 if (! old_widget) |
e4cfda8330d5
* gtkutil.c (xg_get_image_for_pixmap): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
55342
diff
changeset
|
365 old_widget = GTK_IMAGE (gtk_image_new_from_pixmap (gpix, gmask)); |
e4cfda8330d5
* gtkutil.c (xg_get_image_for_pixmap): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
55342
diff
changeset
|
366 else |
e4cfda8330d5
* gtkutil.c (xg_get_image_for_pixmap): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
55342
diff
changeset
|
367 gtk_image_set_from_pixmap (old_widget, gpix, gmask); |
e4cfda8330d5
* gtkutil.c (xg_get_image_for_pixmap): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
55342
diff
changeset
|
368 } |
e4cfda8330d5
* gtkutil.c (xg_get_image_for_pixmap): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
55342
diff
changeset
|
369 else |
e4cfda8330d5
* gtkutil.c (xg_get_image_for_pixmap): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
55342
diff
changeset
|
370 { |
64936
d5e998f50c2d
* gtkutil.c (xg_get_pixbuf_from_pix_and_mask): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
64783
diff
changeset
|
371 |
56269
4f8b4f60e748
(xg_get_image_for_pixmap): Add workaround for monochrome displays
Jan Djärv <jan.h.d@swipnet.se>
parents:
56268
diff
changeset
|
372 /* This is a workaround to make icons look good on pseudo color |
4f8b4f60e748
(xg_get_image_for_pixmap): Add workaround for monochrome displays
Jan Djärv <jan.h.d@swipnet.se>
parents:
56268
diff
changeset
|
373 displays. Apparently GTK expects the images to have an alpha |
4f8b4f60e748
(xg_get_image_for_pixmap): Add workaround for monochrome displays
Jan Djärv <jan.h.d@swipnet.se>
parents:
56268
diff
changeset
|
374 channel. If they don't, insensitive and activated icons will |
4f8b4f60e748
(xg_get_image_for_pixmap): Add workaround for monochrome displays
Jan Djärv <jan.h.d@swipnet.se>
parents:
56268
diff
changeset
|
375 look bad. This workaround does not work on monochrome displays, |
4f8b4f60e748
(xg_get_image_for_pixmap): Add workaround for monochrome displays
Jan Djärv <jan.h.d@swipnet.se>
parents:
56268
diff
changeset
|
376 and is not needed on true color/static color displays (i.e. |
4f8b4f60e748
(xg_get_image_for_pixmap): Add workaround for monochrome displays
Jan Djärv <jan.h.d@swipnet.se>
parents:
56268
diff
changeset
|
377 16 bits and higher). */ |
64936
d5e998f50c2d
* gtkutil.c (xg_get_pixbuf_from_pix_and_mask): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
64783
diff
changeset
|
378 GdkColormap *cmap = gtk_widget_get_colormap (widget); |
d5e998f50c2d
* gtkutil.c (xg_get_pixbuf_from_pix_and_mask): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
64783
diff
changeset
|
379 GdkPixbuf *icon_buf = xg_get_pixbuf_from_pix_and_mask (gpix, gmask, cmap); |
56112
e4cfda8330d5
* gtkutil.c (xg_get_image_for_pixmap): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
55342
diff
changeset
|
380 |
e4cfda8330d5
* gtkutil.c (xg_get_image_for_pixmap): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
55342
diff
changeset
|
381 if (! old_widget) |
e4cfda8330d5
* gtkutil.c (xg_get_image_for_pixmap): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
55342
diff
changeset
|
382 old_widget = GTK_IMAGE (gtk_image_new_from_pixbuf (icon_buf)); |
e4cfda8330d5
* gtkutil.c (xg_get_image_for_pixmap): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
55342
diff
changeset
|
383 else |
e4cfda8330d5
* gtkutil.c (xg_get_image_for_pixmap): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
55342
diff
changeset
|
384 gtk_image_set_from_pixbuf (old_widget, icon_buf); |
e4cfda8330d5
* gtkutil.c (xg_get_image_for_pixmap): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
55342
diff
changeset
|
385 |
e4cfda8330d5
* gtkutil.c (xg_get_image_for_pixmap): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
55342
diff
changeset
|
386 g_object_unref (G_OBJECT (icon_buf)); |
e4cfda8330d5
* gtkutil.c (xg_get_image_for_pixmap): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
55342
diff
changeset
|
387 } |
e4cfda8330d5
* gtkutil.c (xg_get_image_for_pixmap): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
55342
diff
changeset
|
388 |
56268
9853134cd610
* gtkutil.c (xg_get_image_for_pixmap): Call g_object_unref on
Jan Djärv <jan.h.d@swipnet.se>
parents:
56112
diff
changeset
|
389 g_object_unref (G_OBJECT (gpix)); |
9853134cd610
* gtkutil.c (xg_get_image_for_pixmap): Call g_object_unref on
Jan Djärv <jan.h.d@swipnet.se>
parents:
56112
diff
changeset
|
390 if (gmask) g_object_unref (G_OBJECT (gmask)); |
9853134cd610
* gtkutil.c (xg_get_image_for_pixmap): Call g_object_unref on
Jan Djärv <jan.h.d@swipnet.se>
parents:
56112
diff
changeset
|
391 |
56112
e4cfda8330d5
* gtkutil.c (xg_get_image_for_pixmap): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
55342
diff
changeset
|
392 return GTK_WIDGET (old_widget); |
53069
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
393 } |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
394 |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
395 |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
396 /* Set CURSOR on W and all widgets W contain. We must do like this |
49323 | 397 for scroll bars and menu because they create widgets internally, |
53069
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
398 and it is those widgets that are visible. */ |
57715
cdc48cdd5b0e
* gtkutil.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57597
diff
changeset
|
399 |
53069
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
400 static void |
49323 | 401 xg_set_cursor (w, cursor) |
402 GtkWidget *w; | |
53069
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
403 GdkCursor *cursor; |
49323 | 404 { |
405 GList *children = gdk_window_peek_children (w->window); | |
406 | |
53069
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
407 gdk_window_set_cursor (w->window, cursor); |
49323 | 408 |
409 /* The scroll bar widget has more than one GDK window (had to look at | |
410 the source to figure this out), and there is no way to set cursor | |
411 on widgets in GTK. So we must set the cursor for all GDK windows. | |
412 Ditto for menus. */ | |
413 | |
414 for ( ; children; children = g_list_next (children)) | |
53069
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
415 gdk_window_set_cursor (GDK_WINDOW (children->data), cursor); |
49323 | 416 } |
417 | |
418 /* Timer function called when a timeout occurs for xg_timer. | |
419 This function processes all GTK events in a recursive event loop. | |
420 This is done because GTK timer events are not seen by Emacs event | |
421 detection, Emacs only looks for X events. When a scroll bar has the | |
422 pointer (detected by button press/release events below) an Emacs | |
423 timer is started, and this function can then check if the GTK timer | |
424 has expired by calling the GTK event loop. | |
425 Also, when a menu is active, it has a small timeout before it | |
426 pops down the sub menu under it. */ | |
57715
cdc48cdd5b0e
* gtkutil.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57597
diff
changeset
|
427 |
49323 | 428 static void |
429 xg_process_timeouts (timer) | |
430 struct atimer *timer; | |
431 { | |
432 BLOCK_INPUT; | |
433 /* Ideally we would like to just handle timer events, like the Xt version | |
434 of this does in xterm.c, but there is no such feature in GTK. */ | |
435 while (gtk_events_pending ()) | |
436 gtk_main_iteration (); | |
437 UNBLOCK_INPUT; | |
438 } | |
439 | |
440 /* Start the xg_timer with an interval of 0.1 seconds, if not already started. | |
441 xg_process_timeouts is called when the timer expires. The timer | |
50270
fa50953c02dc
Finally (?) fix flicker in scroll bar.
Jan Djärv <jan.h.d@swipnet.se>
parents:
50192
diff
changeset
|
442 started is continuous, i.e. runs until xg_stop_timer is called. */ |
57715
cdc48cdd5b0e
* gtkutil.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57597
diff
changeset
|
443 |
49323 | 444 static void |
445 xg_start_timer () | |
446 { | |
447 if (! xg_timer) | |
448 { | |
449 EMACS_TIME interval; | |
450 EMACS_SET_SECS_USECS (interval, 0, 100000); | |
451 xg_timer = start_atimer (ATIMER_CONTINUOUS, | |
452 interval, | |
453 xg_process_timeouts, | |
454 0); | |
455 } | |
456 } | |
457 | |
458 /* Stop the xg_timer if started. */ | |
57715
cdc48cdd5b0e
* gtkutil.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57597
diff
changeset
|
459 |
49323 | 460 static void |
461 xg_stop_timer () | |
462 { | |
463 if (xg_timer) | |
464 { | |
465 cancel_atimer (xg_timer); | |
466 xg_timer = 0; | |
467 } | |
468 } | |
469 | |
470 /* Insert NODE into linked LIST. */ | |
57715
cdc48cdd5b0e
* gtkutil.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57597
diff
changeset
|
471 |
49323 | 472 static void |
473 xg_list_insert (xg_list_node *list, xg_list_node *node) | |
474 { | |
475 xg_list_node *list_start = list->next; | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
476 |
49323 | 477 if (list_start) list_start->prev = node; |
478 node->next = list_start; | |
479 node->prev = 0; | |
480 list->next = node; | |
481 } | |
482 | |
483 /* Remove NODE from linked LIST. */ | |
57715
cdc48cdd5b0e
* gtkutil.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57597
diff
changeset
|
484 |
49323 | 485 static void |
486 xg_list_remove (xg_list_node *list, xg_list_node *node) | |
487 { | |
488 xg_list_node *list_start = list->next; | |
489 if (node == list_start) | |
490 { | |
491 list->next = node->next; | |
492 if (list->next) list->next->prev = 0; | |
493 } | |
494 else | |
495 { | |
496 node->prev->next = node->next; | |
497 if (node->next) node->next->prev = node->prev; | |
498 } | |
499 } | |
500 | |
501 /* Allocate and return a utf8 version of STR. If STR is already | |
502 utf8 or NULL, just return STR. | |
503 If not, a new string is allocated and the caller must free the result | |
504 with g_free. */ | |
57715
cdc48cdd5b0e
* gtkutil.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57597
diff
changeset
|
505 |
49323 | 506 static char * |
507 get_utf8_string (str) | |
508 char *str; | |
509 { | |
510 char *utf8_str = str; | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
511 |
49323 | 512 /* If not UTF-8, try current locale. */ |
513 if (str && !g_utf8_validate (str, -1, NULL)) | |
514 utf8_str = g_locale_to_utf8 (str, -1, 0, 0, 0); | |
515 | |
516 return utf8_str; | |
517 } | |
518 | |
519 | |
520 | |
521 /*********************************************************************** | |
522 General functions for creating widgets, resizing, events, e.t.c. | |
523 ***********************************************************************/ | |
524 | |
525 /* Make a geometry string and pass that to GTK. It seems this is the | |
526 only way to get geometry position right if the user explicitly | |
527 asked for a position when starting Emacs. | |
528 F is the frame we shall set geometry for. */ | |
57715
cdc48cdd5b0e
* gtkutil.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57597
diff
changeset
|
529 |
49323 | 530 static void |
531 xg_set_geometry (f) | |
532 FRAME_PTR f; | |
533 { | |
51211
28ea05de2dc5
Make (many) trivial substitutions for renamed and
Kim F. Storm <storm@cua.dk>
parents:
50778
diff
changeset
|
534 if (f->size_hint_flags & USPosition) |
49323 | 535 { |
51211
28ea05de2dc5
Make (many) trivial substitutions for renamed and
Kim F. Storm <storm@cua.dk>
parents:
50778
diff
changeset
|
536 int left = f->left_pos; |
28ea05de2dc5
Make (many) trivial substitutions for renamed and
Kim F. Storm <storm@cua.dk>
parents:
50778
diff
changeset
|
537 int xneg = f->size_hint_flags & XNegative; |
28ea05de2dc5
Make (many) trivial substitutions for renamed and
Kim F. Storm <storm@cua.dk>
parents:
50778
diff
changeset
|
538 int top = f->top_pos; |
28ea05de2dc5
Make (many) trivial substitutions for renamed and
Kim F. Storm <storm@cua.dk>
parents:
50778
diff
changeset
|
539 int yneg = f->size_hint_flags & YNegative; |
49323 | 540 char geom_str[32]; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
541 |
49323 | 542 if (xneg) |
543 left = -left; | |
544 if (yneg) | |
545 top = -top; | |
546 | |
547 sprintf (geom_str, "=%dx%d%c%d%c%d", | |
51211
28ea05de2dc5
Make (many) trivial substitutions for renamed and
Kim F. Storm <storm@cua.dk>
parents:
50778
diff
changeset
|
548 FRAME_PIXEL_WIDTH (f), |
49323 | 549 FRAME_TOTAL_PIXEL_HEIGHT (f), |
550 (xneg ? '-' : '+'), left, | |
551 (yneg ? '-' : '+'), top); | |
552 | |
553 if (!gtk_window_parse_geometry (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)), | |
554 geom_str)) | |
555 fprintf (stderr, "Failed to parse: '%s'\n", geom_str); | |
65628
a998f173b21a
* gtkutil.c (xg_set_geometry): Do a gtk_window_move if program
Jan Djärv <jan.h.d@swipnet.se>
parents:
65006
diff
changeset
|
556 } else if (f->size_hint_flags & PPosition) { |
a998f173b21a
* gtkutil.c (xg_set_geometry): Do a gtk_window_move if program
Jan Djärv <jan.h.d@swipnet.se>
parents:
65006
diff
changeset
|
557 gtk_window_move (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)), |
a998f173b21a
* gtkutil.c (xg_set_geometry): Do a gtk_window_move if program
Jan Djärv <jan.h.d@swipnet.se>
parents:
65006
diff
changeset
|
558 f->left_pos, f->top_pos); |
49323 | 559 } |
560 } | |
561 | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
562 |
49323 | 563 /* Resize the outer window of frame F after chainging the height. |
564 This happend when the menu bar or the tool bar is added or removed. | |
565 COLUMNS/ROWS is the size the edit area shall have after the resize. */ | |
57715
cdc48cdd5b0e
* gtkutil.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57597
diff
changeset
|
566 |
49323 | 567 static void |
568 xg_resize_outer_widget (f, columns, rows) | |
569 FRAME_PTR f; | |
570 int columns; | |
571 int rows; | |
572 { | |
573 /* If we are not mapped yet, set geometry once again, as window | |
574 height now have changed. */ | |
575 if (! GTK_WIDGET_MAPPED (FRAME_GTK_OUTER_WIDGET (f))) | |
576 xg_set_geometry (f); | |
577 | |
578 xg_frame_set_char_size (f, columns, rows); | |
579 gdk_window_process_all_updates (); | |
580 } | |
581 | |
582 /* Function to handle resize of our widgets. Since Emacs has some layouts | |
583 that does not fit well with GTK standard containers, we do most layout | |
584 manually. | |
585 F is the frame to resize. | |
586 PIXELWIDTH, PIXELHEIGHT is the new size in pixels. */ | |
57715
cdc48cdd5b0e
* gtkutil.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57597
diff
changeset
|
587 |
49323 | 588 void |
589 xg_resize_widgets (f, pixelwidth, pixelheight) | |
590 FRAME_PTR f; | |
591 int pixelwidth, pixelheight; | |
592 { | |
593 int mbheight = FRAME_MENUBAR_HEIGHT (f); | |
594 int tbheight = FRAME_TOOLBAR_HEIGHT (f); | |
60185
391f44959566
(xg_create_frame_widgets): UNBLOCK_INPUT on error.
Kim F. Storm <storm@cua.dk>
parents:
59913
diff
changeset
|
595 int rows = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, (pixelheight |
51211
28ea05de2dc5
Make (many) trivial substitutions for renamed and
Kim F. Storm <storm@cua.dk>
parents:
50778
diff
changeset
|
596 - mbheight - tbheight)); |
28ea05de2dc5
Make (many) trivial substitutions for renamed and
Kim F. Storm <storm@cua.dk>
parents:
50778
diff
changeset
|
597 int columns = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, pixelwidth); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
598 |
49323 | 599 if (FRAME_GTK_WIDGET (f) |
60185
391f44959566
(xg_create_frame_widgets): UNBLOCK_INPUT on error.
Kim F. Storm <storm@cua.dk>
parents:
59913
diff
changeset
|
600 && (columns != FRAME_COLS (f) |
57597
754a6433f048
* gtkutil.c (xg_frame_cleared, xg_fixed_handle_expose,
Jan Djärv <jan.h.d@swipnet.se>
parents:
57575
diff
changeset
|
601 || rows != FRAME_LINES (f) |
60185
391f44959566
(xg_create_frame_widgets): UNBLOCK_INPUT on error.
Kim F. Storm <storm@cua.dk>
parents:
59913
diff
changeset
|
602 || pixelwidth != FRAME_PIXEL_WIDTH (f) |
57597
754a6433f048
* gtkutil.c (xg_frame_cleared, xg_fixed_handle_expose,
Jan Djärv <jan.h.d@swipnet.se>
parents:
57575
diff
changeset
|
603 || pixelheight != FRAME_PIXEL_HEIGHT (f))) |
49323 | 604 { |
605 struct x_output *x = f->output_data.x; | |
606 GtkAllocation all; | |
607 | |
608 all.y = mbheight + tbheight; | |
609 all.x = 0; | |
610 | |
611 all.width = pixelwidth; | |
612 all.height = pixelheight - mbheight - tbheight; | |
613 | |
614 gtk_widget_size_allocate (x->edit_widget, &all); | |
50129
d0142038feaa
Reduce flicker in GTK scrollbars.
Jan Djärv <jan.h.d@swipnet.se>
parents:
50112
diff
changeset
|
615 |
49323 | 616 change_frame_size (f, rows, columns, 0, 1, 0); |
617 SET_FRAME_GARBAGED (f); | |
618 cancel_mouse_face (f); | |
619 } | |
620 } | |
621 | |
622 | |
623 /* Update our widget size to be COLS/ROWS characters for frame F. */ | |
57715
cdc48cdd5b0e
* gtkutil.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57597
diff
changeset
|
624 |
49323 | 625 void |
626 xg_frame_set_char_size (f, cols, rows) | |
627 FRAME_PTR f; | |
628 int cols; | |
629 int rows; | |
630 { | |
51211
28ea05de2dc5
Make (many) trivial substitutions for renamed and
Kim F. Storm <storm@cua.dk>
parents:
50778
diff
changeset
|
631 int pixelheight = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, rows) |
49323 | 632 + FRAME_MENUBAR_HEIGHT (f) + FRAME_TOOLBAR_HEIGHT (f); |
50318
5b50d76d9211
* gtkutil.c (xg_resize_widgets): Don't call xg_frame_cleared.
Jan Djärv <jan.h.d@swipnet.se>
parents:
50272
diff
changeset
|
633 int pixelwidth; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
634 |
49323 | 635 /* Take into account the size of the scroll bar. Always use the |
636 number of columns occupied by the scroll bar here otherwise we | |
637 might end up with a frame width that is not a multiple of the | |
638 frame's character width which is bad for vertically split | |
639 windows. */ | |
51211
28ea05de2dc5
Make (many) trivial substitutions for renamed and
Kim F. Storm <storm@cua.dk>
parents:
50778
diff
changeset
|
640 f->scroll_bar_actual_width |
28ea05de2dc5
Make (many) trivial substitutions for renamed and
Kim F. Storm <storm@cua.dk>
parents:
50778
diff
changeset
|
641 = FRAME_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f); |
49323 | 642 |
50099
a62497b91c74
Use generic compute_fringe_widths.
Kim F. Storm <storm@cua.dk>
parents:
50063
diff
changeset
|
643 compute_fringe_widths (f, 0); |
49323 | 644 |
51211
28ea05de2dc5
Make (many) trivial substitutions for renamed and
Kim F. Storm <storm@cua.dk>
parents:
50778
diff
changeset
|
645 /* FRAME_TEXT_COLS_TO_PIXEL_WIDTH uses scroll_bar_actual_width, so call it |
50318
5b50d76d9211
* gtkutil.c (xg_resize_widgets): Don't call xg_frame_cleared.
Jan Djärv <jan.h.d@swipnet.se>
parents:
50272
diff
changeset
|
646 after calculating that value. */ |
51211
28ea05de2dc5
Make (many) trivial substitutions for renamed and
Kim F. Storm <storm@cua.dk>
parents:
50778
diff
changeset
|
647 pixelwidth = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, cols); |
50318
5b50d76d9211
* gtkutil.c (xg_resize_widgets): Don't call xg_frame_cleared.
Jan Djärv <jan.h.d@swipnet.se>
parents:
50272
diff
changeset
|
648 |
49323 | 649 /* Must resize our top level widget. Font size may have changed, |
650 but not rows/cols. */ | |
651 gtk_window_resize (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)), | |
652 pixelwidth, pixelheight); | |
653 xg_resize_widgets (f, pixelwidth, pixelheight); | |
53275
a07a0bae1990
* gtkutil.c (xg_frame_set_char_size): Call x_wm_set_size_hint.
Jan Djärv <jan.h.d@swipnet.se>
parents:
53069
diff
changeset
|
654 x_wm_set_size_hint (f, 0, 0); |
50318
5b50d76d9211
* gtkutil.c (xg_resize_widgets): Don't call xg_frame_cleared.
Jan Djärv <jan.h.d@swipnet.se>
parents:
50272
diff
changeset
|
655 SET_FRAME_GARBAGED (f); |
5b50d76d9211
* gtkutil.c (xg_resize_widgets): Don't call xg_frame_cleared.
Jan Djärv <jan.h.d@swipnet.se>
parents:
50272
diff
changeset
|
656 cancel_mouse_face (f); |
49323 | 657 } |
658 | |
53069
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
659 /* Convert an X Window WSESC on display DPY to its corresponding GtkWidget. |
49323 | 660 Must be done like this, because GtkWidget:s can have "hidden" |
661 X Window that aren't accessible. | |
662 | |
663 Return 0 if no widget match WDESC. */ | |
57715
cdc48cdd5b0e
* gtkutil.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57597
diff
changeset
|
664 |
49323 | 665 GtkWidget * |
53069
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
666 xg_win_to_widget (dpy, wdesc) |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
667 Display *dpy; |
49323 | 668 Window wdesc; |
669 { | |
670 gpointer gdkwin; | |
671 GtkWidget *gwdesc = 0; | |
672 | |
673 BLOCK_INPUT; | |
53069
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
674 |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
675 gdkwin = gdk_xid_table_lookup_for_display (gdk_x11_lookup_xdisplay (dpy), |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
676 wdesc); |
49323 | 677 if (gdkwin) |
678 { | |
679 GdkEvent event; | |
680 event.any.window = gdkwin; | |
681 gwdesc = gtk_get_event_widget (&event); | |
682 } | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
683 |
49323 | 684 UNBLOCK_INPUT; |
685 return gwdesc; | |
686 } | |
687 | |
688 /* Fill in the GdkColor C so that it represents PIXEL. | |
689 W is the widget that color will be used for. Used to find colormap. */ | |
57715
cdc48cdd5b0e
* gtkutil.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57597
diff
changeset
|
690 |
49323 | 691 static void |
692 xg_pix_to_gcolor (w, pixel, c) | |
693 GtkWidget *w; | |
694 unsigned long pixel; | |
695 GdkColor *c; | |
696 { | |
697 GdkColormap *map = gtk_widget_get_colormap (w); | |
698 gdk_colormap_query_color (map, pixel, c); | |
699 } | |
700 | |
701 /* Create and set up the GTK widgets for frame F. | |
702 Return 0 if creation failed, non-zero otherwise. */ | |
57715
cdc48cdd5b0e
* gtkutil.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57597
diff
changeset
|
703 |
49323 | 704 int |
705 xg_create_frame_widgets (f) | |
706 FRAME_PTR f; | |
707 { | |
708 GtkWidget *wtop; | |
709 GtkWidget *wvbox; | |
710 GtkWidget *wfixed; | |
711 GdkColor bg; | |
712 GtkRcStyle *style; | |
713 int i; | |
714 char *title = 0; | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
715 |
49323 | 716 BLOCK_INPUT; |
717 | |
718 wtop = gtk_window_new (GTK_WINDOW_TOPLEVEL); | |
53069
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
719 xg_set_screen (wtop, f); |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
720 |
49323 | 721 wvbox = gtk_vbox_new (FALSE, 0); |
722 wfixed = gtk_fixed_new (); /* Must have this to place scroll bars */ | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
723 |
49323 | 724 if (! wtop || ! wvbox || ! wfixed) |
725 { | |
726 if (wtop) gtk_widget_destroy (wtop); | |
727 if (wvbox) gtk_widget_destroy (wvbox); | |
728 if (wfixed) gtk_widget_destroy (wfixed); | |
729 | |
60185
391f44959566
(xg_create_frame_widgets): UNBLOCK_INPUT on error.
Kim F. Storm <storm@cua.dk>
parents:
59913
diff
changeset
|
730 UNBLOCK_INPUT; |
49323 | 731 return 0; |
732 } | |
733 | |
734 /* Use same names as the Xt port does. I.e. Emacs.pane.emacs by default */ | |
735 gtk_widget_set_name (wtop, EMACS_CLASS); | |
736 gtk_widget_set_name (wvbox, "pane"); | |
67528
c5c00342184b
* gtkutil.c (SSDATA): New macro to remove compiler warnings.
Jan Djärv <jan.h.d@swipnet.se>
parents:
65628
diff
changeset
|
737 gtk_widget_set_name (wfixed, SSDATA (Vx_resource_name)); |
49323 | 738 |
739 /* If this frame has a title or name, set it in the title bar. */ | |
67528
c5c00342184b
* gtkutil.c (SSDATA): New macro to remove compiler warnings.
Jan Djärv <jan.h.d@swipnet.se>
parents:
65628
diff
changeset
|
740 if (! NILP (f->title)) title = SSDATA (ENCODE_UTF_8 (f->title)); |
c5c00342184b
* gtkutil.c (SSDATA): New macro to remove compiler warnings.
Jan Djärv <jan.h.d@swipnet.se>
parents:
65628
diff
changeset
|
741 else if (! NILP (f->name)) title = SSDATA (ENCODE_UTF_8 (f->name)); |
49323 | 742 |
743 if (title) gtk_window_set_title (GTK_WINDOW (wtop), title); | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
744 |
49323 | 745 FRAME_GTK_OUTER_WIDGET (f) = wtop; |
746 FRAME_GTK_WIDGET (f) = wfixed; | |
747 f->output_data.x->vbox_widget = wvbox; | |
748 | |
749 gtk_fixed_set_has_window (GTK_FIXED (wfixed), TRUE); | |
750 | |
53069
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
751 gtk_widget_set_size_request (wfixed, FRAME_PIXEL_WIDTH (f), |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
752 FRAME_PIXEL_HEIGHT (f)); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
753 |
49323 | 754 gtk_container_add (GTK_CONTAINER (wtop), wvbox); |
755 gtk_box_pack_end (GTK_BOX (wvbox), wfixed, TRUE, TRUE, 0); | |
756 | |
757 if (FRAME_EXTERNAL_TOOL_BAR (f)) | |
758 update_frame_tool_bar (f); | |
759 | |
760 /* The tool bar is created but first there are no items in it. | |
761 This causes it to be zero height. Later items are added, but then | |
762 the frame is already mapped, so there is a "jumping" resize. | |
763 This makes geometry handling difficult, for example -0-0 will end | |
764 up in the wrong place as tool bar height has not been taken into account. | |
765 So we cheat a bit by setting a height that is what it will have | |
766 later on when tool bar items are added. */ | |
56804
3f2598db97ac
* gtkutil.c (xg_create_frame_widgets): Compensate for tool bar when
Jan Djärv <jan.h.d@swipnet.se>
parents:
56269
diff
changeset
|
767 if (FRAME_EXTERNAL_TOOL_BAR (f) && f->n_tool_bar_items == 0) |
59420
eb72706060ad
* xterm.h (struct x_output): New member, toolbar_detached.
Jan Djärv <jan.h.d@swipnet.se>
parents:
59411
diff
changeset
|
768 FRAME_TOOLBAR_HEIGHT (f) = 38; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
769 |
50270
fa50953c02dc
Finally (?) fix flicker in scroll bar.
Jan Djärv <jan.h.d@swipnet.se>
parents:
50192
diff
changeset
|
770 |
fa50953c02dc
Finally (?) fix flicker in scroll bar.
Jan Djärv <jan.h.d@swipnet.se>
parents:
50192
diff
changeset
|
771 /* We don't want this widget double buffered, because we draw on it |
fa50953c02dc
Finally (?) fix flicker in scroll bar.
Jan Djärv <jan.h.d@swipnet.se>
parents:
50192
diff
changeset
|
772 with regular X drawing primitives, so from a GTK/GDK point of |
fa50953c02dc
Finally (?) fix flicker in scroll bar.
Jan Djärv <jan.h.d@swipnet.se>
parents:
50192
diff
changeset
|
773 view, the widget is totally blank. When an expose comes, this |
fa50953c02dc
Finally (?) fix flicker in scroll bar.
Jan Djärv <jan.h.d@swipnet.se>
parents:
50192
diff
changeset
|
774 will make the widget blank, and then Emacs redraws it. This flickers |
fa50953c02dc
Finally (?) fix flicker in scroll bar.
Jan Djärv <jan.h.d@swipnet.se>
parents:
50192
diff
changeset
|
775 a lot, so we turn off double buffering. */ |
49323 | 776 gtk_widget_set_double_buffered (wfixed, FALSE); |
50270
fa50953c02dc
Finally (?) fix flicker in scroll bar.
Jan Djärv <jan.h.d@swipnet.se>
parents:
50192
diff
changeset
|
777 |
49323 | 778 /* GTK documents says use gtk_window_set_resizable. But then a user |
779 can't shrink the window from its starting size. */ | |
780 gtk_window_set_policy (GTK_WINDOW (wtop), TRUE, TRUE, TRUE); | |
781 gtk_window_set_wmclass (GTK_WINDOW (wtop), | |
67528
c5c00342184b
* gtkutil.c (SSDATA): New macro to remove compiler warnings.
Jan Djärv <jan.h.d@swipnet.se>
parents:
65628
diff
changeset
|
782 SSDATA (Vx_resource_name), |
c5c00342184b
* gtkutil.c (SSDATA): New macro to remove compiler warnings.
Jan Djärv <jan.h.d@swipnet.se>
parents:
65628
diff
changeset
|
783 SSDATA (Vx_resource_class)); |
49323 | 784 |
785 /* Add callback to do nothing on WM_DELETE_WINDOW. The default in | |
786 GTK is to destroy the widget. We want Emacs to do that instead. */ | |
787 g_signal_connect (G_OBJECT (wtop), "delete-event", | |
788 G_CALLBACK (gtk_true), 0); | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
789 |
49323 | 790 /* Convert our geometry parameters into a geometry string |
791 and specify it. | |
792 GTK will itself handle calculating the real position this way. */ | |
793 xg_set_geometry (f); | |
794 | |
795 gtk_widget_add_events (wfixed, | |
796 GDK_POINTER_MOTION_MASK | |
797 | GDK_EXPOSURE_MASK | |
798 | GDK_BUTTON_PRESS_MASK | |
799 | GDK_BUTTON_RELEASE_MASK | |
800 | GDK_KEY_PRESS_MASK | |
801 | GDK_ENTER_NOTIFY_MASK | |
802 | GDK_LEAVE_NOTIFY_MASK | |
803 | GDK_FOCUS_CHANGE_MASK | |
804 | GDK_STRUCTURE_MASK | |
805 | GDK_VISIBILITY_NOTIFY_MASK); | |
806 | |
807 /* Must realize the windows so the X window gets created. It is used | |
808 by callers of this function. */ | |
809 gtk_widget_realize (wfixed); | |
810 FRAME_X_WINDOW (f) = GTK_WIDGET_TO_X_WIN (wfixed); | |
811 | |
812 /* Since GTK clears its window by filling with the background color, | |
813 we must keep X and GTK background in sync. */ | |
814 xg_pix_to_gcolor (wfixed, f->output_data.x->background_pixel, &bg); | |
815 gtk_widget_modify_bg (wfixed, GTK_STATE_NORMAL, &bg); | |
816 | |
817 /* Also, do not let any background pixmap to be set, this looks very | |
818 bad as Emacs overwrites the background pixmap with its own idea | |
819 of background color. */ | |
820 style = gtk_widget_get_modifier_style (wfixed); | |
821 | |
822 /* Must use g_strdup because gtk_widget_modify_style does g_free. */ | |
823 style->bg_pixmap_name[GTK_STATE_NORMAL] = g_strdup ("<none>"); | |
824 gtk_widget_modify_style (wfixed, style); | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
825 |
49323 | 826 /* GTK does not set any border, and they look bad with GTK. */ |
51211
28ea05de2dc5
Make (many) trivial substitutions for renamed and
Kim F. Storm <storm@cua.dk>
parents:
50778
diff
changeset
|
827 f->border_width = 0; |
28ea05de2dc5
Make (many) trivial substitutions for renamed and
Kim F. Storm <storm@cua.dk>
parents:
50778
diff
changeset
|
828 f->internal_border_width = 0; |
49323 | 829 |
830 UNBLOCK_INPUT; | |
831 | |
832 return 1; | |
833 } | |
834 | |
835 /* Set the normal size hints for the window manager, for frame F. | |
836 FLAGS is the flags word to use--or 0 meaning preserve the flags | |
837 that the window now has. | |
838 If USER_POSITION is nonzero, we set the User Position | |
839 flag (this is useful when FLAGS is 0). */ | |
57715
cdc48cdd5b0e
* gtkutil.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57597
diff
changeset
|
840 |
49323 | 841 void |
842 x_wm_set_size_hint (f, flags, user_position) | |
843 FRAME_PTR f; | |
844 long flags; | |
845 int user_position; | |
846 { | |
847 if (FRAME_GTK_OUTER_WIDGET (f)) | |
848 { | |
849 /* Must use GTK routines here, otherwise GTK resets the size hints | |
850 to its own defaults. */ | |
851 GdkGeometry size_hints; | |
852 gint hint_flags = 0; | |
853 int base_width, base_height; | |
854 int min_rows = 0, min_cols = 0; | |
51211
28ea05de2dc5
Make (many) trivial substitutions for renamed and
Kim F. Storm <storm@cua.dk>
parents:
50778
diff
changeset
|
855 int win_gravity = f->win_gravity; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
856 |
49323 | 857 if (flags) |
858 { | |
859 memset (&size_hints, 0, sizeof (size_hints)); | |
860 f->output_data.x->size_hints = size_hints; | |
861 f->output_data.x->hint_flags = hint_flags; | |
862 } | |
863 else | |
51211
28ea05de2dc5
Make (many) trivial substitutions for renamed and
Kim F. Storm <storm@cua.dk>
parents:
50778
diff
changeset
|
864 flags = f->size_hint_flags; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
865 |
49323 | 866 size_hints = f->output_data.x->size_hints; |
867 hint_flags = f->output_data.x->hint_flags; | |
868 | |
869 hint_flags |= GDK_HINT_RESIZE_INC | GDK_HINT_MIN_SIZE; | |
51211
28ea05de2dc5
Make (many) trivial substitutions for renamed and
Kim F. Storm <storm@cua.dk>
parents:
50778
diff
changeset
|
870 size_hints.width_inc = FRAME_COLUMN_WIDTH (f); |
28ea05de2dc5
Make (many) trivial substitutions for renamed and
Kim F. Storm <storm@cua.dk>
parents:
50778
diff
changeset
|
871 size_hints.height_inc = FRAME_LINE_HEIGHT (f); |
49323 | 872 |
873 hint_flags |= GDK_HINT_BASE_SIZE; | |
51211
28ea05de2dc5
Make (many) trivial substitutions for renamed and
Kim F. Storm <storm@cua.dk>
parents:
50778
diff
changeset
|
874 base_width = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, 0); |
28ea05de2dc5
Make (many) trivial substitutions for renamed and
Kim F. Storm <storm@cua.dk>
parents:
50778
diff
changeset
|
875 base_height = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, 0) |
49323 | 876 + FRAME_MENUBAR_HEIGHT (f) + FRAME_TOOLBAR_HEIGHT (f); |
877 | |
878 check_frame_size (f, &min_rows, &min_cols); | |
879 | |
880 size_hints.base_width = base_width; | |
881 size_hints.base_height = base_height; | |
882 size_hints.min_width = base_width + min_cols * size_hints.width_inc; | |
883 size_hints.min_height = base_height + min_rows * size_hints.height_inc; | |
884 | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
885 |
49323 | 886 /* These currently have a one to one mapping with the X values, but I |
887 don't think we should rely on that. */ | |
888 hint_flags |= GDK_HINT_WIN_GRAVITY; | |
889 size_hints.win_gravity = 0; | |
890 if (win_gravity == NorthWestGravity) | |
891 size_hints.win_gravity = GDK_GRAVITY_NORTH_WEST; | |
892 else if (win_gravity == NorthGravity) | |
893 size_hints.win_gravity = GDK_GRAVITY_NORTH; | |
894 else if (win_gravity == NorthEastGravity) | |
895 size_hints.win_gravity = GDK_GRAVITY_NORTH_EAST; | |
896 else if (win_gravity == WestGravity) | |
897 size_hints.win_gravity = GDK_GRAVITY_WEST; | |
898 else if (win_gravity == CenterGravity) | |
899 size_hints.win_gravity = GDK_GRAVITY_CENTER; | |
900 else if (win_gravity == EastGravity) | |
901 size_hints.win_gravity = GDK_GRAVITY_EAST; | |
902 else if (win_gravity == SouthWestGravity) | |
903 size_hints.win_gravity = GDK_GRAVITY_SOUTH_WEST; | |
904 else if (win_gravity == SouthGravity) | |
905 size_hints.win_gravity = GDK_GRAVITY_SOUTH; | |
906 else if (win_gravity == SouthEastGravity) | |
907 size_hints.win_gravity = GDK_GRAVITY_SOUTH_EAST; | |
908 else if (win_gravity == StaticGravity) | |
909 size_hints.win_gravity = GDK_GRAVITY_STATIC; | |
910 | |
911 if (flags & PPosition) hint_flags |= GDK_HINT_POS; | |
912 if (flags & USPosition) hint_flags |= GDK_HINT_USER_POS; | |
913 if (flags & USSize) hint_flags |= GDK_HINT_USER_SIZE; | |
914 | |
915 if (user_position) | |
916 { | |
917 hint_flags &= ~GDK_HINT_POS; | |
918 hint_flags |= GDK_HINT_USER_POS; | |
919 } | |
920 | |
921 BLOCK_INPUT; | |
922 | |
923 gtk_window_set_geometry_hints (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)), | |
924 FRAME_GTK_OUTER_WIDGET (f), | |
925 &size_hints, | |
926 hint_flags); | |
927 | |
928 f->output_data.x->size_hints = size_hints; | |
929 f->output_data.x->hint_flags = hint_flags; | |
930 UNBLOCK_INPUT; | |
931 } | |
932 } | |
933 | |
934 /* Change background color of a frame. | |
935 Since GTK uses the background colour to clear the window, we must | |
936 keep the GTK and X colors in sync. | |
937 F is the frame to change, | |
938 BG is the pixel value to change to. */ | |
57715
cdc48cdd5b0e
* gtkutil.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57597
diff
changeset
|
939 |
49323 | 940 void |
941 xg_set_background_color (f, bg) | |
942 FRAME_PTR f; | |
943 unsigned long bg; | |
944 { | |
945 if (FRAME_GTK_WIDGET (f)) | |
946 { | |
947 GdkColor gdk_bg; | |
948 | |
949 BLOCK_INPUT; | |
950 xg_pix_to_gcolor (FRAME_GTK_WIDGET (f), bg, &gdk_bg); | |
951 gtk_widget_modify_bg (FRAME_GTK_WIDGET (f), GTK_STATE_NORMAL, &gdk_bg); | |
952 UNBLOCK_INPUT; | |
953 } | |
954 } | |
955 | |
956 | |
65006
ec2fa2e1d4ea
* gtkutil.c (xg_set_frame_icon): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
64936
diff
changeset
|
957 /* Set the frame icon to ICON_PIXMAP/MASK. This must be done with GTK |
ec2fa2e1d4ea
* gtkutil.c (xg_set_frame_icon): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
64936
diff
changeset
|
958 functions so GTK does not overwrite the icon. */ |
ec2fa2e1d4ea
* gtkutil.c (xg_set_frame_icon): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
64936
diff
changeset
|
959 |
ec2fa2e1d4ea
* gtkutil.c (xg_set_frame_icon): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
64936
diff
changeset
|
960 void |
ec2fa2e1d4ea
* gtkutil.c (xg_set_frame_icon): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
64936
diff
changeset
|
961 xg_set_frame_icon (f, icon_pixmap, icon_mask) |
ec2fa2e1d4ea
* gtkutil.c (xg_set_frame_icon): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
64936
diff
changeset
|
962 FRAME_PTR f; |
ec2fa2e1d4ea
* gtkutil.c (xg_set_frame_icon): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
64936
diff
changeset
|
963 Pixmap icon_pixmap; |
ec2fa2e1d4ea
* gtkutil.c (xg_set_frame_icon): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
64936
diff
changeset
|
964 Pixmap icon_mask; |
ec2fa2e1d4ea
* gtkutil.c (xg_set_frame_icon): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
64936
diff
changeset
|
965 { |
ec2fa2e1d4ea
* gtkutil.c (xg_set_frame_icon): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
64936
diff
changeset
|
966 GdkDisplay *gdpy = gdk_x11_lookup_xdisplay (FRAME_X_DISPLAY (f)); |
ec2fa2e1d4ea
* gtkutil.c (xg_set_frame_icon): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
64936
diff
changeset
|
967 GdkPixmap *gpix = gdk_pixmap_foreign_new_for_display (gdpy, icon_pixmap); |
ec2fa2e1d4ea
* gtkutil.c (xg_set_frame_icon): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
64936
diff
changeset
|
968 GdkPixmap *gmask = gdk_pixmap_foreign_new_for_display (gdpy, icon_mask); |
ec2fa2e1d4ea
* gtkutil.c (xg_set_frame_icon): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
64936
diff
changeset
|
969 GdkPixbuf *gp = xg_get_pixbuf_from_pix_and_mask (gpix, gmask, NULL); |
ec2fa2e1d4ea
* gtkutil.c (xg_set_frame_icon): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
64936
diff
changeset
|
970 |
ec2fa2e1d4ea
* gtkutil.c (xg_set_frame_icon): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
64936
diff
changeset
|
971 gtk_window_set_icon (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)), gp); |
ec2fa2e1d4ea
* gtkutil.c (xg_set_frame_icon): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
64936
diff
changeset
|
972 } |
ec2fa2e1d4ea
* gtkutil.c (xg_set_frame_icon): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
64936
diff
changeset
|
973 |
ec2fa2e1d4ea
* gtkutil.c (xg_set_frame_icon): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
64936
diff
changeset
|
974 |
49323 | 975 |
976 /*********************************************************************** | |
977 Dialog functions | |
978 ***********************************************************************/ | |
979 /* Return the dialog title to use for a dialog of type KEY. | |
980 This is the encoding used by lwlib. We use the same for GTK. */ | |
57715
cdc48cdd5b0e
* gtkutil.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57597
diff
changeset
|
981 |
49323 | 982 static char * |
983 get_dialog_title (char key) | |
984 { | |
985 char *title = ""; | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
986 |
49323 | 987 switch (key) { |
988 case 'E': case 'e': | |
989 title = "Error"; | |
990 break; | |
991 | |
992 case 'I': case 'i': | |
993 title = "Information"; | |
994 break; | |
995 | |
996 case 'L': case 'l': | |
997 title = "Prompt"; | |
998 break; | |
999 | |
1000 case 'P': case 'p': | |
1001 title = "Prompt"; | |
1002 break; | |
1003 | |
1004 case 'Q': case 'q': | |
1005 title = "Question"; | |
1006 break; | |
1007 } | |
1008 | |
1009 return title; | |
1010 } | |
1011 | |
1012 /* Callback for dialogs that get WM_DELETE_WINDOW. We pop down | |
1013 the dialog, but return TRUE so the event does not propagate further | |
1014 in GTK. This prevents GTK from destroying the dialog widget automatically | |
1015 and we can always destrou the widget manually, regardles of how | |
1016 it was popped down (button press or WM_DELETE_WINDOW). | |
1017 W is the dialog widget. | |
1018 EVENT is the GdkEvent that represents WM_DELETE_WINDOW (not used). | |
1019 user_data is NULL (not used). | |
1020 | |
1021 Returns TRUE to end propagation of event. */ | |
57715
cdc48cdd5b0e
* gtkutil.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57597
diff
changeset
|
1022 |
49323 | 1023 static gboolean |
1024 dialog_delete_callback (w, event, user_data) | |
1025 GtkWidget *w; | |
1026 GdkEvent *event; | |
1027 gpointer user_data; | |
1028 { | |
1029 gtk_widget_unmap (w); | |
1030 return TRUE; | |
1031 } | |
1032 | |
1033 /* Create a popup dialog window. See also xg_create_widget below. | |
1034 WV is a widget_value describing the dialog. | |
1035 SELECT_CB is the callback to use when a button has been pressed. | |
1036 DEACTIVATE_CB is the callback to use when the dialog pops down. | |
1037 | |
1038 Returns the GTK dialog widget. */ | |
57715
cdc48cdd5b0e
* gtkutil.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57597
diff
changeset
|
1039 |
49323 | 1040 static GtkWidget * |
1041 create_dialog (wv, select_cb, deactivate_cb) | |
1042 widget_value *wv; | |
1043 GCallback select_cb; | |
1044 GCallback deactivate_cb; | |
1045 { | |
1046 char *title = get_dialog_title (wv->name[0]); | |
1047 int total_buttons = wv->name[1] - '0'; | |
1048 int right_buttons = wv->name[4] - '0'; | |
1049 int left_buttons; | |
1050 int button_nr = 0; | |
1051 int button_spacing = 10; | |
1052 GtkWidget *wdialog = gtk_dialog_new (); | |
1053 widget_value *item; | |
1054 GtkBox *cur_box; | |
1055 GtkWidget *wvbox; | |
1056 GtkWidget *whbox_up; | |
1057 GtkWidget *whbox_down; | |
1058 | |
1059 /* If the number of buttons is greater than 4, make two rows of buttons | |
1060 instead. This looks better. */ | |
1061 int make_two_rows = total_buttons > 4; | |
1062 | |
1063 if (right_buttons == 0) right_buttons = total_buttons/2; | |
1064 left_buttons = total_buttons - right_buttons; | |
1065 | |
1066 gtk_window_set_title (GTK_WINDOW (wdialog), title); | |
1067 gtk_widget_set_name (wdialog, "emacs-dialog"); | |
1068 | |
1069 cur_box = GTK_BOX (GTK_DIALOG (wdialog)->action_area); | |
1070 | |
1071 if (make_two_rows) | |
1072 { | |
1073 wvbox = gtk_vbox_new (TRUE, button_spacing); | |
1074 whbox_up = gtk_hbox_new (FALSE, 0); | |
1075 whbox_down = gtk_hbox_new (FALSE, 0); | |
1076 | |
1077 gtk_box_pack_start (cur_box, wvbox, FALSE, FALSE, 0); | |
1078 gtk_box_pack_start (GTK_BOX (wvbox), whbox_up, FALSE, FALSE, 0); | |
1079 gtk_box_pack_start (GTK_BOX (wvbox), whbox_down, FALSE, FALSE, 0); | |
1080 | |
1081 cur_box = GTK_BOX (whbox_up); | |
1082 } | |
1083 | |
1084 g_signal_connect (G_OBJECT (wdialog), "delete-event", | |
1085 G_CALLBACK (dialog_delete_callback), 0); | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
1086 |
49323 | 1087 if (deactivate_cb) |
1088 { | |
1089 g_signal_connect (G_OBJECT (wdialog), "close", deactivate_cb, 0); | |
1090 g_signal_connect (G_OBJECT (wdialog), "response", deactivate_cb, 0); | |
1091 } | |
1092 | |
1093 for (item = wv->contents; item; item = item->next) | |
1094 { | |
1095 char *utf8_label = get_utf8_string (item->value); | |
1096 GtkWidget *w; | |
1097 GtkRequisition req; | |
1098 | |
49488
da6abcaef15c
gtkutil.c: Check for NULL string before calling strcmp or strlen.
Jan Djärv <jan.h.d@swipnet.se>
parents:
49468
diff
changeset
|
1099 if (item->name && strcmp (item->name, "message") == 0) |
49323 | 1100 { |
1101 /* This is the text part of the dialog. */ | |
1102 w = gtk_label_new (utf8_label); | |
1103 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (wdialog)->vbox), | |
1104 gtk_label_new (""), | |
1105 FALSE, FALSE, 0); | |
1106 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (wdialog)->vbox), w, | |
1107 TRUE, TRUE, 0); | |
1108 gtk_misc_set_alignment (GTK_MISC (w), 0.1, 0.5); | |
1109 | |
1110 /* Try to make dialog look better. Must realize first so | |
1111 the widget can calculate the size it needs. */ | |
1112 gtk_widget_realize (w); | |
1113 gtk_widget_size_request (w, &req); | |
1114 gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (wdialog)->vbox), | |
1115 req.height); | |
49488
da6abcaef15c
gtkutil.c: Check for NULL string before calling strcmp or strlen.
Jan Djärv <jan.h.d@swipnet.se>
parents:
49468
diff
changeset
|
1116 if (item->value && strlen (item->value) > 0) |
49323 | 1117 button_spacing = 2*req.width/strlen (item->value); |
1118 } | |
1119 else | |
1120 { | |
1121 /* This is one button to add to the dialog. */ | |
50778
f30e6f029d65
* gtkutil.c (create_dialog, make_widget_for_menu_item)
Jan Djärv <jan.h.d@swipnet.se>
parents:
50521
diff
changeset
|
1122 w = gtk_button_new_with_label (utf8_label); |
49323 | 1123 if (! item->enabled) |
1124 gtk_widget_set_sensitive (w, FALSE); | |
1125 if (select_cb) | |
1126 g_signal_connect (G_OBJECT (w), "clicked", | |
1127 select_cb, item->call_data); | |
1128 | |
1129 gtk_box_pack_start (cur_box, w, TRUE, TRUE, button_spacing); | |
1130 if (++button_nr == left_buttons) | |
1131 { | |
1132 if (make_two_rows) | |
1133 cur_box = GTK_BOX (whbox_down); | |
1134 else | |
1135 gtk_box_pack_start (cur_box, | |
1136 gtk_label_new (""), | |
1137 TRUE, TRUE, | |
1138 button_spacing); | |
1139 } | |
1140 } | |
1141 | |
1142 if (utf8_label && utf8_label != item->value) | |
1143 g_free (utf8_label); | |
1144 } | |
1145 | |
1146 return wdialog; | |
1147 } | |
1148 | |
1149 | |
57868
c955f6add62a
* fileio.c (Fread_file_name): Pass Qt as fifth parameter to
Jan Djärv <jan.h.d@swipnet.se>
parents:
57715
diff
changeset
|
1150 |
c955f6add62a
* fileio.c (Fread_file_name): Pass Qt as fifth parameter to
Jan Djärv <jan.h.d@swipnet.se>
parents:
57715
diff
changeset
|
1151 /*********************************************************************** |
c955f6add62a
* fileio.c (Fread_file_name): Pass Qt as fifth parameter to
Jan Djärv <jan.h.d@swipnet.se>
parents:
57715
diff
changeset
|
1152 File dialog functions |
c955f6add62a
* fileio.c (Fread_file_name): Pass Qt as fifth parameter to
Jan Djärv <jan.h.d@swipnet.se>
parents:
57715
diff
changeset
|
1153 ***********************************************************************/ |
67761
5b8799d65159
* xfns.c (Fx_uses_old_gtk_dialog): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
67528
diff
changeset
|
1154 /* Return non-zero if the old file selection dialog is being used. |
5b8799d65159
* xfns.c (Fx_uses_old_gtk_dialog): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
67528
diff
changeset
|
1155 Return zero if not. */ |
5b8799d65159
* xfns.c (Fx_uses_old_gtk_dialog): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
67528
diff
changeset
|
1156 |
5b8799d65159
* xfns.c (Fx_uses_old_gtk_dialog): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
67528
diff
changeset
|
1157 int |
5b8799d65159
* xfns.c (Fx_uses_old_gtk_dialog): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
67528
diff
changeset
|
1158 xg_uses_old_file_dialog () |
5b8799d65159
* xfns.c (Fx_uses_old_gtk_dialog): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
67528
diff
changeset
|
1159 { |
5b8799d65159
* xfns.c (Fx_uses_old_gtk_dialog): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
67528
diff
changeset
|
1160 #ifdef HAVE_GTK_FILE_BOTH |
5b8799d65159
* xfns.c (Fx_uses_old_gtk_dialog): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
67528
diff
changeset
|
1161 extern int x_use_old_gtk_file_dialog; |
5b8799d65159
* xfns.c (Fx_uses_old_gtk_dialog): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
67528
diff
changeset
|
1162 return x_use_old_gtk_file_dialog; |
5b8799d65159
* xfns.c (Fx_uses_old_gtk_dialog): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
67528
diff
changeset
|
1163 #else /* ! HAVE_GTK_FILE_BOTH */ |
5b8799d65159
* xfns.c (Fx_uses_old_gtk_dialog): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
67528
diff
changeset
|
1164 |
5b8799d65159
* xfns.c (Fx_uses_old_gtk_dialog): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
67528
diff
changeset
|
1165 #ifdef HAVE_GTK_FILE_SELECTION_NEW |
5b8799d65159
* xfns.c (Fx_uses_old_gtk_dialog): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
67528
diff
changeset
|
1166 return 1; |
5b8799d65159
* xfns.c (Fx_uses_old_gtk_dialog): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
67528
diff
changeset
|
1167 #else |
5b8799d65159
* xfns.c (Fx_uses_old_gtk_dialog): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
67528
diff
changeset
|
1168 return 0; |
5b8799d65159
* xfns.c (Fx_uses_old_gtk_dialog): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
67528
diff
changeset
|
1169 #endif |
5b8799d65159
* xfns.c (Fx_uses_old_gtk_dialog): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
67528
diff
changeset
|
1170 |
5b8799d65159
* xfns.c (Fx_uses_old_gtk_dialog): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
67528
diff
changeset
|
1171 #endif /* ! HAVE_GTK_FILE_BOTH */ |
5b8799d65159
* xfns.c (Fx_uses_old_gtk_dialog): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
67528
diff
changeset
|
1172 } |
5b8799d65159
* xfns.c (Fx_uses_old_gtk_dialog): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
67528
diff
changeset
|
1173 |
5b8799d65159
* xfns.c (Fx_uses_old_gtk_dialog): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
67528
diff
changeset
|
1174 |
58200
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1175 /* Function that is called when the file dialog pops down. |
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1176 W is the dialog widget, RESPONSE is the response code. |
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1177 USER_DATA is what we passed in to g_signal_connect (pointer to int). */ |
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1178 |
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1179 static void |
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1180 xg_file_response_cb (w, |
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1181 response, |
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1182 user_data) |
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1183 GtkDialog *w; |
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1184 gint response; |
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1185 gpointer user_data; |
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1186 { |
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1187 int *ptr = (int *) user_data; |
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1188 *ptr = response; |
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1189 } |
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1190 |
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1191 |
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1192 /* Destroy the dialog. This makes it pop down. */ |
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1193 |
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1194 static Lisp_Object |
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1195 pop_down_file_dialog (arg) |
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1196 Lisp_Object arg; |
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1197 { |
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1198 struct Lisp_Save_Value *p = XSAVE_VALUE (arg); |
58201
d433adb0e42c
Add BLOCK_INPUT in pop_down_file_dialog.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58200
diff
changeset
|
1199 BLOCK_INPUT; |
58200
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1200 gtk_widget_destroy (GTK_WIDGET (p->pointer)); |
58201
d433adb0e42c
Add BLOCK_INPUT in pop_down_file_dialog.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58200
diff
changeset
|
1201 UNBLOCK_INPUT; |
58200
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1202 return Qnil; |
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1203 } |
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1204 |
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1205 typedef char * (*xg_get_file_func) P_ ((GtkWidget *)); |
57868
c955f6add62a
* fileio.c (Fread_file_name): Pass Qt as fifth parameter to
Jan Djärv <jan.h.d@swipnet.se>
parents:
57715
diff
changeset
|
1206 |
c955f6add62a
* fileio.c (Fread_file_name): Pass Qt as fifth parameter to
Jan Djärv <jan.h.d@swipnet.se>
parents:
57715
diff
changeset
|
1207 #ifdef HAVE_GTK_FILE_CHOOSER_DIALOG_NEW |
58200
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1208 |
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1209 /* Return the selected file for file chooser dialog W. |
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1210 The returned string must be free:d. */ |
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1211 |
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1212 static char * |
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1213 xg_get_file_name_from_chooser (w) |
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1214 GtkWidget *w; |
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1215 { |
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1216 return gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (w)); |
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1217 } |
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1218 |
68100
e5611feba7f7
* gtkutil.c (xg_toggle_notify_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
68027
diff
changeset
|
1219 /* Callback called when the "Show hidden files" toggle is pressed. |
e5611feba7f7
* gtkutil.c (xg_toggle_notify_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
68027
diff
changeset
|
1220 WIDGET is the toggle widget, DATA is the file chooser dialog. */ |
e5611feba7f7
* gtkutil.c (xg_toggle_notify_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
68027
diff
changeset
|
1221 |
67843
6cf5dc28bd1e
* gtkutil.c (xg_toggle_visibility_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
67761
diff
changeset
|
1222 static void |
67849 | 1223 xg_toggle_visibility_cb (widget, data) |
67843
6cf5dc28bd1e
* gtkutil.c (xg_toggle_visibility_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
67761
diff
changeset
|
1224 GtkWidget *widget; |
6cf5dc28bd1e
* gtkutil.c (xg_toggle_visibility_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
67761
diff
changeset
|
1225 gpointer data; |
6cf5dc28bd1e
* gtkutil.c (xg_toggle_visibility_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
67761
diff
changeset
|
1226 { |
6cf5dc28bd1e
* gtkutil.c (xg_toggle_visibility_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
67761
diff
changeset
|
1227 GtkFileChooser *dialog = GTK_FILE_CHOOSER (data); |
6cf5dc28bd1e
* gtkutil.c (xg_toggle_visibility_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
67761
diff
changeset
|
1228 gboolean visible; |
6cf5dc28bd1e
* gtkutil.c (xg_toggle_visibility_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
67761
diff
changeset
|
1229 g_object_get (G_OBJECT (dialog), "show-hidden", &visible, NULL); |
6cf5dc28bd1e
* gtkutil.c (xg_toggle_visibility_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
67761
diff
changeset
|
1230 g_object_set (G_OBJECT (dialog), "show-hidden", !visible, NULL); |
68100
e5611feba7f7
* gtkutil.c (xg_toggle_notify_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
68027
diff
changeset
|
1231 } |
e5611feba7f7
* gtkutil.c (xg_toggle_notify_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
68027
diff
changeset
|
1232 |
e5611feba7f7
* gtkutil.c (xg_toggle_notify_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
68027
diff
changeset
|
1233 |
e5611feba7f7
* gtkutil.c (xg_toggle_notify_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
68027
diff
changeset
|
1234 /* Callback called when a property changes in a file chooser. |
e5611feba7f7
* gtkutil.c (xg_toggle_notify_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
68027
diff
changeset
|
1235 GOBJECT is the file chooser dialog, ARG1 describes the property. |
e5611feba7f7
* gtkutil.c (xg_toggle_notify_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
68027
diff
changeset
|
1236 USER_DATA is the toggle widget in the file chooser dialog. |
e5611feba7f7
* gtkutil.c (xg_toggle_notify_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
68027
diff
changeset
|
1237 We use this to update the "Show hidden files" toggle when the user |
e5611feba7f7
* gtkutil.c (xg_toggle_notify_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
68027
diff
changeset
|
1238 changes that property by right clicking in the file list. */ |
e5611feba7f7
* gtkutil.c (xg_toggle_notify_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
68027
diff
changeset
|
1239 |
e5611feba7f7
* gtkutil.c (xg_toggle_notify_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
68027
diff
changeset
|
1240 static void |
e5611feba7f7
* gtkutil.c (xg_toggle_notify_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
68027
diff
changeset
|
1241 xg_toggle_notify_cb (gobject, arg1, user_data) |
e5611feba7f7
* gtkutil.c (xg_toggle_notify_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
68027
diff
changeset
|
1242 GObject *gobject; |
e5611feba7f7
* gtkutil.c (xg_toggle_notify_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
68027
diff
changeset
|
1243 GParamSpec *arg1; |
e5611feba7f7
* gtkutil.c (xg_toggle_notify_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
68027
diff
changeset
|
1244 gpointer user_data; |
e5611feba7f7
* gtkutil.c (xg_toggle_notify_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
68027
diff
changeset
|
1245 { |
e5611feba7f7
* gtkutil.c (xg_toggle_notify_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
68027
diff
changeset
|
1246 extern int x_gtk_show_hidden_files; |
e5611feba7f7
* gtkutil.c (xg_toggle_notify_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
68027
diff
changeset
|
1247 |
e5611feba7f7
* gtkutil.c (xg_toggle_notify_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
68027
diff
changeset
|
1248 if (strcmp (arg1->name, "show-hidden") == 0) |
e5611feba7f7
* gtkutil.c (xg_toggle_notify_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
68027
diff
changeset
|
1249 { |
e5611feba7f7
* gtkutil.c (xg_toggle_notify_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
68027
diff
changeset
|
1250 GtkFileChooser *dialog = GTK_FILE_CHOOSER (gobject); |
e5611feba7f7
* gtkutil.c (xg_toggle_notify_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
68027
diff
changeset
|
1251 GtkWidget *wtoggle = GTK_WIDGET (user_data); |
e5611feba7f7
* gtkutil.c (xg_toggle_notify_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
68027
diff
changeset
|
1252 gboolean visible, toggle_on; |
e5611feba7f7
* gtkutil.c (xg_toggle_notify_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
68027
diff
changeset
|
1253 |
e5611feba7f7
* gtkutil.c (xg_toggle_notify_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
68027
diff
changeset
|
1254 g_object_get (G_OBJECT (gobject), "show-hidden", &visible, NULL); |
e5611feba7f7
* gtkutil.c (xg_toggle_notify_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
68027
diff
changeset
|
1255 toggle_on = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (wtoggle)); |
e5611feba7f7
* gtkutil.c (xg_toggle_notify_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
68027
diff
changeset
|
1256 |
e5611feba7f7
* gtkutil.c (xg_toggle_notify_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
68027
diff
changeset
|
1257 if (!!visible != !!toggle_on) |
e5611feba7f7
* gtkutil.c (xg_toggle_notify_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
68027
diff
changeset
|
1258 { |
e5611feba7f7
* gtkutil.c (xg_toggle_notify_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
68027
diff
changeset
|
1259 g_signal_handlers_block_by_func (G_OBJECT (wtoggle), |
e5611feba7f7
* gtkutil.c (xg_toggle_notify_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
68027
diff
changeset
|
1260 G_CALLBACK (xg_toggle_visibility_cb), |
e5611feba7f7
* gtkutil.c (xg_toggle_notify_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
68027
diff
changeset
|
1261 gobject); |
e5611feba7f7
* gtkutil.c (xg_toggle_notify_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
68027
diff
changeset
|
1262 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (wtoggle), visible); |
e5611feba7f7
* gtkutil.c (xg_toggle_notify_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
68027
diff
changeset
|
1263 g_signal_handlers_unblock_by_func |
e5611feba7f7
* gtkutil.c (xg_toggle_notify_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
68027
diff
changeset
|
1264 (G_OBJECT (wtoggle), |
e5611feba7f7
* gtkutil.c (xg_toggle_notify_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
68027
diff
changeset
|
1265 G_CALLBACK (xg_toggle_visibility_cb), |
e5611feba7f7
* gtkutil.c (xg_toggle_notify_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
68027
diff
changeset
|
1266 gobject); |
e5611feba7f7
* gtkutil.c (xg_toggle_notify_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
68027
diff
changeset
|
1267 } |
e5611feba7f7
* gtkutil.c (xg_toggle_notify_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
68027
diff
changeset
|
1268 x_gtk_show_hidden_files = visible; |
e5611feba7f7
* gtkutil.c (xg_toggle_notify_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
68027
diff
changeset
|
1269 } |
67843
6cf5dc28bd1e
* gtkutil.c (xg_toggle_visibility_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
67761
diff
changeset
|
1270 } |
6cf5dc28bd1e
* gtkutil.c (xg_toggle_visibility_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
67761
diff
changeset
|
1271 |
57868
c955f6add62a
* fileio.c (Fread_file_name): Pass Qt as fifth parameter to
Jan Djärv <jan.h.d@swipnet.se>
parents:
57715
diff
changeset
|
1272 /* Read a file name from the user using a file chooser dialog. |
c955f6add62a
* fileio.c (Fread_file_name): Pass Qt as fifth parameter to
Jan Djärv <jan.h.d@swipnet.se>
parents:
57715
diff
changeset
|
1273 F is the current frame. |
c955f6add62a
* fileio.c (Fread_file_name): Pass Qt as fifth parameter to
Jan Djärv <jan.h.d@swipnet.se>
parents:
57715
diff
changeset
|
1274 PROMPT is a prompt to show to the user. May not be NULL. |
c955f6add62a
* fileio.c (Fread_file_name): Pass Qt as fifth parameter to
Jan Djärv <jan.h.d@swipnet.se>
parents:
57715
diff
changeset
|
1275 DEFAULT_FILENAME is a default selection to be displayed. May be NULL. |
c955f6add62a
* fileio.c (Fread_file_name): Pass Qt as fifth parameter to
Jan Djärv <jan.h.d@swipnet.se>
parents:
57715
diff
changeset
|
1276 If MUSTMATCH_P is non-zero, the returned file name must be an existing |
58200
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1277 file. *FUNC is set to a function that can be used to retrieve the |
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1278 selected file name from the returned widget. |
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1279 |
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1280 Returns the created widget. */ |
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1281 |
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1282 static GtkWidget * |
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1283 xg_get_file_with_chooser (f, prompt, default_filename, |
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1284 mustmatch_p, only_dir_p, func) |
57868
c955f6add62a
* fileio.c (Fread_file_name): Pass Qt as fifth parameter to
Jan Djärv <jan.h.d@swipnet.se>
parents:
57715
diff
changeset
|
1285 FRAME_PTR f; |
c955f6add62a
* fileio.c (Fread_file_name): Pass Qt as fifth parameter to
Jan Djärv <jan.h.d@swipnet.se>
parents:
57715
diff
changeset
|
1286 char *prompt; |
c955f6add62a
* fileio.c (Fread_file_name): Pass Qt as fifth parameter to
Jan Djärv <jan.h.d@swipnet.se>
parents:
57715
diff
changeset
|
1287 char *default_filename; |
c955f6add62a
* fileio.c (Fread_file_name): Pass Qt as fifth parameter to
Jan Djärv <jan.h.d@swipnet.se>
parents:
57715
diff
changeset
|
1288 int mustmatch_p, only_dir_p; |
58200
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1289 xg_get_file_func *func; |
57868
c955f6add62a
* fileio.c (Fread_file_name): Pass Qt as fifth parameter to
Jan Djärv <jan.h.d@swipnet.se>
parents:
57715
diff
changeset
|
1290 { |
67843
6cf5dc28bd1e
* gtkutil.c (xg_toggle_visibility_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
67761
diff
changeset
|
1291 char message[1024]; |
6cf5dc28bd1e
* gtkutil.c (xg_toggle_visibility_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
67761
diff
changeset
|
1292 |
6cf5dc28bd1e
* gtkutil.c (xg_toggle_visibility_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
67761
diff
changeset
|
1293 GtkWidget *filewin, *wtoggle, *wbox, *wmessage; |
57868
c955f6add62a
* fileio.c (Fread_file_name): Pass Qt as fifth parameter to
Jan Djärv <jan.h.d@swipnet.se>
parents:
57715
diff
changeset
|
1294 GtkWindow *gwin = GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)); |
c955f6add62a
* fileio.c (Fread_file_name): Pass Qt as fifth parameter to
Jan Djärv <jan.h.d@swipnet.se>
parents:
57715
diff
changeset
|
1295 GtkFileChooserAction action = (mustmatch_p ? |
c955f6add62a
* fileio.c (Fread_file_name): Pass Qt as fifth parameter to
Jan Djärv <jan.h.d@swipnet.se>
parents:
57715
diff
changeset
|
1296 GTK_FILE_CHOOSER_ACTION_OPEN : |
c955f6add62a
* fileio.c (Fread_file_name): Pass Qt as fifth parameter to
Jan Djärv <jan.h.d@swipnet.se>
parents:
57715
diff
changeset
|
1297 GTK_FILE_CHOOSER_ACTION_SAVE); |
67843
6cf5dc28bd1e
* gtkutil.c (xg_toggle_visibility_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
67761
diff
changeset
|
1298 extern int x_gtk_show_hidden_files; |
57868
c955f6add62a
* fileio.c (Fread_file_name): Pass Qt as fifth parameter to
Jan Djärv <jan.h.d@swipnet.se>
parents:
57715
diff
changeset
|
1299 |
c955f6add62a
* fileio.c (Fread_file_name): Pass Qt as fifth parameter to
Jan Djärv <jan.h.d@swipnet.se>
parents:
57715
diff
changeset
|
1300 if (only_dir_p) |
c955f6add62a
* fileio.c (Fread_file_name): Pass Qt as fifth parameter to
Jan Djärv <jan.h.d@swipnet.se>
parents:
57715
diff
changeset
|
1301 action = GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER; |
c955f6add62a
* fileio.c (Fread_file_name): Pass Qt as fifth parameter to
Jan Djärv <jan.h.d@swipnet.se>
parents:
57715
diff
changeset
|
1302 |
c955f6add62a
* fileio.c (Fread_file_name): Pass Qt as fifth parameter to
Jan Djärv <jan.h.d@swipnet.se>
parents:
57715
diff
changeset
|
1303 filewin = gtk_file_chooser_dialog_new (prompt, gwin, action, |
c955f6add62a
* fileio.c (Fread_file_name): Pass Qt as fifth parameter to
Jan Djärv <jan.h.d@swipnet.se>
parents:
57715
diff
changeset
|
1304 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, |
c955f6add62a
* fileio.c (Fread_file_name): Pass Qt as fifth parameter to
Jan Djärv <jan.h.d@swipnet.se>
parents:
57715
diff
changeset
|
1305 (mustmatch_p || only_dir_p ? |
57900
a76858072e78
* gtkutil.c (xg_get_file_with_chooser): Use GTK_STOCK_OK instead
Jan Djärv <jan.h.d@swipnet.se>
parents:
57868
diff
changeset
|
1306 GTK_STOCK_OPEN : GTK_STOCK_OK), |
57868
c955f6add62a
* fileio.c (Fread_file_name): Pass Qt as fifth parameter to
Jan Djärv <jan.h.d@swipnet.se>
parents:
57715
diff
changeset
|
1307 GTK_RESPONSE_OK, |
c955f6add62a
* fileio.c (Fread_file_name): Pass Qt as fifth parameter to
Jan Djärv <jan.h.d@swipnet.se>
parents:
57715
diff
changeset
|
1308 NULL); |
58817
65f1b18b7f66
* gtkutil.c (xg_get_file_with_chooser): Handle local files only.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58463
diff
changeset
|
1309 gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (filewin), TRUE); |
57868
c955f6add62a
* fileio.c (Fread_file_name): Pass Qt as fifth parameter to
Jan Djärv <jan.h.d@swipnet.se>
parents:
57715
diff
changeset
|
1310 |
67843
6cf5dc28bd1e
* gtkutil.c (xg_toggle_visibility_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
67761
diff
changeset
|
1311 wbox = gtk_vbox_new (FALSE, 0); |
6cf5dc28bd1e
* gtkutil.c (xg_toggle_visibility_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
67761
diff
changeset
|
1312 gtk_widget_show (wbox); |
6cf5dc28bd1e
* gtkutil.c (xg_toggle_visibility_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
67761
diff
changeset
|
1313 wtoggle = gtk_check_button_new_with_label ("Show hidden files."); |
6cf5dc28bd1e
* gtkutil.c (xg_toggle_visibility_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
67761
diff
changeset
|
1314 |
6cf5dc28bd1e
* gtkutil.c (xg_toggle_visibility_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
67761
diff
changeset
|
1315 if (x_gtk_show_hidden_files) |
6cf5dc28bd1e
* gtkutil.c (xg_toggle_visibility_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
67761
diff
changeset
|
1316 { |
6cf5dc28bd1e
* gtkutil.c (xg_toggle_visibility_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
67761
diff
changeset
|
1317 g_object_set (G_OBJECT (filewin), "show-hidden", TRUE, NULL); |
6cf5dc28bd1e
* gtkutil.c (xg_toggle_visibility_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
67761
diff
changeset
|
1318 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (wtoggle), TRUE); |
6cf5dc28bd1e
* gtkutil.c (xg_toggle_visibility_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
67761
diff
changeset
|
1319 } |
6cf5dc28bd1e
* gtkutil.c (xg_toggle_visibility_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
67761
diff
changeset
|
1320 gtk_widget_show (wtoggle); |
6cf5dc28bd1e
* gtkutil.c (xg_toggle_visibility_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
67761
diff
changeset
|
1321 g_signal_connect (G_OBJECT (wtoggle), "clicked", |
68100
e5611feba7f7
* gtkutil.c (xg_toggle_notify_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
68027
diff
changeset
|
1322 G_CALLBACK (xg_toggle_visibility_cb), filewin); |
e5611feba7f7
* gtkutil.c (xg_toggle_notify_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
68027
diff
changeset
|
1323 g_signal_connect (G_OBJECT (filewin), "notify", |
e5611feba7f7
* gtkutil.c (xg_toggle_notify_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
68027
diff
changeset
|
1324 G_CALLBACK (xg_toggle_notify_cb), wtoggle); |
67843
6cf5dc28bd1e
* gtkutil.c (xg_toggle_visibility_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
67761
diff
changeset
|
1325 |
67875
e1dfc5458653
* gtkutil.c (xg_get_file_with_chooser): Changed message shown
Jan Djärv <jan.h.d@swipnet.se>
parents:
67849
diff
changeset
|
1326 message[0] = '\0'; |
e1dfc5458653
* gtkutil.c (xg_get_file_with_chooser): Changed message shown
Jan Djärv <jan.h.d@swipnet.se>
parents:
67849
diff
changeset
|
1327 if (action != GTK_FILE_CHOOSER_ACTION_SAVE) |
e1dfc5458653
* gtkutil.c (xg_get_file_with_chooser): Changed message shown
Jan Djärv <jan.h.d@swipnet.se>
parents:
67849
diff
changeset
|
1328 strcat (message, "\nType C-l to display a file name text entry box.\n"); |
72637
9db8c9a68f0f
* gtkutil.c (xg_get_file_with_chooser): Don't mention specific keys in
Jan Djärv <jan.h.d@swipnet.se>
parents:
72614
diff
changeset
|
1329 strcat (message, "\nIf you don't like this file selector, use the " |
9db8c9a68f0f
* gtkutil.c (xg_get_file_with_chooser): Don't mention specific keys in
Jan Djärv <jan.h.d@swipnet.se>
parents:
72614
diff
changeset
|
1330 "corresponding\nkey binding or customize " |
9db8c9a68f0f
* gtkutil.c (xg_get_file_with_chooser): Don't mention specific keys in
Jan Djärv <jan.h.d@swipnet.se>
parents:
72614
diff
changeset
|
1331 "use-file-dialog to turn it off."); |
72614
af91ff74c754
* gtkutil.c (xg_get_file_with_chooser): Change file chooser message
Jan Djärv <jan.h.d@swipnet.se>
parents:
71160
diff
changeset
|
1332 |
67843
6cf5dc28bd1e
* gtkutil.c (xg_toggle_visibility_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
67761
diff
changeset
|
1333 wmessage = gtk_label_new (message); |
6cf5dc28bd1e
* gtkutil.c (xg_toggle_visibility_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
67761
diff
changeset
|
1334 gtk_widget_show (wmessage); |
6cf5dc28bd1e
* gtkutil.c (xg_toggle_visibility_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
67761
diff
changeset
|
1335 gtk_box_pack_start (GTK_BOX (wbox), wtoggle, FALSE, FALSE, 0); |
6cf5dc28bd1e
* gtkutil.c (xg_toggle_visibility_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
67761
diff
changeset
|
1336 gtk_box_pack_start (GTK_BOX (wbox), wmessage, FALSE, FALSE, 0); |
6cf5dc28bd1e
* gtkutil.c (xg_toggle_visibility_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
67761
diff
changeset
|
1337 gtk_file_chooser_set_extra_widget (GTK_FILE_CHOOSER (filewin), wbox); |
6cf5dc28bd1e
* gtkutil.c (xg_toggle_visibility_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
67761
diff
changeset
|
1338 |
57868
c955f6add62a
* fileio.c (Fread_file_name): Pass Qt as fifth parameter to
Jan Djärv <jan.h.d@swipnet.se>
parents:
57715
diff
changeset
|
1339 if (default_filename) |
57940
a3fa0e63dd67
* gtkutil.c (xg_get_file_with_chooser): Expand DEFAULT_FILENAME if
Jan Djärv <jan.h.d@swipnet.se>
parents:
57900
diff
changeset
|
1340 { |
a3fa0e63dd67
* gtkutil.c (xg_get_file_with_chooser): Expand DEFAULT_FILENAME if
Jan Djärv <jan.h.d@swipnet.se>
parents:
57900
diff
changeset
|
1341 Lisp_Object file; |
a3fa0e63dd67
* gtkutil.c (xg_get_file_with_chooser): Expand DEFAULT_FILENAME if
Jan Djärv <jan.h.d@swipnet.se>
parents:
57900
diff
changeset
|
1342 struct gcpro gcpro1; |
a3fa0e63dd67
* gtkutil.c (xg_get_file_with_chooser): Expand DEFAULT_FILENAME if
Jan Djärv <jan.h.d@swipnet.se>
parents:
57900
diff
changeset
|
1343 GCPRO1 (file); |
72614
af91ff74c754
* gtkutil.c (xg_get_file_with_chooser): Change file chooser message
Jan Djärv <jan.h.d@swipnet.se>
parents:
71160
diff
changeset
|
1344 char *utf8_filename; |
57940
a3fa0e63dd67
* gtkutil.c (xg_get_file_with_chooser): Expand DEFAULT_FILENAME if
Jan Djärv <jan.h.d@swipnet.se>
parents:
57900
diff
changeset
|
1345 |
58817
65f1b18b7f66
* gtkutil.c (xg_get_file_with_chooser): Handle local files only.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58463
diff
changeset
|
1346 file = build_string (default_filename); |
65f1b18b7f66
* gtkutil.c (xg_get_file_with_chooser): Handle local files only.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58463
diff
changeset
|
1347 |
57940
a3fa0e63dd67
* gtkutil.c (xg_get_file_with_chooser): Expand DEFAULT_FILENAME if
Jan Djärv <jan.h.d@swipnet.se>
parents:
57900
diff
changeset
|
1348 /* File chooser does not understand ~/... in the file name. It must be |
a3fa0e63dd67
* gtkutil.c (xg_get_file_with_chooser): Expand DEFAULT_FILENAME if
Jan Djärv <jan.h.d@swipnet.se>
parents:
57900
diff
changeset
|
1349 an absolute name starting with /. */ |
a3fa0e63dd67
* gtkutil.c (xg_get_file_with_chooser): Expand DEFAULT_FILENAME if
Jan Djärv <jan.h.d@swipnet.se>
parents:
57900
diff
changeset
|
1350 if (default_filename[0] != '/') |
58817
65f1b18b7f66
* gtkutil.c (xg_get_file_with_chooser): Handle local files only.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58463
diff
changeset
|
1351 file = Fexpand_file_name (file, Qnil); |
72614
af91ff74c754
* gtkutil.c (xg_get_file_with_chooser): Change file chooser message
Jan Djärv <jan.h.d@swipnet.se>
parents:
71160
diff
changeset
|
1352 |
af91ff74c754
* gtkutil.c (xg_get_file_with_chooser): Change file chooser message
Jan Djärv <jan.h.d@swipnet.se>
parents:
71160
diff
changeset
|
1353 utf8_filename = SSDATA (ENCODE_UTF_8 (file)); |
af91ff74c754
* gtkutil.c (xg_get_file_with_chooser): Change file chooser message
Jan Djärv <jan.h.d@swipnet.se>
parents:
71160
diff
changeset
|
1354 if (! NILP (Ffile_directory_p (file))) |
58817
65f1b18b7f66
* gtkutil.c (xg_get_file_with_chooser): Handle local files only.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58463
diff
changeset
|
1355 gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (filewin), |
72614
af91ff74c754
* gtkutil.c (xg_get_file_with_chooser): Change file chooser message
Jan Djärv <jan.h.d@swipnet.se>
parents:
71160
diff
changeset
|
1356 utf8_filename); |
58817
65f1b18b7f66
* gtkutil.c (xg_get_file_with_chooser): Handle local files only.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58463
diff
changeset
|
1357 else |
72614
af91ff74c754
* gtkutil.c (xg_get_file_with_chooser): Change file chooser message
Jan Djärv <jan.h.d@swipnet.se>
parents:
71160
diff
changeset
|
1358 { |
af91ff74c754
* gtkutil.c (xg_get_file_with_chooser): Change file chooser message
Jan Djärv <jan.h.d@swipnet.se>
parents:
71160
diff
changeset
|
1359 gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (filewin), |
af91ff74c754
* gtkutil.c (xg_get_file_with_chooser): Change file chooser message
Jan Djärv <jan.h.d@swipnet.se>
parents:
71160
diff
changeset
|
1360 utf8_filename); |
72637
9db8c9a68f0f
* gtkutil.c (xg_get_file_with_chooser): Don't mention specific keys in
Jan Djärv <jan.h.d@swipnet.se>
parents:
72614
diff
changeset
|
1361 if (action == GTK_FILE_CHOOSER_ACTION_SAVE) |
9db8c9a68f0f
* gtkutil.c (xg_get_file_with_chooser): Don't mention specific keys in
Jan Djärv <jan.h.d@swipnet.se>
parents:
72614
diff
changeset
|
1362 { |
9db8c9a68f0f
* gtkutil.c (xg_get_file_with_chooser): Don't mention specific keys in
Jan Djärv <jan.h.d@swipnet.se>
parents:
72614
diff
changeset
|
1363 char *cp = strrchr (utf8_filename, '/'); |
9db8c9a68f0f
* gtkutil.c (xg_get_file_with_chooser): Don't mention specific keys in
Jan Djärv <jan.h.d@swipnet.se>
parents:
72614
diff
changeset
|
1364 if (cp) ++cp; |
9db8c9a68f0f
* gtkutil.c (xg_get_file_with_chooser): Don't mention specific keys in
Jan Djärv <jan.h.d@swipnet.se>
parents:
72614
diff
changeset
|
1365 else cp = utf8_filename; |
9db8c9a68f0f
* gtkutil.c (xg_get_file_with_chooser): Don't mention specific keys in
Jan Djärv <jan.h.d@swipnet.se>
parents:
72614
diff
changeset
|
1366 gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (filewin), cp); |
9db8c9a68f0f
* gtkutil.c (xg_get_file_with_chooser): Don't mention specific keys in
Jan Djärv <jan.h.d@swipnet.se>
parents:
72614
diff
changeset
|
1367 } |
72614
af91ff74c754
* gtkutil.c (xg_get_file_with_chooser): Change file chooser message
Jan Djärv <jan.h.d@swipnet.se>
parents:
71160
diff
changeset
|
1368 } |
57940
a3fa0e63dd67
* gtkutil.c (xg_get_file_with_chooser): Expand DEFAULT_FILENAME if
Jan Djärv <jan.h.d@swipnet.se>
parents:
57900
diff
changeset
|
1369 |
a3fa0e63dd67
* gtkutil.c (xg_get_file_with_chooser): Expand DEFAULT_FILENAME if
Jan Djärv <jan.h.d@swipnet.se>
parents:
57900
diff
changeset
|
1370 UNGCPRO; |
a3fa0e63dd67
* gtkutil.c (xg_get_file_with_chooser): Expand DEFAULT_FILENAME if
Jan Djärv <jan.h.d@swipnet.se>
parents:
57900
diff
changeset
|
1371 } |
57868
c955f6add62a
* fileio.c (Fread_file_name): Pass Qt as fifth parameter to
Jan Djärv <jan.h.d@swipnet.se>
parents:
57715
diff
changeset
|
1372 |
58200
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1373 *func = xg_get_file_name_from_chooser; |
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1374 return filewin; |
57868
c955f6add62a
* fileio.c (Fread_file_name): Pass Qt as fifth parameter to
Jan Djärv <jan.h.d@swipnet.se>
parents:
57715
diff
changeset
|
1375 } |
c955f6add62a
* fileio.c (Fread_file_name): Pass Qt as fifth parameter to
Jan Djärv <jan.h.d@swipnet.se>
parents:
57715
diff
changeset
|
1376 #endif /* HAVE_GTK_FILE_CHOOSER_DIALOG_NEW */ |
c955f6add62a
* fileio.c (Fread_file_name): Pass Qt as fifth parameter to
Jan Djärv <jan.h.d@swipnet.se>
parents:
57715
diff
changeset
|
1377 |
c955f6add62a
* fileio.c (Fread_file_name): Pass Qt as fifth parameter to
Jan Djärv <jan.h.d@swipnet.se>
parents:
57715
diff
changeset
|
1378 #ifdef HAVE_GTK_FILE_SELECTION_NEW |
58200
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1379 |
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1380 /* Return the selected file for file selector dialog W. |
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1381 The returned string must be free:d. */ |
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1382 |
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1383 static char * |
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1384 xg_get_file_name_from_selector (w) |
49323 | 1385 GtkWidget *w; |
1386 { | |
58200
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1387 GtkFileSelection *filesel = GTK_FILE_SELECTION (w); |
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1388 return xstrdup ((char*) gtk_file_selection_get_filename (filesel)); |
49323 | 1389 } |
1390 | |
58200
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1391 /* Create a file selection dialog. |
49323 | 1392 F is the current frame. |
1393 PROMPT is a prompt to show to the user. May not be NULL. | |
1394 DEFAULT_FILENAME is a default selection to be displayed. May be NULL. | |
1395 If MUSTMATCH_P is non-zero, the returned file name must be an existing | |
58200
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1396 file. *FUNC is set to a function that can be used to retrieve the |
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1397 selected file name from the returned widget. |
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1398 |
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1399 Returns the created widget. */ |
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1400 |
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1401 static GtkWidget * |
57868
c955f6add62a
* fileio.c (Fread_file_name): Pass Qt as fifth parameter to
Jan Djärv <jan.h.d@swipnet.se>
parents:
57715
diff
changeset
|
1402 xg_get_file_with_selection (f, prompt, default_filename, |
58200
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1403 mustmatch_p, only_dir_p, func) |
49323 | 1404 FRAME_PTR f; |
1405 char *prompt; | |
1406 char *default_filename; | |
57868
c955f6add62a
* fileio.c (Fread_file_name): Pass Qt as fifth parameter to
Jan Djärv <jan.h.d@swipnet.se>
parents:
57715
diff
changeset
|
1407 int mustmatch_p, only_dir_p; |
58200
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1408 xg_get_file_func *func; |
49323 | 1409 { |
1410 GtkWidget *filewin; | |
1411 GtkFileSelection *filesel; | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
1412 |
49323 | 1413 filewin = gtk_file_selection_new (prompt); |
1414 filesel = GTK_FILE_SELECTION (filewin); | |
1415 | |
1416 if (default_filename) | |
1417 gtk_file_selection_set_filename (filesel, default_filename); | |
1418 | |
1419 if (mustmatch_p) | |
1420 { | |
1421 /* The selection_entry part of filesel is not documented. */ | |
1422 gtk_widget_set_sensitive (filesel->selection_entry, FALSE); | |
1423 gtk_file_selection_hide_fileop_buttons (filesel); | |
1424 } | |
1425 | |
58200
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1426 *func = xg_get_file_name_from_selector; |
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1427 |
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1428 return filewin; |
49323 | 1429 } |
57868
c955f6add62a
* fileio.c (Fread_file_name): Pass Qt as fifth parameter to
Jan Djärv <jan.h.d@swipnet.se>
parents:
57715
diff
changeset
|
1430 #endif /* HAVE_GTK_FILE_SELECTION_NEW */ |
c955f6add62a
* fileio.c (Fread_file_name): Pass Qt as fifth parameter to
Jan Djärv <jan.h.d@swipnet.se>
parents:
57715
diff
changeset
|
1431 |
c955f6add62a
* fileio.c (Fread_file_name): Pass Qt as fifth parameter to
Jan Djärv <jan.h.d@swipnet.se>
parents:
57715
diff
changeset
|
1432 /* Read a file name from the user using a file dialog, either the old |
c955f6add62a
* fileio.c (Fread_file_name): Pass Qt as fifth parameter to
Jan Djärv <jan.h.d@swipnet.se>
parents:
57715
diff
changeset
|
1433 file selection dialog, or the new file chooser dialog. Which to use |
c955f6add62a
* fileio.c (Fread_file_name): Pass Qt as fifth parameter to
Jan Djärv <jan.h.d@swipnet.se>
parents:
57715
diff
changeset
|
1434 depends on what the GTK version used has, and what the value of |
c955f6add62a
* fileio.c (Fread_file_name): Pass Qt as fifth parameter to
Jan Djärv <jan.h.d@swipnet.se>
parents:
57715
diff
changeset
|
1435 gtk-use-old-file-dialog. |
c955f6add62a
* fileio.c (Fread_file_name): Pass Qt as fifth parameter to
Jan Djärv <jan.h.d@swipnet.se>
parents:
57715
diff
changeset
|
1436 F is the current frame. |
c955f6add62a
* fileio.c (Fread_file_name): Pass Qt as fifth parameter to
Jan Djärv <jan.h.d@swipnet.se>
parents:
57715
diff
changeset
|
1437 PROMPT is a prompt to show to the user. May not be NULL. |
c955f6add62a
* fileio.c (Fread_file_name): Pass Qt as fifth parameter to
Jan Djärv <jan.h.d@swipnet.se>
parents:
57715
diff
changeset
|
1438 DEFAULT_FILENAME is a default selection to be displayed. May be NULL. |
c955f6add62a
* fileio.c (Fread_file_name): Pass Qt as fifth parameter to
Jan Djärv <jan.h.d@swipnet.se>
parents:
57715
diff
changeset
|
1439 If MUSTMATCH_P is non-zero, the returned file name must be an existing |
c955f6add62a
* fileio.c (Fread_file_name): Pass Qt as fifth parameter to
Jan Djärv <jan.h.d@swipnet.se>
parents:
57715
diff
changeset
|
1440 file. |
c955f6add62a
* fileio.c (Fread_file_name): Pass Qt as fifth parameter to
Jan Djärv <jan.h.d@swipnet.se>
parents:
57715
diff
changeset
|
1441 |
c955f6add62a
* fileio.c (Fread_file_name): Pass Qt as fifth parameter to
Jan Djärv <jan.h.d@swipnet.se>
parents:
57715
diff
changeset
|
1442 Returns a file name or NULL if no file was selected. |
c955f6add62a
* fileio.c (Fread_file_name): Pass Qt as fifth parameter to
Jan Djärv <jan.h.d@swipnet.se>
parents:
57715
diff
changeset
|
1443 The returned string must be freed by the caller. */ |
c955f6add62a
* fileio.c (Fread_file_name): Pass Qt as fifth parameter to
Jan Djärv <jan.h.d@swipnet.se>
parents:
57715
diff
changeset
|
1444 |
c955f6add62a
* fileio.c (Fread_file_name): Pass Qt as fifth parameter to
Jan Djärv <jan.h.d@swipnet.se>
parents:
57715
diff
changeset
|
1445 char * |
c955f6add62a
* fileio.c (Fread_file_name): Pass Qt as fifth parameter to
Jan Djärv <jan.h.d@swipnet.se>
parents:
57715
diff
changeset
|
1446 xg_get_file_name (f, prompt, default_filename, mustmatch_p, only_dir_p) |
c955f6add62a
* fileio.c (Fread_file_name): Pass Qt as fifth parameter to
Jan Djärv <jan.h.d@swipnet.se>
parents:
57715
diff
changeset
|
1447 FRAME_PTR f; |
c955f6add62a
* fileio.c (Fread_file_name): Pass Qt as fifth parameter to
Jan Djärv <jan.h.d@swipnet.se>
parents:
57715
diff
changeset
|
1448 char *prompt; |
c955f6add62a
* fileio.c (Fread_file_name): Pass Qt as fifth parameter to
Jan Djärv <jan.h.d@swipnet.se>
parents:
57715
diff
changeset
|
1449 char *default_filename; |
c955f6add62a
* fileio.c (Fread_file_name): Pass Qt as fifth parameter to
Jan Djärv <jan.h.d@swipnet.se>
parents:
57715
diff
changeset
|
1450 int mustmatch_p, only_dir_p; |
c955f6add62a
* fileio.c (Fread_file_name): Pass Qt as fifth parameter to
Jan Djärv <jan.h.d@swipnet.se>
parents:
57715
diff
changeset
|
1451 { |
58284
10efc827e15c
* gtkutil.c (xg_get_file_name): Fix typo in
Jan Djärv <jan.h.d@swipnet.se>
parents:
58201
diff
changeset
|
1452 GtkWidget *w = 0; |
58200
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1453 int count = SPECPDL_INDEX (); |
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1454 char *fn = 0; |
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1455 int filesel_done = 0; |
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1456 xg_get_file_func func; |
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1457 |
58818
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58817
diff
changeset
|
1458 #if defined (HAVE_GTK_AND_PTHREAD) && defined (__SIGRTMIN) |
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58817
diff
changeset
|
1459 /* I really don't know why this is needed, but without this the GLIBC add on |
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58817
diff
changeset
|
1460 library linuxthreads hangs when the Gnome file chooser backend creates |
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58817
diff
changeset
|
1461 threads. */ |
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58817
diff
changeset
|
1462 sigblock (sigmask (__SIGRTMIN)); |
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58817
diff
changeset
|
1463 #endif /* HAVE_GTK_AND_PTHREAD */ |
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58817
diff
changeset
|
1464 |
57868
c955f6add62a
* fileio.c (Fread_file_name): Pass Qt as fifth parameter to
Jan Djärv <jan.h.d@swipnet.se>
parents:
57715
diff
changeset
|
1465 #ifdef HAVE_GTK_FILE_BOTH |
58463
86fddd350b35
* gtkutil.c (xg_get_file_name): Rename use-old-gtk-file-dialog to
Jan Djärv <jan.h.d@swipnet.se>
parents:
58284
diff
changeset
|
1466 |
67761
5b8799d65159
* xfns.c (Fx_uses_old_gtk_dialog): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
67528
diff
changeset
|
1467 if (xg_uses_old_file_dialog ()) |
58200
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1468 w = xg_get_file_with_selection (f, prompt, default_filename, |
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1469 mustmatch_p, only_dir_p, &func); |
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1470 else |
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1471 w = xg_get_file_with_chooser (f, prompt, default_filename, |
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1472 mustmatch_p, only_dir_p, &func); |
57868
c955f6add62a
* fileio.c (Fread_file_name): Pass Qt as fifth parameter to
Jan Djärv <jan.h.d@swipnet.se>
parents:
57715
diff
changeset
|
1473 |
c955f6add62a
* fileio.c (Fread_file_name): Pass Qt as fifth parameter to
Jan Djärv <jan.h.d@swipnet.se>
parents:
57715
diff
changeset
|
1474 #else /* not HAVE_GTK_FILE_BOTH */ |
c955f6add62a
* fileio.c (Fread_file_name): Pass Qt as fifth parameter to
Jan Djärv <jan.h.d@swipnet.se>
parents:
57715
diff
changeset
|
1475 |
58284
10efc827e15c
* gtkutil.c (xg_get_file_name): Fix typo in
Jan Djärv <jan.h.d@swipnet.se>
parents:
58201
diff
changeset
|
1476 #ifdef HAVE_GTK_FILE_SELECTION_NEW |
58200
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1477 w = xg_get_file_with_selection (f, prompt, default_filename, |
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1478 mustmatch_p, only_dir_p, &func); |
57868
c955f6add62a
* fileio.c (Fread_file_name): Pass Qt as fifth parameter to
Jan Djärv <jan.h.d@swipnet.se>
parents:
57715
diff
changeset
|
1479 #endif |
c955f6add62a
* fileio.c (Fread_file_name): Pass Qt as fifth parameter to
Jan Djärv <jan.h.d@swipnet.se>
parents:
57715
diff
changeset
|
1480 #ifdef HAVE_GTK_FILE_CHOOSER_DIALOG_NEW |
58200
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1481 w = xg_get_file_with_chooser (f, prompt, default_filename, |
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1482 mustmatch_p, only_dir_p, &func); |
57868
c955f6add62a
* fileio.c (Fread_file_name): Pass Qt as fifth parameter to
Jan Djärv <jan.h.d@swipnet.se>
parents:
57715
diff
changeset
|
1483 #endif |
c955f6add62a
* fileio.c (Fread_file_name): Pass Qt as fifth parameter to
Jan Djärv <jan.h.d@swipnet.se>
parents:
57715
diff
changeset
|
1484 |
c955f6add62a
* fileio.c (Fread_file_name): Pass Qt as fifth parameter to
Jan Djärv <jan.h.d@swipnet.se>
parents:
57715
diff
changeset
|
1485 #endif /* HAVE_GTK_FILE_BOTH */ |
58200
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1486 |
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1487 xg_set_screen (w, f); |
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1488 gtk_widget_set_name (w, "emacs-filedialog"); |
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1489 gtk_window_set_transient_for (GTK_WINDOW (w), |
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1490 GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f))); |
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1491 gtk_window_set_destroy_with_parent (GTK_WINDOW (w), TRUE); |
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1492 gtk_window_set_modal (GTK_WINDOW (w), TRUE); |
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1493 |
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1494 g_signal_connect (G_OBJECT (w), |
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1495 "response", |
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1496 G_CALLBACK (xg_file_response_cb), |
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1497 &filesel_done); |
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1498 |
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1499 /* Don't destroy the widget if closed by the window manager close button. */ |
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1500 g_signal_connect (G_OBJECT (w), "delete-event", G_CALLBACK (gtk_true), NULL); |
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1501 |
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1502 gtk_widget_show (w); |
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1503 |
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1504 record_unwind_protect (pop_down_file_dialog, make_save_value (w, 0)); |
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1505 while (! filesel_done) |
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1506 { |
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1507 x_menu_wait_for_event (0); |
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1508 gtk_main_iteration (); |
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1509 } |
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1510 |
58818
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58817
diff
changeset
|
1511 #if defined (HAVE_GTK_AND_PTHREAD) && defined (__SIGRTMIN) |
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58817
diff
changeset
|
1512 sigunblock (sigmask (__SIGRTMIN)); |
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58817
diff
changeset
|
1513 #endif |
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Djärv <jan.h.d@swipnet.se>
parents:
58817
diff
changeset
|
1514 |
58200
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1515 if (filesel_done == GTK_RESPONSE_OK) |
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1516 fn = (*func) (w); |
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1517 |
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1518 unbind_to (count, Qnil); |
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1519 |
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1520 return fn; |
57868
c955f6add62a
* fileio.c (Fread_file_name): Pass Qt as fifth parameter to
Jan Djärv <jan.h.d@swipnet.se>
parents:
57715
diff
changeset
|
1521 } |
49323 | 1522 |
1523 | |
1524 /*********************************************************************** | |
1525 Menu functions. | |
1526 ***********************************************************************/ | |
1527 | |
1528 /* The name of menu items that can be used for citomization. Since GTK | |
1529 RC files are very crude and primitive, we have to set this on all | |
1530 menu item names so a user can easily cutomize menu items. */ | |
1531 | |
1532 #define MENU_ITEM_NAME "emacs-menuitem" | |
1533 | |
1534 | |
1535 /* Linked list of all allocated struct xg_menu_cb_data. Used for marking | |
1536 during GC. The next member points to the items. */ | |
1537 static xg_list_node xg_menu_cb_list; | |
1538 | |
1539 /* Linked list of all allocated struct xg_menu_item_cb_data. Used for marking | |
1540 during GC. The next member points to the items. */ | |
1541 static xg_list_node xg_menu_item_cb_list; | |
1542 | |
1543 /* Allocate and initialize CL_DATA if NULL, otherwise increase ref_count. | |
1544 F is the frame CL_DATA will be initialized for. | |
1545 HIGHLIGHT_CB is the callback to call when entering/leaving menu items. | |
1546 | |
1547 The menu bar and all sub menus under the menu bar in a frame | |
1548 share the same structure, hence the reference count. | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
1549 |
49323 | 1550 Returns CL_DATA if CL_DATA is not NULL, or a pointer to a newly |
1551 allocated xg_menu_cb_data if CL_DATA is NULL. */ | |
57715
cdc48cdd5b0e
* gtkutil.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57597
diff
changeset
|
1552 |
49323 | 1553 static xg_menu_cb_data * |
1554 make_cl_data (cl_data, f, highlight_cb) | |
1555 xg_menu_cb_data *cl_data; | |
1556 FRAME_PTR f; | |
1557 GCallback highlight_cb; | |
1558 { | |
1559 if (! cl_data) | |
1560 { | |
1561 cl_data = (xg_menu_cb_data*) xmalloc (sizeof (*cl_data)); | |
1562 cl_data->f = f; | |
1563 cl_data->menu_bar_vector = f->menu_bar_vector; | |
1564 cl_data->menu_bar_items_used = f->menu_bar_items_used; | |
1565 cl_data->highlight_cb = highlight_cb; | |
1566 cl_data->ref_count = 0; | |
1567 | |
1568 xg_list_insert (&xg_menu_cb_list, &cl_data->ptrs); | |
1569 } | |
1570 | |
1571 cl_data->ref_count++; | |
1572 | |
1573 return cl_data; | |
1574 } | |
1575 | |
1576 /* Update CL_DATA with values from frame F and with HIGHLIGHT_CB. | |
1577 HIGHLIGHT_CB is the callback to call when entering/leaving menu items. | |
1578 | |
1579 When the menu bar is updated, menu items may have been added and/or | |
1580 removed, so menu_bar_vector and menu_bar_items_used change. We must | |
1581 then update CL_DATA since it is used to determine which menu | |
1582 item that is invoked in the menu. | |
1583 HIGHLIGHT_CB could change, there is no check that the same | |
1584 function is given when modifying a menu bar as was given when | |
1585 creating the menu bar. */ | |
57715
cdc48cdd5b0e
* gtkutil.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57597
diff
changeset
|
1586 |
49323 | 1587 static void |
1588 update_cl_data (cl_data, f, highlight_cb) | |
1589 xg_menu_cb_data *cl_data; | |
1590 FRAME_PTR f; | |
1591 GCallback highlight_cb; | |
1592 { | |
1593 if (cl_data) | |
1594 { | |
1595 cl_data->f = f; | |
1596 cl_data->menu_bar_vector = f->menu_bar_vector; | |
1597 cl_data->menu_bar_items_used = f->menu_bar_items_used; | |
1598 cl_data->highlight_cb = highlight_cb; | |
1599 } | |
1600 } | |
1601 | |
1602 /* Decrease reference count for CL_DATA. | |
1603 If reference count is zero, free CL_DATA. */ | |
57715
cdc48cdd5b0e
* gtkutil.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57597
diff
changeset
|
1604 |
49323 | 1605 static void |
1606 unref_cl_data (cl_data) | |
1607 xg_menu_cb_data *cl_data; | |
1608 { | |
1609 if (cl_data && cl_data->ref_count > 0) | |
1610 { | |
1611 cl_data->ref_count--; | |
1612 if (cl_data->ref_count == 0) | |
1613 { | |
1614 xg_list_remove (&xg_menu_cb_list, &cl_data->ptrs); | |
1615 xfree (cl_data); | |
1616 } | |
1617 } | |
1618 } | |
1619 | |
1620 /* Function that marks all lisp data during GC. */ | |
57715
cdc48cdd5b0e
* gtkutil.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57597
diff
changeset
|
1621 |
49323 | 1622 void |
1623 xg_mark_data () | |
1624 { | |
1625 xg_list_node *iter; | |
1626 | |
1627 for (iter = xg_menu_cb_list.next; iter; iter = iter->next) | |
52080
c150d4a7aa36
gtkutil.c (xg_mark_data): Update calls to mark_object.
Jan Djärv <jan.h.d@swipnet.se>
parents:
51569
diff
changeset
|
1628 mark_object (((xg_menu_cb_data *) iter)->menu_bar_vector); |
49323 | 1629 |
1630 for (iter = xg_menu_item_cb_list.next; iter; iter = iter->next) | |
1631 { | |
1632 xg_menu_item_cb_data *cb_data = (xg_menu_item_cb_data *) iter; | |
1633 | |
1634 if (! NILP (cb_data->help)) | |
52080
c150d4a7aa36
gtkutil.c (xg_mark_data): Update calls to mark_object.
Jan Djärv <jan.h.d@swipnet.se>
parents:
51569
diff
changeset
|
1635 mark_object (cb_data->help); |
49323 | 1636 } |
1637 } | |
1638 | |
1639 | |
1640 /* Callback called when a menu item is destroyed. Used to free data. | |
1641 W is the widget that is being destroyed (not used). | |
1642 CLIENT_DATA points to the xg_menu_item_cb_data associated with the W. */ | |
57715
cdc48cdd5b0e
* gtkutil.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57597
diff
changeset
|
1643 |
49323 | 1644 static void |
1645 menuitem_destroy_callback (w, client_data) | |
1646 GtkWidget *w; | |
1647 gpointer client_data; | |
1648 { | |
1649 if (client_data) | |
1650 { | |
1651 xg_menu_item_cb_data *data = (xg_menu_item_cb_data*) client_data; | |
1652 xg_list_remove (&xg_menu_item_cb_list, &data->ptrs); | |
1653 xfree (data); | |
1654 } | |
1655 } | |
1656 | |
1657 /* Callback called when the pointer enters/leaves a menu item. | |
1658 W is the menu item. | |
1659 EVENT is either an enter event or leave event. | |
1660 CLIENT_DATA points to the xg_menu_item_cb_data associated with the W. | |
1661 | |
1662 Returns FALSE to tell GTK to keep processing this event. */ | |
57715
cdc48cdd5b0e
* gtkutil.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57597
diff
changeset
|
1663 |
49323 | 1664 static gboolean |
1665 menuitem_highlight_callback (w, event, client_data) | |
1666 GtkWidget *w; | |
1667 GdkEventCrossing *event; | |
1668 gpointer client_data; | |
1669 { | |
1670 if (client_data) | |
1671 { | |
1672 xg_menu_item_cb_data *data = (xg_menu_item_cb_data*) client_data; | |
1673 gpointer call_data = event->type == GDK_LEAVE_NOTIFY ? 0 : client_data; | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
1674 |
49323 | 1675 if (! NILP (data->help) && data->cl_data->highlight_cb) |
1676 { | |
1677 GtkCallback func = (GtkCallback) data->cl_data->highlight_cb; | |
1678 (*func) (w, call_data); | |
1679 } | |
1680 } | |
1681 | |
1682 return FALSE; | |
1683 } | |
1684 | |
1685 /* Callback called when a menu is destroyed. Used to free data. | |
1686 W is the widget that is being destroyed (not used). | |
1687 CLIENT_DATA points to the xg_menu_cb_data associated with W. */ | |
57715
cdc48cdd5b0e
* gtkutil.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57597
diff
changeset
|
1688 |
49323 | 1689 static void |
1690 menu_destroy_callback (w, client_data) | |
1691 GtkWidget *w; | |
1692 gpointer client_data; | |
1693 { | |
1694 unref_cl_data ((xg_menu_cb_data*) client_data); | |
1695 } | |
1696 | |
1697 /* Callback called when a menu does a grab or ungrab. That means the | |
1698 menu has been activated or deactivated. | |
1699 Used to start a timer so the small timeout the menus in GTK uses before | |
1700 popping down a menu is seen by Emacs (see xg_process_timeouts above). | |
1701 W is the widget that does the grab (not used). | |
1702 UNGRAB_P is TRUE if this is an ungrab, FALSE if it is a grab. | |
1703 CLIENT_DATA is NULL (not used). */ | |
57715
cdc48cdd5b0e
* gtkutil.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57597
diff
changeset
|
1704 |
49323 | 1705 static void |
1706 menu_grab_callback (GtkWidget *widget, | |
1707 gboolean ungrab_p, | |
1708 gpointer client_data) | |
1709 { | |
1710 /* Keep track of total number of grabs. */ | |
1711 static int cnt; | |
1712 | |
1713 if (ungrab_p) cnt--; | |
1714 else cnt++; | |
1715 | |
1716 if (cnt > 0 && ! xg_timer) xg_start_timer (); | |
1717 else if (cnt == 0 && xg_timer) xg_stop_timer (); | |
1718 } | |
1719 | |
1720 /* Make a GTK widget that contains both UTF8_LABEL and UTF8_KEY (both | |
1721 must be non-NULL) and can be inserted into a menu item. | |
1722 | |
1723 Returns the GtkHBox. */ | |
57715
cdc48cdd5b0e
* gtkutil.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57597
diff
changeset
|
1724 |
49323 | 1725 static GtkWidget * |
1726 make_widget_for_menu_item (utf8_label, utf8_key) | |
1727 char *utf8_label; | |
1728 char *utf8_key; | |
1729 { | |
1730 GtkWidget *wlbl; | |
1731 GtkWidget *wkey; | |
1732 GtkWidget *wbox; | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
1733 |
49323 | 1734 wbox = gtk_hbox_new (FALSE, 0); |
50778
f30e6f029d65
* gtkutil.c (create_dialog, make_widget_for_menu_item)
Jan Djärv <jan.h.d@swipnet.se>
parents:
50521
diff
changeset
|
1735 wlbl = gtk_label_new (utf8_label); |
49323 | 1736 wkey = gtk_label_new (utf8_key); |
1737 | |
1738 gtk_misc_set_alignment (GTK_MISC (wlbl), 0.0, 0.5); | |
1739 gtk_misc_set_alignment (GTK_MISC (wkey), 0.0, 0.5); | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
1740 |
49323 | 1741 gtk_box_pack_start (GTK_BOX (wbox), wlbl, TRUE, TRUE, 0); |
1742 gtk_box_pack_start (GTK_BOX (wbox), wkey, FALSE, FALSE, 0); | |
1743 | |
1744 gtk_widget_set_name (wlbl, MENU_ITEM_NAME); | |
1745 gtk_widget_set_name (wkey, MENU_ITEM_NAME); | |
50270
fa50953c02dc
Finally (?) fix flicker in scroll bar.
Jan Djärv <jan.h.d@swipnet.se>
parents:
50192
diff
changeset
|
1746 gtk_widget_set_name (wbox, MENU_ITEM_NAME); |
49323 | 1747 |
1748 return wbox; | |
1749 } | |
1750 | |
1751 /* Make and return a menu item widget with the key to the right. | |
1752 UTF8_LABEL is the text for the menu item (GTK uses UTF8 internally). | |
1753 UTF8_KEY is the text representing the key binding. | |
1754 ITEM is the widget_value describing the menu item. | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
1755 |
49323 | 1756 GROUP is an in/out parameter. If the menu item to be created is not |
1757 part of any radio menu group, *GROUP contains NULL on entry and exit. | |
1758 If the menu item to be created is part of a radio menu group, on entry | |
1759 *GROUP contains the group to use, or NULL if this is the first item | |
1760 in the group. On exit, *GROUP contains the radio item group. | |
1761 | |
1762 Unfortunately, keys don't line up as nicely as in Motif, | |
1763 but the MacOS X version doesn't either, so I guess that is OK. */ | |
57715
cdc48cdd5b0e
* gtkutil.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57597
diff
changeset
|
1764 |
49323 | 1765 static GtkWidget * |
1766 make_menu_item (utf8_label, utf8_key, item, group) | |
1767 char *utf8_label; | |
1768 char *utf8_key; | |
1769 widget_value *item; | |
1770 GSList **group; | |
1771 { | |
1772 GtkWidget *w; | |
1773 GtkWidget *wtoadd = 0; | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
1774 |
51432
6db55492aca9
* gtkutil.c (make_menu_item): Make sure we don't crash on a NULL
Jan Djärv <jan.h.d@swipnet.se>
parents:
51408
diff
changeset
|
1775 /* It has been observed that some menu items have a NULL name field. |
6db55492aca9
* gtkutil.c (make_menu_item): Make sure we don't crash on a NULL
Jan Djärv <jan.h.d@swipnet.se>
parents:
51408
diff
changeset
|
1776 This will lead to this function being called with a NULL utf8_label. |
6db55492aca9
* gtkutil.c (make_menu_item): Make sure we don't crash on a NULL
Jan Djärv <jan.h.d@swipnet.se>
parents:
51408
diff
changeset
|
1777 GTK crashes on that so we set a blank label. Why there is a NULL |
6db55492aca9
* gtkutil.c (make_menu_item): Make sure we don't crash on a NULL
Jan Djärv <jan.h.d@swipnet.se>
parents:
51408
diff
changeset
|
1778 name remains to be investigated. */ |
6db55492aca9
* gtkutil.c (make_menu_item): Make sure we don't crash on a NULL
Jan Djärv <jan.h.d@swipnet.se>
parents:
51408
diff
changeset
|
1779 if (! utf8_label) utf8_label = " "; |
6db55492aca9
* gtkutil.c (make_menu_item): Make sure we don't crash on a NULL
Jan Djärv <jan.h.d@swipnet.se>
parents:
51408
diff
changeset
|
1780 |
49323 | 1781 if (utf8_key) |
1782 wtoadd = make_widget_for_menu_item (utf8_label, utf8_key); | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
1783 |
49323 | 1784 if (item->button_type == BUTTON_TYPE_TOGGLE) |
1785 { | |
1786 *group = NULL; | |
1787 if (utf8_key) w = gtk_check_menu_item_new (); | |
50778
f30e6f029d65
* gtkutil.c (create_dialog, make_widget_for_menu_item)
Jan Djärv <jan.h.d@swipnet.se>
parents:
50521
diff
changeset
|
1788 else w = gtk_check_menu_item_new_with_label (utf8_label); |
49323 | 1789 gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (w), item->selected); |
1790 } | |
1791 else if (item->button_type == BUTTON_TYPE_RADIO) | |
1792 { | |
1793 if (utf8_key) w = gtk_radio_menu_item_new (*group); | |
50778
f30e6f029d65
* gtkutil.c (create_dialog, make_widget_for_menu_item)
Jan Djärv <jan.h.d@swipnet.se>
parents:
50521
diff
changeset
|
1794 else w = gtk_radio_menu_item_new_with_label (*group, utf8_label); |
49323 | 1795 *group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (w)); |
1796 if (item->selected) | |
1797 gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (w), TRUE); | |
1798 } | |
1799 else | |
1800 { | |
1801 *group = NULL; | |
1802 if (utf8_key) w = gtk_menu_item_new (); | |
50778
f30e6f029d65
* gtkutil.c (create_dialog, make_widget_for_menu_item)
Jan Djärv <jan.h.d@swipnet.se>
parents:
50521
diff
changeset
|
1803 else w = gtk_menu_item_new_with_label (utf8_label); |
49323 | 1804 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
1805 |
49323 | 1806 if (wtoadd) gtk_container_add (GTK_CONTAINER (w), wtoadd); |
1807 if (! item->enabled) gtk_widget_set_sensitive (w, FALSE); | |
1808 | |
1809 return w; | |
1810 } | |
1811 | |
50318
5b50d76d9211
* gtkutil.c (xg_resize_widgets): Don't call xg_frame_cleared.
Jan Djärv <jan.h.d@swipnet.se>
parents:
50272
diff
changeset
|
1812 /* Return non-zero if LABEL specifies a separator (GTK only has one |
49323 | 1813 separator type) */ |
57715
cdc48cdd5b0e
* gtkutil.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57597
diff
changeset
|
1814 |
49323 | 1815 static int |
50318
5b50d76d9211
* gtkutil.c (xg_resize_widgets): Don't call xg_frame_cleared.
Jan Djärv <jan.h.d@swipnet.se>
parents:
50272
diff
changeset
|
1816 xg_separator_p (char *label) |
49323 | 1817 { |
50318
5b50d76d9211
* gtkutil.c (xg_resize_widgets): Don't call xg_frame_cleared.
Jan Djärv <jan.h.d@swipnet.se>
parents:
50272
diff
changeset
|
1818 if (! label) return 0; |
5b50d76d9211
* gtkutil.c (xg_resize_widgets): Don't call xg_frame_cleared.
Jan Djärv <jan.h.d@swipnet.se>
parents:
50272
diff
changeset
|
1819 else if (strlen (label) > 3 |
5b50d76d9211
* gtkutil.c (xg_resize_widgets): Don't call xg_frame_cleared.
Jan Djärv <jan.h.d@swipnet.se>
parents:
50272
diff
changeset
|
1820 && strncmp (label, "--", 2) == 0 |
5b50d76d9211
* gtkutil.c (xg_resize_widgets): Don't call xg_frame_cleared.
Jan Djärv <jan.h.d@swipnet.se>
parents:
50272
diff
changeset
|
1821 && label[2] != '-') |
5b50d76d9211
* gtkutil.c (xg_resize_widgets): Don't call xg_frame_cleared.
Jan Djärv <jan.h.d@swipnet.se>
parents:
50272
diff
changeset
|
1822 { |
5b50d76d9211
* gtkutil.c (xg_resize_widgets): Don't call xg_frame_cleared.
Jan Djärv <jan.h.d@swipnet.se>
parents:
50272
diff
changeset
|
1823 static char* separator_names[] = { |
5b50d76d9211
* gtkutil.c (xg_resize_widgets): Don't call xg_frame_cleared.
Jan Djärv <jan.h.d@swipnet.se>
parents:
50272
diff
changeset
|
1824 "space", |
5b50d76d9211
* gtkutil.c (xg_resize_widgets): Don't call xg_frame_cleared.
Jan Djärv <jan.h.d@swipnet.se>
parents:
50272
diff
changeset
|
1825 "no-line", |
5b50d76d9211
* gtkutil.c (xg_resize_widgets): Don't call xg_frame_cleared.
Jan Djärv <jan.h.d@swipnet.se>
parents:
50272
diff
changeset
|
1826 "single-line", |
5b50d76d9211
* gtkutil.c (xg_resize_widgets): Don't call xg_frame_cleared.
Jan Djärv <jan.h.d@swipnet.se>
parents:
50272
diff
changeset
|
1827 "double-line", |
5b50d76d9211
* gtkutil.c (xg_resize_widgets): Don't call xg_frame_cleared.
Jan Djärv <jan.h.d@swipnet.se>
parents:
50272
diff
changeset
|
1828 "single-dashed-line", |
5b50d76d9211
* gtkutil.c (xg_resize_widgets): Don't call xg_frame_cleared.
Jan Djärv <jan.h.d@swipnet.se>
parents:
50272
diff
changeset
|
1829 "double-dashed-line", |
5b50d76d9211
* gtkutil.c (xg_resize_widgets): Don't call xg_frame_cleared.
Jan Djärv <jan.h.d@swipnet.se>
parents:
50272
diff
changeset
|
1830 "shadow-etched-in", |
5b50d76d9211
* gtkutil.c (xg_resize_widgets): Don't call xg_frame_cleared.
Jan Djärv <jan.h.d@swipnet.se>
parents:
50272
diff
changeset
|
1831 "shadow-etched-out", |
5b50d76d9211
* gtkutil.c (xg_resize_widgets): Don't call xg_frame_cleared.
Jan Djärv <jan.h.d@swipnet.se>
parents:
50272
diff
changeset
|
1832 "shadow-etched-in-dash", |
5b50d76d9211
* gtkutil.c (xg_resize_widgets): Don't call xg_frame_cleared.
Jan Djärv <jan.h.d@swipnet.se>
parents:
50272
diff
changeset
|
1833 "shadow-etched-out-dash", |
5b50d76d9211
* gtkutil.c (xg_resize_widgets): Don't call xg_frame_cleared.
Jan Djärv <jan.h.d@swipnet.se>
parents:
50272
diff
changeset
|
1834 "shadow-double-etched-in", |
5b50d76d9211
* gtkutil.c (xg_resize_widgets): Don't call xg_frame_cleared.
Jan Djärv <jan.h.d@swipnet.se>
parents:
50272
diff
changeset
|
1835 "shadow-double-etched-out", |
5b50d76d9211
* gtkutil.c (xg_resize_widgets): Don't call xg_frame_cleared.
Jan Djärv <jan.h.d@swipnet.se>
parents:
50272
diff
changeset
|
1836 "shadow-double-etched-in-dash", |
5b50d76d9211
* gtkutil.c (xg_resize_widgets): Don't call xg_frame_cleared.
Jan Djärv <jan.h.d@swipnet.se>
parents:
50272
diff
changeset
|
1837 "shadow-double-etched-out-dash", |
5b50d76d9211
* gtkutil.c (xg_resize_widgets): Don't call xg_frame_cleared.
Jan Djärv <jan.h.d@swipnet.se>
parents:
50272
diff
changeset
|
1838 0, |
5b50d76d9211
* gtkutil.c (xg_resize_widgets): Don't call xg_frame_cleared.
Jan Djärv <jan.h.d@swipnet.se>
parents:
50272
diff
changeset
|
1839 }; |
5b50d76d9211
* gtkutil.c (xg_resize_widgets): Don't call xg_frame_cleared.
Jan Djärv <jan.h.d@swipnet.se>
parents:
50272
diff
changeset
|
1840 |
5b50d76d9211
* gtkutil.c (xg_resize_widgets): Don't call xg_frame_cleared.
Jan Djärv <jan.h.d@swipnet.se>
parents:
50272
diff
changeset
|
1841 int i; |
5b50d76d9211
* gtkutil.c (xg_resize_widgets): Don't call xg_frame_cleared.
Jan Djärv <jan.h.d@swipnet.se>
parents:
50272
diff
changeset
|
1842 |
5b50d76d9211
* gtkutil.c (xg_resize_widgets): Don't call xg_frame_cleared.
Jan Djärv <jan.h.d@swipnet.se>
parents:
50272
diff
changeset
|
1843 label += 2; |
5b50d76d9211
* gtkutil.c (xg_resize_widgets): Don't call xg_frame_cleared.
Jan Djärv <jan.h.d@swipnet.se>
parents:
50272
diff
changeset
|
1844 for (i = 0; separator_names[i]; ++i) |
5b50d76d9211
* gtkutil.c (xg_resize_widgets): Don't call xg_frame_cleared.
Jan Djärv <jan.h.d@swipnet.se>
parents:
50272
diff
changeset
|
1845 if (strcmp (label, separator_names[i]) == 0) |
5b50d76d9211
* gtkutil.c (xg_resize_widgets): Don't call xg_frame_cleared.
Jan Djärv <jan.h.d@swipnet.se>
parents:
50272
diff
changeset
|
1846 return 1; |
5b50d76d9211
* gtkutil.c (xg_resize_widgets): Don't call xg_frame_cleared.
Jan Djärv <jan.h.d@swipnet.se>
parents:
50272
diff
changeset
|
1847 } |
5b50d76d9211
* gtkutil.c (xg_resize_widgets): Don't call xg_frame_cleared.
Jan Djärv <jan.h.d@swipnet.se>
parents:
50272
diff
changeset
|
1848 else |
5b50d76d9211
* gtkutil.c (xg_resize_widgets): Don't call xg_frame_cleared.
Jan Djärv <jan.h.d@swipnet.se>
parents:
50272
diff
changeset
|
1849 { |
5b50d76d9211
* gtkutil.c (xg_resize_widgets): Don't call xg_frame_cleared.
Jan Djärv <jan.h.d@swipnet.se>
parents:
50272
diff
changeset
|
1850 /* Old-style separator, maybe. It's a separator if it contains |
5b50d76d9211
* gtkutil.c (xg_resize_widgets): Don't call xg_frame_cleared.
Jan Djärv <jan.h.d@swipnet.se>
parents:
50272
diff
changeset
|
1851 only dashes. */ |
5b50d76d9211
* gtkutil.c (xg_resize_widgets): Don't call xg_frame_cleared.
Jan Djärv <jan.h.d@swipnet.se>
parents:
50272
diff
changeset
|
1852 while (*label == '-') |
5b50d76d9211
* gtkutil.c (xg_resize_widgets): Don't call xg_frame_cleared.
Jan Djärv <jan.h.d@swipnet.se>
parents:
50272
diff
changeset
|
1853 ++label; |
5b50d76d9211
* gtkutil.c (xg_resize_widgets): Don't call xg_frame_cleared.
Jan Djärv <jan.h.d@swipnet.se>
parents:
50272
diff
changeset
|
1854 if (*label == 0) return 1; |
5b50d76d9211
* gtkutil.c (xg_resize_widgets): Don't call xg_frame_cleared.
Jan Djärv <jan.h.d@swipnet.se>
parents:
50272
diff
changeset
|
1855 } |
5b50d76d9211
* gtkutil.c (xg_resize_widgets): Don't call xg_frame_cleared.
Jan Djärv <jan.h.d@swipnet.se>
parents:
50272
diff
changeset
|
1856 |
5b50d76d9211
* gtkutil.c (xg_resize_widgets): Don't call xg_frame_cleared.
Jan Djärv <jan.h.d@swipnet.se>
parents:
50272
diff
changeset
|
1857 return 0; |
49323 | 1858 } |
1859 | |
52981
54482f5ea7be
Remove tear off capability for GTK popup menus.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
1860 static int xg_detached_menus; |
54482f5ea7be
Remove tear off capability for GTK popup menus.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
1861 |
54482f5ea7be
Remove tear off capability for GTK popup menus.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
1862 /* Returns non-zero if there are detached menus. */ |
57715
cdc48cdd5b0e
* gtkutil.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57597
diff
changeset
|
1863 |
52981
54482f5ea7be
Remove tear off capability for GTK popup menus.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
1864 int |
54482f5ea7be
Remove tear off capability for GTK popup menus.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
1865 xg_have_tear_offs () |
54482f5ea7be
Remove tear off capability for GTK popup menus.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
1866 { |
54482f5ea7be
Remove tear off capability for GTK popup menus.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
1867 return xg_detached_menus > 0; |
54482f5ea7be
Remove tear off capability for GTK popup menus.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
1868 } |
49323 | 1869 |
1870 /* Callback invoked when a detached menu window is removed. Here we | |
52981
54482f5ea7be
Remove tear off capability for GTK popup menus.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
1871 decrease the xg_detached_menus count. |
49323 | 1872 WIDGET is the top level window that is removed (the parent of the menu). |
52981
54482f5ea7be
Remove tear off capability for GTK popup menus.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
1873 CLIENT_DATA is not used. */ |
57715
cdc48cdd5b0e
* gtkutil.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57597
diff
changeset
|
1874 |
52981
54482f5ea7be
Remove tear off capability for GTK popup menus.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
1875 static void |
54482f5ea7be
Remove tear off capability for GTK popup menus.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
1876 tearoff_remove (widget, client_data) |
49323 | 1877 GtkWidget *widget; |
1878 gpointer client_data; | |
1879 { | |
52981
54482f5ea7be
Remove tear off capability for GTK popup menus.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
1880 if (xg_detached_menus > 0) --xg_detached_menus; |
49323 | 1881 } |
1882 | |
52981
54482f5ea7be
Remove tear off capability for GTK popup menus.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
1883 /* Callback invoked when a menu is detached. It increases the |
54482f5ea7be
Remove tear off capability for GTK popup menus.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
1884 xg_detached_menus count. |
49323 | 1885 WIDGET is the GtkTearoffMenuItem. |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
1886 CLIENT_DATA is not used. */ |
57715
cdc48cdd5b0e
* gtkutil.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57597
diff
changeset
|
1887 |
49323 | 1888 static void |
1889 tearoff_activate (widget, client_data) | |
1890 GtkWidget *widget; | |
1891 gpointer client_data; | |
1892 { | |
1893 GtkWidget *menu = gtk_widget_get_parent (widget); | |
52981
54482f5ea7be
Remove tear off capability for GTK popup menus.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
1894 if (gtk_menu_get_tearoff_state (GTK_MENU (menu))) |
54482f5ea7be
Remove tear off capability for GTK popup menus.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
1895 { |
54482f5ea7be
Remove tear off capability for GTK popup menus.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
1896 ++xg_detached_menus; |
54482f5ea7be
Remove tear off capability for GTK popup menus.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
1897 g_signal_connect (G_OBJECT (gtk_widget_get_toplevel (widget)), |
54482f5ea7be
Remove tear off capability for GTK popup menus.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
1898 "destroy", |
54482f5ea7be
Remove tear off capability for GTK popup menus.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
1899 G_CALLBACK (tearoff_remove), 0); |
54482f5ea7be
Remove tear off capability for GTK popup menus.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
1900 } |
49323 | 1901 } |
1902 | |
1903 | |
1904 /* Create a menu item widget, and connect the callbacks. | |
1905 ITEM decribes the menu item. | |
1906 F is the frame the created menu belongs to. | |
1907 SELECT_CB is the callback to use when a menu item is selected. | |
1908 HIGHLIGHT_CB is the callback to call when entering/leaving menu items. | |
1909 CL_DATA points to the callback data to be used for this menu. | |
1910 GROUP is an in/out parameter. If the menu item to be created is not | |
1911 part of any radio menu group, *GROUP contains NULL on entry and exit. | |
1912 If the menu item to be created is part of a radio menu group, on entry | |
1913 *GROUP contains the group to use, or NULL if this is the first item | |
1914 in the group. On exit, *GROUP contains the radio item group. | |
1915 | |
1916 Returns the created GtkWidget. */ | |
57715
cdc48cdd5b0e
* gtkutil.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57597
diff
changeset
|
1917 |
49323 | 1918 static GtkWidget * |
1919 xg_create_one_menuitem (item, f, select_cb, highlight_cb, cl_data, group) | |
1920 widget_value *item; | |
1921 FRAME_PTR f; | |
1922 GCallback select_cb; | |
1923 GCallback highlight_cb; | |
1924 xg_menu_cb_data *cl_data; | |
1925 GSList **group; | |
1926 { | |
1927 char *utf8_label; | |
1928 char *utf8_key; | |
1929 GtkWidget *w; | |
1930 xg_menu_item_cb_data *cb_data; | |
1931 | |
1932 utf8_label = get_utf8_string (item->name); | |
1933 utf8_key = get_utf8_string (item->key); | |
1934 | |
1935 w = make_menu_item (utf8_label, utf8_key, item, group); | |
1936 | |
1937 if (utf8_label && utf8_label != item->name) g_free (utf8_label); | |
1938 if (utf8_key && utf8_key != item->key) g_free (utf8_key); | |
1939 | |
1940 cb_data = xmalloc (sizeof (xg_menu_item_cb_data)); | |
1941 | |
1942 xg_list_insert (&xg_menu_item_cb_list, &cb_data->ptrs); | |
1943 | |
1944 cb_data->unhighlight_id = cb_data->highlight_id = cb_data->select_id = 0; | |
1945 cb_data->help = item->help; | |
1946 cb_data->cl_data = cl_data; | |
1947 cb_data->call_data = item->call_data; | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
1948 |
49323 | 1949 g_signal_connect (G_OBJECT (w), |
1950 "destroy", | |
1951 G_CALLBACK (menuitem_destroy_callback), | |
1952 cb_data); | |
1953 | |
1954 /* Put cb_data in widget, so we can get at it when modifying menubar */ | |
1955 g_object_set_data (G_OBJECT (w), XG_ITEM_DATA, cb_data); | |
1956 | |
1957 /* final item, not a submenu */ | |
1958 if (item->call_data && ! item->contents) | |
1959 { | |
1960 if (select_cb) | |
1961 cb_data->select_id | |
1962 = g_signal_connect (G_OBJECT (w), "activate", select_cb, cb_data); | |
1963 } | |
1964 | |
1965 if (! NILP (item->help) && highlight_cb) | |
1966 { | |
1967 /* We use enter/leave notify instead of select/deselect because | |
1968 select/deselect doesn't go well with detached menus. */ | |
1969 cb_data->highlight_id | |
1970 = g_signal_connect (G_OBJECT (w), | |
1971 "enter-notify-event", | |
1972 G_CALLBACK (menuitem_highlight_callback), | |
1973 cb_data); | |
1974 cb_data->unhighlight_id | |
1975 = g_signal_connect (G_OBJECT (w), | |
1976 "leave-notify-event", | |
1977 G_CALLBACK (menuitem_highlight_callback), | |
1978 cb_data); | |
1979 } | |
1980 | |
1981 return w; | |
1982 } | |
1983 | |
71132
162d493b1e5c
* gtkutil.c (menu_nav_ended): Change x-menu-bar-start to menu-bar-open.
Jan Djärv <jan.h.d@swipnet.se>
parents:
71056
diff
changeset
|
1984 /* Callback called when keyboard traversal (started by menu-bar-open) ends. |
71056
3e5c40f72a04
Connect menu_nav_ended to "selection-done" to fix grabs
Jan Djärv <jan.h.d@swipnet.se>
parents:
69141
diff
changeset
|
1985 WMENU is the menu for which traversal has been done. DATA points to the |
3e5c40f72a04
Connect menu_nav_ended to "selection-done" to fix grabs
Jan Djärv <jan.h.d@swipnet.se>
parents:
69141
diff
changeset
|
1986 frame for WMENU. We must release grabs, some bad interaction between GTK |
3e5c40f72a04
Connect menu_nav_ended to "selection-done" to fix grabs
Jan Djärv <jan.h.d@swipnet.se>
parents:
69141
diff
changeset
|
1987 and Emacs makes the menus keep the grabs. */ |
3e5c40f72a04
Connect menu_nav_ended to "selection-done" to fix grabs
Jan Djärv <jan.h.d@swipnet.se>
parents:
69141
diff
changeset
|
1988 |
3e5c40f72a04
Connect menu_nav_ended to "selection-done" to fix grabs
Jan Djärv <jan.h.d@swipnet.se>
parents:
69141
diff
changeset
|
1989 static void |
3e5c40f72a04
Connect menu_nav_ended to "selection-done" to fix grabs
Jan Djärv <jan.h.d@swipnet.se>
parents:
69141
diff
changeset
|
1990 menu_nav_ended (wmenu, data) |
3e5c40f72a04
Connect menu_nav_ended to "selection-done" to fix grabs
Jan Djärv <jan.h.d@swipnet.se>
parents:
69141
diff
changeset
|
1991 GtkMenuShell *wmenu; |
3e5c40f72a04
Connect menu_nav_ended to "selection-done" to fix grabs
Jan Djärv <jan.h.d@swipnet.se>
parents:
69141
diff
changeset
|
1992 gpointer data; |
3e5c40f72a04
Connect menu_nav_ended to "selection-done" to fix grabs
Jan Djärv <jan.h.d@swipnet.se>
parents:
69141
diff
changeset
|
1993 { |
3e5c40f72a04
Connect menu_nav_ended to "selection-done" to fix grabs
Jan Djärv <jan.h.d@swipnet.se>
parents:
69141
diff
changeset
|
1994 FRAME_PTR f = (FRAME_PTR) data; |
71160
070b40db0b2a
* gtkutil.c (menu_nav_ended): Check that menubar_widget is not NULL.
Jan Djärv <jan.h.d@swipnet.se>
parents:
71132
diff
changeset
|
1995 |
070b40db0b2a
* gtkutil.c (menu_nav_ended): Check that menubar_widget is not NULL.
Jan Djärv <jan.h.d@swipnet.se>
parents:
71132
diff
changeset
|
1996 if (FRAME_X_OUTPUT (f)->menubar_widget) |
070b40db0b2a
* gtkutil.c (menu_nav_ended): Check that menubar_widget is not NULL.
Jan Djärv <jan.h.d@swipnet.se>
parents:
71132
diff
changeset
|
1997 { |
71056
3e5c40f72a04
Connect menu_nav_ended to "selection-done" to fix grabs
Jan Djärv <jan.h.d@swipnet.se>
parents:
69141
diff
changeset
|
1998 GtkMenuShell *w = GTK_MENU_SHELL (FRAME_X_OUTPUT (f)->menubar_widget); |
71160
070b40db0b2a
* gtkutil.c (menu_nav_ended): Check that menubar_widget is not NULL.
Jan Djärv <jan.h.d@swipnet.se>
parents:
71132
diff
changeset
|
1999 Display *dpy = FRAME_X_DISPLAY (f); |
070b40db0b2a
* gtkutil.c (menu_nav_ended): Check that menubar_widget is not NULL.
Jan Djärv <jan.h.d@swipnet.se>
parents:
71132
diff
changeset
|
2000 |
070b40db0b2a
* gtkutil.c (menu_nav_ended): Check that menubar_widget is not NULL.
Jan Djärv <jan.h.d@swipnet.se>
parents:
71132
diff
changeset
|
2001 BLOCK_INPUT; |
71056
3e5c40f72a04
Connect menu_nav_ended to "selection-done" to fix grabs
Jan Djärv <jan.h.d@swipnet.se>
parents:
69141
diff
changeset
|
2002 gtk_menu_shell_deactivate (w); |
3e5c40f72a04
Connect menu_nav_ended to "selection-done" to fix grabs
Jan Djärv <jan.h.d@swipnet.se>
parents:
69141
diff
changeset
|
2003 gtk_menu_shell_deselect (w); |
3e5c40f72a04
Connect menu_nav_ended to "selection-done" to fix grabs
Jan Djärv <jan.h.d@swipnet.se>
parents:
69141
diff
changeset
|
2004 |
71160
070b40db0b2a
* gtkutil.c (menu_nav_ended): Check that menubar_widget is not NULL.
Jan Djärv <jan.h.d@swipnet.se>
parents:
71132
diff
changeset
|
2005 XUngrabKeyboard (dpy, CurrentTime); |
070b40db0b2a
* gtkutil.c (menu_nav_ended): Check that menubar_widget is not NULL.
Jan Djärv <jan.h.d@swipnet.se>
parents:
71132
diff
changeset
|
2006 XUngrabPointer (dpy, CurrentTime); |
070b40db0b2a
* gtkutil.c (menu_nav_ended): Check that menubar_widget is not NULL.
Jan Djärv <jan.h.d@swipnet.se>
parents:
71132
diff
changeset
|
2007 UNBLOCK_INPUT; |
070b40db0b2a
* gtkutil.c (menu_nav_ended): Check that menubar_widget is not NULL.
Jan Djärv <jan.h.d@swipnet.se>
parents:
71132
diff
changeset
|
2008 } |
71056
3e5c40f72a04
Connect menu_nav_ended to "selection-done" to fix grabs
Jan Djärv <jan.h.d@swipnet.se>
parents:
69141
diff
changeset
|
2009 } |
3e5c40f72a04
Connect menu_nav_ended to "selection-done" to fix grabs
Jan Djärv <jan.h.d@swipnet.se>
parents:
69141
diff
changeset
|
2010 |
3e5c40f72a04
Connect menu_nav_ended to "selection-done" to fix grabs
Jan Djärv <jan.h.d@swipnet.se>
parents:
69141
diff
changeset
|
2011 |
50112
50df9e41f1a3
Add prototype for create_menus.
Andreas Schwab <schwab@suse.de>
parents:
50108
diff
changeset
|
2012 static GtkWidget *create_menus P_ ((widget_value *, FRAME_PTR, GCallback, |
50df9e41f1a3
Add prototype for create_menus.
Andreas Schwab <schwab@suse.de>
parents:
50108
diff
changeset
|
2013 GCallback, GCallback, int, int, int, |
50df9e41f1a3
Add prototype for create_menus.
Andreas Schwab <schwab@suse.de>
parents:
50108
diff
changeset
|
2014 GtkWidget *, xg_menu_cb_data *, char *)); |
50df9e41f1a3
Add prototype for create_menus.
Andreas Schwab <schwab@suse.de>
parents:
50108
diff
changeset
|
2015 |
49323 | 2016 /* Create a full menu tree specified by DATA. |
2017 F is the frame the created menu belongs to. | |
2018 SELECT_CB is the callback to use when a menu item is selected. | |
2019 DEACTIVATE_CB is the callback to use when a sub menu is not shown anymore. | |
2020 HIGHLIGHT_CB is the callback to call when entering/leaving menu items. | |
2021 POP_UP_P is non-zero if we shall create a popup menu. | |
2022 MENU_BAR_P is non-zero if we shall create a menu bar. | |
2023 ADD_TEAROFF_P is non-zero if we shall add a teroff menu item. Ignored | |
2024 if MENU_BAR_P is non-zero. | |
2025 TOPMENU is the topmost GtkWidget that others shall be placed under. | |
2026 It may be NULL, in that case we create the appropriate widget | |
2027 (menu bar or menu item depending on POP_UP_P and MENU_BAR_P) | |
2028 CL_DATA is the callback data we shall use for this menu, or NULL | |
2029 if we haven't set the first callback yet. | |
2030 NAME is the name to give to the top level menu if this function | |
2031 creates it. May be NULL to not set any name. | |
2032 | |
2033 Returns the top level GtkWidget. This is TOPLEVEL if TOPLEVEL is | |
2034 not NULL. | |
2035 | |
2036 This function calls itself to create submenus. */ | |
2037 | |
2038 static GtkWidget * | |
2039 create_menus (data, f, select_cb, deactivate_cb, highlight_cb, | |
2040 pop_up_p, menu_bar_p, add_tearoff_p, topmenu, cl_data, name) | |
2041 widget_value *data; | |
2042 FRAME_PTR f; | |
2043 GCallback select_cb; | |
2044 GCallback deactivate_cb; | |
2045 GCallback highlight_cb; | |
2046 int pop_up_p; | |
2047 int menu_bar_p; | |
2048 int add_tearoff_p; | |
2049 GtkWidget *topmenu; | |
2050 xg_menu_cb_data *cl_data; | |
2051 char *name; | |
2052 { | |
2053 widget_value *item; | |
2054 GtkWidget *wmenu = topmenu; | |
2055 GSList *group = NULL; | |
2056 | |
2057 if (! topmenu) | |
2058 { | |
53069
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
2059 if (! menu_bar_p) |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
2060 { |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
2061 wmenu = gtk_menu_new (); |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
2062 xg_set_screen (wmenu, f); |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
2063 } |
49323 | 2064 else wmenu = gtk_menu_bar_new (); |
2065 | |
71056
3e5c40f72a04
Connect menu_nav_ended to "selection-done" to fix grabs
Jan Djärv <jan.h.d@swipnet.se>
parents:
69141
diff
changeset
|
2066 /* Fix up grabs after keyboard traversal ends. */ |
3e5c40f72a04
Connect menu_nav_ended to "selection-done" to fix grabs
Jan Djärv <jan.h.d@swipnet.se>
parents:
69141
diff
changeset
|
2067 g_signal_connect (G_OBJECT (wmenu), |
3e5c40f72a04
Connect menu_nav_ended to "selection-done" to fix grabs
Jan Djärv <jan.h.d@swipnet.se>
parents:
69141
diff
changeset
|
2068 "selection-done", |
3e5c40f72a04
Connect menu_nav_ended to "selection-done" to fix grabs
Jan Djärv <jan.h.d@swipnet.se>
parents:
69141
diff
changeset
|
2069 G_CALLBACK (menu_nav_ended), |
3e5c40f72a04
Connect menu_nav_ended to "selection-done" to fix grabs
Jan Djärv <jan.h.d@swipnet.se>
parents:
69141
diff
changeset
|
2070 f); |
3e5c40f72a04
Connect menu_nav_ended to "selection-done" to fix grabs
Jan Djärv <jan.h.d@swipnet.se>
parents:
69141
diff
changeset
|
2071 |
49323 | 2072 /* Put cl_data on the top menu for easier access. */ |
2073 cl_data = make_cl_data (cl_data, f, highlight_cb); | |
2074 g_object_set_data (G_OBJECT (wmenu), XG_FRAME_DATA, (gpointer)cl_data); | |
2075 g_signal_connect (G_OBJECT (wmenu), "destroy", | |
2076 G_CALLBACK (menu_destroy_callback), cl_data); | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
2077 |
49323 | 2078 if (name) |
2079 gtk_widget_set_name (wmenu, name); | |
2080 | |
2081 if (deactivate_cb) | |
2082 g_signal_connect (G_OBJECT (wmenu), | |
59913
b3664fca53d1
* gtkutil.c (create_menus): Connect selection-done event instead of
Jan Djärv <jan.h.d@swipnet.se>
parents:
59666
diff
changeset
|
2083 "selection-done", deactivate_cb, 0); |
49323 | 2084 |
2085 g_signal_connect (G_OBJECT (wmenu), | |
2086 "grab-notify", G_CALLBACK (menu_grab_callback), 0); | |
2087 } | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
2088 |
49323 | 2089 if (! menu_bar_p && add_tearoff_p) |
2090 { | |
2091 GtkWidget *tearoff = gtk_tearoff_menu_item_new (); | |
2092 gtk_menu_shell_append (GTK_MENU_SHELL (wmenu), tearoff); | |
2093 | |
2094 g_signal_connect (G_OBJECT (tearoff), "activate", | |
2095 G_CALLBACK (tearoff_activate), 0); | |
2096 } | |
2097 | |
2098 for (item = data; item; item = item->next) | |
2099 { | |
2100 GtkWidget *w; | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
2101 |
49323 | 2102 if (pop_up_p && !item->contents && !item->call_data |
2103 && !xg_separator_p (item->name)) | |
2104 { | |
2105 char *utf8_label; | |
2106 /* A title for a popup. We do the same as GTK does when | |
2107 creating titles, but it does not look good. */ | |
2108 group = NULL; | |
2109 utf8_label = get_utf8_string (item->name); | |
2110 | |
2111 gtk_menu_set_title (GTK_MENU (wmenu), utf8_label); | |
50778
f30e6f029d65
* gtkutil.c (create_dialog, make_widget_for_menu_item)
Jan Djärv <jan.h.d@swipnet.se>
parents:
50521
diff
changeset
|
2112 w = gtk_menu_item_new_with_label (utf8_label); |
49323 | 2113 gtk_widget_set_sensitive (w, FALSE); |
2114 if (utf8_label && utf8_label != item->name) g_free (utf8_label); | |
2115 } | |
2116 else if (xg_separator_p (item->name)) | |
2117 { | |
2118 group = NULL; | |
2119 /* GTK only have one separator type. */ | |
2120 w = gtk_separator_menu_item_new (); | |
2121 } | |
2122 else | |
2123 { | |
2124 w = xg_create_one_menuitem (item, | |
2125 f, | |
2126 item->contents ? 0 : select_cb, | |
2127 highlight_cb, | |
2128 cl_data, | |
2129 &group); | |
2130 | |
2131 if (item->contents) | |
2132 { | |
2133 GtkWidget *submenu = create_menus (item->contents, | |
2134 f, | |
2135 select_cb, | |
2136 deactivate_cb, | |
2137 highlight_cb, | |
2138 0, | |
2139 0, | |
52981
54482f5ea7be
Remove tear off capability for GTK popup menus.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
2140 add_tearoff_p, |
49323 | 2141 0, |
2142 cl_data, | |
2143 0); | |
2144 gtk_menu_item_set_submenu (GTK_MENU_ITEM (w), submenu); | |
2145 } | |
2146 } | |
2147 | |
2148 gtk_menu_shell_append (GTK_MENU_SHELL (wmenu), w); | |
2149 gtk_widget_set_name (w, MENU_ITEM_NAME); | |
2150 } | |
2151 | |
2152 return wmenu; | |
2153 } | |
2154 | |
2155 /* Create a menubar, popup menu or dialog, depending on the TYPE argument. | |
2156 TYPE can be "menubar", "popup" for popup menu, or "dialog" for a dialog | |
2157 with some text and buttons. | |
2158 F is the frame the created item belongs to. | |
2159 NAME is the name to use for the top widget. | |
2160 VAL is a widget_value structure describing items to be created. | |
2161 SELECT_CB is the callback to use when a menu item is selected or | |
2162 a dialog button is pressed. | |
2163 DEACTIVATE_CB is the callback to use when an item is deactivated. | |
2164 For a menu, when a sub menu is not shown anymore, for a dialog it is | |
2165 called when the dialog is popped down. | |
2166 HIGHLIGHT_CB is the callback to call when entering/leaving menu items. | |
2167 | |
2168 Returns the widget created. */ | |
57715
cdc48cdd5b0e
* gtkutil.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57597
diff
changeset
|
2169 |
49323 | 2170 GtkWidget * |
2171 xg_create_widget (type, name, f, val, | |
2172 select_cb, deactivate_cb, highlight_cb) | |
2173 char *type; | |
2174 char *name; | |
2175 FRAME_PTR f; | |
2176 widget_value *val; | |
2177 GCallback select_cb; | |
2178 GCallback deactivate_cb; | |
2179 GCallback highlight_cb; | |
2180 { | |
2181 GtkWidget *w = 0; | |
52981
54482f5ea7be
Remove tear off capability for GTK popup menus.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
2182 int menu_bar_p = strcmp (type, "menubar") == 0; |
54482f5ea7be
Remove tear off capability for GTK popup menus.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
2183 int pop_up_p = strcmp (type, "popup") == 0; |
54482f5ea7be
Remove tear off capability for GTK popup menus.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
2184 |
49323 | 2185 if (strcmp (type, "dialog") == 0) |
2186 { | |
2187 w = create_dialog (val, select_cb, deactivate_cb); | |
53069
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
2188 xg_set_screen (w, f); |
49323 | 2189 gtk_window_set_transient_for (GTK_WINDOW (w), |
2190 GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f))); | |
2191 gtk_window_set_destroy_with_parent (GTK_WINDOW (w), TRUE); | |
53069
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
2192 gtk_widget_set_name (w, "emacs-dialog"); |
58200
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Djärv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
2193 gtk_window_set_modal (GTK_WINDOW (w), TRUE); |
49323 | 2194 } |
52981
54482f5ea7be
Remove tear off capability for GTK popup menus.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
2195 else if (menu_bar_p || pop_up_p) |
49323 | 2196 { |
2197 w = create_menus (val->contents, | |
2198 f, | |
2199 select_cb, | |
2200 deactivate_cb, | |
2201 highlight_cb, | |
52981
54482f5ea7be
Remove tear off capability for GTK popup menus.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
2202 pop_up_p, |
54482f5ea7be
Remove tear off capability for GTK popup menus.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
2203 menu_bar_p, |
54482f5ea7be
Remove tear off capability for GTK popup menus.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
2204 menu_bar_p, |
49323 | 2205 0, |
2206 0, | |
2207 name); | |
2208 | |
2209 /* Set the cursor to an arrow for popup menus when they are mapped. | |
2210 This is done by default for menu bar menus. */ | |
52981
54482f5ea7be
Remove tear off capability for GTK popup menus.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
2211 if (pop_up_p) |
49323 | 2212 { |
2213 /* Must realize so the GdkWindow inside the widget is created. */ | |
2214 gtk_widget_realize (w); | |
53069
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
2215 xg_set_cursor (w, FRAME_X_DISPLAY_INFO (f)->xg_cursor); |
49323 | 2216 } |
2217 } | |
2218 else | |
2219 { | |
2220 fprintf (stderr, "bad type in xg_create_widget: %s, doing nothing\n", | |
2221 type); | |
2222 } | |
2223 | |
2224 return w; | |
2225 } | |
2226 | |
49488
da6abcaef15c
gtkutil.c: Check for NULL string before calling strcmp or strlen.
Jan Djärv <jan.h.d@swipnet.se>
parents:
49468
diff
changeset
|
2227 /* Return the label for menu item WITEM. */ |
57715
cdc48cdd5b0e
* gtkutil.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57597
diff
changeset
|
2228 |
49323 | 2229 static const char * |
2230 xg_get_menu_item_label (witem) | |
2231 GtkMenuItem *witem; | |
2232 { | |
2233 GtkLabel *wlabel = GTK_LABEL (gtk_bin_get_child (GTK_BIN (witem))); | |
2234 return gtk_label_get_label (wlabel); | |
2235 } | |
2236 | |
49488
da6abcaef15c
gtkutil.c: Check for NULL string before calling strcmp or strlen.
Jan Djärv <jan.h.d@swipnet.se>
parents:
49468
diff
changeset
|
2237 /* Return non-zero if the menu item WITEM has the text LABEL. */ |
57715
cdc48cdd5b0e
* gtkutil.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57597
diff
changeset
|
2238 |
49323 | 2239 static int |
2240 xg_item_label_same_p (witem, label) | |
2241 GtkMenuItem *witem; | |
2242 char *label; | |
2243 { | |
49488
da6abcaef15c
gtkutil.c: Check for NULL string before calling strcmp or strlen.
Jan Djärv <jan.h.d@swipnet.se>
parents:
49468
diff
changeset
|
2244 int is_same = 0; |
49323 | 2245 char *utf8_label = get_utf8_string (label); |
49488
da6abcaef15c
gtkutil.c: Check for NULL string before calling strcmp or strlen.
Jan Djärv <jan.h.d@swipnet.se>
parents:
49468
diff
changeset
|
2246 const char *old_label = witem ? xg_get_menu_item_label (witem) : 0; |
da6abcaef15c
gtkutil.c: Check for NULL string before calling strcmp or strlen.
Jan Djärv <jan.h.d@swipnet.se>
parents:
49468
diff
changeset
|
2247 |
da6abcaef15c
gtkutil.c: Check for NULL string before calling strcmp or strlen.
Jan Djärv <jan.h.d@swipnet.se>
parents:
49468
diff
changeset
|
2248 if (! old_label && ! utf8_label) |
da6abcaef15c
gtkutil.c: Check for NULL string before calling strcmp or strlen.
Jan Djärv <jan.h.d@swipnet.se>
parents:
49468
diff
changeset
|
2249 is_same = 1; |
da6abcaef15c
gtkutil.c: Check for NULL string before calling strcmp or strlen.
Jan Djärv <jan.h.d@swipnet.se>
parents:
49468
diff
changeset
|
2250 else if (old_label && utf8_label) |
da6abcaef15c
gtkutil.c: Check for NULL string before calling strcmp or strlen.
Jan Djärv <jan.h.d@swipnet.se>
parents:
49468
diff
changeset
|
2251 is_same = strcmp (utf8_label, old_label) == 0; |
da6abcaef15c
gtkutil.c: Check for NULL string before calling strcmp or strlen.
Jan Djärv <jan.h.d@swipnet.se>
parents:
49468
diff
changeset
|
2252 |
da6abcaef15c
gtkutil.c: Check for NULL string before calling strcmp or strlen.
Jan Djärv <jan.h.d@swipnet.se>
parents:
49468
diff
changeset
|
2253 if (utf8_label && utf8_label != label) g_free (utf8_label); |
49323 | 2254 |
2255 return is_same; | |
2256 } | |
2257 | |
57715
cdc48cdd5b0e
* gtkutil.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57597
diff
changeset
|
2258 /* Destroy widgets in LIST. */ |
cdc48cdd5b0e
* gtkutil.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57597
diff
changeset
|
2259 |
49323 | 2260 static void |
57715
cdc48cdd5b0e
* gtkutil.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57597
diff
changeset
|
2261 xg_destroy_widgets (list) |
49323 | 2262 GList *list; |
2263 { | |
2264 GList *iter; | |
2265 | |
49572 | 2266 for (iter = list; iter; iter = g_list_next (iter)) |
49323 | 2267 { |
2268 GtkWidget *w = GTK_WIDGET (iter->data); | |
2269 | |
57715
cdc48cdd5b0e
* gtkutil.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57597
diff
changeset
|
2270 /* Destroying the widget will remove it from the container it is in. */ |
49323 | 2271 gtk_widget_destroy (w); |
2272 } | |
2273 } | |
2274 | |
2275 /* Update the top level names in MENUBAR (i.e. not submenus). | |
2276 F is the frame the menu bar belongs to. | |
49572 | 2277 *LIST is a list with the current menu bar names (menu item widgets). |
2278 ITER is the item within *LIST that shall be updated. | |
2279 POS is the numerical position, starting at 0, of ITER in *LIST. | |
49323 | 2280 VAL describes what the menu bar shall look like after the update. |
2281 SELECT_CB is the callback to use when a menu item is selected. | |
2282 HIGHLIGHT_CB is the callback to call when entering/leaving menu items. | |
49572 | 2283 CL_DATA points to the callback data to be used for this menu bar. |
49323 | 2284 |
2285 This function calls itself to walk through the menu bar names. */ | |
57715
cdc48cdd5b0e
* gtkutil.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57597
diff
changeset
|
2286 |
49323 | 2287 static void |
49572 | 2288 xg_update_menubar (menubar, f, list, iter, pos, val, |
2289 select_cb, highlight_cb, cl_data) | |
49323 | 2290 GtkWidget *menubar; |
2291 FRAME_PTR f; | |
49572 | 2292 GList **list; |
2293 GList *iter; | |
2294 int pos; | |
49323 | 2295 widget_value *val; |
2296 GCallback select_cb; | |
2297 GCallback highlight_cb; | |
2298 xg_menu_cb_data *cl_data; | |
2299 { | |
49572 | 2300 if (! iter && ! val) |
49323 | 2301 return; |
49572 | 2302 else if (iter && ! val) |
49323 | 2303 { |
49572 | 2304 /* Item(s) have been removed. Remove all remaining items. */ |
57715
cdc48cdd5b0e
* gtkutil.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57597
diff
changeset
|
2305 xg_destroy_widgets (iter); |
49323 | 2306 |
2307 /* All updated. */ | |
2308 val = 0; | |
49572 | 2309 iter = 0; |
49323 | 2310 } |
49572 | 2311 else if (! iter && val) |
49323 | 2312 { |
2313 /* Item(s) added. Add all new items in one call. */ | |
2314 create_menus (val, f, select_cb, 0, highlight_cb, | |
2315 0, 1, 0, menubar, cl_data, 0); | |
2316 | |
2317 /* All updated. */ | |
2318 val = 0; | |
49572 | 2319 iter = 0; |
49323 | 2320 } |
49572 | 2321 /* Below this neither iter or val is NULL */ |
2322 else if (xg_item_label_same_p (GTK_MENU_ITEM (iter->data), val->name)) | |
49323 | 2323 { |
2324 /* This item is still the same, check next item. */ | |
2325 val = val->next; | |
49572 | 2326 iter = g_list_next (iter); |
2327 ++pos; | |
49323 | 2328 } |
2329 else /* This item is changed. */ | |
2330 { | |
49572 | 2331 GtkMenuItem *witem = GTK_MENU_ITEM (iter->data); |
49323 | 2332 GtkMenuItem *witem2 = 0; |
2333 int val_in_menubar = 0; | |
49572 | 2334 int iter_in_new_menubar = 0; |
2335 GList *iter2; | |
49323 | 2336 widget_value *cur; |
2337 | |
2338 /* See if the changed entry (val) is present later in the menu bar */ | |
49572 | 2339 for (iter2 = iter; |
2340 iter2 && ! val_in_menubar; | |
2341 iter2 = g_list_next (iter2)) | |
49323 | 2342 { |
49572 | 2343 witem2 = GTK_MENU_ITEM (iter2->data); |
49323 | 2344 val_in_menubar = xg_item_label_same_p (witem2, val->name); |
2345 } | |
2346 | |
49572 | 2347 /* See if the current entry (iter) is present later in the |
49323 | 2348 specification for the new menu bar. */ |
49572 | 2349 for (cur = val; cur && ! iter_in_new_menubar; cur = cur->next) |
2350 iter_in_new_menubar = xg_item_label_same_p (witem, cur->name); | |
2351 | |
2352 if (val_in_menubar && ! iter_in_new_menubar) | |
49323 | 2353 { |
49572 | 2354 int nr = pos; |
2355 | |
49323 | 2356 /* This corresponds to: |
2357 Current: A B C | |
2358 New: A C | |
2359 Remove B. */ | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
2360 |
49323 | 2361 gtk_widget_ref (GTK_WIDGET (witem)); |
2362 gtk_container_remove (GTK_CONTAINER (menubar), GTK_WIDGET (witem)); | |
2363 gtk_widget_destroy (GTK_WIDGET (witem)); | |
2364 | |
2365 /* Must get new list since the old changed. */ | |
49572 | 2366 g_list_free (*list); |
2367 *list = iter = gtk_container_get_children (GTK_CONTAINER (menubar)); | |
2368 while (nr-- > 0) iter = g_list_next (iter); | |
49323 | 2369 } |
49572 | 2370 else if (! val_in_menubar && ! iter_in_new_menubar) |
49323 | 2371 { |
2372 /* This corresponds to: | |
2373 Current: A B C | |
2374 New: A X C | |
2375 Rename B to X. This might seem to be a strange thing to do, | |
2376 since if there is a menu under B it will be totally wrong for X. | |
2377 But consider editing a C file. Then there is a C-mode menu | |
2378 (corresponds to B above). | |
2379 If then doing C-x C-f the minibuf menu (X above) replaces the | |
2380 C-mode menu. When returning from the minibuffer, we get | |
2381 back the C-mode menu. Thus we do: | |
2382 Rename B to X (C-mode to minibuf menu) | |
2383 Rename X to B (minibuf to C-mode menu). | |
2384 If the X menu hasn't been invoked, the menu under B | |
2385 is up to date when leaving the minibuffer. */ | |
2386 GtkLabel *wlabel = GTK_LABEL (gtk_bin_get_child (GTK_BIN (witem))); | |
2387 char *utf8_label = get_utf8_string (val->name); | |
52981
54482f5ea7be
Remove tear off capability for GTK popup menus.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
2388 GtkWidget *submenu = gtk_menu_item_get_submenu (witem); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
2389 |
50778
f30e6f029d65
* gtkutil.c (create_dialog, make_widget_for_menu_item)
Jan Djärv <jan.h.d@swipnet.se>
parents:
50521
diff
changeset
|
2390 gtk_label_set_text (wlabel, utf8_label); |
49323 | 2391 |
52981
54482f5ea7be
Remove tear off capability for GTK popup menus.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
2392 /* If this item has a submenu that has been detached, change |
54482f5ea7be
Remove tear off capability for GTK popup menus.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
2393 the title in the WM decorations also. */ |
54482f5ea7be
Remove tear off capability for GTK popup menus.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
2394 if (submenu && gtk_menu_get_tearoff_state (GTK_MENU (submenu))) |
54482f5ea7be
Remove tear off capability for GTK popup menus.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
2395 /* Set the title of the detached window. */ |
54482f5ea7be
Remove tear off capability for GTK popup menus.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
2396 gtk_menu_set_title (GTK_MENU (submenu), utf8_label); |
54482f5ea7be
Remove tear off capability for GTK popup menus.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
2397 |
49572 | 2398 iter = g_list_next (iter); |
49323 | 2399 val = val->next; |
49572 | 2400 ++pos; |
49323 | 2401 } |
49572 | 2402 else if (! val_in_menubar && iter_in_new_menubar) |
49323 | 2403 { |
2404 /* This corresponds to: | |
2405 Current: A B C | |
2406 New: A X B C | |
2407 Insert X. */ | |
2408 | |
49572 | 2409 int nr = pos; |
49323 | 2410 GList *group = 0; |
2411 GtkWidget *w = xg_create_one_menuitem (val, | |
2412 f, | |
2413 select_cb, | |
2414 highlight_cb, | |
2415 cl_data, | |
2416 &group); | |
2417 | |
2418 gtk_widget_set_name (w, MENU_ITEM_NAME); | |
2419 gtk_menu_shell_insert (GTK_MENU_SHELL (menubar), w, pos); | |
2420 | |
49572 | 2421 g_list_free (*list); |
2422 *list = iter = gtk_container_get_children (GTK_CONTAINER (menubar)); | |
2423 while (nr-- > 0) iter = g_list_next (iter); | |
2424 iter = g_list_next (iter); | |
49323 | 2425 val = val->next; |
49572 | 2426 ++pos; |
49323 | 2427 } |
49572 | 2428 else /* if (val_in_menubar && iter_in_new_menubar) */ |
49323 | 2429 { |
49572 | 2430 int nr = pos; |
49323 | 2431 /* This corresponds to: |
2432 Current: A B C | |
2433 New: A C B | |
2434 Move C before B */ | |
2435 | |
2436 gtk_widget_ref (GTK_WIDGET (witem2)); | |
2437 gtk_container_remove (GTK_CONTAINER (menubar), GTK_WIDGET (witem2)); | |
2438 gtk_menu_shell_insert (GTK_MENU_SHELL (menubar), | |
2439 GTK_WIDGET (witem2), pos); | |
2440 gtk_widget_unref (GTK_WIDGET (witem2)); | |
2441 | |
49572 | 2442 g_list_free (*list); |
2443 *list = iter = gtk_container_get_children (GTK_CONTAINER (menubar)); | |
2444 while (nr-- > 0) iter = g_list_next (iter); | |
49323 | 2445 val = val->next; |
49572 | 2446 ++pos; |
49323 | 2447 } |
2448 } | |
2449 | |
2450 /* Update the rest of the menu bar. */ | |
49572 | 2451 xg_update_menubar (menubar, f, list, iter, pos, val, |
2452 select_cb, highlight_cb, cl_data); | |
49323 | 2453 } |
2454 | |
2455 /* Update the menu item W so it corresponds to VAL. | |
2456 SELECT_CB is the callback to use when a menu item is selected. | |
2457 HIGHLIGHT_CB is the callback to call when entering/leaving menu items. | |
2458 CL_DATA is the data to set in the widget for menu invokation. */ | |
57715
cdc48cdd5b0e
* gtkutil.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57597
diff
changeset
|
2459 |
49323 | 2460 static void |
2461 xg_update_menu_item (val, w, select_cb, highlight_cb, cl_data) | |
2462 widget_value *val; | |
2463 GtkWidget *w; | |
2464 GCallback select_cb; | |
2465 GCallback highlight_cb; | |
2466 xg_menu_cb_data *cl_data; | |
2467 { | |
2468 GtkWidget *wchild; | |
2469 GtkLabel *wlbl = 0; | |
2470 GtkLabel *wkey = 0; | |
2471 char *utf8_label; | |
2472 char *utf8_key; | |
49488
da6abcaef15c
gtkutil.c: Check for NULL string before calling strcmp or strlen.
Jan Djärv <jan.h.d@swipnet.se>
parents:
49468
diff
changeset
|
2473 const char *old_label = 0; |
da6abcaef15c
gtkutil.c: Check for NULL string before calling strcmp or strlen.
Jan Djärv <jan.h.d@swipnet.se>
parents:
49468
diff
changeset
|
2474 const char *old_key = 0; |
49323 | 2475 xg_menu_item_cb_data *cb_data; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
2476 |
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
2477 wchild = gtk_bin_get_child (GTK_BIN (w)); |
49323 | 2478 utf8_label = get_utf8_string (val->name); |
2479 utf8_key = get_utf8_string (val->key); | |
2480 | |
2481 /* See if W is a menu item with a key. See make_menu_item above. */ | |
2482 if (GTK_IS_HBOX (wchild)) | |
2483 { | |
2484 GList *list = gtk_container_get_children (GTK_CONTAINER (wchild)); | |
2485 | |
2486 wlbl = GTK_LABEL (list->data); | |
2487 wkey = GTK_LABEL (list->next->data); | |
49572 | 2488 g_list_free (list); |
2489 | |
49323 | 2490 if (! utf8_key) |
2491 { | |
2492 /* Remove the key and keep just the label. */ | |
2493 gtk_widget_ref (GTK_WIDGET (wlbl)); | |
2494 gtk_container_remove (GTK_CONTAINER (w), wchild); | |
2495 gtk_container_add (GTK_CONTAINER (w), GTK_WIDGET (wlbl)); | |
2496 wkey = 0; | |
2497 } | |
49572 | 2498 |
49323 | 2499 } |
2500 else /* Just a label. */ | |
2501 { | |
2502 wlbl = GTK_LABEL (wchild); | |
2503 | |
2504 /* Check if there is now a key. */ | |
2505 if (utf8_key) | |
2506 { | |
2507 GtkWidget *wtoadd = make_widget_for_menu_item (utf8_label, utf8_key); | |
2508 GList *list = gtk_container_get_children (GTK_CONTAINER (wtoadd)); | |
49572 | 2509 |
49323 | 2510 wlbl = GTK_LABEL (list->data); |
2511 wkey = GTK_LABEL (list->next->data); | |
49572 | 2512 g_list_free (list); |
49323 | 2513 |
2514 gtk_container_remove (GTK_CONTAINER (w), wchild); | |
2515 gtk_container_add (GTK_CONTAINER (w), wtoadd); | |
2516 } | |
2517 } | |
2518 | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
2519 |
49488
da6abcaef15c
gtkutil.c: Check for NULL string before calling strcmp or strlen.
Jan Djärv <jan.h.d@swipnet.se>
parents:
49468
diff
changeset
|
2520 if (wkey) old_key = gtk_label_get_label (wkey); |
da6abcaef15c
gtkutil.c: Check for NULL string before calling strcmp or strlen.
Jan Djärv <jan.h.d@swipnet.se>
parents:
49468
diff
changeset
|
2521 if (wlbl) old_label = gtk_label_get_label (wlbl); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
2522 |
49488
da6abcaef15c
gtkutil.c: Check for NULL string before calling strcmp or strlen.
Jan Djärv <jan.h.d@swipnet.se>
parents:
49468
diff
changeset
|
2523 if (wkey && utf8_key && (! old_key || strcmp (utf8_key, old_key) != 0)) |
49323 | 2524 gtk_label_set_text (wkey, utf8_key); |
2525 | |
49488
da6abcaef15c
gtkutil.c: Check for NULL string before calling strcmp or strlen.
Jan Djärv <jan.h.d@swipnet.se>
parents:
49468
diff
changeset
|
2526 if (! old_label || strcmp (utf8_label, old_label) != 0) |
50778
f30e6f029d65
* gtkutil.c (create_dialog, make_widget_for_menu_item)
Jan Djärv <jan.h.d@swipnet.se>
parents:
50521
diff
changeset
|
2527 gtk_label_set_text (wlbl, utf8_label); |
49323 | 2528 |
49488
da6abcaef15c
gtkutil.c: Check for NULL string before calling strcmp or strlen.
Jan Djärv <jan.h.d@swipnet.se>
parents:
49468
diff
changeset
|
2529 if (utf8_key && utf8_key != val->key) g_free (utf8_key); |
da6abcaef15c
gtkutil.c: Check for NULL string before calling strcmp or strlen.
Jan Djärv <jan.h.d@swipnet.se>
parents:
49468
diff
changeset
|
2530 if (utf8_label && utf8_label != val->name) g_free (utf8_label); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
2531 |
49323 | 2532 if (! val->enabled && GTK_WIDGET_SENSITIVE (w)) |
2533 gtk_widget_set_sensitive (w, FALSE); | |
2534 else if (val->enabled && ! GTK_WIDGET_SENSITIVE (w)) | |
2535 gtk_widget_set_sensitive (w, TRUE); | |
2536 | |
2537 cb_data = (xg_menu_item_cb_data*) g_object_get_data (G_OBJECT (w), | |
2538 XG_ITEM_DATA); | |
2539 if (cb_data) | |
2540 { | |
2541 cb_data->call_data = val->call_data; | |
2542 cb_data->help = val->help; | |
2543 cb_data->cl_data = cl_data; | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
2544 |
49323 | 2545 /* We assume the callback functions don't change. */ |
2546 if (val->call_data && ! val->contents) | |
2547 { | |
2548 /* This item shall have a select callback. */ | |
2549 if (! cb_data->select_id) | |
2550 cb_data->select_id | |
2551 = g_signal_connect (G_OBJECT (w), "activate", | |
2552 select_cb, cb_data); | |
2553 } | |
2554 else if (cb_data->select_id) | |
2555 { | |
2556 g_signal_handler_disconnect (w, cb_data->select_id); | |
2557 cb_data->select_id = 0; | |
2558 } | |
2559 | |
2560 if (NILP (cb_data->help)) | |
2561 { | |
2562 /* Shall not have help. Remove if any existed previously. */ | |
2563 if (cb_data->highlight_id) | |
2564 { | |
2565 g_signal_handler_disconnect (G_OBJECT (w), | |
2566 cb_data->highlight_id); | |
2567 cb_data->highlight_id = 0; | |
2568 } | |
2569 if (cb_data->unhighlight_id) | |
2570 { | |
2571 g_signal_handler_disconnect (G_OBJECT (w), | |
2572 cb_data->unhighlight_id); | |
2573 cb_data->unhighlight_id = 0; | |
2574 } | |
2575 } | |
2576 else if (! cb_data->highlight_id && highlight_cb) | |
2577 { | |
2578 /* Have help now, but didn't previously. Add callback. */ | |
2579 cb_data->highlight_id | |
2580 = g_signal_connect (G_OBJECT (w), | |
2581 "enter-notify-event", | |
2582 G_CALLBACK (menuitem_highlight_callback), | |
2583 cb_data); | |
2584 cb_data->unhighlight_id | |
2585 = g_signal_connect (G_OBJECT (w), | |
2586 "leave-notify-event", | |
2587 G_CALLBACK (menuitem_highlight_callback), | |
2588 cb_data); | |
2589 } | |
2590 } | |
2591 } | |
2592 | |
2593 /* Update the toggle menu item W so it corresponds to VAL. */ | |
57715
cdc48cdd5b0e
* gtkutil.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57597
diff
changeset
|
2594 |
49323 | 2595 static void |
2596 xg_update_toggle_item (val, w) | |
2597 widget_value *val; | |
2598 GtkWidget *w; | |
2599 { | |
2600 gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (w), val->selected); | |
2601 } | |
2602 | |
2603 /* Update the radio menu item W so it corresponds to VAL. */ | |
57715
cdc48cdd5b0e
* gtkutil.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57597
diff
changeset
|
2604 |
49323 | 2605 static void |
2606 xg_update_radio_item (val, w) | |
2607 widget_value *val; | |
2608 GtkWidget *w; | |
2609 { | |
2610 gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (w), val->selected); | |
2611 } | |
2612 | |
2613 /* Update the sub menu SUBMENU and all its children so it corresponds to VAL. | |
2614 SUBMENU may be NULL, in that case a new menu is created. | |
2615 F is the frame the menu bar belongs to. | |
2616 VAL describes the contents of the menu bar. | |
2617 SELECT_CB is the callback to use when a menu item is selected. | |
2618 DEACTIVATE_CB is the callback to use when a sub menu is not shown anymore. | |
2619 HIGHLIGHT_CB is the callback to call when entering/leaving menu items. | |
2620 CL_DATA is the call back data to use for any newly created items. | |
2621 | |
2622 Returns the updated submenu widget, that is SUBMENU unless SUBMENU | |
2623 was NULL. */ | |
2624 | |
2625 static GtkWidget * | |
2626 xg_update_submenu (submenu, f, val, | |
2627 select_cb, deactivate_cb, highlight_cb, cl_data) | |
2628 GtkWidget *submenu; | |
2629 FRAME_PTR f; | |
2630 widget_value *val; | |
2631 GCallback select_cb; | |
2632 GCallback deactivate_cb; | |
2633 GCallback highlight_cb; | |
2634 xg_menu_cb_data *cl_data; | |
2635 { | |
2636 GtkWidget *newsub = submenu; | |
2637 GList *list = 0; | |
2638 GList *iter; | |
2639 widget_value *cur; | |
2640 int has_tearoff_p = 0; | |
2641 GList *first_radio = 0; | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
2642 |
49323 | 2643 if (submenu) |
2644 list = gtk_container_get_children (GTK_CONTAINER (submenu)); | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
2645 |
49323 | 2646 for (cur = val, iter = list; |
2647 cur && iter; | |
2648 iter = g_list_next (iter), cur = cur->next) | |
2649 { | |
2650 GtkWidget *w = GTK_WIDGET (iter->data); | |
2651 | |
2652 /* Skip tearoff items, they have no counterpart in val. */ | |
2653 if (GTK_IS_TEAROFF_MENU_ITEM (w)) | |
2654 { | |
2655 has_tearoff_p = 1; | |
2656 iter = g_list_next (iter); | |
2657 if (iter) w = GTK_WIDGET (iter->data); | |
2658 else break; | |
2659 } | |
2660 | |
2661 /* Remember first radio button in a group. If we get a mismatch in | |
2662 a radio group we must rebuild the whole group so that the connections | |
2663 in GTK becomes correct. */ | |
2664 if (cur->button_type == BUTTON_TYPE_RADIO && ! first_radio) | |
2665 first_radio = iter; | |
2666 else if (cur->button_type != BUTTON_TYPE_RADIO | |
2667 && ! GTK_IS_RADIO_MENU_ITEM (w)) | |
2668 first_radio = 0; | |
2669 | |
2670 if (GTK_IS_SEPARATOR_MENU_ITEM (w)) | |
2671 { | |
2672 if (! xg_separator_p (cur->name)) | |
2673 break; | |
2674 } | |
2675 else if (GTK_IS_CHECK_MENU_ITEM (w)) | |
2676 { | |
2677 if (cur->button_type != BUTTON_TYPE_TOGGLE) | |
2678 break; | |
2679 xg_update_toggle_item (cur, w); | |
2680 xg_update_menu_item (cur, w, select_cb, highlight_cb, cl_data); | |
2681 } | |
2682 else if (GTK_IS_RADIO_MENU_ITEM (w)) | |
2683 { | |
2684 if (cur->button_type != BUTTON_TYPE_RADIO) | |
2685 break; | |
2686 xg_update_radio_item (cur, w); | |
2687 xg_update_menu_item (cur, w, select_cb, highlight_cb, cl_data); | |
2688 } | |
2689 else if (GTK_IS_MENU_ITEM (w)) | |
2690 { | |
2691 GtkMenuItem *witem = GTK_MENU_ITEM (w); | |
2692 GtkWidget *sub; | |
2693 | |
2694 if (cur->button_type != BUTTON_TYPE_NONE || | |
2695 xg_separator_p (cur->name)) | |
2696 break; | |
2697 | |
2698 xg_update_menu_item (cur, w, select_cb, highlight_cb, cl_data); | |
2699 | |
2700 sub = gtk_menu_item_get_submenu (witem); | |
2701 if (sub && ! cur->contents) | |
2702 { | |
2703 /* Not a submenu anymore. */ | |
2704 gtk_widget_ref (sub); | |
2705 gtk_menu_item_remove_submenu (witem); | |
2706 gtk_widget_destroy (sub); | |
2707 } | |
2708 else if (cur->contents) | |
2709 { | |
2710 GtkWidget *nsub; | |
2711 | |
2712 nsub = xg_update_submenu (sub, f, cur->contents, | |
2713 select_cb, deactivate_cb, | |
2714 highlight_cb, cl_data); | |
2715 | |
2716 /* If this item just became a submenu, we must set it. */ | |
2717 if (nsub != sub) | |
2718 gtk_menu_item_set_submenu (witem, nsub); | |
2719 } | |
2720 } | |
2721 else | |
2722 { | |
2723 /* Structural difference. Remove everything from here and down | |
2724 in SUBMENU. */ | |
2725 break; | |
2726 } | |
2727 } | |
2728 | |
2729 /* Remove widgets from first structual change. */ | |
2730 if (iter) | |
2731 { | |
2732 /* If we are adding new menu items below, we must remove from | |
2733 first radio button so that radio groups become correct. */ | |
57715
cdc48cdd5b0e
* gtkutil.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57597
diff
changeset
|
2734 if (cur && first_radio) xg_destroy_widgets (first_radio); |
cdc48cdd5b0e
* gtkutil.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57597
diff
changeset
|
2735 else xg_destroy_widgets (iter); |
49323 | 2736 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
2737 |
49323 | 2738 if (cur) |
2739 { | |
2740 /* More items added. Create them. */ | |
2741 newsub = create_menus (cur, | |
2742 f, | |
2743 select_cb, | |
2744 deactivate_cb, | |
2745 highlight_cb, | |
2746 0, | |
2747 0, | |
2748 ! has_tearoff_p, | |
2749 submenu, | |
2750 cl_data, | |
2751 0); | |
2752 } | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
2753 |
49572 | 2754 if (list) g_list_free (list); |
2755 | |
49323 | 2756 return newsub; |
2757 } | |
2758 | |
2759 /* Update the MENUBAR. | |
2760 F is the frame the menu bar belongs to. | |
2761 VAL describes the contents of the menu bar. | |
2762 If DEEP_P is non-zero, rebuild all but the top level menu names in | |
2763 the MENUBAR. If DEEP_P is zero, just rebuild the names in the menubar. | |
2764 SELECT_CB is the callback to use when a menu item is selected. | |
2765 DEACTIVATE_CB is the callback to use when a sub menu is not shown anymore. | |
2766 HIGHLIGHT_CB is the callback to call when entering/leaving menu items. */ | |
57715
cdc48cdd5b0e
* gtkutil.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57597
diff
changeset
|
2767 |
49323 | 2768 void |
2769 xg_modify_menubar_widgets (menubar, f, val, deep_p, | |
2770 select_cb, deactivate_cb, highlight_cb) | |
2771 GtkWidget *menubar; | |
2772 FRAME_PTR f; | |
2773 widget_value *val; | |
2774 int deep_p; | |
2775 GCallback select_cb; | |
2776 GCallback deactivate_cb; | |
2777 GCallback highlight_cb; | |
2778 { | |
2779 xg_menu_cb_data *cl_data; | |
2780 GList *list = gtk_container_get_children (GTK_CONTAINER (menubar)); | |
2781 | |
2782 if (! list) return; | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
2783 |
49323 | 2784 cl_data = (xg_menu_cb_data*) g_object_get_data (G_OBJECT (menubar), |
2785 XG_FRAME_DATA); | |
2786 | |
52981
54482f5ea7be
Remove tear off capability for GTK popup menus.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
2787 xg_update_menubar (menubar, f, &list, list, 0, val->contents, |
54482f5ea7be
Remove tear off capability for GTK popup menus.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
2788 select_cb, highlight_cb, cl_data); |
54482f5ea7be
Remove tear off capability for GTK popup menus.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
2789 |
64783
0975467abc17
* gtkutil.c (xg_modify_menubar_widgets): Remove semicolon that
Jan Djärv <jan.h.d@swipnet.se>
parents:
64770
diff
changeset
|
2790 if (deep_p) |
49323 | 2791 { |
2792 widget_value *cur; | |
2793 | |
2794 /* Update all sub menus. | |
52981
54482f5ea7be
Remove tear off capability for GTK popup menus.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
2795 We must keep the submenus (GTK menu item widgets) since the |
49323 | 2796 X Window in the XEvent that activates the menu are those widgets. */ |
2797 | |
2798 /* Update cl_data, menu_item things in F may have changed. */ | |
2799 update_cl_data (cl_data, f, highlight_cb); | |
2800 | |
2801 for (cur = val->contents; cur; cur = cur->next) | |
2802 { | |
49572 | 2803 GList *iter; |
49323 | 2804 GtkWidget *sub = 0; |
2805 GtkWidget *newsub; | |
2806 GtkMenuItem *witem; | |
2807 | |
2808 /* Find sub menu that corresponds to val and update it. */ | |
2809 for (iter = list ; iter; iter = g_list_next (iter)) | |
2810 { | |
2811 witem = GTK_MENU_ITEM (iter->data); | |
2812 if (xg_item_label_same_p (witem, cur->name)) | |
2813 { | |
2814 sub = gtk_menu_item_get_submenu (witem); | |
2815 break; | |
2816 } | |
2817 } | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
2818 |
49323 | 2819 newsub = xg_update_submenu (sub, |
2820 f, | |
2821 cur->contents, | |
2822 select_cb, | |
2823 deactivate_cb, | |
2824 highlight_cb, | |
2825 cl_data); | |
2826 /* sub may still be NULL. If we just updated non deep and added | |
2827 a new menu bar item, it has no sub menu yet. So we set the | |
2828 newly created sub menu under witem. */ | |
2829 if (newsub != sub) | |
53069
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
2830 { |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
2831 xg_set_screen (newsub, f); |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
2832 gtk_menu_item_set_submenu (witem, newsub); |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
2833 } |
49323 | 2834 } |
2835 } | |
2836 | |
49572 | 2837 g_list_free (list); |
49323 | 2838 gtk_widget_show_all (menubar); |
2839 } | |
2840 | |
2841 /* Recompute all the widgets of frame F, when the menu bar has been | |
2842 changed. Value is non-zero if widgets were updated. */ | |
2843 | |
2844 int | |
2845 xg_update_frame_menubar (f) | |
2846 FRAME_PTR f; | |
2847 { | |
2848 struct x_output *x = f->output_data.x; | |
2849 GtkRequisition req; | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
2850 |
49323 | 2851 if (!x->menubar_widget || GTK_WIDGET_MAPPED (x->menubar_widget)) |
2852 return 0; | |
2853 | |
2854 BLOCK_INPUT; | |
2855 | |
2856 gtk_box_pack_start (GTK_BOX (x->vbox_widget), x->menubar_widget, | |
2857 FALSE, FALSE, 0); | |
2858 gtk_box_reorder_child (GTK_BOX (x->vbox_widget), x->menubar_widget, 0); | |
2859 | |
2860 gtk_widget_show_all (x->menubar_widget); | |
2861 gtk_widget_size_request (x->menubar_widget, &req); | |
2862 | |
2863 FRAME_MENUBAR_HEIGHT (f) = req.height; | |
2864 | |
2865 /* The height has changed, resize outer widget and set columns | |
2866 rows to what we had before adding the menu bar. */ | |
51211
28ea05de2dc5
Make (many) trivial substitutions for renamed and
Kim F. Storm <storm@cua.dk>
parents:
50778
diff
changeset
|
2867 xg_resize_outer_widget (f, FRAME_COLS (f), FRAME_LINES (f)); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
2868 |
49323 | 2869 SET_FRAME_GARBAGED (f); |
2870 UNBLOCK_INPUT; | |
50106
5675d6a0080c
(xg_update_frame_menubar): Add missing return value.
Andreas Schwab <schwab@suse.de>
parents:
50099
diff
changeset
|
2871 |
5675d6a0080c
(xg_update_frame_menubar): Add missing return value.
Andreas Schwab <schwab@suse.de>
parents:
50099
diff
changeset
|
2872 return 1; |
49323 | 2873 } |
2874 | |
2875 /* Get rid of the menu bar of frame F, and free its storage. | |
2876 This is used when deleting a frame, and when turning off the menu bar. */ | |
2877 | |
2878 void | |
2879 free_frame_menubar (f) | |
2880 FRAME_PTR f; | |
2881 { | |
2882 struct x_output *x = f->output_data.x; | |
2883 | |
2884 if (x->menubar_widget) | |
2885 { | |
2886 BLOCK_INPUT; | |
2887 | |
2888 gtk_container_remove (GTK_CONTAINER (x->vbox_widget), x->menubar_widget); | |
2889 /* The menubar and its children shall be deleted when removed from | |
2890 the container. */ | |
2891 x->menubar_widget = 0; | |
2892 FRAME_MENUBAR_HEIGHT (f) = 0; | |
2893 | |
2894 /* The height has changed, resize outer widget and set columns | |
2895 rows to what we had before removing the menu bar. */ | |
51211
28ea05de2dc5
Make (many) trivial substitutions for renamed and
Kim F. Storm <storm@cua.dk>
parents:
50778
diff
changeset
|
2896 xg_resize_outer_widget (f, FRAME_COLS (f), FRAME_LINES (f)); |
49323 | 2897 |
2898 SET_FRAME_GARBAGED (f); | |
2899 UNBLOCK_INPUT; | |
2900 } | |
2901 } | |
2902 | |
2903 | |
2904 | |
2905 /*********************************************************************** | |
2906 Scroll bar functions | |
2907 ***********************************************************************/ | |
2908 | |
2909 | |
2910 /* Setting scroll bar values invokes the callback. Use this variable | |
2911 to indicate that callback should do nothing. */ | |
57715
cdc48cdd5b0e
* gtkutil.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57597
diff
changeset
|
2912 |
49323 | 2913 int xg_ignore_gtk_scrollbar; |
2914 | |
2915 /* SET_SCROLL_BAR_X_WINDOW assumes the second argument fits in | |
2916 32 bits. But we want to store pointers, and they may be larger | |
2917 than 32 bits. Keep a mapping from integer index to widget pointers | |
2918 to get around the 32 bit limitation. */ | |
57715
cdc48cdd5b0e
* gtkutil.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57597
diff
changeset
|
2919 |
49323 | 2920 static struct |
2921 { | |
2922 GtkWidget **widgets; | |
2923 int max_size; | |
2924 int used; | |
49419
6562bb5f04aa
gtkutil.c (xg_initialize): Initialize id_to_widget here instead
Jan Djärv <jan.h.d@swipnet.se>
parents:
49359
diff
changeset
|
2925 } id_to_widget; |
49323 | 2926 |
2927 /* Grow this much every time we need to allocate more */ | |
57715
cdc48cdd5b0e
* gtkutil.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57597
diff
changeset
|
2928 |
49323 | 2929 #define ID_TO_WIDGET_INCR 32 |
2930 | |
2931 /* Store the widget pointer W in id_to_widget and return the integer index. */ | |
57715
cdc48cdd5b0e
* gtkutil.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57597
diff
changeset
|
2932 |
49323 | 2933 static int |
2934 xg_store_widget_in_map (w) | |
2935 GtkWidget *w; | |
2936 { | |
2937 int i; | |
2938 | |
2939 if (id_to_widget.max_size == id_to_widget.used) | |
2940 { | |
2941 int new_size = id_to_widget.max_size + ID_TO_WIDGET_INCR; | |
2942 | |
2943 id_to_widget.widgets = xrealloc (id_to_widget.widgets, | |
2944 sizeof (GtkWidget *)*new_size); | |
2945 | |
2946 for (i = id_to_widget.max_size; i < new_size; ++i) | |
2947 id_to_widget.widgets[i] = 0; | |
2948 id_to_widget.max_size = new_size; | |
2949 } | |
2950 | |
2951 /* Just loop over the array and find a free place. After all, | |
2952 how many scroll bars are we creating? Should be a small number. | |
2953 The check above guarantees we will find a free place. */ | |
2954 for (i = 0; i < id_to_widget.max_size; ++i) | |
2955 { | |
2956 if (! id_to_widget.widgets[i]) | |
2957 { | |
2958 id_to_widget.widgets[i] = w; | |
2959 ++id_to_widget.used; | |
2960 | |
2961 return i; | |
2962 } | |
2963 } | |
2964 | |
2965 /* Should never end up here */ | |
2966 abort (); | |
2967 } | |
2968 | |
2969 /* Remove pointer at IDX from id_to_widget. | |
2970 Called when scroll bar is destroyed. */ | |
57715
cdc48cdd5b0e
* gtkutil.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57597
diff
changeset
|
2971 |
49323 | 2972 static void |
2973 xg_remove_widget_from_map (idx) | |
2974 int idx; | |
2975 { | |
2976 if (idx < id_to_widget.max_size && id_to_widget.widgets[idx] != 0) | |
2977 { | |
2978 id_to_widget.widgets[idx] = 0; | |
2979 --id_to_widget.used; | |
2980 } | |
2981 } | |
2982 | |
2983 /* Get the widget pointer at IDX from id_to_widget. */ | |
57715
cdc48cdd5b0e
* gtkutil.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57597
diff
changeset
|
2984 |
49323 | 2985 static GtkWidget * |
2986 xg_get_widget_from_map (idx) | |
2987 int idx; | |
2988 { | |
2989 if (idx < id_to_widget.max_size && id_to_widget.widgets[idx] != 0) | |
2990 return id_to_widget.widgets[idx]; | |
2991 | |
2992 return 0; | |
2993 } | |
2994 | |
53069
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
2995 /* Return the scrollbar id for X Window WID on display DPY. |
50063 | 2996 Return -1 if WID not in id_to_widget. */ |
57715
cdc48cdd5b0e
* gtkutil.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57597
diff
changeset
|
2997 |
50063 | 2998 int |
53069
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
2999 xg_get_scroll_id_for_window (dpy, wid) |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
3000 Display *dpy; |
50063 | 3001 Window wid; |
3002 { | |
3003 int idx; | |
3004 GtkWidget *w; | |
3005 | |
53069
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
3006 w = xg_win_to_widget (dpy, wid); |
50063 | 3007 |
3008 if (w) | |
3009 { | |
3010 for (idx = 0; idx < id_to_widget.max_size; ++idx) | |
3011 if (id_to_widget.widgets[idx] == w) | |
3012 return idx; | |
3013 } | |
3014 | |
3015 return -1; | |
3016 } | |
3017 | |
49323 | 3018 /* Callback invoked when scroll bar WIDGET is destroyed. |
3019 DATA is the index into id_to_widget for WIDGET. | |
50129
d0142038feaa
Reduce flicker in GTK scrollbars.
Jan Djärv <jan.h.d@swipnet.se>
parents:
50112
diff
changeset
|
3020 We free pointer to last scroll bar values here and remove the index. */ |
57715
cdc48cdd5b0e
* gtkutil.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57597
diff
changeset
|
3021 |
49323 | 3022 static void |
3023 xg_gtk_scroll_destroy (widget, data) | |
3024 GtkWidget *widget; | |
3025 gpointer data; | |
3026 { | |
3027 gpointer p; | |
59411
ecb6689e04bf
* gtkutil.c (xg_gtk_scroll_destroy, xg_create_scroll_bar)
Jan Djärv <jan.h.d@swipnet.se>
parents:
59102
diff
changeset
|
3028 int id = (int) (EMACS_INT) data; /* The EMACS_INT cast avoids a warning. */ |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
3029 |
49323 | 3030 p = g_object_get_data (G_OBJECT (widget), XG_LAST_SB_DATA); |
3031 if (p) xfree (p); | |
3032 xg_remove_widget_from_map (id); | |
3033 } | |
3034 | |
3035 /* Callback for button press/release events. Used to start timer so that | |
3036 the scroll bar repetition timer in GTK gets handeled. | |
50177
297925dd73b1
New approach to scrolling and scroll bars for better redraw and smoother
Jan Djärv <jan.h.d@swipnet.se>
parents:
50130
diff
changeset
|
3037 Also, sets bar->dragging to Qnil when dragging (button release) is done. |
49323 | 3038 WIDGET is the scroll bar widget the event is for (not used). |
3039 EVENT contains the event. | |
50177
297925dd73b1
New approach to scrolling and scroll bars for better redraw and smoother
Jan Djärv <jan.h.d@swipnet.se>
parents:
50130
diff
changeset
|
3040 USER_DATA points to the struct scrollbar structure. |
49323 | 3041 |
3042 Returns FALSE to tell GTK that it shall continue propagate the event | |
3043 to widgets. */ | |
57715
cdc48cdd5b0e
* gtkutil.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57597
diff
changeset
|
3044 |
49323 | 3045 static gboolean |
3046 scroll_bar_button_cb (widget, event, user_data) | |
3047 GtkWidget *widget; | |
3048 GdkEventButton *event; | |
3049 gpointer user_data; | |
3050 { | |
3051 if (event->type == GDK_BUTTON_PRESS && ! xg_timer) | |
3052 xg_start_timer (); | |
50177
297925dd73b1
New approach to scrolling and scroll bars for better redraw and smoother
Jan Djärv <jan.h.d@swipnet.se>
parents:
50130
diff
changeset
|
3053 else if (event->type == GDK_BUTTON_RELEASE) |
297925dd73b1
New approach to scrolling and scroll bars for better redraw and smoother
Jan Djärv <jan.h.d@swipnet.se>
parents:
50130
diff
changeset
|
3054 { |
297925dd73b1
New approach to scrolling and scroll bars for better redraw and smoother
Jan Djärv <jan.h.d@swipnet.se>
parents:
50130
diff
changeset
|
3055 struct scroll_bar *bar = (struct scroll_bar *) user_data; |
297925dd73b1
New approach to scrolling and scroll bars for better redraw and smoother
Jan Djärv <jan.h.d@swipnet.se>
parents:
50130
diff
changeset
|
3056 if (xg_timer) xg_stop_timer (); |
297925dd73b1
New approach to scrolling and scroll bars for better redraw and smoother
Jan Djärv <jan.h.d@swipnet.se>
parents:
50130
diff
changeset
|
3057 bar->dragging = Qnil; |
297925dd73b1
New approach to scrolling and scroll bars for better redraw and smoother
Jan Djärv <jan.h.d@swipnet.se>
parents:
50130
diff
changeset
|
3058 } |
60185
391f44959566
(xg_create_frame_widgets): UNBLOCK_INPUT on error.
Kim F. Storm <storm@cua.dk>
parents:
59913
diff
changeset
|
3059 |
49323 | 3060 return FALSE; |
3061 } | |
3062 | |
3063 /* Create a scroll bar widget for frame F. Store the scroll bar | |
3064 in BAR. | |
3065 SCROLL_CALLBACK is the callback to invoke when the value of the | |
3066 bar changes. | |
3067 SCROLL_BAR_NAME is the name we use for the scroll bar. Can be used | |
3068 to set resources for the widget. */ | |
57715
cdc48cdd5b0e
* gtkutil.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57597
diff
changeset
|
3069 |
49323 | 3070 void |
3071 xg_create_scroll_bar (f, bar, scroll_callback, scroll_bar_name) | |
3072 FRAME_PTR f; | |
3073 struct scroll_bar *bar; | |
3074 GCallback scroll_callback; | |
3075 char *scroll_bar_name; | |
3076 { | |
3077 GtkWidget *wscroll; | |
57597
754a6433f048
* gtkutil.c (xg_frame_cleared, xg_fixed_handle_expose,
Jan Djärv <jan.h.d@swipnet.se>
parents:
57575
diff
changeset
|
3078 GtkWidget *webox; |
49323 | 3079 GtkObject *vadj; |
3080 int scroll_id; | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
3081 |
49323 | 3082 /* Page, step increment values are not so important here, they |
3083 will be corrected in x_set_toolkit_scroll_bar_thumb. */ | |
3084 vadj = gtk_adjustment_new (XG_SB_MIN, XG_SB_MIN, XG_SB_MAX, | |
3085 0.1, 0.1, 0.1); | |
3086 | |
3087 wscroll = gtk_vscrollbar_new (GTK_ADJUSTMENT (vadj)); | |
57597
754a6433f048
* gtkutil.c (xg_frame_cleared, xg_fixed_handle_expose,
Jan Djärv <jan.h.d@swipnet.se>
parents:
57575
diff
changeset
|
3088 webox = gtk_event_box_new (); |
49323 | 3089 gtk_widget_set_name (wscroll, scroll_bar_name); |
3090 gtk_range_set_update_policy (GTK_RANGE (wscroll), GTK_UPDATE_CONTINUOUS); | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
3091 |
49323 | 3092 scroll_id = xg_store_widget_in_map (wscroll); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
3093 |
50521
3b4cda88d7ef
* xterm.c (xg_scroll_callback): Call gtk_range_get_adjustment to
Jan Djärv <jan.h.d@swipnet.se>
parents:
50333
diff
changeset
|
3094 g_signal_connect (G_OBJECT (wscroll), |
49323 | 3095 "value-changed", |
3096 scroll_callback, | |
50521
3b4cda88d7ef
* xterm.c (xg_scroll_callback): Call gtk_range_get_adjustment to
Jan Djärv <jan.h.d@swipnet.se>
parents:
50333
diff
changeset
|
3097 (gpointer) bar); |
59411
ecb6689e04bf
* gtkutil.c (xg_gtk_scroll_destroy, xg_create_scroll_bar)
Jan Djärv <jan.h.d@swipnet.se>
parents:
59102
diff
changeset
|
3098 /* The EMACS_INT cast avoids a warning. */ |
49323 | 3099 g_signal_connect (G_OBJECT (wscroll), |
3100 "destroy", | |
3101 G_CALLBACK (xg_gtk_scroll_destroy), | |
59411
ecb6689e04bf
* gtkutil.c (xg_gtk_scroll_destroy, xg_create_scroll_bar)
Jan Djärv <jan.h.d@swipnet.se>
parents:
59102
diff
changeset
|
3102 (gpointer) (EMACS_INT) scroll_id); |
49323 | 3103 |
3104 /* Connect to button press and button release to detect if any scroll bar | |
3105 has the pointer. */ | |
3106 g_signal_connect (G_OBJECT (wscroll), | |
3107 "button-press-event", | |
3108 G_CALLBACK (scroll_bar_button_cb), | |
50521
3b4cda88d7ef
* xterm.c (xg_scroll_callback): Call gtk_range_get_adjustment to
Jan Djärv <jan.h.d@swipnet.se>
parents:
50333
diff
changeset
|
3109 (gpointer) bar); |
49323 | 3110 g_signal_connect (G_OBJECT (wscroll), |
3111 "button-release-event", | |
3112 G_CALLBACK (scroll_bar_button_cb), | |
50521
3b4cda88d7ef
* xterm.c (xg_scroll_callback): Call gtk_range_get_adjustment to
Jan Djärv <jan.h.d@swipnet.se>
parents:
50333
diff
changeset
|
3113 (gpointer) bar); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
3114 |
57597
754a6433f048
* gtkutil.c (xg_frame_cleared, xg_fixed_handle_expose,
Jan Djärv <jan.h.d@swipnet.se>
parents:
57575
diff
changeset
|
3115 /* The scroll bar widget does not draw on a window of its own. Instead |
754a6433f048
* gtkutil.c (xg_frame_cleared, xg_fixed_handle_expose,
Jan Djärv <jan.h.d@swipnet.se>
parents:
57575
diff
changeset
|
3116 it draws on the parent window, in this case the edit widget. So |
754a6433f048
* gtkutil.c (xg_frame_cleared, xg_fixed_handle_expose,
Jan Djärv <jan.h.d@swipnet.se>
parents:
57575
diff
changeset
|
3117 whenever the edit widget is cleared, the scroll bar needs to redraw |
754a6433f048
* gtkutil.c (xg_frame_cleared, xg_fixed_handle_expose,
Jan Djärv <jan.h.d@swipnet.se>
parents:
57575
diff
changeset
|
3118 also, which causes flicker. Put an event box between the edit widget |
754a6433f048
* gtkutil.c (xg_frame_cleared, xg_fixed_handle_expose,
Jan Djärv <jan.h.d@swipnet.se>
parents:
57575
diff
changeset
|
3119 and the scroll bar, so the scroll bar instead draws itself on the |
754a6433f048
* gtkutil.c (xg_frame_cleared, xg_fixed_handle_expose,
Jan Djärv <jan.h.d@swipnet.se>
parents:
57575
diff
changeset
|
3120 event box window. */ |
754a6433f048
* gtkutil.c (xg_frame_cleared, xg_fixed_handle_expose,
Jan Djärv <jan.h.d@swipnet.se>
parents:
57575
diff
changeset
|
3121 gtk_fixed_put (GTK_FIXED (f->output_data.x->edit_widget), webox, -1, -1); |
754a6433f048
* gtkutil.c (xg_frame_cleared, xg_fixed_handle_expose,
Jan Djärv <jan.h.d@swipnet.se>
parents:
57575
diff
changeset
|
3122 gtk_container_add (GTK_CONTAINER (webox), wscroll); |
60185
391f44959566
(xg_create_frame_widgets): UNBLOCK_INPUT on error.
Kim F. Storm <storm@cua.dk>
parents:
59913
diff
changeset
|
3123 |
49323 | 3124 |
3125 /* Set the cursor to an arrow. */ | |
57597
754a6433f048
* gtkutil.c (xg_frame_cleared, xg_fixed_handle_expose,
Jan Djärv <jan.h.d@swipnet.se>
parents:
57575
diff
changeset
|
3126 xg_set_cursor (webox, FRAME_X_DISPLAY_INFO (f)->xg_cursor); |
49323 | 3127 |
3128 SET_SCROLL_BAR_X_WINDOW (bar, scroll_id); | |
3129 } | |
3130 | |
3131 /* Make the scroll bar represented by SCROLLBAR_ID visible. */ | |
57715
cdc48cdd5b0e
* gtkutil.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57597
diff
changeset
|
3132 |
49323 | 3133 void |
3134 xg_show_scroll_bar (scrollbar_id) | |
3135 int scrollbar_id; | |
3136 { | |
3137 GtkWidget *w = xg_get_widget_from_map (scrollbar_id); | |
3138 if (w) | |
57597
754a6433f048
* gtkutil.c (xg_frame_cleared, xg_fixed_handle_expose,
Jan Djärv <jan.h.d@swipnet.se>
parents:
57575
diff
changeset
|
3139 gtk_widget_show_all (gtk_widget_get_parent (w)); |
49323 | 3140 } |
3141 | |
3142 /* Remove the scroll bar represented by SCROLLBAR_ID from the frame F. */ | |
57715
cdc48cdd5b0e
* gtkutil.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57597
diff
changeset
|
3143 |
49323 | 3144 void |
3145 xg_remove_scroll_bar (f, scrollbar_id) | |
3146 FRAME_PTR f; | |
3147 int scrollbar_id; | |
3148 { | |
3149 GtkWidget *w = xg_get_widget_from_map (scrollbar_id); | |
3150 if (w) | |
3151 { | |
57597
754a6433f048
* gtkutil.c (xg_frame_cleared, xg_fixed_handle_expose,
Jan Djärv <jan.h.d@swipnet.se>
parents:
57575
diff
changeset
|
3152 GtkWidget *wparent = gtk_widget_get_parent (w); |
49323 | 3153 gtk_widget_destroy (w); |
57597
754a6433f048
* gtkutil.c (xg_frame_cleared, xg_fixed_handle_expose,
Jan Djärv <jan.h.d@swipnet.se>
parents:
57575
diff
changeset
|
3154 gtk_widget_destroy (wparent); |
49323 | 3155 SET_FRAME_GARBAGED (f); |
3156 } | |
3157 } | |
3158 | |
3159 /* Update the position of the vertical scroll bar represented by SCROLLBAR_ID | |
3160 in frame F. | |
3161 TOP/LEFT are the new pixel positions where the bar shall appear. | |
3162 WIDTH, HEIGHT is the size in pixels the bar shall have. */ | |
57715
cdc48cdd5b0e
* gtkutil.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57597
diff
changeset
|
3163 |
49323 | 3164 void |
57597
754a6433f048
* gtkutil.c (xg_frame_cleared, xg_fixed_handle_expose,
Jan Djärv <jan.h.d@swipnet.se>
parents:
57575
diff
changeset
|
3165 xg_update_scrollbar_pos (f, scrollbar_id, top, left, width, height) |
49323 | 3166 FRAME_PTR f; |
3167 int scrollbar_id; | |
3168 int top; | |
3169 int left; | |
3170 int width; | |
3171 int height; | |
3172 { | |
49572 | 3173 |
3174 GtkWidget *wscroll = xg_get_widget_from_map (scrollbar_id); | |
50270
fa50953c02dc
Finally (?) fix flicker in scroll bar.
Jan Djärv <jan.h.d@swipnet.se>
parents:
50192
diff
changeset
|
3175 |
49572 | 3176 if (wscroll) |
3177 { | |
50177
297925dd73b1
New approach to scrolling and scroll bars for better redraw and smoother
Jan Djärv <jan.h.d@swipnet.se>
parents:
50130
diff
changeset
|
3178 GtkWidget *wfixed = f->output_data.x->edit_widget; |
57597
754a6433f048
* gtkutil.c (xg_frame_cleared, xg_fixed_handle_expose,
Jan Djärv <jan.h.d@swipnet.se>
parents:
57575
diff
changeset
|
3179 GtkWidget *wparent = gtk_widget_get_parent (wscroll); |
55342
44d086f5e08a
* gtkutil.c (xg_update_scrollbar_pos): Call XClearWindow to clear
Jan Djärv <jan.h.d@swipnet.se>
parents:
53275
diff
changeset
|
3180 |
44d086f5e08a
* gtkutil.c (xg_update_scrollbar_pos): Call XClearWindow to clear
Jan Djärv <jan.h.d@swipnet.se>
parents:
53275
diff
changeset
|
3181 /* Move and resize to new values. */ |
60553
5ace6337c8fa
* gtkutil.c (xg_update_scrollbar_pos): Call x_sync so that the
Jan Djärv <jan.h.d@swipnet.se>
parents:
60291
diff
changeset
|
3182 gtk_fixed_move (GTK_FIXED (wfixed), wparent, left, top); |
55342
44d086f5e08a
* gtkutil.c (xg_update_scrollbar_pos): Call XClearWindow to clear
Jan Djärv <jan.h.d@swipnet.se>
parents:
53275
diff
changeset
|
3183 gtk_widget_set_size_request (wscroll, width, height); |
60553
5ace6337c8fa
* gtkutil.c (xg_update_scrollbar_pos): Call x_sync so that the
Jan Djärv <jan.h.d@swipnet.se>
parents:
60291
diff
changeset
|
3184 gtk_widget_queue_draw (wparent); |
5ace6337c8fa
* gtkutil.c (xg_update_scrollbar_pos): Call x_sync so that the
Jan Djärv <jan.h.d@swipnet.se>
parents:
60291
diff
changeset
|
3185 gdk_window_process_all_updates (); |
5ace6337c8fa
* gtkutil.c (xg_update_scrollbar_pos): Call x_sync so that the
Jan Djärv <jan.h.d@swipnet.se>
parents:
60291
diff
changeset
|
3186 /* GTK does not redraw until the main loop is entered again, but |
5ace6337c8fa
* gtkutil.c (xg_update_scrollbar_pos): Call x_sync so that the
Jan Djärv <jan.h.d@swipnet.se>
parents:
60291
diff
changeset
|
3187 if there are no X events pending we will not enter it. So we sync |
5ace6337c8fa
* gtkutil.c (xg_update_scrollbar_pos): Call x_sync so that the
Jan Djärv <jan.h.d@swipnet.se>
parents:
60291
diff
changeset
|
3188 here to get some events. */ |
5ace6337c8fa
* gtkutil.c (xg_update_scrollbar_pos): Call x_sync so that the
Jan Djärv <jan.h.d@swipnet.se>
parents:
60291
diff
changeset
|
3189 x_sync (f); |
49572 | 3190 SET_FRAME_GARBAGED (f); |
3191 cancel_mouse_face (f); | |
3192 } | |
49323 | 3193 } |
3194 | |
3195 /* Set the thumb size and position of scroll bar BAR. We are currently | |
3196 displaying PORTION out of a whole WHOLE, and our position POSITION. */ | |
57715
cdc48cdd5b0e
* gtkutil.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57597
diff
changeset
|
3197 |
49323 | 3198 void |
3199 xg_set_toolkit_scroll_bar_thumb (bar, portion, position, whole) | |
3200 struct scroll_bar *bar; | |
3201 int portion, position, whole; | |
3202 { | |
3203 GtkWidget *wscroll = xg_get_widget_from_map (SCROLL_BAR_X_WINDOW (bar)); | |
3204 | |
3205 FRAME_PTR f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window))); | |
3206 | |
50177
297925dd73b1
New approach to scrolling and scroll bars for better redraw and smoother
Jan Djärv <jan.h.d@swipnet.se>
parents:
50130
diff
changeset
|
3207 if (wscroll && NILP (bar->dragging)) |
49323 | 3208 { |
3209 GtkAdjustment *adj; | |
3210 gdouble shown; | |
3211 gdouble top; | |
3212 int size, value; | |
50270
fa50953c02dc
Finally (?) fix flicker in scroll bar.
Jan Djärv <jan.h.d@swipnet.se>
parents:
50192
diff
changeset
|
3213 int new_step; |
fa50953c02dc
Finally (?) fix flicker in scroll bar.
Jan Djärv <jan.h.d@swipnet.se>
parents:
50192
diff
changeset
|
3214 int changed = 0; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
3215 |
49323 | 3216 adj = gtk_range_get_adjustment (GTK_RANGE (wscroll)); |
3217 | |
50177
297925dd73b1
New approach to scrolling and scroll bars for better redraw and smoother
Jan Djärv <jan.h.d@swipnet.se>
parents:
50130
diff
changeset
|
3218 /* We do the same as for MOTIF in xterm.c, assume 30 chars per line |
297925dd73b1
New approach to scrolling and scroll bars for better redraw and smoother
Jan Djärv <jan.h.d@swipnet.se>
parents:
50130
diff
changeset
|
3219 rather than the real portion value. This makes the thumb less likely |
297925dd73b1
New approach to scrolling and scroll bars for better redraw and smoother
Jan Djärv <jan.h.d@swipnet.se>
parents:
50130
diff
changeset
|
3220 to resize and that looks better. */ |
51211
28ea05de2dc5
Make (many) trivial substitutions for renamed and
Kim F. Storm <storm@cua.dk>
parents:
50778
diff
changeset
|
3221 portion = WINDOW_TOTAL_LINES (XWINDOW (bar->window)) * 30; |
50177
297925dd73b1
New approach to scrolling and scroll bars for better redraw and smoother
Jan Djärv <jan.h.d@swipnet.se>
parents:
50130
diff
changeset
|
3222 /* When the thumb is at the bottom, position == whole. |
297925dd73b1
New approach to scrolling and scroll bars for better redraw and smoother
Jan Djärv <jan.h.d@swipnet.se>
parents:
50130
diff
changeset
|
3223 So we need to increase `whole' to make space for the thumb. */ |
297925dd73b1
New approach to scrolling and scroll bars for better redraw and smoother
Jan Djärv <jan.h.d@swipnet.se>
parents:
50130
diff
changeset
|
3224 whole += portion; |
297925dd73b1
New approach to scrolling and scroll bars for better redraw and smoother
Jan Djärv <jan.h.d@swipnet.se>
parents:
50130
diff
changeset
|
3225 |
49323 | 3226 if (whole <= 0) |
3227 top = 0, shown = 1; | |
3228 else | |
3229 { | |
50270
fa50953c02dc
Finally (?) fix flicker in scroll bar.
Jan Djärv <jan.h.d@swipnet.se>
parents:
50192
diff
changeset
|
3230 top = (gdouble) position / whole; |
49323 | 3231 shown = (gdouble) portion / whole; |
3232 } | |
3233 | |
50270
fa50953c02dc
Finally (?) fix flicker in scroll bar.
Jan Djärv <jan.h.d@swipnet.se>
parents:
50192
diff
changeset
|
3234 size = shown * XG_SB_RANGE; |
fa50953c02dc
Finally (?) fix flicker in scroll bar.
Jan Djärv <jan.h.d@swipnet.se>
parents:
50192
diff
changeset
|
3235 size = min (size, XG_SB_RANGE); |
49323 | 3236 size = max (size, 1); |
3237 | |
50270
fa50953c02dc
Finally (?) fix flicker in scroll bar.
Jan Djärv <jan.h.d@swipnet.se>
parents:
50192
diff
changeset
|
3238 value = top * XG_SB_RANGE; |
fa50953c02dc
Finally (?) fix flicker in scroll bar.
Jan Djärv <jan.h.d@swipnet.se>
parents:
50192
diff
changeset
|
3239 value = min (value, XG_SB_MAX - size); |
49323 | 3240 value = max (value, XG_SB_MIN); |
3241 | |
50270
fa50953c02dc
Finally (?) fix flicker in scroll bar.
Jan Djärv <jan.h.d@swipnet.se>
parents:
50192
diff
changeset
|
3242 /* Assume all lines are of equal size. */ |
51211
28ea05de2dc5
Make (many) trivial substitutions for renamed and
Kim F. Storm <storm@cua.dk>
parents:
50778
diff
changeset
|
3243 new_step = size / max (1, FRAME_LINES (f)); |
50178
61194aef8668
* gtkutil.c (xg_set_toolkit_scroll_bar_thumb): Check if new values
Jan Djärv <jan.h.d@swipnet.se>
parents:
50177
diff
changeset
|
3244 |
61194aef8668
* gtkutil.c (xg_set_toolkit_scroll_bar_thumb): Check if new values
Jan Djärv <jan.h.d@swipnet.se>
parents:
50177
diff
changeset
|
3245 if ((int) adj->page_size != size |
61194aef8668
* gtkutil.c (xg_set_toolkit_scroll_bar_thumb): Check if new values
Jan Djärv <jan.h.d@swipnet.se>
parents:
50177
diff
changeset
|
3246 || (int) adj->step_increment != new_step) |
61194aef8668
* gtkutil.c (xg_set_toolkit_scroll_bar_thumb): Check if new values
Jan Djärv <jan.h.d@swipnet.se>
parents:
50177
diff
changeset
|
3247 { |
50270
fa50953c02dc
Finally (?) fix flicker in scroll bar.
Jan Djärv <jan.h.d@swipnet.se>
parents:
50192
diff
changeset
|
3248 adj->page_size = size; |
fa50953c02dc
Finally (?) fix flicker in scroll bar.
Jan Djärv <jan.h.d@swipnet.se>
parents:
50192
diff
changeset
|
3249 adj->step_increment = new_step; |
50178
61194aef8668
* gtkutil.c (xg_set_toolkit_scroll_bar_thumb): Check if new values
Jan Djärv <jan.h.d@swipnet.se>
parents:
50177
diff
changeset
|
3250 /* Assume a page increment is about 95% of the page size */ |
50270
fa50953c02dc
Finally (?) fix flicker in scroll bar.
Jan Djärv <jan.h.d@swipnet.se>
parents:
50192
diff
changeset
|
3251 adj->page_increment = (int) (0.95*adj->page_size); |
fa50953c02dc
Finally (?) fix flicker in scroll bar.
Jan Djärv <jan.h.d@swipnet.se>
parents:
50192
diff
changeset
|
3252 changed = 1; |
50178
61194aef8668
* gtkutil.c (xg_set_toolkit_scroll_bar_thumb): Check if new values
Jan Djärv <jan.h.d@swipnet.se>
parents:
50177
diff
changeset
|
3253 } |
61194aef8668
* gtkutil.c (xg_set_toolkit_scroll_bar_thumb): Check if new values
Jan Djärv <jan.h.d@swipnet.se>
parents:
50177
diff
changeset
|
3254 |
50270
fa50953c02dc
Finally (?) fix flicker in scroll bar.
Jan Djärv <jan.h.d@swipnet.se>
parents:
50192
diff
changeset
|
3255 if (changed || (int) gtk_range_get_value (GTK_RANGE (wscroll)) != value) |
fa50953c02dc
Finally (?) fix flicker in scroll bar.
Jan Djärv <jan.h.d@swipnet.se>
parents:
50192
diff
changeset
|
3256 { |
fa50953c02dc
Finally (?) fix flicker in scroll bar.
Jan Djärv <jan.h.d@swipnet.se>
parents:
50192
diff
changeset
|
3257 GtkWidget *wfixed = f->output_data.x->edit_widget; |
fa50953c02dc
Finally (?) fix flicker in scroll bar.
Jan Djärv <jan.h.d@swipnet.se>
parents:
50192
diff
changeset
|
3258 |
fa50953c02dc
Finally (?) fix flicker in scroll bar.
Jan Djärv <jan.h.d@swipnet.se>
parents:
50192
diff
changeset
|
3259 BLOCK_INPUT; |
fa50953c02dc
Finally (?) fix flicker in scroll bar.
Jan Djärv <jan.h.d@swipnet.se>
parents:
50192
diff
changeset
|
3260 |
fa50953c02dc
Finally (?) fix flicker in scroll bar.
Jan Djärv <jan.h.d@swipnet.se>
parents:
50192
diff
changeset
|
3261 /* gtk_range_set_value invokes the callback. Set |
fa50953c02dc
Finally (?) fix flicker in scroll bar.
Jan Djärv <jan.h.d@swipnet.se>
parents:
50192
diff
changeset
|
3262 ignore_gtk_scrollbar to make the callback do nothing */ |
fa50953c02dc
Finally (?) fix flicker in scroll bar.
Jan Djärv <jan.h.d@swipnet.se>
parents:
50192
diff
changeset
|
3263 xg_ignore_gtk_scrollbar = 1; |
fa50953c02dc
Finally (?) fix flicker in scroll bar.
Jan Djärv <jan.h.d@swipnet.se>
parents:
50192
diff
changeset
|
3264 |
fa50953c02dc
Finally (?) fix flicker in scroll bar.
Jan Djärv <jan.h.d@swipnet.se>
parents:
50192
diff
changeset
|
3265 if ((int) gtk_range_get_value (GTK_RANGE (wscroll)) != value) |
fa50953c02dc
Finally (?) fix flicker in scroll bar.
Jan Djärv <jan.h.d@swipnet.se>
parents:
50192
diff
changeset
|
3266 gtk_range_set_value (GTK_RANGE (wscroll), (gdouble)value); |
fa50953c02dc
Finally (?) fix flicker in scroll bar.
Jan Djärv <jan.h.d@swipnet.se>
parents:
50192
diff
changeset
|
3267 else if (changed) |
fa50953c02dc
Finally (?) fix flicker in scroll bar.
Jan Djärv <jan.h.d@swipnet.se>
parents:
50192
diff
changeset
|
3268 gtk_adjustment_changed (adj); |
fa50953c02dc
Finally (?) fix flicker in scroll bar.
Jan Djärv <jan.h.d@swipnet.se>
parents:
50192
diff
changeset
|
3269 |
fa50953c02dc
Finally (?) fix flicker in scroll bar.
Jan Djärv <jan.h.d@swipnet.se>
parents:
50192
diff
changeset
|
3270 xg_ignore_gtk_scrollbar = 0; |
fa50953c02dc
Finally (?) fix flicker in scroll bar.
Jan Djärv <jan.h.d@swipnet.se>
parents:
50192
diff
changeset
|
3271 |
fa50953c02dc
Finally (?) fix flicker in scroll bar.
Jan Djärv <jan.h.d@swipnet.se>
parents:
50192
diff
changeset
|
3272 UNBLOCK_INPUT; |
fa50953c02dc
Finally (?) fix flicker in scroll bar.
Jan Djärv <jan.h.d@swipnet.se>
parents:
50192
diff
changeset
|
3273 } |
49323 | 3274 } |
3275 } | |
3276 | |
3277 | |
3278 /*********************************************************************** | |
3279 Tool bar functions | |
3280 ***********************************************************************/ | |
3281 /* The key for the data we put in the GtkImage widgets. The data is | |
3282 the image used by Emacs. We use this to see if we need to update | |
3283 the GtkImage with a new image. */ | |
3284 #define XG_TOOL_BAR_IMAGE_DATA "emacs-tool-bar-image" | |
3285 | |
68874
8ccdd5aee32d
* gtkutil.c (xg_tool_bar_button_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
68651
diff
changeset
|
3286 /* The key for storing the latest modifiers so the activate callback can |
8ccdd5aee32d
* gtkutil.c (xg_tool_bar_button_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
68651
diff
changeset
|
3287 get them. */ |
8ccdd5aee32d
* gtkutil.c (xg_tool_bar_button_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
68651
diff
changeset
|
3288 #define XG_TOOL_BAR_LAST_MODIFIER "emacs-tool-bar-modifier" |
8ccdd5aee32d
* gtkutil.c (xg_tool_bar_button_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
68651
diff
changeset
|
3289 |
8ccdd5aee32d
* gtkutil.c (xg_tool_bar_button_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
68651
diff
changeset
|
3290 |
49323 | 3291 /* Callback function invoked when a tool bar item is pressed. |
3292 W is the button widget in the tool bar that got pressed, | |
3293 CLIENT_DATA is an integer that is the index of the button in the | |
3294 tool bar. 0 is the first button. */ | |
57715
cdc48cdd5b0e
* gtkutil.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57597
diff
changeset
|
3295 |
68874
8ccdd5aee32d
* gtkutil.c (xg_tool_bar_button_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
68651
diff
changeset
|
3296 static gboolean |
8ccdd5aee32d
* gtkutil.c (xg_tool_bar_button_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
68651
diff
changeset
|
3297 xg_tool_bar_button_cb (widget, event, user_data) |
8ccdd5aee32d
* gtkutil.c (xg_tool_bar_button_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
68651
diff
changeset
|
3298 GtkWidget *widget; |
8ccdd5aee32d
* gtkutil.c (xg_tool_bar_button_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
68651
diff
changeset
|
3299 GdkEventButton *event; |
8ccdd5aee32d
* gtkutil.c (xg_tool_bar_button_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
68651
diff
changeset
|
3300 gpointer user_data; |
8ccdd5aee32d
* gtkutil.c (xg_tool_bar_button_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
68651
diff
changeset
|
3301 { |
68922 | 3302 g_object_set_data (G_OBJECT (user_data), XG_TOOL_BAR_LAST_MODIFIER, |
3303 (gpointer) event->state); | |
3304 return FALSE; | |
68874
8ccdd5aee32d
* gtkutil.c (xg_tool_bar_button_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
68651
diff
changeset
|
3305 } |
8ccdd5aee32d
* gtkutil.c (xg_tool_bar_button_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
68651
diff
changeset
|
3306 |
8ccdd5aee32d
* gtkutil.c (xg_tool_bar_button_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
68651
diff
changeset
|
3307 |
49323 | 3308 static void |
3309 xg_tool_bar_callback (w, client_data) | |
3310 GtkWidget *w; | |
3311 gpointer client_data; | |
3312 { | |
59411
ecb6689e04bf
* gtkutil.c (xg_gtk_scroll_destroy, xg_create_scroll_bar)
Jan Djärv <jan.h.d@swipnet.se>
parents:
59102
diff
changeset
|
3313 /* The EMACS_INT cast avoids a warning. */ |
ecb6689e04bf
* gtkutil.c (xg_gtk_scroll_destroy, xg_create_scroll_bar)
Jan Djärv <jan.h.d@swipnet.se>
parents:
59102
diff
changeset
|
3314 int idx = (int) (EMACS_INT) client_data; |
68874
8ccdd5aee32d
* gtkutil.c (xg_tool_bar_button_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
68651
diff
changeset
|
3315 int mod = (int) g_object_get_data (G_OBJECT (w), XG_TOOL_BAR_LAST_MODIFIER); |
8ccdd5aee32d
* gtkutil.c (xg_tool_bar_button_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
68651
diff
changeset
|
3316 |
49323 | 3317 FRAME_PTR f = (FRAME_PTR) g_object_get_data (G_OBJECT (w), XG_FRAME_DATA); |
3318 Lisp_Object key, frame; | |
3319 struct input_event event; | |
51569
e7bd8581e306
(xg_tool_bar_callback): Don't pass uninitialized
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51432
diff
changeset
|
3320 EVENT_INIT (event); |
49323 | 3321 |
3322 if (! f || ! f->n_tool_bar_items || NILP (f->tool_bar_items)) | |
3323 return; | |
3324 | |
3325 idx *= TOOL_BAR_ITEM_NSLOTS; | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
3326 |
49323 | 3327 key = AREF (f->tool_bar_items, idx + TOOL_BAR_ITEM_KEY); |
3328 XSETFRAME (frame, f); | |
3329 event.kind = TOOL_BAR_EVENT; | |
3330 event.frame_or_window = frame; | |
3331 event.arg = frame; | |
3332 kbd_buffer_store_event (&event); | |
3333 | |
3334 event.kind = TOOL_BAR_EVENT; | |
3335 event.frame_or_window = frame; | |
3336 event.arg = key; | |
68874
8ccdd5aee32d
* gtkutil.c (xg_tool_bar_button_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
68651
diff
changeset
|
3337 /* Convert between the modifier bits GDK uses and the modifier bits |
8ccdd5aee32d
* gtkutil.c (xg_tool_bar_button_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
68651
diff
changeset
|
3338 Emacs uses. This assumes GDK an X masks are the same, which they are when |
8ccdd5aee32d
* gtkutil.c (xg_tool_bar_button_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
68651
diff
changeset
|
3339 this is written. */ |
8ccdd5aee32d
* gtkutil.c (xg_tool_bar_button_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
68651
diff
changeset
|
3340 event.modifiers = x_x_to_emacs_modifiers (FRAME_X_DISPLAY_INFO (f), mod); |
49323 | 3341 kbd_buffer_store_event (&event); |
3342 } | |
3343 | |
3344 /* This callback is called when a tool bar is detached. We must set | |
3345 the height of the tool bar to zero when this happens so frame sizes | |
3346 are correctly calculated. | |
3347 WBOX is the handle box widget that enables detach/attach of the tool bar. | |
3348 W is the tool bar widget. | |
3349 CLIENT_DATA is a pointer to the frame the tool bar belongs to. */ | |
57715
cdc48cdd5b0e
* gtkutil.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57597
diff
changeset
|
3350 |
49323 | 3351 static void |
3352 xg_tool_bar_detach_callback (wbox, w, client_data) | |
3353 GtkHandleBox *wbox; | |
3354 GtkWidget *w; | |
3355 gpointer client_data; | |
3356 { | |
3357 FRAME_PTR f = (FRAME_PTR) client_data; | |
68879
3249a3dd3284
* gtkutil.c (xg_tool_bar_detach_callback): Set show-arrow to the
Jan Djärv <jan.h.d@swipnet.se>
parents:
68874
diff
changeset
|
3358 extern int x_gtk_whole_detached_tool_bar; |
3249a3dd3284
* gtkutil.c (xg_tool_bar_detach_callback): Set show-arrow to the
Jan Djärv <jan.h.d@swipnet.se>
parents:
68874
diff
changeset
|
3359 |
3249a3dd3284
* gtkutil.c (xg_tool_bar_detach_callback): Set show-arrow to the
Jan Djärv <jan.h.d@swipnet.se>
parents:
68874
diff
changeset
|
3360 g_object_set (G_OBJECT (w), "show-arrow", !x_gtk_whole_detached_tool_bar, |
3249a3dd3284
* gtkutil.c (xg_tool_bar_detach_callback): Set show-arrow to the
Jan Djärv <jan.h.d@swipnet.se>
parents:
68874
diff
changeset
|
3361 NULL); |
49323 | 3362 |
3363 if (f) | |
3364 { | |
59420
eb72706060ad
* xterm.h (struct x_output): New member, toolbar_detached.
Jan Djärv <jan.h.d@swipnet.se>
parents:
59411
diff
changeset
|
3365 FRAME_X_OUTPUT (f)->toolbar_detached = 1; |
eb72706060ad
* xterm.h (struct x_output): New member, toolbar_detached.
Jan Djärv <jan.h.d@swipnet.se>
parents:
59411
diff
changeset
|
3366 |
49323 | 3367 /* When detaching a tool bar, not everything dissapear. There are |
3368 a few pixels left that are used to drop the tool bar back into | |
3369 place. */ | |
3370 FRAME_TOOLBAR_HEIGHT (f) = 2; | |
3371 | |
3372 /* The height has changed, resize outer widget and set columns | |
3373 rows to what we had before detaching the tool bar. */ | |
51211
28ea05de2dc5
Make (many) trivial substitutions for renamed and
Kim F. Storm <storm@cua.dk>
parents:
50778
diff
changeset
|
3374 xg_resize_outer_widget (f, FRAME_COLS (f), FRAME_LINES (f)); |
49323 | 3375 } |
3376 } | |
3377 | |
3378 /* This callback is called when a tool bar is reattached. We must set | |
3379 the height of the tool bar when this happens so frame sizes | |
3380 are correctly calculated. | |
3381 WBOX is the handle box widget that enables detach/attach of the tool bar. | |
3382 W is the tool bar widget. | |
3383 CLIENT_DATA is a pointer to the frame the tool bar belongs to. */ | |
57715
cdc48cdd5b0e
* gtkutil.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57597
diff
changeset
|
3384 |
49323 | 3385 static void |
3386 xg_tool_bar_attach_callback (wbox, w, client_data) | |
3387 GtkHandleBox *wbox; | |
3388 GtkWidget *w; | |
3389 gpointer client_data; | |
3390 { | |
3391 FRAME_PTR f = (FRAME_PTR) client_data; | |
68879
3249a3dd3284
* gtkutil.c (xg_tool_bar_detach_callback): Set show-arrow to the
Jan Djärv <jan.h.d@swipnet.se>
parents:
68874
diff
changeset
|
3392 g_object_set (G_OBJECT (w), "show-arrow", TRUE, NULL); |
49323 | 3393 |
3394 if (f) | |
3395 { | |
3396 GtkRequisition req; | |
3397 | |
59420
eb72706060ad
* xterm.h (struct x_output): New member, toolbar_detached.
Jan Djärv <jan.h.d@swipnet.se>
parents:
59411
diff
changeset
|
3398 FRAME_X_OUTPUT (f)->toolbar_detached = 0; |
eb72706060ad
* xterm.h (struct x_output): New member, toolbar_detached.
Jan Djärv <jan.h.d@swipnet.se>
parents:
59411
diff
changeset
|
3399 |
49323 | 3400 gtk_widget_size_request (w, &req); |
3401 FRAME_TOOLBAR_HEIGHT (f) = req.height; | |
3402 | |
3403 /* The height has changed, resize outer widget and set columns | |
59420
eb72706060ad
* xterm.h (struct x_output): New member, toolbar_detached.
Jan Djärv <jan.h.d@swipnet.se>
parents:
59411
diff
changeset
|
3404 rows to what we had before attaching the tool bar. */ |
51211
28ea05de2dc5
Make (many) trivial substitutions for renamed and
Kim F. Storm <storm@cua.dk>
parents:
50778
diff
changeset
|
3405 xg_resize_outer_widget (f, FRAME_COLS (f), FRAME_LINES (f)); |
49323 | 3406 } |
3407 } | |
3408 | |
3409 /* This callback is called when the mouse enters or leaves a tool bar item. | |
3410 It is used for displaying and hiding the help text. | |
3411 W is the tool bar item, a button. | |
3412 EVENT is either an enter event or leave event. | |
3413 CLIENT_DATA is an integer that is the index of the button in the | |
3414 tool bar. 0 is the first button. | |
3415 | |
3416 Returns FALSE to tell GTK to keep processing this event. */ | |
57715
cdc48cdd5b0e
* gtkutil.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57597
diff
changeset
|
3417 |
49323 | 3418 static gboolean |
3419 xg_tool_bar_help_callback (w, event, client_data) | |
3420 GtkWidget *w; | |
3421 GdkEventCrossing *event; | |
3422 gpointer client_data; | |
3423 { | |
59411
ecb6689e04bf
* gtkutil.c (xg_gtk_scroll_destroy, xg_create_scroll_bar)
Jan Djärv <jan.h.d@swipnet.se>
parents:
59102
diff
changeset
|
3424 /* The EMACS_INT cast avoids a warning. */ |
ecb6689e04bf
* gtkutil.c (xg_gtk_scroll_destroy, xg_create_scroll_bar)
Jan Djärv <jan.h.d@swipnet.se>
parents:
59102
diff
changeset
|
3425 int idx = (int) (EMACS_INT) client_data; |
49323 | 3426 FRAME_PTR f = (FRAME_PTR) g_object_get_data (G_OBJECT (w), XG_FRAME_DATA); |
3427 Lisp_Object help, frame; | |
3428 | |
3429 if (! GTK_IS_BUTTON (w)) | |
68500
4e4d545ce006
* gtkutil.c (update_frame_tool_bar): Use new tool bar functions
Jan Djärv <jan.h.d@swipnet.se>
parents:
68100
diff
changeset
|
3430 return FALSE; |
49323 | 3431 |
3432 if (! f || ! f->n_tool_bar_items || NILP (f->tool_bar_items)) | |
50108
a9ff586d3d09
(xg_tool_bar_help_callback): Add missing return value.
Andreas Schwab <schwab@suse.de>
parents:
50106
diff
changeset
|
3433 return FALSE; |
49323 | 3434 |
3435 if (event->type == GDK_ENTER_NOTIFY) | |
3436 { | |
3437 idx *= TOOL_BAR_ITEM_NSLOTS; | |
3438 help = AREF (f->tool_bar_items, idx + TOOL_BAR_ITEM_HELP); | |
3439 | |
3440 if (NILP (help)) | |
3441 help = AREF (f->tool_bar_items, idx + TOOL_BAR_ITEM_CAPTION); | |
3442 } | |
3443 else | |
3444 help = Qnil; | |
3445 | |
3446 XSETFRAME (frame, f); | |
3447 kbd_buffer_store_help_event (frame, help); | |
3448 | |
3449 return FALSE; | |
3450 } | |
3451 | |
3452 | |
49826
e99f1a981a3b
* gtkutil.c (xg_tool_bar_expose_callback): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
49600
diff
changeset
|
3453 /* This callback is called when a tool bar item shall be redrawn. |
e99f1a981a3b
* gtkutil.c (xg_tool_bar_expose_callback): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
49600
diff
changeset
|
3454 It modifies the expose event so that the GtkImage widget redraws the |
e99f1a981a3b
* gtkutil.c (xg_tool_bar_expose_callback): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
49600
diff
changeset
|
3455 whole image. This to overcome a bug that makes GtkImage draw the image |
e99f1a981a3b
* gtkutil.c (xg_tool_bar_expose_callback): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
49600
diff
changeset
|
3456 in the wrong place when it tries to redraw just a part of the image. |
e99f1a981a3b
* gtkutil.c (xg_tool_bar_expose_callback): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
49600
diff
changeset
|
3457 W is the GtkImage to be redrawn. |
e99f1a981a3b
* gtkutil.c (xg_tool_bar_expose_callback): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
49600
diff
changeset
|
3458 EVENT is the expose event for W. |
e99f1a981a3b
* gtkutil.c (xg_tool_bar_expose_callback): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
49600
diff
changeset
|
3459 CLIENT_DATA is unused. |
e99f1a981a3b
* gtkutil.c (xg_tool_bar_expose_callback): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
49600
diff
changeset
|
3460 |
e99f1a981a3b
* gtkutil.c (xg_tool_bar_expose_callback): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
49600
diff
changeset
|
3461 Returns FALSE to tell GTK to keep processing this event. */ |
57715
cdc48cdd5b0e
* gtkutil.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57597
diff
changeset
|
3462 |
49826
e99f1a981a3b
* gtkutil.c (xg_tool_bar_expose_callback): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
49600
diff
changeset
|
3463 static gboolean |
50063 | 3464 xg_tool_bar_item_expose_callback (w, event, client_data) |
49826
e99f1a981a3b
* gtkutil.c (xg_tool_bar_expose_callback): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
49600
diff
changeset
|
3465 GtkWidget *w; |
e99f1a981a3b
* gtkutil.c (xg_tool_bar_expose_callback): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
49600
diff
changeset
|
3466 GdkEventExpose *event; |
e99f1a981a3b
* gtkutil.c (xg_tool_bar_expose_callback): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
49600
diff
changeset
|
3467 gpointer client_data; |
e99f1a981a3b
* gtkutil.c (xg_tool_bar_expose_callback): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
49600
diff
changeset
|
3468 { |
50333
60da21fd968b
* gtkutil.c (xg_tool_bar_item_expose_callback): Reduce size
Jan Djärv <jan.h.d@swipnet.se>
parents:
50318
diff
changeset
|
3469 gint width, height; |
60da21fd968b
* gtkutil.c (xg_tool_bar_item_expose_callback): Reduce size
Jan Djärv <jan.h.d@swipnet.se>
parents:
50318
diff
changeset
|
3470 |
60da21fd968b
* gtkutil.c (xg_tool_bar_item_expose_callback): Reduce size
Jan Djärv <jan.h.d@swipnet.se>
parents:
50318
diff
changeset
|
3471 gdk_drawable_get_size (event->window, &width, &height); |
60da21fd968b
* gtkutil.c (xg_tool_bar_item_expose_callback): Reduce size
Jan Djärv <jan.h.d@swipnet.se>
parents:
50318
diff
changeset
|
3472 |
60da21fd968b
* gtkutil.c (xg_tool_bar_item_expose_callback): Reduce size
Jan Djärv <jan.h.d@swipnet.se>
parents:
50318
diff
changeset
|
3473 event->area.x -= width > event->area.width ? width-event->area.width : 0; |
60da21fd968b
* gtkutil.c (xg_tool_bar_item_expose_callback): Reduce size
Jan Djärv <jan.h.d@swipnet.se>
parents:
50318
diff
changeset
|
3474 event->area.y -= height > event->area.height ? height-event->area.height : 0; |
60da21fd968b
* gtkutil.c (xg_tool_bar_item_expose_callback): Reduce size
Jan Djärv <jan.h.d@swipnet.se>
parents:
50318
diff
changeset
|
3475 |
53069
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
3476 event->area.x = max (0, event->area.x); |
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
3477 event->area.y = max (0, event->area.y); |
60185
391f44959566
(xg_create_frame_widgets): UNBLOCK_INPUT on error.
Kim F. Storm <storm@cua.dk>
parents:
59913
diff
changeset
|
3478 |
50333
60da21fd968b
* gtkutil.c (xg_tool_bar_item_expose_callback): Reduce size
Jan Djärv <jan.h.d@swipnet.se>
parents:
50318
diff
changeset
|
3479 event->area.width = max (width, event->area.width); |
60da21fd968b
* gtkutil.c (xg_tool_bar_item_expose_callback): Reduce size
Jan Djärv <jan.h.d@swipnet.se>
parents:
50318
diff
changeset
|
3480 event->area.height = max (height, event->area.height); |
60185
391f44959566
(xg_create_frame_widgets): UNBLOCK_INPUT on error.
Kim F. Storm <storm@cua.dk>
parents:
59913
diff
changeset
|
3481 |
49826
e99f1a981a3b
* gtkutil.c (xg_tool_bar_expose_callback): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
49600
diff
changeset
|
3482 return FALSE; |
e99f1a981a3b
* gtkutil.c (xg_tool_bar_expose_callback): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
49600
diff
changeset
|
3483 } |
e99f1a981a3b
* gtkutil.c (xg_tool_bar_expose_callback): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
49600
diff
changeset
|
3484 |
50063 | 3485 /* This callback is called when a tool bar shall be redrawn. |
3486 We need to update the tool bar from here in case the image cache | |
3487 has deleted the pixmaps used in the tool bar. | |
3488 W is the GtkToolbar to be redrawn. | |
3489 EVENT is the expose event for W. | |
3490 CLIENT_DATA is pointing to the frame for this tool bar. | |
3491 | |
3492 Returns FALSE to tell GTK to keep processing this event. */ | |
57715
cdc48cdd5b0e
* gtkutil.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57597
diff
changeset
|
3493 |
50063 | 3494 static gboolean |
3495 xg_tool_bar_expose_callback (w, event, client_data) | |
3496 GtkWidget *w; | |
3497 GdkEventExpose *event; | |
3498 gpointer client_data; | |
3499 { | |
53069
1218a42792ea
Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
3500 update_frame_tool_bar ((FRAME_PTR) client_data); |
50063 | 3501 return FALSE; |
3502 } | |
3503 | |
57715
cdc48cdd5b0e
* gtkutil.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57597
diff
changeset
|
3504 /* Create a tool bar for frame F. */ |
cdc48cdd5b0e
* gtkutil.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57597
diff
changeset
|
3505 |
49323 | 3506 static void |
3507 xg_create_tool_bar (f) | |
3508 FRAME_PTR f; | |
3509 { | |
3510 struct x_output *x = f->output_data.x; | |
3511 GtkRequisition req; | |
3512 int vbox_pos = x->menubar_widget ? 1 : 0; | |
3513 | |
3514 x->toolbar_widget = gtk_toolbar_new (); | |
3515 x->handlebox_widget = gtk_handle_box_new (); | |
59420
eb72706060ad
* xterm.h (struct x_output): New member, toolbar_detached.
Jan Djärv <jan.h.d@swipnet.se>
parents:
59411
diff
changeset
|
3516 x->toolbar_detached = 0; |
eb72706060ad
* xterm.h (struct x_output): New member, toolbar_detached.
Jan Djärv <jan.h.d@swipnet.se>
parents:
59411
diff
changeset
|
3517 |
49323 | 3518 gtk_container_add (GTK_CONTAINER (x->handlebox_widget), |
3519 x->toolbar_widget); | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
3520 |
49323 | 3521 gtk_box_pack_start (GTK_BOX (x->vbox_widget), x->handlebox_widget, |
3522 FALSE, FALSE, 0); | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
3523 |
49323 | 3524 gtk_box_reorder_child (GTK_BOX (x->vbox_widget), x->handlebox_widget, |
3525 vbox_pos); | |
3526 | |
49826
e99f1a981a3b
* gtkutil.c (xg_tool_bar_expose_callback): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
49600
diff
changeset
|
3527 gtk_widget_set_name (x->toolbar_widget, "emacs-toolbar"); |
e99f1a981a3b
* gtkutil.c (xg_tool_bar_expose_callback): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
49600
diff
changeset
|
3528 |
e99f1a981a3b
* gtkutil.c (xg_tool_bar_expose_callback): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
49600
diff
changeset
|
3529 /* We only have icons, so override any user setting. We could |
e99f1a981a3b
* gtkutil.c (xg_tool_bar_expose_callback): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
49600
diff
changeset
|
3530 use the caption property of the toolbar item (see update_frame_tool_bar |
e99f1a981a3b
* gtkutil.c (xg_tool_bar_expose_callback): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
49600
diff
changeset
|
3531 below), but some of those strings are long, making the toolbar so |
e99f1a981a3b
* gtkutil.c (xg_tool_bar_expose_callback): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
49600
diff
changeset
|
3532 long it does not fit on the screen. The GtkToolbar widget makes every |
e99f1a981a3b
* gtkutil.c (xg_tool_bar_expose_callback): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
49600
diff
changeset
|
3533 item equal size, so the longest caption determine the size of every |
e99f1a981a3b
* gtkutil.c (xg_tool_bar_expose_callback): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
49600
diff
changeset
|
3534 tool bar item. I think the creators of the GtkToolbar widget |
e99f1a981a3b
* gtkutil.c (xg_tool_bar_expose_callback): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
49600
diff
changeset
|
3535 counted on 4 or 5 character long strings. */ |
e99f1a981a3b
* gtkutil.c (xg_tool_bar_expose_callback): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
49600
diff
changeset
|
3536 gtk_toolbar_set_style (GTK_TOOLBAR (x->toolbar_widget), GTK_TOOLBAR_ICONS); |
e99f1a981a3b
* gtkutil.c (xg_tool_bar_expose_callback): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
49600
diff
changeset
|
3537 gtk_toolbar_set_orientation (GTK_TOOLBAR (x->toolbar_widget), |
e99f1a981a3b
* gtkutil.c (xg_tool_bar_expose_callback): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
49600
diff
changeset
|
3538 GTK_ORIENTATION_HORIZONTAL); |
e99f1a981a3b
* gtkutil.c (xg_tool_bar_expose_callback): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
49600
diff
changeset
|
3539 |
49323 | 3540 g_signal_connect (G_OBJECT (x->handlebox_widget), "child-detached", |
3541 G_CALLBACK (xg_tool_bar_detach_callback), f); | |
3542 g_signal_connect (G_OBJECT (x->handlebox_widget), "child-attached", | |
3543 G_CALLBACK (xg_tool_bar_attach_callback), f); | |
50063 | 3544 g_signal_connect (G_OBJECT (x->toolbar_widget), |
3545 "expose-event", | |
3546 G_CALLBACK (xg_tool_bar_expose_callback), | |
3547 f); | |
49323 | 3548 |
3549 gtk_widget_show_all (x->handlebox_widget); | |
3550 | |
3551 gtk_widget_size_request (x->toolbar_widget, &req); | |
3552 FRAME_TOOLBAR_HEIGHT (f) = req.height; | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
3553 |
49323 | 3554 /* The height has changed, resize outer widget and set columns |
3555 rows to what we had before adding the tool bar. */ | |
51211
28ea05de2dc5
Make (many) trivial substitutions for renamed and
Kim F. Storm <storm@cua.dk>
parents:
50778
diff
changeset
|
3556 xg_resize_outer_widget (f, FRAME_COLS (f), FRAME_LINES (f)); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
3557 |
49323 | 3558 SET_FRAME_GARBAGED (f); |
3559 } | |
3560 | |
57715
cdc48cdd5b0e
* gtkutil.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57597
diff
changeset
|
3561 /* Update the tool bar for frame F. Add new buttons and remove old. */ |
cdc48cdd5b0e
* gtkutil.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57597
diff
changeset
|
3562 |
49323 | 3563 void |
3564 update_frame_tool_bar (f) | |
3565 FRAME_PTR f; | |
3566 { | |
3567 int i; | |
3568 GtkRequisition old_req, new_req; | |
3569 GList *icon_list; | |
49572 | 3570 GList *iter; |
49323 | 3571 struct x_output *x = f->output_data.x; |
59084
6a0b8f23858b
* gtkutil.c (update_frame_tool_bar): Make the value of
Jan Djärv <jan.h.d@swipnet.se>
parents:
58818
diff
changeset
|
3572 int hmargin, vmargin; |
49323 | 3573 |
3574 if (! FRAME_GTK_WIDGET (f)) | |
3575 return; | |
3576 | |
3577 BLOCK_INPUT; | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
3578 |
59084
6a0b8f23858b
* gtkutil.c (update_frame_tool_bar): Make the value of
Jan Djärv <jan.h.d@swipnet.se>
parents:
58818
diff
changeset
|
3579 if (INTEGERP (Vtool_bar_button_margin) |
6a0b8f23858b
* gtkutil.c (update_frame_tool_bar): Make the value of
Jan Djärv <jan.h.d@swipnet.se>
parents:
58818
diff
changeset
|
3580 && XINT (Vtool_bar_button_margin) > 0) |
6a0b8f23858b
* gtkutil.c (update_frame_tool_bar): Make the value of
Jan Djärv <jan.h.d@swipnet.se>
parents:
58818
diff
changeset
|
3581 { |
6a0b8f23858b
* gtkutil.c (update_frame_tool_bar): Make the value of
Jan Djärv <jan.h.d@swipnet.se>
parents:
58818
diff
changeset
|
3582 hmargin = XFASTINT (Vtool_bar_button_margin); |
6a0b8f23858b
* gtkutil.c (update_frame_tool_bar): Make the value of
Jan Djärv <jan.h.d@swipnet.se>
parents:
58818
diff
changeset
|
3583 vmargin = XFASTINT (Vtool_bar_button_margin); |
6a0b8f23858b
* gtkutil.c (update_frame_tool_bar): Make the value of
Jan Djärv <jan.h.d@swipnet.se>
parents:
58818
diff
changeset
|
3584 } |
6a0b8f23858b
* gtkutil.c (update_frame_tool_bar): Make the value of
Jan Djärv <jan.h.d@swipnet.se>
parents:
58818
diff
changeset
|
3585 else if (CONSP (Vtool_bar_button_margin)) |
6a0b8f23858b
* gtkutil.c (update_frame_tool_bar): Make the value of
Jan Djärv <jan.h.d@swipnet.se>
parents:
58818
diff
changeset
|
3586 { |
6a0b8f23858b
* gtkutil.c (update_frame_tool_bar): Make the value of
Jan Djärv <jan.h.d@swipnet.se>
parents:
58818
diff
changeset
|
3587 if (INTEGERP (XCAR (Vtool_bar_button_margin)) |
6a0b8f23858b
* gtkutil.c (update_frame_tool_bar): Make the value of
Jan Djärv <jan.h.d@swipnet.se>
parents:
58818
diff
changeset
|
3588 && XINT (XCAR (Vtool_bar_button_margin)) > 0) |
6a0b8f23858b
* gtkutil.c (update_frame_tool_bar): Make the value of
Jan Djärv <jan.h.d@swipnet.se>
parents:
58818
diff
changeset
|
3589 hmargin = XFASTINT (XCAR (Vtool_bar_button_margin)); |
6a0b8f23858b
* gtkutil.c (update_frame_tool_bar): Make the value of
Jan Djärv <jan.h.d@swipnet.se>
parents:
58818
diff
changeset
|
3590 |
6a0b8f23858b
* gtkutil.c (update_frame_tool_bar): Make the value of
Jan Djärv <jan.h.d@swipnet.se>
parents:
58818
diff
changeset
|
3591 if (INTEGERP (XCDR (Vtool_bar_button_margin)) |
6a0b8f23858b
* gtkutil.c (update_frame_tool_bar): Make the value of
Jan Djärv <jan.h.d@swipnet.se>
parents:
58818
diff
changeset
|
3592 && XINT (XCDR (Vtool_bar_button_margin)) > 0) |
6a0b8f23858b
* gtkutil.c (update_frame_tool_bar): Make the value of
Jan Djärv <jan.h.d@swipnet.se>
parents:
58818
diff
changeset
|
3593 vmargin = XFASTINT (XCDR (Vtool_bar_button_margin)); |
6a0b8f23858b
* gtkutil.c (update_frame_tool_bar): Make the value of
Jan Djärv <jan.h.d@swipnet.se>
parents:
58818
diff
changeset
|
3594 } |
6a0b8f23858b
* gtkutil.c (update_frame_tool_bar): Make the value of
Jan Djärv <jan.h.d@swipnet.se>
parents:
58818
diff
changeset
|
3595 |
6a0b8f23858b
* gtkutil.c (update_frame_tool_bar): Make the value of
Jan Djärv <jan.h.d@swipnet.se>
parents:
58818
diff
changeset
|
3596 /* The natural size (i.e. when GTK uses 0 as margin) looks best, |
6a0b8f23858b
* gtkutil.c (update_frame_tool_bar): Make the value of
Jan Djärv <jan.h.d@swipnet.se>
parents:
58818
diff
changeset
|
3597 so take DEFAULT_TOOL_BAR_BUTTON_MARGIN to mean "default for GTK", |
6a0b8f23858b
* gtkutil.c (update_frame_tool_bar): Make the value of
Jan Djärv <jan.h.d@swipnet.se>
parents:
58818
diff
changeset
|
3598 i.e. zero. This means that margins less than |
6a0b8f23858b
* gtkutil.c (update_frame_tool_bar): Make the value of
Jan Djärv <jan.h.d@swipnet.se>
parents:
58818
diff
changeset
|
3599 DEFAULT_TOOL_BAR_BUTTON_MARGIN has no effect. */ |
6a0b8f23858b
* gtkutil.c (update_frame_tool_bar): Make the value of
Jan Djärv <jan.h.d@swipnet.se>
parents:
58818
diff
changeset
|
3600 hmargin = max (0, hmargin - DEFAULT_TOOL_BAR_BUTTON_MARGIN); |
6a0b8f23858b
* gtkutil.c (update_frame_tool_bar): Make the value of
Jan Djärv <jan.h.d@swipnet.se>
parents:
58818
diff
changeset
|
3601 vmargin = max (0, vmargin - DEFAULT_TOOL_BAR_BUTTON_MARGIN); |
60185
391f44959566
(xg_create_frame_widgets): UNBLOCK_INPUT on error.
Kim F. Storm <storm@cua.dk>
parents:
59913
diff
changeset
|
3602 |
49323 | 3603 if (! x->toolbar_widget) |
3604 xg_create_tool_bar (f); | |
3605 | |
3606 gtk_widget_size_request (x->toolbar_widget, &old_req); | |
3607 | |
3608 icon_list = gtk_container_get_children (GTK_CONTAINER (x->toolbar_widget)); | |
49572 | 3609 iter = icon_list; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
3610 |
49323 | 3611 for (i = 0; i < f->n_tool_bar_items; ++i) |
3612 { | |
3613 #define PROP(IDX) AREF (f->tool_bar_items, i * TOOL_BAR_ITEM_NSLOTS + (IDX)) | |
3614 | |
3615 int enabled_p = !NILP (PROP (TOOL_BAR_ITEM_ENABLED_P)); | |
3616 int selected_p = !NILP (PROP (TOOL_BAR_ITEM_SELECTED_P)); | |
3617 int idx; | |
3618 int img_id; | |
3619 struct image *img; | |
3620 Lisp_Object image; | |
49572 | 3621 GtkWidget *wicon = iter ? GTK_WIDGET (iter->data) : 0; |
50059
ffb4a4dbe4c0
* gtkutil.c (update_frame_tool_bar): Compare pixmap ID instead of
Jan Djärv <jan.h.d@swipnet.se>
parents:
49826
diff
changeset
|
3622 |
49572 | 3623 if (iter) iter = g_list_next (iter); |
49323 | 3624 |
3625 /* If image is a vector, choose the image according to the | |
3626 button state. */ | |
3627 image = PROP (TOOL_BAR_ITEM_IMAGES); | |
3628 if (VECTORP (image)) | |
3629 { | |
3630 if (enabled_p) | |
3631 idx = (selected_p | |
3632 ? TOOL_BAR_IMAGE_ENABLED_SELECTED | |
3633 : TOOL_BAR_IMAGE_ENABLED_DESELECTED); | |
3634 else | |
3635 idx = (selected_p | |
3636 ? TOOL_BAR_IMAGE_DISABLED_SELECTED | |
3637 : TOOL_BAR_IMAGE_DISABLED_DESELECTED); | |
3638 | |
3639 xassert (ASIZE (image) >= idx); | |
3640 image = AREF (image, idx); | |
3641 } | |
3642 else | |
3643 idx = -1; | |
3644 | |
3645 /* Ignore invalid image specifications. */ | |
3646 if (!valid_image_p (image)) | |
3647 { | |
3648 if (wicon) gtk_widget_hide (wicon); | |
3649 continue; | |
3650 } | |
3651 | |
3652 img_id = lookup_image (f, image); | |
3653 img = IMAGE_FROM_ID (f, img_id); | |
49468
f2be5cd8262f
gtkutil.c (update_frame_tool_bar): Call prepare_image_for_display
Jan Djärv <jan.h.d@swipnet.se>
parents:
49434
diff
changeset
|
3654 prepare_image_for_display (f, img); |
f2be5cd8262f
gtkutil.c (update_frame_tool_bar): Call prepare_image_for_display
Jan Djärv <jan.h.d@swipnet.se>
parents:
49434
diff
changeset
|
3655 |
f2be5cd8262f
gtkutil.c (update_frame_tool_bar): Call prepare_image_for_display
Jan Djärv <jan.h.d@swipnet.se>
parents:
49434
diff
changeset
|
3656 if (img->load_failed_p || img->pixmap == None) |
f2be5cd8262f
gtkutil.c (update_frame_tool_bar): Call prepare_image_for_display
Jan Djärv <jan.h.d@swipnet.se>
parents:
49434
diff
changeset
|
3657 { |
f2be5cd8262f
gtkutil.c (update_frame_tool_bar): Call prepare_image_for_display
Jan Djärv <jan.h.d@swipnet.se>
parents:
49434
diff
changeset
|
3658 if (wicon) gtk_widget_hide (wicon); |
f2be5cd8262f
gtkutil.c (update_frame_tool_bar): Call prepare_image_for_display
Jan Djärv <jan.h.d@swipnet.se>
parents:
49434
diff
changeset
|
3659 continue; |
f2be5cd8262f
gtkutil.c (update_frame_tool_bar): Call prepare_image_for_display
Jan Djärv <jan.h.d@swipnet.se>
parents:
49434
diff
changeset
|
3660 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
3661 |
49323 | 3662 if (! wicon) |
3663 { | |
56112
e4cfda8330d5
* gtkutil.c (xg_get_image_for_pixmap): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
55342
diff
changeset
|
3664 GtkWidget *w = xg_get_image_for_pixmap (f, img, x->widget, NULL); |
68500
4e4d545ce006
* gtkutil.c (update_frame_tool_bar): Use new tool bar functions
Jan Djärv <jan.h.d@swipnet.se>
parents:
68100
diff
changeset
|
3665 GtkToolItem *ti = gtk_tool_button_new (w, ""); |
56112
e4cfda8330d5
* gtkutil.c (xg_get_image_for_pixmap): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
55342
diff
changeset
|
3666 |
59084
6a0b8f23858b
* gtkutil.c (update_frame_tool_bar): Make the value of
Jan Djärv <jan.h.d@swipnet.se>
parents:
58818
diff
changeset
|
3667 gtk_misc_set_padding (GTK_MISC (w), hmargin, vmargin); |
6a0b8f23858b
* gtkutil.c (update_frame_tool_bar): Make the value of
Jan Djärv <jan.h.d@swipnet.se>
parents:
58818
diff
changeset
|
3668 |
68500
4e4d545ce006
* gtkutil.c (update_frame_tool_bar): Use new tool bar functions
Jan Djärv <jan.h.d@swipnet.se>
parents:
68100
diff
changeset
|
3669 gtk_toolbar_insert (GTK_TOOLBAR (x->toolbar_widget), |
4e4d545ce006
* gtkutil.c (update_frame_tool_bar): Use new tool bar functions
Jan Djärv <jan.h.d@swipnet.se>
parents:
68100
diff
changeset
|
3670 ti, |
4e4d545ce006
* gtkutil.c (update_frame_tool_bar): Use new tool bar functions
Jan Djärv <jan.h.d@swipnet.se>
parents:
68100
diff
changeset
|
3671 i); |
59411
ecb6689e04bf
* gtkutil.c (xg_gtk_scroll_destroy, xg_create_scroll_bar)
Jan Djärv <jan.h.d@swipnet.se>
parents:
59102
diff
changeset
|
3672 /* The EMACS_INT cast avoids a warning. */ |
68500
4e4d545ce006
* gtkutil.c (update_frame_tool_bar): Use new tool bar functions
Jan Djärv <jan.h.d@swipnet.se>
parents:
68100
diff
changeset
|
3673 g_signal_connect (GTK_WIDGET (ti), "clicked", |
4e4d545ce006
* gtkutil.c (update_frame_tool_bar): Use new tool bar functions
Jan Djärv <jan.h.d@swipnet.se>
parents:
68100
diff
changeset
|
3674 GTK_SIGNAL_FUNC (xg_tool_bar_callback), |
4e4d545ce006
* gtkutil.c (update_frame_tool_bar): Use new tool bar functions
Jan Djärv <jan.h.d@swipnet.se>
parents:
68100
diff
changeset
|
3675 (gpointer) (EMACS_INT) i); |
4e4d545ce006
* gtkutil.c (update_frame_tool_bar): Use new tool bar functions
Jan Djärv <jan.h.d@swipnet.se>
parents:
68100
diff
changeset
|
3676 |
4e4d545ce006
* gtkutil.c (update_frame_tool_bar): Use new tool bar functions
Jan Djärv <jan.h.d@swipnet.se>
parents:
68100
diff
changeset
|
3677 gtk_widget_show (GTK_WIDGET (ti)); |
4e4d545ce006
* gtkutil.c (update_frame_tool_bar): Use new tool bar functions
Jan Djärv <jan.h.d@swipnet.se>
parents:
68100
diff
changeset
|
3678 gtk_widget_show (GTK_WIDGET (w)); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
3679 |
49323 | 3680 /* Save the image so we can see if an update is needed when |
3681 this function is called again. */ | |
3682 g_object_set_data (G_OBJECT (w), XG_TOOL_BAR_IMAGE_DATA, | |
50059
ffb4a4dbe4c0
* gtkutil.c (update_frame_tool_bar): Compare pixmap ID instead of
Jan Djärv <jan.h.d@swipnet.se>
parents:
49826
diff
changeset
|
3683 (gpointer)img->pixmap); |
49323 | 3684 |
68500
4e4d545ce006
* gtkutil.c (update_frame_tool_bar): Use new tool bar functions
Jan Djärv <jan.h.d@swipnet.se>
parents:
68100
diff
changeset
|
3685 g_object_set_data (G_OBJECT (ti), XG_FRAME_DATA, (gpointer)f); |
4e4d545ce006
* gtkutil.c (update_frame_tool_bar): Use new tool bar functions
Jan Djärv <jan.h.d@swipnet.se>
parents:
68100
diff
changeset
|
3686 |
49826
e99f1a981a3b
* gtkutil.c (xg_tool_bar_expose_callback): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
49600
diff
changeset
|
3687 /* Catch expose events to overcome an annoying redraw bug, see |
50063 | 3688 comment for xg_tool_bar_item_expose_callback. */ |
68500
4e4d545ce006
* gtkutil.c (update_frame_tool_bar): Use new tool bar functions
Jan Djärv <jan.h.d@swipnet.se>
parents:
68100
diff
changeset
|
3689 g_signal_connect (G_OBJECT (ti), |
49826
e99f1a981a3b
* gtkutil.c (xg_tool_bar_expose_callback): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
49600
diff
changeset
|
3690 "expose-event", |
50063 | 3691 G_CALLBACK (xg_tool_bar_item_expose_callback), |
49826
e99f1a981a3b
* gtkutil.c (xg_tool_bar_expose_callback): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
49600
diff
changeset
|
3692 0); |
e99f1a981a3b
* gtkutil.c (xg_tool_bar_expose_callback): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
49600
diff
changeset
|
3693 |
68500
4e4d545ce006
* gtkutil.c (update_frame_tool_bar): Use new tool bar functions
Jan Djärv <jan.h.d@swipnet.se>
parents:
68100
diff
changeset
|
3694 gtk_widget_set_sensitive (GTK_WIDGET (ti), enabled_p); |
4e4d545ce006
* gtkutil.c (update_frame_tool_bar): Use new tool bar functions
Jan Djärv <jan.h.d@swipnet.se>
parents:
68100
diff
changeset
|
3695 gtk_tool_item_set_homogeneous (GTK_TOOL_ITEM (ti), FALSE); |
4e4d545ce006
* gtkutil.c (update_frame_tool_bar): Use new tool bar functions
Jan Djärv <jan.h.d@swipnet.se>
parents:
68100
diff
changeset
|
3696 |
49323 | 3697 while (! GTK_IS_BUTTON (w)) |
3698 w = gtk_widget_get_parent (w); | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
3699 |
68874
8ccdd5aee32d
* gtkutil.c (xg_tool_bar_button_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
68651
diff
changeset
|
3700 /* Callback to save modifyer mask (Shift/Control, etc). GTK makes |
8ccdd5aee32d
* gtkutil.c (xg_tool_bar_button_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
68651
diff
changeset
|
3701 no distinction based on modifiers in the activate callback, |
8ccdd5aee32d
* gtkutil.c (xg_tool_bar_button_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
68651
diff
changeset
|
3702 so we have to do it ourselves. */ |
8ccdd5aee32d
* gtkutil.c (xg_tool_bar_button_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
68651
diff
changeset
|
3703 g_signal_connect (w, "button-release-event", |
8ccdd5aee32d
* gtkutil.c (xg_tool_bar_button_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
68651
diff
changeset
|
3704 GTK_SIGNAL_FUNC (xg_tool_bar_button_cb), |
8ccdd5aee32d
* gtkutil.c (xg_tool_bar_button_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
68651
diff
changeset
|
3705 ti); |
8ccdd5aee32d
* gtkutil.c (xg_tool_bar_button_cb): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
68651
diff
changeset
|
3706 |
68500
4e4d545ce006
* gtkutil.c (update_frame_tool_bar): Use new tool bar functions
Jan Djärv <jan.h.d@swipnet.se>
parents:
68100
diff
changeset
|
3707 g_object_set_data (G_OBJECT (w), XG_FRAME_DATA, (gpointer)f); |
4e4d545ce006
* gtkutil.c (update_frame_tool_bar): Use new tool bar functions
Jan Djärv <jan.h.d@swipnet.se>
parents:
68100
diff
changeset
|
3708 |
4e4d545ce006
* gtkutil.c (update_frame_tool_bar): Use new tool bar functions
Jan Djärv <jan.h.d@swipnet.se>
parents:
68100
diff
changeset
|
3709 /* Use enter/leave notify to show help. We use the events |
4e4d545ce006
* gtkutil.c (update_frame_tool_bar): Use new tool bar functions
Jan Djärv <jan.h.d@swipnet.se>
parents:
68100
diff
changeset
|
3710 rather than the GtkButton specific signals "enter" and |
4e4d545ce006
* gtkutil.c (update_frame_tool_bar): Use new tool bar functions
Jan Djärv <jan.h.d@swipnet.se>
parents:
68100
diff
changeset
|
3711 "leave", so we can have only one callback. The event |
4e4d545ce006
* gtkutil.c (update_frame_tool_bar): Use new tool bar functions
Jan Djärv <jan.h.d@swipnet.se>
parents:
68100
diff
changeset
|
3712 will tell us what kind of event it is. */ |
4e4d545ce006
* gtkutil.c (update_frame_tool_bar): Use new tool bar functions
Jan Djärv <jan.h.d@swipnet.se>
parents:
68100
diff
changeset
|
3713 /* The EMACS_INT cast avoids a warning. */ |
4e4d545ce006
* gtkutil.c (update_frame_tool_bar): Use new tool bar functions
Jan Djärv <jan.h.d@swipnet.se>
parents:
68100
diff
changeset
|
3714 g_signal_connect (G_OBJECT (w), |
4e4d545ce006
* gtkutil.c (update_frame_tool_bar): Use new tool bar functions
Jan Djärv <jan.h.d@swipnet.se>
parents:
68100
diff
changeset
|
3715 "enter-notify-event", |
4e4d545ce006
* gtkutil.c (update_frame_tool_bar): Use new tool bar functions
Jan Djärv <jan.h.d@swipnet.se>
parents:
68100
diff
changeset
|
3716 G_CALLBACK (xg_tool_bar_help_callback), |
4e4d545ce006
* gtkutil.c (update_frame_tool_bar): Use new tool bar functions
Jan Djärv <jan.h.d@swipnet.se>
parents:
68100
diff
changeset
|
3717 (gpointer) (EMACS_INT) i); |
4e4d545ce006
* gtkutil.c (update_frame_tool_bar): Use new tool bar functions
Jan Djärv <jan.h.d@swipnet.se>
parents:
68100
diff
changeset
|
3718 g_signal_connect (G_OBJECT (w), |
4e4d545ce006
* gtkutil.c (update_frame_tool_bar): Use new tool bar functions
Jan Djärv <jan.h.d@swipnet.se>
parents:
68100
diff
changeset
|
3719 "leave-notify-event", |
4e4d545ce006
* gtkutil.c (update_frame_tool_bar): Use new tool bar functions
Jan Djärv <jan.h.d@swipnet.se>
parents:
68100
diff
changeset
|
3720 G_CALLBACK (xg_tool_bar_help_callback), |
4e4d545ce006
* gtkutil.c (update_frame_tool_bar): Use new tool bar functions
Jan Djärv <jan.h.d@swipnet.se>
parents:
68100
diff
changeset
|
3721 (gpointer) (EMACS_INT) i); |
49323 | 3722 } |
3723 else | |
3724 { | |
3725 /* The child of the tool bar is a button. Inside that button | |
3726 is a vbox. Inside that vbox is the GtkImage. */ | |
3727 GtkWidget *wvbox = gtk_bin_get_child (GTK_BIN (wicon)); | |
49572 | 3728 GList *chlist = gtk_container_get_children (GTK_CONTAINER (wvbox)); |
3729 GtkImage *wimage = GTK_IMAGE (chlist->data); | |
50059
ffb4a4dbe4c0
* gtkutil.c (update_frame_tool_bar): Compare pixmap ID instead of
Jan Djärv <jan.h.d@swipnet.se>
parents:
49826
diff
changeset
|
3730 Pixmap old_img = (Pixmap)g_object_get_data (G_OBJECT (wimage), |
ffb4a4dbe4c0
* gtkutil.c (update_frame_tool_bar): Compare pixmap ID instead of
Jan Djärv <jan.h.d@swipnet.se>
parents:
49826
diff
changeset
|
3731 XG_TOOL_BAR_IMAGE_DATA); |
49572 | 3732 g_list_free (chlist); |
49323 | 3733 |
59084
6a0b8f23858b
* gtkutil.c (update_frame_tool_bar): Make the value of
Jan Djärv <jan.h.d@swipnet.se>
parents:
58818
diff
changeset
|
3734 gtk_misc_set_padding (GTK_MISC (wimage), hmargin, vmargin); |
6a0b8f23858b
* gtkutil.c (update_frame_tool_bar): Make the value of
Jan Djärv <jan.h.d@swipnet.se>
parents:
58818
diff
changeset
|
3735 |
50059
ffb4a4dbe4c0
* gtkutil.c (update_frame_tool_bar): Compare pixmap ID instead of
Jan Djärv <jan.h.d@swipnet.se>
parents:
49826
diff
changeset
|
3736 if (old_img != img->pixmap) |
56112
e4cfda8330d5
* gtkutil.c (xg_get_image_for_pixmap): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents:
55342
diff
changeset
|
3737 (void) xg_get_image_for_pixmap (f, img, x->widget, wimage); |
49323 | 3738 |
3739 g_object_set_data (G_OBJECT (wimage), XG_TOOL_BAR_IMAGE_DATA, | |
50059
ffb4a4dbe4c0
* gtkutil.c (update_frame_tool_bar): Compare pixmap ID instead of
Jan Djärv <jan.h.d@swipnet.se>
parents:
49826
diff
changeset
|
3740 (gpointer)img->pixmap); |
49323 | 3741 |
3742 gtk_widget_set_sensitive (wicon, enabled_p); | |
3743 gtk_widget_show (wicon); | |
3744 } | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
3745 |
49323 | 3746 #undef PROP |
3747 } | |
3748 | |
3749 /* Remove buttons not longer needed. We just hide them so they | |
3750 can be reused later on. */ | |
49572 | 3751 while (iter) |
49323 | 3752 { |
49572 | 3753 GtkWidget *w = GTK_WIDGET (iter->data); |
49323 | 3754 gtk_widget_hide (w); |
49572 | 3755 iter = g_list_next (iter); |
49323 | 3756 } |
3757 | |
3758 gtk_widget_size_request (x->toolbar_widget, &new_req); | |
59420
eb72706060ad
* xterm.h (struct x_output): New member, toolbar_detached.
Jan Djärv <jan.h.d@swipnet.se>
parents:
59411
diff
changeset
|
3759 if (old_req.height != new_req.height |
eb72706060ad
* xterm.h (struct x_output): New member, toolbar_detached.
Jan Djärv <jan.h.d@swipnet.se>
parents:
59411
diff
changeset
|
3760 && ! FRAME_X_OUTPUT (f)->toolbar_detached) |
49323 | 3761 { |
3762 FRAME_TOOLBAR_HEIGHT (f) = new_req.height; | |
51211
28ea05de2dc5
Make (many) trivial substitutions for renamed and
Kim F. Storm <storm@cua.dk>
parents:
50778
diff
changeset
|
3763 xg_resize_outer_widget (f, FRAME_COLS (f), FRAME_LINES (f)); |
49323 | 3764 } |
3765 | |
49572 | 3766 if (icon_list) g_list_free (icon_list); |
3767 | |
49323 | 3768 UNBLOCK_INPUT; |
3769 } | |
3770 | |
57715
cdc48cdd5b0e
* gtkutil.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57597
diff
changeset
|
3771 /* Deallocate all resources for the tool bar on frame F. |
cdc48cdd5b0e
* gtkutil.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57597
diff
changeset
|
3772 Remove the tool bar. */ |
cdc48cdd5b0e
* gtkutil.c: Put empty line between comment and function body.
Jan Djärv <jan.h.d@swipnet.se>
parents:
57597
diff
changeset
|
3773 |
49323 | 3774 void |
3775 free_frame_tool_bar (f) | |
3776 FRAME_PTR f; | |
3777 { | |
3778 struct x_output *x = f->output_data.x; | |
3779 | |
3780 if (x->toolbar_widget) | |
3781 { | |
3782 BLOCK_INPUT; | |
3783 gtk_container_remove (GTK_CONTAINER (x->vbox_widget), | |
3784 x->handlebox_widget); | |
3785 x->toolbar_widget = 0; | |
3786 x->handlebox_widget = 0; | |
3787 FRAME_TOOLBAR_HEIGHT (f) = 0; | |
3788 | |
3789 /* The height has changed, resize outer widget and set columns | |
3790 rows to what we had before removing the tool bar. */ | |
51211
28ea05de2dc5
Make (many) trivial substitutions for renamed and
Kim F. Storm <storm@cua.dk>
parents:
50778
diff
changeset
|
3791 xg_resize_outer_widget (f, FRAME_COLS (f), FRAME_LINES (f)); |
49323 | 3792 |
3793 SET_FRAME_GARBAGED (f); | |
3794 UNBLOCK_INPUT; | |
3795 } | |
3796 } | |
3797 | |
3798 | |
3799 | |
3800 /*********************************************************************** | |
3801 Initializing | |
3802 ***********************************************************************/ | |
3803 void | |
3804 xg_initialize () | |
3805 { | |
59102
0096c58ce34a
* xmenu.c (popup_get_selection): Pop down on C-g.
Jan Djärv <jan.h.d@swipnet.se>
parents:
59084
diff
changeset
|
3806 GtkBindingSet *binding_set; |
0096c58ce34a
* xmenu.c (popup_get_selection): Pop down on C-g.
Jan Djärv <jan.h.d@swipnet.se>
parents:
59084
diff
changeset
|
3807 |
49323 | 3808 xg_ignore_gtk_scrollbar = 0; |
52981
54482f5ea7be
Remove tear off capability for GTK popup menus.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
3809 xg_detached_menus = 0; |
49323 | 3810 xg_menu_cb_list.prev = xg_menu_cb_list.next = |
3811 xg_menu_item_cb_list.prev = xg_menu_item_cb_list.next = 0; | |
3812 | |
49419
6562bb5f04aa
gtkutil.c (xg_initialize): Initialize id_to_widget here instead
Jan Djärv <jan.h.d@swipnet.se>
parents:
49359
diff
changeset
|
3813 id_to_widget.max_size = id_to_widget.used = 0; |
6562bb5f04aa
gtkutil.c (xg_initialize): Initialize id_to_widget here instead
Jan Djärv <jan.h.d@swipnet.se>
parents:
49359
diff
changeset
|
3814 id_to_widget.widgets = 0; |
6562bb5f04aa
gtkutil.c (xg_initialize): Initialize id_to_widget here instead
Jan Djärv <jan.h.d@swipnet.se>
parents:
49359
diff
changeset
|
3815 |
49323 | 3816 /* Remove F10 as a menu accelerator, it does not mix well with Emacs key |
3817 bindings. It doesn't seem to be any way to remove properties, | |
3818 so we set it to VoidSymbol which in X means "no key". */ | |
3819 gtk_settings_set_string_property (gtk_settings_get_default (), | |
3820 "gtk-menu-bar-accel", | |
3821 "VoidSymbol", | |
3822 EMACS_CLASS); | |
49419
6562bb5f04aa
gtkutil.c (xg_initialize): Initialize id_to_widget here instead
Jan Djärv <jan.h.d@swipnet.se>
parents:
49359
diff
changeset
|
3823 |
6562bb5f04aa
gtkutil.c (xg_initialize): Initialize id_to_widget here instead
Jan Djärv <jan.h.d@swipnet.se>
parents:
49359
diff
changeset
|
3824 /* Make GTK text input widgets use Emacs style keybindings. This is |
6562bb5f04aa
gtkutil.c (xg_initialize): Initialize id_to_widget here instead
Jan Djärv <jan.h.d@swipnet.se>
parents:
49359
diff
changeset
|
3825 Emacs after all. */ |
6562bb5f04aa
gtkutil.c (xg_initialize): Initialize id_to_widget here instead
Jan Djärv <jan.h.d@swipnet.se>
parents:
49359
diff
changeset
|
3826 gtk_settings_set_string_property (gtk_settings_get_default (), |
6562bb5f04aa
gtkutil.c (xg_initialize): Initialize id_to_widget here instead
Jan Djärv <jan.h.d@swipnet.se>
parents:
49359
diff
changeset
|
3827 "gtk-key-theme-name", |
6562bb5f04aa
gtkutil.c (xg_initialize): Initialize id_to_widget here instead
Jan Djärv <jan.h.d@swipnet.se>
parents:
49359
diff
changeset
|
3828 "Emacs", |
6562bb5f04aa
gtkutil.c (xg_initialize): Initialize id_to_widget here instead
Jan Djärv <jan.h.d@swipnet.se>
parents:
49359
diff
changeset
|
3829 EMACS_CLASS); |
59102
0096c58ce34a
* xmenu.c (popup_get_selection): Pop down on C-g.
Jan Djärv <jan.h.d@swipnet.se>
parents:
59084
diff
changeset
|
3830 |
0096c58ce34a
* xmenu.c (popup_get_selection): Pop down on C-g.
Jan Djärv <jan.h.d@swipnet.se>
parents:
59084
diff
changeset
|
3831 /* Make dialogs close on C-g. Since file dialog inherits from |
0096c58ce34a
* xmenu.c (popup_get_selection): Pop down on C-g.
Jan Djärv <jan.h.d@swipnet.se>
parents:
59084
diff
changeset
|
3832 dialog, this works for them also. */ |
0096c58ce34a
* xmenu.c (popup_get_selection): Pop down on C-g.
Jan Djärv <jan.h.d@swipnet.se>
parents:
59084
diff
changeset
|
3833 binding_set = gtk_binding_set_by_class (gtk_type_class (GTK_TYPE_DIALOG)); |
0096c58ce34a
* xmenu.c (popup_get_selection): Pop down on C-g.
Jan Djärv <jan.h.d@swipnet.se>
parents:
59084
diff
changeset
|
3834 gtk_binding_entry_add_signal (binding_set, GDK_g, GDK_CONTROL_MASK, |
0096c58ce34a
* xmenu.c (popup_get_selection): Pop down on C-g.
Jan Djärv <jan.h.d@swipnet.se>
parents:
59084
diff
changeset
|
3835 "close", 0); |
0096c58ce34a
* xmenu.c (popup_get_selection): Pop down on C-g.
Jan Djärv <jan.h.d@swipnet.se>
parents:
59084
diff
changeset
|
3836 |
0096c58ce34a
* xmenu.c (popup_get_selection): Pop down on C-g.
Jan Djärv <jan.h.d@swipnet.se>
parents:
59084
diff
changeset
|
3837 /* Make menus close on C-g. */ |
0096c58ce34a
* xmenu.c (popup_get_selection): Pop down on C-g.
Jan Djärv <jan.h.d@swipnet.se>
parents:
59084
diff
changeset
|
3838 binding_set = gtk_binding_set_by_class (gtk_type_class (GTK_TYPE_MENU_SHELL)); |
0096c58ce34a
* xmenu.c (popup_get_selection): Pop down on C-g.
Jan Djärv <jan.h.d@swipnet.se>
parents:
59084
diff
changeset
|
3839 gtk_binding_entry_add_signal (binding_set, GDK_g, GDK_CONTROL_MASK, |
0096c58ce34a
* xmenu.c (popup_get_selection): Pop down on C-g.
Jan Djärv <jan.h.d@swipnet.se>
parents:
59084
diff
changeset
|
3840 "cancel", 0); |
49323 | 3841 } |
3842 | |
3843 #endif /* USE_GTK */ | |
52401 | 3844 |
3845 /* arch-tag: fe7104da-bc1e-4aba-9bd1-f349c528f7e3 | |
3846 (do not change this comment) */ |