From 0dc3b7ae4120b8a7ef052dfa8118672c9434b0dc Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Tue, 6 May 2014 16:51:24 -0500 Subject: [PATCH] Attempt to fix crashes of type reported in TDECRSH-462c534-5e49d10-6c0a952-ef4ca8d-e1a8a91-9c3a359-fc344d2 --- src/qt_qt_wrapper.cpp | 416 +++++++++++++++++++++--------------------- 1 file changed, 210 insertions(+), 206 deletions(-) diff --git a/src/qt_qt_wrapper.cpp b/src/qt_qt_wrapper.cpp index eebcc93..c2b674f 100644 --- a/src/qt_qt_wrapper.cpp +++ b/src/qt_qt_wrapper.cpp @@ -104,26 +104,34 @@ int gtkQtDebug; Atom kipcCommAtom; Atom desktopWindowAtom; +static int argc_fake = 1; +static char** argv_fake; + +static TDEAboutData aboutData("gtk-qt-engine", I18N_NOOP("gtk-qt-engine"), "v0.1", + "GTK Qt theme engine", TDEAboutData::License_GPL, + "(c) 2011-2014, Trinity Desktop Project", + "A Qt theme engine for GTK Applications", "https://www.trinitydesktop.org/", 0); + void setFillPixmap(GdkPixbuf* buf) { if (!gtkQtEnable) return; - + // This code isn't very robust. It doesn't handle depths other than 24 bits. // It sure is fast though! int depth = gdk_pixbuf_get_n_channels(buf) * gdk_pixbuf_get_bits_per_sample(buf); int width = gdk_pixbuf_get_width(buf); int height = gdk_pixbuf_get_height(buf); int excess = gdk_pixbuf_get_rowstride(buf) - (width*3); - + if (depth != 24) return; - + TQImage fillImage(width, height, 32); - + uchar* source = gdk_pixbuf_get_pixels(buf); uchar* dest = fillImage.bits(); - + for (int y=0 ; ysetSingleToolkitEventHandling(false); } } - + if (!gtkQtEnable) return; - + isBaghira = (TQString(tqApp->style().name()).lower() == "baghira"); isKeramik = (TQString(tqApp->style().name()).lower() == "keramik"); isAlloy = (TQString(tqApp->style().name()).lower() == "alloy"); isDomino = (TQString(tqApp->style().name()).lower() == "domino"); isPolyester = (TQString(tqApp->style().name()).lower() == "polyester"); - + if (isDomino) { TQScrollBar sbar(NULL); sbar.setOrientation(Qt::Horizontal); sbar.setValue(1); sbar.resize(200,25); - + TQRect rect = tqApp->style().querySubControlMetrics(TQStyle::CC_ScrollBar, &sbar, TQStyle::SC_ScrollBarGroove); scrollBarSpacingLeft = rect.x(); scrollBarSpacingRight = 200 - rect.x() - rect.width(); } - + // Set Gtk fonts and icons /*setGnomeFonts(); setGnomeIcons();*/ - + if (!cmdLine.contains("xfce-mcs-manager")) { // Get KDE related atoms from the X server kipcCommAtom = XInternAtom ( gdk_x11_get_default_xdisplay() , "KIPC_COMM_ATOM" , false ); desktopWindowAtom = XInternAtom ( gdk_x11_get_default_xdisplay() , "KDE_DESKTOP_WINDOW" , false ); - + // Create a new window, and set the KDE_DESKTOP_WINDOW property on it // This window will then receive events from KDE when the style changes smw = new TQWidget(0,0); @@ -445,18 +446,18 @@ void createTQApp() XChangeProperty(gdk_x11_get_default_xdisplay(), smw->winId(), desktopWindowAtom, desktopWindowAtom, 32, PropModeReplace, (unsigned char *)&data, 1); - + // This filter will intercept those events gdk_window_add_filter( NULL, gdkEventFilter, 0); } - + meepWidgetP = new TQWidget(0); meepWidget = new TQWidget(meepWidgetP); meepSlider = new TQSlider(meepWidget); meepWidget->polish(); - + meepTabBar = new TQTabBar(meepWidget); - + menuBackgroundPixmap = NULL; backgroundTile = meepWidget->paletteBackgroundPixmap(); if (backgroundTile != NULL) @@ -478,6 +479,9 @@ void destroyTQApp() } if (altBackGC != 0) gtk_gc_release(altBackGC); + + free(argv_fake[0]); + free(argv_fake); } GdkFilterReturn gdkEventFilter(GdkXEvent *xevent, GdkEvent *gevent, gpointer data) @@ -491,23 +495,23 @@ GdkFilterReturn gdkEventFilter(GdkXEvent *xevent, GdkEvent *gevent, gpointer dat // As defined in tdelibs/tdecore/kipc.h, 2 = StyleChanged if (event->xclient.data.l[0] != 2) return GDK_FILTER_REMOVE; - + if (gtkQtDebug) printf("StyleChanged IPC message\n"); - + // Find out the new widget style TQString styleName = kdeConfigValue("General", "widgetStyle", ""); TQStyle* style = TQStyleFactory::create(styleName); if (!style) return GDK_FILTER_REMOVE; - + // Tell the TQApplication about this new style tqApp->setStyle(style); - + // Now we need to update GTK's properties setRcProperties(gtkRcStyle, 1); // Rewrite our cache file gtk_rc_reparse_all(); // Tell GTK to parse the cache file - + return GDK_FILTER_REMOVE; } return GDK_FILTER_CONTINUE; @@ -542,7 +546,7 @@ TQString runCommand(const TQString& command) FILE* p = popen(command.latin1(), "r"); if ((p == NULL) || (p < 0)) return TQString(); - + TQString ret; while (!feof(p)) { @@ -552,28 +556,28 @@ TQString runCommand(const TQString& command) ret += buffer; } pclose(p); - + return ret.stripWhiteSpace(); } void initKdeSettings() { kdeSearchPaths.clear(); - + TQString kdeHome = getenv("TDEHOME"); TQString kdeDirs = getenv("TDEDIRS"); TQString kdeDir = getenv("TDEDIR"); - + if (!kdeHome.isEmpty()) kdeSearchPaths.append(kdeHome); kdeSearchPaths.append(runCommand("tde-config --localprefix")); - + if (!kdeDirs.isEmpty()) kdeSearchPaths += TQStringList::split(':', kdeDirs); if (!kdeDir.isEmpty()) kdeSearchPaths.append(kdeDir); kdeSearchPaths.append(runCommand("tde-config --prefix")); - + iconTheme = kdeConfigValue("Icons", "Theme", "crystalsvg"); tde_showIconsOnPushButtons = kdeBoolConfigValue("KDE", "ShowIconsOnPushButtons", false); @@ -581,8 +585,8 @@ void initKdeSettings() alternateBackgroundColour.setRgb(back[0].toInt(), back[1].toInt(), back[2].toInt()); showIconsOnButtons = (kdeConfigValue("KDE", "ShowIconsOnPushButtons", "true").lower() == "true"); - - + + TQString tmp = kdeConfigValue("Toolbar style", "IconText", "true").lower(); if (tmp == "icononly") toolbarStyle = 0; @@ -630,7 +634,7 @@ void drawButton(GdkWindow* window, GtkStyle* style, GtkStateType state, int defa { if (!gtkQtEnable) return; - + if ((w < 1) || (h < 1)) return; @@ -700,19 +704,19 @@ void drawButton(GdkWindow* window, GtkStyle* style, GtkStateType state, int defa TQIconSet buttonIconSet(buttonicon); TQPixmap pixmap(w, h); TQPainter painter(&pixmap); - TQPushButton button(meepWidget); + TQPushButton button(meepWidget); button.setBackgroundOrigin(TQWidget::ParentOrigin); button.setGeometry(x, y, w, h); if (style->rc_style->bg[GTK_STATE_NORMAL].pixel != 0) { button.setPaletteBackgroundColor(gdkColorToTQColor(&style->rc_style->bg[GTK_STATE_NORMAL])); } - + TQStyle::SFlags sflags = stateToSFlags(state); - + if (defaultButton) sflags |= TQStyle::Style_ButtonDefault; button.setDefault(defaultButton); - + painter.fillRect(0, 0, w, h, tqApp->palette().active().background()); button.setText(gwLabel); @@ -722,12 +726,12 @@ void drawButton(GdkWindow* window, GtkStyle* style, GtkStateType state, int defa button.setOn(sflags&TQStyle::Style_On); // This emulates ::drawButton() in the Qt qbutton.cpp file - tqApp->style().drawControl(TQStyle::CE_PushButton, &painter, &button, + tqApp->style().drawControl(TQStyle::CE_PushButton, &painter, &button, TQRect(0,0,w,h), button.palette().active(), sflags); - tqApp->style().drawControl(TQStyle::CE_PushButtonLabel, &painter, &button, - tqApp->style().subRect(TQStyle::SR_PushButtonContents, &button), + tqApp->style().drawControl(TQStyle::CE_PushButtonLabel, &painter, &button, + tqApp->style().subRect(TQStyle::SR_PushButtonContents, &button), button.colorGroup(), sflags); - + GdkPixmap* pix = gdk_pixmap_foreign_new(pixmap.handle()); gdk_draw_drawable(window, style->bg_gc[state], pix, 0, 0, x, y, w, h); g_object_unref(pix); @@ -735,23 +739,23 @@ void drawButton(GdkWindow* window, GtkStyle* style, GtkStateType state, int defa else { TQPixmap pixmap(w, h); TQPainter painter(&pixmap); - TQPushButton button(meepWidget); + TQPushButton button(meepWidget); button.setBackgroundOrigin(TQWidget::ParentOrigin); button.setGeometry(x, y, w, h); if (style->rc_style->bg[GTK_STATE_NORMAL].pixel != 0) button.setPaletteBackgroundColor(gdkColorToTQColor(&style->rc_style->bg[GTK_STATE_NORMAL])); - + TQStyle::SFlags sflags = stateToSFlags(state); - + if (defaultButton) sflags |= TQStyle::Style_ButtonDefault; button.setDefault(defaultButton); painter.fillRect(0, 0, w, h, tqApp->palette().active().background()); - tqApp->style().drawControl(TQStyle::CE_PushButton, &painter, &button, + tqApp->style().drawControl(TQStyle::CE_PushButton, &painter, &button, TQRect(0,0,w,h), button.palette().active(), sflags); - + GdkPixmap* pix = gdk_pixmap_foreign_new(pixmap.handle()); gdk_draw_drawable(window, style->bg_gc[state], pix, 0, 0, x, y, w, h); g_object_unref(pix); @@ -763,7 +767,7 @@ void drawToolbar(GdkWindow* window, GtkStyle* style, GtkStateType state, int x, { if (!gtkQtEnable) return; - + int w1, h1; TQStyle::SFlags sflags = stateToSFlags(state) | TQStyle::Style_Raised; @@ -772,7 +776,7 @@ void drawToolbar(GdkWindow* window, GtkStyle* style, GtkStateType state, int x, // Keramik only draws the toolbar border, and not the gradient // so we also draw a separator, but make sure the line is off the // widget - + if (w > h) { sflags |= TQStyle::Style_Horizontal; @@ -797,7 +801,7 @@ void drawToolbar(GdkWindow* window, GtkStyle* style, GtkStateType state, int x, painter.fillRect(0, 0, w1, h1, TQBrush(TQColor(255,255,255), *backgroundTile)); else painter.fillRect(0, 0, w1, h1, tqApp->palette().active().brush(TQColorGroup::Background)); - + tqApp->style().tqdrawPrimitive(TQStyle::PE_PanelDockWindow, &painter, TQRect(0,0,w1,h1), tqApp->palette().active(),sflags); @@ -818,7 +822,7 @@ void drawMenubar(GdkWindow* window, GtkStyle* style, GtkStateType state, int x, { if (!gtkQtEnable) return; - + int w1, h1; TQStyle::SFlags sflags = stateToSFlags(state); @@ -827,7 +831,7 @@ void drawMenubar(GdkWindow* window, GtkStyle* style, GtkStateType state, int x, // Keramik only draws the toolbar border, and not the gradient // so we also draw a separator, but make sure the line is off the // widget - + if (w > h) { sflags |= TQStyle::Style_Horizontal; @@ -873,7 +877,7 @@ void drawTab(GdkWindow* window, GtkStyle* style, GtkStateType state, int x, int TQPixmap pixmap(w,h); TQPainter painter(&pixmap); - + // GTK doesn't tell us if our tab is on the left, right, or middle of the tabbar // So, let's always assume it's in the middle - it looks pretty TQTab* tab = new TQTab; @@ -886,11 +890,11 @@ void drawTab(GdkWindow* window, GtkStyle* style, GtkStateType state, int x, int painter.fillRect(0, 0, w, h, tqApp->palette().active().brush(TQColorGroup::Background)); tqApp->style().drawControl(TQStyle::CE_TabBarTab, &painter, meepTabBar, TQRect(0,0,w,h), tqApp->palette().active(), sflags, TQStyleOption(tab)); - + GdkPixmap* pix = gdk_pixmap_foreign_new(pixmap.handle()); gdk_draw_drawable(window, style->bg_gc[state], pix, 0, 0, x, y, w, h); g_object_unref(pix); - + meepTabBar->removeTab(tab); } @@ -898,10 +902,10 @@ void drawVLine(GdkWindow* window, GtkStyle* style, GtkStateType state, int x, in { if (!gtkQtEnable) return; - + int width = style->xthickness; int height = abs(ySource-yDest); - + if (width < 2) width = 2; if ((width < 1) || (height < 1)) @@ -925,7 +929,7 @@ void drawHLine(GdkWindow* window, GtkStyle* style, GtkStateType state, int y, in { if (!gtkQtEnable) return; - + int width = abs(xSource-xDest); int height = style->ythickness; @@ -960,7 +964,7 @@ void drawLineEdit(GdkWindow* window, GtkStyle* style, GtkStateType state, int ha TQStyle::SFlags sflags = stateToSFlags(state); if (hasFocus) sflags |= TQStyle::Style_HasFocus; - + painter.fillRect(0, 0, w, h, tqApp->palette().active().base()); tqApp->style().tqdrawPrimitive(TQStyle::PE_PanelLineEdit, &painter, TQRect(0, 0, w, h), tqApp->palette().active(), sflags, TQStyleOption(1,1)); @@ -973,7 +977,7 @@ void drawFrame(GdkWindow* window, GtkStyle* style, GtkStateType state, GtkShadow { if (!gtkQtEnable) return; - + if ((w < 1) || (h < 1)) // Caused crash in gaim file transfers window return; @@ -990,7 +994,7 @@ void drawFrame(GdkWindow* window, GtkStyle* style, GtkStateType state, GtkShadow painter.fillRect(0, 0, w, h, tqApp->palette().active().brush(TQColorGroup::Background)); tqApp->style().tqdrawPrimitive(TQStyle::PE_Panel, &painter, TQRect(0, 0, w, h), tqApp->palette().active(), sflags, TQStyleOption(2,2) ); - + GdkPixmap* pix = gdk_pixmap_foreign_new(pixmap.handle()); gdk_draw_drawable(window, style->bg_gc[state], pix, 0, 0, x, y, w, h); g_object_unref(pix); @@ -1008,7 +1012,7 @@ void drawComboBox(GdkWindow* window, GtkStyle* style, GtkStateType state, int x, TQPainter painter(&pixmap); TQComboBox cb(false, 0); cb.resize(w,h); - + TQStyle::SFlags sflags = stateToSFlags(state); TQStyle::SCFlags scflags = TQStyle::SC_ComboBoxArrow | TQStyle::SC_ComboBoxFrame | TQStyle::SC_ComboBoxListBoxPopup; TQStyle::SCFlags activeflags = TQStyle::SC_None; @@ -1121,7 +1125,7 @@ void drawRadioButton(GdkWindow* window, GtkStyle* style, GtkStateType state, int // We cheat, and draw them over the expected area. int xOffset = (realW - w) / 2; int yOffset = (realH - h) / 2; - + GdkPixmap* pix = gdk_pixmap_foreign_new(pixmap.handle()); gdk_draw_drawable(window, style->bg_gc[state], pix, 0, 0, x - xOffset, y - yOffset, realW, realH); g_object_unref(pix); @@ -1132,7 +1136,7 @@ void drawScrollBarSlider(GdkWindow* window, GtkStyle* style, GtkStateType state, { if (!gtkQtEnable) return; - + if ((w < 1) || (h < 1)) return; @@ -1147,13 +1151,13 @@ void drawScrollBarSlider(GdkWindow* window, GtkStyle* style, GtkStateType state, } TQPixmap pixmap(wCorrected, hCorrected); TQPainter painter(&pixmap); - + TQStyle::SFlags sflags = stateToSFlags(state); if (orientation == GTK_ORIENTATION_HORIZONTAL) sflags |= TQStyle::Style_Horizontal; - + tqApp->style().tqdrawPrimitive(TQStyle::PE_ScrollBarSlider, &painter, TQRect(0,0,wCorrected,hCorrected), tqApp->palette().active(), sflags); - + // The domino style doesn't draw the entire slider in PE_ScrollBarSlider // We have to draw PE_ScrollBarAddPage and PE_ScrollBarSubPage and piece the bits together if (isDomino && !mozillaFix && !eclipseFix) @@ -1174,14 +1178,14 @@ void drawScrollBarSlider(GdkWindow* window, GtkStyle* style, GtkStateType state, leftPix.resize(w, 6 + leftRect.height()); rightPix.resize(w, 6 + rightRect.height()); } - + TQPainter dominoPainter(&leftPix); tqApp->style().tqdrawPrimitive(TQStyle::PE_ScrollBarSubPage, &dominoPainter, leftRect, tqApp->palette().active(), sflags); - + dominoPainter.end(); dominoPainter.begin(&rightPix); tqApp->style().tqdrawPrimitive(TQStyle::PE_ScrollBarAddPage, &dominoPainter, rightRect, tqApp->palette().active(), sflags); - + if (orientation == GTK_ORIENTATION_HORIZONTAL) { bitBlt(TQT_TQPAINTDEVICE(&pixmap), 1, 0, TQT_TQPAINTDEVICE(&leftPix), leftRect.width(), 0, 6, h, Qt::CopyROP, true); @@ -1193,9 +1197,9 @@ void drawScrollBarSlider(GdkWindow* window, GtkStyle* style, GtkStateType state, bitBlt(TQT_TQPAINTDEVICE(&pixmap), 0, h-7, TQT_TQPAINTDEVICE(&rightPix), 0, 0, w, 7, Qt::CopyROP, true); } } - + GdkPixmap* pix = gdk_pixmap_foreign_new(pixmap.handle()); - + if (isDomino) { int endsSkip = mozillaFix ? 7 : 1; @@ -1213,14 +1217,14 @@ void drawScrollBar(GdkWindow* window, GtkStyle* style, GtkStateType state, int o { if (!gtkQtEnable) return; - + if ((w < 1) || (h < 1)) return; if (scrollBar != 0) delete scrollBar; scrollBar = new TQScrollBar(NULL); - + scrollBar->resize(w,h); // Patch from Chad Kitching @@ -1229,19 +1233,19 @@ void drawScrollBar(GdkWindow* window, GtkStyle* style, GtkStateType state, int o // another check for mozilla is step_increment and page_increment // are set to zero for mozilla, and have values set by all other // gtk applications I've tested this with. - + // Why oh why couldn't mozilla use native widgets instead of // handling everything in cross platform. - + scrollBar->setOrientation(orientation ? Qt::Vertical : Qt::Horizontal); - - + + TQStyle::SFlags sflags = stateToSFlags(state); if (sflags |= TQStyle::Style_Down) sflags = TQStyle::Style_Enabled; if (orientation == GTK_ORIENTATION_HORIZONTAL) sflags |= TQStyle::Style_Horizontal; - + TQPixmap pixmap(w,h); - + scrollBar->setMinValue(0); scrollBar->setMaxValue(65535); scrollBar->setValue(32767); @@ -1259,7 +1263,7 @@ void drawScrollBar(GdkWindow* window, GtkStyle* style, GtkStateType state, int o thumbSize = r.height(); if (thumbSize < 0) thumbSize = -thumbSize; - + if (!r.isValid()) // Fix a crash bug in Eclipse where it was trying to draw tiny scrollbars. return; @@ -1287,7 +1291,7 @@ void drawScrollBar(GdkWindow* window, GtkStyle* style, GtkStateType state, int o if (!r.isValid()) // Fix a crash bug in Eclipse when it was trying to draw tiny scrollbars. return; - + TQPixmap tmpPixmap(w + thumbSize, h); TQPainter painter2(&tmpPixmap); scrollBar->resize(w + thumbSize, h); @@ -1302,7 +1306,7 @@ void drawScrollBar(GdkWindow* window, GtkStyle* style, GtkStateType state, int o bitBlt(&pixmap, offset, 0, &tmpPixmap, offset + thumbSize, 0, w - offset, h, Qt::CopyROP); } - + GdkPixmap* pix = gdk_pixmap_foreign_new(pixmap.handle()); gdk_draw_drawable(window, style->bg_gc[state], pix, 0, 0, x, y, w, h); g_object_unref(pix); @@ -1318,11 +1322,11 @@ void drawToolButton(GdkWindow* window, GtkStyle* style, GtkStateType state, int TQToolButton button(NULL); button.resize(w, h); - - /* + + /* int realW = button.sizeHint().width(); int realH = button.sizeHint().height(); */ - + TQStyle::SFlags sflags = stateToSFlags(state); TQStyle::SCFlags activeflags = TQStyle::SC_None; if (state == GTK_STATE_ACTIVE) @@ -1332,10 +1336,10 @@ void drawToolButton(GdkWindow* window, GtkStyle* style, GtkStateType state, int } else sflags |= TQStyle::Style_AutoRaise | TQStyle::Style_Raised; - + TQPixmap pixmap(w,h); TQPainter painter(&pixmap); - + if ((backgroundTile) && (!backgroundTile->isNull())) painter.fillRect(0, 0, w, h, TQBrush(TQColor(255,255,255), *backgroundTile)); else @@ -1359,11 +1363,11 @@ void drawMenuBarItem(GdkWindow* window, GtkStyle* style, GtkStateType state, int TQPainter painter(&pixmap); TQMenuItem mi; TQMenuBar mb(0); - + TQStyle::SFlags sflags = TQStyle::Style_Down | TQStyle::Style_Enabled | TQStyle::Style_Active | TQStyle::Style_HasFocus; tqApp->style().drawControl(TQStyle::CE_MenuBarItem, &painter, &mb, TQRect(0, 0, w, h), tqApp->palette().active(), sflags, TQStyleOption(&mi)); - + GdkPixmap* pix = gdk_pixmap_foreign_new(pixmap.handle()); gdk_draw_drawable(window, style->bg_gc[state], pix, 0, 0, x, y, w, h); g_object_unref(pix); @@ -1421,12 +1425,12 @@ void drawTabFrame(GdkWindow* window, GtkStyle* style, GtkStateType state, int x, { if (!gtkQtEnable) return; - + if ((w < 1) || (h < 1)) return; TQStyle::SFlags sflags = stateToSFlags(state); - + TQPixmap pixmap(w, h); TQPainter painter(&pixmap); TQStyleOption opt(2, 2); // line width @@ -1436,15 +1440,15 @@ void drawTabFrame(GdkWindow* window, GtkStyle* style, GtkStateType state, int x, else painter.fillRect(0, 0, w, h, tqApp->palette().active().brush(TQColorGroup::Background)); tqApp->style().tqdrawPrimitive(TQStyle::PE_PanelTabWidget, &painter, TQRect(0,0,w,h), tqApp->palette().active(), sflags, opt); - + GdkPixmap* pix = gdk_pixmap_foreign_new(pixmap.handle()); gdk_draw_drawable(window, style->bg_gc[state], pix, 0, 0, x, y, w, h); g_object_unref(pix); - + // Drawing tab base int th = tqApp->style().pixelMetric(TQStyle::PM_TabBarBaseHeight, meepTabBar); int tw = w; - + if ((tw < 1) || (th < 1)) return; @@ -1454,7 +1458,7 @@ void drawTabFrame(GdkWindow* window, GtkStyle* style, GtkStateType state, int x, painter1.fillRect(0, 0, tw, th, TQBrush(TQColor(255,255,255), *backgroundTile)); else painter1.fillRect(0, 0, tw, th, tqApp->palette().active().brush(TQColorGroup::Background)); - + tqApp->style().tqdrawPrimitive(TQStyle::PE_TabBarBase, &painter1, TQRect(0, 0, tw, th), tqApp->palette().active(), sflags, TQStyleOption(1,1)); if (pos == GTK_POS_BOTTOM) @@ -1462,7 +1466,7 @@ void drawTabFrame(GdkWindow* window, GtkStyle* style, GtkStateType state, int x, TQWMatrix m; m.scale(1, -1); pixmap1 = pixmap1.xForm(m); - + GdkPixmap* pix = gdk_pixmap_foreign_new(pixmap1.handle()); gdk_draw_drawable(window, style->bg_gc[state], pix, 0, 0, x, y+h+tqApp->style().pixelMetric(TQStyle::PM_TabBarBaseOverlap, meepTabBar), tw, th); g_object_unref(pix); @@ -1479,7 +1483,7 @@ void drawMenu(GdkWindow* window, GtkStyle* style, GtkStateType state, int x, int { if (!gtkQtEnable) return; - + if ((w < 1) || (h < 1)) return; @@ -1517,10 +1521,10 @@ void drawProgressChunk(GdkWindow * window, GtkStyle * style, GtkStateType state, // This is only for Mozilla/Firefox if (!mozillaFix || !gtkQtEnable) return; - + if ((w<=1) || (h<=1)) return; // Trying to draw something that small caused a segfault - + // Dirty hack: When using the Alloy style, tweak the position and size of progress bar "filling" int w2 = isAlloy ? w+4 : w; int h2 = isAlloy ? h+4 : h; @@ -1531,7 +1535,7 @@ void drawProgressChunk(GdkWindow * window, GtkStyle * style, GtkStateType state, bar.setCenterIndicator(false); bar.setPercentageVisible(false); bar.setFrameStyle(TQFrame::NoFrame); - + if ((w2 < 1) || (h2 < 1)) return; @@ -1539,7 +1543,7 @@ void drawProgressChunk(GdkWindow * window, GtkStyle * style, GtkStateType state, TQPainter painter(&pixmap); TQStyle::SFlags sflags = stateToSFlags(state); - + painter.fillRect(0, 0, w, h, tqApp->palette().active().brush(TQColorGroup::Background)); tqApp->style().drawControl(TQStyle::CE_ProgressBarContents, &painter, &bar, TQRect(0,0,w2,h2), tqApp->palette().active(), sflags); @@ -1556,10 +1560,10 @@ void drawProgressBar(GdkWindow * window, GtkStyle * style, GtkStateType state, G { if (!gtkQtEnable) return; - + if ((w<=1) || (h<=1)) return; // Trying to draw something that small caused a segdault - + TQProgressBar bar(100, NULL); if ((orientation == GTK_PROGRESS_BOTTOM_TO_TOP) || (orientation == GTK_PROGRESS_TOP_TO_BOTTOM)) bar.resize(h, w); @@ -1570,7 +1574,7 @@ void drawProgressBar(GdkWindow * window, GtkStyle * style, GtkStateType state, G bar.setPercentageVisible(false); TQPixmap pixmap = TQPixmap::grabWidget(&bar); - + TQWMatrix matrix; switch (orientation) { @@ -1579,10 +1583,10 @@ void drawProgressBar(GdkWindow * window, GtkStyle * style, GtkStateType state, G case GTK_PROGRESS_TOP_TO_BOTTOM: matrix.rotate(90); break; default: break; } - + if (orientation != GTK_PROGRESS_LEFT_TO_RIGHT) pixmap = pixmap.xForm(matrix); - + GdkPixmap* pix = gdk_pixmap_foreign_new(pixmap.handle()); gdk_draw_drawable(window, style->bg_gc[state], pix, 0, 0, x, y, w, h); g_object_unref(pix); @@ -1594,14 +1598,14 @@ void drawSlider(GdkWindow * window, GtkStyle * style, GtkStateType state, GtkAdj return; meepSlider->setBackgroundOrigin(TQWidget::ParentOrigin); - + meepSlider->setOrientation((orientation == GTK_ORIENTATION_HORIZONTAL) ? Qt::Horizontal : Qt::Vertical); meepSlider->setEnabled(state != GTK_STATE_INSENSITIVE); meepSlider->setGeometry(x, y, w, h); meepSlider->setMinValue(0); meepSlider->setMaxValue(100); - + if (!inverted) // Normal sliders meepSlider->setValue((int)((adj->value-adj->lower)/(adj->upper-adj->lower)*100)); else // Inverted sliders... where max is at the left/top and min is at the right/bottom @@ -1617,7 +1621,7 @@ void drawSpinButton(GdkWindow * window, GtkStyle * style, GtkStateType state, in { if (!gtkQtEnable) return; - + if ((w < 1) || (h < 1)) return; @@ -1625,10 +1629,10 @@ void drawSpinButton(GdkWindow * window, GtkStyle * style, GtkStateType state, in TQPainter painter(&pixmap); TQStyle::SFlags sflags = stateToSFlags(state); - + painter.fillRect(0, 0, w, h, tqApp->palette().active().brush(TQColorGroup::Background)); tqApp->style().tqdrawPrimitive((direction ? TQStyle::PE_SpinWidgetDown : TQStyle::PE_SpinWidgetUp), &painter, TQRect(0,0,w,h), tqApp->palette().active(), sflags); - + GdkPixmap* pix = gdk_pixmap_foreign_new(pixmap.handle()); gdk_draw_drawable(window, style->bg_gc[state], pix, 0, 0, x, y, w, h); g_object_unref(pix); @@ -1686,7 +1690,7 @@ void drawSquareButton(GdkWindow* window, GtkStyle* style, GtkStateType state, in TQPixmap pixmap(20, 20); TQPainter painter(&pixmap); TQPushButton button(0); - + TQStyle::SFlags sflags = stateToSFlags(state); if (fillPixmap && (!fillPixmap->isNull())) painter.fillRect(0, 0, 20, 20, TQBrush(TQColor(255,255,255), *fillPixmap)); @@ -1694,10 +1698,10 @@ void drawSquareButton(GdkWindow* window, GtkStyle* style, GtkStateType state, in painter.fillRect(0, 0, 20, 20, TQBrush(TQColor(255,255,255), *backgroundTile)); else painter.fillRect(0, 0, 20, 20, tqApp->palette().active().brush(TQColorGroup::Background)); - + tqApp->style().drawControl(TQStyle::CE_PushButton, &painter, &button, TQRect(0,0,20,20), tqApp->palette().active(), sflags); - + TQImage image = pixmap.convertToImage().smoothScale(w,h); GdkPixmap* pix = gdk_pixmap_foreign_new(pixmap.handle()); @@ -1709,14 +1713,14 @@ void initDrawTabNG(int count) { if (!gtkQtEnable) return; - + delete meepTabBar; meepTabBar = 0; meepTabBar = new TQTabBar(meepWidget); - + for ( int i = 0; i < count; i++ ) meepTabBar->addTab(new TQTab); - + return; } @@ -1724,9 +1728,9 @@ void drawTabNG(GdkWindow *window, GtkStyle* style, GtkStateType state, int x, in { if (!gtkQtEnable) return; - + GtkPositionType tpos = gtk_notebook_get_tab_pos(notebook); - + // Find tab position int sdiff = 10000, pos = -1, diff = 1; for ( unsigned int i = 0; i < g_list_length(notebook->children); i++ ) @@ -1738,9 +1742,9 @@ void drawTabNG(GdkWindow *window, GtkStyle* style, GtkStateType state, int x, in sdiff = diff; pos = i; } } - + TQTab *tab = meepTabBar->tabAt(pos); - + if (!tab) { // This happens in Firefox. Just draw a normal tab instead @@ -1750,9 +1754,9 @@ void drawTabNG(GdkWindow *window, GtkStyle* style, GtkStateType state, int x, in drawTab(window, style, state, x, y, w, h); return; } - + TQStyle::SFlags sflags = stateToSFlags(state); - + if (state != GTK_STATE_ACTIVE) { sflags = TQStyle::Style_Selected; @@ -1760,20 +1764,20 @@ void drawTabNG(GdkWindow *window, GtkStyle* style, GtkStateType state, int x, in y += 3; h -= 3; } - + if ((w < 1) || (h < 1)) return; TQPixmap pixmap(w,h); TQPainter painter(&pixmap); - + if ((backgroundTile) && (!backgroundTile->isNull())) painter.fillRect(0, 0, w, h, TQBrush(TQColor(255,255,255), *backgroundTile)); else - + painter.fillRect(0, 0, w, h, tqApp->palette().active().brush(TQColorGroup::Background)); tqApp->style().drawControl(TQStyle::CE_TabBarTab, &painter, (TQTabBar *)meepTabBar, TQRect(0,0,w,h), tqApp->palette().active(), sflags, TQStyleOption(tab)); - + painter.end(); // So the pixmap assignment below won't give an error // Account for tab position -- if its in the bottom flip the image if (tpos == GTK_POS_BOTTOM) @@ -1782,7 +1786,7 @@ void drawTabNG(GdkWindow *window, GtkStyle* style, GtkStateType state, int x, in m.scale(1, -1); pixmap = pixmap.xForm(m); } - + GdkPixmap* pix = gdk_pixmap_foreign_new(pixmap.handle()); gdk_draw_drawable(window, style->bg_gc[state], pix, 0, 0, x, y, w, h); g_object_unref(pix); @@ -1792,7 +1796,7 @@ void drawArrow(GdkWindow* window, GtkStyle* style, GtkStateType state, GtkArrowT { if (!gtkQtEnable) return; - + if ((w < 1) || (h < 1)) return; @@ -1813,7 +1817,7 @@ void drawArrow(GdkWindow* window, GtkStyle* style, GtkStateType state, GtkArrowT default: return; } - + TQPixmap pixmap(w,h); TQPainter painter(&pixmap); @@ -1835,7 +1839,7 @@ void drawFocusRect(GdkWindow * window, GtkStyle * style, int x, int y, int w, in { // if (!gtkQtEnable) return; - + if ((w < 1) || (h < 1)) return; @@ -1856,21 +1860,21 @@ GdkGC* alternateBackgroundGc(GtkStyle* style) // Alternate background color for listviews if (altBackGC != 0) return altBackGC; - + GdkColor altBackColor; altBackColor.red = alternateBackgroundColour.red() * 257; altBackColor.green = alternateBackgroundColour.green() * 257; altBackColor.blue = alternateBackgroundColour.blue() * 257; - + gdk_colormap_alloc_color(style->colormap, &altBackColor, FALSE, TRUE); - + GdkGCValues gc_values; GdkGCValuesMask gc_values_mask; gc_values_mask = GDK_GC_FOREGROUND; gc_values.foreground = altBackColor; - + altBackGC = (GdkGC*) gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask); - + return altBackGC; } @@ -1880,7 +1884,7 @@ TQString parse_rc_string(const TQString& defs, const TQString& pattern, bool wid { static int dynamic_counter = 0; ++dynamic_counter; - + return "style \"gtk-qt-dynamic-" + TQString::number(dynamic_counter) + "\" { " + defs + " } " + (widgetClass ? "widget_class" : "widget") + " \"" + pattern + "\" style \"gtk-qt-dynamic-" + TQString::number(dynamic_counter) + "\"\n"; } @@ -1905,10 +1909,10 @@ TQString doIconMapping(const TQString& stockName, const TQString& path, int size } if (!has16 && !has22 && !has32) return ""; - + // sizes is an addition of 1=16, 2=22 and 4=32 TQString ret = "stock[\"" + stockName + "\"]={\n"; - + if (has22) ret += "\t{ \"22x22/" + path +"\", *, *, \"gtk-large-toolbar\" },\n"; @@ -1924,14 +1928,14 @@ TQString doIconMapping(const TQString& stockName, const TQString& path, int size ret += "\t{ \"16x16/" + path +"\", *, *, \"gtk-menu\" },\n"; ret += "\t{ \"16x16/" + path +"\", *, *, \"gtk-small-toolbar\" },\n"; } - + if (has22) ret += "\t{ \"22x22/" + path +"\" }\n"; else if (has32) ret += "\t{ \"32x32/" + path +"\" }\n"; else ret += "\t{ \"16x16/" + path +"\" }\n"; - + ret += "}\n"; return ret; } @@ -1942,7 +1946,7 @@ TQString colorString(TQColor color) ret += TQString::number(color.red() * 257) + ", "; ret += TQString::number(color.green() * 257) + ", "; ret += TQString::number(color.blue() * 257) + "}"; - + return ret; } @@ -1977,37 +1981,37 @@ void setRcProperties(GtkRcStyle* rc_style, int forceRecreate) { if (!gtkQtEnable) return; - + if (gtkQtDebug) printf("setRcProperties()\n"); - + gtkRcStyle = rc_style; - + // Set colors // Normal setColour("fg[NORMAL]", tqApp->palette().active().text()); setColour("bg[NORMAL]", tqApp->palette().active().background()); setColour("text[NORMAL]", tqApp->palette().active().text()); setColour("base[NORMAL]", tqApp->palette().active().base()); - + // Active (on) setColour("fg[ACTIVE]", tqApp->palette().active().text()); setColour("bg[ACTIVE]", tqApp->palette().active().background()); setColour("text[ACTIVE]", tqApp->palette().active().text()); setColour("base[ACTIVE]", tqApp->palette().active().base()); - + // Mouseover setColour("fg[PRELIGHT]", tqApp->palette().active().text()); // menu items - change? setColour("bg[PRELIGHT]", tqApp->palette().active().highlight()); setColour("text[PRELIGHT]", tqApp->palette().active().text()); setColour("base[PRELIGHT]", tqApp->palette().active().base()); - + // Selected setColour("fg[SELECTED]", tqApp->palette().active().highlightedText()); setColour("bg[SELECTED]", tqApp->palette().active().highlight()); setColour("text[SELECTED]", tqApp->palette().active().highlightedText()); setColour("base[SELECTED]", tqApp->palette().active().highlight()); - + // Disabled setColour("fg[INSENSITIVE]", tqApp->palette().disabled().text()); setColour("bg[INSENSITIVE]", tqApp->palette().disabled().background()); @@ -2015,22 +2019,22 @@ void setRcProperties(GtkRcStyle* rc_style, int forceRecreate) setColour("base[INSENSITIVE]", tqApp->palette().disabled().background()); gtk_rc_parse_string(("gtk-button-images = " + TQString::number(showIconsOnButtons)).latin1()); - + gtk_rc_parse_string(("gtk-toolbar-style = " + TQString::number(toolbarStyle)).latin1()); - + // This function takes quite a long time to execute, and is run at the start of every app. // In order to speed it up, we can store the results in a file, along with the name of icon // theme and style. This file can then be regenerated when the icon theme or style change. - + TQString cacheFilePath = TDEGlobal::dirs()->saveLocation("cache")+"/gtk_qt_engine_rc"; TQFile cacheFile(cacheFilePath); TQTextStream stream; - + if (!forceRecreate && cacheFile.exists()) { cacheFile.open(IO_ReadOnly); stream.setDevice(TQT_TQIODEVICE(&cacheFile)); - + if (stream.readLine() == "# " + iconTheme + ", " + tqApp->style().name() + ", " + RC_CACHE_VERSION) { // This cache matches the current icon theme and style @@ -2038,33 +2042,33 @@ void setRcProperties(GtkRcStyle* rc_style, int forceRecreate) gtk_rc_add_default_file(cacheFilePath.latin1()); return; } - + stream.unsetDevice(); cacheFile.close(); } - + cacheFile.open(IO_WriteOnly | IO_Truncate); stream.setDevice(TQT_TQIODEVICE(&cacheFile)); - + stream << "# " << iconTheme << ", " << tqApp->style().name() << ", " << RC_CACHE_VERSION << "\n\n"; stream << "# This file was generated by the Gtk Qt Theme Engine\n"; stream << "# It will be recreated when you change your KDE icon theme or widget style\n\n"; - + TQScrollBar sbar(NULL); sbar.setOrientation(Qt::Horizontal); sbar.setValue(1); sbar.resize(200,25); - + // The following code determines how many buttons are on a scrollbar // It works by looking at each pixel of the scrollbar's area not taken up by the groove, // and asking the style which subcontrol is at that location. TQRect rect = tqApp->style().querySubControlMetrics(TQStyle::CC_ScrollBar, &sbar, TQStyle::SC_ScrollBarGroove); - + bool back1 = false; bool forward1 = false; bool back2 = false; bool forward2 = false; - + TQStyle::SubControl sc = TQStyle::SC_None; for (TQPoint pos(0,7) ; pos.x()style().polish(&pm); - + TQStyleOption opt(mi, 16, 16); TQStyle::SFlags sflags = TQStyle::Style_Default; - + if ((backgroundTile) && (!backgroundTile->isNull())) painter.fillRect(0, 0, 1024, 25, TQBrush(TQColor(255,255,255), *backgroundTile)); else painter.fillRect(0, 0, 1024, 25, tqApp->palette().active().brush(TQColorGroup::Background)); tqApp->style().drawControl(TQStyle::CE_PopupMenuItem, &painter, &pm, TQRect(0,0,1024,25), tqApp->palette().active(), sflags, opt); - + menuBackgroundPixmapGdk = gdk_pixmap_foreign_new(menuBackgroundPixmap->handle()); } @@ -2336,12 +2340,12 @@ void setColors(GtkStyle* style) { if (!gtkQtEnable) return; - + if (gtkQtDebug) printf("setColors()\n"); - + /*gtkStyle = style;*/ - + bool useBg = ((backgroundTile) && (!backgroundTile->isNull())); if (useBg) @@ -2349,7 +2353,7 @@ void setColors(GtkStyle* style) style->bg_pixmap[GTK_STATE_NORMAL] = backgroundTileGdk; g_object_ref(backgroundTileGdk); } - + setMenuBackground(style); } @@ -2357,7 +2361,7 @@ void getTextColor(GdkColor *color, GtkStateType state_type) { if (!gtkQtEnable) return; - + if ((state_type == GTK_STATE_PRELIGHT) || (state_type == GTK_STATE_ACTIVE) || (state_type == GTK_STATE_SELECTED)) setColour(color, tqApp->palette().active().highlightedText()); else if (state_type == GTK_STATE_NORMAL)