comparison src/main.c @ 2221:59b559f747a7 ke-lua

Merge branch 'master' into ke-lua * master: (185 commits) better fix for big-endian architectures Minor indentation fixes. Cleanup checker shader code. Fix exif orientation in clutter rendering mode. Silent 2 warnings using explicit type casting. Polish translation was updated, thanks to Grzegorz Gibas. Update pt_BR translation. Add *~, *.rej, *.orig files to git ignore list. Fix for support >=automake-1.11.4 Trim trailing white spaces on empty lines. Trim trailing white spaces. Add missing vim modeline. Fix indentation and few trailing white spaces. Clear few more warnings, unused variables mostly. Drop unused variable. Remove commented out code. Remove commented out code. Remove commented out code. Remove commented out code. Remove commented out code. ...
author Klaus Ethgen <Klaus@Ethgen.de>
date Tue, 02 Oct 2012 22:19:13 +0100
parents 58cd15125b23 c14a1d8e6aa4
children 5a9bdebb109f
comparison
equal deleted inserted replaced
2220:fea4dd5c4359 2221:59b559f747a7
1 /* 1 /*
2 * Geeqie 2 * Geeqie
3 * (C) 2006 John Ellis 3 * (C) 2006 John Ellis
4 * Copyright (C) 2008 - 2010 The Geeqie Team 4 * Copyright (C) 2008 - 2012 The Geeqie Team
5 * 5 *
6 * Author: John Ellis 6 * Author: John Ellis
7 * 7 *
8 * This software is released under the GNU General Public License (GNU GPL). 8 * This software is released under the GNU General Public License (GNU GPL).
9 * Please read the included file COPYING for more information. 9 * Please read the included file COPYING for more information.
17 17
18 #include <math.h> 18 #include <math.h>
19 #ifdef G_OS_UNIX 19 #ifdef G_OS_UNIX
20 #include <pwd.h> 20 #include <pwd.h>
21 #endif 21 #endif
22 #include <locale.h>
22 23
23 #include "main.h" 24 #include "main.h"
24 25
25 #include "cache.h" 26 #include "cache.h"
26 #include "collect.h" 27 #include "collect.h"
45 #include "exif.h" 46 #include "exif.h"
46 #include "histogram.h" 47 #include "histogram.h"
47 #include "pixbuf_util.h" 48 #include "pixbuf_util.h"
48 #include "glua.h" 49 #include "glua.h"
49 50
50 #ifdef HAVE_LIBCHAMPLAIN 51 #ifdef HAVE_CLUTTER
51 #ifdef HAVE_LIBCHAMPLAIN_GTK
52 #include <clutter-gtk/clutter-gtk.h> 52 #include <clutter-gtk/clutter-gtk.h>
53 #endif
54 #endif 53 #endif
55 54
56 55
57 gboolean thumb_format_changed = FALSE; 56 gboolean thumb_format_changed = FALSE;
58 static RemoteConnection *remote_connection = NULL; 57 static RemoteConnection *remote_connection = NULL;
141 FileData *dir_fd; 140 FileData *dir_fd;
142 141
143 path_parsed = g_strdup(dir); 142 path_parsed = g_strdup(dir);
144 parse_out_relatives(path_parsed); 143 parse_out_relatives(path_parsed);
145 dir_fd = file_data_new_dir(path_parsed); 144 dir_fd = file_data_new_dir(path_parsed);
146 145
147 146
148 if (filelist_read(dir_fd, &files, NULL)) 147 if (filelist_read(dir_fd, &files, NULL))
149 { 148 {
150 GList *work; 149 GList *work;
151 150
211 GList *list = NULL; 210 GList *list = NULL;
212 GList *remote_list = NULL; 211 GList *remote_list = NULL;
213 GList *remote_errors = NULL; 212 GList *remote_errors = NULL;
214 gboolean remote_do = FALSE; 213 gboolean remote_do = FALSE;
215 gchar *first_dir = NULL; 214 gchar *first_dir = NULL;
216 215
217 command_line = g_new0(CommandLine, 1); 216 command_line = g_new0(CommandLine, 1);
218 217
219 command_line->argc = argc; 218 command_line->argc = argc;
220 command_line->argv = argv; 219 command_line->argv = argv;
221 220
222 if (argc > 1) 221 if (argc > 1)
223 { 222 {
371 if (remote_do) 370 if (remote_do)
372 { 371 {
373 if (remote_errors) 372 if (remote_errors)
374 { 373 {
375 GList *work = remote_errors; 374 GList *work = remote_errors;
376 375
377 printf_term(_("Invalid or ignored remote options: ")); 376 printf_term(_("Invalid or ignored remote options: "));
378 while (work) 377 while (work)
379 { 378 {
380 gchar *opt = work->data; 379 gchar *opt = work->data;
381 380
382 printf_term("%s%s", (work == remote_errors) ? "" : ", ", opt); 381 printf_term("%s%s", (work == remote_errors) ? "" : ", ", opt);
383 work = work->next; 382 work = work->next;
384 } 383 }
385 384
386 printf_term(_("\nUse --remote-help for valid remote options.\n")); 385 printf_term(_("\nUse --remote-help for valid remote options.\n"));
542 if (!ssi) 541 if (!ssi)
543 { 542 {
544 log_printf(_("error saving file: %s\n"), path); 543 log_printf(_("error saving file: %s\n"), path);
545 return FALSE; 544 return FALSE;
546 } 545 }
547 546
548 gstring = g_string_new("; "); 547 gstring = g_string_new("; ");
549 if (g_get_prgname()) 548 if (g_get_prgname())
550 g_string_append(gstring, g_get_prgname()); 549 g_string_append(gstring, g_get_prgname());
551 g_string_append(gstring, " GtkAccelMap rc-file -*- scheme -*-\n"); 550 g_string_append(gstring, " GtkAccelMap rc-file -*- scheme -*-\n");
552 g_string_append(gstring, "; this file is an automated accelerator map dump\n"); 551 g_string_append(gstring, "; this file is an automated accelerator map dump\n");
698 if (exit_confirm_dlg()) return; 697 if (exit_confirm_dlg()) return;
699 698
700 exit_program_final(); 699 exit_program_final();
701 } 700 }
702 701
703 /* This code is supposed to handle situation when a file mmaped by image_loader 702 /* This code is supposed to handle situation when a file mmaped by image_loader
704 * or by exif loader is truncated by some other process. 703 * or by exif loader is truncated by some other process.
705 * This is probably not completely correct according to posix, because 704 * This is probably not completely correct according to posix, because
706 * mmap is not in the list of calls that can be used safely in signal handler, 705 * mmap is not in the list of calls that can be used safely in signal handler,
707 * but anyway, the handler is called in situation when the application would 706 * but anyway, the handler is called in situation when the application would
708 * crash otherwise. 707 * crash otherwise.
741 g_thread_init(NULL); 740 g_thread_init(NULL);
742 gdk_threads_init(); 741 gdk_threads_init();
743 gdk_threads_enter(); 742 gdk_threads_enter();
744 743
745 #endif 744 #endif
746 745
747 /* init execution time counter (debug only) */ 746 /* init execution time counter (debug only) */
748 init_exec_time(); 747 init_exec_time();
749 748
750 /* setup locale, i18n */ 749 /* setup locale, i18n */
751 gtk_set_locale(); 750 setlocale(LC_ALL, "");
752 751
753 #ifdef ENABLE_NLS 752 #ifdef ENABLE_NLS
754 bindtextdomain(PACKAGE, GQ_LOCALEDIR); 753 bindtextdomain(PACKAGE, GQ_LOCALEDIR);
755 bind_textdomain_codeset(PACKAGE, "UTF-8"); 754 bind_textdomain_codeset(PACKAGE, "UTF-8");
756 textdomain(PACKAGE); 755 textdomain(PACKAGE);
771 file_data_register_notify_func(cache_notify_cb, NULL, NOTIFY_PRIORITY_HIGH); 770 file_data_register_notify_func(cache_notify_cb, NULL, NOTIFY_PRIORITY_HIGH);
772 file_data_register_notify_func(thumb_notify_cb, NULL, NOTIFY_PRIORITY_HIGH); 771 file_data_register_notify_func(thumb_notify_cb, NULL, NOTIFY_PRIORITY_HIGH);
773 file_data_register_notify_func(histogram_notify_cb, NULL, NOTIFY_PRIORITY_HIGH); 772 file_data_register_notify_func(histogram_notify_cb, NULL, NOTIFY_PRIORITY_HIGH);
774 file_data_register_notify_func(collect_manager_notify_cb, NULL, NOTIFY_PRIORITY_LOW); 773 file_data_register_notify_func(collect_manager_notify_cb, NULL, NOTIFY_PRIORITY_LOW);
775 file_data_register_notify_func(metadata_notify_cb, NULL, NOTIFY_PRIORITY_LOW); 774 file_data_register_notify_func(metadata_notify_cb, NULL, NOTIFY_PRIORITY_LOW);
776 775
777 776
778 gtkrc_load(); 777 gtkrc_load();
779 778
780 parse_command_line_for_debug_option(argc, argv); 779 parse_command_line_for_debug_option(argc, argv);
781 DEBUG_1("%s main: gtk_init", get_exec_time()); 780 DEBUG_1("%s main: gtk_init", get_exec_time());
782 #ifdef HAVE_LIBCHAMPLAIN 781 #ifdef HAVE_CLUTTER
783 #ifdef HAVE_LIBCHAMPLAIN_GTK
784 if (gtk_clutter_init(&argc, &argv) != CLUTTER_INIT_SUCCESS) 782 if (gtk_clutter_init(&argc, &argv) != CLUTTER_INIT_SUCCESS)
785 { 783 {
786 log_printf("Can't initialize clutter-gtk.\n"); 784 log_printf("Can't initialize clutter-gtk.\n");
787 exit(1); 785 exit(1);
788 } 786 }
789 #else
790 gtk_init(&argc, &argv);
791 #endif
792 #else 787 #else
793 gtk_init(&argc, &argv); 788 gtk_init(&argc, &argv);
794 #endif 789 #endif
795 790
796 if (gtk_major_version < GTK_MAJOR_VERSION || 791 if (gtk_major_version < GTK_MAJOR_VERSION ||
801 log_printf("!!! compiled with GTK+-%d.%d\n", GTK_MAJOR_VERSION, GTK_MINOR_VERSION); 796 log_printf("!!! compiled with GTK+-%d.%d\n", GTK_MAJOR_VERSION, GTK_MINOR_VERSION);
802 log_printf("!!! running with GTK+-%d.%d\n", gtk_major_version, gtk_minor_version); 797 log_printf("!!! running with GTK+-%d.%d\n", gtk_major_version, gtk_minor_version);
803 log_printf("!!! %s may quit unexpectedly with a relocation error.\n", GQ_APPNAME); 798 log_printf("!!! %s may quit unexpectedly with a relocation error.\n", GQ_APPNAME);
804 } 799 }
805 800
806 DEBUG_1("%s main: pixbuf_inline_register_stock_icons", get_exec_time()); 801 DEBUG_1("%s main: pixbuf_inline_register_stock_icons", get_exec_time());
807 pixbuf_inline_register_stock_icons(); 802 pixbuf_inline_register_stock_icons();
808 803
809 DEBUG_1("%s main: parse_command_line", get_exec_time()); 804 DEBUG_1("%s main: setting default options before commandline handling", get_exec_time());
805 options = init_options(NULL);
806 setup_default_options(options);
807
808 DEBUG_1("%s main: parse_command_line", get_exec_time());
810 parse_command_line(argc, argv); 809 parse_command_line(argc, argv);
811 810
812 DEBUG_1("%s main: mkdir_if_not_exists", get_exec_time()); 811 DEBUG_1("%s main: mkdir_if_not_exists", get_exec_time());
813 /* these functions don't depend on config file */ 812 /* these functions don't depend on config file */
814 mkdir_if_not_exists(get_rc_dir()); 813 mkdir_if_not_exists(get_rc_dir());
815 mkdir_if_not_exists(get_collections_dir()); 814 mkdir_if_not_exists(get_collections_dir());
816 mkdir_if_not_exists(get_thumbnails_cache_dir()); 815 mkdir_if_not_exists(get_thumbnails_cache_dir());
817 mkdir_if_not_exists(get_metadata_cache_dir()); 816 mkdir_if_not_exists(get_metadata_cache_dir());
821 keys_load(); 820 keys_load();
822 accel_map_load(); 821 accel_map_load();
823 822
824 /* restore session from the config file */ 823 /* restore session from the config file */
825 824
826 options = init_options(NULL); 825
827 setup_default_options(options); 826 DEBUG_1("%s main: load_options", get_exec_time());
828
829 DEBUG_1("%s main: load_options", get_exec_time());
830 if (!load_options(options)) 827 if (!load_options(options))
831 { 828 {
832 /* load_options calls these functions after it parses global options, we have to call it here if it fails */ 829 /* load_options calls these functions after it parses global options, we have to call it here if it fails */
833 filter_add_defaults(); 830 filter_add_defaults();
834 filter_rebuild(); 831 filter_rebuild();
835 } 832 }
836 833
837 /* handle missing config file and commandline additions*/ 834 /* handle missing config file and commandline additions*/
838 if (!layout_window_list) 835 if (!layout_window_list)
839 { 836 {
840 /* broken or no config file */ 837 /* broken or no config file */
841 layout_new_from_config(NULL, NULL, TRUE); 838 layout_new_from_config(NULL, NULL, TRUE);
842 } 839 }
843 840
917 } 914 }
918 915
919 buf = g_build_filename(get_rc_dir(), ".command", NULL); 916 buf = g_build_filename(get_rc_dir(), ".command", NULL);
920 remote_connection = remote_server_init(buf, cd); 917 remote_connection = remote_server_init(buf, cd);
921 g_free(buf); 918 g_free(buf);
922 919
923 DEBUG_1("%s main: gtk_main", get_exec_time()); 920 DEBUG_1("%s main: gtk_main", get_exec_time());
924 gtk_main(); 921 gtk_main();
925 #ifdef HAVE_GTHREAD 922 #ifdef HAVE_GTHREAD
926 gdk_threads_leave(); 923 gdk_threads_leave();
927 #endif 924 #endif
928 return 0; 925 return 0;