Sophie

Sophie

distrib > Mageia > 1 > i586 > media > core-updates-src > by-pkgid > 83ecf8f3cf39318860f0dc9917c84068 > files > 26

kdebase4-workspace-4.6.5-1.4.mga1.src.rpm

diff --git a/kcontrol/colors/colorscm.cpp b/kcontrol/colors/colorscm.cpp
--- a/kcontrol/colors/colorscm.cpp
+++ b/kcontrol/colors/colorscm.cpp
@@ -1231,7 +1231,7 @@ 
     displayGroup.writeEntry("exportKDEColors", applyToAlien->isChecked());
     cfg.sync();
 
-    runRdb(KRdbExportQtColors | ( applyToAlien->isChecked() ? KRdbExportColors : 0 ) );
+    runRdb(KRdbExportQtColors | KRdbExportGtkTheme | ( applyToAlien->isChecked() ? KRdbExportColors : 0 ) );
 
     emit changed(false);
 
diff --git a/kcontrol/fonts/fonts.cpp b/kcontrol/fonts/fonts.cpp
--- a/kcontrol/fonts/fonts.cpp
+++ b/kcontrol/fonts/fonts.cpp
@@ -335,7 +335,7 @@ bool FontAASettings::load()
     xft.apply();  // Save this setting
     KConfigGroup(&kglobals, "General").writeEntry("XftHintStyle", KXftConfig::toStr(hStyle));
     kglobals.sync();
-    runRdb(KRdbExportXftSettings);
+    runRdb(KRdbExportXftSettings | KRdbExportGtkTheme);
   }
 
   hintingStyle->setCurrentIndex(getIndex(hStyle));
@@ -791,7 +791,7 @@ void KFonts::save()
     dpi_original = dpi;
   }
 #endif
-  runRdb(KRdbExportXftSettings);
+  runRdb(KRdbExportXftSettings | KRdbExportGtkTheme);
 
   emit changed(false);
 }
diff --git a/kcontrol/krdb/krdb.h b/kcontrol/krdb/krdb.h
--- a/kcontrol/krdb/krdb.h
+++ b/kcontrol/krdb/krdb.h
@@ -25,7 +25,8 @@ enum KRdbAction
    KRdbExportColors      = 0x0001,   // Export colors to non-(KDE/Qt) apps
    KRdbExportQtColors    = 0x0002,   // Export KDE's colors to qtrc
    KRdbExportQtSettings  = 0x0004,   // Export all possible qtrc settings, excluding colors
-   KRdbExportXftSettings = 0x0008    // Export KDE's Xft (anti-alias) settings
+   KRdbExportXftSettings = 0x0008,   // Export KDE's Xft (anti-alias) settings
+   KRdbExportGtkTheme    = 0x0010    // Export KDE's widget style to Gtk if possible
 };
 
 void runRdb( uint flags );
diff --git a/kcontrol/krdb/krdb.cpp b/kcontrol/krdb/krdb.cpp
--- a/kcontrol/krdb/krdb.cpp
+++ b/kcontrol/krdb/krdb.cpp
@@ -93,10 +93,9 @@ static void applyGtkStyles(bool active, int version)
    QLatin1String systemGtkrc = QLatin1String(sysGtkrc(version));
    if (!list.contains(systemGtkrc))
       list.prepend(systemGtkrc);
+   list.removeAll("");
    list.removeAll(gtkkde);
    list.append(gtkkde);
-   if (!active)
-      ::unlink(QFile::encodeName(gtkkde));
 
    // Pass env. var to kdeinit.
    QString name = gtkEnvVar(version);
@@ -236,7 +235,7 @@ static QString color( const QColor& col )
     return QString( "{ %1, %2, %3 }" ).arg( item( col.red() ) ).arg( item( col.green() ) ).arg( item( col.blue() ) );
 }
 
-static void createGtkrc( bool exportColors, const QPalette& cg, int version )
+static void createGtkrc( bool exportColors, const QPalette& cg, bool exportGtkTheme, const QString& gtkTheme, int version )
 {
     // lukas: why does it create in ~/.kde/share/config ???
     // pfeiffer: so that we don't overwrite the user's gtkrc.
@@ -257,10 +256,74 @@ static void createGtkrc( bool exportColors, const QPalette& cg, int version )
             "#\n"
             "#\n", QDateTime::currentDateTime().toString());
 
-    t << "style \"default\"" << endl;
-    t << "{" << endl;
+    if ( 2==version ) {  // we should maybe check for MacOS settings here
+        t << endl;
+        t << "gtk-alternative-button-order = 1" << endl;
+        t << endl;
+    }
+
+    if (exportGtkTheme)
+    {
+        QString gtkStyle;
+        if (gtkTheme.toLower() == "oxygen")
+            gtkStyle = QString("oxygen-gtk");
+        else
+            gtkStyle = gtkTheme;
+
+        bool exist_gtkrc = false;
+        QByteArray gtkrc = getenv(gtkEnvVar(version));
+        QStringList listGtkrc = QFile::decodeName(gtkrc).split(":");
+        if (listGtkrc.contains(saveFile.fileName()))
+            listGtkrc.removeAll(saveFile.fileName());
+        listGtkrc.append(QDir::homePath() + userGtkrc(version));
+        listGtkrc.append(QDir::homePath() + "/.gtkrc-2.0-kde");
+        listGtkrc.append(QDir::homePath() + "/.gtkrc-2.0-kde4");
+        listGtkrc.removeAll("");
+        listGtkrc.removeDuplicates();
+        for (int i = 0; i < listGtkrc.size(); ++i)
+        {
+            if ((exist_gtkrc = QFile::exists(listGtkrc.at(i))))
+                break;
+        }
+
+        if (!exist_gtkrc)
+        {
+            QString gtk2ThemeFilename;
+            gtk2ThemeFilename = QString("%1/.themes/%2/gtk-2.0/gtkrc").arg(QDir::homePath()).arg(gtkStyle);
+            if (!QFile::exists(gtk2ThemeFilename)) {
+                QStringList gtk2ThemePath;
+                gtk2ThemeFilename.clear();
+                QByteArray xdgDataDirs = getenv("XDG_DATA_DIRS");
+                gtk2ThemePath.append(QDir::homePath() + "/.local");
+                gtk2ThemePath.append(QFile::decodeName(xdgDataDirs).split(":"));
+                gtk2ThemePath.removeDuplicates();
+                for (int i = 0; i < gtk2ThemePath.size(); ++i)
+                {
+                    gtk2ThemeFilename = QString("%1/themes/%2/gtk-2.0/gtkrc").arg(gtk2ThemePath.at(i)).arg(gtkStyle);
+                    if (QFile::exists(gtk2ThemeFilename))
+                        break;
+                    else
+                        gtk2ThemeFilename.clear();
+                }
+            }
+
+            if (!gtk2ThemeFilename.isEmpty())
+            {
+                t << "include \"" << gtk2ThemeFilename << "\"" << endl;
+                t << endl;
+                t << "gtk-theme-name=\"" << gtkStyle << "\"" << endl;
+                t << endl;
+                if (gtkStyle == "oxygen-gtk")
+                    exportColors = false;
+            }
+        }
+
+    }
+
     if (exportColors)
     {
+        t << "style \"default\"" << endl;
+        t << "{" << endl;
         t << "  bg[NORMAL] = " << color( cg.color( QPalette::Active, QPalette::Background ) ) << endl;
         t << "  bg[SELECTED] = " << color( cg.color(QPalette::Active, QPalette::Highlight) ) << endl;
         t << "  bg[INSENSITIVE] = " << color( cg.color( QPalette::Active, QPalette::Background ) ) << endl;
@@ -284,19 +347,11 @@ static void createGtkrc( bool exportColors, const QPalette& cg, int version )
         t << "  fg[INSENSITIVE] = " << color( cg.color( QPalette::Active, QPalette::Mid ) ) << endl;
         t << "  fg[ACTIVE] = " << color( cg.color( QPalette::Active, QPalette::Foreground ) ) << endl;
         t << "  fg[PRELIGHT] = " << color( cg.color( QPalette::Active, QPalette::Foreground ) ) << endl;
-    }
-
-    t << "}" << endl;
-    t << endl;
-    t << "class \"*\" style \"default\"" << endl;
-    t << endl;
-    if ( 2==version ) {  // we should maybe check for MacOS settings here
-	t << "gtk-alternative-button-order = 1" << endl;
-	t << endl;
-    }
+        t << "}" << endl;
+        t << endl;
+        t << "class \"*\" style \"default\"" << endl;
+        t << endl;
 
-    if (exportColors)
-    {
         // tooltips don't have the standard background color
         t << "style \"ToolTip\"" << endl;
         t << "{" << endl;
@@ -322,6 +377,7 @@ static void createGtkrc( bool exportColors, const QPalette& cg, int version )
         t << "class \"*MenuItem\" style \"MenuItem\"" << endl;
         t << endl;
     }
+
 }
 
 // -----------------------------------------------------------------------------
@@ -333,6 +389,7 @@ void runRdb( uint flags )
   bool exportQtColors    = flags & KRdbExportQtColors;
   bool exportQtSettings  = flags & KRdbExportQtSettings;
   bool exportXftSettings = flags & KRdbExportXftSettings;
+  bool exportGtkTheme    = flags & KRdbExportGtkTheme;
 
   KSharedConfigPtr kglobalcfg = KSharedConfig::openConfig( "kdeglobals" );
   KConfigGroup kglobals(kglobalcfg, "KDE");
@@ -345,13 +402,23 @@ void runRdb( uint flags )
     exit(0);
   }
 
+
+  KConfigGroup generalCfgGroup(kglobalcfg, "General");
+
+  QString gtkTheme;
+  if (generalCfgGroup.hasKey("widgetStyle"))
+    gtkTheme = generalCfgGroup.readEntry("widgetStyle");
+  else
+    gtkTheme = "oxygen";
+
+  createGtkrc( exportColors, newPal, exportGtkTheme, gtkTheme, 1 );
+  createGtkrc( exportColors, newPal, exportGtkTheme, gtkTheme, 2 );
+
   // Export colors to non-(KDE/Qt) apps (e.g. Motif, GTK+ apps)
   if (exportColors)
   {
     KGlobal::dirs()->addResourceType("appdefaults", "data", "kdisplay/app-defaults/");
     KGlobal::locale()->insertCatalog("krdb");
-    createGtkrc( true, newPal, 1 );
-    createGtkrc( true, newPal, 2 );
 
     QString preproc;
     QColor backCol = newPal.color( QPalette::Active, QPalette::Background );
@@ -413,8 +480,6 @@ void runRdb( uint flags )
 
   if (exportXftSettings)
   {
-    KConfigGroup generalCfgGroup(kglobalcfg, "General");
-
     if (generalCfgGroup.hasKey("XftAntialias"))
     {
       contents += "Xft.antialias: ";
diff --git a/kcontrol/style/kcmstyle.cpp b/kcontrol/style/kcmstyle.cpp
--- a/kcontrol/style/kcmstyle.cpp
+++ b/kcontrol/style/kcmstyle.cpp
@@ -88,7 +88,7 @@ extern "C"
 {
     KDE_EXPORT void kcminit_style()
     {
-        uint flags = KRdbExportQtSettings | KRdbExportQtColors | KRdbExportXftSettings;
+        uint flags = KRdbExportQtSettings | KRdbExportQtColors | KRdbExportXftSettings | KRdbExportGtkTheme;
         KConfig _config( "kcmdisplayrc", KConfig::NoGlobals  );
         KConfigGroup config(&_config, "X11");
 
@@ -407,7 +407,7 @@ void KCMStyle::save()
     // export fonts/colors settings.
     if (m_bStyleDirty | m_bEffectsDirty)    // Export only if necessary
     {
-        uint flags = KRdbExportQtSettings;
+        uint flags = KRdbExportQtSettings | KRdbExportGtkTheme;
         KConfig _kconfig( "kcmdisplayrc", KConfig::NoGlobals  );
         KConfigGroup kconfig(&_kconfig, "X11");
         bool exportKDEColors = kconfig.readEntry("exportKDEColors", true);