diff options
author | nyamatongwe <unknown> | 2010-03-25 23:49:46 +0000 |
---|---|---|
committer | nyamatongwe <unknown> | 2010-03-25 23:49:46 +0000 |
commit | c42b517cbf2c7e85b3f0528fc130a349f391f888 (patch) | |
tree | d58a5d12d6dc2fe37ffec914c98f65cec2792d7b | |
parent | 295013083c4e9454656c0e94ab977057ee55ea11 (diff) | |
download | scintilla-mirror-c42b517cbf2c7e85b3f0528fc130a349f391f888.tar.gz |
Removed support for GTK+ 1.x.
-rw-r--r-- | README | 21 | ||||
-rw-r--r-- | gtk/Converter.h | 19 | ||||
-rw-r--r-- | gtk/PlatGTK.cxx | 287 | ||||
-rw-r--r-- | gtk/ScintillaGTK.cxx | 522 | ||||
-rw-r--r-- | gtk/makefile | 26 | ||||
-rw-r--r-- | gtk/scintilla.mak | 14 | ||||
-rw-r--r-- | include/ScintillaWidget.h | 8 |
7 files changed, 40 insertions, 857 deletions
@@ -6,8 +6,8 @@ To build SciTE, Scintilla must first be built. *** GTK+/Linux version *** -You must first have GTK+ 1.2 or later and GCC (3.1 or better) installed. -GTK+ 1.0x will not work and when it did it was very slow. +You must first have GTK+ 2.0 or later and GCC (3.1 or better) installed. +GTK+ 1.x will not work. Other C++ compilers may work but may require tweaking the make file. To build Scintilla, use the makefile located in the scintilla/gtk directory @@ -29,10 +29,6 @@ and make install as this location is compiled into the executable. The global properties file is installed at $prefix/share/scite/SciTEGlobal.properties. The language specific properties files are also installed into this directory. -To build Scintilla for GTK+ 1 rather than the default GTK+ 2, define GTK1 on -the make command line: - make GTK1=1 - To remove SciTE make uninstall @@ -46,8 +42,7 @@ The current make file only supports static linking between SciTE and Scintilla. A C++ compiler is required. Visual Studio .NET 2008 is the development system used for most development although Mingw32 3.1 is also supported. -Borland did work but the command lines are now too long and the most recent -Borland version does not work. For older versions such as version 5.02, add the -l option. +For older versions of Borland C++ such as version 5.02, add the -l option. To build Scintilla, make in the scintilla/win32 directory cd scintilla\win32 @@ -67,3 +62,13 @@ An executable SciTE will now be in scite\bin. The Visual C++ 6.0 project (.dsp) files are no longer supported but are left in the download for people that are prepared to update them. + +*** GTK+/Windows version *** + +Mingw32 is known to work. Other compilers will probably not work. + +Only Scintilla will build with GTK+ on Windows. SciTE will not work. + +To build Scintilla, make in the scintilla/gtk directory + cd scintilla\gtk + mingw32-make diff --git a/gtk/Converter.h b/gtk/Converter.h index d3038a2f2..8e7e3e9ef 100644 --- a/gtk/Converter.h +++ b/gtk/Converter.h @@ -3,12 +3,7 @@ // Copyright 2004 by Neil Hodgson <neilh@scintilla.org> // The License.txt file describes the conditions under which this software may be distributed. -#include <iconv.h> -#if GTK_MAJOR_VERSION >= 2 - typedef GIConv ConverterHandle; -#else - typedef iconv_t ConverterHandle; -#endif +typedef GIConv ConverterHandle; const ConverterHandle iconvhBad = (ConverterHandle)(-1); // Since various versions of iconv can not agree on whether the src argument // is char ** or const char ** provide a templatised adaptor. @@ -24,11 +19,7 @@ size_t iconv_adaptor(size_t(*f_iconv)(ConverterHandle, T, size_t *, char **, siz class Converter { ConverterHandle iconvh; void OpenHandle(const char *fullDestination, const char *charSetSource) { -#if GTK_MAJOR_VERSION >= 2 iconvh = g_iconv_open(fullDestination, charSetSource); -#else - iconvh = iconv_open(fullDestination, charSetSource); -#endif } bool Succeeded() const { return iconvh != iconvhBad; @@ -65,11 +56,7 @@ public: } void Close() { if (Succeeded()) { -#if GTK_MAJOR_VERSION >= 2 g_iconv_close(iconvh); -#else - iconv_close(iconvh); -#endif iconvh = iconvhBad; } } @@ -77,11 +64,7 @@ public: if (!Succeeded()) { return (size_t)(-1); } else { -#if GTK_MAJOR_VERSION >= 2 return iconv_adaptor(g_iconv, iconvh, src, srcleft, dst, dstleft); -#else - return iconv_adaptor(iconv, iconvh, src, srcleft, dst, dstleft); -#endif } } }; diff --git a/gtk/PlatGTK.cxx b/gtk/PlatGTK.cxx index e7c8299fd..55947113e 100644 --- a/gtk/PlatGTK.cxx +++ b/gtk/PlatGTK.cxx @@ -31,10 +31,7 @@ with gdk_string_extents. */ #define FAST_WAY -#if GTK_MAJOR_VERSION >= 2 -#define USE_PANGO 1 #include "Converter.h" -#endif #ifdef _MSC_VER // Ignore unreferenced local functions in GTK+ headers @@ -105,21 +102,16 @@ class FontHandle { public: int ascent; GdkFont *pfont; -#ifdef USE_PANGO PangoFontDescription *pfd; int characterSet; -#endif FontHandle(GdkFont *pfont_) { et = singleByte; ascent = 0; pfont = pfont_; -#ifdef USE_PANGO pfd = 0; characterSet = -1; -#endif ResetWidths(et); } -#ifdef USE_PANGO FontHandle(PangoFontDescription *pfd_, int characterSet_) { et = singleByte; ascent = 0; @@ -128,16 +120,13 @@ public: characterSet = characterSet_; ResetWidths(et); } -#endif ~FontHandle() { if (pfont) gdk_font_unref(pfont); pfont = 0; -#ifdef USE_PANGO if (pfd) pango_font_description_free(pfd); pfd = 0; -#endif } void ResetWidths(encodingType et_) { et = et_; @@ -513,7 +502,6 @@ FontID FontCached::CreateNewFont(const char *fontName, int characterSet, faceName[0] = '\0'; charset[0] = '\0'; -#ifdef USE_PANGO if (fontName[0] == '!') { PangoFontDescription *pfd = pango_font_description_new(); if (pfd) { @@ -524,7 +512,6 @@ FontID FontCached::CreateNewFont(const char *fontName, int characterSet, return new FontHandle(pfd, characterSet); } } -#endif GdkFont *newid = 0; // If name of the font begins with a '-', assume, that it is @@ -693,13 +680,11 @@ class SurfaceImpl : public Surface int y; bool inited; bool createdGC; -#ifdef USE_PANGO PangoContext *pcontext; PangoLayout *layout; Converter conv; int characterSet; void SetConverter(int characterSet_); -#endif public: SurfaceImpl(); virtual ~SurfaceImpl(); @@ -796,22 +781,16 @@ const char *CharacterSetID(int characterSet) { } } -#ifdef USE_PANGO - void SurfaceImpl::SetConverter(int characterSet_) { if (characterSet != characterSet_) { characterSet = characterSet_; conv.Open("UTF-8", CharacterSetID(characterSet), false); } } -#endif SurfaceImpl::SurfaceImpl() : et(singleByte), drawable(0), gc(0), ppixmap(0), x(0), y(0), inited(false), createdGC(false) -#ifdef USE_PANGO -, pcontext(0), layout(0), characterSet(-1) -#endif -{ +, pcontext(0), layout(0), characterSet(-1) { } SurfaceImpl::~SurfaceImpl() { @@ -829,7 +808,6 @@ void SurfaceImpl::Release() { if (ppixmap) gdk_pixmap_unref(ppixmap); ppixmap = 0; -#ifdef USE_PANGO if (layout) g_object_unref(layout); layout = 0; @@ -838,7 +816,6 @@ void SurfaceImpl::Release() { pcontext = 0; conv.Close(); characterSet = -1; -#endif x = 0; y = 0; inited = false; @@ -849,34 +826,23 @@ bool SurfaceImpl::Initialised() { return inited; } -// The WindowID argument is only used for Pango builds -#ifdef USE_PANGO -#define WID_NAME wid -#else -#define WID_NAME -#endif - -void SurfaceImpl::Init(WindowID WID_NAME) { +void SurfaceImpl::Init(WindowID wid) { Release(); -#ifdef USE_PANGO PLATFORM_ASSERT(wid); pcontext = gtk_widget_create_pango_context(PWidget(wid)); PLATFORM_ASSERT(pcontext); layout = pango_layout_new(pcontext); PLATFORM_ASSERT(layout); -#endif inited = true; } -void SurfaceImpl::Init(SurfaceID sid, WindowID WID_NAME) { +void SurfaceImpl::Init(SurfaceID sid, WindowID wid) { PLATFORM_ASSERT(sid); GdkDrawable *drawable_ = reinterpret_cast<GdkDrawable *>(sid); Release(); -#ifdef USE_PANGO PLATFORM_ASSERT(wid); pcontext = gtk_widget_create_pango_context(PWidget(wid)); layout = pango_layout_new(pcontext); -#endif drawable = drawable_; gc = gdk_gc_new(drawable_); // Ask for lines that do not paint the last pixel so is like Win32 @@ -885,18 +851,16 @@ void SurfaceImpl::Init(SurfaceID sid, WindowID WID_NAME) { inited = true; } -void SurfaceImpl::InitPixMap(int width, int height, Surface *surface_, WindowID WID_NAME) { +void SurfaceImpl::InitPixMap(int width, int height, Surface *surface_, WindowID wid) { PLATFORM_ASSERT(surface_); Release(); SurfaceImpl *surfImpl = static_cast<SurfaceImpl *>(surface_); PLATFORM_ASSERT(surfImpl->drawable); -#ifdef USE_PANGO PLATFORM_ASSERT(wid); pcontext = gtk_widget_create_pango_context(PWidget(wid)); PLATFORM_ASSERT(pcontext); layout = pango_layout_new(pcontext); PLATFORM_ASSERT(layout); -#endif if (height > 0 && width > 0) ppixmap = gdk_pixmap_new(surfImpl->drawable, width, height, -1); drawable = ppixmap; @@ -1023,8 +987,6 @@ void SurfaceImpl::RoundedRectangle(PRectangle rc, ColourAllocated fore, ColourAl } } -#if GTK_MAJOR_VERSION >= 2 - // Plot a point into a guint32 buffer symetrically to all 4 qudrants static void AllFour(guint32 *pixels, int stride, int width, int height, int x, int y, guint32 val) { pixels[y*stride+x] = val; @@ -1045,20 +1007,6 @@ static unsigned int GetBValue(unsigned int co) { return co & 0xff; } -#endif - -#if GTK_MAJOR_VERSION < 2 -void SurfaceImpl::AlphaRectangle(PRectangle rc, int , ColourAllocated , int , ColourAllocated outline, int , int ) { - if (gc && drawable) { - // Can't use GdkPixbuf on GTK+ 1.x, so draw an outline rather than use alpha. - PenColour(outline); - gdk_draw_rectangle(drawable, gc, 0, - rc.left, rc.top, - rc.right - rc.left - 1, rc.bottom - rc.top - 1); - } -} -#else - static guint32 u32FromRGBA(guint8 r, guint8 g, guint8 b, guint8 a) { union { guint8 pixVal[4]; @@ -1114,8 +1062,6 @@ void SurfaceImpl::AlphaRectangle(PRectangle rc, int cornerSize, ColourAllocated } } -#endif - void SurfaceImpl::Ellipse(PRectangle rc, ColourAllocated fore, ColourAllocated back) { PenColour(back); gdk_draw_arc(drawable, gc, 1, @@ -1169,7 +1115,6 @@ char *UTF8FromLatin1(const char *s, int &len) { return utfForm; } -#ifdef USE_PANGO static char *UTF8FromIconv(const Converter &conv, const char *s, int &len) { if (conv) { char *utfForm = new char[len*3+1]; @@ -1254,8 +1199,6 @@ static size_t UTF8CharLength(const char *s) { } } -#endif - // On GTK+, wchar_t is 4 bytes const int maxLengthTextRun = 10000; @@ -1265,7 +1208,6 @@ void SurfaceImpl::DrawTextBase(PRectangle rc, Font &font_, int ybase, const char PenColour(fore); if (gc && drawable) { int xText = rc.left; -#ifdef USE_PANGO if (PFont(font_)->pfd) { char *utfForm = 0; bool useGFree = false; @@ -1301,7 +1243,6 @@ void SurfaceImpl::DrawTextBase(PRectangle rc, Font &font_, int ybase, const char } return; } -#endif // Draw text as a series of segments to avoid limitations in X servers const int segmentLength = 1000; bool draw8bit = true; @@ -1376,8 +1317,6 @@ void SurfaceImpl::DrawTextTransparent(PRectangle rc, Font &font_, int ybase, con } } -#ifdef USE_PANGO - class ClusterIterator { PangoLayoutIter *iter; PangoRectangle pos; @@ -1412,12 +1351,9 @@ public: } }; -#endif - void SurfaceImpl::MeasureWidths(Font &font_, const char *s, int len, int *positions) { if (font_.GetID()) { int totalWidth = 0; -#ifdef USE_PANGO const int lenPositions = len; if (PFont(font_)->pfd) { if (len == 1) { @@ -1516,7 +1452,6 @@ void SurfaceImpl::MeasureWidths(Font &font_, const char *s, int len, int *positi } return; } -#endif GdkFont *gf = PFont(font_)->pfont; bool measure8bit = true; if (et != singleByte) { @@ -1577,7 +1512,6 @@ void SurfaceImpl::MeasureWidths(Font &font_, const char *s, int len, int *positi int SurfaceImpl::WidthText(Font &font_, const char *s, int len) { if (font_.GetID()) { -#ifdef USE_PANGO if (PFont(font_)->pfd) { char *utfForm = 0; pango_layout_set_font_description(layout, PFont(font_)->pfd); @@ -1612,7 +1546,6 @@ int SurfaceImpl::WidthText(Font &font_, const char *s, int len) { } return PANGO_PIXELS(pos.width); } -#endif if (et == UTF8) { GdkWChar wctext[maxLengthTextRun]; size_t wclen = UTF16FromUTF8(s, len, static_cast<wchar_t *>(static_cast<void *>(wctext)), @@ -1629,11 +1562,9 @@ int SurfaceImpl::WidthText(Font &font_, const char *s, int len) { int SurfaceImpl::WidthChar(Font &font_, char ch) { if (font_.GetID()) { -#ifdef USE_PANGO if (PFont(font_)->pfd) { return WidthText(font_, &ch, 1); } -#endif return gdk_char_width(PFont(font_)->pfont, ch); } else { return 1; @@ -1663,7 +1594,6 @@ int SurfaceImpl::Ascent(Font &font_) { #ifdef FAST_WAY FontMutexLock(); int ascent = PFont(font_)->ascent; -#ifdef USE_PANGO if ((ascent == 0) && (PFont(font_)->pfd)) { PangoFontMetrics *metrics = pango_context_get_metrics(pcontext, PFont(font_)->pfd, pango_context_get_language(pcontext)); @@ -1672,7 +1602,6 @@ int SurfaceImpl::Ascent(Font &font_) { pango_font_metrics_unref(metrics); ascent = PFont(font_)->ascent; } -#endif if ((ascent == 0) && (PFont(font_)->pfont)) { ascent = PFont(font_)->pfont->ascent; } @@ -1700,7 +1629,6 @@ int SurfaceImpl::Descent(Font &font_) { return 1; #ifdef FAST_WAY -#ifdef USE_PANGO if (PFont(font_)->pfd) { PangoFontMetrics *metrics = pango_context_get_metrics(pcontext, PFont(font_)->pfd, pango_context_get_language(pcontext)); @@ -1708,7 +1636,6 @@ int SurfaceImpl::Descent(Font &font_) { pango_font_metrics_unref(metrics); return descent; } -#endif return PFont(font_)->pfont->descent; #else @@ -1794,18 +1721,12 @@ PRectangle Window::GetPosition() { } void Window::SetPosition(PRectangle rc) { -#if 1 GtkAllocation alloc; alloc.x = rc.left; alloc.y = rc.top; alloc.width = rc.Width(); alloc.height = rc.Height(); gtk_widget_size_allocate(PWidget(wid), &alloc); -#else - - gtk_widget_set_uposition(wid, rc.left, rc.top); - gtk_widget_set_usize(wid, rc.right - rc.left, rc.bottom - rc.top); -#endif } void Window::SetPositionRelative(PRectangle rc, Window relativeTo) { @@ -1831,21 +1752,8 @@ void Window::SetPositionRelative(PRectangle rc, Window relativeTo) { if (oy + sizey > screenHeight) oy = screenHeight - sizey; -#if GTK_MAJOR_VERSION >= 2 gtk_window_move(GTK_WINDOW(PWidget(wid)), ox, oy); -#else - gtk_widget_set_uposition(PWidget(wid), ox, oy); -#endif - -#if 0 - GtkAllocation alloc; - alloc.x = rc.left + ox; - alloc.y = rc.top + oy; - alloc.width = rc.right - rc.left; - alloc.height = rc.bottom - rc.top; - gtk_widget_size_allocate(wid, &alloc); -#endif gtk_widget_set_usize(PWidget(wid), sizex, sizey); } @@ -1927,8 +1835,8 @@ PRectangle Window::GetMonitorRect(Point pt) { gdk_window_get_origin(PWidget(wid)->window, &x_offset, &y_offset); -// gtk 2.2+ -#if GTK_MAJOR_VERSION > 2 || (GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION >= 2) +#if GTK_CHECK_VERSION(2,2,0) + // GTK+ 2.2+ { GdkScreen* screen; gint monitor_num; @@ -1949,25 +1857,13 @@ PRectangle Window::GetMonitorRect(Point pt) { struct ListImage { const char *xpm_data; -#if GTK_MAJOR_VERSION < 2 - GdkPixmap *pixmap; - GdkBitmap *bitmap; -#else GdkPixbuf *pixbuf; -#endif }; static void list_image_free(gpointer, gpointer value, gpointer) { ListImage *list_image = (ListImage *) value; -#if GTK_MAJOR_VERSION < 2 - if (list_image->pixmap) - gdk_pixmap_unref(list_image->pixmap); - if (list_image->bitmap) - gdk_bitmap_unref(list_image->bitmap); -#else if (list_image->pixbuf) gdk_pixbuf_unref (list_image->pixbuf); -#endif g_free(list_image); } @@ -1977,24 +1873,17 @@ ListBox::ListBox() { ListBox::~ListBox() { } -#if GTK_MAJOR_VERSION >= 2 enum { PIXBUF_COLUMN, TEXT_COLUMN, N_COLUMNS }; -#endif class ListBoxX : public ListBox { WindowID list; WindowID scroller; -#if GTK_MAJOR_VERSION < 2 - int current; -#endif void *pixhash; -#if GTK_MAJOR_VERSION >= 2 - GtkCellRenderer* pixbuf_renderer; -#endif + GtkCellRenderer* pixbuf_renderer; XPMSet xset; int desiredVisibleRows; unsigned int maxItemCharacters; @@ -2003,15 +1892,9 @@ public: CallBackAction doubleClickAction; void *doubleClickActionData; - ListBoxX() : list(0), pixhash(NULL), + ListBoxX() : list(0), pixhash(NULL), pixbuf_renderer(0), desiredVisibleRows(5), maxItemCharacters(0), aveCharWidth(1), doubleClickAction(NULL), doubleClickActionData(NULL) { -#if GTK_MAJOR_VERSION < 2 - current = 0; -#endif -#if GTK_MAJOR_VERSION >= 2 - pixbuf_renderer = 0; -#endif } virtual ~ListBoxX() { if (pixhash) { @@ -2047,19 +1930,6 @@ ListBox *ListBox::Allocate() { return lb; } -#if GTK_MAJOR_VERSION < 2 -static void UnselectionAC(GtkWidget *, gint, gint, - GdkEventButton *, gpointer p) { - int *pi = reinterpret_cast<int *>(p); - *pi = -1; -} -static void SelectionAC(GtkWidget *, gint row, gint, - GdkEventButton *, gpointer p) { - int *pi = reinterpret_cast<int *>(p); - *pi = row; -} -#endif - static gboolean ButtonPress(GtkWidget *, GdkEventButton* ev, gpointer p) { try { ListBoxX* lb = reinterpret_cast<ListBoxX*>(p); @@ -2074,7 +1944,6 @@ static gboolean ButtonPress(GtkWidget *, GdkEventButton* ev, gpointer p) { return FALSE; } -#if GTK_MAJOR_VERSION >= 2 /* Change the active color to the selected color so the listbox uses the color scheme that it would use if it had the focus. */ static void StyleSet(GtkWidget *w, GtkStyle*, void*) { @@ -2097,7 +1966,6 @@ static void StyleSet(GtkWidget *w, GtkStyle*, void*) { if (!gdk_color_equal(&style->text[GTK_STATE_SELECTED], &style->text[GTK_STATE_ACTIVE])) gtk_widget_modify_text(w, GTK_STATE_ACTIVE, &style->text[GTK_STATE_SELECTED]); } -#endif void ListBoxX::Create(Window &, int, Point, int, bool) { wid = gtk_window_new(GTK_WINDOW_POPUP); @@ -2115,21 +1983,6 @@ void ListBoxX::Create(Window &, int, Point, int, bool) { gtk_container_add(GTK_CONTAINER(frame), PWidget(scroller)); gtk_widget_show(PWidget(scroller)); -#if GTK_MAJOR_VERSION < 2 - list = gtk_clist_new(1); - GtkWidget *wid = PWidget(list); // No code inside the GTK_OBJECT macro - gtk_widget_show(wid); - gtk_container_add(GTK_CONTAINER(PWidget(scroller)), wid); - gtk_clist_set_column_auto_resize(GTK_CLIST(wid), 0, TRUE); - gtk_clist_set_selection_mode(GTK_CLIST(wid), GTK_SELECTION_BROWSE); - gtk_signal_connect(GTK_OBJECT(wid), "unselect_row", - GTK_SIGNAL_FUNC(UnselectionAC), ¤t); - gtk_signal_connect(GTK_OBJECT(wid), "select_row", - GTK_SIGNAL_FUNC(SelectionAC), ¤t); - gtk_signal_connect(GTK_OBJECT(wid), "button_press_event", - GTK_SIGNAL_FUNC(ButtonPress), this); - gtk_clist_set_shadow_type(GTK_CLIST(wid), GTK_SHADOW_NONE); -#else /* Tree and its model */ GtkListStore *store = gtk_list_store_new(N_COLUMNS, GDK_TYPE_PIXBUF, G_TYPE_STRING); @@ -2169,28 +2022,15 @@ void ListBoxX::Create(Window &, int, Point, int, bool) { gtk_widget_show(wid); g_signal_connect(G_OBJECT(wid), "button_press_event", G_CALLBACK(ButtonPress), this); -#endif gtk_widget_realize(PWidget(wid)); } void ListBoxX::SetFont(Font &scint_font) { -#if GTK_MAJOR_VERSION < 2 - GtkStyle *style = gtk_widget_get_style(GTK_WIDGET(PWidget(list))); - if (!gdk_font_equal(style->font, PFont(scint_font)->pfont)) { - style = gtk_style_copy(style); - gdk_font_unref(style->font); - style->font = PFont(scint_font)->pfont; - gdk_font_ref(style->font); - gtk_widget_set_style(GTK_WIDGET(PWidget(list)), style); - gtk_style_unref(style); - } -#else // Only do for Pango font as there have been crashes for GDK fonts if (Created() && PFont(scint_font)->pfd) { // Current font is Pango font gtk_widget_modify_font(PWidget(list), PFont(scint_font)->pfd); } -#endif } void ListBoxX::SetAverageCharWidth(int width) { @@ -2218,13 +2058,6 @@ PRectangle ListBoxX::GetDesiredRect() { // First calculate height of the clist for our desired visible // row count otherwise it tries to expand to the total # of rows -#if GTK_MAJOR_VERSION < 2 - int ythickness = PWidget(list)->style->klass->ythickness; - height = (rows * GTK_CLIST(list)->row_height - + rows + 1 - + 2 * (ythickness - + GTK_CONTAINER(PWidget(list))->border_width)); -#else // Get cell height int row_width=0; int row_height=0; @@ -2236,7 +2069,6 @@ PRectangle ListBoxX::GetDesiredRect() { height = (rows * row_height + 2 * (ythickness + GTK_CONTAINER(PWidget(list))->border_width + 1)); -#endif gtk_widget_set_usize(GTK_WIDGET(PWidget(list)), -1, height); // Get the size of the scroller because we set usize on the window @@ -2256,30 +2088,19 @@ PRectangle ListBoxX::GetDesiredRect() { } int ListBoxX::CaretFromEdge() { -#if GTK_MAJOR_VERSION >= 2 gint renderer_width, renderer_height; gtk_cell_renderer_get_fixed_size(pixbuf_renderer, &renderer_width, &renderer_height); return 4 + renderer_width; -#endif - return 4 + xset.GetWidth(); } void ListBoxX::Clear() { -#if GTK_MAJOR_VERSION < 2 - gtk_clist_clear(GTK_CLIST(list)); -#else GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(list)); gtk_list_store_clear(GTK_LIST_STORE(model)); -#endif maxItemCharacters = 0; } -#if GTK_MAJOR_VERSION < 2 -static void init_pixmap(ListImage *list_image, GtkWidget *window) { -#else static void init_pixmap(ListImage *list_image) { -#endif const char *textForm = list_image->xpm_data; const char * const * xpm_lineform = reinterpret_cast<const char * const *>(textForm); const char **xpm_lineformfromtext = 0; @@ -2294,28 +2115,10 @@ static void init_pixmap(ListImage *list_image) { } // Drop any existing pixmap/bitmap as data may have changed -#if GTK_MAJOR_VERSION < 2 - if (list_image->pixmap) - gdk_pixmap_unref(list_image->pixmap); - list_image->pixmap = NULL; - if (list_image->bitmap) - gdk_bitmap_unref(list_image->bitmap); - list_image->bitmap = NULL; - - list_image->pixmap = gdk_pixmap_colormap_create_from_xpm_d(NULL - , gtk_widget_get_colormap(window), &(list_image->bitmap), NULL - , (gchar **) xpm_lineform); - if (NULL == list_image->pixmap) { - if (list_image->bitmap) - gdk_bitmap_unref(list_image->bitmap); - list_image->bitmap = NULL; - } -#else if (list_image->pixbuf) gdk_pixbuf_unref(list_image->pixbuf); list_image->pixbuf = gdk_pixbuf_new_from_xpm_data((const gchar**)xpm_lineform); -#endif delete []xpm_lineformfromtext; } @@ -2327,16 +2130,6 @@ void ListBoxX::Append(char *s, int type) { list_image = (ListImage *) g_hash_table_lookup((GHashTable *) pixhash , (gconstpointer) GINT_TO_POINTER(type)); } -#if GTK_MAJOR_VERSION < 2 - char * szs[] = { s, NULL }; - int rownum = gtk_clist_append(GTK_CLIST(list), szs); - if (list_image) { - if (NULL == list_image->pixmap) - init_pixmap(list_image, (GtkWidget *) list); - gtk_clist_set_pixtext(GTK_CLIST(list), rownum, 0, s, SPACING - , list_image->pixmap, list_image->bitmap); - } -#else GtkTreeIter iter; GtkListStore *store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(list))); @@ -2364,7 +2157,6 @@ void ListBoxX::Append(char *s, int type) { gtk_list_store_set(GTK_LIST_STORE(store), &iter, TEXT_COLUMN, s, -1); } -#endif size_t len = strlen(s); if (maxItemCharacters < len) maxItemCharacters = len; @@ -2372,24 +2164,12 @@ void ListBoxX::Append(char *s, int type) { int ListBoxX::Length() { if (wid) -#if GTK_MAJOR_VERSION < 2 - return GTK_CLIST(list)->rows; -#else return gtk_tree_model_iter_n_children(gtk_tree_view_get_model (GTK_TREE_VIEW(list)), NULL); -#endif return 0; } void ListBoxX::Select(int n) { -#if GTK_MAJOR_VERSION < 2 - if (n == -1) { - gtk_clist_unselect_row(GTK_CLIST(list), current, 0); - } else { - gtk_clist_select_row(GTK_CLIST(list), n, 0); - gtk_clist_moveto(GTK_CLIST(list), n, 0, 0.5, 0.5); - } -#else GtkTreeIter iter; GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(list)); GtkTreeSelection *selection = @@ -2437,13 +2217,9 @@ void ListBoxX::Select(int n) { } else { gtk_tree_selection_unselect_all(selection); } -#endif } int ListBoxX::GetSelection() { -#if GTK_MAJOR_VERSION < 2 - return current; -#else GtkTreeIter iter; GtkTreeModel *model; GtkTreeSelection *selection; @@ -2456,20 +2232,9 @@ int ListBoxX::GetSelection() { return indices[0]; } return -1; -#endif } int ListBoxX::Find(const char *prefix) { -#if GTK_MAJOR_VERSION < 2 - int count = Length(); - for (int i = 0; i < count; i++) { - char *s = 0; - gtk_clist_get_text(GTK_CLIST(list), i, 0, &s); - if (s && (0 == strncmp(prefix, s, strlen(prefix)))) { - return i; - } - } -#else GtkTreeIter iter; GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(list)); @@ -2484,32 +2249,17 @@ int ListBoxX::Find(const char *prefix) { valid = gtk_tree_model_iter_next(model, &iter) != FALSE; i++; } -#endif return -1; } void ListBoxX::GetValue(int n, char *value, int len) { char *text = NULL; -#if GTK_MAJOR_VERSION < 2 - GtkCellType type = gtk_clist_get_cell_type(GTK_CLIST(list), n, 0); - switch (type) { - case GTK_CELL_TEXT: - gtk_clist_get_text(GTK_CLIST(list), n, 0, &text); - break; - case GTK_CELL_PIXTEXT: - gtk_clist_get_pixtext(GTK_CLIST(list), n, 0, &text, NULL, NULL, NULL); - break; - default: - break; - } -#else GtkTreeIter iter; GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(list)); bool valid = gtk_tree_model_iter_nth_child(model, &iter, NULL, n) != FALSE; if (valid) { gtk_tree_model_get(model, &iter, TEXT_COLUMN, &text, -1); } -#endif if (text && len > 0) { strncpy(value, text, len); value[len - 1] = '\0'; @@ -2538,18 +2288,9 @@ void ListBoxX::RegisterImage(int type, const char *xpm_data) { (gconstpointer) GINT_TO_POINTER(type)); if (list_image) { // Drop icon already registered -#if GTK_MAJOR_VERSION < 2 - if (list_image->pixmap) - gdk_pixmap_unref(list_image->pixmap); - list_image->pixmap = 0; - if (list_image->bitmap) - gdk_bitmap_unref(list_image->bitmap); - list_image->bitmap = 0; -#else if (list_image->pixbuf) gdk_pixbuf_unref(list_image->pixbuf); list_image->pixbuf = NULL; -#endif list_image->xpm_data = xpm_data; } else { list_image = g_new0(ListImage, 1); @@ -2602,11 +2343,7 @@ void Menu::CreatePopUp() { void Menu::Destroy() { if (mid) -#if GTK_MAJOR_VERSION < 2 - gtk_object_unref(GTK_OBJECT(mid)); -#else g_object_unref(G_OBJECT(mid)); -#endif mid = 0; } @@ -2624,12 +2361,8 @@ void Menu::Show(Point pt, Window &) { if ((pt.y + requisition.height) > screenHeight) { pt.y = screenHeight - requisition.height; } -#if GTK_MAJOR_VERSION >= 2 gtk_item_factory_popup(factory, pt.x - 4, pt.y - 4, 3, gtk_get_current_event_time()); -#else - gtk_item_factory_popup(factory, pt.x - 4, pt.y - 4, 3, 0); -#endif } ElapsedTime::ElapsedTime() { @@ -2701,11 +2434,7 @@ const char *Platform::DefaultFont() { #ifdef G_OS_WIN32 return "Lucida Console"; #else -#ifdef USE_PANGO return "!Sans"; -#else - return "lucidatypewriter"; -#endif #endif } diff --git a/gtk/ScintillaGTK.cxx b/gtk/ScintillaGTK.cxx index b53b46691..a0f55fd2b 100644 --- a/gtk/ScintillaGTK.cxx +++ b/gtk/ScintillaGTK.cxx @@ -56,9 +56,7 @@ #include "gtk/gtksignal.h" #include "gtk/gtkmarshal.h" -#if GLIB_MAJOR_VERSION >= 2 #include "scintilla-marshal.h" -#endif #ifdef SCI_LEXER #include <glib.h> @@ -66,15 +64,7 @@ #include "ExternalLexer.h" #endif -#define INTERNATIONAL_INPUT - -#if !PLAT_GTK_WIN32 || GTK_MAJOR_VERSION >= 2 -#define USE_CONVERTER -#endif - -#ifdef USE_CONVERTER #include "Converter.h" -#endif #ifdef _MSC_VER // Constant conditional expressions are because of GTK+ headers @@ -87,11 +77,7 @@ #define USE_GTK_CLIPBOARD #endif -#if GLIB_MAJOR_VERSION < 2 -#define OBJECT_CLASS GtkObjectClass -#else #define OBJECT_CLASS GObjectClass -#endif #ifdef SCI_NAMESPACE using namespace Scintilla; @@ -135,17 +121,9 @@ class ScintillaGTK : public ScintillaBase { CLIPFORMAT cfColumnSelect; #endif -#ifdef INTERNATIONAL_INPUT -#if GTK_MAJOR_VERSION < 2 - // Input context used for supporting internationalized key entry - GdkIC *ic; - GdkICAttr *ic_attr; -#else Window wPreedit; Window wPreeditDraw; GtkIMContext *im_context; -#endif -#endif // Wheel mouse support unsigned int linesPerScroll; @@ -245,36 +223,25 @@ private: gint PressThis(GdkEventButton *event); static gint Press(GtkWidget *widget, GdkEventButton *event); static gint MouseRelease(GtkWidget *widget, GdkEventButton *event); -#if PLAT_GTK_WIN32 || (GTK_MAJOR_VERSION >= 2) static gint ScrollEvent(GtkWidget *widget, GdkEventScroll *event); -#endif static gint Motion(GtkWidget *widget, GdkEventMotion *event); gboolean KeyThis(GdkEventKey *event); static gboolean KeyPress(GtkWidget *widget, GdkEventKey *event); static gboolean KeyRelease(GtkWidget *widget, GdkEventKey *event); -#if GTK_MAJOR_VERSION >= 2 gboolean ExposePreeditThis(GtkWidget *widget, GdkEventExpose *ose); static gboolean ExposePreedit(GtkWidget *widget, GdkEventExpose *ose, ScintillaGTK *sciThis); void CommitThis(char *str); static void Commit(GtkIMContext *context, char *str, ScintillaGTK *sciThis); void PreeditChangedThis(); static void PreeditChanged(GtkIMContext *context, ScintillaGTK *sciThis); -#endif static gint StyleSetText(GtkWidget *widget, GtkStyle *previous, void*); static gint RealizeText(GtkWidget *widget, void*); -#if GLIB_MAJOR_VERSION < 2 - static void Destroy(GtkObject *object); -#else static void Destroy(GObject *object); -#endif static void SelectionReceived(GtkWidget *widget, GtkSelectionData *selection_data, guint time); static void SelectionGet(GtkWidget *widget, GtkSelectionData *selection_data, guint info, guint time); static gint SelectionClear(GtkWidget *widget, GdkEventSelection *selection_event); -#if GTK_MAJOR_VERSION < 2 - static gint SelectionNotify(GtkWidget *widget, GdkEventSelection *selection_event); -#endif static void DragBegin(GtkWidget *widget, GdkDragContext *context); gboolean DragMotionThis(GdkDragContext *context, gint x, gint y, guint dragtime); static gboolean DragMotion(GtkWidget *widget, GdkDragContext *context, @@ -309,9 +276,6 @@ enum { }; static gint scintilla_signals[LAST_SIGNAL] = { 0 }; -#if GLIB_MAJOR_VERSION < 2 -static GtkWidgetClass *parent_class = NULL; -#endif enum { TARGET_STRING, @@ -354,14 +318,7 @@ ScintillaGTK::ScintillaGTK(_ScintillaObject *sci_) : scrollBarWidth(30), scrollBarHeight(30), capturedMouse(false), dragWasDropped(false), lastKey(0), rectangularSelectionModifier(SCMOD_CTRL), parentClass(0), -#ifdef INTERNATIONAL_INPUT -#if GTK_MAJOR_VERSION < 2 - ic(NULL), - ic_attr(NULL), -#else im_context(NULL), -#endif -#endif lastWheelMouseDirection(0), wheelMouseIntensity(0), rgnUpdate(0) { @@ -420,65 +377,6 @@ void ScintillaGTK::RealizeThis(GtkWidget *widget) { gdk_window_show(widget->window); gdk_cursor_destroy(cursor); widget->style = gtk_style_attach(widget->style, widget->window); -#ifdef INTERNATIONAL_INPUT -#if GTK_MAJOR_VERSION < 2 - if (gdk_im_ready() && (ic_attr = gdk_ic_attr_new()) != NULL) { - gint width, height; - GdkColormap *colormap; - GdkEventMask mask; - GdkICAttr *attr = ic_attr; - GdkICAttributesType attrmask = GDK_IC_ALL_REQ; - GdkIMStyle style; - GdkIMStyle supported_style = (GdkIMStyle) (GDK_IM_PREEDIT_NONE | - GDK_IM_PREEDIT_NOTHING | - GDK_IM_PREEDIT_POSITION | - GDK_IM_STATUS_NONE | - GDK_IM_STATUS_NOTHING); - - if (widget->style && widget->style->font->type != GDK_FONT_FONTSET) - supported_style = (GdkIMStyle) ((int) supported_style & ~GDK_IM_PREEDIT_POSITION); - - attr->style = style = gdk_im_decide_style(supported_style); - attr->client_window = widget->window; - - if ((colormap = gtk_widget_get_colormap (widget)) != gtk_widget_get_default_colormap ()) { - attrmask = (GdkICAttributesType) ((int) attrmask | GDK_IC_PREEDIT_COLORMAP); - attr->preedit_colormap = colormap; - } - - switch (style & GDK_IM_PREEDIT_MASK) { - case GDK_IM_PREEDIT_POSITION: - if (widget->style && widget->style->font->type != GDK_FONT_FONTSET) { - g_warning("over-the-spot style requires fontset"); - break; - } - - attrmask = (GdkICAttributesType) ((int) attrmask | GDK_IC_PREEDIT_POSITION_REQ); - gdk_window_get_size(widget->window, &width, &height); - attr->spot_location.x = 0; - attr->spot_location.y = height; - attr->preedit_area.x = 0; - attr->preedit_area.y = 0; - attr->preedit_area.width = width; - attr->preedit_area.height = height; - attr->preedit_fontset = widget->style->font; - - break; - } - ic = gdk_ic_new(attr, attrmask); - - if (ic == NULL) { - g_warning("Can't create input context."); - } else { - mask = gdk_window_get_events(widget->window); - mask = (GdkEventMask) ((int) mask | gdk_ic_get_events(ic)); - gdk_window_set_events(widget->window, mask); - - if (GTK_WIDGET_HAS_FOCUS(widget)) - gdk_im_begin(ic, widget->window); - } - } -#else wPreedit = gtk_window_new(GTK_WINDOW_POPUP); wPreeditDraw = gtk_drawing_area_new(); GtkWidget *predrw = PWidget(wPreeditDraw); // No code inside the G_OBJECT macro @@ -495,20 +393,11 @@ void ScintillaGTK::RealizeThis(GtkWidget *widget) { g_signal_connect(G_OBJECT(im_context), "preedit_changed", G_CALLBACK(PreeditChanged), this); gtk_im_context_set_client_window(im_context, widget->window); -#endif -#endif GtkWidget *widtxt = PWidget(wText); // // No code inside the G_OBJECT macro -#if GLIB_MAJOR_VERSION < 2 - gtk_signal_connect_after(GTK_OBJECT(widtxt), "style_set", - GtkSignalFunc(ScintillaGTK::StyleSetText), NULL); - gtk_signal_connect_after(GTK_OBJECT(widtxt), "realize", - GtkSignalFunc(ScintillaGTK::RealizeText), NULL); -#else g_signal_connect_after(G_OBJECT(widtxt), "style_set", G_CALLBACK(ScintillaGTK::StyleSetText), NULL); g_signal_connect_after(G_OBJECT(widtxt), "realize", G_CALLBACK(ScintillaGTK::RealizeText), NULL); -#endif gtk_widget_realize(widtxt); gtk_widget_realize(PWidget(scrollbarv)); gtk_widget_realize(PWidget(scrollbarh)); @@ -528,23 +417,10 @@ void ScintillaGTK::UnRealizeThis(GtkWidget *widget) { gtk_widget_unrealize(PWidget(wText)); gtk_widget_unrealize(PWidget(scrollbarv)); gtk_widget_unrealize(PWidget(scrollbarh)); -#ifdef INTERNATIONAL_INPUT -#if GTK_MAJOR_VERSION < 2 - if (ic) { - gdk_ic_destroy(ic); - ic = NULL; - } - if (ic_attr) { - gdk_ic_attr_destroy(ic_attr); - ic_attr = NULL; - } -#else gtk_widget_unrealize(PWidget(wPreedit)); gtk_widget_unrealize(PWidget(wPreeditDraw)); g_object_unref(im_context); im_context = NULL; -#endif -#endif if (GTK_WIDGET_CLASS(parentClass)->unrealize) GTK_WIDGET_CLASS(parentClass)->unrealize(widget); @@ -626,18 +502,6 @@ void ScintillaGTK::MainForAll(GtkContainer *container, gboolean include_internal } } -#ifdef INTERNATIONAL_INPUT -#if GTK_MAJOR_VERSION < 2 -gint ScintillaGTK::CursorMoved(GtkWidget *widget, int xoffset, int yoffset, ScintillaGTK *sciThis) { - if (GTK_WIDGET_HAS_FOCUS(widget) && gdk_im_ready() && sciThis->ic && - (gdk_ic_get_style(sciThis->ic) & GDK_IM_PREEDIT_POSITION)) { - sciThis->ic_attr->spot_location.x = xoffset; - sciThis->ic_attr->spot_location.y = yoffset; - gdk_ic_set_attr(sciThis->ic, sciThis->ic_attr, GDK_IC_SPOT_LOCATION); - } - return FALSE; -} -#else gint ScintillaGTK::CursorMoved(GtkWidget *, int xoffset, int yoffset, ScintillaGTK *sciThis) { GdkRectangle area; area.x = xoffset; @@ -647,22 +511,11 @@ gint ScintillaGTK::CursorMoved(GtkWidget *, int xoffset, int yoffset, ScintillaG gtk_im_context_set_cursor_location(sciThis->im_context, &area); return FALSE; } -#endif -#else -gint ScintillaGTK::CursorMoved(GtkWidget *, int, int, ScintillaGTK *) { - return FALSE; -} -#endif gint ScintillaGTK::FocusInThis(GtkWidget *widget) { try { GTK_WIDGET_SET_FLAGS(widget, GTK_HAS_FOCUS); SetFocusState(true); -#ifdef INTERNATIONAL_INPUT -#if GTK_MAJOR_VERSION < 2 - if (ic) - gdk_im_begin(ic, widget->window); -#else if (im_context != NULL) { gchar *str = NULL; gint cursor_pos; @@ -678,8 +531,6 @@ gint ScintillaGTK::FocusInThis(GtkWidget *widget) { g_free(str); gtk_im_context_focus_in(im_context); } -#endif -#endif } catch (...) { errorStatus = SC_STATUS_FAILURE; @@ -697,16 +548,10 @@ gint ScintillaGTK::FocusOutThis(GtkWidget *widget) { GTK_WIDGET_UNSET_FLAGS(widget, GTK_HAS_FOCUS); SetFocusState(false); -#ifdef INTERNATIONAL_INPUT -#if GTK_MAJOR_VERSION < 2 - gdk_im_end(); -#else if (PWidget(wPreedit) != NULL) gtk_widget_hide(PWidget(wPreedit)); if (im_context != NULL) gtk_im_context_focus_out(im_context); -#endif -#endif } catch (...) { errorStatus = SC_STATUS_FAILURE; @@ -741,19 +586,6 @@ void ScintillaGTK::SizeAllocate(GtkWidget *widget, GtkAllocation *allocation) { sciThis->Resize(allocation->width, allocation->height); -#ifdef INTERNATIONAL_INPUT -#if GTK_MAJOR_VERSION < 2 - if (sciThis->ic && (gdk_ic_get_style(sciThis->ic) & GDK_IM_PREEDIT_POSITION)) { - gint width, height; - - gdk_window_get_size(widget->window, &width, &height); - sciThis->ic_attr->preedit_area.width = width; - sciThis->ic_attr->preedit_area.height = height; - - gdk_ic_set_attr(sciThis->ic, sciThis->ic_attr, GDK_IC_PREEDIT_AREA); - } -#endif -#endif } catch (...) { sciThis->errorStatus = SC_STATUS_FAILURE; } @@ -782,43 +614,26 @@ void ScintillaGTK::Initialise() { gtk_widget_set_parent(PWidget(wText), PWidget(wMain)); GtkWidget *widtxt = PWidget(wText); // No code inside the G_OBJECT macro gtk_widget_show(widtxt); -#if GLIB_MAJOR_VERSION < 2 - gtk_signal_connect(GTK_OBJECT(widtxt), "expose_event", - GtkSignalFunc(ScintillaGTK::ExposeText), this); -#else g_signal_connect(G_OBJECT(widtxt), "expose_event", G_CALLBACK(ScintillaGTK::ExposeText), this); -#endif gtk_widget_set_events(widtxt, GDK_EXPOSURE_MASK); -#if GTK_MAJOR_VERSION >= 2 // Avoid background drawing flash gtk_widget_set_double_buffered(widtxt, FALSE); -#endif gtk_drawing_area_size(GTK_DRAWING_AREA(widtxt), 100,100); adjustmentv = gtk_adjustment_new(0.0, 0.0, 201.0, 1.0, 20.0, 20.0); scrollbarv = gtk_vscrollbar_new(GTK_ADJUSTMENT(adjustmentv)); GTK_WIDGET_UNSET_FLAGS(PWidget(scrollbarv), GTK_CAN_FOCUS); -#if GLIB_MAJOR_VERSION < 2 - gtk_signal_connect(adjustmentv, "value_changed", - GtkSignalFunc(ScrollSignal), this); -#else g_signal_connect(G_OBJECT(adjustmentv), "value_changed", G_CALLBACK(ScrollSignal), this); -#endif gtk_widget_set_parent(PWidget(scrollbarv), PWidget(wMain)); gtk_widget_show(PWidget(scrollbarv)); adjustmenth = gtk_adjustment_new(0.0, 0.0, 101.0, 1.0, 20.0, 20.0); scrollbarh = gtk_hscrollbar_new(GTK_ADJUSTMENT(adjustmenth)); GTK_WIDGET_UNSET_FLAGS(PWidget(scrollbarh), GTK_CAN_FOCUS); -#if GLIB_MAJOR_VERSION < 2 - gtk_signal_connect(adjustmenth, "value_changed", - GtkSignalFunc(ScrollHSignal), this); -#else g_signal_connect(G_OBJECT(adjustmenth), "value_changed", G_CALLBACK(ScrollHSignal), this); -#endif gtk_widget_set_parent(PWidget(scrollbarh), PWidget(wMain)); gtk_widget_show(PWidget(scrollbarh)); @@ -836,7 +651,6 @@ void ScintillaGTK::Initialise() { GTK_DEST_DEFAULT_ALL, clipboardPasteTargets, nClipboardPasteTargets, static_cast<GdkDragAction>(GDK_ACTION_COPY | GDK_ACTION_MOVE)); -#if GLIB_MAJOR_VERSION >= 2 // Set caret period based on GTK settings gboolean blinkOn = false; if (g_object_class_find_property(G_OBJECT_GET_CLASS( @@ -854,7 +668,6 @@ void ScintillaGTK::Initialise() { } else { caret.period = 0; } -#endif SetTicking(true); } @@ -872,12 +685,8 @@ void ScintillaGTK::DisplayCursor(Window::Cursor c) { } bool ScintillaGTK::DragThreshold(Point ptStart, Point ptNow) { -#if GTK_MAJOR_VERSION < 2 - return Editor::DragThreshold(ptStart, ptNow); -#else return gtk_drag_check_threshold(GTK_WIDGET(PWidget(wMain)), ptStart.x, ptStart.y, ptNow.x, ptNow.y); -#endif } void ScintillaGTK::StartDrag() { @@ -891,7 +700,6 @@ void ScintillaGTK::StartDrag() { reinterpret_cast<GdkEvent *>(&evbtn)); } -#ifdef USE_CONVERTER static char *ConvertText(int *lenResult, char *s, size_t len, const char *charSetDest, const char *charSetSource, bool transliterations) { // s is not const because of different versions of iconv disagreeing about const @@ -924,7 +732,6 @@ fprintf(stderr, "Can not iconv %s %s\n", charSetDest, charSetSource); } return destForm; } -#endif // Returns the target converted to UTF8. // Return the length in bytes. @@ -936,7 +743,6 @@ int ScintillaGTK::TargetAsUTF8(char *text) { } } else { // Need to convert -#ifdef USE_CONVERTER const char *charSetBuffer = CharacterSetID(); if (*charSetBuffer) { //~ fprintf(stderr, "AsUTF8 %s %d %0d-%0d\n", charSetBuffer, targetLength, targetStart, targetEnd); @@ -957,10 +763,6 @@ int ScintillaGTK::TargetAsUTF8(char *text) { pdoc->GetCharRange(text, targetStart, targetLength); } } -#else - // Fail - return 0; -#endif } //~ fprintf(stderr, "Length = %d bytes\n", targetLength); return targetLength; @@ -977,14 +779,11 @@ int ScintillaGTK::EncodedFromUTF8(char *utf8, char *encoded) { return inputLength; } else { // Need to convert -#ifdef USE_CONVERTER const char *charSetBuffer = CharacterSetID(); if (*charSetBuffer) { -//~ fprintf(stderr, "Encode %s %d\n", charSetBuffer, inputLength); int outLength = 0; char *tmpEncoded = ConvertText(&outLength, utf8, inputLength, charSetBuffer, "UTF-8", true); if (tmpEncoded) { -//~ fprintf(stderr, " \"%s\"\n", tmpEncoded); if (encoded) { memcpy(encoded, tmpEncoded, outLength); } @@ -997,7 +796,6 @@ int ScintillaGTK::EncodedFromUTF8(char *utf8, char *encoded) { } return inputLength; } -#endif } // Fail return 0; @@ -1123,25 +921,7 @@ bool ScintillaGTK::PaintContains(PRectangle rc) { // Redraw all of text area. This paint will not be abandoned. void ScintillaGTK::FullPaint() { -#if GTK_MAJOR_VERSION < 2 - paintState = painting; - rcPaint = GetClientRectangle(); - //Platform::DebugPrintf("ScintillaGTK::FullPaint %0d,%0d %0d,%0d\n", - // rcPaint.left, rcPaint.top, rcPaint.right, rcPaint.bottom); - paintingAllText = true; - if ((PWidget(wText))->window) { - Surface *sw = Surface::Allocate(); - if (sw) { - sw->Init(PWidget(wText)->window, PWidget(wText)); - Paint(sw, rcPaint); - sw->Release(); - delete sw; - } - } - paintState = notPainting; -#else wText.InvalidateAll(); -#endif } PRectangle ScintillaGTK::GetClientRectangle() { @@ -1186,50 +966,8 @@ void ScintillaGTK::ScrollText(int linesToMove) { // rc.left, rc.top, rc.right, rc.bottom); GtkWidget *wi = PWidget(wText); -#if GTK_MAJOR_VERSION < 2 - PRectangle rc = GetClientRectangle(); - GdkGC *gc = gdk_gc_new(wi->window); - - // Set up gc so we get GraphicsExposures from gdk_draw_pixmap - // which calls XCopyArea - gdk_gc_set_exposures(gc, TRUE); - - // Redraw exposed bit : scrolling upwards - if (diff > 0) { - gdk_draw_pixmap(wi->window, - gc, wi->window, - 0, diff, - 0, 0, - rc.Width()-1, rc.Height() - diff); - SyncPaint(PRectangle(0, rc.Height() - diff, - rc.Width(), rc.Height()+1)); - - // Redraw exposed bit : scrolling downwards - } else { - gdk_draw_pixmap(wi->window, - gc, wi->window, - 0, 0, - 0, -diff, - rc.Width()-1, rc.Height() + diff); - SyncPaint(PRectangle(0, 0, rc.Width(), -diff)); - } - - // Look for any graphics expose - GdkEvent* event; - while ((event = gdk_event_get_graphics_expose(wi->window)) != NULL) { - gtk_widget_event(wi, event); - if (event->expose.count == 0) { - gdk_event_free(event); - break; - } - gdk_event_free(event); - } - - gdk_gc_unref(gc); -#else gdk_window_scroll(wi->window, 0, -diff); gdk_window_process_updates(wi->window, FALSE); -#endif } void ScintillaGTK::SetVerticalScrollPos() { @@ -1283,37 +1021,21 @@ void ScintillaGTK::ReconfigureScrollBars() { } void ScintillaGTK::NotifyChange() { -#if GLIB_MAJOR_VERSION < 2 - gtk_signal_emit(GTK_OBJECT(sci), scintilla_signals[COMMAND_SIGNAL], - Platform::LongFromTwoShorts(GetCtrlID(), SCEN_CHANGE), PWidget(wMain)); -#else g_signal_emit(G_OBJECT(sci), scintilla_signals[COMMAND_SIGNAL], 0, Platform::LongFromTwoShorts(GetCtrlID(), SCEN_CHANGE), PWidget(wMain)); -#endif } void ScintillaGTK::NotifyFocus(bool focus) { -#if GLIB_MAJOR_VERSION < 2 - gtk_signal_emit(GTK_OBJECT(sci), scintilla_signals[COMMAND_SIGNAL], - Platform::LongFromTwoShorts - (GetCtrlID(), focus ? SCEN_SETFOCUS : SCEN_KILLFOCUS), PWidget(wMain)); -#else g_signal_emit(G_OBJECT(sci), scintilla_signals[COMMAND_SIGNAL], 0, Platform::LongFromTwoShorts (GetCtrlID(), focus ? SCEN_SETFOCUS : SCEN_KILLFOCUS), PWidget(wMain)); -#endif } void ScintillaGTK::NotifyParent(SCNotification scn) { scn.nmhdr.hwndFrom = PWidget(wMain); scn.nmhdr.idFrom = GetCtrlID(); -#if GLIB_MAJOR_VERSION < 2 - gtk_signal_emit(GTK_OBJECT(sci), scintilla_signals[NOTIFY_SIGNAL], - GetCtrlID(), &scn); -#else g_signal_emit(G_OBJECT(sci), scintilla_signals[NOTIFY_SIGNAL], 0, GetCtrlID(), &scn); -#endif } void ScintillaGTK::NotifyKey(int key, int modifiers) { @@ -1398,9 +1120,6 @@ CaseFolder *ScintillaGTK::CaseFolderForEncoding() { } std::string ScintillaGTK::CaseMapString(const std::string &s, int caseMapping) { -#if GTK_MAJOR_VERSION < 2 - return Editor::CaseMapString(s, caseMapping); -#else if (s.size() == 0) return std::string(); @@ -1444,7 +1163,6 @@ std::string ScintillaGTK::CaseMapString(const std::string &s, int caseMapping) { delete []needsFree1; delete []needsFree2; return ret; -#endif } int ScintillaGTK::KeyDefault(int key, int modifiers) { @@ -1512,17 +1230,10 @@ void ScintillaGTK::CreateCallTipWindow(PRectangle rc) { ct.wDraw = gtk_drawing_area_new(); GtkWidget *widcdrw = PWidget(ct.wDraw); // // No code inside the G_OBJECT macro gtk_container_add(GTK_CONTAINER(PWidget(ct.wCallTip)), widcdrw); -#if GLIB_MAJOR_VERSION < 2 - gtk_signal_connect(GTK_OBJECT(widcdrw), "expose_event", - GtkSignalFunc(ScintillaGTK::ExposeCT), &ct); - gtk_signal_connect(GTK_OBJECT(widcdrw), "button_press_event", - GtkSignalFunc(ScintillaGTK::PressCT), static_cast<void *>(this)); -#else g_signal_connect(G_OBJECT(widcdrw), "expose_event", G_CALLBACK(ScintillaGTK::ExposeCT), &ct); g_signal_connect(G_OBJECT(widcdrw), "button_press_event", G_CALLBACK(ScintillaGTK::PressCT), static_cast<void *>(this)); -#endif gtk_widget_set_events(widcdrw, GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK); } @@ -1544,9 +1255,7 @@ void ScintillaGTK::AddToPopUp(const char *label, int cmd, bool enabled) { menuSig, cmd, const_cast<gchar *>(label[0] ? "<Item>" : "<Separator>"), -#if GTK_MAJOR_VERSION >= 2 NULL -#endif }; gtk_item_factory_create_item(GTK_ITEM_FACTORY(popup.GetID()), &itemEntry, this, 1); @@ -1623,16 +1332,13 @@ void ScintillaGTK::GetGtkSelectionText(GtkSelectionData *selectionData, Selectio } else { // UTF-8 dest = Document::TransformLineEnds(&len, data, len, pdoc->eolMode); selText.Set(dest, len, SC_CP_UTF8, 0, isRectangular, false); -#ifdef USE_CONVERTER const char *charSetBuffer = CharacterSetID(); if (!IsUnicodeMode() && *charSetBuffer) { -//fprintf(stderr, "Convert to locale %s\n", CharacterSetID()); - // Convert to locale - dest = ConvertText(&len, selText.s, selText.len, charSetBuffer, "UTF-8", true); - selText.Set(dest, len, pdoc->dbcsCodePage, - vs.styles[STYLE_DEFAULT].characterSet, selText.rectangular, false); + // Convert to locale + dest = ConvertText(&len, selText.s, selText.len, charSetBuffer, "UTF-8", true); + selText.Set(dest, len, pdoc->dbcsCodePage, + vs.styles[STYLE_DEFAULT].characterSet, selText.rectangular, false); } -#endif } } @@ -1710,7 +1416,6 @@ void ScintillaGTK::GetSelection(GtkSelectionData *selection_data, guint info, Se } #endif -#if GTK_MAJOR_VERSION >= 2 // Convert text to utf8 if it isn't already SelectionText *converted = 0; if ((text->codePage != SC_CP_UTF8) && (info == TARGET_UTF8_STRING)) { @@ -1747,64 +1452,6 @@ void ScintillaGTK::GetSelection(GtkSelectionData *selection_data, guint info, Se } delete converted; -#else /* Gtk 1 */ - char *selBuffer = text->s; - - char *tmputf = 0; - if ((info == TARGET_UTF8_STRING) || (info == TARGET_STRING)) { - int len = strlen(selBuffer); -#ifdef USE_CONVERTER - // Possible character set conversion - const char *charSetBuffer = ::CharacterSetID(text->characterSet); - if (info == TARGET_UTF8_STRING) { - //fprintf(stderr, "Copy to clipboard as UTF-8\n"); - if (text->codePage != SC_CP_UTF8) { - // Convert to UTF-8 - //fprintf(stderr, "Convert to UTF-8 from %s\n", charSetBuffer); - tmputf = ConvertText(&len, selBuffer, len, "UTF-8", charSetBuffer, false); - selBuffer = tmputf; - } - } else if (info == TARGET_STRING) { - if (text->codePage == SC_CP_UTF8) { - //fprintf(stderr, "Convert to locale %s\n", charSetBuffer); - // Convert to locale - tmputf = ConvertText(&len, selBuffer, len, charSetBuffer, "UTF-8", true); - selBuffer = tmputf; - } - } -#endif - - // Here is a somewhat evil kludge. - // As I can not work out how to store data on the clipboard in multiple formats - // and need some way to mark the clipping as being stream or rectangular, - // the terminating \0 is included in the length for rectangular clippings. - // All other tested aplications behave benignly by ignoring the \0. - // The #if is here because on Windows cfColumnSelect clip entry is used - // instead as standard indicator of rectangularness (so no need to kludge) -#if PLAT_GTK_WIN32 == 0 - if (text->rectangular) - len++; -#endif - gtk_selection_data_set(selection_data, - (info == TARGET_STRING) ? - static_cast<GdkAtom>(GDK_SELECTION_TYPE_STRING) : atomUTF8, - 8, reinterpret_cast<unsigned char *>(selBuffer), - len); - } else if ((info == TARGET_TEXT) || (info == TARGET_COMPOUND_TEXT)) { - guchar *text; - GdkAtom encoding; - gint format; - gint new_length; - - gdk_string_to_compound_text(reinterpret_cast<char *>(selBuffer), - &encoding, &format, &text, &new_length); - gtk_selection_data_set(selection_data, encoding, format, text, new_length); - gdk_free_compound_text(text); - } - - delete []tmputf; -#endif /* Gtk >= 2 */ - #if PLAT_GTK_WIN32 delete newline_normalized; #endif @@ -1996,11 +1643,7 @@ gint ScintillaGTK::PressThis(GdkEventButton *event) { } catch (...) { errorStatus = SC_STATUS_FAILURE; } -#if GTK_MAJOR_VERSION >= 2 return TRUE; -#else - return FALSE; -#endif } gint ScintillaGTK::Press(GtkWidget *widget, GdkEventButton *event) { @@ -2036,7 +1679,6 @@ gint ScintillaGTK::MouseRelease(GtkWidget *widget, GdkEventButton *event) { // win32gtk and GTK >= 2 use SCROLL_* events instead of passing the // button4/5/6/7 events to the GTK app -#if PLAT_GTK_WIN32 || (GTK_MAJOR_VERSION >= 2) gint ScintillaGTK::ScrollEvent(GtkWidget *widget, GdkEventScroll *event) { ScintillaGTK *sciThis = ScintillaFromWidget(widget); @@ -2113,7 +1755,6 @@ gint ScintillaGTK::ScrollEvent(GtkWidget *widget, } return FALSE; } -#endif gint ScintillaGTK::Motion(GtkWidget *widget, GdkEventMotion *event) { ScintillaGTK *sciThis = ScintillaFromWidget(widget); @@ -2218,11 +1859,9 @@ gboolean ScintillaGTK::KeyThis(GdkEventKey *event) { try { //fprintf(stderr, "SC-key: %d %x [%s]\n", // event->keyval, event->state, (event->length > 0) ? event->string : "empty"); -#if GTK_MAJOR_VERSION >= 2 if (gtk_im_context_filter_keypress(im_context, event)) { return 1; } -#endif if (!event->keyval) { return true; } @@ -2239,10 +1878,6 @@ gboolean ScintillaGTK::KeyThis(GdkEventKey *event) { // This will have to change for Unicode else if (key >= 0xFE00) key = KeyTranslate(key); -#if GTK_MAJOR_VERSION < 2 - else if (!IsUnicodeMode() && (key >= 0x100) && (key < 0x1000)) - key &= 0xff; -#endif bool consumed = false; bool added = KeyDown(key, shift, ctrl, alt, &consumed) != 0; @@ -2272,7 +1907,6 @@ gboolean ScintillaGTK::KeyRelease(GtkWidget *, GdkEventKey * /*event*/) { return FALSE; } -#if GTK_MAJOR_VERSION >= 2 gboolean ScintillaGTK::ExposePreeditThis(GtkWidget *widget, GdkEventExpose *ose) { try { gchar *str; @@ -2388,7 +2022,6 @@ void ScintillaGTK::PreeditChangedThis() { void ScintillaGTK::PreeditChanged(GtkIMContext *, ScintillaGTK *sciThis) { sciThis->PreeditChangedThis(); } -#endif gint ScintillaGTK::StyleSetText(GtkWidget *widget, GtkStyle *, void*) { if (widget->window != NULL) @@ -2402,12 +2035,7 @@ gint ScintillaGTK::RealizeText(GtkWidget *widget, void*) { return FALSE; } -#if GLIB_MAJOR_VERSION < 2 -void ScintillaGTK::Destroy(GtkObject *object) -#else -void ScintillaGTK::Destroy(GObject *object) -#endif -{ +void ScintillaGTK::Destroy(GObject *object) { try { ScintillaObject *scio = reinterpret_cast<ScintillaObject *>(object); // This avoids a double destruction @@ -2417,13 +2045,6 @@ void ScintillaGTK::Destroy(GObject *object) //Platform::DebugPrintf("Destroying %x %x\n", sciThis, object); sciThis->Finalise(); -#if GLIB_MAJOR_VERSION < 2 - if (GTK_OBJECT_CLASS(parent_class)->destroy) - (* GTK_OBJECT_CLASS(parent_class)->destroy)(object); -#else - // IS ANYTHING NEEDED ? -#endif - delete sciThis; scio->pscin = 0; } catch (...) { @@ -2451,13 +2072,11 @@ void ScintillaGTK::Draw(GtkWidget *widget, GdkRectangle *area) { DrawChild(PWidget(sciThis->scrollbarv), area); } -#ifdef INTERNATIONAL_INPUT Point pt = sciThis->PointMainCaret(); pt.y += sciThis->vs.lineHeight - 2; if (pt.x < 0) pt.x = 0; if (pt.y < 0) pt.y = 0; CursorMoved(widget, pt.x, pt.y, sciThis); -#endif } catch (...) { sciThis->errorStatus = SC_STATUS_FAILURE; } @@ -2473,9 +2092,7 @@ gint ScintillaGTK::ExposeTextThis(GtkWidget * /*widget*/, GdkEventExpose *ose) { rcPaint.bottom = ose->area.y + ose->area.height; PLATFORM_ASSERT(rgnUpdate == NULL); -#if GTK_MAJOR_VERSION >= 2 rgnUpdate = gdk_region_copy(ose->region); -#endif PRectangle rcClient = GetClientRectangle(); paintingAllText = rcPaint.Contains(rcClient); Surface *surfaceWindow = Surface::Allocate(); @@ -2518,51 +2135,11 @@ gint ScintillaGTK::Expose(GtkWidget *, GdkEventExpose *ose) { //fprintf(stderr, "Expose %0d,%0d %0d,%0d\n", //ose->area.x, ose->area.y, ose->area.width, ose->area.height); -#if GTK_MAJOR_VERSION < 2 - - paintState = painting; - - rcPaint.left = ose->area.x; - rcPaint.top = ose->area.y; - rcPaint.right = ose->area.x + ose->area.width; - rcPaint.bottom = ose->area.y + ose->area.height; - - PRectangle rcClient = GetClientRectangle(); - paintingAllText = rcPaint.Contains(rcClient); - Surface *surfaceWindow = Surface::Allocate(); - if (surfaceWindow) { - surfaceWindow->Init(PWidget(wMain)->window, PWidget(wMain)); - - // Fill the corner between the scrollbars - if (verticalScrollBarVisible) { - if (horizontalScrollBarVisible && (wrapState == eWrapNone)) { - PRectangle rcCorner = wMain.GetClientPosition(); - rcCorner.left = rcCorner.right - scrollBarWidth + 1; - rcCorner.top = rcCorner.bottom - scrollBarHeight + 1; - //fprintf(stderr, "Corner %0d,%0d %0d,%0d\n", - //rcCorner.left, rcCorner.top, rcCorner.right, rcCorner.bottom); - surfaceWindow->FillRectangle(rcCorner, - vs.styles[STYLE_LINENUMBER].back.allocated); - } - } - - //Paint(surfaceWindow, rcPaint); - surfaceWindow->Release(); - delete surfaceWindow; - } - if (paintState == paintAbandoned) { - // Painting area was insufficient to cover new styling or brace highlight positions - FullPaint(); - } - paintState = notPainting; - -#else - // For GTK+ 2, the text is painted in ExposeText + // The text is painted in ExposeText gtk_container_propagate_expose( GTK_CONTAINER(PWidget(wMain)), PWidget(scrollbarh), ose); gtk_container_propagate_expose( GTK_CONTAINER(PWidget(wMain)), PWidget(scrollbarv), ose); -#endif } catch (...) { errorStatus = SC_STATUS_FAILURE; @@ -2621,13 +2198,6 @@ gint ScintillaGTK::SelectionClear(GtkWidget *widget, GdkEventSelection *selectio return gtk_selection_clear(widget, selection_event); } -#if GTK_MAJOR_VERSION < 2 -gint ScintillaGTK::SelectionNotify(GtkWidget *widget, GdkEventSelection *selection_event) { - //Platform::DebugPrintf("Selection notify\n"); - return gtk_selection_notify(widget, selection_event); -} -#endif - void ScintillaGTK::DragBegin(GtkWidget *, GdkDragContext *) { //Platform::DebugPrintf("DragBegin\n"); } @@ -2770,11 +2340,7 @@ gint ScintillaGTK::PressCT(GtkWidget *widget, GdkEventButton *event, ScintillaGT sciThis->CallTipClick(); } catch (...) { } -#if GTK_MAJOR_VERSION >= 2 return TRUE; -#else - return FALSE; -#endif } gint ScintillaGTK::ExposeCT(GtkWidget *widget, GdkEventExpose * /*ose*/, CallTip *ctip) { @@ -2810,32 +2376,6 @@ static void scintilla_init(ScintillaObject *sci); extern void Platform_Initialise(); extern void Platform_Finalise(); -#if GLIB_MAJOR_VERSION < 2 -GtkType scintilla_get_type() { - static GtkType scintilla_type = 0; - try { - - if (!scintilla_type) { - Platform_Initialise(); - static GtkTypeInfo scintilla_info = { - "Scintilla", - sizeof (ScintillaObject), - sizeof (ScintillaClass), - (GtkClassInitFunc) scintilla_class_init, - (GtkObjectInitFunc) scintilla_init, - (gpointer) NULL, - (gpointer) NULL, - 0 - }; - - scintilla_type = gtk_type_unique(gtk_container_get_type(), &scintilla_info); - } - - } catch (...) { - } - return scintilla_type; -} -#else GType scintilla_get_type() { static GType scintilla_type = 0; try { @@ -2865,12 +2405,9 @@ GType scintilla_get_type() { } return scintilla_type; } -#endif void ScintillaGTK::ClassInit(OBJECT_CLASS* object_class, GtkWidgetClass *widget_class, GtkContainerClass *container_class) { -#if GLIB_MAJOR_VERSION >= 2 Platform_Initialise(); -#endif atomClipboard = gdk_atom_intern("CLIPBOARD", FALSE); atomUTF8 = gdk_atom_intern("UTF8_STRING", FALSE); atomString = GDK_SELECTION_TYPE_STRING; @@ -2881,23 +2418,14 @@ void ScintillaGTK::ClassInit(OBJECT_CLASS* object_class, GtkWidgetClass *widget_ // of the signal handlers here (those that currently attached to wDraw // in Initialise() may require coordinate translation?) -#if GLIB_MAJOR_VERSION < 2 - object_class->destroy = Destroy; -#else object_class->finalize = Destroy; -#endif widget_class->size_request = SizeRequest; widget_class->size_allocate = SizeAllocate; widget_class->expose_event = ExposeMain; -#if GTK_MAJOR_VERSION < 2 - widget_class->draw = Draw; -#endif widget_class->motion_notify_event = Motion; widget_class->button_press_event = Press; widget_class->button_release_event = MouseRelease; -#if PLAT_GTK_WIN32 || (GTK_MAJOR_VERSION >= 2) widget_class->scroll_event = ScrollEvent; -#endif widget_class->key_press_event = KeyPress; widget_class->key_release_event = KeyRelease; widget_class->focus_in_event = FocusIn; @@ -2905,9 +2433,6 @@ void ScintillaGTK::ClassInit(OBJECT_CLASS* object_class, GtkWidgetClass *widget_ widget_class->selection_received = SelectionReceived; widget_class->selection_get = SelectionGet; widget_class->selection_clear_event = SelectionClear; -#if GTK_MAJOR_VERSION < 2 - widget_class->selection_notify_event = SelectionNotify; -#endif widget_class->drag_data_received = DragDataReceived; widget_class->drag_motion = DragMotion; @@ -2924,14 +2449,8 @@ void ScintillaGTK::ClassInit(OBJECT_CLASS* object_class, GtkWidgetClass *widget_ container_class->forall = MainForAll; } -#if GLIB_MAJOR_VERSION < 2 -#define GTK_CLASS_TYPE(c) (c->type) -#define SIG_MARSHAL gtk_marshal_NONE__INT_POINTER -#define MARSHAL_ARGUMENTS GTK_TYPE_INT, GTK_TYPE_POINTER -#else #define SIG_MARSHAL scintilla_marshal_NONE__INT_POINTER #define MARSHAL_ARGUMENTS G_TYPE_INT, G_TYPE_POINTER -#endif static void scintilla_class_init(ScintillaClass *klass) { try { @@ -2939,29 +2458,6 @@ static void scintilla_class_init(ScintillaClass *klass) { GtkWidgetClass *widget_class = (GtkWidgetClass*) klass; GtkContainerClass *container_class = (GtkContainerClass*) klass; -#if GLIB_MAJOR_VERSION < 2 - parent_class = (GtkWidgetClass*) gtk_type_class(gtk_container_get_type()); - - scintilla_signals[COMMAND_SIGNAL] = gtk_signal_new( - "command", - GTK_RUN_LAST, - GTK_CLASS_TYPE(object_class), - GTK_SIGNAL_OFFSET(ScintillaClass, command), - SIG_MARSHAL, - GTK_TYPE_NONE, - 2, MARSHAL_ARGUMENTS); - - scintilla_signals[NOTIFY_SIGNAL] = gtk_signal_new( - SCINTILLA_NOTIFY, - GTK_RUN_LAST, - GTK_CLASS_TYPE(object_class), - GTK_SIGNAL_OFFSET(ScintillaClass, notify), - SIG_MARSHAL, - GTK_TYPE_NONE, - 2, MARSHAL_ARGUMENTS); - gtk_object_class_add_signals(object_class, - reinterpret_cast<unsigned int *>(scintilla_signals), LAST_SIGNAL); -#else GSignalFlags sigflags = GSignalFlags(G_SIGNAL_ACTION | G_SIGNAL_RUN_LAST); scintilla_signals[COMMAND_SIGNAL] = g_signal_new( "command", @@ -2984,7 +2480,7 @@ static void scintilla_class_init(ScintillaClass *klass) { SIG_MARSHAL, G_TYPE_NONE, 2, MARSHAL_ARGUMENTS); -#endif + klass->command = NULL; klass->notify = NULL; @@ -3002,11 +2498,7 @@ static void scintilla_init(ScintillaObject *sci) { } GtkWidget* scintilla_new() { -#if GLIB_MAJOR_VERSION < 2 - return GTK_WIDGET(gtk_type_new(scintilla_get_type())); -#else return GTK_WIDGET(g_object_new(scintilla_get_type(), NULL)); -#endif } void scintilla_set_id(ScintillaObject *sci, uptr_t id) { diff --git a/gtk/makefile b/gtk/makefile index 8e00b1ddb..4227337f0 100644 --- a/gtk/makefile +++ b/gtk/makefile @@ -1,11 +1,10 @@ # Make file for Scintilla on Linux or compatible OS -# Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org> +# Copyright 1998-2010 by Neil Hodgson <neilh@scintilla.org> # The License.txt file describes the conditions under which this software may be distributed. -# This makefile assumes GCC 3.1 is used and changes will be needed to use other compilers. +# This makefile assumes GCC 4.3 is used and changes will be needed to use other compilers. # GNU make does not like \r\n line endings so should be saved to CVS in binary form. -# Builds for GTK+ 2 if available else GTK+ 1. -# To force GTK+ 2 build, define GTK2 on the make command line. -# To force GTK+ 1 build, define GTK1 on the make command line. +# Builds for GTK+ 2 and no longer supports GTK+ 1. +# Also works with ming32-make on Windows. .SUFFIXES: .cxx .c .o .h .a CC = g++ @@ -13,9 +12,11 @@ CCOMP = gcc AR = ar RANLIB = touch +ifndef windir ifeq ($(shell uname),Darwin) RANLIB = ranlib endif +endif COMPLIB=../bin/scintilla.a @@ -37,23 +38,8 @@ else CXXFLAGS=-DNDEBUG -Os $(CXXBASEFLAGS) $(THREADFLAGS) endif -# If explicit setting of GTK1 or GTK2 then use that else look for -# pkg-config which is an OK indication that GTK2 is available -ifdef GTK2 -CONFIGFLAGS:=$(shell pkg-config --cflags gtk+-2.0) -MARSHALLER=scintilla-marshal.o -else -ifdef GTK1 -CONFIGFLAGS:=$(shell gtk-config --cflags) -else -ifneq (,$(findstring /,$(shell whereis pkg-config))) CONFIGFLAGS:=$(shell pkg-config --cflags gtk+-2.0) MARSHALLER=scintilla-marshal.o -else -CONFIGFLAGS:=$(shell gtk-config --cflags) -endif -endif -endif .cxx.o: $(CC) $(CONFIGFLAGS) $(CXXFLAGS) -c $< diff --git a/gtk/scintilla.mak b/gtk/scintilla.mak index d7ca81e0e..9b09b2f86 100644 --- a/gtk/scintilla.mak +++ b/gtk/scintilla.mak @@ -1,16 +1,12 @@ # Make file for GTK+/Scintilla on Windows Visual C++ # Borland C++ does not work -# Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org> +# Copyright 1998-2010 by Neil Hodgson <neilh@scintilla.org> # The License.txt file describes the conditions under which this software may be distributed. -# This makefile is for using Visual C++ with nmake or Borland C++ with make depending on -# the setting of the VENDOR macro. If no VENDOR is defined n the command line then -# the tool used is automatically detected. -# Usage for Microsoft: +# This makefile is for using Visual C++ with nmake. +# Usage: # nmake -f scintilla.mak -# Usage for Borland: -# make -f scintilla.mak -# For debug versions define DEBUG on the command line, for Borland: -# make DEBUG=1 -f scintilla.mak +# For debug versions define DEBUG on the command line: +# nmake DEBUG=1 -f scintilla.mak # The main makefile uses mingw32 gcc and may be more current than this file. .SUFFIXES: .cxx diff --git a/include/ScintillaWidget.h b/include/ScintillaWidget.h index 61650c9e2..7521f4c06 100644 --- a/include/ScintillaWidget.h +++ b/include/ScintillaWidget.h @@ -34,21 +34,13 @@ struct _ScintillaClass { void (* notify) (ScintillaObject *ttt); }; -#if GLIB_MAJOR_VERSION < 2 -GtkType scintilla_get_type (void); -#else GType scintilla_get_type (void); -#endif GtkWidget* scintilla_new (void); void scintilla_set_id (ScintillaObject *sci, uptr_t id); sptr_t scintilla_send_message (ScintillaObject *sci,unsigned int iMessage, uptr_t wParam, sptr_t lParam); void scintilla_release_resources(void); -#if GTK_MAJOR_VERSION < 2 -#define SCINTILLA_NOTIFY "notify" -#else #define SCINTILLA_NOTIFY "sci-notify" -#endif #ifdef __cplusplus } |