Author: cazfi
Date: Mon Dec 21 14:02:47 2015
New Revision: 31140

URL: http://svn.gna.org/viewcvs/freeciv?rev=31140&view=rev
Log:
Fixed gtk3-client theme switching to completely replace the theme, not just 
adding to old one.

See bug #24203

Modified:
    branches/S2_5/client/gui-gtk-3.0/themes.c

Modified: branches/S2_5/client/gui-gtk-3.0/themes.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/client/gui-gtk-3.0/themes.c?rev=31140&r1=31139&r2=31140&view=diff
==============================================================================
--- branches/S2_5/client/gui-gtk-3.0/themes.c   (original)
+++ branches/S2_5/client/gui-gtk-3.0/themes.c   Mon Dec 21 14:02:47 2015
@@ -39,22 +39,28 @@
 *****************************************************************************/
 void gui_load_theme(const char *directory, const char *theme_name)
 {
-  GtkCssProvider *css_provider;
+  static GtkCssProvider *fc_css_provider = NULL;
   GError *error = NULL;
   char buf[strlen(directory) + strlen(theme_name) + 32];
+
+  if (fc_css_provider == NULL) {
+    fc_css_provider = gtk_css_provider_new();
+    gtk_style_context_add_provider(gtk_widget_get_style_context(toplevel),
+        GTK_STYLE_PROVIDER(fc_css_provider),
+        GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+  }
+
   /* Gtk theme is a directory containing gtk-3.0/gtk.css file */
   fc_snprintf(buf, sizeof(buf), "%s/%s/gtk-3.0/gtk.css", directory,
               theme_name);
-  css_provider = gtk_css_provider_new();
-  gtk_css_provider_load_from_file(css_provider, g_file_new_for_path(buf), 
&error);
+
+  gtk_css_provider_load_from_file(fc_css_provider, g_file_new_for_path(buf), 
&error);
+
   if (error) {
     g_warning("%s\n", error->message);
-    return;
   }
-  gtk_style_context_add_provider_for_screen(
-      gtk_widget_get_screen(toplevel),
-      GTK_STYLE_PROVIDER(css_provider),
-      GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+
+  gtk_style_context_invalidate(gtk_widget_get_style_context(toplevel));
 }
 
 /*****************************************************************************


_______________________________________________
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits

Reply via email to