Mercurial > geeqie
comparison src/info.c @ 684:9f00d0d874fa
Save order of Properties dialog tabs to rc file.
Users of GTK+ <2.10 can set tabs order directly in the rc file,
others can move tabs using drag'n drop.
The option is named properties.tabs_order, its default value
is "123" which is General, Keywords, Exif tabs (left to right).
author | zas_ |
---|---|
date | Sun, 18 May 2008 21:14:01 +0000 |
parents | e34c1002e553 |
children | a7289f9e8d29 |
comparison
equal
deleted
inserted
replaced
683:fece9ff5c624 | 684:9f00d0d874fa |
---|---|
486 | 486 |
487 if (ta->pos > tb->pos) return 1; | 487 if (ta->pos > tb->pos) return 1; |
488 return -1; | 488 return -1; |
489 } | 489 } |
490 | 490 |
491 static gpointer info_tab_new_funcs[] = { | |
492 info_tab_general_new, | |
493 info_tab_meta_new, | |
494 info_tab_exif_new, | |
495 }; | |
496 | |
497 gchar *info_tab_default_order(void) | |
498 { | |
499 gint i; | |
500 static gchar str[G_N_ELEMENTS(info_tab_new_funcs) + 1]; | |
501 | |
502 for (i = 0; i < G_N_ELEMENTS(info_tab_new_funcs); i++) | |
503 str[i] = i + '1'; | |
504 str[i] = '\0'; | |
505 | |
506 return str; | |
507 } | |
508 | |
509 static void info_tab_get_order_string(gchar **dest) | |
510 { | |
511 GList *work; | |
512 gchar str[G_N_ELEMENTS(info_tab_new_funcs) + 1]; | |
513 | |
514 g_assert(dest); | |
515 | |
516 if (!info_tabs_pos_list) | |
517 return; | |
518 | |
519 memset(str, 0, G_N_ELEMENTS(info_tab_new_funcs) + 1); | |
520 | |
521 work = info_tabs_pos_list; | |
522 while (work) | |
523 { | |
524 gint i; | |
525 InfoTabsPos *t = work->data; | |
526 work = work->next; | |
527 | |
528 for (i = 0; i < G_N_ELEMENTS(info_tab_new_funcs); i++) | |
529 { | |
530 if (t->func == info_tab_new_funcs[i]) | |
531 { | |
532 g_assert(t->pos >= 0 && t->pos < G_N_ELEMENTS(info_tab_new_funcs)); | |
533 str[t->pos] = i + '1'; | |
534 } | |
535 } | |
536 } | |
537 | |
538 if (strlen(str) != G_N_ELEMENTS(info_tab_new_funcs)) return; | |
539 | |
540 g_free(*dest); | |
541 *dest = g_strdup(str); | |
542 } | |
543 | |
491 static void info_tabs_init(InfoData *id) | 544 static void info_tabs_init(InfoData *id) |
492 { | 545 { |
493 GList *work; | 546 GList *work; |
494 | 547 |
495 if (!info_tabs_pos_list) | 548 if (!info_tabs_pos_list) |
496 { | 549 { |
497 /* First run, default tabs order is defined here. */ | 550 gint count = 0; |
498 info_tabs_pos_list_append(info_tab_general_new); | 551 gint i; |
499 info_tabs_pos_list_append(info_tab_meta_new); | 552 gchar *order = options->properties.tabs_order; |
500 info_tabs_pos_list_append(info_tab_exif_new); | 553 |
554 for (i = 0; i < strlen(order); i++) | |
555 { | |
556 gint n = order[i] - '1'; | |
557 | |
558 if (n < 0 || n >= G_N_ELEMENTS(info_tab_new_funcs)) break; | |
559 count++; | |
560 } | |
561 | |
562 if (count != G_N_ELEMENTS(info_tab_new_funcs)) | |
563 order = info_tab_default_order(); | |
564 | |
565 for (i = 0; i < strlen(order); i++) | |
566 { | |
567 gint n = order[i] - '1'; | |
568 | |
569 if (n < 0 || n >= G_N_ELEMENTS(info_tab_new_funcs)) continue; | |
570 if (g_list_find(info_tabs_pos_list, info_tab_new_funcs[n])) continue; | |
571 info_tabs_pos_list_append(info_tab_new_funcs[n]); | |
572 } | |
501 } | 573 } |
502 else | 574 else |
503 info_tabs_pos_list = g_list_sort(info_tabs_pos_list, compare_info_tabs_pos); | 575 info_tabs_pos_list = g_list_sort(info_tabs_pos_list, compare_info_tabs_pos); |
576 | |
577 info_tab_get_order_string(&options->properties.tabs_order); | |
504 | 578 |
505 work = info_tabs_pos_list; | 579 work = info_tabs_pos_list; |
506 while (work) | 580 while (work) |
507 { | 581 { |
508 InfoTabsPos *t = work->data; | 582 InfoTabsPos *t = work->data; |
566 t->pos = pos; | 640 t->pos = pos; |
567 break; | 641 break; |
568 } | 642 } |
569 } | 643 } |
570 } | 644 } |
645 | |
646 info_tabs_pos_list = g_list_sort(info_tabs_pos_list, compare_info_tabs_pos); | |
647 info_tab_get_order_string(&options->properties.tabs_order); | |
571 } | 648 } |
572 | 649 |
573 /* | 650 /* |
574 *------------------------------------------------------------------- | 651 *------------------------------------------------------------------- |
575 * drag n drop (dropping not supported!) | 652 * drag n drop (dropping not supported!) |