comparison src/main.c @ 442:4b2d7f9af171

Big whitespaces cleanup: - drop whitespaces at end of lines - convert eight spaces to tab at start of lines - drop spurious spaces mixed with tabs - remove empty lines at end of files
author zas_
date Sun, 20 Apr 2008 13:04:57 +0000
parents 5ddcf93278c7
children ddabc4873a3f
comparison
equal deleted inserted replaced
441:08eb7137cd94 442:4b2d7f9af171
49 49
50 /* 50 /*
51 *----------------------------------------------------------------------------- 51 *-----------------------------------------------------------------------------
52 * misc (public) 52 * misc (public)
53 *----------------------------------------------------------------------------- 53 *-----------------------------------------------------------------------------
54 */ 54 */
55 55
56 GtkWidget *window_new(GtkWindowType type, const gchar *name, const gchar *icon, 56 GtkWidget *window_new(GtkWindowType type, const gchar *name, const gchar *icon,
57 const gchar *icon_file, const gchar *subtitle) 57 const gchar *icon_file, const gchar *subtitle)
58 { 58 {
59 gchar *title; 59 gchar *title;
60 GtkWidget *window; 60 GtkWidget *window;
61 61
62 window = gtk_window_new(type); 62 window = gtk_window_new(type);
63 if (!window) return NULL; 63 if (!window) return NULL;
64 64
65 if (subtitle) 65 if (subtitle)
66 { 66 {
67 title = g_strdup_printf("%s - %s", subtitle, GQ_APPNAME); 67 title = g_strdup_printf("%s - %s", subtitle, GQ_APPNAME);
68 } 68 }
69 else 69 else
70 { 70 {
71 title = g_strdup_printf("%s", GQ_APPNAME); 71 title = g_strdup_printf("%s", GQ_APPNAME);
72 } 72 }
73 73
74 gtk_window_set_title(GTK_WINDOW(window), title); 74 gtk_window_set_title(GTK_WINDOW(window), title);
75 g_free(title); 75 g_free(title);
76 76
77 window_set_icon(window, icon, icon_file); 77 window_set_icon(window, icon, icon_file);
78 gtk_window_set_role(GTK_WINDOW(window), name); 78 gtk_window_set_role(GTK_WINDOW(window), name);
148 148
149 struct timeval tv = {0, 0}; 149 struct timeval tv = {0, 0};
150 static struct timeval delta = {0, 0}; 150 static struct timeval delta = {0, 0};
151 151
152 gettimeofday(&tv, NULL); 152 gettimeofday(&tv, NULL);
153 153
154 if (start_tv.tv_sec == 0) start_tv = tv; 154 if (start_tv.tv_sec == 0) start_tv = tv;
155 155
156 tv.tv_sec -= start_tv.tv_sec; 156 tv.tv_sec -= start_tv.tv_sec;
157 if (tv.tv_usec >= start_tv.tv_usec) 157 if (tv.tv_usec >= start_tv.tv_usec)
158 tv.tv_usec -= start_tv.tv_usec; 158 tv.tv_usec -= start_tv.tv_usec;
159 else 159 else
160 { 160 {
161 tv.tv_usec += 1000000 - start_tv.tv_usec; 161 tv.tv_usec += 1000000 - start_tv.tv_usec;
162 tv.tv_sec -= 1; 162 tv.tv_sec -= 1;
166 166
167 previous = tv; 167 previous = tv;
168 started = 1; 168 started = 1;
169 169
170 g_snprintf(timestr, sizeof(timestr), "%5d.%06d (+%05d.%06d)", (int)tv.tv_sec, (int)tv.tv_usec, (int)delta.tv_sec, (int)delta.tv_usec); 170 g_snprintf(timestr, sizeof(timestr), "%5d.%06d (+%05d.%06d)", (int)tv.tv_sec, (int)tv.tv_usec, (int)delta.tv_sec, (int)delta.tv_usec);
171 171
172 return timestr; 172 return timestr;
173 } 173 }
174 174
175 /* 175 /*
176 *----------------------------------------------------------------------------- 176 *-----------------------------------------------------------------------------
293 293
294 /* 294 /*
295 *----------------------------------------------------------------------------- 295 *-----------------------------------------------------------------------------
296 * help window 296 * help window
297 *----------------------------------------------------------------------------- 297 *-----------------------------------------------------------------------------
298 */ 298 */
299 299
300 static GtkWidget *help_window = NULL; 300 static GtkWidget *help_window = NULL;
301 301
302 static void help_window_destroy_cb(GtkWidget *window, gpointer data) 302 static void help_window_destroy_cb(GtkWidget *window, gpointer data)
303 { 303 {
320 } 320 }
321 321
322 { 322 {
323 gchar *title = g_strdup_printf("%s - %s", _("Help"), GQ_APPNAME); 323 gchar *title = g_strdup_printf("%s - %s", _("Help"), GQ_APPNAME);
324 help_window = help_window_new(title, GQ_WMCLASS, "help", 324 help_window = help_window_new(title, GQ_WMCLASS, "help",
325 GQ_HELPDIR "/README", key); 325 GQ_HELPDIR "/README", key);
326 g_free(title); 326 g_free(title);
327 } 327 }
328 g_signal_connect(G_OBJECT(help_window), "destroy", 328 g_signal_connect(G_OBJECT(help_window), "destroy",
329 G_CALLBACK(help_window_destroy_cb), NULL); 329 G_CALLBACK(help_window_destroy_cb), NULL);
330 } 330 }
580 static RemoteCommandEntry remote_commands[] = { 580 static RemoteCommandEntry remote_commands[] = {
581 /* short, long callback, extra, prefer,description */ 581 /* short, long callback, extra, prefer,description */
582 { "-n", "--next", gr_image_next, FALSE, FALSE, N_("next image") }, 582 { "-n", "--next", gr_image_next, FALSE, FALSE, N_("next image") },
583 { "-b", "--back", gr_image_prev, FALSE, FALSE, N_("previous image") }, 583 { "-b", "--back", gr_image_prev, FALSE, FALSE, N_("previous image") },
584 { NULL, "--first", gr_image_first, FALSE, FALSE, N_("first image") }, 584 { NULL, "--first", gr_image_first, FALSE, FALSE, N_("first image") },
585 { NULL, "--last", gr_image_last, FALSE, FALSE, N_("last image") }, 585 { NULL, "--last", gr_image_last, FALSE, FALSE, N_("last image") },
586 { "-f", "--fullscreen", gr_fullscreen_toggle, FALSE, TRUE, N_("toggle full screen") }, 586 { "-f", "--fullscreen", gr_fullscreen_toggle, FALSE, TRUE, N_("toggle full screen") },
587 { "-fs","--fullscreen-start", gr_fullscreen_start, FALSE, FALSE, N_("start full screen") }, 587 { "-fs","--fullscreen-start", gr_fullscreen_start, FALSE, FALSE, N_("start full screen") },
588 { "-fS","--fullscreen-stop", gr_fullscreen_stop, FALSE, FALSE, N_("stop full screen") }, 588 { "-fS","--fullscreen-stop", gr_fullscreen_stop, FALSE, FALSE, N_("stop full screen") },
589 { "-s", "--slideshow", gr_slideshow_toggle, FALSE, TRUE, N_("toggle slide show") }, 589 { "-s", "--slideshow", gr_slideshow_toggle, FALSE, TRUE, N_("toggle slide show") },
590 { "-ss","--slideshow-start", gr_slideshow_start, FALSE, FALSE, N_("start slide show") }, 590 { "-ss","--slideshow-start", gr_slideshow_start, FALSE, FALSE, N_("start slide show") },
858 858
859 /* 859 /*
860 *----------------------------------------------------------------------------- 860 *-----------------------------------------------------------------------------
861 * command line parser (private) hehe, who needs popt anyway? 861 * command line parser (private) hehe, who needs popt anyway?
862 *----------------------------------------------------------------------------- 862 *-----------------------------------------------------------------------------
863 */ 863 */
864 864
865 static gint startup_blank = FALSE; 865 static gint startup_blank = FALSE;
866 static gint startup_full_screen = FALSE; 866 static gint startup_full_screen = FALSE;
867 static gint startup_in_slideshow = FALSE; 867 static gint startup_in_slideshow = FALSE;
868 static gint startup_command_line_collection = FALSE; 868 static gint startup_command_line_collection = FALSE;
869 869
870 870
871 static void parse_command_line_add_file(const gchar *file_path, gchar **path, gchar **file, 871 static void parse_command_line_add_file(const gchar *file_path, gchar **path, gchar **file,
872 GList **list, GList **collection_list) 872 GList **list, GList **collection_list)
873 { 873 {
874 gchar *path_parsed; 874 gchar *path_parsed;
875 875
876 path_parsed = g_strdup(file_path); 876 path_parsed = g_strdup(file_path);
877 parse_out_relatives(path_parsed); 877 parse_out_relatives(path_parsed);
924 } 924 }
925 925
926 static void parse_command_line_process_dir(const gchar *dir, gchar **path, gchar **file, 926 static void parse_command_line_process_dir(const gchar *dir, gchar **path, gchar **file,
927 GList **list, gchar **first_dir) 927 GList **list, gchar **first_dir)
928 { 928 {
929 929
930 if (!*list && !*first_dir) 930 if (!*list && !*first_dir)
931 { 931 {
932 *first_dir = g_strdup(dir); 932 *first_dir = g_strdup(dir);
933 } 933 }
934 else 934 else
944 } 944 }
945 945
946 static void parse_command_line_process_file(const gchar *file_path, gchar **path, gchar **file, 946 static void parse_command_line_process_file(const gchar *file_path, gchar **path, gchar **file,
947 GList **list, GList **collection_list, gchar **first_dir) 947 GList **list, GList **collection_list, gchar **first_dir)
948 { 948 {
949 949
950 if (*first_dir) 950 if (*first_dir)
951 { 951 {
952 parse_command_line_add_dir(*first_dir, path, file, list); 952 parse_command_line_add_dir(*first_dir, path, file, list);
953 g_free(*first_dir); 953 g_free(*first_dir);
954 *first_dir = NULL; 954 *first_dir = NULL;
1079 #ifdef DEBUG 1079 #ifdef DEBUG
1080 print_term(_(" --debug[=level] turn on debug output\n")); 1080 print_term(_(" --debug[=level] turn on debug output\n"));
1081 #endif 1081 #endif
1082 print_term(_(" -v, --version print version info\n")); 1082 print_term(_(" -v, --version print version info\n"));
1083 print_term(_(" -h, --help show this message\n\n")); 1083 print_term(_(" -h, --help show this message\n\n"));
1084 1084
1085 #if 0 1085 #if 0
1086 /* these options are not officially supported! 1086 /* these options are not officially supported!
1087 * only for testing new features, no need to translate them */ 1087 * only for testing new features, no need to translate them */
1088 print_term( " --alternate use alternate similarity algorithm\n"); 1088 print_term( " --alternate use alternate similarity algorithm\n");
1089 #endif 1089 #endif
1090 1090
1091 exit (0); 1091 exit (0);
1092 } 1092 }
1093 else if (!remote_do) 1093 else if (!remote_do)
1094 { 1094 {
1095 printf_term(_("invalid or ignored: %s\nUse --help for options\n"), cmd_line); 1095 printf_term(_("invalid or ignored: %s\nUse --help for options\n"), cmd_line);
1138 gint len = strlen(debug_option); 1138 gint len = strlen(debug_option);
1139 1139
1140 if (argc > 1) 1140 if (argc > 1)
1141 { 1141 {
1142 gint i; 1142 gint i;
1143 1143
1144 for (i = 1; i < argc; i++) 1144 for (i = 1; i < argc; i++)
1145 { 1145 {
1146 const gchar *cmd_line = argv[i]; 1146 const gchar *cmd_line = argv[i];
1147 if (strncmp(cmd_line, debug_option, len) == 0) 1147 if (strncmp(cmd_line, debug_option, len) == 0)
1148 { 1148 {
1167 1167
1168 /* 1168 /*
1169 *----------------------------------------------------------------------------- 1169 *-----------------------------------------------------------------------------
1170 * startup, init, and exit 1170 * startup, init, and exit
1171 *----------------------------------------------------------------------------- 1171 *-----------------------------------------------------------------------------
1172 */ 1172 */
1173 1173
1174 #define RC_HISTORY_NAME "history" 1174 #define RC_HISTORY_NAME "history"
1175 1175
1176 static void keys_load(void) 1176 static void keys_load(void)
1177 { 1177 {
1197 1197
1198 buf = g_strconcat(homedir(), "/", path, NULL); 1198 buf = g_strconcat(homedir(), "/", path, NULL);
1199 if (!isdir(buf)) 1199 if (!isdir(buf))
1200 { 1200 {
1201 printf_term(_("Creating %s dir:%s\n"), GQ_APPNAME, buf); 1201 printf_term(_("Creating %s dir:%s\n"), GQ_APPNAME, buf);
1202 1202
1203 if (!mkdir_utf8(buf, 0755)) 1203 if (!mkdir_utf8(buf, 0755))
1204 { 1204 {
1205 printf_term(_("Could not create dir:%s\n"), buf); 1205 printf_term(_("Could not create dir:%s\n"), buf);
1206 } 1206 }
1207 } 1207 }
1370 gchar *buf; 1370 gchar *buf;
1371 gchar *bufl; 1371 gchar *bufl;
1372 1372
1373 /* init execution time counter*/ 1373 /* init execution time counter*/
1374 get_exec_time(); 1374 get_exec_time();
1375 1375
1376 /* setup locale, i18n */ 1376 /* setup locale, i18n */
1377 gtk_set_locale(); 1377 gtk_set_locale();
1378 bindtextdomain(PACKAGE, GQ_LOCALEDIR); 1378 bindtextdomain(PACKAGE, GQ_LOCALEDIR);
1379 bind_textdomain_codeset(PACKAGE, "UTF-8"); 1379 bind_textdomain_codeset(PACKAGE, "UTF-8");
1380 textdomain(PACKAGE); 1380 textdomain(PACKAGE);
1381 1381
1382 /* setup random seed for random slideshow */ 1382 /* setup random seed for random slideshow */
1383 srand(time(NULL)); 1383 srand(time(NULL));
1384 1384
1385 #if 1 1385 #if 1
1386 printf("%s %s, This is an alpha release.\n", GQ_APPNAME, VERSION); 1386 printf("%s %s, This is an alpha release.\n", GQ_APPNAME, VERSION);
1387 #endif 1387 #endif
1388 parse_command_line_for_debug_option(argc, argv); 1388 parse_command_line_for_debug_option(argc, argv);
1411 check_for_home_path(GQ_CACHE_RC_METADATA); 1411 check_for_home_path(GQ_CACHE_RC_METADATA);
1412 1412
1413 keys_load(); 1413 keys_load();
1414 filter_add_defaults(); 1414 filter_add_defaults();
1415 filter_rebuild(); 1415 filter_rebuild();
1416 1416
1417 buf = g_strconcat(homedir(), "/", GQ_RC_DIR, "/accels", NULL); 1417 buf = g_strconcat(homedir(), "/", GQ_RC_DIR, "/accels", NULL);
1418 bufl = path_from_utf8(buf); 1418 bufl = path_from_utf8(buf);
1419 gtk_accel_map_load(bufl); 1419 gtk_accel_map_load(bufl);
1420 g_free(bufl); 1420 g_free(bufl);
1421 g_free(buf); 1421 g_free(buf);