* textmodes/reftex-vars.el (reftex-label-alist): Docfix.
[emacs.git] / src / emacsgtkfixed.c
blob1a62b59b7afb7c8d69fea7ee117c5b9d5f284d04
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 #define EMACS_TYPE_FIXED emacs_fixed_get_type ()
32 #define EMACS_FIXED(obj) \
33 G_TYPE_CHECK_INSTANCE_CAST (obj, EMACS_TYPE_FIXED, EmacsFixed)
35 typedef struct _EmacsFixed EmacsFixed;
36 typedef struct _EmacsFixedPrivate EmacsFixedPrivate;
37 typedef struct _EmacsFixedClass EmacsFixedClass;
39 struct _EmacsFixed
41 GtkFixed container;
43 /*< private >*/
44 EmacsFixedPrivate *priv;
47 struct _EmacsFixedClass
49 GtkFixedClass parent_class;
52 struct _EmacsFixedPrivate
54 struct frame *f;
58 static void emacs_fixed_get_preferred_width (GtkWidget *widget,
59 gint *minimum,
60 gint *natural);
61 static void emacs_fixed_get_preferred_height (GtkWidget *widget,
62 gint *minimum,
63 gint *natural);
64 static GType emacs_fixed_get_type (void);
65 G_DEFINE_TYPE (EmacsFixed, emacs_fixed, GTK_TYPE_FIXED)
67 static void
68 emacs_fixed_class_init (EmacsFixedClass *klass)
70 GtkWidgetClass *widget_class;
72 widget_class = (GtkWidgetClass*) klass;
74 widget_class->get_preferred_width = emacs_fixed_get_preferred_width;
75 widget_class->get_preferred_height = emacs_fixed_get_preferred_height;
76 g_type_class_add_private (klass, sizeof (EmacsFixedPrivate));
79 static void
80 emacs_fixed_init (EmacsFixed *fixed)
82 fixed->priv = G_TYPE_INSTANCE_GET_PRIVATE (fixed, EMACS_TYPE_FIXED,
83 EmacsFixedPrivate);
84 fixed->priv->f = 0;
87 /**
88 * emacs_fixed_new:
90 * Creates a new #EmacsFixed.
92 * Returns: a new #EmacsFixed.
94 GtkWidget*
95 emacs_fixed_new (struct frame *f)
97 EmacsFixed *fixed = g_object_new (EMACS_TYPE_FIXED, NULL);
98 EmacsFixedPrivate *priv = fixed->priv;
99 priv->f = f;
100 return GTK_WIDGET (fixed);
103 static void
104 emacs_fixed_get_preferred_width (GtkWidget *widget,
105 gint *minimum,
106 gint *natural)
108 EmacsFixed *fixed = EMACS_FIXED (widget);
109 EmacsFixedPrivate *priv = fixed->priv;
110 int w = priv->f->output_data.x->size_hints.min_width;
111 if (minimum) *minimum = w;
112 if (natural) *natural = w;
115 static void
116 emacs_fixed_get_preferred_height (GtkWidget *widget,
117 gint *minimum,
118 gint *natural)
120 EmacsFixed *fixed = EMACS_FIXED (widget);
121 EmacsFixedPrivate *priv = fixed->priv;
122 int h = priv->f->output_data.x->size_hints.min_height;
123 if (minimum) *minimum = h;
124 if (natural) *natural = h;
128 /* Override the X function so we can intercept Gtk+ 3 calls.
129 Use our values for min_width/height so that KDE don't freak out
130 (Bug#8919), and so users can resize our frames as they wish. */
132 void
133 XSetWMSizeHints (Display* d,
134 Window w,
135 XSizeHints* hints,
136 Atom prop)
138 struct x_display_info *dpyinfo = x_display_info_for_display (d);
139 struct frame *f = x_top_window_to_frame (dpyinfo, w);
140 long data[18];
141 data[0] = hints->flags;
142 data[1] = hints->x;
143 data[2] = hints->y;
144 data[3] = hints->width;
145 data[4] = hints->height;
146 data[5] = hints->min_width;
147 data[6] = hints->min_height;
148 data[7] = hints->max_width;
149 data[8] = hints->max_height;
150 data[9] = hints->width_inc;
151 data[10] = hints->height_inc;
152 data[11] = hints->min_aspect.x;
153 data[12] = hints->min_aspect.y;
154 data[13] = hints->max_aspect.x;
155 data[14] = hints->max_aspect.y;
156 data[15] = hints->base_width;
157 data[16] = hints->base_height;
158 data[17] = hints->win_gravity;
160 if ((hints->flags & PMinSize) && f)
162 int w = f->output_data.x->size_hints.min_width;
163 int h = f->output_data.x->size_hints.min_height;
164 data[5] = w;
165 data[6] = h;
168 XChangeProperty (d, w, prop, XA_WM_SIZE_HINTS, 32, PropModeReplace,
169 (unsigned char *) data, 18);
172 /* Override this X11 function.
173 This function is in the same X11 file as the one above. So we must
174 provide it also. */
176 void
177 XSetWMNormalHints (Display *d, Window w, XSizeHints *hints)
179 XSetWMSizeHints (d, w, hints, XA_WM_NORMAL_HINTS);