Mercurial > geeqie.yaz
comparison src/rcfile.c @ 738:ff8b802eac58
Separate path building code from options loading code.
Most code of load_options() is moved to new load_options_from().
ExifUIList initialization is moved to setup_default_options().
author | zas_ |
---|---|
date | Thu, 22 May 2008 22:43:07 +0000 |
parents | 8a8873e7a552 |
children | 0e8b802e54d5 |
comparison
equal
deleted
inserted
replaced
737:8a8873e7a552 | 738:ff8b802eac58 |
---|---|
616 | 616 |
617 if (number) *number = atoi(option + prefix_len); | 617 if (number) *number = atoi(option + prefix_len); |
618 return TRUE; | 618 return TRUE; |
619 } | 619 } |
620 | 620 |
621 void load_options(void) | 621 |
622 | |
623 static gboolean load_options_from(const gchar *utf8_path) | |
622 { | 624 { |
623 FILE *f; | 625 FILE *f; |
624 gchar *rc_path; | |
625 gchar *rc_pathl; | 626 gchar *rc_pathl; |
626 gchar s_buf[1024]; | 627 gchar s_buf[1024]; |
627 gchar option[1024]; | 628 gchar option[1024]; |
628 gchar value[1024]; | 629 gchar value[1024]; |
629 gchar value_all[1024]; | 630 gchar value_all[1024]; |
630 gint i; | 631 gint i; |
631 | 632 |
632 for (i = 0; ExifUIList[i].key; i++) | 633 rc_pathl = path_from_utf8(utf8_path); |
633 ExifUIList[i].current = ExifUIList[i].default_value; | |
634 | |
635 rc_path = g_build_filename(homedir(), GQ_RC_DIR, RC_FILE_NAME, NULL); | |
636 | |
637 rc_pathl = path_from_utf8(rc_path); | |
638 f = fopen(rc_pathl,"r"); | 634 f = fopen(rc_pathl,"r"); |
639 g_free(rc_pathl); | 635 g_free(rc_pathl); |
640 if (!f) | 636 if (!f) return FALSE; |
641 { | |
642 g_free(rc_path); | |
643 return; | |
644 } | |
645 | 637 |
646 while (fgets(s_buf, sizeof(s_buf), f)) | 638 while (fgets(s_buf, sizeof(s_buf), f)) |
647 { | 639 { |
648 gchar *option_start, *value_start; | 640 gchar *option_start, *value_start; |
649 gchar *p = s_buf; | 641 gchar *p = s_buf; |
915 continue; | 907 continue; |
916 } | 908 } |
917 } | 909 } |
918 | 910 |
919 fclose(f); | 911 fclose(f); |
912 return TRUE; | |
913 } | |
914 | |
915 void load_options(void) | |
916 { | |
917 gchar *rc_path; | |
918 | |
919 rc_path = g_build_filename(homedir(), GQ_RC_DIR, RC_FILE_NAME, NULL); | |
920 load_options_from(rc_path); | |
920 g_free(rc_path); | 921 g_free(rc_path); |
921 } | 922 } |