summaryrefslogtreecommitdiffstats
path: root/src/gui_gtk_x11.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2010-06-25 05:37:59 +0200
committerBram Moolenaar <Bram@vim.org>2010-06-25 05:37:59 +0200
commit182c5be111889643294083c830080cfbaa3dd154 (patch)
tree4c393150480418e953031c93453cedc10738185f /src/gui_gtk_x11.c
parentba52cde53d8eeb0bd8949ab0acc47a56f87e7963 (diff)
Remove the old and not well supported GTK 1 code. (James Vega)
Diffstat (limited to 'src/gui_gtk_x11.c')
-rw-r--r--src/gui_gtk_x11.c1324
1 files changed, 18 insertions, 1306 deletions
diff --git a/src/gui_gtk_x11.c b/src/gui_gtk_x11.c
index 5cbe9a3c3a..23651bdb6f 100644
--- a/src/gui_gtk_x11.c
+++ b/src/gui_gtk_x11.c
@@ -45,10 +45,8 @@
# endif
# include <gnome.h>
# include "version.h"
-# ifdef HAVE_GTK2
/* missing prototype in bonobo-dock-item.h */
extern void bonobo_dock_item_set_behavior(BonoboDockItem *dock_item, BonoboDockItemBehavior beh);
-# endif
#endif
#if !defined(FEAT_GUI_GTK) && defined(PROTO)
@@ -124,10 +122,8 @@ static const GtkTargetEntry selection_targets[] =
{
{VIMENC_ATOM_NAME, 0, TARGET_VIMENC},
{VIM_ATOM_NAME, 0, TARGET_VIM},
-#ifdef FEAT_MBYTE
{"text/html", 0, TARGET_HTML},
{"UTF8_STRING", 0, TARGET_UTF8_STRING},
-#endif
{"COMPOUND_TEXT", 0, TARGET_COMPOUND_TEXT},
{"TEXT", 0, TARGET_TEXT},
{"STRING", 0, TARGET_STRING}
@@ -142,10 +138,8 @@ static const GtkTargetEntry selection_targets[] =
static const GtkTargetEntry dnd_targets[] =
{
{"text/uri-list", 0, TARGET_TEXT_URI_LIST},
-# ifdef FEAT_MBYTE
{"text/html", 0, TARGET_HTML},
{"UTF8_STRING", 0, TARGET_UTF8_STRING},
-# endif
{"STRING", 0, TARGET_STRING},
{"text/plain", 0, TARGET_TEXT_PLAIN}
};
@@ -153,22 +147,12 @@ static const GtkTargetEntry dnd_targets[] =
#endif
-#ifdef HAVE_GTK2
/*
* "Monospace" is a standard font alias that should be present
* on all proper Pango/fontconfig installations.
*/
# define DEFAULT_FONT "Monospace 10"
-#else /* !HAVE_GTK2 */
-/*
- * This is the single only fixed width font in X11, which seems to be present
- * on all servers and available in all the variants we need.
- */
-# define DEFAULT_FONT "-adobe-courier-medium-r-normal-*-14-*-*-*-m-*-*-*"
-
-#endif /* !HAVE_GTK2 */
-
#if !(defined(FEAT_GUI_GNOME) && defined(FEAT_SESSION))
/*
* Atoms used to communicate save-yourself from the X11 session manager. There
@@ -181,18 +165,10 @@ static GdkAtom save_yourself_atom = GDK_NONE;
/*
* Atoms used to control/reference X11 selections.
*/
-#ifdef FEAT_MBYTE
static GdkAtom html_atom = GDK_NONE;
static GdkAtom utf8_string_atom = GDK_NONE;
-#endif
-#ifndef HAVE_GTK2
-static GdkAtom compound_text_atom = GDK_NONE;
-static GdkAtom text_atom = GDK_NONE;
-#endif
static GdkAtom vim_atom = GDK_NONE; /* Vim's own special selection format */
-#ifdef FEAT_MBYTE
static GdkAtom vimenc_atom = GDK_NONE; /* Vim's extended selection format */
-#endif
/*
* Keycodes recognized by vim.
@@ -348,23 +324,13 @@ static const cmdline_option_T cmdline_options[] =
{"-fg", ARG_FOREGROUND|ARG_HAS_VALUE},
{"-foreground", ARG_FOREGROUND|ARG_HAS_VALUE},
{"-iconic", ARG_ICONIC},
-#ifdef HAVE_GTK2
{"--role", ARG_ROLE|ARG_HAS_VALUE},
-#endif
#ifdef FEAT_NETBEANS_INTG
{"-nb", ARG_NETBEANS}, /* non-standard value format */
{"-xrm", ARG_XRM|ARG_HAS_VALUE}, /* not implemented */
{"-mf", ARG_MENUFONT|ARG_HAS_VALUE}, /* not implemented */
{"-menufont", ARG_MENUFONT|ARG_HAS_VALUE}, /* not implemented */
#endif
-#if 0 /* not implemented; these arguments don't make sense for GTK+ */
- {"-boldfont", ARG_HAS_VALUE},
- {"-italicfont", ARG_HAS_VALUE},
- {"-bw", ARG_HAS_VALUE},
- {"-borderwidth", ARG_HAS_VALUE},
- {"-sw", ARG_HAS_VALUE},
- {"-scrollbarwidth", ARG_HAS_VALUE},
-#endif
/* Arguments handled by GTK (and GNOME) internally. */
{"--g-fatal-warnings", ARG_FOR_GTK},
{"--gdk-debug", ARG_FOR_GTK|ARG_HAS_VALUE},
@@ -376,17 +342,9 @@ static const cmdline_option_T cmdline_options[] =
{"--display", ARG_FOR_GTK|ARG_HAS_VALUE|ARG_COMPAT_LONG},
{"--name", ARG_FOR_GTK|ARG_HAS_VALUE|ARG_COMPAT_LONG},
{"--class", ARG_FOR_GTK|ARG_HAS_VALUE|ARG_COMPAT_LONG},
-#ifdef HAVE_GTK2
{"--screen", ARG_FOR_GTK|ARG_HAS_VALUE},
{"--gxid-host", ARG_FOR_GTK|ARG_HAS_VALUE},
{"--gxid-port", ARG_FOR_GTK|ARG_HAS_VALUE},
-#else /* these don't seem to exist anymore */
- {"--no-xshm", ARG_FOR_GTK},
- {"--xim-preedit", ARG_FOR_GTK|ARG_HAS_VALUE},
- {"--xim-status", ARG_FOR_GTK|ARG_HAS_VALUE},
- {"--gxid_host", ARG_FOR_GTK|ARG_HAS_VALUE},
- {"--gxid_port", ARG_FOR_GTK|ARG_HAS_VALUE},
-#endif
#ifdef FEAT_GUI_GNOME
{"--load-modules", ARG_FOR_GTK|ARG_HAS_VALUE},
{"--sm-client-id", ARG_FOR_GTK|ARG_HAS_VALUE},
@@ -412,9 +370,7 @@ static const cmdline_option_T cmdline_options[] =
static int gui_argc = 0;
static char **gui_argv = NULL;
-#ifdef HAVE_GTK2
static const char *role_argument = NULL;
-#endif
#if defined(FEAT_GUI_GNOME) && defined(FEAT_SESSION)
static const char *restart_command = NULL;
static char *abs_restart_command = NULL;
@@ -561,11 +517,9 @@ gui_mch_prepare(int *argc, char **argv)
case ARG_ICONIC:
found_iconic_arg = TRUE;
break;
-#ifdef HAVE_GTK2
case ARG_ROLE:
role_argument = value; /* used later in gui_mch_open() */
break;
-#endif
#ifdef FEAT_NETBEANS_INTG
case ARG_NETBEANS:
gui.dofork = FALSE; /* don't fork() when starting GUI */
@@ -859,7 +813,6 @@ focus_out_event(GtkWidget *widget UNUSED,
}
-#ifdef HAVE_GTK2
/*
* Translate a GDK key value to UTF-8 independently of the current locale.
* The output is written to string, which must have room for at least 6 bytes
@@ -935,7 +888,6 @@ keyval_to_string(unsigned int keyval, unsigned int state, char_u *string)
return len;
}
-#endif /* HAVE_GTK2 */
static int
modifiers_gdk2vim(guint state)
@@ -981,14 +933,9 @@ key_press_event(GtkWidget *widget UNUSED,
GdkEventKey *event,
gpointer data UNUSED)
{
-#ifdef HAVE_GTK2
- /* 256 bytes is way over the top, but for safety let's reduce it only
- * for GTK+ 2 where we know for sure how large the string might get.
+ /* For GTK+ 2 we know for sure how large the string might get.
* (That is, up to 6 bytes + NUL + CSI escapes + safety measure.) */
char_u string[32], string2[32];
-#else
- char_u string[256], string2[256];
-#endif
guint key_sym;
int len;
int i;
@@ -1000,25 +947,6 @@ key_press_event(GtkWidget *widget UNUSED,
clipboard_event_time = event->time;
key_sym = event->keyval;
state = event->state;
-#ifndef HAVE_GTK2 /* deprecated */
- len = event->length;
- g_assert(len <= sizeof(string));
-#endif
-
-#ifndef HAVE_GTK2
- /*
- * It appears as if we always want to consume a key-press (there currently
- * aren't any 'return FALSE's), so we always do this: when running in a
- * GtkPlug and not a window, we must prevent emission of the key_press
- * EVENT from continuing (which is 'beyond' the level of stopping mere
- * signals by returning FALSE), otherwise things like tab/cursor-keys are
- * processed by the GtkPlug default handler, which moves input focus away
- * from us!
- * Note: This should no longer be necessary with GTK+ 2.
- */
- if (gtk_socket_id != 0)
- gtk_signal_emit_stop_by_name(GTK_OBJECT(widget), "key_press_event");
-#endif
#ifdef FEAT_XIM
if (xim_queue_key_press_event(event, TRUE))
@@ -1044,7 +972,6 @@ key_press_event(GtkWidget *widget UNUSED,
else
#endif
{
-#ifdef HAVE_GTK2
len = keyval_to_string(key_sym, state, string2);
/* Careful: convert_input() doesn't handle the NUL character.
@@ -1053,19 +980,6 @@ key_press_event(GtkWidget *widget UNUSED,
len = convert_input(string2, len, sizeof(string2));
s = string2;
-#else
-# ifdef FEAT_MBYTE
- if (input_conv.vc_type != CONV_NONE)
- {
- mch_memmove(string2, event->string, len);
- len = convert_input(string2, len, sizeof(string2));
- s = string2;
- }
- else
-# endif
- s = (char_u *)event->string;
-#endif
-
d = string;
for (i = 0; i < len; ++i)
{
@@ -1087,21 +1001,6 @@ key_press_event(GtkWidget *widget UNUSED,
state |= GDK_SHIFT_MASK;
}
-#ifndef HAVE_GTK2 /* for GTK+ 2, we handle this in keyval_to_string() */
- if ((key_sym == GDK_2 || key_sym == GDK_at) && (state & GDK_CONTROL_MASK))
- {
- string[0] = NUL; /* CTRL-2 and CTRL-@ is NUL */
- len = 1;
- }
- else if (len == 0 && (key_sym == GDK_space || key_sym == GDK_Tab))
- {
- /* When there are modifiers, these keys get zero length; we need the
- * original key here to be able to add a modifier below. */
- string[0] = (key_sym & 0xff);
- len = 1;
- }
-#endif
-
#ifdef FEAT_MENU
/* If there is a menu and 'wak' is "yes", or 'wak' is "menu" and the key
* is a menu shortcut, we ignore everything with the ALT modifier. */
@@ -1111,13 +1010,9 @@ key_press_event(GtkWidget *widget UNUSED,
|| (*p_wak == 'm'
&& len == 1
&& gui_is_menu_shortcut(string[0]))))
-# ifdef HAVE_GTK2
/* For GTK2 we return false to signify that we haven't handled the
* keypress, so that gtk will handle the mnemonic or accelerator. */
return FALSE;
-# else
- return TRUE;
-# endif
#endif
/* Check for Alt/Meta key (Mod1Mask), but not for a BS, DEL or character
@@ -1134,14 +1029,11 @@ key_press_event(GtkWidget *widget UNUSED,
&& !(key_sym == GDK_BackSpace || key_sym == GDK_Delete)
&& (string[0] & 0x80) == 0
&& !(key_sym == GDK_Tab && (state & GDK_SHIFT_MASK))
-#ifdef FEAT_MBYTE
&& !enc_dbcs
-#endif
)
{
string[0] |= 0x80;
state &= ~GDK_MOD1_MASK; /* don't use it again */
-#ifdef FEAT_MBYTE
if (enc_utf8) /* convert to utf-8 */
{
string[1] = string[0] & 0xbf;
@@ -1155,7 +1047,6 @@ key_press_event(GtkWidget *widget UNUSED,
else
len = 2;
}
-#endif
}
/* Check for special keys. Also do this when len == 1 (key has an ASCII
@@ -1178,26 +1069,17 @@ key_press_event(GtkWidget *widget UNUSED,
if (len == 0) /* Unrecognized key */
return TRUE;
-#if defined(FEAT_XIM) && defined(FEAT_GUI_GTK) && !defined(HAVE_GTK2)
- /* Cancel or type backspace. For GTK2, im_commit_cb() does the same. */
- preedit_start_col = MAXCOL;
- xim_changed_while_preediting = TRUE;
-#endif
-
/* Special keys (and a few others) may have modifiers. Also when using a
* double-byte encoding (can't set the 8th bit). */
if (len == -3 || key_sym == GDK_space || key_sym == GDK_Tab
|| key_sym == GDK_Return || key_sym == GDK_Linefeed
|| key_sym == GDK_Escape || key_sym == GDK_KP_Tab
|| key_sym == GDK_ISO_Enter || key_sym == GDK_3270_Enter
-#ifdef FEAT_MBYTE
|| (enc_dbcs && len == 1 && ((state & GDK_MOD1_MASK)
-# ifdef GDK_SUPER_MASK
+#ifdef GDK_SUPER_MASK
|| (state & GDK_SUPER_MASK)
-# endif
- ))
#endif
- )
+ )))
{
modifiers = modifiers_gdk2vim(state);
@@ -1254,7 +1136,7 @@ key_press_event(GtkWidget *widget UNUSED,
return TRUE;
}
-#if defined(FEAT_XIM) && defined(HAVE_GTK2)
+#if defined(FEAT_XIM)
static gboolean
key_release_event(GtkWidget *widget UNUSED,
GdkEventKey *event,
@@ -1305,9 +1187,7 @@ selection_received_cb(GtkWidget *widget UNUSED,
VimClipboard *cbd;
char_u *text;
char_u *tmpbuf = NULL;
-#ifdef HAVE_GTK2
guchar *tmpbuf_utf8 = NULL;
-#endif
int len;
int motion_type;
@@ -1337,7 +1217,6 @@ selection_received_cb(GtkWidget *widget UNUSED,
--len;
}
-#ifdef FEAT_MBYTE
else if (data->type == vimenc_atom)
{
char_u *enc;
@@ -1362,9 +1241,7 @@ selection_received_cb(GtkWidget *widget UNUSED,
convert_setup(&conv, NULL, NULL);
}
}
-#endif
-#ifdef HAVE_GTK2
/* gtk_selection_data_get_text() handles all the nasty details
* and targets and encodings etc. This rocks so hard. */
else
@@ -1401,51 +1278,6 @@ selection_received_cb(GtkWidget *widget UNUSED,
text = tmpbuf;
}
}
-#else /* !HAVE_GTK2 */
-# ifdef FEAT_MBYTE
- else if (data->type == utf8_string_atom)
- {
- vimconv_T conv;
-
- conv.vc_type = CONV_NONE;
- convert_setup(&conv, (char_u *)"utf-8", p_enc);
-
- if (conv.vc_type != CONV_NONE)
- {
- tmpbuf = string_convert(&conv, text, &len);
- convert_setup(&conv, NULL, NULL);
- }
- if (tmpbuf != NULL)
- text = tmpbuf;
- }
-# endif
- else if (data->type == compound_text_atom || data->type == text_atom)
- {
- char **list = NULL;
- int count;
- int i;
- unsigned tmplen = 0;
-
- count = gdk_text_property_to_text_list(data->type, data->format,
- data->data, data->length,
- &list);
- for (i = 0; i < count; ++i)
- tmplen += strlen(list[i]);
-
- tmpbuf = alloc(tmplen + 1);
- if (tmpbuf != NULL)
- {
- tmpbuf[0] = NUL;
- for (i = 0; i < count; ++i)
- STRCAT(tmpbuf, list[i]);
- text = tmpbuf;
- len = tmplen;
- }
-
- if (list != NULL)
- gdk_free_text_list(list);
- }
-#endif /* !HAVE_GTK2 */
/* Chop off any traiing NUL bytes. OpenOffice sends these. */
while (len > 0 && text[len - 1] == NUL)
@@ -1454,9 +1286,7 @@ selection_received_cb(GtkWidget *widget UNUSED,
clip_yank_selection(motion_type, text, (long)len, cbd);
received_selection = RS_OK;
vim_free(tmpbuf);
-#ifdef HAVE_GTK2
g_free(tmpbuf_utf8);
-#endif
if (gtk_main_level() > 0)
gtk_main_quit();
@@ -1490,11 +1320,9 @@ selection_get_cb(GtkWidget *widget UNUSED,
return; /* Shouldn't ever happen */
if (info != (guint)TARGET_STRING
-#ifdef FEAT_MBYTE
&& (!clip_html || info != (guint)TARGET_HTML)
&& info != (guint)TARGET_UTF8_STRING
&& info != (guint)TARGET_VIMENC
-#endif
&& info != (guint)TARGET_VIM
&& info != (guint)TARGET_COMPOUND_TEXT
&& info != (guint)TARGET_TEXT)
@@ -1526,7 +1354,6 @@ selection_get_cb(GtkWidget *widget UNUSED,
type = vim_atom;
}
-#ifdef FEAT_MBYTE
else if (info == (guint)TARGET_HTML)
{
vimconv_T conv;
@@ -1578,9 +1405,7 @@ selection_get_cb(GtkWidget *widget UNUSED,
string = tmpbuf;
type = vimenc_atom;
}
-#endif
-#ifdef HAVE_GTK2
/* gtk_selection_data_set_text() handles everything for us. This is
* so easy and simple and cool, it'd be insane not to use it. */
else
@@ -1602,50 +1427,6 @@ selection_get_cb(GtkWidget *widget UNUSED,
vim_free(string);
return;
}
-#else /* !HAVE_GTK2 */
-# ifdef FEAT_MBYTE
- else if (info == (guint)TARGET_UTF8_STRING)
- {
- vimconv_T conv;
-
- conv.vc_type = CONV_NONE;
- convert_setup(&conv, p_enc, (char_u *)"utf-8");
-
- if (conv.vc_type != CONV_NONE)
- {
- tmpbuf = string_convert(&conv, string, &length);
- convert_setup(&conv, NULL, NULL);
- vim_free(string);
- string = tmpbuf;
- }
- type = utf8_string_atom;
- }
-# endif
- else if (info == (guint)TARGET_COMPOUND_TEXT
- || info == (guint)TARGET_TEXT)
- {
- int format;
-
- /* Copy the string to ensure NUL-termination */
- tmpbuf = vim_strnsave(string, length);
- vim_free(string);
- if (tmpbuf != NULL)
- {
- gdk_string_to_compound_text((const char *)tmpbuf,
- &type, &format, &string, &length);
- vim_free(tmpbuf);
- selection_data->type = type;
- selection_data->format = format;
- gtk_selection_data_set(selection_data, type, format, string, length);
- gdk_free_compound_text(string);
- }
- return;
- }
- else
- {
- type = GDK_TARGET_STRING;
- }
-#endif /* !HAVE_GTK2 */
if (string != NULL)
{
@@ -1664,12 +1445,6 @@ selection_get_cb(GtkWidget *widget UNUSED,
int
gui_mch_init_check(void)
{
-#ifndef HAVE_GTK2
- /* This is needed to make the locale handling consistent between the GUI
- * and the rest of VIM. */
- gtk_set_locale();
-#endif
-
#ifdef FEAT_GUI_GNOME
if (gtk_socket_id == 0)
using_gnome = 1;
@@ -1912,14 +1687,6 @@ button_press_event(GtkWidget *widget,
case 3:
button = MOUSE_RIGHT;
break;
-#ifndef HAVE_GTK2
- case 4:
- button = MOUSE_4;
- break;
- case 5:
- button = MOUSE_5;
- break;
-#endif
default:
return FALSE; /* Unknown button */
}
@@ -1939,10 +1706,8 @@ button_press_event(GtkWidget *widget,
return TRUE;
}
-#ifdef HAVE_GTK2
/*
- * GTK+ 2 doesn't handle mouse buttons 4, 5, 6 and 7 the same way as GTK+ 1.
- * Instead, it abstracts scrolling via the new GdkEventScroll.
+ * GTK+ 2 abstracts scrolling via the GdkEventScroll.
*/
static gboolean
scroll_event(GtkWidget *widget,
@@ -1983,7 +1748,6 @@ scroll_event(GtkWidget *widget,
return TRUE;
}
-#endif /* HAVE_GTK2 */
static gint
@@ -2143,41 +1907,22 @@ drag_handle_text(GdkDragContext *context,
char_u dropkey[6] = {CSI, KS_MODIFIER, 0, CSI, KS_EXTRA, (char_u)KE_DROP};
char_u *text;
int len;
-# ifdef FEAT_MBYTE
char_u *tmpbuf = NULL;
-# endif
text = data->data;
len = data->length;
-# ifdef FEAT_MBYTE
if (data->type == utf8_string_atom)
{
-# ifdef HAVE_GTK2
if (input_conv.vc_type != CONV_NONE)
tmpbuf = string_convert(&input_conv, text, &len);
-# else
- vimconv_T conv;
-
- conv.vc_type = CONV_NONE;
- convert_setup(&conv, (char_u *)"utf-8", p_enc);
-
- if (conv.vc_type != CONV_NONE)
- {
- tmpbuf = string_convert(&conv, text, &len);
- convert_setup(&conv, NULL, NULL);
- }
-# endif
if (tmpbuf != NULL)
text = tmpbuf;
}
-# endif /* FEAT_MBYTE */
dnd_yank_drag_data(text, (long)len);
gtk_drag_finish(context, TRUE, FALSE, time_); /* accept */
-# ifdef FEAT_MBYTE
vim_free(tmpbuf);
-# endif
dropkey[2] = modifiers_gdk2vim(state);
@@ -2407,10 +2152,8 @@ sm_client_save_yourself(GnomeClient *client,
argv[i++] = restart_command;
argv[i++] = "-f";
argv[i++] = "-g";
-# ifdef HAVE_GTK2
argv[i++] = "--role";
argv[i++] = gtk_window_get_role(GTK_WINDOW(gui.mainwin));
-# endif
argv[i++] = "-S";
argv[i++] = session_file;
argv[i] = NULL;
@@ -2551,13 +2294,11 @@ setup_save_yourself(void)
}
}
-# ifdef HAVE_GTK2
/*
* Installing a global event filter seems to be the only way to catch
* client messages of type WM_PROTOCOLS without overriding GDK's own
* client message event filter. Well, that's still better than trying
* to guess what the GDK filter had done if it had been invoked instead
- * (This is what we did for GTK+ 1.2, see below).
*
* GTK2_FIXME: This doesn't seem to work. For some reason we never
* receive WM_SAVE_YOURSELF even though everything is set up correctly.
@@ -2596,51 +2337,6 @@ global_event_filter(GdkXEvent *xev,
return GDK_FILTER_CONTINUE;
}
-
-# else /* !HAVE_GTK2 */
-
-/*
- * GDK handler for X ClientMessage events.
- */
- static GdkFilterReturn
-gdk_wm_protocols_filter(GdkXEvent *xev, GdkEvent *event, gpointer data)
-{
- /* From example in gdkevents.c/gdk_wm_protocols_filter */
- XEvent *xevent = (XEvent *)xev;
-
- if (xevent != NULL)
- {
- if (xevent->xclient.data.l[0] == GET_X_ATOM(save_yourself_atom))
- {
- out_flush();
- ml_sync_all(FALSE, FALSE); /* preserve all swap files */
-
- /* Set the window's WM_COMMAND property, to let the window manager
- * know we are done saving ourselves. We don't want to be
- * restarted, thus set argv to NULL. */
- XSetCommand(GDK_WINDOW_XDISPLAY(gui.mainwin->window),
- GDK_WINDOW_XWINDOW(gui.mainwin->window),
- NULL, 0);
- }
- /*
- * Functionality from gdkevents.c/gdk_wm_protocols_filter;
- * Registering this filter apparently overrides the default GDK one,
- * so we need to perform its functionality. There seems no way to
- * register for WM_PROTOCOLS, and only process the WM_SAVE_YOURSELF
- * bit; it's all or nothing. Update: No, there is a way -- but it
- * only works with GTK+ 2 apparently. See above.
- */
- else if (xevent->xclient.data.l[0] == GET_X_ATOM(gdk_wm_delete_window))
- {
- event->any.type = GDK_DELETE;
- return GDK_FILTER_TRANSLATE;
- }
- }
-
- return GDK_FILTER_REMOVE;
-}
-# endif /* !HAVE_GTK2 */
-
#endif /* !(FEAT_GUI_GNOME && FEAT_SESSION) */
@@ -2655,10 +2351,8 @@ mainwin_realize(GtkWidget *widget UNUSED, gpointer data UNUSED)
#ifdef magick
# undef magick
#endif
-#ifdef HAVE_GTK2
/* A bit hackish, but avoids casting later and allows optimization */
# define static static const
-#endif
#define magick vim32x32
#include "../runtime/vim32x32.xpm"
#undef magick
@@ -2668,9 +2362,7 @@ mainwin_realize(GtkWidget *widget UNUSED, gpointer data UNUSED)
#define magick vim48x48
#include "../runtime/vim48x48.xpm"
#undef magick
-#ifdef HAVE_GTK2
# undef static
-#endif
/* When started with "--echo-wid" argument, write window ID on stdout. */
if (echo_wid_arg)
@@ -2684,7 +2376,6 @@ mainwin_realize(GtkWidget *widget UNUSED, gpointer data UNUSED)
/*
* Add an icon to the main window. For fun and convenience of the user.
*/
-#ifdef HAVE_GTK2
GList *icons = NULL;
icons = g_list_prepend(icons, gdk_pixbuf_new_from_xpm_data(vim16x16));
@@ -2695,53 +2386,11 @@ mainwin_realize(GtkWidget *widget UNUSED, gpointer data UNUSED)
g_list_foreach(icons, (GFunc)&g_object_unref, NULL);
g_list_free(icons);
-
-#else /* !HAVE_GTK2 */
-
- GdkPixmap *icon;
- GdkBitmap *icon_mask = NULL;
- char **magick = vim32x32;
- Display *xdisplay;
- Window root_window;
- XIconSize *size;
- int number_sizes;
- /*
- * Adjust the icon to the preferences of the actual window manager.
- * This is once again a workaround for a deficiency in GTK+ 1.2.
- */
- xdisplay = GDK_WINDOW_XDISPLAY(gui.mainwin->window);
- root_window = XRootWindow(xdisplay, DefaultScreen(xdisplay));
- if (XGetIconSizes(xdisplay, root_window, &size, &number_sizes))
- {
- if (number_sizes > 0)
- {
- if (size->max_height >= 48 && size->max_height >= 48)
- magick = vim48x48;
- else if (size->max_height >= 32 && size->max_height >= 32)
- magick = vim32x32;
- else if (size->max_height >= 16 && size->max_height >= 16)
- magick = vim16x16;
- }
- XFree(size);
- }
- icon = gdk_pixmap_create_from_xpm_d(gui.mainwin->window,
- &icon_mask, NULL, magick);
- if (icon != NULL)
- /* Note: for some reason gdk_window_set_icon() doesn't acquire
- * a reference on the pixmap, thus we _have_ to leak it. */
- gdk_window_set_icon(gui.mainwin->window, NULL, icon, icon_mask);
-
-#endif /* !HAVE_GTK2 */
}
#if !(defined(FEAT_GUI_GNOME) && defined(FEAT_SESSION))
/* Register a handler for WM_SAVE_YOURSELF with GDK's low-level X I/F */
-# ifdef HAVE_GTK2
gdk_window_add_filter(NULL, &global_event_filter, NULL);
-# else
- gdk_add_client_message_filter(wm_protocols_atom,
- &gdk_wm_protocols_filter, NULL);
-# endif
#endif
/* Setup to indicate to the window manager that we want to catch the
* WM_SAVE_YOURSELF event. For GNOME, this connects to the session
@@ -2884,7 +2533,6 @@ drawarea_unrealize_cb(GtkWidget *widget UNUSED, gpointer data UNUSED)
#ifdef FEAT_XIM
im_shutdown();
#endif
-#ifdef HAVE_GTK2
if (gui.ascii_glyphs != NULL)
{
pango_glyph_string_free(gui.ascii_glyphs);
@@ -2903,13 +2551,6 @@ drawarea_unrealize_cb(GtkWidget *widget UNUSED, gpointer data UNUSED)
gdk_cursor_unref(gui.blank_pointer);
gui.blank_pointer = NULL;
-#else
- gdk_gc_unref(gui.text_gc);
- gui.text_gc = NULL;
-
- gdk_cursor_destroy(gui.blank_pointer);
- gui.blank_pointer = NULL;
-#endif
}
static void
@@ -2942,7 +2583,6 @@ get_item_dimensions(GtkWidget *widget, GtkOrientation orientation)
#ifdef FEAT_GUI_GNOME
if (using_gnome && widget != NULL)
{
-# ifdef HAVE_GTK2
GtkWidget *parent;
BonoboDockItem *dockitem;
@@ -2958,16 +2598,6 @@ get_item_dimensions(GtkWidget *widget, GtkOrientation orientation)
return 0;
item_orientation = bonobo_dock_item_get_orientation(dockitem);
}
-# else
- GnomeDockItem *dockitem;
-
- widget = widget->parent;
- dockitem = GNOME_DOCK_ITEM(widget);
-
- if (dockitem == NULL || dockitem->is_floating)
- return 0;
- item_orientation = gnome_dock_item_get_orientation(dockitem);
-# endif
}
#endif
if (widget != NULL
@@ -3065,10 +2695,8 @@ update_window_manager_hints(int force_width, int force_height)
# ifdef FEAT_MENU
height += tabline_height() * gui.char_height;
# endif
-# ifdef HAVE_GTK2
width += get_menu_tool_width();
height += get_menu_tool_height();
-# endif
/* GtkSockets use GtkPlug's [gui,mainwin] min-size hints to determine
* their actual widget size. When we set our size ourselves (e.g.,
@@ -3106,16 +2734,11 @@ update_window_manager_hints(int force_width, int force_height)
geometry.min_height = min_height;
geometry_mask = GDK_HINT_BASE_SIZE|GDK_HINT_RESIZE_INC
|GDK_HINT_MIN_SIZE;
-# ifdef HAVE_GTK2
/* Using gui.formwin as geometry widget doesn't work as expected
* with GTK+ 2 -- dunno why. Presumably all the resizing hacks
* in Vim confuse GTK+. */
gtk_window_set_geometry_hints(GTK_WINDOW(gui.mainwin), gui.mainwin,
&geometry, geometry_mask);
-# else
- gtk_window_set_geometry_hints(GTK_WINDOW(gui.mainwin), gui.formwin,
- &geometry, geometry_mask);
-# endif
old_width = width;
old_height = height;
old_min_width = min_width;
@@ -3127,7 +2750,6 @@ update_window_manager_hints(int force_width, int force_height)
#ifdef FEAT_TOOLBAR
-# ifdef HAVE_GTK2
/*
* This extra effort wouldn't be necessary if we only used stock icons in the
* toolbar, as we do for all builtin icons. But user-defined toolbar icons
@@ -3161,24 +2783,18 @@ icon_size_changed_foreach(GtkWidget *widget, gpointer user_data)
user_data);
}
}
-# endif /* HAVE_GTK2 */
static void
set_toolbar_style(GtkToolbar *toolbar)
{
GtkToolbarStyle style;
-# ifdef HAVE_GTK2
GtkIconSize size;
GtkIconSize oldsize;
-# endif
-# ifdef HAVE_GTK2
if ((toolbar_flags & (TOOLBAR_TEXT | TOOLBAR_ICONS | TOOLBAR_HORIZ))
== (TOOLBAR_TEXT | TOOLBAR_ICONS | TOOLBAR_HORIZ))
style = GTK_TOOLBAR_BOTH_HORIZ;
- else
-# endif
- if ((toolbar_flags & (TOOLBAR_TEXT | TOOLBAR_ICONS))
+ else if ((toolbar_flags & (TOOLBAR_TEXT | TOOLBAR_ICONS))
== (TOOLBAR_TEXT | TOOLBAR_ICONS))
style = GTK_TOOLBAR_BOTH;
else if (toolbar_flags & TOOLBAR_TEXT)
@@ -3189,7 +2805,6 @@ set_toolbar_style(GtkToolbar *toolbar)
gtk_toolbar_set_style(toolbar, style);
gtk_toolbar_set_tooltips(toolbar, (toolbar_flags & TOOLBAR_TOOLTIPS) != 0);
-# ifdef HAVE_GTK2
switch (tbis_flags)
{
case TBIS_TINY: size = GTK_ICON_SIZE_MENU; break;
@@ -3213,7 +2828,6 @@ set_toolbar_style(GtkToolbar *toolbar)
GINT_TO_POINTER((int)size));
}
gtk_toolbar_set_icon_size(toolbar, size);
-# endif
}
#endif /* FEAT_TOOLBAR */
@@ -3313,11 +2927,6 @@ on_tabline_menu(GtkWidget *widget, GdkEvent *event)
if (send_tabline_event(x < 50 ? -1 : 0) && gtk_main_level() > 0)
gtk_main_quit();
}
-#ifndef HAVE_GTK2
- else
- gtk_notebook_set_page(GTK_NOTEBOOK(gui.tabline),
- clicked_page - 1);
-#endif
}
}
@@ -3342,10 +2951,6 @@ on_select_tab(
}
}
-#ifndef HAVE_GTK2
-static int showing_tabline = 0;
-#endif
-
/*
* Show or hide the tabline.
*/
@@ -3355,19 +2960,11 @@ gui_mch_show_tabline(int showit)
if (gui.tabline == NULL)
return;
-#ifdef HAVE_GTK2
- /* gtk_notebook_get_show_tabs does not exist in gtk+-1.2.10 */
if (!showit != !gtk_notebook_get_show_tabs(GTK_NOTEBOOK(gui.tabline)))
-#else
- if (!showit != !showing_tabline)
-#endif
{
/* Note: this may cause a resize event */
gtk_notebook_set_show_tabs(GTK_NOTEBOOK(gui.tabline), showit);
update_window_manager_hints(0, 0);
-#ifndef HAVE_GTK2
- showing_tabline = showit;
-#endif
if (showit)
GTK_WIDGET_UNSET_FLAGS(GTK_WIDGET(gui.tabline), GTK_CAN_FOCUS);
}
@@ -3382,13 +2979,7 @@ gui_mch_show_tabline(int showit)
gui_mch_showing_tabline(void)
{
return gui.tabline != NULL
-#ifdef HAVE_GTK2
- /* gtk_notebook_get_show_tabs does not exist in gtk+-1.2.10 */
- && gtk_notebook_get_show_tabs(GTK_NOTEBOOK(gui.tabline))
-#else
- && showing_tabline
-#endif
- ;
+ && gtk_notebook_get_show_tabs(GTK_NOTEBOOK(gui.tabline));
}
/*
@@ -3496,14 +3087,12 @@ gui_gtk_set_selection_targets(void)
for (i = 0; i < (int)N_SELECTION_TARGETS; ++i)
{
-#ifdef FEAT_MBYTE
/* OpenOffice tries to use TARGET_HTML and fails when it doesn't
* return something, instead of trying another target. Therefore only
* offer TARGET_HTML when it works. */
if (!clip_html && selection_targets[i].info == TARGET_HTML)
n_targets--;
else
-#endif
targets[j++] = selection_targets[i];
}
@@ -3529,11 +3118,9 @@ gui_gtk_set_dnd_targets(void)
for (i = 0; i < (int)N_DND_TARGETS; ++i)
{
-#ifdef FEAT_MBYTE
if (!clip_html && selection_targets[i].info == TARGET_HTML)
n_targets--;
else
-#endif
targets[j++] = dnd_targets[i];
}
@@ -3558,21 +3145,16 @@ gui_mch_init(void)
* exits on failure, but that's a non-issue because we already called
* gtk_init_check() in gui_mch_init_check(). */
if (using_gnome)
-# ifdef HAVE_GTK2
gnome_program_init(VIMPACKAGE, VIM_VERSION_SHORT,
LIBGNOMEUI_MODULE, gui_argc, gui_argv, NULL);
-# else
- gnome_init(VIMPACKAGE, VIM_VERSION_SHORT, gui_argc, gui_argv);
-# endif
#endif
vim_free(gui_argv);
gui_argv = NULL;
-#ifdef HAVE_GTK2
-# if GLIB_CHECK_VERSION(2,1,3)
+#if GLIB_CHECK_VERSION(2,1,3)
/* Set the human-readable application name */
g_set_application_name("Vim");
-# endif
+#endif
/*
* Force UTF-8 output no matter what the value of 'encoding' is.
* did_set_string_option() in option.c prohibits changing 'termencoding'
@@ -3580,14 +3162,13 @@ gui_mch_init(void)
*/
set_option_value((char_u *)"termencoding", 0L, (char_u *)"utf-8", 0);
-# ifdef FEAT_TOOLBAR
+#ifdef FEAT_TOOLBAR
gui_gtk_register_stock_icons();
-# endif
+#endif
/* FIXME: Need to install the classic icons and a gtkrc.classic file.
* The hard part is deciding install locations and the Makefile magic. */
-# if 0
+#if 0
gtk_rc_parse("gtkrc");
-# endif
#endif
/* Initialize values */
@@ -3602,14 +3183,8 @@ gui_mch_init(void)
gui.spcolor = g_new0(GdkColor, 1);
/* Initialise atoms */
-#ifdef FEAT_MBYTE
html_atom = gdk_atom_intern("text/html", FALSE);
utf8_string_atom = gdk_atom_intern("UTF8_STRING", FALSE);
-#endif
-#ifndef HAVE_GTK2
- compound_text_atom = gdk_atom_intern("COMPOUND_TEXT", FALSE);
- text_atom = gdk_atom_intern("TEXT", FALSE);
-#endif
/* Set default foreground and background colors. */
gui.norm_pixel = gui.def_norm_pixel;
@@ -3657,15 +3232,10 @@ gui_mch_init(void)
gtk_widget_set_name(gui.mainwin, "vim-main-window");
-#ifdef HAVE_GTK2
/* Create the PangoContext used for drawing all text. */
gui.text_context = gtk_widget_create_pango_context(gui.mainwin);
pango_context_set_base_dir(gui.text_context, PANGO_DIRECTION_LTR);
-#endif
-#ifndef HAVE_GTK2
- gtk_window_set_policy(GTK_WINDOW(gui.mainwin), TRUE, TRUE, TRUE);
-#endif
gtk_container_border_width(GTK_CONTAINER(gui.mainwin), 0);
gtk_widget_add_events(gui.mainwin, GDK_VISIBILITY_NOTIFY_MASK);
@@ -3678,12 +3248,8 @@ gui_mch_init(void)
g_signal_connect(G_OBJECT(gui.mainwin), "screen_changed",
G_CALLBACK(&mainwin_screen_changed_cb), NULL);
#endif
-#ifdef HAVE_GTK2
gui.accel_group = gtk_accel_group_new();
gtk_window_add_accel_group(GTK_WINDOW(gui.mainwin), gui.accel_group);
-#else
- gui.accel_group = gtk_accel_group_get_default();
-#endif
/* A vertical box holds the menubar, toolbar and main text window. */
vbox = gtk_vbox_new(FALSE, 0);
@@ -3691,7 +3257,7 @@ gui_mch_init(void)
#ifdef FEAT_GUI_GNOME
if (using_gnome)
{
-# if defined(HAVE_GTK2) && defined(FEAT_MENU)
+# if defined(FEAT_MENU)
/* automagically restore menubar/toolbar placement */
gnome_app_enable_layout_config(GNOME_APP(gui.mainwin), TRUE);
# endif
@@ -3711,7 +3277,6 @@ gui_mch_init(void)
gui.menubar = gtk_menu_bar_new();
gtk_widget_set_name(gui.menubar, "vim-menubar");
-# ifdef HAVE_GTK2
/* Avoid that GTK takes <F10> away from us. */
{
GtkSettings *gtk_settings;
@@ -3719,13 +3284,11 @@ gui_mch_init(void)
gtk_settings = gtk_settings_get_for_screen(gdk_screen_get_default());
g_object_set(gtk_settings, "gtk-menu-bar-accel", NULL, NULL);
}
-# endif
# ifdef FEAT_GUI_GNOME
if (using_gnome)
{
-# ifdef HAVE_GTK2
BonoboDockItem *dockitem;
gnome_app_set_menus(GNOME_APP(gui.mainwin), GTK_MENU_BAR(gui.menubar));
@@ -3736,21 +3299,6 @@ gui_mch_init(void)
bonobo_dock_item_get_behavior(dockitem)
| BONOBO_DOCK_ITEM_BEH_NEVER_FLOATING);
gui.menubar_h = GTK_WIDGET(dockitem);
-# else
- gui.menubar_h = gnome_dock_item_new("VimMainMenu",
- GNOME_DOCK_ITEM_BEH_EXCLUSIVE |
- GNOME_DOCK_ITEM_BEH_NEVER_VERTICAL);
- gtk_container_add(GTK_CONTAINER(gui.menubar_h), gui.menubar);
-
- gnome_dock_add_item(GNOME_DOCK(GNOME_APP(gui.mainwin)->dock),
- GNOME_DOCK_ITEM(gui.menubar_h),
- GNOME_DOCK_TOP, /* placement */
- 1, /* band_num */
- 0, /* band_position */
- 0, /* offset */
- TRUE);
- gtk_widget_show(gui.menubar);
-# endif
}
else
# endif /* FEAT_GUI_GNOME */
@@ -3766,7 +3314,6 @@ gui_mch_init(void)
/*
* Create the toolbar and handle
*/
-# ifdef HAVE_GTK2
/* some aesthetics on the toolbar */
gtk_rc_parse_string(
"style \"vim-toolbar-style\" {\n"
@@ -3775,17 +3322,11 @@ gui_mch_init(void)
"widget \"*.vim-toolbar\" style \"vim-toolbar-style\"\n");
gui.toolbar = gtk_toolbar_new();
gtk_widget_set_name(gui.toolbar, "vim-toolbar");
-# else
- gui.toolbar = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL,
- GTK_TOOLBAR_ICONS);
- gtk_toolbar_set_button_relief(GTK_TOOLBAR(gui.toolbar), GTK_RELIEF_NONE);
-# endif
set_toolbar_style(GTK_TOOLBAR(gui.toolbar));
# ifdef FEAT_GUI_GNOME
if (using_gnome)</