From: Jan Djärv Date: Mon, 2 Aug 2010 12:50:03 +0000 (+0200) Subject: Don't use Gtk+ tooltip unless Gtk+ version => 2.14. X-Git-Tag: emacs-pretest-24.0.90~104^2~275^2~438^2~49^2~75 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=ac01763ed233b649f0daffc08b4f6e3b16d8876a;p=emacs.git Don't use Gtk+ tooltip unless Gtk+ version => 2.14. * gtkutil.c (hierarchy_ch_cb, qttip_cb): Do not define unless USE_GTK_TOOLTIP. (xg_prepare_tooltip): Return 0 unless USE_GTK_TOOLTIP (xg_show_tooltip, xg_hide_tooltip): Do nothing unless USE_GTK_TOOLTIP. (xg_create_frame_widgets): Surrond tooltip-related code with ifdef USE_GTK_TOOLTIP. (xg_free_frame_widgets): Don't delete ttip_* unless USE_GTK_TOOLTIP. * xterm.h (USE_GTK_TOOLTIP): New define. (struct x_output): Put ttip_* inside ifdef USE_GTK_TOOLTIP. --- diff --git a/src/ChangeLog b/src/ChangeLog index 60b881b3784..4368c621201 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,17 @@ 2010-08-02 Jan Djärv + * gtkutil.c (hierarchy_ch_cb, qttip_cb): Do not define unless + USE_GTK_TOOLTIP. + (xg_prepare_tooltip): Return 0 unless USE_GTK_TOOLTIP + (xg_show_tooltip, xg_hide_tooltip): Do nothing unless + USE_GTK_TOOLTIP. + (xg_create_frame_widgets): Surrond tooltip-related code with ifdef + USE_GTK_TOOLTIP. + (xg_free_frame_widgets): Don't delete ttip_* unless USE_GTK_TOOLTIP. + + * xterm.h (USE_GTK_TOOLTIP): New define. + (struct x_output): Put ttip_* inside ifdef USE_GTK_TOOLTIP. + * sysdep.c (child_setup_tty): Enable ICANON in lflags and set VEOF to Control-D (Bug#6771). diff --git a/src/gtkutil.c b/src/gtkutil.c index 48b013993a7..103522075bf 100644 --- a/src/gtkutil.c +++ b/src/gtkutil.c @@ -514,6 +514,8 @@ get_utf8_string (char *str) 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, @@ -562,15 +564,20 @@ qttip_cb (GtkWidget *widget, return FALSE; } +#endif /* USE_GTK_TOOLTIP */ + /* Prepare a tooltip to be shown, i.e. calculate WIDTH and HEIGHT. Return zero if no system tooltip available, non-zero otherwise. */ int xg_prepare_tooltip (FRAME_PTR f, - Lisp_Object string, - int *width, + Lisp_Object string, + int *width, int *height) { +#ifndef USE_GTK_TOOLTIP + return 0; +#else struct x_output *x = f->output_data.x; GtkWidget *widget; GdkWindow *gwin; @@ -614,6 +621,7 @@ xg_prepare_tooltip (FRAME_PTR f, UNBLOCK_INPUT; return 1; +#endif /* USE_GTK_TOOLTIP */ } /* Show the tooltip at ROOT_X and ROOT_Y. @@ -622,6 +630,7 @@ xg_prepare_tooltip (FRAME_PTR f, void xg_show_tooltip (FRAME_PTR f, int root_x, int root_y) { +#ifdef USE_GTK_TOOLTIP struct x_output *x = f->output_data.x; if (x->ttip_window) { @@ -630,6 +639,7 @@ xg_show_tooltip (FRAME_PTR f, int root_x, int root_y) gtk_widget_show_all (GTK_WIDGET (x->ttip_window)); UNBLOCK_INPUT; } +#endif } /* Hide tooltip if shown. Do nothing if not shown. @@ -640,6 +650,7 @@ int xg_hide_tooltip (FRAME_PTR f) { int ret = 0; +#ifdef USE_GTK_TOOLTIP if (f->output_data.x->ttip_window) { GtkWindow *win = f->output_data.x->ttip_window; @@ -657,7 +668,7 @@ xg_hide_tooltip (FRAME_PTR f) ret = 1; } - +#endif return ret; } @@ -1002,12 +1013,14 @@ xg_create_frame_widgets (FRAME_PTR f) style->bg_pixmap_name[GTK_STATE_NORMAL] = g_strdup (""); gtk_widget_modify_style (wfixed, style); +#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 UNBLOCK_INPUT; @@ -1023,10 +1036,12 @@ xg_free_frame_widgets (FRAME_PTR f) gtk_widget_destroy (FRAME_GTK_OUTER_WIDGET (f)); FRAME_X_WINDOW (f) = 0; /* Set to avoid XDestroyWindow in xterm.c */ 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 } } diff --git a/src/xterm.h b/src/xterm.h index 1674cdbac68..278c6b13cf1 100644 --- a/src/xterm.h +++ b/src/xterm.h @@ -51,6 +51,10 @@ typedef GtkWidget *xt_or_gtk_widget; #define XSync(d, b) do { gdk_window_process_all_updates (); \ XSync (d, b); } while (0) +/* The GtkTooltip API came in 2.12, but gtk-enable-tooltips in 2.14. */ +#if GTK_MAJOR_VERSION > 2 || GTK_MINOR_VERSION > 13 +#define USE_GTK_TOOLTIP +#endif #endif /* USE_GTK */ @@ -503,10 +507,13 @@ struct x_output GdkGeometry size_hints; long hint_flags; +#ifdef USE_GTK_TOOLTIP GtkTooltip *ttip_widget; GtkWidget *ttip_lbl; GtkWindow *ttip_window; -#endif +#endif /* USE_GTK_TOOLTIP */ + +#endif /* USE_GTK */ /* If >=0, a bitmap index. The indicated bitmap is used for the icon. */