Mercurial > emacs
annotate src/gtkutil.c @ 83537:c19f348befac
Fix F10 behaviour. (Reported by Bernard Adrian.)
* src/xmenu.c (Fx_menu_bar_open) [USE_X_TOOLKIT, USE_GTK]:
Rename from Fmenu_bar_open.
(syms_of_xmenu): Update defsubr.
* lisp/menu-bar.el (menu-bar-open): New function.
Bind it to f10.
* lisp/term/x-win.el: Don't bind f10.
* lisp/tmm.el: Remove autoload binding for f10.
* lisp/ldefs-boot.el: Regenerate.
git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-577
| author | Karoly Lorentey <lorentey@elte.hu> |
|---|---|
| date | Sat, 29 Jul 2006 20:57:26 +0000 |
| parents | 46b1096093f5 |
| children | 2d56e13fd23d |
| 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. */ | |
| 83505 | 814 xg_pix_to_gcolor (wfixed, FRAME_BACKGROUND_PIXEL (f), &bg); |
| 49323 | 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"); |
|
e1dfc5458653
* gtkutil.c (xg_get_file_with_chooser): Changed message shown
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
67849
diff
changeset
|
1329 strcat (message, "\nIf you don't like this file selector, customize " |
|
e1dfc5458653
* gtkutil.c (xg_get_file_with_chooser): Changed message shown
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
67849
diff
changeset
|
1330 "use-file-dialog\nto turn it off, or type C-x C-f to visit files."); |
|
67843
6cf5dc28bd1e
* gtkutil.c (xg_toggle_visibility_cb): New function.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
67761
diff
changeset
|
1331 |
|
6cf5dc28bd1e
* gtkutil.c (xg_toggle_visibility_cb): New function.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
67761
diff
changeset
|
1332 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
|
1333 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
|
1334 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
|
1335 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
|
1336 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
|
1337 |
|
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
|
1338 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
|
1339 { |
|
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 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
|
1341 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
|
1342 GCPRO1 (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
|
1343 |
|
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
|
1344 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
|
1345 |
|
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
|
1346 /* 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
|
1347 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
|
1348 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
|
1349 file = Fexpand_file_name (file, Qnil); |
|
65f1b18b7f66
* gtkutil.c (xg_get_file_with_chooser): Handle local files only.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
58463
diff
changeset
|
1350 |
|
67528
c5c00342184b
* gtkutil.c (SSDATA): New macro to remove compiler warnings.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
65628
diff
changeset
|
1351 default_filename = SSDATA (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
|
1352 if (Ffile_directory_p (file)) |
|
65f1b18b7f66
* gtkutil.c (xg_get_file_with_chooser): Handle local files only.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
58463
diff
changeset
|
1353 gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (filewin), |
|
65f1b18b7f66
* gtkutil.c (xg_get_file_with_chooser): Handle local files only.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
58463
diff
changeset
|
1354 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
|
1355 else |
|
65f1b18b7f66
* gtkutil.c (xg_get_file_with_chooser): Handle local files only.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
58463
diff
changeset
|
1356 gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (filewin), |
|
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 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
|
1358 |
|
a3fa0e63dd67
* gtkutil.c (xg_get_file_with_chooser): Expand DEFAULT_FILENAME if
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
57900
diff
changeset
|
1359 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
|
1360 } |
|
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
|
1361 |
|
58200
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1362 *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
|
1363 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
|
1364 } |
|
c955f6add62a
* fileio.c (Fread_file_name): Pass Qt as fifth parameter to
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
57715
diff
changeset
|
1365 #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
|
1366 |
|
c955f6add62a
* fileio.c (Fread_file_name): Pass Qt as fifth parameter to
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
57715
diff
changeset
|
1367 #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
|
1368 |
|
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1369 /* 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
|
1370 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
|
1371 |
|
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1372 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
|
1373 xg_get_file_name_from_selector (w) |
| 49323 | 1374 GtkWidget *w; |
| 1375 { | |
|
58200
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1376 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
|
1377 return xstrdup ((char*) gtk_file_selection_get_filename (filesel)); |
| 49323 | 1378 } |
| 1379 | |
|
58200
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1380 /* Create a file selection dialog. |
| 49323 | 1381 F is the current frame. |
| 1382 PROMPT is a prompt to show to the user. May not be NULL. | |
| 1383 DEFAULT_FILENAME is a default selection to be displayed. May be NULL. | |
| 1384 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
|
1385 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
|
1386 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
|
1387 |
|
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1388 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
|
1389 |
|
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1390 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
|
1391 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
|
1392 mustmatch_p, only_dir_p, func) |
| 49323 | 1393 FRAME_PTR f; |
| 1394 char *prompt; | |
| 1395 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
|
1396 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
|
1397 xg_get_file_func *func; |
| 49323 | 1398 { |
| 1399 GtkWidget *filewin; | |
| 1400 GtkFileSelection *filesel; | |
|
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
1401 |
| 49323 | 1402 filewin = gtk_file_selection_new (prompt); |
| 1403 filesel = GTK_FILE_SELECTION (filewin); | |
| 1404 | |
| 1405 if (default_filename) | |
| 1406 gtk_file_selection_set_filename (filesel, default_filename); | |
| 1407 | |
| 1408 if (mustmatch_p) | |
| 1409 { | |
| 1410 /* The selection_entry part of filesel is not documented. */ | |
| 1411 gtk_widget_set_sensitive (filesel->selection_entry, FALSE); | |
| 1412 gtk_file_selection_hide_fileop_buttons (filesel); | |
| 1413 } | |
| 1414 | |
|
58200
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1415 *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
|
1416 |
|
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1417 return filewin; |
| 49323 | 1418 } |
|
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
|
1419 #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
|
1420 |
|
c955f6add62a
* fileio.c (Fread_file_name): Pass Qt as fifth parameter to
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
57715
diff
changeset
|
1421 /* 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
|
1422 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
|
1423 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
|
1424 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
|
1425 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
|
1426 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
|
1427 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
|
1428 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
|
1429 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
|
1430 |
|
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 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
|
1432 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
|
1433 |
|
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 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
|
1435 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
|
1436 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
|
1437 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
|
1438 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
|
1439 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
|
1440 { |
|
58284
10efc827e15c
* gtkutil.c (xg_get_file_name): Fix typo in
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
58201
diff
changeset
|
1441 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
|
1442 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
|
1443 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
|
1444 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
|
1445 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
|
1446 |
|
58818
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
58817
diff
changeset
|
1447 #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
|
1448 /* 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
|
1449 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
|
1450 threads. */ |
|
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
58817
diff
changeset
|
1451 sigblock (sigmask (__SIGRTMIN)); |
|
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
58817
diff
changeset
|
1452 #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
|
1453 |
|
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
|
1454 #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
|
1455 |
|
67761
5b8799d65159
* xfns.c (Fx_uses_old_gtk_dialog): New function.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
67528
diff
changeset
|
1456 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
|
1457 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
|
1458 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
|
1459 else |
|
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1460 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
|
1461 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
|
1462 |
|
c955f6add62a
* fileio.c (Fread_file_name): Pass Qt as fifth parameter to
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
57715
diff
changeset
|
1463 #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
|
1464 |
|
58284
10efc827e15c
* gtkutil.c (xg_get_file_name): Fix typo in
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
58201
diff
changeset
|
1465 #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
|
1466 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
|
1467 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
|
1468 #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
|
1469 #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
|
1470 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
|
1471 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
|
1472 #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
|
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 #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
|
1475 |
|
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1476 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
|
1477 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
|
1478 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
|
1479 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
|
1480 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
|
1481 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
|
1482 |
|
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1483 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
|
1484 "response", |
|
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1485 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
|
1486 &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
|
1487 |
|
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1488 /* 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
|
1489 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
|
1490 |
|
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_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
|
1492 |
|
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1493 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
|
1494 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
|
1495 { |
|
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1496 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
|
1497 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
|
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 |
|
58818
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
58817
diff
changeset
|
1500 #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
|
1501 sigunblock (sigmask (__SIGRTMIN)); |
|
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
58817
diff
changeset
|
1502 #endif |
|
f8cddae7d959
* gtkutil.c: Include signal.h and syssignal.h.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
58817
diff
changeset
|
1503 |
|
58200
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1504 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
|
1505 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
|
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 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
|
1508 |
|
3608b64ba20f
* gtkutil.c (xg_file_sel_ok, xg_file_sel_cancel)
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
57941
diff
changeset
|
1509 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
|
1510 } |
| 49323 | 1511 |
| 1512 | |
| 1513 /*********************************************************************** | |
| 1514 Menu functions. | |
| 1515 ***********************************************************************/ | |
| 1516 | |
| 1517 /* The name of menu items that can be used for citomization. Since GTK | |
| 1518 RC files are very crude and primitive, we have to set this on all | |
| 1519 menu item names so a user can easily cutomize menu items. */ | |
| 1520 | |
| 1521 #define MENU_ITEM_NAME "emacs-menuitem" | |
| 1522 | |
| 1523 | |
| 1524 /* Linked list of all allocated struct xg_menu_cb_data. Used for marking | |
| 1525 during GC. The next member points to the items. */ | |
| 1526 static xg_list_node xg_menu_cb_list; | |
| 1527 | |
| 1528 /* Linked list of all allocated struct xg_menu_item_cb_data. Used for marking | |
| 1529 during GC. The next member points to the items. */ | |
| 1530 static xg_list_node xg_menu_item_cb_list; | |
| 1531 | |
| 1532 /* Allocate and initialize CL_DATA if NULL, otherwise increase ref_count. | |
| 1533 F is the frame CL_DATA will be initialized for. | |
| 1534 HIGHLIGHT_CB is the callback to call when entering/leaving menu items. | |
| 1535 | |
| 1536 The menu bar and all sub menus under the menu bar in a frame | |
| 1537 share the same structure, hence the reference count. | |
|
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
1538 |
| 49323 | 1539 Returns CL_DATA if CL_DATA is not NULL, or a pointer to a newly |
| 1540 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
|
1541 |
| 49323 | 1542 static xg_menu_cb_data * |
| 1543 make_cl_data (cl_data, f, highlight_cb) | |
| 1544 xg_menu_cb_data *cl_data; | |
| 1545 FRAME_PTR f; | |
| 1546 GCallback highlight_cb; | |
| 1547 { | |
| 1548 if (! cl_data) | |
| 1549 { | |
| 1550 cl_data = (xg_menu_cb_data*) xmalloc (sizeof (*cl_data)); | |
| 1551 cl_data->f = f; | |
| 1552 cl_data->menu_bar_vector = f->menu_bar_vector; | |
| 1553 cl_data->menu_bar_items_used = f->menu_bar_items_used; | |
| 1554 cl_data->highlight_cb = highlight_cb; | |
| 1555 cl_data->ref_count = 0; | |
| 1556 | |
| 1557 xg_list_insert (&xg_menu_cb_list, &cl_data->ptrs); | |
| 1558 } | |
| 1559 | |
| 1560 cl_data->ref_count++; | |
| 1561 | |
| 1562 return cl_data; | |
| 1563 } | |
| 1564 | |
| 1565 /* Update CL_DATA with values from frame F and with HIGHLIGHT_CB. | |
| 1566 HIGHLIGHT_CB is the callback to call when entering/leaving menu items. | |
| 1567 | |
| 1568 When the menu bar is updated, menu items may have been added and/or | |
| 1569 removed, so menu_bar_vector and menu_bar_items_used change. We must | |
| 1570 then update CL_DATA since it is used to determine which menu | |
| 1571 item that is invoked in the menu. | |
| 1572 HIGHLIGHT_CB could change, there is no check that the same | |
| 1573 function is given when modifying a menu bar as was given when | |
| 1574 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
|
1575 |
| 49323 | 1576 static void |
| 1577 update_cl_data (cl_data, f, highlight_cb) | |
| 1578 xg_menu_cb_data *cl_data; | |
| 1579 FRAME_PTR f; | |
| 1580 GCallback highlight_cb; | |
| 1581 { | |
| 1582 if (cl_data) | |
| 1583 { | |
| 1584 cl_data->f = f; | |
| 1585 cl_data->menu_bar_vector = f->menu_bar_vector; | |
| 1586 cl_data->menu_bar_items_used = f->menu_bar_items_used; | |
| 1587 cl_data->highlight_cb = highlight_cb; | |
| 1588 } | |
| 1589 } | |
| 1590 | |
| 1591 /* Decrease reference count for CL_DATA. | |
| 1592 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
|
1593 |
| 49323 | 1594 static void |
| 1595 unref_cl_data (cl_data) | |
| 1596 xg_menu_cb_data *cl_data; | |
| 1597 { | |
| 1598 if (cl_data && cl_data->ref_count > 0) | |
| 1599 { | |
| 1600 cl_data->ref_count--; | |
| 1601 if (cl_data->ref_count == 0) | |
| 1602 { | |
| 1603 xg_list_remove (&xg_menu_cb_list, &cl_data->ptrs); | |
| 1604 xfree (cl_data); | |
| 1605 } | |
| 1606 } | |
| 1607 } | |
| 1608 | |
| 1609 /* 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
|
1610 |
| 49323 | 1611 void |
| 1612 xg_mark_data () | |
| 1613 { | |
| 1614 xg_list_node *iter; | |
| 1615 | |
| 1616 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
|
1617 mark_object (((xg_menu_cb_data *) iter)->menu_bar_vector); |
| 49323 | 1618 |
| 1619 for (iter = xg_menu_item_cb_list.next; iter; iter = iter->next) | |
| 1620 { | |
| 1621 xg_menu_item_cb_data *cb_data = (xg_menu_item_cb_data *) iter; | |
| 1622 | |
| 1623 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
|
1624 mark_object (cb_data->help); |
| 49323 | 1625 } |
| 1626 } | |
| 1627 | |
| 1628 | |
| 1629 /* Callback called when a menu item is destroyed. Used to free data. | |
| 1630 W is the widget that is being destroyed (not used). | |
| 1631 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
|
1632 |
| 49323 | 1633 static void |
| 1634 menuitem_destroy_callback (w, client_data) | |
| 1635 GtkWidget *w; | |
| 1636 gpointer client_data; | |
| 1637 { | |
| 1638 if (client_data) | |
| 1639 { | |
| 1640 xg_menu_item_cb_data *data = (xg_menu_item_cb_data*) client_data; | |
| 1641 xg_list_remove (&xg_menu_item_cb_list, &data->ptrs); | |
| 1642 xfree (data); | |
| 1643 } | |
| 1644 } | |
| 1645 | |
| 1646 /* Callback called when the pointer enters/leaves a menu item. | |
| 1647 W is the menu item. | |
| 1648 EVENT is either an enter event or leave event. | |
| 1649 CLIENT_DATA points to the xg_menu_item_cb_data associated with the W. | |
| 1650 | |
| 1651 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
|
1652 |
| 49323 | 1653 static gboolean |
| 1654 menuitem_highlight_callback (w, event, client_data) | |
| 1655 GtkWidget *w; | |
| 1656 GdkEventCrossing *event; | |
| 1657 gpointer client_data; | |
| 1658 { | |
| 1659 if (client_data) | |
| 1660 { | |
| 1661 xg_menu_item_cb_data *data = (xg_menu_item_cb_data*) client_data; | |
| 1662 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
|
1663 |
| 49323 | 1664 if (! NILP (data->help) && data->cl_data->highlight_cb) |
| 1665 { | |
| 1666 GtkCallback func = (GtkCallback) data->cl_data->highlight_cb; | |
| 1667 (*func) (w, call_data); | |
| 1668 } | |
| 1669 } | |
| 1670 | |
| 1671 return FALSE; | |
| 1672 } | |
| 1673 | |
| 1674 /* Callback called when a menu is destroyed. Used to free data. | |
| 1675 W is the widget that is being destroyed (not used). | |
| 1676 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
|
1677 |
| 49323 | 1678 static void |
| 1679 menu_destroy_callback (w, client_data) | |
| 1680 GtkWidget *w; | |
| 1681 gpointer client_data; | |
| 1682 { | |
| 1683 unref_cl_data ((xg_menu_cb_data*) client_data); | |
| 1684 } | |
| 1685 | |
| 1686 /* Callback called when a menu does a grab or ungrab. That means the | |
| 1687 menu has been activated or deactivated. | |
| 1688 Used to start a timer so the small timeout the menus in GTK uses before | |
| 1689 popping down a menu is seen by Emacs (see xg_process_timeouts above). | |
| 1690 W is the widget that does the grab (not used). | |
| 1691 UNGRAB_P is TRUE if this is an ungrab, FALSE if it is a grab. | |
| 1692 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
|
1693 |
| 49323 | 1694 static void |
| 1695 menu_grab_callback (GtkWidget *widget, | |
| 1696 gboolean ungrab_p, | |
| 1697 gpointer client_data) | |
| 1698 { | |
| 1699 /* Keep track of total number of grabs. */ | |
| 1700 static int cnt; | |
| 1701 | |
| 1702 if (ungrab_p) cnt--; | |
| 1703 else cnt++; | |
| 1704 | |
| 1705 if (cnt > 0 && ! xg_timer) xg_start_timer (); | |
| 1706 else if (cnt == 0 && xg_timer) xg_stop_timer (); | |
| 1707 } | |
| 1708 | |
| 1709 /* Make a GTK widget that contains both UTF8_LABEL and UTF8_KEY (both | |
| 1710 must be non-NULL) and can be inserted into a menu item. | |
| 1711 | |
| 1712 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
|
1713 |
| 49323 | 1714 static GtkWidget * |
| 1715 make_widget_for_menu_item (utf8_label, utf8_key) | |
| 1716 char *utf8_label; | |
| 1717 char *utf8_key; | |
| 1718 { | |
| 1719 GtkWidget *wlbl; | |
| 1720 GtkWidget *wkey; | |
| 1721 GtkWidget *wbox; | |
|
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
1722 |
| 49323 | 1723 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
|
1724 wlbl = gtk_label_new (utf8_label); |
| 49323 | 1725 wkey = gtk_label_new (utf8_key); |
| 1726 | |
| 1727 gtk_misc_set_alignment (GTK_MISC (wlbl), 0.0, 0.5); | |
| 1728 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
|
1729 |
| 49323 | 1730 gtk_box_pack_start (GTK_BOX (wbox), wlbl, TRUE, TRUE, 0); |
| 1731 gtk_box_pack_start (GTK_BOX (wbox), wkey, FALSE, FALSE, 0); | |
| 1732 | |
| 1733 gtk_widget_set_name (wlbl, MENU_ITEM_NAME); | |
| 1734 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
|
1735 gtk_widget_set_name (wbox, MENU_ITEM_NAME); |
| 49323 | 1736 |
| 1737 return wbox; | |
| 1738 } | |
| 1739 | |
| 1740 /* Make and return a menu item widget with the key to the right. | |
| 1741 UTF8_LABEL is the text for the menu item (GTK uses UTF8 internally). | |
| 1742 UTF8_KEY is the text representing the key binding. | |
| 1743 ITEM is the widget_value describing the menu item. | |
|
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
1744 |
| 49323 | 1745 GROUP is an in/out parameter. If the menu item to be created is not |
| 1746 part of any radio menu group, *GROUP contains NULL on entry and exit. | |
| 1747 If the menu item to be created is part of a radio menu group, on entry | |
| 1748 *GROUP contains the group to use, or NULL if this is the first item | |
| 1749 in the group. On exit, *GROUP contains the radio item group. | |
| 1750 | |
| 1751 Unfortunately, keys don't line up as nicely as in Motif, | |
| 1752 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
|
1753 |
| 49323 | 1754 static GtkWidget * |
| 1755 make_menu_item (utf8_label, utf8_key, item, group) | |
| 1756 char *utf8_label; | |
| 1757 char *utf8_key; | |
| 1758 widget_value *item; | |
| 1759 GSList **group; | |
| 1760 { | |
| 1761 GtkWidget *w; | |
| 1762 GtkWidget *wtoadd = 0; | |
|
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
1763 |
|
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
|
1764 /* 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
|
1765 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
|
1766 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
|
1767 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
|
1768 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
|
1769 |
| 49323 | 1770 if (utf8_key) |
| 1771 wtoadd = make_widget_for_menu_item (utf8_label, utf8_key); | |
|
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
1772 |
| 49323 | 1773 if (item->button_type == BUTTON_TYPE_TOGGLE) |
| 1774 { | |
| 1775 *group = NULL; | |
| 1776 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
|
1777 else w = gtk_check_menu_item_new_with_label (utf8_label); |
| 49323 | 1778 gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (w), item->selected); |
| 1779 } | |
| 1780 else if (item->button_type == BUTTON_TYPE_RADIO) | |
| 1781 { | |
| 1782 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
|
1783 else w = gtk_radio_menu_item_new_with_label (*group, utf8_label); |
| 49323 | 1784 *group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (w)); |
| 1785 if (item->selected) | |
| 1786 gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (w), TRUE); | |
| 1787 } | |
| 1788 else | |
| 1789 { | |
| 1790 *group = NULL; | |
| 1791 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
|
1792 else w = gtk_menu_item_new_with_label (utf8_label); |
| 49323 | 1793 } |
|
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
1794 |
| 49323 | 1795 if (wtoadd) gtk_container_add (GTK_CONTAINER (w), wtoadd); |
| 1796 if (! item->enabled) gtk_widget_set_sensitive (w, FALSE); | |
| 1797 | |
| 1798 return w; | |
| 1799 } | |
| 1800 | |
|
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
|
1801 /* Return non-zero if LABEL specifies a separator (GTK only has one |
| 49323 | 1802 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
|
1803 |
| 49323 | 1804 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
|
1805 xg_separator_p (char *label) |
| 49323 | 1806 { |
|
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
|
1807 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
|
1808 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
|
1809 && 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
|
1810 && 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
|
1811 { |
|
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 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
|
1813 "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
|
1814 "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
|
1815 "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
|
1816 "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
|
1817 "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
|
1818 "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
|
1819 "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
|
1820 "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
|
1821 "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
|
1822 "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
|
1823 "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
|
1824 "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
|
1825 "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
|
1826 "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
|
1827 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
|
1828 }; |
|
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 |
|
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 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
|
1831 |
|
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 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
|
1833 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
|
1834 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
|
1835 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
|
1836 } |
|
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 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
|
1838 { |
|
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 /* 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
|
1840 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
|
1841 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
|
1842 ++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
|
1843 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
|
1844 } |
|
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 |
|
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 0; |
| 49323 | 1847 } |
| 1848 | |
|
52981
54482f5ea7be
Remove tear off capability for GTK popup menus.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
1849 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
|
1850 |
|
54482f5ea7be
Remove tear off capability for GTK popup menus.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
1851 /* 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
|
1852 |
|
52981
54482f5ea7be
Remove tear off capability for GTK popup menus.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
1853 int |
|
54482f5ea7be
Remove tear off capability for GTK popup menus.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
1854 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
|
1855 { |
|
54482f5ea7be
Remove tear off capability for GTK popup menus.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
1856 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
|
1857 } |
| 49323 | 1858 |
| 1859 /* 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
|
1860 decrease the xg_detached_menus count. |
| 49323 | 1861 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
|
1862 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
|
1863 |
|
52981
54482f5ea7be
Remove tear off capability for GTK popup menus.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
1864 static void |
|
54482f5ea7be
Remove tear off capability for GTK popup menus.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
1865 tearoff_remove (widget, client_data) |
| 49323 | 1866 GtkWidget *widget; |
| 1867 gpointer client_data; | |
| 1868 { | |
|
52981
54482f5ea7be
Remove tear off capability for GTK popup menus.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
1869 if (xg_detached_menus > 0) --xg_detached_menus; |
| 49323 | 1870 } |
| 1871 | |
|
52981
54482f5ea7be
Remove tear off capability for GTK popup menus.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
1872 /* 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
|
1873 xg_detached_menus count. |
| 49323 | 1874 WIDGET is the GtkTearoffMenuItem. |
|
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
1875 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
|
1876 |
| 49323 | 1877 static void |
| 1878 tearoff_activate (widget, client_data) | |
| 1879 GtkWidget *widget; | |
| 1880 gpointer client_data; | |
| 1881 { | |
| 1882 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
|
1883 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
|
1884 { |
|
54482f5ea7be
Remove tear off capability for GTK popup menus.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
1885 ++xg_detached_menus; |
|
54482f5ea7be
Remove tear off capability for GTK popup menus.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
1886 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
|
1887 "destroy", |
|
54482f5ea7be
Remove tear off capability for GTK popup menus.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
1888 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
|
1889 } |
| 49323 | 1890 } |
| 1891 | |
| 1892 | |
| 1893 /* Create a menu item widget, and connect the callbacks. | |
| 1894 ITEM decribes the menu item. | |
| 1895 F is the frame the created menu belongs to. | |
| 1896 SELECT_CB is the callback to use when a menu item is selected. | |
| 1897 HIGHLIGHT_CB is the callback to call when entering/leaving menu items. | |
| 1898 CL_DATA points to the callback data to be used for this menu. | |
| 1899 GROUP is an in/out parameter. If the menu item to be created is not | |
| 1900 part of any radio menu group, *GROUP contains NULL on entry and exit. | |
| 1901 If the menu item to be created is part of a radio menu group, on entry | |
| 1902 *GROUP contains the group to use, or NULL if this is the first item | |
| 1903 in the group. On exit, *GROUP contains the radio item group. | |
| 1904 | |
| 1905 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
|
1906 |
| 49323 | 1907 static GtkWidget * |
| 1908 xg_create_one_menuitem (item, f, select_cb, highlight_cb, cl_data, group) | |
| 1909 widget_value *item; | |
| 1910 FRAME_PTR f; | |
| 1911 GCallback select_cb; | |
| 1912 GCallback highlight_cb; | |
| 1913 xg_menu_cb_data *cl_data; | |
| 1914 GSList **group; | |
| 1915 { | |
| 1916 char *utf8_label; | |
| 1917 char *utf8_key; | |
| 1918 GtkWidget *w; | |
| 1919 xg_menu_item_cb_data *cb_data; | |
| 1920 | |
| 1921 utf8_label = get_utf8_string (item->name); | |
| 1922 utf8_key = get_utf8_string (item->key); | |
| 1923 | |
| 1924 w = make_menu_item (utf8_label, utf8_key, item, group); | |
| 1925 | |
| 1926 if (utf8_label && utf8_label != item->name) g_free (utf8_label); | |
| 1927 if (utf8_key && utf8_key != item->key) g_free (utf8_key); | |
| 1928 | |
| 1929 cb_data = xmalloc (sizeof (xg_menu_item_cb_data)); | |
| 1930 | |
| 1931 xg_list_insert (&xg_menu_item_cb_list, &cb_data->ptrs); | |
| 1932 | |
| 1933 cb_data->unhighlight_id = cb_data->highlight_id = cb_data->select_id = 0; | |
| 1934 cb_data->help = item->help; | |
| 1935 cb_data->cl_data = cl_data; | |
| 1936 cb_data->call_data = item->call_data; | |
|
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
1937 |
| 49323 | 1938 g_signal_connect (G_OBJECT (w), |
| 1939 "destroy", | |
| 1940 G_CALLBACK (menuitem_destroy_callback), | |
| 1941 cb_data); | |
| 1942 | |
| 1943 /* Put cb_data in widget, so we can get at it when modifying menubar */ | |
| 1944 g_object_set_data (G_OBJECT (w), XG_ITEM_DATA, cb_data); | |
| 1945 | |
| 1946 /* final item, not a submenu */ | |
| 1947 if (item->call_data && ! item->contents) | |
| 1948 { | |
| 1949 if (select_cb) | |
| 1950 cb_data->select_id | |
| 1951 = g_signal_connect (G_OBJECT (w), "activate", select_cb, cb_data); | |
| 1952 } | |
| 1953 | |
| 1954 if (! NILP (item->help) && highlight_cb) | |
| 1955 { | |
| 1956 /* We use enter/leave notify instead of select/deselect because | |
| 1957 select/deselect doesn't go well with detached menus. */ | |
| 1958 cb_data->highlight_id | |
| 1959 = g_signal_connect (G_OBJECT (w), | |
| 1960 "enter-notify-event", | |
| 1961 G_CALLBACK (menuitem_highlight_callback), | |
| 1962 cb_data); | |
| 1963 cb_data->unhighlight_id | |
| 1964 = g_signal_connect (G_OBJECT (w), | |
| 1965 "leave-notify-event", | |
| 1966 G_CALLBACK (menuitem_highlight_callback), | |
| 1967 cb_data); | |
| 1968 } | |
| 1969 | |
| 1970 return w; | |
| 1971 } | |
| 1972 | |
|
83537
c19f348befac
Fix F10 behaviour. (Reported by Bernard Adrian.)
Karoly Lorentey <lorentey@elte.hu>
parents:
83530
diff
changeset
|
1973 /* Callback called when keyboard traversal (started by x-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
|
1974 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
|
1975 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
|
1976 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
|
1977 |
|
3e5c40f72a04
Connect menu_nav_ended to "selection-done" to fix grabs
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
69141
diff
changeset
|
1978 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
|
1979 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
|
1980 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
|
1981 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
|
1982 { |
|
3e5c40f72a04
Connect menu_nav_ended to "selection-done" to fix grabs
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
69141
diff
changeset
|
1983 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
|
1984 |
|
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
|
1985 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
|
1986 { |
|
71056
3e5c40f72a04
Connect menu_nav_ended to "selection-done" to fix grabs
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
69141
diff
changeset
|
1987 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
|
1988 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
|
1989 |
|
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
|
1990 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
|
1991 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
|
1992 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
|
1993 |
|
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
|
1994 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
|
1995 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
|
1996 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
|
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 } |
|
3e5c40f72a04
Connect menu_nav_ended to "selection-done" to fix grabs
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
69141
diff
changeset
|
1999 |
|
3e5c40f72a04
Connect menu_nav_ended to "selection-done" to fix grabs
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
69141
diff
changeset
|
2000 |
|
50112
50df9e41f1a3
Add prototype for create_menus.
Andreas Schwab <schwab@suse.de>
parents:
50108
diff
changeset
|
2001 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
|
2002 GCallback, GCallback, int, int, int, |
|
50df9e41f1a3
Add prototype for create_menus.
Andreas Schwab <schwab@suse.de>
parents:
50108
diff
changeset
|
2003 GtkWidget *, xg_menu_cb_data *, char *)); |
|
50df9e41f1a3
Add prototype for create_menus.
Andreas Schwab <schwab@suse.de>
parents:
50108
diff
changeset
|
2004 |
| 49323 | 2005 /* Create a full menu tree specified by DATA. |
| 2006 F is the frame the created menu belongs to. | |
| 2007 SELECT_CB is the callback to use when a menu item is selected. | |
| 2008 DEACTIVATE_CB is the callback to use when a sub menu is not shown anymore. | |
| 2009 HIGHLIGHT_CB is the callback to call when entering/leaving menu items. | |
| 2010 POP_UP_P is non-zero if we shall create a popup menu. | |
| 2011 MENU_BAR_P is non-zero if we shall create a menu bar. | |
| 2012 ADD_TEAROFF_P is non-zero if we shall add a teroff menu item. Ignored | |
| 2013 if MENU_BAR_P is non-zero. | |
| 2014 TOPMENU is the topmost GtkWidget that others shall be placed under. | |
| 2015 It may be NULL, in that case we create the appropriate widget | |
| 2016 (menu bar or menu item depending on POP_UP_P and MENU_BAR_P) | |
| 2017 CL_DATA is the callback data we shall use for this menu, or NULL | |
| 2018 if we haven't set the first callback yet. | |
| 2019 NAME is the name to give to the top level menu if this function | |
| 2020 creates it. May be NULL to not set any name. | |
| 2021 | |
| 2022 Returns the top level GtkWidget. This is TOPLEVEL if TOPLEVEL is | |
| 2023 not NULL. | |
| 2024 | |
| 2025 This function calls itself to create submenus. */ | |
| 2026 | |
| 2027 static GtkWidget * | |
| 2028 create_menus (data, f, select_cb, deactivate_cb, highlight_cb, | |
| 2029 pop_up_p, menu_bar_p, add_tearoff_p, topmenu, cl_data, name) | |
| 2030 widget_value *data; | |
| 2031 FRAME_PTR f; | |
| 2032 GCallback select_cb; | |
| 2033 GCallback deactivate_cb; | |
| 2034 GCallback highlight_cb; | |
| 2035 int pop_up_p; | |
| 2036 int menu_bar_p; | |
| 2037 int add_tearoff_p; | |
| 2038 GtkWidget *topmenu; | |
| 2039 xg_menu_cb_data *cl_data; | |
| 2040 char *name; | |
| 2041 { | |
| 2042 widget_value *item; | |
| 2043 GtkWidget *wmenu = topmenu; | |
| 2044 GSList *group = NULL; | |
| 2045 | |
| 2046 if (! topmenu) | |
| 2047 { | |
|
53069
1218a42792ea
Implement multiple display handling for GTK.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
2048 if (! menu_bar_p) |
|
1218a42792ea
Implement multiple display handling for GTK.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
2049 { |
|
1218a42792ea
Implement multiple display handling for GTK.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
2050 wmenu = gtk_menu_new (); |
|
1218a42792ea
Implement multiple display handling for GTK.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
2051 xg_set_screen (wmenu, f); |
|
1218a42792ea
Implement multiple display handling for GTK.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
2052 } |
| 49323 | 2053 else wmenu = gtk_menu_bar_new (); |
| 2054 | |
|
71056
3e5c40f72a04
Connect menu_nav_ended to "selection-done" to fix grabs
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
69141
diff
changeset
|
2055 /* 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
|
2056 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
|
2057 "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
|
2058 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
|
2059 f); |
|
3e5c40f72a04
Connect menu_nav_ended to "selection-done" to fix grabs
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
69141
diff
changeset
|
2060 |
| 49323 | 2061 /* Put cl_data on the top menu for easier access. */ |
| 2062 cl_data = make_cl_data (cl_data, f, highlight_cb); | |
| 2063 g_object_set_data (G_OBJECT (wmenu), XG_FRAME_DATA, (gpointer)cl_data); | |
| 2064 g_signal_connect (G_OBJECT (wmenu), "destroy", | |
| 2065 G_CALLBACK (menu_destroy_callback), cl_data); | |
|
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
2066 |
| 49323 | 2067 if (name) |
| 2068 gtk_widget_set_name (wmenu, name); | |
| 2069 | |
| 2070 if (deactivate_cb) | |
| 2071 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
|
2072 "selection-done", deactivate_cb, 0); |
| 49323 | 2073 |
| 2074 g_signal_connect (G_OBJECT (wmenu), | |
| 2075 "grab-notify", G_CALLBACK (menu_grab_callback), 0); | |
| 2076 } | |
|
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
2077 |
| 49323 | 2078 if (! menu_bar_p && add_tearoff_p) |
| 2079 { | |
| 2080 GtkWidget *tearoff = gtk_tearoff_menu_item_new (); | |
| 2081 gtk_menu_shell_append (GTK_MENU_SHELL (wmenu), tearoff); | |
| 2082 | |
| 2083 g_signal_connect (G_OBJECT (tearoff), "activate", | |
| 2084 G_CALLBACK (tearoff_activate), 0); | |
| 2085 } | |
| 2086 | |
| 2087 for (item = data; item; item = item->next) | |
| 2088 { | |
| 2089 GtkWidget *w; | |
|
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
2090 |
| 49323 | 2091 if (pop_up_p && !item->contents && !item->call_data |
| 2092 && !xg_separator_p (item->name)) | |
| 2093 { | |
| 2094 char *utf8_label; | |
| 2095 /* A title for a popup. We do the same as GTK does when | |
| 2096 creating titles, but it does not look good. */ | |
| 2097 group = NULL; | |
| 2098 utf8_label = get_utf8_string (item->name); | |
| 2099 | |
| 2100 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
|
2101 w = gtk_menu_item_new_with_label (utf8_label); |
| 49323 | 2102 gtk_widget_set_sensitive (w, FALSE); |
| 2103 if (utf8_label && utf8_label != item->name) g_free (utf8_label); | |
| 2104 } | |
| 2105 else if (xg_separator_p (item->name)) | |
| 2106 { | |
| 2107 group = NULL; | |
| 2108 /* GTK only have one separator type. */ | |
| 2109 w = gtk_separator_menu_item_new (); | |
| 2110 } | |
| 2111 else | |
| 2112 { | |
| 2113 w = xg_create_one_menuitem (item, | |
| 2114 f, | |
| 2115 item->contents ? 0 : select_cb, | |
| 2116 highlight_cb, | |
| 2117 cl_data, | |
| 2118 &group); | |
| 2119 | |
| 2120 if (item->contents) | |
| 2121 { | |
| 2122 GtkWidget *submenu = create_menus (item->contents, | |
| 2123 f, | |
| 2124 select_cb, | |
| 2125 deactivate_cb, | |
| 2126 highlight_cb, | |
| 2127 0, | |
| 2128 0, | |
|
52981
54482f5ea7be
Remove tear off capability for GTK popup menus.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
2129 add_tearoff_p, |
| 49323 | 2130 0, |
| 2131 cl_data, | |
| 2132 0); | |
| 2133 gtk_menu_item_set_submenu (GTK_MENU_ITEM (w), submenu); | |
| 2134 } | |
| 2135 } | |
| 2136 | |
| 2137 gtk_menu_shell_append (GTK_MENU_SHELL (wmenu), w); | |
| 2138 gtk_widget_set_name (w, MENU_ITEM_NAME); | |
| 2139 } | |
| 2140 | |
| 2141 return wmenu; | |
| 2142 } | |
| 2143 | |
| 2144 /* Create a menubar, popup menu or dialog, depending on the TYPE argument. | |
| 2145 TYPE can be "menubar", "popup" for popup menu, or "dialog" for a dialog | |
| 2146 with some text and buttons. | |
| 2147 F is the frame the created item belongs to. | |
| 2148 NAME is the name to use for the top widget. | |
| 2149 VAL is a widget_value structure describing items to be created. | |
| 2150 SELECT_CB is the callback to use when a menu item is selected or | |
| 2151 a dialog button is pressed. | |
| 2152 DEACTIVATE_CB is the callback to use when an item is deactivated. | |
| 2153 For a menu, when a sub menu is not shown anymore, for a dialog it is | |
| 2154 called when the dialog is popped down. | |
| 2155 HIGHLIGHT_CB is the callback to call when entering/leaving menu items. | |
| 2156 | |
| 2157 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
|
2158 |
| 49323 | 2159 GtkWidget * |
| 2160 xg_create_widget (type, name, f, val, | |
| 2161 select_cb, deactivate_cb, highlight_cb) | |
| 2162 char *type; | |
| 2163 char *name; | |
| 2164 FRAME_PTR f; | |
| 2165 widget_value *val; | |
| 2166 GCallback select_cb; | |
| 2167 GCallback deactivate_cb; | |
| 2168 GCallback highlight_cb; | |
| 2169 { | |
| 2170 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
|
2171 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
|
2172 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
|
2173 |
| 49323 | 2174 if (strcmp (type, "dialog") == 0) |
| 2175 { | |
| 2176 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
|
2177 xg_set_screen (w, f); |
| 49323 | 2178 gtk_window_set_transient_for (GTK_WINDOW (w), |
| 2179 GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f))); | |
| 2180 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
|
2181 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
|
2182 gtk_window_set_modal (GTK_WINDOW (w), TRUE); |
| 49323 | 2183 } |
|
52981
54482f5ea7be
Remove tear off capability for GTK popup menus.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
2184 else if (menu_bar_p || pop_up_p) |
| 49323 | 2185 { |
| 2186 w = create_menus (val->contents, | |
| 2187 f, | |
| 2188 select_cb, | |
| 2189 deactivate_cb, | |
| 2190 highlight_cb, | |
|
52981
54482f5ea7be
Remove tear off capability for GTK popup menus.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
2191 pop_up_p, |
|
54482f5ea7be
Remove tear off capability for GTK popup menus.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
2192 menu_bar_p, |
|
54482f5ea7be
Remove tear off capability for GTK popup menus.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
2193 menu_bar_p, |
| 49323 | 2194 0, |
| 2195 0, | |
| 2196 name); | |
| 2197 | |
| 2198 /* Set the cursor to an arrow for popup menus when they are mapped. | |
| 2199 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
|
2200 if (pop_up_p) |
| 49323 | 2201 { |
| 2202 /* Must realize so the GdkWindow inside the widget is created. */ | |
| 2203 gtk_widget_realize (w); | |
|
53069
1218a42792ea
Implement multiple display handling for GTK.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
2204 xg_set_cursor (w, FRAME_X_DISPLAY_INFO (f)->xg_cursor); |
| 49323 | 2205 } |
| 2206 } | |
| 2207 else | |
| 2208 { | |
| 2209 fprintf (stderr, "bad type in xg_create_widget: %s, doing nothing\n", | |
| 2210 type); | |
| 2211 } | |
| 2212 | |
| 2213 return w; | |
| 2214 } | |
| 2215 | |
|
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
|
2216 /* 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
|
2217 |
| 49323 | 2218 static const char * |
| 2219 xg_get_menu_item_label (witem) | |
| 2220 GtkMenuItem *witem; | |
| 2221 { | |
| 2222 GtkLabel *wlabel = GTK_LABEL (gtk_bin_get_child (GTK_BIN (witem))); | |
| 2223 return gtk_label_get_label (wlabel); | |
| 2224 } | |
| 2225 | |
|
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
|
2226 /* 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
|
2227 |
| 49323 | 2228 static int |
| 2229 xg_item_label_same_p (witem, label) | |
| 2230 GtkMenuItem *witem; | |
| 2231 char *label; | |
| 2232 { | |
|
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
|
2233 int is_same = 0; |
| 49323 | 2234 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
|
2235 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
|
2236 |
|
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 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
|
2238 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
|
2239 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
|
2240 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
|
2241 |
|
da6abcaef15c
gtkutil.c: Check for NULL string before calling strcmp or strlen.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
49468
diff
changeset
|
2242 if (utf8_label && utf8_label != label) g_free (utf8_label); |
| 49323 | 2243 |
| 2244 return is_same; | |
| 2245 } | |
| 2246 | |
|
57715
cdc48cdd5b0e
* gtkutil.c: Put empty line between comment and function body.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
57597
diff
changeset
|
2247 /* 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
|
2248 |
| 49323 | 2249 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
|
2250 xg_destroy_widgets (list) |
| 49323 | 2251 GList *list; |
| 2252 { | |
| 2253 GList *iter; | |
| 2254 | |
| 49572 | 2255 for (iter = list; iter; iter = g_list_next (iter)) |
| 49323 | 2256 { |
| 2257 GtkWidget *w = GTK_WIDGET (iter->data); | |
| 2258 | |
|
57715
cdc48cdd5b0e
* gtkutil.c: Put empty line between comment and function body.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
57597
diff
changeset
|
2259 /* Destroying the widget will remove it from the container it is in. */ |
| 49323 | 2260 gtk_widget_destroy (w); |
| 2261 } | |
| 2262 } | |
| 2263 | |
| 2264 /* Update the top level names in MENUBAR (i.e. not submenus). | |
| 2265 F is the frame the menu bar belongs to. | |
| 49572 | 2266 *LIST is a list with the current menu bar names (menu item widgets). |
| 2267 ITER is the item within *LIST that shall be updated. | |
| 2268 POS is the numerical position, starting at 0, of ITER in *LIST. | |
| 49323 | 2269 VAL describes what the menu bar shall look like after the update. |
| 2270 SELECT_CB is the callback to use when a menu item is selected. | |
| 2271 HIGHLIGHT_CB is the callback to call when entering/leaving menu items. | |
| 49572 | 2272 CL_DATA points to the callback data to be used for this menu bar. |
| 49323 | 2273 |
| 2274 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
|
2275 |
| 49323 | 2276 static void |
| 49572 | 2277 xg_update_menubar (menubar, f, list, iter, pos, val, |
| 2278 select_cb, highlight_cb, cl_data) | |
| 49323 | 2279 GtkWidget *menubar; |
| 2280 FRAME_PTR f; | |
| 49572 | 2281 GList **list; |
| 2282 GList *iter; | |
| 2283 int pos; | |
| 49323 | 2284 widget_value *val; |
| 2285 GCallback select_cb; | |
| 2286 GCallback highlight_cb; | |
| 2287 xg_menu_cb_data *cl_data; | |
| 2288 { | |
| 49572 | 2289 if (! iter && ! val) |
| 49323 | 2290 return; |
| 49572 | 2291 else if (iter && ! val) |
| 49323 | 2292 { |
| 49572 | 2293 /* 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
|
2294 xg_destroy_widgets (iter); |
| 49323 | 2295 |
| 2296 /* All updated. */ | |
| 2297 val = 0; | |
| 49572 | 2298 iter = 0; |
| 49323 | 2299 } |
| 49572 | 2300 else if (! iter && val) |
| 49323 | 2301 { |
| 2302 /* Item(s) added. Add all new items in one call. */ | |
| 2303 create_menus (val, f, select_cb, 0, highlight_cb, | |
| 2304 0, 1, 0, menubar, cl_data, 0); | |
| 2305 | |
| 2306 /* All updated. */ | |
| 2307 val = 0; | |
| 49572 | 2308 iter = 0; |
| 49323 | 2309 } |
| 49572 | 2310 /* Below this neither iter or val is NULL */ |
| 2311 else if (xg_item_label_same_p (GTK_MENU_ITEM (iter->data), val->name)) | |
| 49323 | 2312 { |
| 2313 /* This item is still the same, check next item. */ | |
| 2314 val = val->next; | |
| 49572 | 2315 iter = g_list_next (iter); |
| 2316 ++pos; | |
| 49323 | 2317 } |
| 2318 else /* This item is changed. */ | |
| 2319 { | |
| 49572 | 2320 GtkMenuItem *witem = GTK_MENU_ITEM (iter->data); |
| 49323 | 2321 GtkMenuItem *witem2 = 0; |
| 2322 int val_in_menubar = 0; | |
| 49572 | 2323 int iter_in_new_menubar = 0; |
| 2324 GList *iter2; | |
| 49323 | 2325 widget_value *cur; |
| 2326 | |
| 2327 /* See if the changed entry (val) is present later in the menu bar */ | |
| 49572 | 2328 for (iter2 = iter; |
| 2329 iter2 && ! val_in_menubar; | |
| 2330 iter2 = g_list_next (iter2)) | |
| 49323 | 2331 { |
| 49572 | 2332 witem2 = GTK_MENU_ITEM (iter2->data); |
| 49323 | 2333 val_in_menubar = xg_item_label_same_p (witem2, val->name); |
| 2334 } | |
| 2335 | |
| 49572 | 2336 /* See if the current entry (iter) is present later in the |
| 49323 | 2337 specification for the new menu bar. */ |
| 49572 | 2338 for (cur = val; cur && ! iter_in_new_menubar; cur = cur->next) |
| 2339 iter_in_new_menubar = xg_item_label_same_p (witem, cur->name); | |
| 2340 | |
| 2341 if (val_in_menubar && ! iter_in_new_menubar) | |
| 49323 | 2342 { |
| 49572 | 2343 int nr = pos; |
| 2344 | |
| 49323 | 2345 /* This corresponds to: |
| 2346 Current: A B C | |
| 2347 New: A C | |
| 2348 Remove B. */ | |
|
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
2349 |
| 49323 | 2350 gtk_widget_ref (GTK_WIDGET (witem)); |
| 2351 gtk_container_remove (GTK_CONTAINER (menubar), GTK_WIDGET (witem)); | |
| 2352 gtk_widget_destroy (GTK_WIDGET (witem)); | |
| 2353 | |
| 2354 /* Must get new list since the old changed. */ | |
| 49572 | 2355 g_list_free (*list); |
| 2356 *list = iter = gtk_container_get_children (GTK_CONTAINER (menubar)); | |
| 2357 while (nr-- > 0) iter = g_list_next (iter); | |
| 49323 | 2358 } |
| 49572 | 2359 else if (! val_in_menubar && ! iter_in_new_menubar) |
| 49323 | 2360 { |
| 2361 /* This corresponds to: | |
| 2362 Current: A B C | |
| 2363 New: A X C | |
| 2364 Rename B to X. This might seem to be a strange thing to do, | |
| 2365 since if there is a menu under B it will be totally wrong for X. | |
| 2366 But consider editing a C file. Then there is a C-mode menu | |
| 2367 (corresponds to B above). | |
| 2368 If then doing C-x C-f the minibuf menu (X above) replaces the | |
| 2369 C-mode menu. When returning from the minibuffer, we get | |
| 2370 back the C-mode menu. Thus we do: | |
| 2371 Rename B to X (C-mode to minibuf menu) | |
| 2372 Rename X to B (minibuf to C-mode menu). | |
| 2373 If the X menu hasn't been invoked, the menu under B | |
| 2374 is up to date when leaving the minibuffer. */ | |
| 2375 GtkLabel *wlabel = GTK_LABEL (gtk_bin_get_child (GTK_BIN (witem))); | |
| 2376 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
|
2377 GtkWidget *submenu = gtk_menu_item_get_submenu (witem); |
|
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
2378 |
|
50778
f30e6f029d65
* gtkutil.c (create_dialog, make_widget_for_menu_item)
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
50521
diff
changeset
|
2379 gtk_label_set_text (wlabel, utf8_label); |
| 49323 | 2380 |
|
52981
54482f5ea7be
Remove tear off capability for GTK popup menus.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
2381 /* 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
|
2382 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
|
2383 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
|
2384 /* 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
|
2385 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
|
2386 |
| 49572 | 2387 iter = g_list_next (iter); |
| 49323 | 2388 val = val->next; |
| 49572 | 2389 ++pos; |
| 49323 | 2390 } |
| 49572 | 2391 else if (! val_in_menubar && iter_in_new_menubar) |
| 49323 | 2392 { |
| 2393 /* This corresponds to: | |
| 2394 Current: A B C | |
| 2395 New: A X B C | |
| 2396 Insert X. */ | |
| 2397 | |
| 49572 | 2398 int nr = pos; |
| 49323 | 2399 GList *group = 0; |
| 2400 GtkWidget *w = xg_create_one_menuitem (val, | |
| 2401 f, | |
| 2402 select_cb, | |
| 2403 highlight_cb, | |
| 2404 cl_data, | |
| 2405 &group); | |
| 2406 | |
| 2407 gtk_widget_set_name (w, MENU_ITEM_NAME); | |
| 2408 gtk_menu_shell_insert (GTK_MENU_SHELL (menubar), w, pos); | |
| 2409 | |
| 49572 | 2410 g_list_free (*list); |
| 2411 *list = iter = gtk_container_get_children (GTK_CONTAINER (menubar)); | |
| 2412 while (nr-- > 0) iter = g_list_next (iter); | |
| 2413 iter = g_list_next (iter); | |
| 49323 | 2414 val = val->next; |
| 49572 | 2415 ++pos; |
| 49323 | 2416 } |
| 49572 | 2417 else /* if (val_in_menubar && iter_in_new_menubar) */ |
| 49323 | 2418 { |
| 49572 | 2419 int nr = pos; |
| 49323 | 2420 /* This corresponds to: |
| 2421 Current: A B C | |
| 2422 New: A C B | |
| 2423 Move C before B */ | |
| 2424 | |
| 2425 gtk_widget_ref (GTK_WIDGET (witem2)); | |
| 2426 gtk_container_remove (GTK_CONTAINER (menubar), GTK_WIDGET (witem2)); | |
| 2427 gtk_menu_shell_insert (GTK_MENU_SHELL (menubar), | |
| 2428 GTK_WIDGET (witem2), pos); | |
| 2429 gtk_widget_unref (GTK_WIDGET (witem2)); | |
| 2430 | |
| 49572 | 2431 g_list_free (*list); |
| 2432 *list = iter = gtk_container_get_children (GTK_CONTAINER (menubar)); | |
| 2433 while (nr-- > 0) iter = g_list_next (iter); | |
| 49323 | 2434 val = val->next; |
| 49572 | 2435 ++pos; |
| 49323 | 2436 } |
| 2437 } | |
| 2438 | |
| 2439 /* Update the rest of the menu bar. */ | |
| 49572 | 2440 xg_update_menubar (menubar, f, list, iter, pos, val, |
| 2441 select_cb, highlight_cb, cl_data); | |
| 49323 | 2442 } |
| 2443 | |
| 2444 /* Update the menu item W so it corresponds to VAL. | |
| 2445 SELECT_CB is the callback to use when a menu item is selected. | |
| 2446 HIGHLIGHT_CB is the callback to call when entering/leaving menu items. | |
| 2447 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
|
2448 |
| 49323 | 2449 static void |
| 2450 xg_update_menu_item (val, w, select_cb, highlight_cb, cl_data) | |
| 2451 widget_value *val; | |
| 2452 GtkWidget *w; | |
| 2453 GCallback select_cb; | |
| 2454 GCallback highlight_cb; | |
| 2455 xg_menu_cb_data *cl_data; | |
| 2456 { | |
| 2457 GtkWidget *wchild; | |
| 2458 GtkLabel *wlbl = 0; | |
| 2459 GtkLabel *wkey = 0; | |
| 2460 char *utf8_label; | |
| 2461 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
|
2462 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
|
2463 const char *old_key = 0; |
| 49323 | 2464 xg_menu_item_cb_data *cb_data; |
|
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
2465 |
|
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
2466 wchild = gtk_bin_get_child (GTK_BIN (w)); |
| 49323 | 2467 utf8_label = get_utf8_string (val->name); |
| 2468 utf8_key = get_utf8_string (val->key); | |
| 2469 | |
| 2470 /* See if W is a menu item with a key. See make_menu_item above. */ | |
| 2471 if (GTK_IS_HBOX (wchild)) | |
| 2472 { | |
| 2473 GList *list = gtk_container_get_children (GTK_CONTAINER (wchild)); | |
| 2474 | |
| 2475 wlbl = GTK_LABEL (list->data); | |
| 2476 wkey = GTK_LABEL (list->next->data); | |
| 49572 | 2477 g_list_free (list); |
| 2478 | |
| 49323 | 2479 if (! utf8_key) |
| 2480 { | |
| 2481 /* Remove the key and keep just the label. */ | |
| 2482 gtk_widget_ref (GTK_WIDGET (wlbl)); | |
| 2483 gtk_container_remove (GTK_CONTAINER (w), wchild); | |
| 2484 gtk_container_add (GTK_CONTAINER (w), GTK_WIDGET (wlbl)); | |
| 2485 wkey = 0; | |
| 2486 } | |
| 49572 | 2487 |
| 49323 | 2488 } |
| 2489 else /* Just a label. */ | |
| 2490 { | |
| 2491 wlbl = GTK_LABEL (wchild); | |
| 2492 | |
| 2493 /* Check if there is now a key. */ | |
| 2494 if (utf8_key) | |
| 2495 { | |
| 2496 GtkWidget *wtoadd = make_widget_for_menu_item (utf8_label, utf8_key); | |
| 2497 GList *list = gtk_container_get_children (GTK_CONTAINER (wtoadd)); | |
| 49572 | 2498 |
| 49323 | 2499 wlbl = GTK_LABEL (list->data); |
| 2500 wkey = GTK_LABEL (list->next->data); | |
| 49572 | 2501 g_list_free (list); |
| 49323 | 2502 |
| 2503 gtk_container_remove (GTK_CONTAINER (w), wchild); | |
| 2504 gtk_container_add (GTK_CONTAINER (w), wtoadd); | |
| 2505 } | |
| 2506 } | |
| 2507 | |
|
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
2508 |
|
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
|
2509 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
|
2510 if (wlbl) old_label = gtk_label_get_label (wlbl); |
|
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
2511 |
|
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
|
2512 if (wkey && utf8_key && (! old_key || strcmp (utf8_key, old_key) != 0)) |
| 49323 | 2513 gtk_label_set_text (wkey, utf8_key); |
| 2514 | |
|
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
|
2515 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
|
2516 gtk_label_set_text (wlbl, utf8_label); |
| 49323 | 2517 |
|
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
|
2518 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
|
2519 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
|
2520 |
| 49323 | 2521 if (! val->enabled && GTK_WIDGET_SENSITIVE (w)) |
| 2522 gtk_widget_set_sensitive (w, FALSE); | |
| 2523 else if (val->enabled && ! GTK_WIDGET_SENSITIVE (w)) | |
| 2524 gtk_widget_set_sensitive (w, TRUE); | |
| 2525 | |
| 2526 cb_data = (xg_menu_item_cb_data*) g_object_get_data (G_OBJECT (w), | |
| 2527 XG_ITEM_DATA); | |
| 2528 if (cb_data) | |
| 2529 { | |
| 2530 cb_data->call_data = val->call_data; | |
| 2531 cb_data->help = val->help; | |
| 2532 cb_data->cl_data = cl_data; | |
|
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
2533 |
| 49323 | 2534 /* We assume the callback functions don't change. */ |
| 2535 if (val->call_data && ! val->contents) | |
| 2536 { | |
| 2537 /* This item shall have a select callback. */ | |
| 2538 if (! cb_data->select_id) | |
| 2539 cb_data->select_id | |
| 2540 = g_signal_connect (G_OBJECT (w), "activate", | |
| 2541 select_cb, cb_data); | |
| 2542 } | |
| 2543 else if (cb_data->select_id) | |
| 2544 { | |
| 2545 g_signal_handler_disconnect (w, cb_data->select_id); | |
| 2546 cb_data->select_id = 0; | |
| 2547 } | |
| 2548 | |
| 2549 if (NILP (cb_data->help)) | |
| 2550 { | |
| 2551 /* Shall not have help. Remove if any existed previously. */ | |
| 2552 if (cb_data->highlight_id) | |
| 2553 { | |
| 2554 g_signal_handler_disconnect (G_OBJECT (w), | |
| 2555 cb_data->highlight_id); | |
| 2556 cb_data->highlight_id = 0; | |
| 2557 } | |
| 2558 if (cb_data->unhighlight_id) | |
| 2559 { | |
| 2560 g_signal_handler_disconnect (G_OBJECT (w), | |
| 2561 cb_data->unhighlight_id); | |
| 2562 cb_data->unhighlight_id = 0; | |
| 2563 } | |
| 2564 } | |
| 2565 else if (! cb_data->highlight_id && highlight_cb) | |
| 2566 { | |
| 2567 /* Have help now, but didn't previously. Add callback. */ | |
| 2568 cb_data->highlight_id | |
| 2569 = g_signal_connect (G_OBJECT (w), | |
| 2570 "enter-notify-event", | |
| 2571 G_CALLBACK (menuitem_highlight_callback), | |
| 2572 cb_data); | |
| 2573 cb_data->unhighlight_id | |
| 2574 = g_signal_connect (G_OBJECT (w), | |
| 2575 "leave-notify-event", | |
| 2576 G_CALLBACK (menuitem_highlight_callback), | |
| 2577 cb_data); | |
| 2578 } | |
| 2579 } | |
| 2580 } | |
| 2581 | |
| 2582 /* 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
|
2583 |
| 49323 | 2584 static void |
| 2585 xg_update_toggle_item (val, w) | |
| 2586 widget_value *val; | |
| 2587 GtkWidget *w; | |
| 2588 { | |
| 2589 gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (w), val->selected); | |
| 2590 } | |
| 2591 | |
| 2592 /* 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
|
2593 |
| 49323 | 2594 static void |
| 2595 xg_update_radio_item (val, w) | |
| 2596 widget_value *val; | |
| 2597 GtkWidget *w; | |
| 2598 { | |
| 2599 gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (w), val->selected); | |
| 2600 } | |
| 2601 | |
| 2602 /* Update the sub menu SUBMENU and all its children so it corresponds to VAL. | |
| 2603 SUBMENU may be NULL, in that case a new menu is created. | |
| 2604 F is the frame the menu bar belongs to. | |
| 2605 VAL describes the contents of the menu bar. | |
| 2606 SELECT_CB is the callback to use when a menu item is selected. | |
| 2607 DEACTIVATE_CB is the callback to use when a sub menu is not shown anymore. | |
| 2608 HIGHLIGHT_CB is the callback to call when entering/leaving menu items. | |
| 2609 CL_DATA is the call back data to use for any newly created items. | |
| 2610 | |
| 2611 Returns the updated submenu widget, that is SUBMENU unless SUBMENU | |
| 2612 was NULL. */ | |
| 2613 | |
| 2614 static GtkWidget * | |
| 2615 xg_update_submenu (submenu, f, val, | |
| 2616 select_cb, deactivate_cb, highlight_cb, cl_data) | |
| 2617 GtkWidget *submenu; | |
| 2618 FRAME_PTR f; | |
| 2619 widget_value *val; | |
| 2620 GCallback select_cb; | |
| 2621 GCallback deactivate_cb; | |
| 2622 GCallback highlight_cb; | |
| 2623 xg_menu_cb_data *cl_data; | |
| 2624 { | |
| 2625 GtkWidget *newsub = submenu; | |
| 2626 GList *list = 0; | |
| 2627 GList *iter; | |
| 2628 widget_value *cur; | |
| 2629 int has_tearoff_p = 0; | |
| 2630 GList *first_radio = 0; | |
|
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
2631 |
| 49323 | 2632 if (submenu) |
| 2633 list = gtk_container_get_children (GTK_CONTAINER (submenu)); | |
|
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
2634 |
| 49323 | 2635 for (cur = val, iter = list; |
| 2636 cur && iter; | |
| 2637 iter = g_list_next (iter), cur = cur->next) | |
| 2638 { | |
| 2639 GtkWidget *w = GTK_WIDGET (iter->data); | |
| 2640 | |
| 2641 /* Skip tearoff items, they have no counterpart in val. */ | |
| 2642 if (GTK_IS_TEAROFF_MENU_ITEM (w)) | |
| 2643 { | |
| 2644 has_tearoff_p = 1; | |
| 2645 iter = g_list_next (iter); | |
| 2646 if (iter) w = GTK_WIDGET (iter->data); | |
| 2647 else break; | |
| 2648 } | |
| 2649 | |
| 2650 /* Remember first radio button in a group. If we get a mismatch in | |
| 2651 a radio group we must rebuild the whole group so that the connections | |
| 2652 in GTK becomes correct. */ | |
| 2653 if (cur->button_type == BUTTON_TYPE_RADIO && ! first_radio) | |
| 2654 first_radio = iter; | |
| 2655 else if (cur->button_type != BUTTON_TYPE_RADIO | |
| 2656 && ! GTK_IS_RADIO_MENU_ITEM (w)) | |
| 2657 first_radio = 0; | |
| 2658 | |
| 2659 if (GTK_IS_SEPARATOR_MENU_ITEM (w)) | |
| 2660 { | |
| 2661 if (! xg_separator_p (cur->name)) | |
| 2662 break; | |
| 2663 } | |
| 2664 else if (GTK_IS_CHECK_MENU_ITEM (w)) | |
| 2665 { | |
| 2666 if (cur->button_type != BUTTON_TYPE_TOGGLE) | |
| 2667 break; | |
| 2668 xg_update_toggle_item (cur, w); | |
| 2669 xg_update_menu_item (cur, w, select_cb, highlight_cb, cl_data); | |
| 2670 } | |
| 2671 else if (GTK_IS_RADIO_MENU_ITEM (w)) | |
| 2672 { | |
| 2673 if (cur->button_type != BUTTON_TYPE_RADIO) | |
| 2674 break; | |
| 2675 xg_update_radio_item (cur, w); | |
| 2676 xg_update_menu_item (cur, w, select_cb, highlight_cb, cl_data); | |
| 2677 } | |
| 2678 else if (GTK_IS_MENU_ITEM (w)) | |
| 2679 { | |
| 2680 GtkMenuItem *witem = GTK_MENU_ITEM (w); | |
| 2681 GtkWidget *sub; | |
| 2682 | |
| 2683 if (cur->button_type != BUTTON_TYPE_NONE || | |
| 2684 xg_separator_p (cur->name)) | |
| 2685 break; | |
| 2686 | |
| 2687 xg_update_menu_item (cur, w, select_cb, highlight_cb, cl_data); | |
| 2688 | |
| 2689 sub = gtk_menu_item_get_submenu (witem); | |
| 2690 if (sub && ! cur->contents) | |
| 2691 { | |
| 2692 /* Not a submenu anymore. */ | |
| 2693 gtk_widget_ref (sub); | |
| 2694 gtk_menu_item_remove_submenu (witem); | |
| 2695 gtk_widget_destroy (sub); | |
| 2696 } | |
| 2697 else if (cur->contents) | |
| 2698 { | |
| 2699 GtkWidget *nsub; | |
| 2700 | |
| 2701 nsub = xg_update_submenu (sub, f, cur->contents, | |
| 2702 select_cb, deactivate_cb, | |
| 2703 highlight_cb, cl_data); | |
| 2704 | |
| 2705 /* If this item just became a submenu, we must set it. */ | |
| 2706 if (nsub != sub) | |
| 2707 gtk_menu_item_set_submenu (witem, nsub); | |
| 2708 } | |
| 2709 } | |
| 2710 else | |
| 2711 { | |
| 2712 /* Structural difference. Remove everything from here and down | |
| 2713 in SUBMENU. */ | |
| 2714 break; | |
| 2715 } | |
| 2716 } | |
| 2717 | |
| 2718 /* Remove widgets from first structual change. */ | |
| 2719 if (iter) | |
| 2720 { | |
| 2721 /* If we are adding new menu items below, we must remove from | |
| 2722 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
|
2723 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
|
2724 else xg_destroy_widgets (iter); |
| 49323 | 2725 } |
|
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
2726 |
| 49323 | 2727 if (cur) |
| 2728 { | |
| 2729 /* More items added. Create them. */ | |
| 2730 newsub = create_menus (cur, | |
| 2731 f, | |
| 2732 select_cb, | |
| 2733 deactivate_cb, | |
| 2734 highlight_cb, | |
| 2735 0, | |
| 2736 0, | |
| 2737 ! has_tearoff_p, | |
| 2738 submenu, | |
| 2739 cl_data, | |
| 2740 0); | |
| 2741 } | |
|
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
2742 |
| 49572 | 2743 if (list) g_list_free (list); |
| 2744 | |
| 49323 | 2745 return newsub; |
| 2746 } | |
| 2747 | |
| 2748 /* Update the MENUBAR. | |
| 2749 F is the frame the menu bar belongs to. | |
| 2750 VAL describes the contents of the menu bar. | |
| 2751 If DEEP_P is non-zero, rebuild all but the top level menu names in | |
| 2752 the MENUBAR. If DEEP_P is zero, just rebuild the names in the menubar. | |
| 2753 SELECT_CB is the callback to use when a menu item is selected. | |
| 2754 DEACTIVATE_CB is the callback to use when a sub menu is not shown anymore. | |
| 2755 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
|
2756 |
| 49323 | 2757 void |
| 2758 xg_modify_menubar_widgets (menubar, f, val, deep_p, | |
| 2759 select_cb, deactivate_cb, highlight_cb) | |
| 2760 GtkWidget *menubar; | |
| 2761 FRAME_PTR f; | |
| 2762 widget_value *val; | |
| 2763 int deep_p; | |
| 2764 GCallback select_cb; | |
| 2765 GCallback deactivate_cb; | |
| 2766 GCallback highlight_cb; | |
| 2767 { | |
| 2768 xg_menu_cb_data *cl_data; | |
| 2769 GList *list = gtk_container_get_children (GTK_CONTAINER (menubar)); | |
| 2770 | |
| 2771 if (! list) return; | |
|
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
2772 |
| 49323 | 2773 cl_data = (xg_menu_cb_data*) g_object_get_data (G_OBJECT (menubar), |
| 2774 XG_FRAME_DATA); | |
| 2775 | |
|
52981
54482f5ea7be
Remove tear off capability for GTK popup menus.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
2776 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
|
2777 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
|
2778 |
|
64783
0975467abc17
* gtkutil.c (xg_modify_menubar_widgets): Remove semicolon that
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
64770
diff
changeset
|
2779 if (deep_p) |
| 49323 | 2780 { |
| 2781 widget_value *cur; | |
| 2782 | |
| 2783 /* 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
|
2784 We must keep the submenus (GTK menu item widgets) since the |
| 49323 | 2785 X Window in the XEvent that activates the menu are those widgets. */ |
| 2786 | |
| 2787 /* Update cl_data, menu_item things in F may have changed. */ | |
| 2788 update_cl_data (cl_data, f, highlight_cb); | |
| 2789 | |
| 2790 for (cur = val->contents; cur; cur = cur->next) | |
| 2791 { | |
| 49572 | 2792 GList *iter; |
| 49323 | 2793 GtkWidget *sub = 0; |
| 2794 GtkWidget *newsub; | |
| 2795 GtkMenuItem *witem; | |
| 2796 | |
| 2797 /* Find sub menu that corresponds to val and update it. */ | |
| 2798 for (iter = list ; iter; iter = g_list_next (iter)) | |
| 2799 { | |
| 2800 witem = GTK_MENU_ITEM (iter->data); | |
| 2801 if (xg_item_label_same_p (witem, cur->name)) | |
| 2802 { | |
| 2803 sub = gtk_menu_item_get_submenu (witem); | |
| 2804 break; | |
| 2805 } | |
| 2806 } | |
|
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
2807 |
| 49323 | 2808 newsub = xg_update_submenu (sub, |
| 2809 f, | |
| 2810 cur->contents, | |
| 2811 select_cb, | |
| 2812 deactivate_cb, | |
| 2813 highlight_cb, | |
| 2814 cl_data); | |
| 2815 /* sub may still be NULL. If we just updated non deep and added | |
| 2816 a new menu bar item, it has no sub menu yet. So we set the | |
| 2817 newly created sub menu under witem. */ | |
| 2818 if (newsub != sub) | |
|
53069
1218a42792ea
Implement multiple display handling for GTK.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
2819 { |
|
1218a42792ea
Implement multiple display handling for GTK.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
2820 xg_set_screen (newsub, f); |
|
1218a42792ea
Implement multiple display handling for GTK.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
2821 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
|
2822 } |
| 49323 | 2823 } |
| 2824 } | |
| 2825 | |
| 49572 | 2826 g_list_free (list); |
| 49323 | 2827 gtk_widget_show_all (menubar); |
| 2828 } | |
| 2829 | |
| 2830 /* Recompute all the widgets of frame F, when the menu bar has been | |
| 2831 changed. Value is non-zero if widgets were updated. */ | |
| 2832 | |
| 2833 int | |
| 2834 xg_update_frame_menubar (f) | |
| 2835 FRAME_PTR f; | |
| 2836 { | |
| 2837 struct x_output *x = f->output_data.x; | |
| 2838 GtkRequisition req; | |
|
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
2839 |
| 49323 | 2840 if (!x->menubar_widget || GTK_WIDGET_MAPPED (x->menubar_widget)) |
| 2841 return 0; | |
| 2842 | |
| 2843 BLOCK_INPUT; | |
| 2844 | |
| 2845 gtk_box_pack_start (GTK_BOX (x->vbox_widget), x->menubar_widget, | |
| 2846 FALSE, FALSE, 0); | |
| 2847 gtk_box_reorder_child (GTK_BOX (x->vbox_widget), x->menubar_widget, 0); | |
| 2848 | |
| 2849 gtk_widget_show_all (x->menubar_widget); | |
| 2850 gtk_widget_size_request (x->menubar_widget, &req); | |
| 2851 | |
| 2852 FRAME_MENUBAR_HEIGHT (f) = req.height; | |
| 2853 | |
| 2854 /* The height has changed, resize outer widget and set columns | |
| 2855 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
|
2856 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
|
2857 |
| 49323 | 2858 SET_FRAME_GARBAGED (f); |
| 2859 UNBLOCK_INPUT; | |
|
50106
5675d6a0080c
(xg_update_frame_menubar): Add missing return value.
Andreas Schwab <schwab@suse.de>
parents:
50099
diff
changeset
|
2860 |
|
5675d6a0080c
(xg_update_frame_menubar): Add missing return value.
Andreas Schwab <schwab@suse.de>
parents:
50099
diff
changeset
|
2861 return 1; |
| 49323 | 2862 } |
| 2863 | |
| 2864 /* Get rid of the menu bar of frame F, and free its storage. | |
| 2865 This is used when deleting a frame, and when turning off the menu bar. */ | |
| 2866 | |
| 2867 void | |
| 2868 free_frame_menubar (f) | |
| 2869 FRAME_PTR f; | |
| 2870 { | |
| 2871 struct x_output *x = f->output_data.x; | |
| 2872 | |
| 2873 if (x->menubar_widget) | |
| 2874 { | |
| 2875 BLOCK_INPUT; | |
| 2876 | |
| 2877 gtk_container_remove (GTK_CONTAINER (x->vbox_widget), x->menubar_widget); | |
| 2878 /* The menubar and its children shall be deleted when removed from | |
| 2879 the container. */ | |
| 2880 x->menubar_widget = 0; | |
| 2881 FRAME_MENUBAR_HEIGHT (f) = 0; | |
| 2882 | |
| 2883 /* The height has changed, resize outer widget and set columns | |
| 2884 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
|
2885 xg_resize_outer_widget (f, FRAME_COLS (f), FRAME_LINES (f)); |
| 49323 | 2886 |
| 2887 SET_FRAME_GARBAGED (f); | |
| 2888 UNBLOCK_INPUT; | |
| 2889 } | |
| 2890 } | |
| 2891 | |
| 2892 | |
| 2893 | |
| 2894 /*********************************************************************** | |
| 2895 Scroll bar functions | |
| 2896 ***********************************************************************/ | |
| 2897 | |
| 2898 | |
| 2899 /* Setting scroll bar values invokes the callback. Use this variable | |
| 2900 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
|
2901 |
| 49323 | 2902 int xg_ignore_gtk_scrollbar; |
| 2903 | |
| 2904 /* SET_SCROLL_BAR_X_WINDOW assumes the second argument fits in | |
| 2905 32 bits. But we want to store pointers, and they may be larger | |
| 2906 than 32 bits. Keep a mapping from integer index to widget pointers | |
| 2907 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
|
2908 |
| 49323 | 2909 static struct |
| 2910 { | |
| 2911 GtkWidget **widgets; | |
| 2912 int max_size; | |
| 2913 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
|
2914 } id_to_widget; |
| 49323 | 2915 |
| 2916 /* 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
|
2917 |
| 49323 | 2918 #define ID_TO_WIDGET_INCR 32 |
| 2919 | |
| 2920 /* 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
|
2921 |
| 49323 | 2922 static int |
| 2923 xg_store_widget_in_map (w) | |
| 2924 GtkWidget *w; | |
| 2925 { | |
| 2926 int i; | |
| 2927 | |
| 2928 if (id_to_widget.max_size == id_to_widget.used) | |
| 2929 { | |
| 2930 int new_size = id_to_widget.max_size + ID_TO_WIDGET_INCR; | |
| 2931 | |
| 2932 id_to_widget.widgets = xrealloc (id_to_widget.widgets, | |
| 2933 sizeof (GtkWidget *)*new_size); | |
| 2934 | |
| 2935 for (i = id_to_widget.max_size; i < new_size; ++i) | |
| 2936 id_to_widget.widgets[i] = 0; | |
| 2937 id_to_widget.max_size = new_size; | |
| 2938 } | |
| 2939 | |
| 2940 /* Just loop over the array and find a free place. After all, | |
| 2941 how many scroll bars are we creating? Should be a small number. | |
| 2942 The check above guarantees we will find a free place. */ | |
| 2943 for (i = 0; i < id_to_widget.max_size; ++i) | |
| 2944 { | |
| 2945 if (! id_to_widget.widgets[i]) | |
| 2946 { | |
| 2947 id_to_widget.widgets[i] = w; | |
| 2948 ++id_to_widget.used; | |
| 2949 | |
| 2950 return i; | |
| 2951 } | |
| 2952 } | |
| 2953 | |
| 2954 /* Should never end up here */ | |
| 2955 abort (); | |
| 2956 } | |
| 2957 | |
| 2958 /* Remove pointer at IDX from id_to_widget. | |
| 2959 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
|
2960 |
| 49323 | 2961 static void |
| 2962 xg_remove_widget_from_map (idx) | |
| 2963 int idx; | |
| 2964 { | |
| 2965 if (idx < id_to_widget.max_size && id_to_widget.widgets[idx] != 0) | |
| 2966 { | |
| 2967 id_to_widget.widgets[idx] = 0; | |
| 2968 --id_to_widget.used; | |
| 2969 } | |
| 2970 } | |
| 2971 | |
| 2972 /* 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
|
2973 |
| 49323 | 2974 static GtkWidget * |
| 2975 xg_get_widget_from_map (idx) | |
| 2976 int idx; | |
| 2977 { | |
| 2978 if (idx < id_to_widget.max_size && id_to_widget.widgets[idx] != 0) | |
| 2979 return id_to_widget.widgets[idx]; | |
| 2980 | |
| 2981 return 0; | |
| 2982 } | |
| 2983 | |
|
53069
1218a42792ea
Implement multiple display handling for GTK.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
2984 /* Return the scrollbar id for X Window WID on display DPY. |
| 50063 | 2985 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
|
2986 |
| 50063 | 2987 int |
|
53069
1218a42792ea
Implement multiple display handling for GTK.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
2988 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
|
2989 Display *dpy; |
| 50063 | 2990 Window wid; |
| 2991 { | |
| 2992 int idx; | |
| 2993 GtkWidget *w; | |
| 2994 | |
|
53069
1218a42792ea
Implement multiple display handling for GTK.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
2995 w = xg_win_to_widget (dpy, wid); |
| 50063 | 2996 |
| 2997 if (w) | |
| 2998 { | |
| 2999 for (idx = 0; idx < id_to_widget.max_size; ++idx) | |
| 3000 if (id_to_widget.widgets[idx] == w) | |
| 3001 return idx; | |
| 3002 } | |
| 3003 | |
| 3004 return -1; | |
| 3005 } | |
| 3006 | |
| 49323 | 3007 /* Callback invoked when scroll bar WIDGET is destroyed. |
| 3008 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
|
3009 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
|
3010 |
| 49323 | 3011 static void |
| 3012 xg_gtk_scroll_destroy (widget, data) | |
| 3013 GtkWidget *widget; | |
| 3014 gpointer data; | |
| 3015 { | |
| 3016 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
|
3017 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
|
3018 |
| 49323 | 3019 p = g_object_get_data (G_OBJECT (widget), XG_LAST_SB_DATA); |
| 3020 if (p) xfree (p); | |
| 3021 xg_remove_widget_from_map (id); | |
| 3022 } | |
| 3023 | |
| 3024 /* Callback for button press/release events. Used to start timer so that | |
| 3025 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
|
3026 Also, sets bar->dragging to Qnil when dragging (button release) is done. |
| 49323 | 3027 WIDGET is the scroll bar widget the event is for (not used). |
| 3028 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
|
3029 USER_DATA points to the struct scrollbar structure. |
| 49323 | 3030 |
| 3031 Returns FALSE to tell GTK that it shall continue propagate the event | |
| 3032 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
|
3033 |
| 49323 | 3034 static gboolean |
| 3035 scroll_bar_button_cb (widget, event, user_data) | |
| 3036 GtkWidget *widget; | |
| 3037 GdkEventButton *event; | |
| 3038 gpointer user_data; | |
| 3039 { | |
| 3040 if (event->type == GDK_BUTTON_PRESS && ! xg_timer) | |
| 3041 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
|
3042 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
|
3043 { |
|
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
|
3044 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
|
3045 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
|
3046 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
|
3047 } |
|
60185
391f44959566
(xg_create_frame_widgets): UNBLOCK_INPUT on error.
Kim F. Storm <storm@cua.dk>
parents:
59913
diff
changeset
|
3048 |
| 49323 | 3049 return FALSE; |
| 3050 } | |
| 3051 | |
| 3052 /* Create a scroll bar widget for frame F. Store the scroll bar | |
| 3053 in BAR. | |
| 3054 SCROLL_CALLBACK is the callback to invoke when the value of the | |
| 3055 bar changes. | |
| 3056 SCROLL_BAR_NAME is the name we use for the scroll bar. Can be used | |
| 3057 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
|
3058 |
| 49323 | 3059 void |
| 3060 xg_create_scroll_bar (f, bar, scroll_callback, scroll_bar_name) | |
| 3061 FRAME_PTR f; | |
| 3062 struct scroll_bar *bar; | |
| 3063 GCallback scroll_callback; | |
| 3064 char *scroll_bar_name; | |
| 3065 { | |
| 3066 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
|
3067 GtkWidget *webox; |
| 49323 | 3068 GtkObject *vadj; |
| 3069 int scroll_id; | |
|
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
3070 |
| 49323 | 3071 /* Page, step increment values are not so important here, they |
| 3072 will be corrected in x_set_toolkit_scroll_bar_thumb. */ | |
| 3073 vadj = gtk_adjustment_new (XG_SB_MIN, XG_SB_MIN, XG_SB_MAX, | |
| 3074 0.1, 0.1, 0.1); | |
| 3075 | |
| 3076 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
|
3077 webox = gtk_event_box_new (); |
| 49323 | 3078 gtk_widget_set_name (wscroll, scroll_bar_name); |
| 3079 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
|
3080 |
| 49323 | 3081 scroll_id = xg_store_widget_in_map (wscroll); |
|
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
3082 |
|
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
|
3083 g_signal_connect (G_OBJECT (wscroll), |
| 49323 | 3084 "value-changed", |
| 3085 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
|
3086 (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
|
3087 /* The EMACS_INT cast avoids a warning. */ |
| 49323 | 3088 g_signal_connect (G_OBJECT (wscroll), |
| 3089 "destroy", | |
| 3090 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
|
3091 (gpointer) (EMACS_INT) scroll_id); |
| 49323 | 3092 |
| 3093 /* Connect to button press and button release to detect if any scroll bar | |
| 3094 has the pointer. */ | |
| 3095 g_signal_connect (G_OBJECT (wscroll), | |
| 3096 "button-press-event", | |
| 3097 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
|
3098 (gpointer) bar); |
| 49323 | 3099 g_signal_connect (G_OBJECT (wscroll), |
| 3100 "button-release-event", | |
| 3101 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
|
3102 (gpointer) bar); |
|
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
3103 |
|
57597
754a6433f048
* gtkutil.c (xg_frame_cleared, xg_fixed_handle_expose,
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
57575
diff
changeset
|
3104 /* 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
|
3105 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
|
3106 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
|
3107 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
|
3108 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
|
3109 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
|
3110 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
|
3111 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
|
3112 |
| 49323 | 3113 |
| 3114 /* 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
|
3115 xg_set_cursor (webox, FRAME_X_DISPLAY_INFO (f)->xg_cursor); |
| 49323 | 3116 |
| 3117 SET_SCROLL_BAR_X_WINDOW (bar, scroll_id); | |
| 3118 } | |
| 3119 | |
| 3120 /* 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
|
3121 |
| 49323 | 3122 void |
| 3123 xg_show_scroll_bar (scrollbar_id) | |
| 3124 int scrollbar_id; | |
| 3125 { | |
| 3126 GtkWidget *w = xg_get_widget_from_map (scrollbar_id); | |
| 3127 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
|
3128 gtk_widget_show_all (gtk_widget_get_parent (w)); |
| 49323 | 3129 } |
| 3130 | |
| 3131 /* 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
|
3132 |
| 49323 | 3133 void |
| 3134 xg_remove_scroll_bar (f, scrollbar_id) | |
| 3135 FRAME_PTR f; | |
| 3136 int scrollbar_id; | |
| 3137 { | |
| 3138 GtkWidget *w = xg_get_widget_from_map (scrollbar_id); | |
| 3139 if (w) | |
| 3140 { | |
|
57597
754a6433f048
* gtkutil.c (xg_frame_cleared, xg_fixed_handle_expose,
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
57575
diff
changeset
|
3141 GtkWidget *wparent = gtk_widget_get_parent (w); |
| 49323 | 3142 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
|
3143 gtk_widget_destroy (wparent); |
| 49323 | 3144 SET_FRAME_GARBAGED (f); |
| 3145 } | |
| 3146 } | |
| 3147 | |
| 3148 /* Update the position of the vertical scroll bar represented by SCROLLBAR_ID | |
| 3149 in frame F. | |
| 3150 TOP/LEFT are the new pixel positions where the bar shall appear. | |
| 3151 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
|
3152 |
| 49323 | 3153 void |
|
57597
754a6433f048
* gtkutil.c (xg_frame_cleared, xg_fixed_handle_expose,
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
57575
diff
changeset
|
3154 xg_update_scrollbar_pos (f, scrollbar_id, top, left, width, height) |
| 49323 | 3155 FRAME_PTR f; |
| 3156 int scrollbar_id; | |
| 3157 int top; | |
| 3158 int left; | |
| 3159 int width; | |
| 3160 int height; | |
| 3161 { | |
| 49572 | 3162 |
| 3163 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
|
3164 |
| 49572 | 3165 if (wscroll) |
| 3166 { | |
|
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
|
3167 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
|
3168 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
|
3169 |
|
44d086f5e08a
* gtkutil.c (xg_update_scrollbar_pos): Call XClearWindow to clear
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
53275
diff
changeset
|
3170 /* 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
|
3171 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
|
3172 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
|
3173 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
|
3174 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
|
3175 /* 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
|
3176 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
|
3177 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
|
3178 x_sync (f); |
| 49572 | 3179 SET_FRAME_GARBAGED (f); |
| 3180 cancel_mouse_face (f); | |
| 3181 } | |
| 49323 | 3182 } |
| 3183 | |
| 3184 /* Set the thumb size and position of scroll bar BAR. We are currently | |
| 3185 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
|
3186 |
| 49323 | 3187 void |
| 3188 xg_set_toolkit_scroll_bar_thumb (bar, portion, position, whole) | |
| 3189 struct scroll_bar *bar; | |
| 3190 int portion, position, whole; | |
| 3191 { | |
| 3192 GtkWidget *wscroll = xg_get_widget_from_map (SCROLL_BAR_X_WINDOW (bar)); | |
| 3193 | |
| 3194 FRAME_PTR f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window))); | |
| 3195 | |
|
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
|
3196 if (wscroll && NILP (bar->dragging)) |
| 49323 | 3197 { |
| 3198 GtkAdjustment *adj; | |
| 3199 gdouble shown; | |
| 3200 gdouble top; | |
| 3201 int size, value; | |
|
50270
fa50953c02dc
Finally (?) fix flicker in scroll bar.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
50192
diff
changeset
|
3202 int new_step; |
|
fa50953c02dc
Finally (?) fix flicker in scroll bar.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
50192
diff
changeset
|
3203 int changed = 0; |
|
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
3204 |
| 49323 | 3205 adj = gtk_range_get_adjustment (GTK_RANGE (wscroll)); |
| 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 /* 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
|
3208 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
|
3209 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
|
3210 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
|
3211 /* 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
|
3212 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
|
3213 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
|
3214 |
| 49323 | 3215 if (whole <= 0) |
| 3216 top = 0, shown = 1; | |
| 3217 else | |
| 3218 { | |
|
50270
fa50953c02dc
Finally (?) fix flicker in scroll bar.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
50192
diff
changeset
|
3219 top = (gdouble) position / whole; |
| 49323 | 3220 shown = (gdouble) portion / whole; |
| 3221 } | |
| 3222 | |
|
50270
fa50953c02dc
Finally (?) fix flicker in scroll bar.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
50192
diff
changeset
|
3223 size = shown * XG_SB_RANGE; |
|
fa50953c02dc
Finally (?) fix flicker in scroll bar.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
50192
diff
changeset
|
3224 size = min (size, XG_SB_RANGE); |
| 49323 | 3225 size = max (size, 1); |
| 3226 | |
|
50270
fa50953c02dc
Finally (?) fix flicker in scroll bar.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
50192
diff
changeset
|
3227 value = top * XG_SB_RANGE; |
|
fa50953c02dc
Finally (?) fix flicker in scroll bar.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
50192
diff
changeset
|
3228 value = min (value, XG_SB_MAX - size); |
| 49323 | 3229 value = max (value, XG_SB_MIN); |
| 3230 | |
|
50270
fa50953c02dc
Finally (?) fix flicker in scroll bar.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
50192
diff
changeset
|
3231 /* 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
|
3232 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
|
3233 |
|
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
|
3234 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
|
3235 || (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
|
3236 { |
|
50270
fa50953c02dc
Finally (?) fix flicker in scroll bar.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
50192
diff
changeset
|
3237 adj->page_size = size; |
|
fa50953c02dc
Finally (?) fix flicker in scroll bar.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
50192
diff
changeset
|
3238 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
|
3239 /* 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
|
3240 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
|
3241 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
|
3242 } |
|
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
|
3243 |
|
50270
fa50953c02dc
Finally (?) fix flicker in scroll bar.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
50192
diff
changeset
|
3244 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
|
3245 { |
|
fa50953c02dc
Finally (?) fix flicker in scroll bar.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
50192
diff
changeset
|
3246 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
|
3247 |
|
fa50953c02dc
Finally (?) fix flicker in scroll bar.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
50192
diff
changeset
|
3248 BLOCK_INPUT; |
|
fa50953c02dc
Finally (?) fix flicker in scroll bar.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
50192
diff
changeset
|
3249 |
|
fa50953c02dc
Finally (?) fix flicker in scroll bar.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
50192
diff
changeset
|
3250 /* 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
|
3251 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
|
3252 xg_ignore_gtk_scrollbar = 1; |
|
fa50953c02dc
Finally (?) fix flicker in scroll bar.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
50192
diff
changeset
|
3253 |
|
fa50953c02dc
Finally (?) fix flicker in scroll bar.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
50192
diff
changeset
|
3254 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
|
3255 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
|
3256 else if (changed) |
|
fa50953c02dc
Finally (?) fix flicker in scroll bar.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
50192
diff
changeset
|
3257 gtk_adjustment_changed (adj); |
|
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 xg_ignore_gtk_scrollbar = 0; |
|
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 UNBLOCK_INPUT; |
|
fa50953c02dc
Finally (?) fix flicker in scroll bar.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
50192
diff
changeset
|
3262 } |
| 49323 | 3263 } |
| 3264 } | |
| 3265 | |
| 3266 | |
| 3267 /*********************************************************************** | |
| 3268 Tool bar functions | |
| 3269 ***********************************************************************/ | |
| 3270 /* The key for the data we put in the GtkImage widgets. The data is | |
| 3271 the image used by Emacs. We use this to see if we need to update | |
| 3272 the GtkImage with a new image. */ | |
| 3273 #define XG_TOOL_BAR_IMAGE_DATA "emacs-tool-bar-image" | |
| 3274 | |
|
68874
8ccdd5aee32d
* gtkutil.c (xg_tool_bar_button_cb): New function.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
68651
diff
changeset
|
3275 /* 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
|
3276 get them. */ |
|
8ccdd5aee32d
* gtkutil.c (xg_tool_bar_button_cb): New function.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
68651
diff
changeset
|
3277 #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
|
3278 |
|
8ccdd5aee32d
* gtkutil.c (xg_tool_bar_button_cb): New function.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
68651
diff
changeset
|
3279 |
| 49323 | 3280 /* Callback function invoked when a tool bar item is pressed. |
| 3281 W is the button widget in the tool bar that got pressed, | |
| 3282 CLIENT_DATA is an integer that is the index of the button in the | |
| 3283 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
|
3284 |
|
68874
8ccdd5aee32d
* gtkutil.c (xg_tool_bar_button_cb): New function.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
68651
diff
changeset
|
3285 static gboolean |
|
8ccdd5aee32d
* gtkutil.c (xg_tool_bar_button_cb): New function.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
68651
diff
changeset
|
3286 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
|
3287 GtkWidget *widget; |
|
8ccdd5aee32d
* gtkutil.c (xg_tool_bar_button_cb): New function.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
68651
diff
changeset
|
3288 GdkEventButton *event; |
|
8ccdd5aee32d
* gtkutil.c (xg_tool_bar_button_cb): New function.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
68651
diff
changeset
|
3289 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
|
3290 { |
| 68922 | 3291 g_object_set_data (G_OBJECT (user_data), XG_TOOL_BAR_LAST_MODIFIER, |
| 3292 (gpointer) event->state); | |
| 3293 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
|
3294 } |
|
8ccdd5aee32d
* gtkutil.c (xg_tool_bar_button_cb): New function.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
68651
diff
changeset
|
3295 |
|
8ccdd5aee32d
* gtkutil.c (xg_tool_bar_button_cb): New function.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
68651
diff
changeset
|
3296 |
| 49323 | 3297 static void |
| 3298 xg_tool_bar_callback (w, client_data) | |
| 3299 GtkWidget *w; | |
| 3300 gpointer client_data; | |
| 3301 { | |
|
59411
ecb6689e04bf
* gtkutil.c (xg_gtk_scroll_destroy, xg_create_scroll_bar)
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
59102
diff
changeset
|
3302 /* 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
|
3303 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
|
3304 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
|
3305 |
| 49323 | 3306 FRAME_PTR f = (FRAME_PTR) g_object_get_data (G_OBJECT (w), XG_FRAME_DATA); |
| 3307 Lisp_Object key, frame; | |
| 3308 struct input_event event; | |
|
51569
e7bd8581e306
(xg_tool_bar_callback): Don't pass uninitialized
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51432
diff
changeset
|
3309 EVENT_INIT (event); |
| 49323 | 3310 |
| 3311 if (! f || ! f->n_tool_bar_items || NILP (f->tool_bar_items)) | |
| 3312 return; | |
| 3313 | |
| 3314 idx *= TOOL_BAR_ITEM_NSLOTS; | |
|
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
3315 |
| 49323 | 3316 key = AREF (f->tool_bar_items, idx + TOOL_BAR_ITEM_KEY); |
| 3317 XSETFRAME (frame, f); | |
| 3318 event.kind = TOOL_BAR_EVENT; | |
| 3319 event.frame_or_window = frame; | |
| 3320 event.arg = frame; | |
| 3321 kbd_buffer_store_event (&event); | |
| 3322 | |
| 3323 event.kind = TOOL_BAR_EVENT; | |
| 3324 event.frame_or_window = frame; | |
| 3325 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
|
3326 /* 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
|
3327 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
|
3328 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
|
3329 event.modifiers = x_x_to_emacs_modifiers (FRAME_X_DISPLAY_INFO (f), mod); |
| 49323 | 3330 kbd_buffer_store_event (&event); |
| 3331 } | |
| 3332 | |
| 3333 /* This callback is called when a tool bar is detached. We must set | |
| 3334 the height of the tool bar to zero when this happens so frame sizes | |
| 3335 are correctly calculated. | |
| 3336 WBOX is the handle box widget that enables detach/attach of the tool bar. | |
| 3337 W is the tool bar widget. | |
| 3338 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
|
3339 |
| 49323 | 3340 static void |
| 3341 xg_tool_bar_detach_callback (wbox, w, client_data) | |
| 3342 GtkHandleBox *wbox; | |
| 3343 GtkWidget *w; | |
| 3344 gpointer client_data; | |
| 3345 { | |
| 3346 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
|
3347 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
|
3348 |
|
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
|
3349 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
|
3350 NULL); |
| 49323 | 3351 |
| 3352 if (f) | |
| 3353 { | |
|
59420
eb72706060ad
* xterm.h (struct x_output): New member, toolbar_detached.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
59411
diff
changeset
|
3354 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
|
3355 |
| 49323 | 3356 /* When detaching a tool bar, not everything dissapear. There are |
| 3357 a few pixels left that are used to drop the tool bar back into | |
| 3358 place. */ | |
| 3359 FRAME_TOOLBAR_HEIGHT (f) = 2; | |
| 3360 | |
| 3361 /* The height has changed, resize outer widget and set columns | |
| 3362 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
|
3363 xg_resize_outer_widget (f, FRAME_COLS (f), FRAME_LINES (f)); |
| 49323 | 3364 } |
| 3365 } | |
| 3366 | |
| 3367 /* This callback is called when a tool bar is reattached. We must set | |
| 3368 the height of the tool bar when this happens so frame sizes | |
| 3369 are correctly calculated. | |
| 3370 WBOX is the handle box widget that enables detach/attach of the tool bar. | |
| 3371 W is the tool bar widget. | |
| 3372 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
|
3373 |
| 49323 | 3374 static void |
| 3375 xg_tool_bar_attach_callback (wbox, w, client_data) | |
| 3376 GtkHandleBox *wbox; | |
| 3377 GtkWidget *w; | |
| 3378 gpointer client_data; | |
| 3379 { | |
| 3380 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
|
3381 g_object_set (G_OBJECT (w), "show-arrow", TRUE, NULL); |
| 49323 | 3382 |
| 3383 if (f) | |
| 3384 { | |
| 3385 GtkRequisition req; | |
| 3386 | |
|
59420
eb72706060ad
* xterm.h (struct x_output): New member, toolbar_detached.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
59411
diff
changeset
|
3387 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
|
3388 |
| 49323 | 3389 gtk_widget_size_request (w, &req); |
| 3390 FRAME_TOOLBAR_HEIGHT (f) = req.height; | |
| 3391 | |
| 3392 /* 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
|
3393 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
|
3394 xg_resize_outer_widget (f, FRAME_COLS (f), FRAME_LINES (f)); |
| 49323 | 3395 } |
| 3396 } | |
| 3397 | |
| 3398 /* This callback is called when the mouse enters or leaves a tool bar item. | |
| 3399 It is used for displaying and hiding the help text. | |
| 3400 W is the tool bar item, a button. | |
| 3401 EVENT is either an enter event or leave event. | |
| 3402 CLIENT_DATA is an integer that is the index of the button in the | |
| 3403 tool bar. 0 is the first button. | |
| 3404 | |
| 3405 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
|
3406 |
| 49323 | 3407 static gboolean |
| 3408 xg_tool_bar_help_callback (w, event, client_data) | |
| 3409 GtkWidget *w; | |
| 3410 GdkEventCrossing *event; | |
| 3411 gpointer client_data; | |
| 3412 { | |
|
59411
ecb6689e04bf
* gtkutil.c (xg_gtk_scroll_destroy, xg_create_scroll_bar)
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
59102
diff
changeset
|
3413 /* 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
|
3414 int idx = (int) (EMACS_INT) client_data; |
| 49323 | 3415 FRAME_PTR f = (FRAME_PTR) g_object_get_data (G_OBJECT (w), XG_FRAME_DATA); |
| 3416 Lisp_Object help, frame; | |
| 3417 | |
| 3418 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
|
3419 return FALSE; |
| 49323 | 3420 |
| 3421 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
|
3422 return FALSE; |
| 49323 | 3423 |
| 3424 if (event->type == GDK_ENTER_NOTIFY) | |
| 3425 { | |
| 3426 idx *= TOOL_BAR_ITEM_NSLOTS; | |
| 3427 help = AREF (f->tool_bar_items, idx + TOOL_BAR_ITEM_HELP); | |
| 3428 | |
| 3429 if (NILP (help)) | |
| 3430 help = AREF (f->tool_bar_items, idx + TOOL_BAR_ITEM_CAPTION); | |
| 3431 } | |
| 3432 else | |
| 3433 help = Qnil; | |
| 3434 | |
| 3435 XSETFRAME (frame, f); | |
| 3436 kbd_buffer_store_help_event (frame, help); | |
| 3437 | |
| 3438 return FALSE; | |
| 3439 } | |
| 3440 | |
| 3441 | |
|
49826
e99f1a981a3b
* gtkutil.c (xg_tool_bar_expose_callback): New function.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
49600
diff
changeset
|
3442 /* 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
|
3443 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
|
3444 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
|
3445 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
|
3446 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
|
3447 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
|
3448 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
|
3449 |
|
e99f1a981a3b
* gtkutil.c (xg_tool_bar_expose_callback): New function.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
49600
diff
changeset
|
3450 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
|
3451 |
|
49826
e99f1a981a3b
* gtkutil.c (xg_tool_bar_expose_callback): New function.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
49600
diff
changeset
|
3452 static gboolean |
| 50063 | 3453 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
|
3454 GtkWidget *w; |
|
e99f1a981a3b
* gtkutil.c (xg_tool_bar_expose_callback): New function.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
49600
diff
changeset
|
3455 GdkEventExpose *event; |
|
e99f1a981a3b
* gtkutil.c (xg_tool_bar_expose_callback): New function.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
49600
diff
changeset
|
3456 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
|
3457 { |
|
50333
60da21fd968b
* gtkutil.c (xg_tool_bar_item_expose_callback): Reduce size
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
50318
diff
changeset
|
3458 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
|
3459 |
|
60da21fd968b
* gtkutil.c (xg_tool_bar_item_expose_callback): Reduce size
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
50318
diff
changeset
|
3460 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
|
3461 |
|
60da21fd968b
* gtkutil.c (xg_tool_bar_item_expose_callback): Reduce size
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
50318
diff
changeset
|
3462 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
|
3463 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
|
3464 |
|
53069
1218a42792ea
Implement multiple display handling for GTK.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
3465 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
|
3466 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
|
3467 |
|
50333
60da21fd968b
* gtkutil.c (xg_tool_bar_item_expose_callback): Reduce size
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
50318
diff
changeset
|
3468 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
|
3469 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
|
3470 |
|
49826
e99f1a981a3b
* gtkutil.c (xg_tool_bar_expose_callback): New function.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
49600
diff
changeset
|
3471 return FALSE; |
|
e99f1a981a3b
* gtkutil.c (xg_tool_bar_expose_callback): New function.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
49600
diff
changeset
|
3472 } |
|
e99f1a981a3b
* gtkutil.c (xg_tool_bar_expose_callback): New function.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
49600
diff
changeset
|
3473 |
| 50063 | 3474 /* This callback is called when a tool bar shall be redrawn. |
| 3475 We need to update the tool bar from here in case the image cache | |
| 3476 has deleted the pixmaps used in the tool bar. | |
| 3477 W is the GtkToolbar to be redrawn. | |
| 3478 EVENT is the expose event for W. | |
| 3479 CLIENT_DATA is pointing to the frame for this tool bar. | |
| 3480 | |
| 3481 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
|
3482 |
| 50063 | 3483 static gboolean |
| 3484 xg_tool_bar_expose_callback (w, event, client_data) | |
| 3485 GtkWidget *w; | |
| 3486 GdkEventExpose *event; | |
| 3487 gpointer client_data; | |
| 3488 { | |
|
53069
1218a42792ea
Implement multiple display handling for GTK.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
52981
diff
changeset
|
3489 update_frame_tool_bar ((FRAME_PTR) client_data); |
| 50063 | 3490 return FALSE; |
| 3491 } | |
| 3492 | |
|
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 /* 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
|
3494 |
| 49323 | 3495 static void |
| 3496 xg_create_tool_bar (f) | |
| 3497 FRAME_PTR f; | |
| 3498 { | |
| 3499 struct x_output *x = f->output_data.x; | |
| 3500 GtkRequisition req; | |
| 3501 int vbox_pos = x->menubar_widget ? 1 : 0; | |
| 3502 | |
| 3503 x->toolbar_widget = gtk_toolbar_new (); | |
| 3504 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
|
3505 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
|
3506 |
| 49323 | 3507 gtk_container_add (GTK_CONTAINER (x->handlebox_widget), |
| 3508 x->toolbar_widget); | |
|
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
3509 |
| 49323 | 3510 gtk_box_pack_start (GTK_BOX (x->vbox_widget), x->handlebox_widget, |
| 3511 FALSE, FALSE, 0); | |
|
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
3512 |
| 49323 | 3513 gtk_box_reorder_child (GTK_BOX (x->vbox_widget), x->handlebox_widget, |
| 3514 vbox_pos); | |
| 3515 | |
|
49826
e99f1a981a3b
* gtkutil.c (xg_tool_bar_expose_callback): New function.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
49600
diff
changeset
|
3516 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
|
3517 |
|
e99f1a981a3b
* gtkutil.c (xg_tool_bar_expose_callback): New function.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
49600
diff
changeset
|
3518 /* 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
|
3519 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
|
3520 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
|
3521 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
|
3522 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
|
3523 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
|
3524 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
|
3525 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
|
3526 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
|
3527 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
|
3528 |
| 49323 | 3529 g_signal_connect (G_OBJECT (x->handlebox_widget), "child-detached", |
| 3530 G_CALLBACK (xg_tool_bar_detach_callback), f); | |
| 3531 g_signal_connect (G_OBJECT (x->handlebox_widget), "child-attached", | |
| 3532 G_CALLBACK (xg_tool_bar_attach_callback), f); | |
| 50063 | 3533 g_signal_connect (G_OBJECT (x->toolbar_widget), |
| 3534 "expose-event", | |
| 3535 G_CALLBACK (xg_tool_bar_expose_callback), | |
| 3536 f); | |
| 49323 | 3537 |
| 3538 gtk_widget_show_all (x->handlebox_widget); | |
| 3539 | |
| 3540 gtk_widget_size_request (x->toolbar_widget, &req); | |
| 3541 FRAME_TOOLBAR_HEIGHT (f) = req.height; | |
|
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
3542 |
| 49323 | 3543 /* The height has changed, resize outer widget and set columns |
| 3544 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
|
3545 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
|
3546 |
| 49323 | 3547 SET_FRAME_GARBAGED (f); |
| 3548 } | |
| 3549 | |
|
57715
cdc48cdd5b0e
* gtkutil.c: Put empty line between comment and function body.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
57597
diff
changeset
|
3550 /* 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
|
3551 |
| 49323 | 3552 void |
| 3553 update_frame_tool_bar (f) | |
| 3554 FRAME_PTR f; | |
| 3555 { | |
| 3556 int i; | |
| 3557 GtkRequisition old_req, new_req; | |
| 3558 GList *icon_list; | |
| 49572 | 3559 GList *iter; |
| 49323 | 3560 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
|
3561 int hmargin, vmargin; |
| 49323 | 3562 |
| 3563 if (! FRAME_GTK_WIDGET (f)) | |
| 3564 return; | |
| 3565 | |
| 3566 BLOCK_INPUT; | |
|
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
3567 |
|
59084
6a0b8f23858b
* gtkutil.c (update_frame_tool_bar): Make the value of
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
58818
diff
changeset
|
3568 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
|
3569 && 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
|
3570 { |
|
6a0b8f23858b
* gtkutil.c (update_frame_tool_bar): Make the value of
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
58818
diff
changeset
|
3571 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
|
3572 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
|
3573 } |
|
6a0b8f23858b
* gtkutil.c (update_frame_tool_bar): Make the value of
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
58818
diff
changeset
|
3574 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
|
3575 { |
|
6a0b8f23858b
* gtkutil.c (update_frame_tool_bar): Make the value of
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
58818
diff
changeset
|
3576 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
|
3577 && 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
|
3578 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
|
3579 |
|
6a0b8f23858b
* gtkutil.c (update_frame_tool_bar): Make the value of
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
58818
diff
changeset
|
3580 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
|
3581 && 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
|
3582 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
|
3583 } |
|
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 /* 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
|
3586 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
|
3587 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
|
3588 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
|
3589 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
|
3590 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
|
3591 |
| 49323 | 3592 if (! x->toolbar_widget) |
| 3593 xg_create_tool_bar (f); | |
| 3594 | |
| 3595 gtk_widget_size_request (x->toolbar_widget, &old_req); | |
| 3596 | |
| 3597 icon_list = gtk_container_get_children (GTK_CONTAINER (x->toolbar_widget)); | |
| 49572 | 3598 iter = icon_list; |
|
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
3599 |
| 49323 | 3600 for (i = 0; i < f->n_tool_bar_items; ++i) |
| 3601 { | |
| 3602 #define PROP(IDX) AREF (f->tool_bar_items, i * TOOL_BAR_ITEM_NSLOTS + (IDX)) | |
| 3603 | |
| 3604 int enabled_p = !NILP (PROP (TOOL_BAR_ITEM_ENABLED_P)); | |
| 3605 int selected_p = !NILP (PROP (TOOL_BAR_ITEM_SELECTED_P)); | |
| 3606 int idx; | |
| 3607 int img_id; | |
| 3608 struct image *img; | |
| 3609 Lisp_Object image; | |
| 49572 | 3610 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
|
3611 |
| 49572 | 3612 if (iter) iter = g_list_next (iter); |
| 49323 | 3613 |
| 3614 /* If image is a vector, choose the image according to the | |
| 3615 button state. */ | |
| 3616 image = PROP (TOOL_BAR_ITEM_IMAGES); | |
| 3617 if (VECTORP (image)) | |
| 3618 { | |
| 3619 if (enabled_p) | |
| 3620 idx = (selected_p | |
| 3621 ? TOOL_BAR_IMAGE_ENABLED_SELECTED | |
| 3622 : TOOL_BAR_IMAGE_ENABLED_DESELECTED); | |
| 3623 else | |
| 3624 idx = (selected_p | |
| 3625 ? TOOL_BAR_IMAGE_DISABLED_SELECTED | |
| 3626 : TOOL_BAR_IMAGE_DISABLED_DESELECTED); | |
| 3627 | |
| 3628 xassert (ASIZE (image) >= idx); | |
| 3629 image = AREF (image, idx); | |
| 3630 } | |
| 3631 else | |
| 3632 idx = -1; | |
| 3633 | |
| 3634 /* Ignore invalid image specifications. */ | |
| 3635 if (!valid_image_p (image)) | |
| 3636 { | |
| 3637 if (wicon) gtk_widget_hide (wicon); | |
| 3638 continue; | |
| 3639 } | |
| 3640 | |
| 3641 img_id = lookup_image (f, image); | |
| 3642 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
|
3643 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
|
3644 |
|
f2be5cd8262f
gtkutil.c (update_frame_tool_bar): Call prepare_image_for_display
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
49434
diff
changeset
|
3645 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
|
3646 { |
|
f2be5cd8262f
gtkutil.c (update_frame_tool_bar): Call prepare_image_for_display
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
49434
diff
changeset
|
3647 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
|
3648 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
|
3649 } |
|
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
3650 |
| 49323 | 3651 if (! wicon) |
| 3652 { | |
|
56112
e4cfda8330d5
* gtkutil.c (xg_get_image_for_pixmap): New function.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
55342
diff
changeset
|
3653 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
|
3654 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
|
3655 |
|
59084
6a0b8f23858b
* gtkutil.c (update_frame_tool_bar): Make the value of
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
58818
diff
changeset
|
3656 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
|
3657 |
|
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
|
3658 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
|
3659 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
|
3660 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
|
3661 /* 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
|
3662 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
|
3663 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
|
3664 (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
|
3665 |
|
4e4d545ce006
* gtkutil.c (update_frame_tool_bar): Use new tool bar functions
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
68100
diff
changeset
|
3666 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
|
3667 gtk_widget_show (GTK_WIDGET (w)); |
|
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
3668 |
| 49323 | 3669 /* Save the image so we can see if an update is needed when |
| 3670 this function is called again. */ | |
| 3671 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
|
3672 (gpointer)img->pixmap); |
| 49323 | 3673 |
|
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
|
3674 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
|
3675 |
|
49826
e99f1a981a3b
* gtkutil.c (xg_tool_bar_expose_callback): New function.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
49600
diff
changeset
|
3676 /* Catch expose events to overcome an annoying redraw bug, see |
| 50063 | 3677 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
|
3678 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
|
3679 "expose-event", |
| 50063 | 3680 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
|
3681 0); |
|
e99f1a981a3b
* gtkutil.c (xg_tool_bar_expose_callback): New function.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
49600
diff
changeset
|
3682 |
|
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
|
3683 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
|
3684 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
|
3685 |
| 49323 | 3686 while (! GTK_IS_BUTTON (w)) |
| 3687 w = gtk_widget_get_parent (w); | |
|
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
3688 |
|
68874
8ccdd5aee32d
* gtkutil.c (xg_tool_bar_button_cb): New function.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
68651
diff
changeset
|
3689 /* 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
|
3690 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
|
3691 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
|
3692 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
|
3693 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
|
3694 ti); |
|
8ccdd5aee32d
* gtkutil.c (xg_tool_bar_button_cb): New function.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
68651
diff
changeset
|
3695 |
|
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
|
3696 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
|
3697 |
|
4e4d545ce006
* gtkutil.c (update_frame_tool_bar): Use new tool bar functions
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
68100
diff
changeset
|
3698 /* 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
|
3699 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
|
3700 "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
|
3701 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
|
3702 /* 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
|
3703 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
|
3704 "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
|
3705 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
|
3706 (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
|
3707 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
|
3708 "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
|
3709 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
|
3710 (gpointer) (EMACS_INT) i); |
| 49323 | 3711 } |
| 3712 else | |
| 3713 { | |
| 3714 /* The child of the tool bar is a button. Inside that button | |
| 3715 is a vbox. Inside that vbox is the GtkImage. */ | |
| 3716 GtkWidget *wvbox = gtk_bin_get_child (GTK_BIN (wicon)); | |
| 49572 | 3717 GList *chlist = gtk_container_get_children (GTK_CONTAINER (wvbox)); |
| 3718 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
|
3719 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
|
3720 XG_TOOL_BAR_IMAGE_DATA); |
| 49572 | 3721 g_list_free (chlist); |
| 49323 | 3722 |
|
59084
6a0b8f23858b
* gtkutil.c (update_frame_tool_bar): Make the value of
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
58818
diff
changeset
|
3723 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
|
3724 |
|
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
|
3725 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
|
3726 (void) xg_get_image_for_pixmap (f, img, x->widget, wimage); |
| 49323 | 3727 |
| 3728 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
|
3729 (gpointer)img->pixmap); |
| 49323 | 3730 |
| 3731 gtk_widget_set_sensitive (wicon, enabled_p); | |
| 3732 gtk_widget_show (wicon); | |
| 3733 } | |
|
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49572
diff
changeset
|
3734 |
| 49323 | 3735 #undef PROP |
| 3736 } | |
| 3737 | |
| 3738 /* Remove buttons not longer needed. We just hide them so they | |
| 3739 can be reused later on. */ | |
| 49572 | 3740 while (iter) |
| 49323 | 3741 { |
| 49572 | 3742 GtkWidget *w = GTK_WIDGET (iter->data); |
| 49323 | 3743 gtk_widget_hide (w); |
| 49572 | 3744 iter = g_list_next (iter); |
| 49323 | 3745 } |
| 3746 | |
| 3747 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
|
3748 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
|
3749 && ! FRAME_X_OUTPUT (f)->toolbar_detached) |
| 49323 | 3750 { |
| 3751 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
|
3752 xg_resize_outer_widget (f, FRAME_COLS (f), FRAME_LINES (f)); |
| 49323 | 3753 } |
| 3754 | |
| 49572 | 3755 if (icon_list) g_list_free (icon_list); |
| 3756 | |
| 49323 | 3757 UNBLOCK_INPUT; |
| 3758 } | |
| 3759 | |
|
57715
cdc48cdd5b0e
* gtkutil.c: Put empty line between comment and function body.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
57597
diff
changeset
|
3760 /* 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
|
3761 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
|
3762 |
| 49323 | 3763 void |
| 3764 free_frame_tool_bar (f) | |
| 3765 FRAME_PTR f; | |
| 3766 { | |
| 3767 struct x_output *x = f->output_data.x; | |
| 3768 | |
| 3769 if (x->toolbar_widget) | |
| 3770 { | |
| 3771 BLOCK_INPUT; | |
| 3772 gtk_container_remove (GTK_CONTAINER (x->vbox_widget), | |
| 3773 x->handlebox_widget); | |
| 3774 x->toolbar_widget = 0; | |
| 3775 x->handlebox_widget = 0; | |
| 3776 FRAME_TOOLBAR_HEIGHT (f) = 0; | |
| 3777 | |
| 3778 /* The height has changed, resize outer widget and set columns | |
| 3779 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
|
3780 xg_resize_outer_widget (f, FRAME_COLS (f), FRAME_LINES (f)); |
| 49323 | 3781 |
| 3782 SET_FRAME_GARBAGED (f); | |
| 3783 UNBLOCK_INPUT; | |
| 3784 } | |
| 3785 } | |
| 3786 | |
| 3787 | |
| 3788 | |
| 3789 /*********************************************************************** | |
| 3790 Initializing | |
| 3791 ***********************************************************************/ | |
| 3792 void | |
| 3793 xg_initialize () | |
| 3794 { | |
|
59102
0096c58ce34a
* xmenu.c (popup_get_selection): Pop down on C-g.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
59084
diff
changeset
|
3795 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
|
3796 |
| 49323 | 3797 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
|
3798 xg_detached_menus = 0; |
| 49323 | 3799 xg_menu_cb_list.prev = xg_menu_cb_list.next = |
| 3800 xg_menu_item_cb_list.prev = xg_menu_item_cb_list.next = 0; | |
| 3801 | |
|
49419
6562bb5f04aa
gtkutil.c (xg_initialize): Initialize id_to_widget here instead
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
49359
diff
changeset
|
3802 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
|
3803 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
|
3804 |
| 49323 | 3805 /* Remove F10 as a menu accelerator, it does not mix well with Emacs key |
| 3806 bindings. It doesn't seem to be any way to remove properties, | |
| 3807 so we set it to VoidSymbol which in X means "no key". */ | |
| 3808 gtk_settings_set_string_property (gtk_settings_get_default (), | |
| 3809 "gtk-menu-bar-accel", | |
| 3810 "VoidSymbol", | |
| 3811 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
|
3812 |
|
6562bb5f04aa
gtkutil.c (xg_initialize): Initialize id_to_widget here instead
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
49359
diff
changeset
|
3813 /* 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
|
3814 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
|
3815 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
|
3816 "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
|
3817 "Emacs", |
|
6562bb5f04aa
gtkutil.c (xg_initialize): Initialize id_to_widget here instead
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
49359
diff
changeset
|
3818 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
|
3819 |
|
0096c58ce34a
* xmenu.c (popup_get_selection): Pop down on C-g.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
59084
diff
changeset
|
3820 /* 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
|
3821 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
|
3822 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
|
3823 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
|
3824 "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
|
3825 |
|
0096c58ce34a
* xmenu.c (popup_get_selection): Pop down on C-g.
Jan Dj?rv <jan.h.d@swipnet.se>
parents:
59084
diff
changeset
|
3826 /* 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
|
3827 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
|
3828 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
|
3829 "cancel", 0); |
| 49323 | 3830 } |
| 3831 | |
| 3832 #endif /* USE_GTK */ | |
| 52401 | 3833 |
| 3834 /* arch-tag: fe7104da-bc1e-4aba-9bd1-f349c528f7e3 | |
| 3835 (do not change this comment) */ |
