#include <X11/extensions/Xdbe.h>
#endif
-#ifndef HAVE_GTK_WIDGET_SET_HAS_WINDOW
-#define gtk_widget_set_has_window(w, b) \
- (gtk_fixed_set_has_window (GTK_FIXED (w), b))
-#endif
-#ifndef HAVE_GTK_DIALOG_GET_ACTION_AREA
-#define gtk_dialog_get_action_area(w) ((w)->action_area)
-#define gtk_dialog_get_content_area(w) ((w)->vbox)
-#endif
-#ifndef HAVE_GTK_WIDGET_GET_SENSITIVE
-#define gtk_widget_get_sensitive(w) (GTK_WIDGET_SENSITIVE (w))
-#endif
-#ifndef HAVE_GTK_ADJUSTMENT_GET_PAGE_SIZE
-#define gtk_adjustment_set_page_size(w, s) ((w)->page_size = (s))
-#define gtk_adjustment_set_page_increment(w, s) ((w)->page_increment = (s))
-#define gtk_adjustment_get_step_increment(w) ((w)->step_increment)
-#define gtk_adjustment_set_step_increment(w, s) ((w)->step_increment = (s))
-#endif
-#if GTK_CHECK_VERSION (2, 12, 0)
-#define remove_submenu(w) gtk_menu_item_set_submenu ((w), NULL)
+#ifdef HAVE_GTK3
+#define XG_TEXT_CANCEL "Cancel"
+#define XG_TEXT_OK "OK"
+#define XG_TEXT_OPEN "Open"
#else
-#define remove_submenu(w) gtk_menu_item_remove_submenu ((w))
+#define XG_TEXT_CANCEL GTK_STOCK_CANCEL
+#define XG_TEXT_OK GTK_STOCK_OK
+#define XG_TEXT_OPEN GTK_STOCK_OPEN
#endif
-#if ! GTK_CHECK_VERSION (2, 14, 0)
-#define gtk_adjustment_configure(adj, xvalue, xlower, \
- xupper, xstep_increment, \
- xpage_increment, xpagesize) \
- do { \
- adj->lower = xlower; \
- adj->upper = xupper; \
- adj->page_size = xpagesize; \
- gtk_adjustment_set_value (adj, xvalue); \
- adj->page_increment = xpage_increment; \
- adj->step_increment = xstep_increment; \
- } while (0)
-#endif /* < Gtk+ 2.14 */
+#ifndef HAVE_GTK3
#ifdef HAVE_FREETYPE
-#if GTK_CHECK_VERSION (3, 2, 0)
-#define USE_NEW_GTK_FONT_CHOOSER 1
-#else
-#define USE_NEW_GTK_FONT_CHOOSER 0
#define gtk_font_chooser_dialog_new(x, y) \
gtk_font_selection_dialog_new (x)
#undef GTK_FONT_CHOOSER
#define gtk_font_chooser_set_font(x, y) \
gtk_font_selection_dialog_set_font_name (x, y)
#endif
-#endif /* HAVE_FREETYPE */
-
-#if GTK_CHECK_VERSION (3, 10, 0)
-#define XG_TEXT_CANCEL "Cancel"
-#define XG_TEXT_OK "OK"
-#define XG_TEXT_OPEN "Open"
-#else
-#define XG_TEXT_CANCEL GTK_STOCK_CANCEL
-#define XG_TEXT_OK GTK_STOCK_OK
-#define XG_TEXT_OPEN GTK_STOCK_OPEN
-#endif
-#ifndef HAVE_GTK3
-#ifdef USE_GTK_TOOLTIP
-#define gdk_window_get_screen(w) gdk_drawable_get_screen (w)
-#endif
#define gdk_window_get_geometry(w, a, b, c, d) \
gdk_window_get_geometry (w, a, b, c, d, 0)
-#define gdk_x11_window_lookup_for_display(d, w) \
- gdk_xid_table_lookup_for_display (d, w)
#define gtk_box_new(ori, spacing) \
((ori) == GTK_ORIENTATION_HORIZONTAL \
? gtk_hbox_new (FALSE, (spacing)) : gtk_vbox_new (FALSE, (spacing)))
#define gtk_scrollbar_new(ori, spacing) \
((ori) == GTK_ORIENTATION_HORIZONTAL \
? gtk_hscrollbar_new ((spacing)) : gtk_vscrollbar_new ((spacing)))
-#ifndef GDK_KEY_g
-#define GDK_KEY_g GDK_g
-#endif
#endif /* HAVE_GTK3 */
#define XG_BIN_CHILD(x) gtk_bin_get_child (GTK_BIN (x))
int
xg_get_scale (struct frame *f)
{
-#if GTK_CHECK_VERSION (3, 10, 0)
+#ifdef HAVE_GTK3
if (FRAME_GTK_WIDGET (f))
return gtk_widget_get_scale_factor (FRAME_GTK_WIDGET (f));
#endif
gdpy_def = gdpy_new;
}
-#if GTK_CHECK_VERSION (2, 0, 0) && ! GTK_CHECK_VERSION (2, 10, 0)
- /* GTK 2.2-2.8 has a bug that makes gdk_display_close crash
- <https://gitlab.gnome.org/GNOME/gtk/issues/221>. This way we
- can continue running, but there will be memory leaks. */
- g_object_run_dispose (G_OBJECT (gdpy));
-#else
- /* This seems to be fixed in GTK 2.10. */
gdk_display_close (gdpy);
-#endif
}
\f
GtkWidget *widget,
GtkImage *old_widget)
{
-#if defined USE_CAIRO && GTK_CHECK_VERSION (3, 10, 0)
+#if defined USE_CAIRO && defined HAVE_GTK3
cairo_surface_t *surface;
#else
GdkPixbuf *icon_buf;
on a monochrome display, and sometimes bad on all displays with
certain themes. */
-#if defined USE_CAIRO && GTK_CHECK_VERSION (3, 10, 0)
+#if defined USE_CAIRO && defined HAVE_GTK3
surface = img->cr_data;
if (surface)
We use that to pop down the tooltip. This happens if Gtk+ for some
reason wants to change or hide the tooltip. */
-#ifdef USE_GTK_TOOLTIP
-
static void
hierarchy_ch_cb (GtkWidget *widget,
GtkWidget *previous_toplevel,
return FALSE;
}
-#endif /* USE_GTK_TOOLTIP */
-
/* Prepare a tooltip to be shown, i.e. calculate WIDTH and HEIGHT.
Return true if a system tooltip is available. */
int *width,
int *height)
{
-#ifndef USE_GTK_TOOLTIP
- return 0;
-#else
struct x_output *x = f->output_data.x;
GtkWidget *widget;
GdkWindow *gwin;
unblock_input ();
return TRUE;
-#endif /* USE_GTK_TOOLTIP */
}
/* Show the tooltip at ROOT_X and ROOT_Y.
void
xg_show_tooltip (struct frame *f, int root_x, int root_y)
{
-#ifdef USE_GTK_TOOLTIP
struct x_output *x = f->output_data.x;
if (x->ttip_window)
{
gtk_widget_show (GTK_WIDGET (x->ttip_window));
unblock_input ();
}
-#endif
}
bool
xg_hide_tooltip (struct frame *f)
{
-#ifdef USE_GTK_TOOLTIP
if (f->output_data.x->ttip_window)
{
GtkWindow *win = f->output_data.x->ttip_window;
return TRUE;
}
-#endif
return FALSE;
}
has backported it to Gtk+ 2.0 and they add the resize grip for
Gtk+ 2.0 applications also. But it has a bug that makes Emacs loop
forever, so disable the grip. */
-#if (! GTK_CHECK_VERSION (3, 0, 0) \
+#if (! defined HAVE_GTK3 \
&& defined HAVE_GTK_WINDOW_SET_HAS_RESIZE_GRIP)
gtk_window_set_has_resize_grip (GTK_WINDOW (wtop), FALSE);
#endif
gdk_window_set_override_redirect (gwin, TRUE);
}
-#ifdef USE_GTK_TOOLTIP
/* Steal a tool tip window we can move ourselves. */
f->output_data.x->ttip_widget = 0;
f->output_data.x->ttip_lbl = 0;
f->output_data.x->ttip_window = 0;
gtk_widget_set_tooltip_text (wtop, "Dummy text");
g_signal_connect (wtop, "query-tooltip", G_CALLBACK (qttip_cb), f);
-#endif
{
GdkScreen *screen = gtk_widget_get_screen (wtop);
{
if (FRAME_GTK_OUTER_WIDGET (f))
{
-#ifdef USE_GTK_TOOLTIP
struct x_output *x = f->output_data.x;
-#endif
struct xg_frame_tb_info *tbinfo
= g_object_get_data (G_OBJECT (FRAME_GTK_OUTER_WIDGET (f)),
TB_INFO_KEY);
FRAME_X_WINDOW (f) = 0; /* Set to avoid XDestroyWindow in xterm.c */
FRAME_X_RAW_DRAWABLE (f) = 0;
FRAME_GTK_OUTER_WIDGET (f) = 0;
-#ifdef USE_GTK_TOOLTIP
if (x->ttip_lbl)
gtk_widget_destroy (x->ttip_lbl);
if (x->ttip_widget)
g_object_unref (G_OBJECT (x->ttip_widget));
-#endif
}
}
void
xg_frame_restack (struct frame *f1, struct frame *f2, bool above_flag)
{
-#if GTK_CHECK_VERSION (2, 18, 0)
block_input ();
if (FRAME_GTK_OUTER_WIDGET (f1) && FRAME_GTK_OUTER_WIDGET (f2))
{
x_sync (f1);
}
unblock_input ();
-#endif
}
#ifdef HAVE_FREETYPE
-#if USE_NEW_GTK_FONT_CHOOSER
+#ifdef HAVE_GTK3
#define XG_WEIGHT_TO_SYMBOL(w) \
(w <= PANGO_WEIGHT_THIN ? Qextra_light \
: s == PANGO_STYLE_ITALIC ? Qitalic \
: Qnormal)
-#endif /* USE_NEW_GTK_FONT_CHOOSER */
+#endif /* HAVE_GTK3 */
static char *x_last_font_name;
done = xg_dialog_run (f, w);
if (done == GTK_RESPONSE_OK)
{
-#if USE_NEW_GTK_FONT_CHOOSER
+#ifdef HAVE_GTK3
/* Use the GTK3 font chooser. */
PangoFontDescription *desc
= gtk_font_chooser_get_font_desc (GTK_FONT_CHOOSER (w));
g_free (x_last_font_name);
x_last_font_name = font_name;
}
-#endif /* USE_NEW_GTK_FONT_CHOOSER */
+#endif /* HAVE_GTK3 */
}
gtk_widget_destroy (w);
bridge that might be loaded) that the item's label has
changed. */
gtk_label_set_text (wlabel, utf8_label);
-#if GTK_CHECK_VERSION (2, 16, 0)
g_object_notify (G_OBJECT (witem), "label");
-#endif
if (utf8_label) g_free (utf8_label);
iter = g_list_next (iter);
val = val->next;
}
}
-#if GTK_CHECK_VERSION (2, 16, 0)
if (label_changed) /* See comment in xg_update_menubar. */
g_object_notify (G_OBJECT (w), "label");
-#endif
}
/* Update the toggle menu item W so it corresponds to VAL. */
{
/* Not a submenu anymore. */
g_object_ref (G_OBJECT (sub));
- remove_submenu (witem);
+ gtk_menu_item_set_submenu (witem, NULL);
gtk_widget_destroy (sub);
}
else if (cur->contents)
}
#endif
-#ifdef HAVE_GTK_ORIENTABLE_SET_ORIENTATION
-#define toolbar_set_orientation(w, o) \
- gtk_orientable_set_orientation (GTK_ORIENTABLE (w), o)
-#else
-#define toolbar_set_orientation(w, o) \
- gtk_toolbar_set_orientation (GTK_TOOLBAR (w), o)
-#endif
-
/* Attach a tool bar to frame F. */
static void
bool into_hbox = EQ (pos, Qleft) || EQ (pos, Qright);
GtkWidget *top_widget = x->toolbar_widget;
- toolbar_set_orientation (x->toolbar_widget,
- into_hbox
- ? GTK_ORIENTATION_VERTICAL
- : GTK_ORIENTATION_HORIZONTAL);
+ gtk_orientable_set_orientation (GTK_ORIENTABLE (x->toolbar_widget),
+ into_hbox
+ ? GTK_ORIENTATION_VERTICAL
+ : GTK_ORIENTATION_HORIZONTAL);
if (into_hbox)
{
xg_create_tool_bar (struct frame *f)
{
struct x_output *x = f->output_data.x;
-#if GTK_CHECK_VERSION (3, 3, 6)
+#ifdef HAVE_GTK3
GtkStyleContext *gsty;
#endif
struct xg_frame_tb_info *tbinfo
gtk_widget_set_name (x->toolbar_widget, "emacs-toolbar");
gtk_toolbar_set_style (GTK_TOOLBAR (x->toolbar_widget), GTK_TOOLBAR_ICONS);
- toolbar_set_orientation (x->toolbar_widget, GTK_ORIENTATION_HORIZONTAL);
+ gtk_orientable_set_orientation (GTK_ORIENTABLE (x->toolbar_widget),
+ GTK_ORIENTATION_HORIZONTAL);
g_signal_connect (x->toolbar_widget, "size-allocate",
G_CALLBACK (tb_size_cb), f);
-#if GTK_CHECK_VERSION (3, 3, 6)
+#ifdef HAVE_GTK3
gsty = gtk_widget_get_style_context (x->toolbar_widget);
gtk_style_context_add_class (gsty, "primary-toolbar");
#endif
GtkWidget *wb = gtk_button_new ();
/* The eventbox is here so we can have tooltips on disabled items. */
GtkWidget *weventbox = gtk_event_box_new ();
-#if GTK_CHECK_VERSION (3, 3, 6)
+#ifdef HAVE_GTK3
GtkCssProvider *css_prov = gtk_css_provider_new ();
GtkStyleContext *gsty;
{
gpointer gold_img = g_object_get_data (G_OBJECT (wimage),
XG_TOOL_BAR_IMAGE_DATA);
-#if defined USE_CAIRO && GTK_CHECK_VERSION (3, 10, 0)
+#if defined USE_CAIRO && defined HAVE_GTK3
void *old_img = (void *) gold_img;
if (old_img != img->cr_data)
return 1;
GtkIconTheme *icon_theme,
char **icon_name)
{
-#if ! GTK_CHECK_VERSION (3, 10, 0)
+#ifndef HAVE_GTK3
GtkStockItem stock_item;
#endif
*icon_name = NULL;
}
-#if ! GTK_CHECK_VERSION (3, 10, 0)
+#ifndef HAVE_GTK3
else if (gtk_stock_lookup (name, &stock_item))
*icon_name = NULL;
#endif
prepare_image_for_display (f, img);
if (img->load_failed_p
-#if defined USE_CAIRO && GTK_CHECK_VERSION (3, 10, 0)
+#if defined USE_CAIRO && defined HAVE_GTK3
|| img->cr_data == NULL
#else
|| img->pixmap == None
else if (stock_name)
{
-#if GTK_CHECK_VERSION (3, 10, 0)
+#ifdef HAVE_GTK3
w = gtk_image_new_from_icon_name (stock_name, icon_size);
#else
w = gtk_image_new_from_stock (stock_name, icon_size);
{
w = xg_get_image_for_pixmap (f, img, x->widget, NULL);
g_object_set_data (G_OBJECT (w), XG_TOOL_BAR_IMAGE_DATA,
-#if defined USE_CAIRO && GTK_CHECK_VERSION (3, 10, 0)
+#if defined USE_CAIRO && defined HAVE_GTK3
(gpointer)img->cr_data
#else
(gpointer)img->pixmap
settings = gtk_settings_get_for_screen (gdk_display_get_default_screen
(gdk_display_get_default ()));
-#if ! GTK_CHECK_VERSION (3, 10, 0)
+#ifndef HAVE_GTK3
/* Remove F10 as a menu accelerator, it does not mix well with Emacs key
bindings. It doesn't seem to be any way to remove properties,
so we set it to "" which in means "no key". */
Return false if and only if the workarea information cannot be
obtained via the _NET_WORKAREA root window property. */
-#if ! GTK_CHECK_VERSION (3, 4, 0)
+#ifndef HAVE_GTK3
static bool
x_get_net_workarea (struct x_display_info *dpyinfo, XRectangle *rect)
{
Lisp_Object attributes_list = Qnil;
#ifdef USE_GTK
- double mm_width_per_pixel, mm_height_per_pixel;
GdkDisplay *gdpy;
#if ! GTK_CHECK_VERSION (3, 22, 0)
+ double mm_width_per_pixel, mm_height_per_pixel;
GdkScreen *gscreen;
#endif
gint primary_monitor = 0, n_monitors, i;
struct MonitorInfo *monitors;
block_input ();
- mm_width_per_pixel = ((double) WidthMMOfScreen (dpyinfo->screen)
- / x_display_pixel_width (dpyinfo));
- mm_height_per_pixel = ((double) HeightMMOfScreen (dpyinfo->screen)
- / x_display_pixel_height (dpyinfo));
gdpy = gdk_x11_lookup_xdisplay (dpyinfo->display);
#if GTK_CHECK_VERSION (3, 22, 0)
n_monitors = gdk_display_get_n_monitors (gdpy);
#else
gscreen = gdk_display_get_default_screen (gdpy);
-#if GTK_CHECK_VERSION (2, 20, 0)
- primary_monitor = gdk_screen_get_primary_monitor (gscreen);
-#endif
n_monitors = gdk_screen_get_n_monitors (gscreen);
+ primary_monitor = gdk_screen_get_primary_monitor (gscreen);
+ /* Fallback if gdk_screen_get_monitor_{width,height}_mm fail */
+ mm_width_per_pixel = ((double) WidthMMOfScreen (dpyinfo->screen)
+ / x_display_pixel_width (dpyinfo));
+ mm_height_per_pixel = ((double) HeightMMOfScreen (dpyinfo->screen)
+ / x_display_pixel_height (dpyinfo));
#endif
monitor_frames = make_nil_vector (n_monitors);
monitors = xzalloc (n_monitors * sizeof *monitors);
for (i = 0; i < n_monitors; ++i)
{
- gint width_mm = -1, height_mm = -1;
+ gint width_mm, height_mm;
GdkRectangle rec, work;
struct MonitorInfo *mi = &monitors[i];
int scale = 1;
#if GTK_CHECK_VERSION (3, 22, 0)
width_mm = gdk_monitor_get_width_mm (monitor);
height_mm = gdk_monitor_get_height_mm (monitor);
-#elif GTK_CHECK_VERSION (2, 14, 0)
+#else
width_mm = gdk_screen_get_monitor_width_mm (gscreen, i);
height_mm = gdk_screen_get_monitor_height_mm (gscreen, i);
-#endif
if (width_mm < 0)
width_mm = rec.width * mm_width_per_pixel + 0.5;
if (height_mm < 0)
height_mm = rec.height * mm_height_per_pixel + 0.5;
-
+#endif
#if GTK_CHECK_VERSION (3, 22, 0)
gdk_monitor_get_workarea (monitor, &work);
-#elif GTK_CHECK_VERSION (3, 4, 0)
+#elif defined HAVE_GTK3
gdk_screen_get_monitor_workarea (gscreen, i, &work);
#else
/* Emulate the behavior of GTK+ 3.4. */
/* GTK returns scaled sizes for the workareas. */
#if GTK_CHECK_VERSION (3, 22, 0)
scale = gdk_monitor_get_scale_factor (monitor);
-#elif GTK_CHECK_VERSION (3, 10, 0)
+#elif defined HAVE_GTK3
scale = gdk_screen_get_monitor_scale_factor (gscreen, i);
#endif
rec.width *= scale;
#if GTK_CHECK_VERSION (3, 22, 0)
dupstring (&mi->name, (gdk_monitor_get_model (monitor)));
-#elif GTK_CHECK_VERSION (2, 14, 0)
+#else
mi->name = gdk_screen_get_monitor_plug_name (gscreen, i);
#endif
}
primary_monitor,
monitor_frames,
source);
-#if GTK_CHECK_VERSION (2, 14, 0)
free_monitors (monitors, n_monitors);
-#else
- xfree (monitors);
-#endif
unblock_input ();
#else /* not USE_GTK */
static void
x_frame_restack (struct frame *f1, struct frame *f2, bool above_flag)
{
-#if defined (USE_GTK) && GTK_CHECK_VERSION (2, 18, 0)
+#ifdef USE_GTK
block_input ();
xg_frame_restack (f1, f2, above_flag);
unblock_input ();