diff --git a/ChangeLog b/ChangeLog index 3e404183669..cd73001d541 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2011-06-14 Jan Djärv + + * configure.in: Add emacsgtkfixed.o to GTK_OBJ if HAVE_GTK3. + 2011-06-08 Paul Eggert * lib/gnulib.mk, m4/gnulib-common.m4: Merge from gnulib. diff --git a/admin/CPP-DEFINES b/admin/CPP-DEFINES index 7f6a18f7d54..6e0f736a06f 100644 --- a/admin/CPP-DEFINES +++ b/admin/CPP-DEFINES @@ -53,8 +53,6 @@ CLASH_DETECTION COFF FIRST_PTY_LETTER HAVE_PTYS -HAVE_TERMIO -HAVE_TERMIOS INTERRUPT_INPUT NARROWPROTO SEPCHAR @@ -175,7 +173,6 @@ HAVE_SYS_SYSTEMINFO_H HAVE_SYS_TIMEB_H HAVE_SYS_TIME_H HAVE_TCATTR -HAVE_TERMIOS_H HAVE_TIMEVAL HAVE_TM_ZONE HAVE_TZSET @@ -258,14 +255,9 @@ USG5_4 USG_SUBTTY_WORKS VALBITS WRETCODE -XINT XOS_NEEDS_TIME_H -XPNTR -XSET -XUINT _AIX _ARCH_PPC64 -_CALLBACK_ _FILE_OFFSET_BITS _LP64 _MALLOC_INTERNAL @@ -273,21 +265,6 @@ _NAIVE_DOS_REGS _VARARGS_ _WINSOCKAPI_ _WINSOCK_H -__ELF__ -__FreeBSD__ -__GNUC__ -__GNU_LIBRARY__ -__GNUC_MINOR__ -__NetBSD__ -__OpenBSD__ -__STDC__ -__arch64__ -__cplusplus -__hpux -__ia64__ -__linux__ -__mc68000__ -__mips__ _longjmp _setjmp _start @@ -323,9 +300,7 @@ getenv getpid getuid gmtime -i386 index -init_process isatty kill link @@ -333,7 +308,6 @@ linux localtime logb lseek -m68k malloc mkdir mktemp diff --git a/autogen/configure b/autogen/configure index c76bb4acf18..e4a96f2b2d7 100755 --- a/autogen/configure +++ b/autogen/configure @@ -10483,6 +10483,7 @@ fi HAVE_GTK=no +GTK_OBJ= if test "${with_gtk3}" = "yes"; then GLIB_REQUIRED=2.28 GTK_REQUIRED=3.0 @@ -10588,6 +10589,7 @@ $as_echo "no" >&6; } $as_echo "#define HAVE_GTK3 1" >>confdefs.h + GTK_OBJ=emacsgtkfixed.o fi if test "$pkg_check_gtk" != "yes"; then @@ -10697,7 +10699,6 @@ $as_echo "no" >&6; } fi fi -GTK_OBJ= if test x"$pkg_check_gtk" = xyes; then @@ -10726,7 +10727,7 @@ done $as_echo "#define USE_GTK 1" >>confdefs.h - GTK_OBJ=gtkutil.o + GTK_OBJ="gtkutil.o $GTK_OBJ" USE_X_TOOLKIT=none if $PKG_CONFIG --atleast-version=2.10 gtk+-2.0; then : diff --git a/configure.in b/configure.in index 3d507789f22..9e7ea8522b2 100644 --- a/configure.in +++ b/configure.in @@ -1819,6 +1819,7 @@ fi HAVE_GTK=no +GTK_OBJ= if test "${with_gtk3}" = "yes"; then GLIB_REQUIRED=2.28 GTK_REQUIRED=3.0 @@ -1830,6 +1831,7 @@ if test "${with_gtk3}" = "yes"; then AC_MSG_ERROR($GTK_PKG_ERRORS) fi AC_DEFINE(HAVE_GTK3, 1, [Define to 1 if using GTK 3 or later.]) + GTK_OBJ=emacsgtkfixed.o fi if test "$pkg_check_gtk" != "yes"; then @@ -1847,7 +1849,6 @@ if test "${with_gtk}" = "yes" || test "$USE_X_TOOLKIT" = "maybe"; then fi fi -GTK_OBJ= if test x"$pkg_check_gtk" = xyes; then AC_SUBST(GTK_CFLAGS) @@ -1865,7 +1866,7 @@ if test x"$pkg_check_gtk" = xyes; then else HAVE_GTK=yes AC_DEFINE(USE_GTK, 1, [Define to 1 if using GTK.]) - GTK_OBJ=gtkutil.o + GTK_OBJ="gtkutil.o $GTK_OBJ" USE_X_TOOLKIT=none if $PKG_CONFIG --atleast-version=2.10 gtk+-2.0; then : diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog index 54ad6abdb07..f647bb00f91 100644 --- a/doc/lispref/ChangeLog +++ b/doc/lispref/ChangeLog @@ -1,3 +1,8 @@ +2011-06-15 Lars Magne Ingebrigtsen + + * processes.texi (Process Information): Renamed `process-alive-p' + to `process-live-p' for consistency with other `-live-p' functions. + 2011-06-03 Paul Eggert Document wide integers better. diff --git a/doc/lispref/processes.texi b/doc/lispref/processes.texi index 2284699c82b..5d5b11497f7 100644 --- a/doc/lispref/processes.texi +++ b/doc/lispref/processes.texi @@ -859,7 +859,7 @@ For a network connection, @code{process-status} returns one of the symbols closed the connection, or Emacs did @code{delete-process}. @end defun -@defun process-alive-p process +@defun process-live-p process This function returns nin-@code{nil} if @var{process} is alive. A process is considered alive if its status is @code{run}, @code{open}, @code{listen}, @code{connect} or @code{stop}. diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 2cf968505af..622831cb31f 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,36 @@ +2011-06-15 Lars Magne Ingebrigtsen + + * subr.el (process-live-p): Renamed from `process-alive-p' for + consistency with other `-live-p' functions. + +2011-06-15 Stefan Monnier + + * window.el (same-window-buffer-names, same-window-regexps) + (special-display-frame-alist, special-display-popup-frame) + (special-display-function, special-display-buffer-names) + (special-display-regexps, pop-up-frame-alist) + (pop-up-frame-function, pop-up-frames, display-buffer-reuse-frames) + (pop-up-windows, split-window-preferred-function) + (split-height-threshold, split-width-threshold, even-window-heights) + (display-buffer-mark-dedicated): Don't encourage the use of + display-buffer-alist from Elisp code. + +2011-06-15 Dan Nicolaescu + + * progmodes/python.el (python-mode): Derive from prog-mode. + * progmodes/ps-mode.el (ps-mode): + * progmodes/mixal-mode.el (mixal-mode): + * progmodes/cfengine.el (cfengine-mode): + * progmodes/ld-script.el (ld-script-mode): Likewise. + +2011-06-15 Martin Rudalics + + * window.el (display-buffer-alist): Trim default value to avoid + popping up a new frame (Bug#8857) or reusing an arbitrary window + on another frame. + (display-buffer): Do not fall back on popping up a new frame in + batch mode (Bug#8857). + 2011-06-14 Chong Yidong * cus-theme.el (describe-theme-1): Use custom-theme-p. diff --git a/lisp/progmodes/cfengine.el b/lisp/progmodes/cfengine.el index a475bbd5932..22ece17cb28 100644 --- a/lisp/progmodes/cfengine.el +++ b/lisp/progmodes/cfengine.el @@ -198,7 +198,7 @@ Intended as the value of `indent-line-function'." t)) ;;;###autoload -(define-derived-mode cfengine-mode fundamental-mode "Cfengine" +(define-derived-mode cfengine-mode prog-mode "Cfengine" "Major mode for editing cfengine input. There are no special keybindings by default. diff --git a/lisp/progmodes/ld-script.el b/lisp/progmodes/ld-script.el index 8bdac61d4ab..c682bfa0280 100644 --- a/lisp/progmodes/ld-script.el +++ b/lisp/progmodes/ld-script.el @@ -168,7 +168,7 @@ "Default font-lock-keywords for `ld-script-mode'.") ;;;###autoload -(define-derived-mode ld-script-mode nil "LD-Script" +(define-derived-mode ld-script-mode prog-mode "LD-Script" "A major mode to edit GNU ld script files" (set (make-local-variable 'comment-start) "/* ") (set (make-local-variable 'comment-end) " */") diff --git a/lisp/progmodes/mixal-mode.el b/lisp/progmodes/mixal-mode.el index 0d8cdd9f9b1..103c7be7d3c 100644 --- a/lisp/progmodes/mixal-mode.el +++ b/lisp/progmodes/mixal-mode.el @@ -1103,7 +1103,7 @@ Assumes that file has been compiled with debugging support." (error "mixvm.el needs to be loaded to run `mixvm'"))) ;;;###autoload -(define-derived-mode mixal-mode fundamental-mode "mixal" +(define-derived-mode mixal-mode prog-mode "mixal" "Major mode for the mixal asm language." (set (make-local-variable 'comment-start) "*") (set (make-local-variable 'comment-start-skip) "^\\*[ \t]*") diff --git a/lisp/progmodes/ps-mode.el b/lisp/progmodes/ps-mode.el index cade56a194c..d60e7513651 100644 --- a/lisp/progmodes/ps-mode.el +++ b/lisp/progmodes/ps-mode.el @@ -485,7 +485,7 @@ If nil, use `temporary-file-directory'." ;; PostScript mode. ;;;###autoload -(define-derived-mode ps-mode fundamental-mode "PostScript" +(define-derived-mode ps-mode prog-mode "PostScript" "Major mode for editing PostScript with GNU Emacs. Entry to this mode calls `ps-mode-hook'. diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index b99cad1d081..3d243f14f07 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -2420,7 +2420,7 @@ without confirmation." (defvar python-mode-running) ;Dynamically scoped var. ;;;###autoload -(define-derived-mode python-mode fundamental-mode "Python" +(define-derived-mode python-mode prog-mode "Python" "Major mode for editing Python files. Turns on Font Lock mode unconditionally since it is currently required for correct parsing of the source. diff --git a/lisp/subr.el b/lisp/subr.el index d0ef38c1140..b328b7e17b7 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -1805,7 +1805,7 @@ Signal an error if the program returns with a non-zero exit status." (forward-line 1)) (nreverse lines))))) -(defun process-alive-p (process) +(defun process-live-p (process) "Returns non-nil if PROCESS is alive. A process is considered alive if its status is `run', `open', `listen', `connect' or `stop'." diff --git a/lisp/window.el b/lisp/window.el index cad4e15507d..5493893d4c1 100644 --- a/lisp/window.el +++ b/lisp/window.el @@ -3505,9 +3505,7 @@ buffer display specifiers.") reuse-window (reuse-window nil same visible) pop-up-window (pop-up-window (largest . nil) (lru . nil)) - pop-up-frame - (pop-up-frame) - reuse-window (reuse-window nil other visible) + reuse-window (reuse-window other other nil) (reuse-window-even-sizes . t))) "List associating buffer identifiers with display specifiers. The car of each element of this list is built from a set of cons @@ -5303,12 +5301,12 @@ this list as arguments." ;; Try reusing a window not showing BUFFER on any visible or ;; iconified frame. (display-buffer-reuse-window buffer '(nil other 0)) - ;; Try making a new frame. - (display-buffer-pop-up-frame buffer) - ;; Try using weakly dedicated windows. + ;; Try making a new frame (but not in batch mode). + (and (not noninteractive) (display-buffer-pop-up-frame buffer)) + ;; Try using a weakly dedicated window. (display-buffer-reuse-window buffer '(nil nil t) '((reuse-window-dedicated . weak))) - ;; Try using strongly dedicated windows. + ;; Try using a strongly dedicated window. (display-buffer-reuse-window buffer '(nil nil t) '((reuse-window-dedicated . t))))))) @@ -5583,7 +5581,7 @@ See also `same-window-regexps'." :group 'windows) (make-obsolete-variable 'same-window-buffer-names - "use `display-buffer-alist' or 2nd arg of `display-buffer' instead." "24.1") + "use 2nd arg of `display-buffer' instead." "24.1") (defcustom same-window-regexps nil "List of regexps saying which buffers should appear in the \"same\" window. @@ -5601,7 +5599,7 @@ See also `same-window-buffer-names'." :group 'windows) (make-obsolete-variable 'same-window-regexps - "use `display-buffer-alist' or 2nd arg of `display-buffer' instead." "24.1") + "use 2nd arg of `display-buffer' instead." "24.1") (defun same-window-p (buffer-name) "Return non-nil if a buffer named BUFFER-NAME would be shown in the \"same\" window. @@ -5647,7 +5645,7 @@ These supersede the values given in `default-frame-alist'." :group 'frames) (make-obsolete-variable 'special-display-frame-alist - "use `display-buffer-alist' or 2nd arg of `display-buffer' instead." "24.1") + "use 2nd arg of `display-buffer' instead." "24.1") (defun special-display-popup-frame (buffer &optional args) "Display BUFFER in a special frame and return the window chosen. @@ -5695,7 +5693,7 @@ and (cdr ARGS) as second." (frame-selected-window frame)))))) (make-obsolete 'special-display-popup-frame - "use `display-buffer-alist' or 2nd arg of `display-buffer' instead." "24.1") + "use 2nd arg of `display-buffer' instead." "24.1") (defcustom special-display-function 'special-display-popup-frame "Function to call for displaying special buffers. @@ -5714,7 +5712,7 @@ A buffer is special when its name is either listed in :group 'frames) (make-obsolete-variable 'special-display-function - "use `display-buffer-alist' or 2nd arg of `display-buffer' instead." "24.1") + "use 2nd arg of `display-buffer' instead." "24.1") (defcustom special-display-buffer-names nil "List of names of buffers that should be displayed specially. @@ -5781,7 +5779,7 @@ See also `special-display-regexps'." :group 'frames) (make-obsolete-variable 'special-display-buffer-names - "use `display-buffer-alist' or 2nd arg of `display-buffer' instead." "24.1") + "use 2nd arg of `display-buffer' instead." "24.1") ;;;###autoload (put 'special-display-buffer-names 'risky-local-variable t) @@ -5852,7 +5850,7 @@ See also `special-display-buffer-names'." :group 'frames) (make-obsolete-variable 'special-display-regexps - "use `display-buffer-alist' or 2nd arg of `display-buffer' instead." "24.1") + "use 2nd arg of `display-buffer' instead." "24.1") (defun special-display-p (buffer-name) "Return non-nil if a buffer named BUFFER-NAME gets a special frame. @@ -5904,7 +5902,7 @@ affected by this variable." :group 'frames) (make-obsolete-variable 'pop-up-frame-alist - "use `display-buffer-alist' or 2nd arg of `display-buffer' instead." "24.1") + "use 2nd arg of `display-buffer' instead." "24.1") (defcustom pop-up-frame-function (lambda () (make-frame pop-up-frame-alist)) @@ -5916,7 +5914,7 @@ frame. The default value calls `make-frame' with the argument :group 'frames) (make-obsolete-variable 'pop-up-frame-function - "use `display-buffer-alist' or 2nd arg of `display-buffer' instead." "24.1") + "use 2nd arg of `display-buffer' instead." "24.1") (defcustom pop-up-frames 'unset ; nil "Whether `display-buffer' should make a separate frame. @@ -5936,7 +5934,7 @@ Any other non-nil value means always make a separate frame." :group 'frames) (make-obsolete-variable 'pop-up-frames - "use `display-buffer-alist' or 2nd arg of `display-buffer' instead." "24.1") + "use 2nd arg of `display-buffer' instead." "24.1") (defcustom display-buffer-reuse-frames 'unset ; nil "Set and non-nil means `display-buffer' should reuse frames. @@ -5948,7 +5946,7 @@ that frame." :group 'frames) (make-obsolete-variable 'display-buffer-reuse-frames - "use `display-buffer-alist' or 2nd arg of `display-buffer' instead." "24.1") + "use 2nd arg of `display-buffer' instead." "24.1") (defcustom pop-up-windows 'unset ; t "Set and non-nil means `display-buffer' should make a new window." @@ -5957,7 +5955,7 @@ that frame." :group 'windows) (make-obsolete-variable 'pop-up-windows - "use `display-buffer-alist' or 2nd arg of `display-buffer' instead." "24.1") + "use 2nd arg of `display-buffer' instead." "24.1") (defcustom split-window-preferred-function 'split-window-sensibly "Function called by `display-buffer' to split a window. @@ -5986,7 +5984,7 @@ not want to split the selected window." :group 'windows) (make-obsolete-variable 'split-window-preferred-function - "use `display-buffer-alist' or 2nd arg of `display-buffer' instead." "24.1") + "use 2nd arg of `display-buffer' instead." "24.1") (defcustom split-height-threshold 80 "Minimum height for splitting a window to display a buffer. @@ -6000,7 +5998,7 @@ split it vertically disregarding the value of this variable." :group 'windows) (make-obsolete-variable 'split-height-threshold - "use `display-buffer-alist' or 2nd arg of `display-buffer' instead." "24.1") + "use 2nd arg of `display-buffer' instead." "24.1") (defcustom split-width-threshold 160 "Minimum width for splitting a window to display a buffer. @@ -6012,7 +6010,7 @@ is nil, `display-buffer' cannot split windows horizontally." :group 'windows) (make-obsolete-variable 'split-width-threshold - "use `display-buffer-alist' or 2nd arg of `display-buffer' instead." "24.1") + "use 2nd arg of `display-buffer' instead." "24.1") (defcustom even-window-heights t "If non-nil `display-buffer' will try to even window heights. @@ -6024,7 +6022,7 @@ window that appears above or below the selected window." :group 'windows) (make-obsolete-variable 'even-window-heights - "use `display-buffer-alist' or 2nd arg of `display-buffer' instead." "24.1") + "use 2nd arg of `display-buffer' instead." "24.1") (defvar display-buffer-mark-dedicated 'unset ; nil "Set and non-nil means `display-buffer' marks the windows it creates as dedicated. @@ -6032,7 +6030,7 @@ The actual non-nil value of this variable will be copied to the `window-dedicated-p' flag.") (make-obsolete-variable 'display-buffer-mark-dedicated - "use `display-buffer-alist' or 2nd arg of `display-buffer' instead." "24.1") + "use 2nd arg of `display-buffer' instead." "24.1") (defun window-splittable-p (window &optional horizontal) "Return non-nil if `split-window-sensibly' may split WINDOW. diff --git a/src/ChangeLog b/src/ChangeLog index e477162b32b..87f64244c48 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,12 +1,12 @@ 2011-06-15 Paul Eggert + Integer overflow and signedness fixes. + * fileio.c: Don't assume EMACS_INT fits in off_t. (emacs_lseek): New static function. (Finsert_file_contents, Fwrite_region): Use it. Use SEEK_SET, SEEK_CUR, SEEK_END as appropriate. -2011-06-14 Paul Eggert - * fns.c (Fload_average): Don't assume 100 * load average fits in int. * fns.c: Don't overflow int when computing a list length. @@ -66,8 +66,6 @@ * vm-limit.c (check_memory_limits): Fix incorrect extern function decls. * mem-limits.h (SIZE): Remove; no longer used. -2011-06-13 Paul Eggert - * xterm.c (x_alloc_nearest_color_1): Prefer int to long when int works. Remove unnecessary casts. @@ -247,6 +245,30 @@ * alloc.c (Fmake_string): Check for out-of-range init. +2011-06-14 Jan Djärv + + * xfns.c (x_set_scroll_bar_default_width): Remove argument to + xg_get_default_scrollbar_width. + + * gtkutil.c: Include emacsgtkfixed.h if HAVE_GTK3. + (int_gtk_range_get_value): Move to the scroll bar part of the file. + (style_changed_cb): Call update_theme_scrollbar_width and call + x_set_scroll_bar_default_width and xg_frame_set_char_size for + all frames (Bug#8505). + (xg_create_frame_widgets): Call emacs_fixed_new if HAVE_GTK3 (Bug#8505). + Call gtk_window_set_resizable if HAVE_GTK3. + (x_wm_set_size_hint): Call emacs_fixed_set_min_size with min width + and height if HAVE_GTK3 (Bug#8505). + (scroll_bar_width_for_theme): New variable. + (update_theme_scrollbar_width): New function. + (xg_get_default_scrollbar_width): Move code to + update_theme_scrollbar_width, just return scroll_bar_width_for_theme. + (xg_initialize): Call update_theme_scrollbar_width. + + * gtkutil.h (xg_get_default_scrollbar_width): Remove argument. + + * emacsgtkfixed.c, emacsgtkfixed.h: New files. + 2011-06-12 Martin Rudalics * 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 @@ +/* A Gtk Widget that inherits GtkFixed, but can be shrinked. + +Copyright (C) 2011 Free Software Foundation, Inc. + +This file is part of GNU Emacs. + +GNU Emacs is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +GNU Emacs is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Emacs. If not, see . */ + +#include "emacsgtkfixed.h" + + +struct _EmacsFixedPrivate +{ + int minwidth, minheight; +}; + + +static void emacs_fixed_get_preferred_width (GtkWidget *widget, + gint *minimum, + gint *natural); +static void emacs_fixed_get_preferred_height (GtkWidget *widget, + gint *minimum, + gint *natural); +G_DEFINE_TYPE (EmacsFixed, emacs_fixed, GTK_TYPE_FIXED) + +static void +emacs_fixed_class_init (EmacsFixedClass *klass) +{ + GtkWidgetClass *widget_class; + GtkFixedClass *fixed_class; + + widget_class = (GtkWidgetClass*) klass; + fixed_class = (GtkFixedClass*) klass; + + widget_class->get_preferred_width = emacs_fixed_get_preferred_width; + widget_class->get_preferred_height = emacs_fixed_get_preferred_height; + g_type_class_add_private (klass, sizeof (EmacsFixedPrivate)); +} + +static GType +emacs_fixed_child_type (GtkFixed *container) +{ + return GTK_TYPE_WIDGET; +} + +static void +emacs_fixed_init (EmacsFixed *fixed) +{ + fixed->priv = G_TYPE_INSTANCE_GET_PRIVATE (fixed, EMACS_TYPE_FIXED, + EmacsFixedPrivate); + fixed->priv->minwidth = fixed->priv->minheight = 0; +} + +/** + * emacs_fixed_new: + * + * Creates a new #EmacsFixed. + * + * Returns: a new #EmacsFixed. + */ +GtkWidget* +emacs_fixed_new (void) +{ + return g_object_new (EMACS_TYPE_FIXED, NULL); +} + +static GtkWidgetClass * +get_parent_class (EmacsFixed *fixed) +{ + EmacsFixedClass *klass = EMACS_FIXED_GET_CLASS (fixed); + GtkFixedClass *parent_class = g_type_class_peek_parent (klass); + return (GtkWidgetClass*) parent_class; +} + +static void +emacs_fixed_get_preferred_width (GtkWidget *widget, + gint *minimum, + gint *natural) +{ + EmacsFixed *fixed = EMACS_FIXED (widget); + EmacsFixedPrivate *priv = fixed->priv; + GtkWidgetClass *widget_class = get_parent_class (fixed); + widget_class->get_preferred_width (widget, minimum, natural); + if (minimum) *minimum = priv->minwidth; +} + +static void +emacs_fixed_get_preferred_height (GtkWidget *widget, + gint *minimum, + gint *natural) +{ + EmacsFixed *fixed = EMACS_FIXED (widget); + EmacsFixedPrivate *priv = fixed->priv; + GtkWidgetClass *widget_class = get_parent_class (fixed); + widget_class->get_preferred_height (widget, minimum, natural); + if (minimum) *minimum = priv->minheight; +} + +void +emacs_fixed_set_min_size (EmacsFixed *widget, int width, int height) +{ + EmacsFixedPrivate *priv = widget->priv; + GtkWidgetClass *widget_class = get_parent_class (widget); + int mw, nw, mh, nh; + + widget_class->get_preferred_height (GTK_WIDGET (widget), &mh, &nh); + widget_class->get_preferred_width (GTK_WIDGET (widget), &mw, &nw); + + /* Gtk complains if min size is less than natural size. */ + if (width <= nw) priv->minwidth = width; + if (height <= nh) priv->minheight = height; +} 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 @@ +/* A Gtk Widget that inherits GtkFixed, but can be shrinked. + +Copyright (C) 2011 Free Software Foundation, Inc. + +This file is part of GNU Emacs. + +GNU Emacs is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +GNU Emacs is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Emacs. If not, see . */ + +#ifndef EMACSGTKFIXED_H +#define EMACSGTKFIXED_H + +#include + +G_BEGIN_DECLS + +#define EMACS_TYPE_FIXED (emacs_fixed_get_type ()) +#define EMACS_FIXED(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EMACS_TYPE_FIXED, EmacsFixed)) +#define EMACS_FIXED_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EMACS_TYPE_FIXED, EmacsFixedClass)) +#define EMACS_IS_FIXED(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EMACS_TYPE_FIXED)) +#define EMACS_IS_FIXED_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EMACS_TYPE_FIXED)) +#define EMACS_FIXED_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EMACS_TYPE_FIXED, EmacsFixedClass)) + +typedef struct _EmacsFixed EmacsFixed; +typedef struct _EmacsFixedPrivate EmacsFixedPrivate; +typedef struct _EmacsFixedClass EmacsFixedClass; + +struct _EmacsFixed +{ + GtkFixed container; + + /*< private >*/ + EmacsFixedPrivate *priv; +}; + + +struct _EmacsFixedClass +{ + GtkFixedClass parent_class; +}; + +extern GtkWidget *emacs_fixed_new (void); +extern void emacs_fixed_set_min_size (EmacsFixed *widget, int width, int height); +extern GType emacs_fixed_get_type (void); + +G_END_DECLS + +#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 . */ #ifdef HAVE_GTK3 #include +#include "emacsgtkfixed.h" #endif #define FRAME_TOTAL_PIXEL_HEIGHT(f) \ @@ -88,12 +89,7 @@ along with GNU Emacs. If not, see . */ #define XG_BIN_CHILD(x) gtk_bin_get_child (GTK_BIN (x)) -/* Get the current value of the range, truncated to an integer. */ -static int -int_gtk_range_get_value (GtkRange *range) -{ - return gtk_range_get_value (range); -} +static void update_theme_scrollbar_width (void); /*********************************************************************** @@ -1015,6 +1011,7 @@ style_changed_cb (GObject *go, struct input_event event; GdkDisplay *gdpy = (GdkDisplay *) user_data; const char *display_name = gdk_display_get_name (gdpy); + Display *dpy = GDK_DISPLAY_XDISPLAY (gdpy); EVENT_INIT (event); event.kind = CONFIG_CHANGED_EVENT; @@ -1022,6 +1019,24 @@ style_changed_cb (GObject *go, /* Theme doesn't change often, so intern is called seldom. */ event.arg = intern ("theme-name"); kbd_buffer_store_event (&event); + + update_theme_scrollbar_width (); + + /* If scroll bar width changed, we need set the new size on all frames + on this display. */ + if (dpy) + { + Lisp_Object rest, frame; + FOR_EACH_FRAME (rest, frame) + { + FRAME_PTR f = XFRAME (frame); + if (FRAME_X_DISPLAY (f) == dpy) + { + x_set_scroll_bar_default_width (f); + xg_frame_set_char_size (f, FRAME_COLS (f), FRAME_LINES (f)); + } + } + } } /* Called when a delete-event occurs on WIDGET. */ @@ -1069,7 +1084,12 @@ xg_create_frame_widgets (FRAME_PTR f) wvbox = gtk_vbox_new (FALSE, 0); whbox = gtk_hbox_new (FALSE, 0); - wfixed = gtk_fixed_new (); /* Must have this to place scroll bars */ + +#ifdef HAVE_GTK3 + wfixed = emacs_fixed_new (); +#else + wfixed = gtk_fixed_new (); +#endif if (! wtop || ! wvbox || ! whbox || ! wfixed) { @@ -1162,6 +1182,7 @@ xg_create_frame_widgets (FRAME_PTR f) gtk_widget_modify_style (wfixed, style); #else gtk_widget_set_can_focus (wfixed, TRUE); + gtk_window_set_resizable (GTK_WINDOW (wtop), TRUE); #endif #ifdef USE_GTK_TOOLTIP @@ -1265,6 +1286,18 @@ x_wm_set_size_hint (FRAME_PTR f, long int flags, int user_position) size_hints.min_width = base_width + min_cols * size_hints.width_inc; size_hints.min_height = base_height + min_rows * size_hints.height_inc; +#ifdef HAVE_GTK3 + /* Gtk3 ignores min width/height and overwrites them with its own idea + of min width/height. Put out min values to the widget so Gtk + gets the same value we want it to be. Without this, a user can't + shrink an Emacs frame. + */ + if (FRAME_GTK_WIDGET (f)) + emacs_fixed_set_min_size (EMACS_FIXED (FRAME_GTK_WIDGET (f)), + size_hints.min_width, + size_hints.min_height); +#endif + /* These currently have a one to one mapping with the X values, but I don't think we should rely on that. */ hint_flags |= GDK_HINT_WIN_GRAVITY; @@ -3250,6 +3283,10 @@ xg_event_is_for_menubar (FRAME_PTR f, XEvent *event) int xg_ignore_gtk_scrollbar; +/* The width of the scroll bar for the current theme. */ + +static int scroll_bar_width_for_theme; + /* Xlib's `Window' fits in 32 bits. But we want to store pointers, and they may be larger than 32 bits. Keep a mapping from integer index to widget pointers to get around the 32 bit limitation. */ @@ -3326,8 +3363,8 @@ xg_get_widget_from_map (int idx) return 0; } -int -xg_get_default_scrollbar_width (FRAME_PTR f) +static void +update_theme_scrollbar_width (void) { #ifdef HAVE_GTK3 GtkAdjustment *vadj; @@ -3336,13 +3373,22 @@ xg_get_default_scrollbar_width (FRAME_PTR f) #endif GtkWidget *wscroll; int w = 0, b = 0; + vadj = gtk_adjustment_new (XG_SB_MIN, XG_SB_MIN, XG_SB_MAX, 0.1, 0.1, 0.1); wscroll = gtk_vscrollbar_new (GTK_ADJUSTMENT (vadj)); + g_object_ref_sink (G_OBJECT (wscroll)); gtk_widget_style_get (wscroll, "slider-width", &w, "trough-border", &b, NULL); gtk_widget_destroy (wscroll); + g_object_unref (G_OBJECT (wscroll)); w += 2*b; if (w < 16) w = 16; - return w; + scroll_bar_width_for_theme = w; +} + +int +xg_get_default_scrollbar_width (void) +{ + return scroll_bar_width_for_theme; } /* Return the scrollbar id for X Window WID on display DPY. @@ -3528,6 +3574,15 @@ xg_update_scrollbar_pos (FRAME_PTR f, } } +/* Get the current value of the range, truncated to an integer. */ + +static int +int_gtk_range_get_value (GtkRange *range) +{ + return gtk_range_get_value (range); +} + + /* Set the thumb size and position of scroll bar BAR. We are currently displaying PORTION out of a whole WHOLE, and our position POSITION. */ @@ -4680,6 +4735,7 @@ xg_initialize (void) (GTK_TYPE_MENU_SHELL)); gtk_binding_entry_add_signal (binding_set, GDK_KEY_g, GDK_CONTROL_MASK, "cancel", 0); + update_theme_scrollbar_width (); } #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, int position, int whole); extern int xg_event_is_for_scrollbar (FRAME_PTR f, XEvent *event); -extern int xg_get_default_scrollbar_width (FRAME_PTR f); +extern int xg_get_default_scrollbar_width (void); extern void update_frame_tool_bar (FRAME_PTR f); 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) int wid = FRAME_COLUMN_WIDTH (f); #ifdef USE_TOOLKIT_SCROLL_BARS #ifdef USE_GTK - int minw = xg_get_default_scrollbar_width (f); + int minw = xg_get_default_scrollbar_width (); #else int minw = 16; #endif