diff options
| author | Paul Eggert | 2011-06-15 11:07:38 -0700 |
|---|---|---|
| committer | Paul Eggert | 2011-06-15 11:07:38 -0700 |
| commit | ff672d2c8785de6faba84a400fb8153e9fa07cd2 (patch) | |
| tree | 4c5dc68b7a92e54c86e47f3bd9a804c14be57091 /src | |
| parent | e69dafade3ccd5c2997a3f6fd6c7bea29e75ad8e (diff) | |
| parent | b96e6cde3e311cd79f8ad134291d41c8c64cc6ad (diff) | |
| download | emacs-ff672d2c8785de6faba84a400fb8153e9fa07cd2.tar.gz emacs-ff672d2c8785de6faba84a400fb8153e9fa07cd2.zip | |
Merge from trunk.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 30 | ||||
| -rw-r--r-- | src/emacsgtkfixed.c | 123 | ||||
| -rw-r--r-- | src/emacsgtkfixed.h | 58 | ||||
| -rw-r--r-- | src/gtkutil.c | 76 | ||||
| -rw-r--r-- | src/gtkutil.h | 2 | ||||
| -rw-r--r-- | src/xfns.c | 2 |
6 files changed, 275 insertions, 16 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index e477162b32b..87f64244c48 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,12 +1,12 @@ | |||
| 1 | 2011-06-15 Paul Eggert <eggert@cs.ucla.edu> | 1 | 2011-06-15 Paul Eggert <eggert@cs.ucla.edu> |
| 2 | 2 | ||
| 3 | Integer overflow and signedness fixes. | ||
| 4 | |||
| 3 | * fileio.c: Don't assume EMACS_INT fits in off_t. | 5 | * fileio.c: Don't assume EMACS_INT fits in off_t. |
| 4 | (emacs_lseek): New static function. | 6 | (emacs_lseek): New static function. |
| 5 | (Finsert_file_contents, Fwrite_region): Use it. | 7 | (Finsert_file_contents, Fwrite_region): Use it. |
| 6 | Use SEEK_SET, SEEK_CUR, SEEK_END as appropriate. | 8 | Use SEEK_SET, SEEK_CUR, SEEK_END as appropriate. |
| 7 | 9 | ||
| 8 | 2011-06-14 Paul Eggert <eggert@cs.ucla.edu> | ||
| 9 | |||
| 10 | * fns.c (Fload_average): Don't assume 100 * load average fits in int. | 10 | * fns.c (Fload_average): Don't assume 100 * load average fits in int. |
| 11 | 11 | ||
| 12 | * fns.c: Don't overflow int when computing a list length. | 12 | * fns.c: Don't overflow int when computing a list length. |
| @@ -66,8 +66,6 @@ | |||
| 66 | * vm-limit.c (check_memory_limits): Fix incorrect extern function decls. | 66 | * vm-limit.c (check_memory_limits): Fix incorrect extern function decls. |
| 67 | * mem-limits.h (SIZE): Remove; no longer used. | 67 | * mem-limits.h (SIZE): Remove; no longer used. |
| 68 | 68 | ||
| 69 | 2011-06-13 Paul Eggert <eggert@cs.ucla.edu> | ||
| 70 | |||
| 71 | * xterm.c (x_alloc_nearest_color_1): Prefer int to long when int works. | 69 | * xterm.c (x_alloc_nearest_color_1): Prefer int to long when int works. |
| 72 | 70 | ||
| 73 | Remove unnecessary casts. | 71 | Remove unnecessary casts. |
| @@ -247,6 +245,30 @@ | |||
| 247 | 245 | ||
| 248 | * alloc.c (Fmake_string): Check for out-of-range init. | 246 | * alloc.c (Fmake_string): Check for out-of-range init. |
| 249 | 247 | ||
| 248 | 2011-06-14 Jan Djärv <jan.h.d@swipnet.se> | ||
| 249 | |||
| 250 | * xfns.c (x_set_scroll_bar_default_width): Remove argument to | ||
| 251 | xg_get_default_scrollbar_width. | ||
| 252 | |||
| 253 | * gtkutil.c: Include emacsgtkfixed.h if HAVE_GTK3. | ||
| 254 | (int_gtk_range_get_value): Move to the scroll bar part of the file. | ||
| 255 | (style_changed_cb): Call update_theme_scrollbar_width and call | ||
| 256 | x_set_scroll_bar_default_width and xg_frame_set_char_size for | ||
| 257 | all frames (Bug#8505). | ||
| 258 | (xg_create_frame_widgets): Call emacs_fixed_new if HAVE_GTK3 (Bug#8505). | ||
| 259 | Call gtk_window_set_resizable if HAVE_GTK3. | ||
| 260 | (x_wm_set_size_hint): Call emacs_fixed_set_min_size with min width | ||
| 261 | and height if HAVE_GTK3 (Bug#8505). | ||
| 262 | (scroll_bar_width_for_theme): New variable. | ||
| 263 | (update_theme_scrollbar_width): New function. | ||
| 264 | (xg_get_default_scrollbar_width): Move code to | ||
| 265 | update_theme_scrollbar_width, just return scroll_bar_width_for_theme. | ||
| 266 | (xg_initialize): Call update_theme_scrollbar_width. | ||
| 267 | |||
| 268 | * gtkutil.h (xg_get_default_scrollbar_width): Remove argument. | ||
| 269 | |||
| 270 | * emacsgtkfixed.c, emacsgtkfixed.h: New files. | ||
| 271 | |||
| 250 | 2011-06-12 Martin Rudalics <rudalics@gmx.at> | 272 | 2011-06-12 Martin Rudalics <rudalics@gmx.at> |
| 251 | 273 | ||
| 252 | * frame.c (make_frame): Call other_buffer_safely instead of | 274 | * frame.c (make_frame): Call other_buffer_safely instead of |
diff --git a/src/emacsgtkfixed.c b/src/emacsgtkfixed.c new file mode 100644 index 00000000000..fe3514bce93 --- /dev/null +++ b/src/emacsgtkfixed.c | |||
| @@ -0,0 +1,123 @@ | |||
| 1 | /* A Gtk Widget that inherits GtkFixed, but can be shrinked. | ||
| 2 | |||
| 3 | Copyright (C) 2011 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | This file is part of GNU Emacs. | ||
| 6 | |||
| 7 | GNU Emacs is free software: you can redistribute it and/or modify | ||
| 8 | it under the terms of the GNU General Public License as published by | ||
| 9 | the Free Software Foundation, either version 3 of the License, or | ||
| 10 | (at your option) any later version. | ||
| 11 | |||
| 12 | GNU Emacs is distributed in the hope that it will be useful, | ||
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | GNU General Public License for more details. | ||
| 16 | |||
| 17 | You should have received a copy of the GNU General Public License | ||
| 18 | along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | ||
| 19 | |||
| 20 | #include "emacsgtkfixed.h" | ||
| 21 | |||
| 22 | |||
| 23 | struct _EmacsFixedPrivate | ||
| 24 | { | ||
| 25 | int minwidth, minheight; | ||
| 26 | }; | ||
| 27 | |||
| 28 | |||
| 29 | static void emacs_fixed_get_preferred_width (GtkWidget *widget, | ||
| 30 | gint *minimum, | ||
| 31 | gint *natural); | ||
| 32 | static void emacs_fixed_get_preferred_height (GtkWidget *widget, | ||
| 33 | gint *minimum, | ||
| 34 | gint *natural); | ||
| 35 | G_DEFINE_TYPE (EmacsFixed, emacs_fixed, GTK_TYPE_FIXED) | ||
| 36 | |||
| 37 | static void | ||
| 38 | emacs_fixed_class_init (EmacsFixedClass *klass) | ||
| 39 | { | ||
| 40 | GtkWidgetClass *widget_class; | ||
| 41 | GtkFixedClass *fixed_class; | ||
| 42 | |||
| 43 | widget_class = (GtkWidgetClass*) klass; | ||
| 44 | fixed_class = (GtkFixedClass*) klass; | ||
| 45 | |||
| 46 | widget_class->get_preferred_width = emacs_fixed_get_preferred_width; | ||
| 47 | widget_class->get_preferred_height = emacs_fixed_get_preferred_height; | ||
| 48 | g_type_class_add_private (klass, sizeof (EmacsFixedPrivate)); | ||
| 49 | } | ||
| 50 | |||
| 51 | static GType | ||
| 52 | emacs_fixed_child_type (GtkFixed *container) | ||
| 53 | { | ||
| 54 | return GTK_TYPE_WIDGET; | ||
| 55 | } | ||
| 56 | |||
| 57 | static void | ||
| 58 | emacs_fixed_init (EmacsFixed *fixed) | ||
| 59 | { | ||
| 60 | fixed->priv = G_TYPE_INSTANCE_GET_PRIVATE (fixed, EMACS_TYPE_FIXED, | ||
| 61 | EmacsFixedPrivate); | ||
| 62 | fixed->priv->minwidth = fixed->priv->minheight = 0; | ||
| 63 | } | ||
| 64 | |||
| 65 | /** | ||
| 66 | * emacs_fixed_new: | ||
| 67 | * | ||
| 68 | * Creates a new #EmacsFixed. | ||
| 69 | * | ||
| 70 | * Returns: a new #EmacsFixed. | ||
| 71 | */ | ||
| 72 | GtkWidget* | ||
| 73 | emacs_fixed_new (void) | ||
| 74 | { | ||
| 75 | return g_object_new (EMACS_TYPE_FIXED, NULL); | ||
| 76 | } | ||
| 77 | |||
| 78 | static GtkWidgetClass * | ||
| 79 | get_parent_class (EmacsFixed *fixed) | ||
| 80 | { | ||
| 81 | EmacsFixedClass *klass = EMACS_FIXED_GET_CLASS (fixed); | ||
| 82 | GtkFixedClass *parent_class = g_type_class_peek_parent (klass); | ||
| 83 | return (GtkWidgetClass*) parent_class; | ||
| 84 | } | ||
| 85 | |||
| 86 | static void | ||
| 87 | emacs_fixed_get_preferred_width (GtkWidget *widget, | ||
| 88 | gint *minimum, | ||
| 89 | gint *natural) | ||
| 90 | { | ||
| 91 | EmacsFixed *fixed = EMACS_FIXED (widget); | ||
| 92 | EmacsFixedPrivate *priv = fixed->priv; | ||
| 93 | GtkWidgetClass *widget_class = get_parent_class (fixed); | ||
| 94 | widget_class->get_preferred_width (widget, minimum, natural); | ||
| 95 | if (minimum) *minimum = priv->minwidth; | ||
| 96 | } | ||
| 97 | |||
| 98 | static void | ||
| 99 | emacs_fixed_get_preferred_height (GtkWidget *widget, | ||
| 100 | gint *minimum, | ||
| 101 | gint *natural) | ||
| 102 | { | ||
| 103 | EmacsFixed *fixed = EMACS_FIXED (widget); | ||
| 104 | EmacsFixedPrivate *priv = fixed->priv; | ||
| 105 | GtkWidgetClass *widget_class = get_parent_class (fixed); | ||
| 106 | widget_class->get_preferred_height (widget, minimum, natural); | ||
| 107 | if (minimum) *minimum = priv->minheight; | ||
| 108 | } | ||
| 109 | |||
| 110 | void | ||
| 111 | emacs_fixed_set_min_size (EmacsFixed *widget, int width, int height) | ||
| 112 | { | ||
| 113 | EmacsFixedPrivate *priv = widget->priv; | ||
| 114 | GtkWidgetClass *widget_class = get_parent_class (widget); | ||
| 115 | int mw, nw, mh, nh; | ||
| 116 | |||
| 117 | widget_class->get_preferred_height (GTK_WIDGET (widget), &mh, &nh); | ||
| 118 | widget_class->get_preferred_width (GTK_WIDGET (widget), &mw, &nw); | ||
| 119 | |||
| 120 | /* Gtk complains if min size is less than natural size. */ | ||
| 121 | if (width <= nw) priv->minwidth = width; | ||
| 122 | if (height <= nh) priv->minheight = height; | ||
| 123 | } | ||
diff --git a/src/emacsgtkfixed.h b/src/emacsgtkfixed.h new file mode 100644 index 00000000000..405374373ec --- /dev/null +++ b/src/emacsgtkfixed.h | |||
| @@ -0,0 +1,58 @@ | |||
| 1 | /* A Gtk Widget that inherits GtkFixed, but can be shrinked. | ||
| 2 | |||
| 3 | Copyright (C) 2011 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | This file is part of GNU Emacs. | ||
| 6 | |||
| 7 | GNU Emacs is free software: you can redistribute it and/or modify | ||
| 8 | it under the terms of the GNU General Public License as published by | ||
| 9 | the Free Software Foundation, either version 3 of the License, or | ||
| 10 | (at your option) any later version. | ||
| 11 | |||
| 12 | GNU Emacs is distributed in the hope that it will be useful, | ||
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | GNU General Public License for more details. | ||
| 16 | |||
| 17 | You should have received a copy of the GNU General Public License | ||
| 18 | along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | ||
| 19 | |||
| 20 | #ifndef EMACSGTKFIXED_H | ||
| 21 | #define EMACSGTKFIXED_H | ||
| 22 | |||
| 23 | #include <gtk/gtk.h> | ||
| 24 | |||
| 25 | G_BEGIN_DECLS | ||
| 26 | |||
| 27 | #define EMACS_TYPE_FIXED (emacs_fixed_get_type ()) | ||
| 28 | #define EMACS_FIXED(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EMACS_TYPE_FIXED, EmacsFixed)) | ||
| 29 | #define EMACS_FIXED_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EMACS_TYPE_FIXED, EmacsFixedClass)) | ||
| 30 | #define EMACS_IS_FIXED(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EMACS_TYPE_FIXED)) | ||
| 31 | #define EMACS_IS_FIXED_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EMACS_TYPE_FIXED)) | ||
| 32 | #define EMACS_FIXED_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EMACS_TYPE_FIXED, EmacsFixedClass)) | ||
| 33 | |||
| 34 | typedef struct _EmacsFixed EmacsFixed; | ||
| 35 | typedef struct _EmacsFixedPrivate EmacsFixedPrivate; | ||
| 36 | typedef struct _EmacsFixedClass EmacsFixedClass; | ||
| 37 | |||
| 38 | struct _EmacsFixed | ||
| 39 | { | ||
| 40 | GtkFixed container; | ||
| 41 | |||
| 42 | /*< private >*/ | ||
| 43 | EmacsFixedPrivate *priv; | ||
| 44 | }; | ||
| 45 | |||
| 46 | |||
| 47 | struct _EmacsFixedClass | ||
| 48 | { | ||
| 49 | GtkFixedClass parent_class; | ||
| 50 | }; | ||
| 51 | |||
| 52 | extern GtkWidget *emacs_fixed_new (void); | ||
| 53 | extern void emacs_fixed_set_min_size (EmacsFixed *widget, int width, int height); | ||
| 54 | extern GType emacs_fixed_get_type (void); | ||
| 55 | |||
| 56 | G_END_DECLS | ||
| 57 | |||
| 58 | #endif /* EMACSGTKFIXED_H */ | ||
diff --git a/src/gtkutil.c b/src/gtkutil.c index dedb39a7a40..45f112ae9e5 100644 --- a/src/gtkutil.c +++ b/src/gtkutil.c | |||
| @@ -42,6 +42,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 42 | 42 | ||
| 43 | #ifdef HAVE_GTK3 | 43 | #ifdef HAVE_GTK3 |
| 44 | #include <gtk/gtkx.h> | 44 | #include <gtk/gtkx.h> |
| 45 | #include "emacsgtkfixed.h" | ||
| 45 | #endif | 46 | #endif |
| 46 | 47 | ||
| 47 | #define FRAME_TOTAL_PIXEL_HEIGHT(f) \ | 48 | #define FRAME_TOTAL_PIXEL_HEIGHT(f) \ |
| @@ -88,12 +89,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 88 | 89 | ||
| 89 | #define XG_BIN_CHILD(x) gtk_bin_get_child (GTK_BIN (x)) | 90 | #define XG_BIN_CHILD(x) gtk_bin_get_child (GTK_BIN (x)) |
| 90 | 91 | ||
| 91 | /* Get the current value of the range, truncated to an integer. */ | 92 | static void update_theme_scrollbar_width (void); |
| 92 | static int | ||
| 93 | int_gtk_range_get_value (GtkRange *range) | ||
| 94 | { | ||
| 95 | return gtk_range_get_value (range); | ||
| 96 | } | ||
| 97 | 93 | ||
| 98 | 94 | ||
| 99 | /*********************************************************************** | 95 | /*********************************************************************** |
| @@ -1015,6 +1011,7 @@ style_changed_cb (GObject *go, | |||
| 1015 | struct input_event event; | 1011 | struct input_event event; |
| 1016 | GdkDisplay *gdpy = (GdkDisplay *) user_data; | 1012 | GdkDisplay *gdpy = (GdkDisplay *) user_data; |
| 1017 | const char *display_name = gdk_display_get_name (gdpy); | 1013 | const char *display_name = gdk_display_get_name (gdpy); |
| 1014 | Display *dpy = GDK_DISPLAY_XDISPLAY (gdpy); | ||
| 1018 | 1015 | ||
| 1019 | EVENT_INIT (event); | 1016 | EVENT_INIT (event); |
| 1020 | event.kind = CONFIG_CHANGED_EVENT; | 1017 | event.kind = CONFIG_CHANGED_EVENT; |
| @@ -1022,6 +1019,24 @@ style_changed_cb (GObject *go, | |||
| 1022 | /* Theme doesn't change often, so intern is called seldom. */ | 1019 | /* Theme doesn't change often, so intern is called seldom. */ |
| 1023 | event.arg = intern ("theme-name"); | 1020 | event.arg = intern ("theme-name"); |
| 1024 | kbd_buffer_store_event (&event); | 1021 | kbd_buffer_store_event (&event); |
| 1022 | |||
| 1023 | update_theme_scrollbar_width (); | ||
| 1024 | |||
| 1025 | /* If scroll bar width changed, we need set the new size on all frames | ||
| 1026 | on this display. */ | ||
| 1027 | if (dpy) | ||
| 1028 | { | ||
| 1029 | Lisp_Object rest, frame; | ||
| 1030 | FOR_EACH_FRAME (rest, frame) | ||
| 1031 | { | ||
| 1032 | FRAME_PTR f = XFRAME (frame); | ||
| 1033 | if (FRAME_X_DISPLAY (f) == dpy) | ||
| 1034 | { | ||
| 1035 | x_set_scroll_bar_default_width (f); | ||
| 1036 | xg_frame_set_char_size (f, FRAME_COLS (f), FRAME_LINES (f)); | ||
| 1037 | } | ||
| 1038 | } | ||
| 1039 | } | ||
| 1025 | } | 1040 | } |
| 1026 | 1041 | ||
| 1027 | /* Called when a delete-event occurs on WIDGET. */ | 1042 | /* Called when a delete-event occurs on WIDGET. */ |
| @@ -1069,7 +1084,12 @@ xg_create_frame_widgets (FRAME_PTR f) | |||
| 1069 | 1084 | ||
| 1070 | wvbox = gtk_vbox_new (FALSE, 0); | 1085 | wvbox = gtk_vbox_new (FALSE, 0); |
| 1071 | whbox = gtk_hbox_new (FALSE, 0); | 1086 | whbox = gtk_hbox_new (FALSE, 0); |
| 1072 | wfixed = gtk_fixed_new (); /* Must have this to place scroll bars */ | 1087 | |
| 1088 | #ifdef HAVE_GTK3 | ||
| 1089 | wfixed = emacs_fixed_new (); | ||
| 1090 | #else | ||
| 1091 | wfixed = gtk_fixed_new (); | ||
| 1092 | #endif | ||
| 1073 | 1093 | ||
| 1074 | if (! wtop || ! wvbox || ! whbox || ! wfixed) | 1094 | if (! wtop || ! wvbox || ! whbox || ! wfixed) |
| 1075 | { | 1095 | { |
| @@ -1162,6 +1182,7 @@ xg_create_frame_widgets (FRAME_PTR f) | |||
| 1162 | gtk_widget_modify_style (wfixed, style); | 1182 | gtk_widget_modify_style (wfixed, style); |
| 1163 | #else | 1183 | #else |
| 1164 | gtk_widget_set_can_focus (wfixed, TRUE); | 1184 | gtk_widget_set_can_focus (wfixed, TRUE); |
| 1185 | gtk_window_set_resizable (GTK_WINDOW (wtop), TRUE); | ||
| 1165 | #endif | 1186 | #endif |
| 1166 | 1187 | ||
| 1167 | #ifdef USE_GTK_TOOLTIP | 1188 | #ifdef USE_GTK_TOOLTIP |
| @@ -1265,6 +1286,18 @@ x_wm_set_size_hint (FRAME_PTR f, long int flags, int user_position) | |||
| 1265 | size_hints.min_width = base_width + min_cols * size_hints.width_inc; | 1286 | size_hints.min_width = base_width + min_cols * size_hints.width_inc; |
| 1266 | size_hints.min_height = base_height + min_rows * size_hints.height_inc; | 1287 | size_hints.min_height = base_height + min_rows * size_hints.height_inc; |
| 1267 | 1288 | ||
| 1289 | #ifdef HAVE_GTK3 | ||
| 1290 | /* Gtk3 ignores min width/height and overwrites them with its own idea | ||
| 1291 | of min width/height. Put out min values to the widget so Gtk | ||
| 1292 | gets the same value we want it to be. Without this, a user can't | ||
| 1293 | shrink an Emacs frame. | ||
| 1294 | */ | ||
| 1295 | if (FRAME_GTK_WIDGET (f)) | ||
| 1296 | emacs_fixed_set_min_size (EMACS_FIXED (FRAME_GTK_WIDGET (f)), | ||
| 1297 | size_hints.min_width, | ||
| 1298 | size_hints.min_height); | ||
| 1299 | #endif | ||
| 1300 | |||
| 1268 | /* These currently have a one to one mapping with the X values, but I | 1301 | /* These currently have a one to one mapping with the X values, but I |
| 1269 | don't think we should rely on that. */ | 1302 | don't think we should rely on that. */ |
| 1270 | hint_flags |= GDK_HINT_WIN_GRAVITY; | 1303 | hint_flags |= GDK_HINT_WIN_GRAVITY; |
| @@ -3250,6 +3283,10 @@ xg_event_is_for_menubar (FRAME_PTR f, XEvent *event) | |||
| 3250 | 3283 | ||
| 3251 | int xg_ignore_gtk_scrollbar; | 3284 | int xg_ignore_gtk_scrollbar; |
| 3252 | 3285 | ||
| 3286 | /* The width of the scroll bar for the current theme. */ | ||
| 3287 | |||
| 3288 | static int scroll_bar_width_for_theme; | ||
| 3289 | |||
| 3253 | /* Xlib's `Window' fits in 32 bits. But we want to store pointers, and they | 3290 | /* Xlib's `Window' fits in 32 bits. But we want to store pointers, and they |
| 3254 | may be larger than 32 bits. Keep a mapping from integer index to widget | 3291 | may be larger than 32 bits. Keep a mapping from integer index to widget |
| 3255 | pointers to get around the 32 bit limitation. */ | 3292 | pointers to get around the 32 bit limitation. */ |
| @@ -3326,8 +3363,8 @@ xg_get_widget_from_map (int idx) | |||
| 3326 | return 0; | 3363 | return 0; |
| 3327 | } | 3364 | } |
| 3328 | 3365 | ||
| 3329 | int | 3366 | static void |
| 3330 | xg_get_default_scrollbar_width (FRAME_PTR f) | 3367 | update_theme_scrollbar_width (void) |
| 3331 | { | 3368 | { |
| 3332 | #ifdef HAVE_GTK3 | 3369 | #ifdef HAVE_GTK3 |
| 3333 | GtkAdjustment *vadj; | 3370 | GtkAdjustment *vadj; |
| @@ -3336,13 +3373,22 @@ xg_get_default_scrollbar_width (FRAME_PTR f) | |||
| 3336 | #endif | 3373 | #endif |
| 3337 | GtkWidget *wscroll; | 3374 | GtkWidget *wscroll; |
| 3338 | int w = 0, b = 0; | 3375 | int w = 0, b = 0; |
| 3376 | |||
| 3339 | vadj = gtk_adjustment_new (XG_SB_MIN, XG_SB_MIN, XG_SB_MAX, 0.1, 0.1, 0.1); | 3377 | vadj = gtk_adjustment_new (XG_SB_MIN, XG_SB_MIN, XG_SB_MAX, 0.1, 0.1, 0.1); |
| 3340 | wscroll = gtk_vscrollbar_new (GTK_ADJUSTMENT (vadj)); | 3378 | wscroll = gtk_vscrollbar_new (GTK_ADJUSTMENT (vadj)); |
| 3379 | g_object_ref_sink (G_OBJECT (wscroll)); | ||
| 3341 | gtk_widget_style_get (wscroll, "slider-width", &w, "trough-border", &b, NULL); | 3380 | gtk_widget_style_get (wscroll, "slider-width", &w, "trough-border", &b, NULL); |
| 3342 | gtk_widget_destroy (wscroll); | 3381 | gtk_widget_destroy (wscroll); |
| 3382 | g_object_unref (G_OBJECT (wscroll)); | ||
| 3343 | w += 2*b; | 3383 | w += 2*b; |
| 3344 | if (w < 16) w = 16; | 3384 | if (w < 16) w = 16; |
| 3345 | return w; | 3385 | scroll_bar_width_for_theme = w; |
| 3386 | } | ||
| 3387 | |||
| 3388 | int | ||
| 3389 | xg_get_default_scrollbar_width (void) | ||
| 3390 | { | ||
| 3391 | return scroll_bar_width_for_theme; | ||
| 3346 | } | 3392 | } |
| 3347 | 3393 | ||
| 3348 | /* Return the scrollbar id for X Window WID on display DPY. | 3394 | /* Return the scrollbar id for X Window WID on display DPY. |
| @@ -3528,6 +3574,15 @@ xg_update_scrollbar_pos (FRAME_PTR f, | |||
| 3528 | } | 3574 | } |
| 3529 | } | 3575 | } |
| 3530 | 3576 | ||
| 3577 | /* Get the current value of the range, truncated to an integer. */ | ||
| 3578 | |||
| 3579 | static int | ||
| 3580 | int_gtk_range_get_value (GtkRange *range) | ||
| 3581 | { | ||
| 3582 | return gtk_range_get_value (range); | ||
| 3583 | } | ||
| 3584 | |||
| 3585 | |||
| 3531 | /* Set the thumb size and position of scroll bar BAR. We are currently | 3586 | /* Set the thumb size and position of scroll bar BAR. We are currently |
| 3532 | displaying PORTION out of a whole WHOLE, and our position POSITION. */ | 3587 | displaying PORTION out of a whole WHOLE, and our position POSITION. */ |
| 3533 | 3588 | ||
| @@ -4680,6 +4735,7 @@ xg_initialize (void) | |||
| 4680 | (GTK_TYPE_MENU_SHELL)); | 4735 | (GTK_TYPE_MENU_SHELL)); |
| 4681 | gtk_binding_entry_add_signal (binding_set, GDK_KEY_g, GDK_CONTROL_MASK, | 4736 | gtk_binding_entry_add_signal (binding_set, GDK_KEY_g, GDK_CONTROL_MASK, |
| 4682 | "cancel", 0); | 4737 | "cancel", 0); |
| 4738 | update_theme_scrollbar_width (); | ||
| 4683 | } | 4739 | } |
| 4684 | 4740 | ||
| 4685 | #endif /* USE_GTK */ | 4741 | #endif /* USE_GTK */ |
diff --git a/src/gtkutil.h b/src/gtkutil.h index cf58d03b0ce..769e56da917 100644 --- a/src/gtkutil.h +++ b/src/gtkutil.h | |||
| @@ -135,7 +135,7 @@ extern void xg_set_toolkit_scroll_bar_thumb (struct scroll_bar *bar, | |||
| 135 | int position, | 135 | int position, |
| 136 | int whole); | 136 | int whole); |
| 137 | extern int xg_event_is_for_scrollbar (FRAME_PTR f, XEvent *event); | 137 | extern int xg_event_is_for_scrollbar (FRAME_PTR f, XEvent *event); |
| 138 | extern int xg_get_default_scrollbar_width (FRAME_PTR f); | 138 | extern int xg_get_default_scrollbar_width (void); |
| 139 | 139 | ||
| 140 | extern void update_frame_tool_bar (FRAME_PTR f); | 140 | extern void update_frame_tool_bar (FRAME_PTR f); |
| 141 | extern void free_frame_tool_bar (FRAME_PTR f); | 141 | extern void free_frame_tool_bar (FRAME_PTR f); |
diff --git a/src/xfns.c b/src/xfns.c index f847e41855e..abc273c2bdf 100644 --- a/src/xfns.c +++ b/src/xfns.c | |||
| @@ -1700,7 +1700,7 @@ x_set_scroll_bar_default_width (struct frame *f) | |||
| 1700 | int wid = FRAME_COLUMN_WIDTH (f); | 1700 | int wid = FRAME_COLUMN_WIDTH (f); |
| 1701 | #ifdef USE_TOOLKIT_SCROLL_BARS | 1701 | #ifdef USE_TOOLKIT_SCROLL_BARS |
| 1702 | #ifdef USE_GTK | 1702 | #ifdef USE_GTK |
| 1703 | int minw = xg_get_default_scrollbar_width (f); | 1703 | int minw = xg_get_default_scrollbar_width (); |
| 1704 | #else | 1704 | #else |
| 1705 | int minw = 16; | 1705 | int minw = 16; |
| 1706 | #endif | 1706 | #endif |