comparison src/bar_exif.c @ 1469:607c60506863

added a possibility to update existing bars from config
author nadvornik
date Fri, 20 Mar 2009 21:28:31 +0000
parents 1b3751ac4743
children 65a5c27823c2
comparison
equal deleted inserted replaced
1468:e9f9d3da3f43 1469:607c60506863
651 651
652 ped = g_object_get_data(G_OBJECT(pane), "pane_data"); 652 ped = g_object_get_data(G_OBJECT(pane), "pane_data");
653 if (!ped) return; 653 if (!ped) return;
654 654
655 WRITE_NL(); WRITE_STRING("<pane_exif "); 655 WRITE_NL(); WRITE_STRING("<pane_exif ");
656 write_char_option(outstr, indent, "pane.title", gtk_label_get_text(GTK_LABEL(ped->pane.title))); 656 write_char_option(outstr, indent, "id", ped->pane.id);
657 WRITE_BOOL(*ped, pane.expanded); 657 write_char_option(outstr, indent, "title", gtk_label_get_text(GTK_LABEL(ped->pane.title)));
658 WRITE_BOOL(ped->pane, expanded);
658 WRITE_STRING(">"); 659 WRITE_STRING(">");
659 indent++; 660 indent++;
660 661
661 list = gtk_container_get_children(GTK_CONTAINER(ped->vbox)); 662 list = gtk_container_get_children(GTK_CONTAINER(ped->vbox));
662 work = list; 663 work = list;
688 PaneExifData *ped = data; 689 PaneExifData *ped = data;
689 690
690 file_data_unregister_notify_func(bar_pane_exif_notify_cb, ped); 691 file_data_unregister_notify_func(bar_pane_exif_notify_cb, ped);
691 g_object_unref(ped->size_group); 692 g_object_unref(ped->size_group);
692 file_data_unref(ped->fd); 693 file_data_unref(ped->fd);
694 g_free(ped->pane.id);
693 g_free(ped); 695 g_free(ped);
694 } 696 }
695 697
696 static void bar_pane_exif_size_request(GtkWidget *pane, GtkRequisition *requisition, gpointer data) 698 static void bar_pane_exif_size_request(GtkWidget *pane, GtkRequisition *requisition, gpointer data)
697 { 699 {
706 { 708 {
707 PaneExifData *ped = data; 709 PaneExifData *ped = data;
708 ped->min_height = alloc->height; 710 ped->min_height = alloc->height;
709 } 711 }
710 712
711 GtkWidget *bar_pane_exif_new(const gchar *title, gboolean expanded, gboolean populate) 713 GtkWidget *bar_pane_exif_new(const gchar *id, const gchar *title, gboolean expanded, gboolean populate)
712 { 714 {
713 PaneExifData *ped; 715 PaneExifData *ped;
714 716
715 ped = g_new0(PaneExifData, 1); 717 ped = g_new0(PaneExifData, 1);
716 718
717 ped->pane.pane_set_fd = bar_pane_exif_set_fd; 719 ped->pane.pane_set_fd = bar_pane_exif_set_fd;
718 ped->pane.pane_write_config = bar_pane_exif_write_config; 720 ped->pane.pane_write_config = bar_pane_exif_write_config;
719 ped->pane.pane_event = bar_pane_exif_event; 721 ped->pane.pane_event = bar_pane_exif_event;
720 ped->pane.title = bar_pane_expander_title(title); 722 ped->pane.title = bar_pane_expander_title(title);
723 ped->pane.id = g_strdup(id);
721 ped->pane.expanded = expanded; 724 ped->pane.expanded = expanded;
725 ped->pane.type = PANE_EXIF;
722 726
723 ped->size_group = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); 727 ped->size_group = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
724 ped->widget = gtk_event_box_new(); 728 ped->widget = gtk_event_box_new();
725 ped->vbox = gtk_vbox_new(FALSE, PREF_PAD_GAP); 729 ped->vbox = gtk_vbox_new(FALSE, PREF_PAD_GAP);
726 gtk_container_add(GTK_CONTAINER(ped->widget), ped->vbox); 730 gtk_container_add(GTK_CONTAINER(ped->widget), ped->vbox);
769 return ped->widget; 773 return ped->widget;
770 } 774 }
771 775
772 GtkWidget *bar_pane_exif_new_from_config(const gchar **attribute_names, const gchar **attribute_values) 776 GtkWidget *bar_pane_exif_new_from_config(const gchar **attribute_names, const gchar **attribute_values)
773 { 777 {
774 gchar *title = g_strdup(_("NoName")); 778 gchar *title = g_strdup(_("Exif"));
779 gchar *id = g_strdup("exif");
775 gboolean expanded = TRUE; 780 gboolean expanded = TRUE;
781 GtkWidget *ret;
776 782
777 while (*attribute_names) 783 while (*attribute_names)
778 { 784 {
779 const gchar *option = *attribute_names++; 785 const gchar *option = *attribute_names++;
780 const gchar *value = *attribute_values++; 786 const gchar *value = *attribute_values++;
781 787
782 if (READ_CHAR_FULL("pane.title", title)) continue; 788 if (READ_CHAR_FULL("id", id)) continue;
783 if (READ_BOOL_FULL("pane.expanded", expanded)) continue; 789 if (READ_CHAR_FULL("title", title)) continue;
790 if (READ_BOOL_FULL("expanded", expanded)) continue;
784 791
785 log_printf("unknown attribute %s = %s\n", option, value); 792 log_printf("unknown attribute %s = %s\n", option, value);
786 } 793 }
787 794
788 return bar_pane_exif_new(title, expanded, FALSE); 795 ret = bar_pane_exif_new(id, title, expanded, FALSE);
789 } 796 g_free(title);
797 g_free(id);
798 return ret;
799 }
800
801 void bar_pane_exif_update_from_config(GtkWidget *pane, const gchar **attribute_names, const gchar **attribute_values)
802 {
803 PaneExifData *ped;
804
805 ped = g_object_get_data(G_OBJECT(pane), "pane_data");
806 if (!ped) return;
807
808 gchar *title = NULL;
809
810 while (*attribute_names)
811 {
812 const gchar *option = *attribute_names++;
813 const gchar *value = *attribute_values++;
814
815 if (READ_CHAR_FULL("title", title)) continue;
816 if (READ_BOOL_FULL("expanded", ped->pane.expanded)) continue;
817 if (READ_CHAR_FULL("id", ped->pane.id)) continue;
818
819
820 log_printf("unknown attribute %s = %s\n", option, value);
821 }
822
823 if (title)
824 {
825 gtk_label_set_text(GTK_LABEL(ped->pane.title), title);
826 g_free(title);
827 }
828
829 bar_update_expander(pane);
830 bar_pane_exif_update(ped);
831 }
832
790 833
791 void bar_pane_exif_entry_add_from_config(GtkWidget *pane, const gchar **attribute_names, const gchar **attribute_values) 834 void bar_pane_exif_entry_add_from_config(GtkWidget *pane, const gchar **attribute_names, const gchar **attribute_values)
792 { 835 {
793 PaneExifData *ped; 836 PaneExifData *ped;
794 gchar *key = NULL; 837 gchar *key = NULL;