diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2011-10-19 02:53:52 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2011-10-19 02:53:52 +0000 |
commit | 94a5414c7b3366cf894af40079d5ede1c6e17518 (patch) | |
tree | 88fd89e703fc1659abeee7522e6177751e7bc28a /src | |
parent | 2ce5b382990085bcce1ba3ec48536ae16fa2e4bc (diff) | |
download | gtk-qt-engine-94a5414c7b3366cf894af40079d5ede1c6e17518.tar.gz gtk-qt-engine-94a5414c7b3366cf894af40079d5ede1c6e17518.zip |
Fix up a number of GTK/Qt theme engine problems
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/gtk-qt-engine@1259595 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'src')
-rw-r--r-- | src/CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/qt_qt_wrapper.cpp | 306 | ||||
-rw-r--r-- | src/qt_qt_wrapper.h | 5 | ||||
-rw-r--r-- | src/qt_theme_draw.c | 96 |
4 files changed, 309 insertions, 100 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 32bb6cf..d2e5c03 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -11,7 +11,7 @@ ADD_LIBRARY(qtengine SHARED ${GTK-QT-SOURCES}) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GTK_CFLAGS} ${BONOBO_CFLAGS}") SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${GTK_CFLAGS} ${BONOBO_CFLAGS}") -TARGET_LINK_LIBRARIES(qtengine ${GTK_LINK_FLAGS} ${BONOBO_LINK_FLAGS} ${TQT_LIBRARIES} -lX11) +TARGET_LINK_LIBRARIES(qtengine ${GTK_LINK_FLAGS} ${BONOBO_LINK_FLAGS} ${TQT_LIBRARIES} -lX11 -lkdecore) INSTALL( TARGETS qtengine diff --git a/src/qt_qt_wrapper.cpp b/src/qt_qt_wrapper.cpp index 7379888..90e060a 100644 --- a/src/qt_qt_wrapper.cpp +++ b/src/qt_qt_wrapper.cpp @@ -15,9 +15,17 @@ #include <tqapplication.h> #include <tqdir.h> #include <tqregexp.h> +#include <tqbitmap.h> + +#include <kiconloader.h> +#include <kapplication.h> +#include <kcmdlineargs.h> +#include <kaboutdata.h> +#include <kconfig.h> #undef signals #include <gdk/gdkx.h> +#include <gtk/gtk.h> #include <cstdlib> #include <fcntl.h> @@ -44,10 +52,10 @@ #define RC_CACHE_VERSION TQString("1") - bool gtkQtEnable = false; bool mozillaFix = false; bool tqAppOwner = false; +gboolean tde_showIconsOnPushButtons = false; TQStringList appDirList; typedef TQMap<TQString, TQString> IconMap; @@ -161,6 +169,12 @@ void createTQApp() argv = (char**) malloc(sizeof(char*)); argv[0] = (char*) malloc(sizeof(char) * 19); strncpy(argv[0], "gtk-qt-application", 19); + + KAboutData aboutData("gtk-qt-engine", I18N_NOOP("gtk-qt-engine"), "v0.1", + "GTK Qt theme engine", KAboutData::License_GPL, + "(c) 2011, Timothy Pearson", + "message goes here", 0 /* TODO: Website */, "kb9vqf@pearsoncomputing.net"); + KCmdLineArgs::init(argc, argv, &aboutData); TQString cmdLine; @@ -355,14 +369,14 @@ void createTQApp() putenv("SESSION_MANAGER="); #endif - initKdeSettings(); - if (!tqApp) { - new TQApplication(gdk_x11_get_default_xdisplay()); + new KApplication(gdk_x11_get_default_xdisplay()); tqAppOwner = true; } + initKdeSettings(); + #ifndef USE_SOLARIS setenv("SESSION_MANAGER", sessionEnv, 1); #else @@ -488,38 +502,16 @@ GdkFilterReturn gdkEventFilter(GdkXEvent *xevent, GdkEvent *gevent, gpointer dat TQString kdeConfigValue(const TQString& section, const TQString& name, const TQString& def) { - for ( TQStringList::Iterator it = kdeSearchPaths.begin(); it != kdeSearchPaths.end(); ++it ) - { - if (!TQFile::exists((*it) + "/share/config/kdeglobals")) - continue; - - TQFile file((*it) + "/share/config/kdeglobals"); - if (!file.open( IO_ReadOnly )) - continue; - - TQTextStream stream( &file ); - TQString line; - TQString sec; - int i = 1; - while ( !stream.atEnd() ) - { - line = stream.readLine(); - if (line.startsWith("[")) - { - sec = line.mid(1, line.length() - 2); - continue; - } - if (sec != section) - continue; - TQRegExp parser("([\\S]*)\\s*=\\s*([\\S]*)"); - if (parser.search(line) == -1) - continue; - if (parser.cap(1) == name) - return parser.cap(2); - } - file.close(); - } - return def; + KConfig currentConfig; + currentConfig.setGroup(section); + return currentConfig.readEntry(name, def); +} + +bool kdeBoolConfigValue(const TQString& section, const TQString& name, bool def) +{ + KConfig currentConfig; + currentConfig.setGroup(section); + return currentConfig.readBoolEntry(name, def); } TQString kdeFindDir(const TQString& suffix, const TQString& file1, const TQString& file2) @@ -570,6 +562,8 @@ void initKdeSettings() kdeSearchPaths.append(runCommand("kde-config --prefix")); iconTheme = kdeConfigValue("Icons", "Theme", "crystalsvg"); + tde_showIconsOnPushButtons = kdeBoolConfigValue("KDE", "ShowIconsOnPushButtons", false); + TQStringList back = TQStringList::split(',', kdeConfigValue("General", "alternateBackground", "238,246,255")); alternateBackgroundColour.setRgb(back[0].toInt(), back[1].toInt(), back[2].toInt()); @@ -619,7 +613,7 @@ TQColor gdkColorToTQColor(GdkColor* c) // * Paint the pixmap on the window -void drawButton(GdkWindow* window, GtkStyle* style, GtkStateType state, int defaultButton, int x, int y, int w, int h) +void drawButton(GdkWindow* window, GtkStyle* style, GtkStateType state, int defaultButton, int x, int y, int w, int h, GtkButton* gwidget) { if (!gtkQtEnable) return; @@ -627,30 +621,131 @@ void drawButton(GdkWindow* window, GtkStyle* style, GtkStateType state, int defa if ((w < 1) || (h < 1)) return; - TQPixmap pixmap(w, h); - TQPainter painter(&pixmap); - 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])); - TQPoint p = button.backgroundOffset(); - TQPoint pos = button.pos(); - - TQStyle::SFlags sflags = stateToSFlags(state); - - if (defaultButton) - sflags |= TQStyle::Style_ButtonDefault; - button.setDefault(defaultButton); +#ifdef USE_NATIVE_GTK_BUTTON_DRAWING + gwidget = NULL; +#endif - painter.fillRect(0, 0, w, h, tqApp->tqpalette().active().background()); + if (gtkQtDebug) { + GtkWidget* parent; + parent = gtk_widget_get_parent(GTK_WIDGET(gwidget)); + printf("drawButton Parent 1: %s\n",gtk_widget_get_name(parent)); + parent = gtk_widget_get_parent(GTK_WIDGET(parent)); + printf("drawButton Parent 2: %s\n",gtk_widget_get_name(parent)); + parent = gtk_widget_get_parent(GTK_WIDGET(parent)); + printf("drawButton Parent 3: %s\n",gtk_widget_get_name(parent)); + parent = gtk_widget_get_parent(GTK_WIDGET(parent)); + printf("drawButton Parent 4: %s\n",gtk_widget_get_name(parent)); + } - tqApp->tqstyle().tqdrawControl(TQStyle::CE_PushButton, &painter, &button, - TQRect(0,0,w,h), button.tqpalette().active(), sflags); + if (gwidget) { + TQString gwLabel(gtk_button_get_label(gwidget)); + if (gtk_button_get_use_stock(gwidget)) { + GtkStockItem stockData; + gtk_stock_lookup(gwLabel.ascii(), &stockData); + gwLabel = TQString(stockData.label); + } + gwLabel.replace("&", "&&"); + gwLabel.replace("_", "&"); + + TQPixmap buttonicon; + TQBitmap buttonicon_mask; + + GtkWidget* giconwidget = gtk_button_get_image(gwidget); + if (giconwidget) { + GtkIconSize giconSize; + gint iconWidth; + gint iconHeight; + + GtkImageType giconStorageType = gtk_image_get_storage_type(GTK_IMAGE(giconwidget)); + if (giconStorageType == GTK_IMAGE_STOCK) { + gchar *stock_id; + gtk_image_get_stock(GTK_IMAGE(giconwidget), &stock_id, &giconSize); + GdkPixbuf* pixbuf = gtk_widget_render_icon(GTK_WIDGET(gwidget), stock_id, giconSize, NULL); + iconWidth=gdk_pixbuf_get_width(pixbuf); + iconHeight=gdk_pixbuf_get_height(pixbuf); + buttonicon = TQPixmap(iconWidth, iconHeight); + buttonicon_mask = TQBitmap(iconWidth, iconHeight); + buttonicon.fill(tqApp->tqpalette().active().background()); + buttonicon_mask.fill(TQt::color0); + GdkPixmap* pix = gdk_pixmap_foreign_new(buttonicon.handle()); + GdkBitmap* bmp = gdk_pixmap_foreign_new(buttonicon_mask.handle()); + gdk_drawable_set_colormap(pix, gdk_drawable_get_colormap(window)); + gdk_drawable_set_colormap(bmp, gdk_drawable_get_colormap(window)); + gdk_draw_pixbuf(pix, NULL, pixbuf, 0, 0, 0, 0, -1, -1, GDK_RGB_DITHER_NONE, 0, 0); + gdk_pixbuf_render_threshold_alpha(pixbuf, bmp, 0, 0, 0, 0, -1, -1, 128); + buttonicon.setMask(buttonicon_mask); + g_object_unref(pixbuf); + g_object_unref(bmp); + g_object_unref(pix); + } + else { + // FIXME + // Implement pixmap loading here for non-stock icons + } + } - 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); + TQIconSet buttonIconSet(buttonicon); + TQPixmap pixmap(w, h); + TQPainter painter(&pixmap); + 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])); + TQPoint p = button.backgroundOffset(); + TQPoint pos = button.pos(); + + TQStyle::SFlags sflags = stateToSFlags(state); + + if (defaultButton) + sflags |= TQStyle::Style_ButtonDefault; + button.setDefault(defaultButton); + + painter.fillRect(0, 0, w, h, tqApp->tqpalette().active().background()); + + button.setText(gwLabel); + if (tde_showIconsOnPushButtons) + button.setIconSet(buttonIconSet); + button.setDown(sflags&TQStyle::Style_Down); + button.setOn(sflags&TQStyle::Style_On); + + // This emulates ::drawButton() in the Qt qbutton.cpp file + tqApp->tqstyle().tqdrawControl(TQStyle::CE_PushButton, &painter, &button, + TQRect(0,0,w,h), button.tqpalette().active(), sflags); + tqApp->tqstyle().tqdrawControl(TQStyle::CE_PushButtonLabel, &painter, &button, + tqApp->tqstyle().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); + } + else { + TQPixmap pixmap(w, h); + TQPainter painter(&pixmap); + 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])); + TQPoint p = button.backgroundOffset(); + TQPoint pos = button.pos(); + + TQStyle::SFlags sflags = stateToSFlags(state); + + if (defaultButton) + sflags |= TQStyle::Style_ButtonDefault; + button.setDefault(defaultButton); + + painter.fillRect(0, 0, w, h, tqApp->tqpalette().active().background()); + + tqApp->tqstyle().tqdrawControl(TQStyle::CE_PushButton, &painter, &button, + TQRect(0,0,w,h), button.tqpalette().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); + } } // Thanks Peter Hartshorn <peter@dimtech.com.au> @@ -1990,11 +2085,28 @@ void setRcProperties(GtkRcStyle* rc_style, int forceRecreate) stream << parse_rc_string("GtkScrollbar::min-slider-length = " + TQString::number(tqApp->tqstyle().tqpixelMetric(TQStyle::PM_ScrollBarSliderMin)), "*"); stream << parse_rc_string("GtkScrollbar::slider-width = " + TQString::number(tqApp->tqstyle().tqpixelMetric(TQStyle::PM_ScrollBarExtent)-2), "*"); + stream << parse_rc_string("GtkButton::child-displacement-x = " + TQString::number(tqApp->tqstyle().tqpixelMetric(TQStyle::PM_ButtonShiftHorizontal)), "*"); stream << parse_rc_string("GtkButton::child-displacement-y = " + TQString::number(tqApp->tqstyle().tqpixelMetric(TQStyle::PM_ButtonShiftVertical)), "*"); + stream << parse_rc_string("GtkButton::default-border = { 0, 0, 0, 0 }", "*"); + stream << parse_rc_string("GtkButton::default-outside-border = {0, 0, 0, 0}", "*"); +#ifdef USE_NATIVE_GTK_BUTTON_DRAWING + stream << parse_rc_string("GtkButton::inner-border = {0, 0, 0, 0}", "*"); +#else + if (tde_showIconsOnPushButtons) { + stream << parse_rc_string("GtkButton::inner-border = {10, 10, 2, 2}", "*"); // Allow space for the icon on either side of the text + } + else { + stream << parse_rc_string("GtkButton::inner-border = {2, 2, 2, 2}", "*"); + } +#endif + + stream << parse_rc_string("GtkButtonBox::child_min_height = 0", "*"); + stream << parse_rc_string("GtkButtonBox::child_internal_pad_x = 0", "*"); + stream << parse_rc_string("GtkButtonBox::child_internal_pad_y = 0", "*"); + TQSlider slider(NULL); // To keep BlueCurve happy stream << parse_rc_string("GtkScale::slider-length = " + TQString::number(tqApp->tqstyle().tqpixelMetric(TQStyle::PM_SliderLength, &slider)), "*"); - stream << parse_rc_string("GtkButton::default-border = { 0, 0, 0, 0 }", "*"); stream << parse_rc_string("xthickness = " + TQString::number(tqApp->tqstyle().tqpixelMetric(TQStyle::PM_DefaultFrameWidth)), "*.GtkMenu"); stream << parse_rc_string("ythickness = " + TQString::number(tqApp->tqstyle().tqpixelMetric(TQStyle::PM_DefaultFrameWidth)), "*.GtkMenu"); @@ -2003,6 +2115,11 @@ void setRcProperties(GtkRcStyle* rc_style, int forceRecreate) stream << parse_rc_string("ythickness = 3", "*.GtkNotebook"); stream << parse_rc_string("ythickness = 1", "*.GtkButton"); stream << parse_rc_string("fg[NORMAL] = {0, 0, 0}", "gtk-tooltips.GtkLabel", false); + + stream << parse_rc_string("GtkButton::inner-border = {0, 0, 0, 0}", "*GtkToolbar*GtkButton*"); + stream << parse_rc_string("GtkButton::inner-border = {0, 0, 0, 0}", "*GtkToolbar*GtkToggleButton*"); + stream << parse_rc_string("GtkButton::inner-border = {0, 0, 0, 0}", "*GtkNotebook*GtkButton*"); + stream << parse_rc_string("GtkButton::inner-border = {0, 0, 0, 0}", "*GtkNotebook*GtkToggleButton*"); // This one may not work... //insertIntProperty(rc_style, "GtkCheckButton", "indicator-size", tqApp->tqstyle().tqpixelMetric(TQStyle::PM_IndicatorHeight) ); @@ -2023,9 +2140,9 @@ void setRcProperties(GtkRcStyle* rc_style, int forceRecreate) stream << "\npixmap_path \"" + iconThemeDirs.join( ":" ) + "\"\n\n"; stream << "style \"KDE-icons\" {\n"; - stream << doIconMapping("gtk-about", "actions/gtk-about.png"); - stream << doIconMapping("gtk-add", "actions/gtk-add.png"); - stream << doIconMapping("gtk-apply", "actions/gtk-apply.png"); + stream << doIconMapping("gtk-about", "actions/about_kde.png"); + stream << doIconMapping("gtk-add", "actions/add.png"); + stream << doIconMapping("gtk-apply", "actions/apply.png"); stream << doIconMapping("gtk-bold", "actions/text_bold.png"); stream << doIconMapping("gtk-cancel", "actions/button_cancel.png"); stream << doIconMapping("gtk-cdrom", "devices/cdrom_unmount.png"); @@ -2034,7 +2151,7 @@ void setRcProperties(GtkRcStyle* rc_style, int forceRecreate) stream << doIconMapping("gtk-color-picker", "actions/colorpicker.png", 3); stream << doIconMapping("gtk-copy", "actions/editcopy.png"); stream << doIconMapping("gtk-convert", "actions/gtk-convert.png"); - //stream << doIconMapping("gtk-connect", ??); + stream << doIconMapping("gtk-connect", "actions/connect_creating.png"); stream << doIconMapping("gtk-cut", "actions/editcut.png"); stream << doIconMapping("gtk-delete", "actions/editdelete.png"); stream << doIconMapping("gtk-dialog-authentication", "status/gtk-dialog-authentication"); @@ -2042,17 +2159,17 @@ void setRcProperties(GtkRcStyle* rc_style, int forceRecreate) stream << doIconMapping("gtk-dialog-info", "actions/messagebox_info.png", 4); stream << doIconMapping("gtk-dialog-question", "actions/help.png"); stream << doIconMapping("gtk-dialog-warning", "actions/messagebox_warning.png", 4); - //stream << doIconMapping("gtk-directory", ??); - //stream << doIconMapping("gtk-disconnect", ??); + stream << doIconMapping("gtk-directory", "filesystems/folder.png"); + stream << doIconMapping("gtk-disconnect", "actions/connect_no.png"); stream << doIconMapping("gtk-dnd", "mimetypes/empty.png"); stream << doIconMapping("gtk-dnd-multiple", "mimetypes/kmultiple.png"); - stream << doIconMapping("gtk-edit", "actions/gtk-edit.png"); //2.6 + stream << doIconMapping("gtk-edit", "actions/edit.png"); //2.6 stream << doIconMapping("gtk-execute", "actions/exec.png"); - stream << doIconMapping("gtk-file", "mimetypes/gtk-file.png"); + stream << doIconMapping("gtk-file", "mimetypes/unknown.png"); stream << doIconMapping("gtk-find", "actions/find.png"); - stream << doIconMapping("gtk-find-and-replace", "actions/gtk-find-and-replace.png"); + stream << doIconMapping("gtk-find-and-replace", "actions/find.png"); // Is there a TDE "find and replace" icon? FIXME stream << doIconMapping("gtk-floppy", "devices/3floppy_unmount.png"); - stream << doIconMapping("gtk-fullscreen", "actions/gtk-fullscreen.png"); + stream << doIconMapping("gtk-fullscreen", "actions/window-fullscreen.png"); stream << doIconMapping("gtk-goto-bottom", "actions/bottom.png"); stream << doIconMapping("gtk-goto-first", "actions/start.png"); stream << doIconMapping("gtk-goto-last", "actions/finish.png"); @@ -2061,36 +2178,36 @@ void setRcProperties(GtkRcStyle* rc_style, int forceRecreate) stream << doIconMapping("gtk-go-down", "actions/down.png"); stream << doIconMapping("gtk-go-forward", "actions/forward.png"); stream << doIconMapping("gtk-go-up", "actions/up.png"); - stream << doIconMapping("gtk-harddisk", "devices/gtk-harddisk.png"); + stream << doIconMapping("gtk-harddisk", "devices/hdd_unmount.png"); stream << doIconMapping("gtk-help", "apps/khelpcenter.png"); stream << doIconMapping("gtk-home", "filesystems/folder_home.png"); - stream << doIconMapping("gtk-indent", "actions/gtk-indent.png"); + stream << doIconMapping("gtk-indent", "actions/indent.png"); stream << doIconMapping("gtk-index", "actions/contents.png"); - //stream << doIconMapping("gtk-info", "??"); + stream << doIconMapping("gtk-info", "actions/messagebox_info.png"); stream << doIconMapping("gtk-italic", "actions/text_italic.png"); stream << doIconMapping("gtk-jump-to", "actions/goto.png"); stream << doIconMapping("gtk-justify-center", "actions/text_center.png"); stream << doIconMapping("gtk-justify-fill", "actions/text_block.png"); stream << doIconMapping("gtk-justify-left", "actions/text_left.png"); stream << doIconMapping("gtk-justify-right", "actions/text_right.png"); - stream << doIconMapping("gtk-leave-fullscreen", "actions/gtk-leave-fullscreen.png"); - stream << doIconMapping("gtk-media-forward", "actions/gtk-media-forward-ltr.png"); - stream << doIconMapping("gtk-media-next", "actions/gtk-media-next-ltr.png"); - stream << doIconMapping("gtk-media-pause", "actions/gtk-media-pause.png"); - stream << doIconMapping("gtk-media-previous", "actions/gtk-media-previous-ltr.png"); - stream << doIconMapping("gtk-media-record", "actions/gtk-media-record.png"); - stream << doIconMapping("gtk-media-rewind", "actions/gtk-media-rewind-ltr.png"); - stream << doIconMapping("gtk-media-stop", "actions/gtk-media-stop.png"); + stream << doIconMapping("gtk-leave-fullscreen", "actions/window-nofullscreen.png"); + stream << doIconMapping("gtk-media-forward", "player-fwd.png"); + stream << doIconMapping("gtk-media-next", "actions/player-end.png"); + stream << doIconMapping("gtk-media-pause", "actions/player-pause.png"); + stream << doIconMapping("gtk-media-previous", "actions/player-start.png"); + stream << doIconMapping("gtk-media-record", "actions/gtk-media-record.png"); // FIXME + stream << doIconMapping("gtk-media-rewind", "actions/player-rew.png"); + stream << doIconMapping("gtk-media-stop", "actions/player-stop.png"); stream << doIconMapping("gtk-missing-image", "mimetypes/unknown.png"); - stream << doIconMapping("gtk-network", "places/gtk_network.png"); + stream << doIconMapping("gtk-network", "filesystems/network.png"); stream << doIconMapping("gtk-new", "actions/filenew.png"); stream << doIconMapping("gtk-no", "actions/gtk-no.png"); stream << doIconMapping("gtk-ok", "actions/button_ok.png"); stream << doIconMapping("gtk-open", "actions/fileopen.png"); - //stream << doIconMapping("gtk-orientation-landscape", "??"); - //stream << doIconMapping("gtk-orientation-portrait", "??"); - //stream << doIconMapping("gtk-orientation-reverse-landscape", "??"); - //stream << doIconMapping("gtk-orientation-reverse-portrait", "??"); + //stream << doIconMapping("gtk-orientation-landscape", "??"); // FIXME + //stream << doIconMapping("gtk-orientation-portrait", "??"); // FIXME + //stream << doIconMapping("gtk-orientation-reverse-landscape", "??"); // FIXME + //stream << doIconMapping("gtk-orientation-reverse-portrait", "??"); // FIXME stream << doIconMapping("gtk-paste", "actions/editpaste.png"); stream << doIconMapping("gtk-preferences", "actions/configure.png"); stream << doIconMapping("gtk-print", "actions/fileprint.png"); @@ -2099,27 +2216,32 @@ void setRcProperties(GtkRcStyle* rc_style, int forceRecreate) stream << doIconMapping("gtk-quit", "actions/exit.png"); stream << doIconMapping("gtk-redo", "actions/redo.png"); stream << doIconMapping("gtk-refresh", "actions/reload.png"); - stream << doIconMapping("gtk-remove", "actions/gtk-remove.png"); + stream << doIconMapping("gtk-remove", "actions/remove.png"); stream << doIconMapping("gtk-revert-to-saved", "actions/revert.png"); stream << doIconMapping("gtk-save", "actions/filesave.png"); stream << doIconMapping("gtk-save-as", "actions/filesaveas.png"); - stream << doIconMapping("gtk-select-all", "actions/gtk-select-all.png"); + stream << doIconMapping("gtk-select-all", "actions/gtk-select-all.png"); // FIXME stream << doIconMapping("gtk-select-color", "actions/colorize.png"); stream << doIconMapping("gtk-select-font", "mimetypes/font.png"); - //stream << doIconMapping("gtk-sort-ascending", "??"); - //stream << doIconMapping("gtk-sort-descending", "??"); + //stream << doIconMapping("gtk-sort-ascending", "??"); // FIXME + //stream << doIconMapping("gtk-sort-descending", "??"); // FIXME stream << doIconMapping("gtk-spell-check", "actions/spellcheck.png"); stream << doIconMapping("gtk-stop", "actions/stop.png"); stream << doIconMapping("gtk-strikethrough", "actions/text_strike.png", 3); - stream << doIconMapping("gtk-undelete", "actions/gtk-undelete.png"); + stream << doIconMapping("gtk-undelete", "actions/gtk-undelete.png"); // FIXME stream << doIconMapping("gtk-underline", "actions/text_under.png"); stream << doIconMapping("gtk-undo", "actions/undo.png"); - stream << doIconMapping("gtk-unindent", "actions/gtk-unindent.png"); - stream << doIconMapping("gtk-yes", "actions/gtk-yes.png"); + stream << doIconMapping("gtk-unindent", "actions/unindent.png"); + stream << doIconMapping("gtk-yes", "actions/button_ok.png"); // Verify mapping here stream << doIconMapping("gtk-zoom-100", "actions/viewmag1.png"); stream << doIconMapping("gtk-zoom-fit", "actions/viewmagfit.png"); stream << doIconMapping("gtk-zoom-in", "actions/viewmag+.png"); stream << doIconMapping("gtk-zoom-out", "actions/viewmag-.png"); + + // Other icons that really should have Trinity equivalents in kdelibs + stream << doIconMapping("list-add", "actions/add.png"); + stream << doIconMapping("list-remove", "actions/remove.png"); + stream << "} class \"*\" style \"KDE-icons\""; cacheFile.close(); diff --git a/src/qt_qt_wrapper.h b/src/qt_qt_wrapper.h index 969eeee..5d5c804 100644 --- a/src/qt_qt_wrapper.h +++ b/src/qt_qt_wrapper.h @@ -5,8 +5,11 @@ #include <gtk/gtknotebook.h> #include <gdk/gdkgc.h> #include <gtk/gtkstyle.h> +#include <gtk/gtkbutton.h> #include <gtk/gtkprogressbar.h> +// #define USE_NATIVE_GTK_BUTTON_DRAWING 1 + #ifdef __cplusplus extern "C" { @@ -26,7 +29,7 @@ void createTQApp(); void destroyTQApp(); void setColors(GtkStyle* style); void setRcProperties(GtkRcStyle* rc_style, int forceRecreate); -void drawButton(GdkWindow * window, GtkStyle * style, GtkStateType state, int defaultButton, int x, int y, int w, int h); +void drawButton(GdkWindow * window, GtkStyle * style, GtkStateType state, int defaultButton, int x, int y, int w, int h, GtkButton* gwidget); void drawSquareButton(GdkWindow * window, GtkStyle * style, GtkStateType state, int x, int y, int w, int h); int findCachedButton(GdkWindow * window, GtkStyle * style, GtkStateType state, int x, int y, int w, int h); void drawToolButton(GdkWindow * window, GtkStyle * style, GtkStateType state, int x, int y, int w, int h); diff --git a/src/qt_theme_draw.c b/src/qt_theme_draw.c index b95bcda..2ccdaf8 100644 --- a/src/qt_theme_draw.c +++ b/src/qt_theme_draw.c @@ -26,6 +26,11 @@ #define min(x,y) ((x)<=(y)?(x):(y)) #endif +extern gboolean tde_showIconsOnPushButtons; + +static GdkPixbuf * (*stockRenderIcon)() = NULL; +static void * (*stockDrawString)() = NULL; + static void qtengine_style_init (QtEngineStyle *style); static void qtengine_style_class_init (QtEngineStyleClass *klass); @@ -70,6 +75,48 @@ static void sanitize_size(GdkWindow* window, gint* width, gint* height) } +static GdkPixbuf * +draw_icon (GtkStyle *style, + const GtkIconSource *source, + GtkTextDirection direction, + GtkStateType state, + GtkIconSize size, + GtkWidget *widget, + const gchar *detail) +{ + gboolean paint_icon = TRUE; + + if (gtkQtDebug) + printf("ICON Widget: %s Detail: %s\n",gtk_widget_get_name(widget),detail); + + GtkWidget* parent; + parent = gtk_widget_get_parent(widget); + int level = 1; + while (parent) { + if (gtkQtDebug) + printf("ICON Parent: %s\n",gtk_widget_get_name(parent)); + if (strcmp("GtkButton", gtk_widget_get_name(parent)) == 0) { + if (level == 3) { +#ifdef USE_NATIVE_GTK_BUTTON_DRAWING + paint_icon = tde_showIconsOnPushButtons; +#else + paint_icon = FALSE; +#endif + } + } + parent = gtk_widget_get_parent(parent); + level++; + } + + if (paint_icon) { + return stockRenderIcon(style, source, direction, state, size, widget, detail); + } + else { + // FIXME + return NULL; + } +} + static void draw_hline(GtkStyle* style, GdkWindow* window, @@ -594,7 +641,20 @@ draw_diamond(GtkStyle * style, { } - +static void +draw_string(GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GdkRectangle *area, + GtkWidget *widget, + const gchar *detail, + gint x, + gint y, + const gchar *string) +{ + if (gtkQtDebug) + printf("STRING Widget: %s Detail: %s\n",gtk_widget_get_name(widget),detail); +} static void draw_box(GtkStyle * style, @@ -769,7 +829,7 @@ draw_box(GtkStyle * style, if (toplevel && toplevel->default_widget == widget) defaultButton = 1; - drawButton(window,style,state_type,defaultButton,x,y,width,height); + drawButton(window,style,state_type,defaultButton,x,y,width,height,GTK_BUTTON(widget)); } return; } @@ -800,8 +860,9 @@ draw_box(GtkStyle * style, checkout drawTabFrame() for drawing tabbarbase. */ drawTabNG(window,style,state_type,x, y, width - 2, height, nb ); } - else + else { drawTab(window,style,state_type,x,y,width-2,height); + } return; } if (DETAIL("optionmenu")) @@ -1272,7 +1333,7 @@ draw_handle(GtkStyle * style, sanitize_size(window, &width, &height); if (gtkQtDebug) - printf("Handle (%d,%d,%d,%d) Widget: %s Detail: %s \n",x,y,width,height,gtk_widget_get_name(widget),detail, state_type); + printf("Handle (%d,%d,%d,%d) Widget: %s Detail: %s State Type: %d\n",x,y,width,height,gtk_widget_get_name(widget),detail, state_type); drawSplitter(window,style,state_type,orientation,x,y,width,height); return; @@ -1290,13 +1351,31 @@ void draw_layout (GtkStyle *style, gint y, PangoLayout *tqlayout) { + gboolean paint_layout = TRUE; GdkColor color; GdkGC *gc; getTextColor(&color, state_type); if (gtkQtDebug) - printf("Layout (%d,%d) Widget: %s Detail: %s %d \n",x,y,gtk_widget_get_name(widget),detail, state_type); + printf("Layout (%d,%d) Widget: %s Detail: %s State Type: %d use_text: %d\n",x,y,gtk_widget_get_name(widget),detail, state_type, use_text); + +#ifdef USE_NATIVE_GTK_BUTTON_DRAWING +#else + GtkWidget* parent; + parent = gtk_widget_get_parent(widget); + while (parent) { + if (gtkQtDebug) + printf("Layout Parent: %s\n",gtk_widget_get_name(parent)); + if (strcmp("GtkButton", gtk_widget_get_name(parent)) == 0) { + paint_layout = FALSE; + } + parent = gtk_widget_get_parent(parent); + } +#endif + + if (!paint_layout) + return; if (DETAIL("accellabel") || DETAIL("label") || DETAIL("cellrenderertext")) { @@ -1886,6 +1965,11 @@ qtengine_style_class_init (QtEngineStyleClass *klass) GtkStyleClass *style_class = GTK_STYLE_CLASS (klass); parent_class = g_type_class_peek_parent (klass); + + stockRenderIcon = style_class->render_icon; + stockDrawString = style_class->draw_string; + + style_class->render_icon = draw_icon; style_class->draw_hline = draw_hline; style_class->draw_vline = draw_vline; @@ -1893,7 +1977,7 @@ qtengine_style_class_init (QtEngineStyleClass *klass) style_class->draw_polygon = draw_polygon; style_class->draw_arrow = draw_arrow; style_class->draw_diamond = draw_diamond; - /*style_class->draw_string = draw_string;*/ +// style_class->draw_string = draw_string; style_class->draw_box = draw_box; style_class->draw_flat_box = draw_flat_box; style_class->draw_check = draw_check; |