2015-08-08 17:04:28 +03:00
|
|
|
/*
|
|
|
|
* Header file to make compatibility with older GTK versions less
|
|
|
|
* painful, by #defining various things that are pure spelling changes
|
2015-08-22 15:50:56 +03:00
|
|
|
* between GTK1 and GTK2, or between 2 and 3.
|
2015-08-08 17:04:28 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
#if !GTK_CHECK_VERSION(2,0,0)
|
|
|
|
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <X11/X.h>
|
|
|
|
|
2015-08-08 17:53:43 +03:00
|
|
|
/* Helper macro used in definitions below. Note that although it
|
|
|
|
* *expands* w and flag twice, it does not *evaluate* them twice
|
|
|
|
* because the evaluations are in exclusive branches of ?:. So it's
|
|
|
|
* a side-effect-safe macro. */
|
|
|
|
#define gtk1_widget_set_unset_flag(w, flag, b) \
|
|
|
|
((b) ? GTK_WIDGET_SET_FLAGS(w, flag) : GTK_WIDGET_UNSET_FLAGS(w, flag))
|
|
|
|
|
2015-08-08 19:29:02 +03:00
|
|
|
#define GType GtkType
|
|
|
|
#define GObject GtkObject
|
2015-08-08 17:04:28 +03:00
|
|
|
#define G_CALLBACK(x) GTK_SIGNAL_FUNC(x)
|
|
|
|
#define G_OBJECT(x) GTK_OBJECT(x)
|
2015-08-08 19:29:02 +03:00
|
|
|
#define G_TYPE_CHECK_INSTANCE_TYPE GTK_CHECK_TYPE
|
|
|
|
#define G_TYPE_CHECK_INSTANCE_CAST GTK_CHECK_CAST
|
|
|
|
#define G_TYPE_CHECK_CLASS_TYPE GTK_CHECK_CLASS_TYPE
|
|
|
|
#define G_TYPE_CHECK_CLASS_CAST GTK_CHECK_CLASS_CAST
|
2015-08-08 17:53:43 +03:00
|
|
|
|
2015-08-08 17:04:28 +03:00
|
|
|
#define g_ascii_isspace(x) (isspace((unsigned char)(x)))
|
|
|
|
#define g_signal_connect gtk_signal_connect
|
2015-08-08 19:29:02 +03:00
|
|
|
#define g_signal_connect_swapped gtk_signal_connect_object
|
|
|
|
#define g_signal_stop_emission_by_name gtk_signal_emit_stop_by_name
|
|
|
|
#define g_signal_emit_by_name gtk_signal_emit_by_name
|
|
|
|
#define g_signal_handler_disconnect gtk_signal_disconnect
|
|
|
|
#define g_object_get_data gtk_object_get_data
|
2015-08-08 17:53:43 +03:00
|
|
|
#define g_object_set_data gtk_object_set_data
|
Rework special-commands system to add an integer argument.
In order to list cross-certifiable host keys in the GUI specials menu,
the SSH backend has been inventing new values on the end of the
Telnet_Special enumeration, starting from the value TS_LOCALSTART.
This is inelegant, and also makes it awkward to break up special
handlers (e.g. to dispatch different specials to different SSH
layers), since if all you know about a special is that it's somewhere
in the TS_LOCALSTART+n space, you can't tell what _general kind_ of
thing it is. Also, if I ever need another open-ended set of specials
in future, I'll have to remember which TS_LOCALSTART+n codes are in
which set.
So here's a revamp that causes every special to take an extra integer
argument. For all previously numbered specials, this argument is
passed as zero and ignored, but there's a new main special code for
SSH host key cross-certification, in which the integer argument is an
index into the backend's list of available keys. TS_LOCALSTART is now
a thing of the past: if I need any other open-ended sets of specials
in future, I can add a new top-level code with a nicely separated
space of arguments.
While I'm at it, I've removed the legacy misnomer 'Telnet_Special'
from the code completely; the enum is now SessionSpecialCode, the
struct containing full details of a menu entry is SessionSpecial, and
the enum values now start SS_ rather than TS_.
2018-09-24 11:35:52 +03:00
|
|
|
#define g_object_set_data_full gtk_object_set_data_full
|
2019-11-02 11:26:14 +03:00
|
|
|
#define g_object_ref_sink(x) do { \
|
|
|
|
gtk_object_ref(x); \
|
|
|
|
gtk_object_sink(x); \
|
|
|
|
} while (0)
|
2015-08-08 17:53:43 +03:00
|
|
|
|
2015-08-08 17:04:28 +03:00
|
|
|
#define GDK_GRAB_SUCCESS GrabSuccess
|
2015-08-08 17:53:43 +03:00
|
|
|
|
2015-08-16 16:16:23 +03:00
|
|
|
#define GDK_WINDOW_XID GDK_WINDOW_XWINDOW
|
|
|
|
|
2015-08-08 17:53:43 +03:00
|
|
|
#define gtk_widget_set_size_request gtk_widget_set_usize
|
2015-08-08 20:02:01 +03:00
|
|
|
#define gtk_radio_button_get_group gtk_radio_button_group
|
|
|
|
#define gtk_notebook_set_current_page gtk_notebook_set_page
|
2015-08-09 11:59:25 +03:00
|
|
|
#define gtk_color_selection_set_has_opacity_control \
|
|
|
|
gtk_color_selection_set_opacity
|
2015-08-08 17:53:43 +03:00
|
|
|
|
2015-08-08 17:04:28 +03:00
|
|
|
#define gtk_dialog_get_content_area(dlg) ((dlg)->vbox)
|
|
|
|
#define gtk_dialog_get_action_area(dlg) ((dlg)->action_area)
|
2015-08-08 17:53:43 +03:00
|
|
|
#define gtk_dialog_set_can_default(dlg) ((dlg)->action_area)
|
|
|
|
#define gtk_widget_get_window(w) ((w)->window)
|
|
|
|
#define gtk_widget_get_parent(w) ((w)->parent)
|
|
|
|
#define gtk_widget_set_allocation(w, a) ((w)->allocation = *(a))
|
|
|
|
#define gtk_container_get_border_width(c) ((c)->border_width)
|
2018-10-28 12:14:53 +03:00
|
|
|
#define gtk_container_get_focus_child(c) ((c)->focus_child)
|
2015-08-08 17:53:43 +03:00
|
|
|
#define gtk_bin_get_child(b) ((b)->child)
|
|
|
|
#define gtk_color_selection_dialog_get_color_selection(cs) ((cs)->colorsel)
|
|
|
|
#define gtk_selection_data_get_target(sd) ((sd)->target)
|
|
|
|
#define gtk_selection_data_get_data_type(sd) ((sd)->type)
|
|
|
|
#define gtk_selection_data_get_data(sd) ((sd)->data)
|
|
|
|
#define gtk_selection_data_get_length(sd) ((sd)->length)
|
|
|
|
#define gtk_selection_data_get_format(sd) ((sd)->format)
|
|
|
|
#define gtk_adjustment_set_lower(a, val) ((a)->lower = (val))
|
|
|
|
#define gtk_adjustment_set_upper(a, val) ((a)->upper = (val))
|
|
|
|
#define gtk_adjustment_set_page_size(a, val) ((a)->page_size = (val))
|
|
|
|
#define gtk_adjustment_set_page_increment(a, val) ((a)->page_increment = (val))
|
|
|
|
#define gtk_adjustment_set_step_increment(a, val) ((a)->step_increment = (val))
|
|
|
|
#define gtk_adjustment_get_value(a) ((a)->value)
|
2018-03-03 21:18:54 +03:00
|
|
|
#define gtk_selection_data_get_selection(a) ((a)->selection)
|
2018-03-03 21:20:04 +03:00
|
|
|
#define gdk_display_beep(disp) gdk_beep()
|
2015-08-08 17:53:43 +03:00
|
|
|
|
|
|
|
#define gtk_widget_set_has_window(w, b) \
|
|
|
|
gtk1_widget_set_unset_flag(w, GTK_NO_WINDOW, !(b))
|
|
|
|
#define gtk_widget_set_mapped(w, b) \
|
|
|
|
gtk1_widget_set_unset_flag(w, GTK_MAPPED, (b))
|
|
|
|
#define gtk_widget_set_can_default(w, b) \
|
|
|
|
gtk1_widget_set_unset_flag(w, GTK_CAN_DEFAULT, (b))
|
|
|
|
#define gtk_widget_get_visible(w) GTK_WIDGET_VISIBLE(w)
|
|
|
|
#define gtk_widget_get_mapped(w) GTK_WIDGET_MAPPED(w)
|
|
|
|
#define gtk_widget_get_realized(w) GTK_WIDGET_REALIZED(w)
|
|
|
|
#define gtk_widget_get_state(w) GTK_WIDGET_STATE(w)
|
2018-10-28 12:14:53 +03:00
|
|
|
#define gtk_widget_get_can_focus(w) GTK_WIDGET_CAN_FOCUS(w)
|
|
|
|
#define gtk_widget_is_drawable(w) GTK_WIDGET_DRAWABLE(w)
|
|
|
|
#define gtk_widget_is_sensitive(w) GTK_WIDGET_IS_SENSITIVE(w)
|
|
|
|
#define gtk_widget_has_focus(w) GTK_WIDGET_HAS_FOCUS(w)
|
2015-08-08 17:04:28 +03:00
|
|
|
|
2015-08-16 11:23:32 +03:00
|
|
|
/* This is a bit of a bodge because it relies on us only calling this
|
|
|
|
* macro as GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), so under
|
|
|
|
* GTK1 it makes sense to omit the contained function call and just
|
|
|
|
* return the GDK default display. */
|
|
|
|
#define GDK_DISPLAY_XDISPLAY(x) GDK_DISPLAY()
|
|
|
|
|
2018-03-03 21:18:54 +03:00
|
|
|
#define GDK_KEY_C ('C')
|
|
|
|
#define GDK_KEY_V ('V')
|
|
|
|
#define GDK_KEY_c ('c')
|
|
|
|
#define GDK_KEY_v ('v')
|
|
|
|
|
2017-02-23 17:23:46 +03:00
|
|
|
#endif /* 2.0 */
|
|
|
|
|
|
|
|
#if !GTK_CHECK_VERSION(2,22,0)
|
|
|
|
|
|
|
|
#define gdk_visual_get_depth(v) ((v)->depth)
|
|
|
|
|
|
|
|
#endif /* 2.22 */
|
|
|
|
|
|
|
|
#if !GTK_CHECK_VERSION(2,24,0)
|
|
|
|
|
2015-08-08 18:23:54 +03:00
|
|
|
#define GDK_KEY_Alt_L GDK_Alt_L
|
|
|
|
#define GDK_KEY_Alt_R GDK_Alt_R
|
|
|
|
#define GDK_KEY_BackSpace GDK_BackSpace
|
|
|
|
#define GDK_KEY_Begin GDK_Begin
|
|
|
|
#define GDK_KEY_Break GDK_Break
|
|
|
|
#define GDK_KEY_Delete GDK_Delete
|
|
|
|
#define GDK_KEY_Down GDK_Down
|
|
|
|
#define GDK_KEY_End GDK_End
|
|
|
|
#define GDK_KEY_Escape GDK_Escape
|
|
|
|
#define GDK_KEY_F10 GDK_F10
|
|
|
|
#define GDK_KEY_F11 GDK_F11
|
|
|
|
#define GDK_KEY_F12 GDK_F12
|
|
|
|
#define GDK_KEY_F13 GDK_F13
|
|
|
|
#define GDK_KEY_F14 GDK_F14
|
|
|
|
#define GDK_KEY_F15 GDK_F15
|
|
|
|
#define GDK_KEY_F16 GDK_F16
|
|
|
|
#define GDK_KEY_F17 GDK_F17
|
|
|
|
#define GDK_KEY_F18 GDK_F18
|
|
|
|
#define GDK_KEY_F19 GDK_F19
|
|
|
|
#define GDK_KEY_F1 GDK_F1
|
|
|
|
#define GDK_KEY_F20 GDK_F20
|
|
|
|
#define GDK_KEY_F2 GDK_F2
|
|
|
|
#define GDK_KEY_F3 GDK_F3
|
|
|
|
#define GDK_KEY_F4 GDK_F4
|
|
|
|
#define GDK_KEY_F5 GDK_F5
|
|
|
|
#define GDK_KEY_F6 GDK_F6
|
|
|
|
#define GDK_KEY_F7 GDK_F7
|
|
|
|
#define GDK_KEY_F8 GDK_F8
|
|
|
|
#define GDK_KEY_F9 GDK_F9
|
|
|
|
#define GDK_KEY_Home GDK_Home
|
|
|
|
#define GDK_KEY_Insert GDK_Insert
|
|
|
|
#define GDK_KEY_ISO_Left_Tab GDK_ISO_Left_Tab
|
|
|
|
#define GDK_KEY_KP_0 GDK_KP_0
|
|
|
|
#define GDK_KEY_KP_1 GDK_KP_1
|
|
|
|
#define GDK_KEY_KP_2 GDK_KP_2
|
|
|
|
#define GDK_KEY_KP_3 GDK_KP_3
|
|
|
|
#define GDK_KEY_KP_4 GDK_KP_4
|
|
|
|
#define GDK_KEY_KP_5 GDK_KP_5
|
|
|
|
#define GDK_KEY_KP_6 GDK_KP_6
|
|
|
|
#define GDK_KEY_KP_7 GDK_KP_7
|
|
|
|
#define GDK_KEY_KP_8 GDK_KP_8
|
|
|
|
#define GDK_KEY_KP_9 GDK_KP_9
|
|
|
|
#define GDK_KEY_KP_Add GDK_KP_Add
|
|
|
|
#define GDK_KEY_KP_Begin GDK_KP_Begin
|
|
|
|
#define GDK_KEY_KP_Decimal GDK_KP_Decimal
|
|
|
|
#define GDK_KEY_KP_Delete GDK_KP_Delete
|
|
|
|
#define GDK_KEY_KP_Divide GDK_KP_Divide
|
|
|
|
#define GDK_KEY_KP_Down GDK_KP_Down
|
|
|
|
#define GDK_KEY_KP_End GDK_KP_End
|
|
|
|
#define GDK_KEY_KP_Enter GDK_KP_Enter
|
|
|
|
#define GDK_KEY_KP_Home GDK_KP_Home
|
|
|
|
#define GDK_KEY_KP_Insert GDK_KP_Insert
|
|
|
|
#define GDK_KEY_KP_Left GDK_KP_Left
|
|
|
|
#define GDK_KEY_KP_Multiply GDK_KP_Multiply
|
|
|
|
#define GDK_KEY_KP_Page_Down GDK_KP_Page_Down
|
|
|
|
#define GDK_KEY_KP_Page_Up GDK_KP_Page_Up
|
|
|
|
#define GDK_KEY_KP_Right GDK_KP_Right
|
|
|
|
#define GDK_KEY_KP_Subtract GDK_KP_Subtract
|
|
|
|
#define GDK_KEY_KP_Up GDK_KP_Up
|
|
|
|
#define GDK_KEY_Left GDK_Left
|
|
|
|
#define GDK_KEY_Meta_L GDK_Meta_L
|
|
|
|
#define GDK_KEY_Meta_R GDK_Meta_R
|
|
|
|
#define GDK_KEY_Num_Lock GDK_Num_Lock
|
|
|
|
#define GDK_KEY_Page_Down GDK_Page_Down
|
|
|
|
#define GDK_KEY_Page_Up GDK_Page_Up
|
|
|
|
#define GDK_KEY_Return GDK_Return
|
|
|
|
#define GDK_KEY_Right GDK_Right
|
|
|
|
#define GDK_KEY_Tab GDK_Tab
|
|
|
|
#define GDK_KEY_Up GDK_Up
|
2016-11-13 16:53:42 +03:00
|
|
|
#define GDK_KEY_greater GDK_greater
|
|
|
|
#define GDK_KEY_less GDK_less
|
2015-08-08 18:23:54 +03:00
|
|
|
|
2017-02-23 17:23:46 +03:00
|
|
|
#define gdk_window_get_screen(w) gdk_drawable_get_screen(w)
|
|
|
|
#define gtk_combo_box_new_with_model_and_entry(t) gtk_combo_box_entry_new_with_model(t, 1)
|
|
|
|
|
|
|
|
#endif /* 2.24 */
|
2015-08-08 17:04:28 +03:00
|
|
|
|
Basic support for running under GDK Wayland back end.
GTK 3 PuTTY/pterm has always assumed that if it was compiled with
_support_ for talking to the raw X11 layer underneath GTK and GDK,
then it was entitled to expect that raw X11 layer to exist at all
times, i.e. that GDK_DISPLAY_XDISPLAY would return a meaningful X
display that it could do useful things with. So if you ran it over the
GDK Wayland backend, it would immediately segfault.
Modern GTK applications need to cope with multiple GDK backends at run
time. It's fine for GTK PuTTY to _contain_ the code to find and use
underlying X11 primitives like the display and the X window id, but it
should be prepared to find that it's running on Wayland (or something
else again!) so those functions don't return anything useful - in
which case it should degrade gracefully to the subset of functionality
that can be accessed through backend-independent GTK calls.
Accordingly, I've centralised the use of GDK_DISPLAY_XDISPLAY into a
support function get_x_display() in gtkmisc.c, which starts by
checking that there actually is one first. All previous direct uses of
GDK_*_XDISPLAY now go via that function, and check the result for NULL
afterwards. (To save faffing about calling that function too many
times, I'm also caching the display pointer in more places, and
passing it as an extra argument to various subfunctions, mostly in
gtkfont.c.)
Similarly, the get_windowid() function that retrieves the window id to
put in the environment of pterm's child process has to be prepared for
there not to be a window id.
This isn't a complete fix for all Wayland-related problems. The other
one I'm currently aware of is that the default font is "server:fixed",
which is a bad default now that it won't be available on all backends.
And I expect that further problems will show up with more testing. But
it's a start.
2018-05-09 11:18:20 +03:00
|
|
|
#if !GTK_CHECK_VERSION(3,0,0)
|
|
|
|
#define GDK_IS_X11_WINDOW(window) (1)
|
|
|
|
#endif
|
|
|
|
|
2015-08-22 15:50:56 +03:00
|
|
|
#if GTK_CHECK_VERSION(3,0,0)
|
|
|
|
#define STANDARD_OK_LABEL "_OK"
|
|
|
|
#define STANDARD_OPEN_LABEL "_Open"
|
|
|
|
#define STANDARD_CANCEL_LABEL "_Cancel"
|
|
|
|
#else
|
|
|
|
#define STANDARD_OK_LABEL GTK_STOCK_OK
|
|
|
|
#define STANDARD_OPEN_LABEL GTK_STOCK_OPEN
|
|
|
|
#define STANDARD_CANCEL_LABEL GTK_STOCK_CANCEL
|
|
|
|
#endif
|
2015-08-22 15:59:20 +03:00
|
|
|
|
|
|
|
#if GTK_CHECK_VERSION(3,0,0)
|
|
|
|
#define gtk_hseparator_new() gtk_separator_new(GTK_ORIENTATION_HORIZONTAL)
|
|
|
|
/* Fortunately, my hboxes and vboxes never actually set homogeneous to
|
2018-10-29 22:50:29 +03:00
|
|
|
* true, so I can just wrap these deprecated constructors with a macro
|
2015-08-22 15:59:20 +03:00
|
|
|
* without also having to arrange a call to gtk_box_set_homogeneous. */
|
|
|
|
#define gtk_hbox_new(homogeneous, spacing) \
|
|
|
|
gtk_box_new(GTK_ORIENTATION_HORIZONTAL, spacing)
|
|
|
|
#define gtk_vbox_new(homogeneous, spacing) \
|
|
|
|
gtk_box_new(GTK_ORIENTATION_VERTICAL, spacing)
|
|
|
|
#define gtk_vscrollbar_new(adjust) \
|
|
|
|
gtk_scrollbar_new(GTK_ORIENTATION_VERTICAL, adjust)
|
2015-08-22 16:07:02 +03:00
|
|
|
|
|
|
|
#define gdk_get_display() gdk_display_get_name(gdk_display_get_default())
|
|
|
|
|
2015-08-31 15:41:16 +03:00
|
|
|
#define gdk_cursor_new(cur) \
|
|
|
|
gdk_cursor_new_for_display(gdk_display_get_default(), cur)
|
|
|
|
|
2017-02-23 17:23:46 +03:00
|
|
|
#endif /* 3.0 */
|