gitkrthemes.c

Go to the documentation of this file.
00001 
00012 #define GITK_RENDERER_C
00013 #define GITKR_THEMES_C
00014 
00015 #include "gitkrincludes.h"
00016 
00017 gchar *gtkrc_name=NULL;
00018 gchar *gtk_theme_dir=NULL;
00019 
00020 void gitkr_themes_init(void) {
00021   gchar **default_rcs;
00022   guint i=0;
00023 
00024   gtk_theme_dir=gtk_rc_get_theme_dir();
00025   gitk_log1("gtk theme dir: \"%s\"",gitk_save_get_string(gtk_theme_dir));
00026   gtkrc_name=g_strdup_printf("/tmp/gtk-2.0.%d",getpid()); 
00027   gitk_log1("gitk rc file: \"%s\"",gitk_save_get_string(gtkrc_name));
00028   //-- generate an empty gtkrc file
00029   gitkr_theme_switch(NULL);
00030   //-- append this to the list of default rc files
00031   gtk_rc_add_default_file(gtkrc_name);
00032   // read default rc files
00033   if((default_rcs=gtk_rc_get_default_files())) {
00034     gitk_log("gtk default rc files:");
00035     while(default_rcs[i]) {
00036       gitk_log2("  %02d :\"%s\"",i,default_rcs[i]);i++;
00037     }
00038   }
00039   else gitk_log("no gtk default rc files");
00040 }
00041 
00042 void gitkr_themes_done(void) {
00043   if(gtkrc_name) {
00044     unlink(gtkrc_name);
00045     g_free(gtkrc_name);
00046     gtkrc_name=NULL;
00047   }
00048   if(gtk_theme_dir) {
00049     g_free(gtk_theme_dir);
00050     gtk_theme_dir=NULL;
00051   }
00052 }
00053 
00054 void gitkr_theme_switch(gchar *theme_name) {
00055   if(gtkrc_name) {
00056     FILE *rcf;
00057     if((rcf=fopen(gtkrc_name,"wb"))){
00058       fputs("# -- THEME AUTO-WRITTEN DO NOT EDIT\n\n",rcf);
00059       if(theme_name && gtk_theme_dir) {
00060         fprintf(rcf,"include \"%s/%s/gtk-2.0/gtkrc\"\n\n",gtk_theme_dir,theme_name);
00061       }
00062       fputs("# -- THEME AUTO-WRITTEN DO NOT EDIT\n",rcf);
00063       fclose(rcf);
00064     }
00065   }
00066 }

Generated on Thu Oct 28 10:59:12 2004 for gitk by doxygen 1.3.6