* emacs/dired.texi (Operating on Files): Fix dired-recursive-copies default.
[emacs.git] / src / emacsgtkfixed.c
blobfba672ff74d651da1dca89ab40f1aef3eddf8be5
1 /* A Gtk Widget that inherits GtkFixed, but can be shrunk.
2 This file is only use when compiling with Gtk+ 3.
4 Copyright (C) 2011-2012 Free Software Foundation, Inc.
6 This file is part of GNU Emacs.
8 GNU Emacs is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
13 GNU Emacs is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
21 #include <config.h>
23 #include "emacsgtkfixed.h"
24 #include <signal.h>
25 #include <stdio.h>
26 #include <setjmp.h>
27 #include "lisp.h"
28 #include "frame.h"
29 #include "xterm.h"
31 struct _EmacsFixedPrivate
33 struct frame *f;
37 static void emacs_fixed_get_preferred_width (GtkWidget *widget,
38 gint *minimum,
39 gint *natural);
40 static void emacs_fixed_get_preferred_height (GtkWidget *widget,
41 gint *minimum,
42 gint *natural);
43 G_DEFINE_TYPE (EmacsFixed, emacs_fixed, GTK_TYPE_FIXED)
45 static void
46 emacs_fixed_class_init (EmacsFixedClass *klass)
48 GtkWidgetClass *widget_class;
49 GtkFixedClass *fixed_class;
51 widget_class = (GtkWidgetClass*) klass;
52 fixed_class = (GtkFixedClass*) klass;
54 widget_class->get_preferred_width = emacs_fixed_get_preferred_width;
55 widget_class->get_preferred_height = emacs_fixed_get_preferred_height;
56 g_type_class_add_private (klass, sizeof (EmacsFixedPrivate));
59 static GType
60 emacs_fixed_child_type (GtkFixed *container)
62 return GTK_TYPE_WIDGET;
65 static void
66 emacs_fixed_init (EmacsFixed *fixed)
68 fixed->priv = G_TYPE_INSTANCE_GET_PRIVATE (fixed, EMACS_TYPE_FIXED,
69 EmacsFixedPrivate);
70 fixed->priv->f = 0;
73 /**
74 * emacs_fixed_new:
76 * Creates a new #EmacsFixed.
78 * Returns: a new #EmacsFixed.
80 GtkWidget*
81 emacs_fixed_new (struct frame *f)
83 EmacsFixed *fixed = g_object_new (EMACS_TYPE_FIXED, NULL);
84 EmacsFixedPrivate *priv = fixed->priv;
85 priv->f = f;
86 return GTK_WIDGET (fixed);
89 static void
90 emacs_fixed_get_preferred_width (GtkWidget *widget,
91 gint *minimum,
92 gint *natural)
94 EmacsFixed *fixed = EMACS_FIXED (widget);
95 EmacsFixedPrivate *priv = fixed->priv;
96 int w = priv->f->output_data.x->size_hints.min_width;
97 if (minimum) *minimum = w;
98 if (natural) *natural = w;
101 static void
102 emacs_fixed_get_preferred_height (GtkWidget *widget,
103 gint *minimum,
104 gint *natural)
106 EmacsFixed *fixed = EMACS_FIXED (widget);
107 EmacsFixedPrivate *priv = fixed->priv;
108 int h = priv->f->output_data.x->size_hints.min_height;
109 if (minimum) *minimum = h;
110 if (natural) *natural = h;
114 /* Override the X function so we can intercept Gtk+ 3 calls.
115 Use our values for min_width/height so that KDE don't freak out
116 (Bug#8919), and so users can resize our frames as they wish. */
118 void
119 XSetWMSizeHints (Display* d,
120 Window w,
121 XSizeHints* hints,
122 Atom prop)
124 struct x_display_info *dpyinfo = x_display_info_for_display (d);
125 struct frame *f = x_top_window_to_frame (dpyinfo, w);
126 long data[18];
127 data[0] = hints->flags;
128 data[1] = hints->x;
129 data[2] = hints->y;
130 data[3] = hints->width;
131 data[4] = hints->height;
132 data[5] = hints->min_width;
133 data[6] = hints->min_height;
134 data[7] = hints->max_width;
135 data[8] = hints->max_height;
136 data[9] = hints->width_inc;
137 data[10] = hints->height_inc;
138 data[11] = hints->min_aspect.x;
139 data[12] = hints->min_aspect.y;
140 data[13] = hints->max_aspect.x;
141 data[14] = hints->max_aspect.y;
142 data[15] = hints->base_width;
143 data[16] = hints->base_height;
144 data[17] = hints->win_gravity;
146 if ((hints->flags & PMinSize) && f)
148 int w = f->output_data.x->size_hints.min_width;
149 int h = f->output_data.x->size_hints.min_height;
150 data[5] = w;
151 data[6] = h;
154 XChangeProperty (d, w, prop, XA_WM_SIZE_HINTS, 32, PropModeReplace,
155 (unsigned char *) data, 18);
158 /* Override this X11 function.
159 This function is in the same X11 file as the one above. So we must
160 provide it also. */
162 void
163 XSetWMNormalHints (Display *d, Window w, XSizeHints *hints)
165 XSetWMSizeHints (d, w, hints, XA_WM_NORMAL_HINTS);