comparison src/main.c @ 403:2649a28d31b6

Introduce printf_term() macro and use it.
author zas_
date Fri, 18 Apr 2008 09:15:09 +0000
parents de6060230ec5
children eb5ae19a62f6
comparison
equal deleted inserted replaced
402:f6046e1b3622 403:2649a28d31b6
418 gdouble n; 418 gdouble n;
419 419
420 n = strtod(text, NULL); 420 n = strtod(text, NULL);
421 if (n < SLIDESHOW_MIN_SECONDS || n > SLIDESHOW_MAX_SECONDS) 421 if (n < SLIDESHOW_MIN_SECONDS || n > SLIDESHOW_MAX_SECONDS)
422 { 422 {
423 gchar *buf; 423 printf_term("Remote slideshow delay out of range (%.1f to %.1f)\n",
424 424 SLIDESHOW_MIN_SECONDS, SLIDESHOW_MAX_SECONDS);
425 buf = g_strdup_printf("Remote slideshow delay out of range (%.1f to %.1f)\n",
426 SLIDESHOW_MIN_SECONDS, SLIDESHOW_MAX_SECONDS);
427 print_term(buf);
428 g_free(buf);
429
430 return; 425 return;
431 } 426 }
432 options->slideshow.delay = (gint)(n * 10.0 + 0.01); 427 options->slideshow.delay = (gint)(n * 10.0 + 0.01);
433 } 428 }
434 429
641 i = 0; 636 i = 0;
642 while (remote_commands[i].func != NULL) 637 while (remote_commands[i].func != NULL)
643 { 638 {
644 if (remote_commands[i].description) 639 if (remote_commands[i].description)
645 { 640 {
646 gchar *buf; 641 printf_term(" %-3s%s %-20s %s\n",
647 642 (remote_commands[i].opt_s) ? remote_commands[i].opt_s : "",
648 buf = g_strdup_printf(" %-3s%s %-20s %s\n", 643 (remote_commands[i].opt_s && remote_commands[i].opt_l) ? "," : " ",
649 (remote_commands[i].opt_s) ? remote_commands[i].opt_s : "", 644 (remote_commands[i].opt_l) ? remote_commands[i].opt_l : "",
650 (remote_commands[i].opt_s && remote_commands[i].opt_l) ? "," : " ", 645 _(remote_commands[i].description));
651 (remote_commands[i].opt_l) ? remote_commands[i].opt_l : "",
652 _(remote_commands[i].description));
653
654 print_term(buf);
655 g_free(buf);
656 } 646 }
657 i++; 647 i++;
658 } 648 }
659 } 649 }
660 650
692 GString *command; 682 GString *command;
693 GList *work; 683 GList *work;
694 gint retry_count = 12; 684 gint retry_count = 12;
695 gint blank = FALSE; 685 gint blank = FALSE;
696 686
697 { 687 printf_term(_("Remote %s not running, starting..."), GQ_APPNAME);
698 gchar *msg = g_strdup_printf(_("Remote %s not running, starting..."), GQ_APPNAME);
699 print_term(msg);
700 g_free(msg);
701 }
702 688
703 command = g_string_new(arg_exec); 689 command = g_string_new(arg_exec);
704 690
705 work = remote_list; 691 work = remote_list;
706 while (work) 692 while (work)
1047 image_sim_alternate_set(TRUE); 1033 image_sim_alternate_set(TRUE);
1048 } 1034 }
1049 else if (strcmp(cmd_line, "-h") == 0 || 1035 else if (strcmp(cmd_line, "-h") == 0 ||
1050 strcmp(cmd_line, "--help") == 0) 1036 strcmp(cmd_line, "--help") == 0)
1051 { 1037 {
1052 gchar *usage = g_strdup_printf(_("Usage: %s [options] [path]\n\n"), GQ_APPNAME_LC);
1053 printf("%s %s\n", GQ_APPNAME, VERSION); 1038 printf("%s %s\n", GQ_APPNAME, VERSION);
1054 print_term(usage); 1039 printf_term(_("Usage: %s [options] [path]\n\n"), GQ_APPNAME_LC);
1055 g_free(usage);
1056 print_term(_("valid options are:\n")); 1040 print_term(_("valid options are:\n"));
1057 print_term(_(" +t, --with-tools force show of tools\n")); 1041 print_term(_(" +t, --with-tools force show of tools\n"));
1058 print_term(_(" -t, --without-tools force hide of tools\n")); 1042 print_term(_(" -t, --without-tools force hide of tools\n"));
1059 print_term(_(" -f, --fullscreen start in full screen mode\n")); 1043 print_term(_(" -f, --fullscreen start in full screen mode\n"));
1060 print_term(_(" -s, --slideshow start in slideshow mode\n")); 1044 print_term(_(" -s, --slideshow start in slideshow mode\n"));
1076 1060
1077 exit (0); 1061 exit (0);
1078 } 1062 }
1079 else if (!remote_do) 1063 else if (!remote_do)
1080 { 1064 {
1081 gchar *buf; 1065 printf_term(_("invalid or ignored: %s\nUse --help for options\n"), cmd_line);
1082
1083 buf = g_strdup_printf(_("invalid or ignored: %s\nUse --help for options\n"), cmd_line);
1084 print_term(buf);
1085 g_free(buf);
1086 } 1066 }
1087 1067
1088 g_free(cmd_all); 1068 g_free(cmd_all);
1089 i++; 1069 i++;
1090 } 1070 }
1186 gchar *buf; 1166 gchar *buf;
1187 1167
1188 buf = g_strconcat(homedir(), "/", path, NULL); 1168 buf = g_strconcat(homedir(), "/", path, NULL);
1189 if (!isdir(buf)) 1169 if (!isdir(buf))
1190 { 1170 {
1191 gchar *tmp; 1171 printf_term(_("Creating %s dir:%s\n"), GQ_APPNAME, buf);
1192 1172
1193 tmp = g_strdup_printf(_("Creating %s dir:%s\n"), GQ_APPNAME, buf);
1194 print_term(tmp);
1195 g_free(tmp);
1196
1197 if (!mkdir_utf8(buf, 0755)) 1173 if (!mkdir_utf8(buf, 0755))
1198 { 1174 {
1199 tmp = g_strdup_printf(_("Could not create dir:%s\n"), buf); 1175 printf_term(_("Could not create dir:%s\n"), buf);
1200 print_term(tmp);
1201 g_free(tmp);
1202 } 1176 }
1203 } 1177 }
1204 g_free(buf); 1178 g_free(buf);
1205 } 1179 }
1206 1180
1390 gtk_init (&argc, &argv); 1364 gtk_init (&argc, &argv);
1391 1365
1392 if (gtk_major_version < GTK_MAJOR_VERSION || 1366 if (gtk_major_version < GTK_MAJOR_VERSION ||
1393 (gtk_major_version == GTK_MAJOR_VERSION && gtk_minor_version < GTK_MINOR_VERSION) ) 1367 (gtk_major_version == GTK_MAJOR_VERSION && gtk_minor_version < GTK_MINOR_VERSION) )
1394 { 1368 {
1395 gchar *msg; 1369 printf_term("!!! This is a friendly warning.\n");
1396 1370 printf_term("!!! The version of GTK+ in use now is older than when %s was compiled.\n", GQ_APPNAME);
1397 print_term("!!! This is a friendly warning.\n"); 1371 printf_term("!!! compiled with GTK+-%d.%d\n", GTK_MAJOR_VERSION, GTK_MINOR_VERSION);
1398 msg = g_strdup_printf("!!! The version of GTK+ in use now is older than when %s was compiled.\n", GQ_APPNAME); 1372 printf_term("!!! running with GTK+-%d.%d\n", gtk_major_version, gtk_minor_version);
1399 print_term(msg); 1373 printf_term("!!! %s may quit unexpectedly with a relocation error.\n", GQ_APPNAME);
1400 g_free(msg);
1401 msg = g_strdup_printf("!!! compiled with GTK+-%d.%d\n", GTK_MAJOR_VERSION, GTK_MINOR_VERSION);
1402 print_term(msg);
1403 g_free(msg);
1404 msg = g_strdup_printf("!!! running with GTK+-%d.%d\n", gtk_major_version, gtk_minor_version);
1405 print_term(msg);
1406 g_free(msg);
1407 msg = g_strdup_printf("!!! %s may quit unexpectedly with a relocation error.\n", GQ_APPNAME);
1408 print_term(msg);
1409 g_free(msg);
1410 } 1374 }
1411 1375
1412 check_for_home_path(GQ_RC_DIR); 1376 check_for_home_path(GQ_RC_DIR);
1413 check_for_home_path(GQ_RC_DIR_COLLECTIONS); 1377 check_for_home_path(GQ_RC_DIR_COLLECTIONS);
1414 check_for_home_path(GQ_CACHE_RC_THUMB); 1378 check_for_home_path(GQ_CACHE_RC_THUMB);