Sophie

Sophie

distrib > Mageia > 3 > i586 > media > core-release-src > by-pkgid > f1d727d43f59c44fd1eb6888e802b4b1 > files > 2

libyui-gtk-2.42.1-0.git20121227.5.mga3.src.rpm

diff --git a/ChangeLog b/ChangeLog
index 1810764..0df5814 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,8 @@
 -------------------------------------------------------------------
+Fri Jan 18 15:13:21 CET 2013 - anaselli@linux.it
+- Added a basic theme management by using css style (style.css)
+
+-------------------------------------------------------------------
 Thu Dec 27 21:45:30 CET 2012 - anaselli@linux.it
 
 - Fixed YGProgressBar setValue to refresh 
diff --git a/VERSION.cmake b/VERSION.cmake
index cfb8bc3..e5e9833 100644
--- a/VERSION.cmake
+++ b/VERSION.cmake
@@ -1,6 +1,6 @@
 SET( VERSION_MAJOR "2" )
 SET( VERSION_MINOR "42" )
-SET( VERSION_PATCH "1" )
+SET( VERSION_PATCH "2" )
 SET( VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}${VERSION_SHA1}" )
 
 ##### This is need for the libyui core, ONLY.
diff --git a/src/YGUI.cc b/src/YGUI.cc
index 6b5bd49..f4e3730 100644
--- a/src/YGUI.cc
+++ b/src/YGUI.cc
@@ -147,6 +147,45 @@ void YGUI::checkInit()
 	g_log_set_always_fatal (GLogLevelFlags (G_LOG_LEVEL_ERROR|G_LOG_LEVEL_CRITICAL|
 		G_LOG_LEVEL_WARNING| G_LOG_LEVEL_MESSAGE|G_LOG_LEVEL_INFO|G_LOG_LEVEL_DEBUG));
 #endif
+    std::string themeSubDir = YSettings::getThemeDir();
+
+    char* st = getenv("Y2STYLE");
+    std::string style = st ? st : "";
+ 
+    if (style.size())
+    {
+      style = themeSubDir + style;
+    }
+    else
+    {
+      style = themeSubDir + "style.css";
+    }
+
+    yuiMilestone() << "Style \"" << style << "\"\n";
+
+    GtkCssProvider *provider = gtk_css_provider_new();
+    GFile * file = g_file_new_for_path(style.c_str());
+    if (g_file_query_exists(file, NULL))
+    {
+       GError *error = NULL;
+       if (!gtk_css_provider_load_from_file (provider, file, &error))
+       {
+         g_printerr ("%s\n", error->message);
+       }
+       else
+       {
+         GdkDisplay *display = gdk_display_get_default ();
+         GdkScreen *screen = gdk_display_get_default_screen (display);
+
+         gtk_style_context_add_provider_for_screen (screen,
+                                                    GTK_STYLE_PROVIDER (provider),
+                                                    GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);     
+       }
+    }
+    else
+       yuiMilestone() << "Style \"" << style << "\" not found. Ignoring style\n";
+    
+    g_object_unref (provider);
 
 	GdkPixbuf *pixbuf = YGUtils::loadPixbuf (THEMEDIR "/icons/32x32/apps/yast.png");
 	if (pixbuf) {  // default window icon