Complete.Org: Mailing Lists: Archives: freeciv-dev: November 2005:
[Freeciv-Dev] (PR#14613) GTK2 client ignores ~/.gtkrc-2.0
Home

[Freeciv-Dev] (PR#14613) GTK2 client ignores ~/.gtkrc-2.0

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: xbxrjf@xxxxxxxxxx
Subject: [Freeciv-Dev] (PR#14613) GTK2 client ignores ~/.gtkrc-2.0
From: "Mateusz Stefek" <mstefek@xxxxxxxxx>
Date: Fri, 18 Nov 2005 09:09:51 -0800
Reply-to: bugs@xxxxxxxxxxx

<URL: http://bugs.freeciv.org/Ticket/Display.html?id=14613 >

Here's a patch.
Index: client/gui-gtk-2.0/themes.c
===================================================================
--- client/gui-gtk-2.0/themes.c (wersja 11244)
+++ client/gui-gtk-2.0/themes.c (kopia robocza)
@@ -27,14 +27,50 @@
 #include "themes_common.h"
 #include "themes_g.h"
 
+/* Array of default files. First num_default_files positions
+ * are files returned by gtk_rc_get_default_files() on client startup.
+ * There are two extra postions allocated in the array - one for
+ * specific Freeciv file and one for NULL. */
+static char** default_files;
+static int num_default_files;
+
+/****************************************************************************
+  Initialize the default_files array.
+****************************************************************************/
+static void load_default_files()
+{
+  int i;
+  gchar** f;
+  
+  if (default_files != NULL) {
+    return;
+  }
+  
+  f = gtk_rc_get_default_files();
+  
+  for (i = 0; f[i] ; i++) {
+    /* nothing */
+  }
+  num_default_files = i;
+  default_files = fc_malloc(sizeof(char*) * (i + 2));
+  
+  for (i = 0; i < num_default_files; i++) {
+    default_files[i] = mystrdup(f[i]);
+  }
+  default_files[i] = default_files[i + 1] = NULL;
+}
+
 /*****************************************************************************
   Loads a gtk theme directory/theme_name
 *****************************************************************************/
 void gui_load_theme(const char *directory, const char *theme_name)
 {
   char buf[strlen(directory) + strlen(theme_name) + 32];
-  gchar *default_files[] = {buf, NULL};
   
+  load_default_files();
+  default_files[num_default_files] = buf;
+  default_files[num_default_files + 1] = NULL;
+  
   /* Gtk theme is a directory containing gtk-2.0/gtkrc file */
   my_snprintf(buf, sizeof(buf), "%s/%s/gtk-2.0/gtkrc", directory,
              theme_name);
@@ -49,8 +85,8 @@
 *****************************************************************************/
 void gui_clear_theme(void)
 {
-  gchar *default_files[] = {NULL};
-  
+  load_default_files();
+  default_files[num_default_files] = NULL;
   gtk_rc_set_default_files(default_files);
   gtk_rc_reparse_all_for_settings(gtk_settings_get_default(), TRUE);
 }

[Prev in Thread] Current Thread [Next in Thread]