diff options
Diffstat (limited to 'gtk/PlatGTK.cxx')
-rw-r--r-- | gtk/PlatGTK.cxx | 287 |
1 files changed, 8 insertions, 279 deletions
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 } |