diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-02-03 15:17:31 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-02-03 15:17:31 +0000 |
commit | cfe3b19d5ba08a48df1385a9d179bb5bfaa32de3 (patch) | |
tree | 4091c2d60160d2a906c53481ec2a585f823ce8f0 | |
parent | ce10aef80a820bacf1e0f4fd741703b89bc2efd2 (diff) | |
download | gnunet-gtk-cfe3b19d5ba08a48df1385a9d179bb5bfaa32de3.tar.gz gnunet-gtk-cfe3b19d5ba08a48df1385a9d179bb5bfaa32de3.zip |
-convert to UTF-8 if needed
-rw-r--r-- | src/fs/gnunet-fs-gtk_publish-edit-dialog.c | 62 |
1 files changed, 43 insertions, 19 deletions
diff --git a/src/fs/gnunet-fs-gtk_publish-edit-dialog.c b/src/fs/gnunet-fs-gtk_publish-edit-dialog.c index 47197ae3..48b91b8f 100644 --- a/src/fs/gnunet-fs-gtk_publish-edit-dialog.c +++ b/src/fs/gnunet-fs-gtk_publish-edit-dialog.c | |||
@@ -947,6 +947,45 @@ add_keyword (void *cls, const char *keyword, int is_mandatory) | |||
947 | 947 | ||
948 | 948 | ||
949 | /** | 949 | /** |
950 | * Set the title of the window based on the filename in the meta data. | ||
951 | * | ||
952 | * @param cls the window | ||
953 | * @param plugin_name name of the plugin that produced this value; | ||
954 | * special values can be used (i.e. '<zlib>' for zlib being | ||
955 | * used in the main libextractor library and yielding | ||
956 | * meta data). | ||
957 | * @param type libextractor-type describing the meta data | ||
958 | * @param format basic format information about data | ||
959 | * @param data_mime_type mime-type of data (not of the original file); | ||
960 | * can be NULL (if mime-type is not known) | ||
961 | * @param data actual meta-data found | ||
962 | * @param data_len number of bytes in data | ||
963 | * @return 0 to continue extracting, 1 to abort | ||
964 | */ | ||
965 | static int | ||
966 | set_window_title_to_filename (void *cls, | ||
967 | const char *plugin_name, | ||
968 | enum EXTRACTOR_MetaType type, | ||
969 | enum EXTRACTOR_MetaFormat format, | ||
970 | const char *data_mime_type, | ||
971 | const char *data, | ||
972 | size_t data_len) | ||
973 | { | ||
974 | char *utf8; | ||
975 | |||
976 | if (EXTRACTOR_METATYPE_FILENAME != type) | ||
977 | return 0; | ||
978 | utf8 = GNUNET_FS_GTK_dubious_meta_to_utf8 (format, | ||
979 | data, data_len); | ||
980 | if (NULL == utf8) | ||
981 | return 0; | ||
982 | gtk_window_set_title (GTK_WINDOW (cls), utf8); | ||
983 | GNUNET_free (utf8); | ||
984 | return 1; | ||
985 | } | ||
986 | |||
987 | |||
988 | /** | ||
950 | * Function called to extract the information from FI to populate the edit dialog. | 989 | * Function called to extract the information from FI to populate the edit dialog. |
951 | * | 990 | * |
952 | * @param cls the 'struct EditPublicationDialogContext' | 991 | * @param cls the 'struct EditPublicationDialogContext' |
@@ -970,7 +1009,6 @@ file_information_import (void *cls, | |||
970 | { | 1009 | { |
971 | struct EditPublicationDialogContext *ctx = cls; | 1010 | struct EditPublicationDialogContext *ctx = cls; |
972 | GdkPixbuf *pixbuf; | 1011 | GdkPixbuf *pixbuf; |
973 | char *short_fn; | ||
974 | int year; | 1012 | int year; |
975 | 1013 | ||
976 | /* import options */ | 1014 | /* import options */ |
@@ -1001,19 +1039,10 @@ file_information_import (void *cls, | |||
1001 | } | 1039 | } |
1002 | 1040 | ||
1003 | /* Also update window title based on filename */ | 1041 | /* Also update window title based on filename */ |
1004 | short_fn = GNUNET_CONTAINER_meta_data_get_first_by_types (meta, | 1042 | gtk_window_set_title (ctx->edit_publication_window, _("<unnamed>")); |
1005 | EXTRACTOR_METATYPE_FILENAME, | 1043 | GNUNET_CONTAINER_meta_data_iterate (meta, |
1006 | -1); | 1044 | &set_window_title_to_filename, |
1007 | if (NULL == short_fn) | 1045 | ctx->edit_publication_window); |
1008 | { | ||
1009 | gtk_window_set_title (ctx->edit_publication_window, _("<unnamed>")); | ||
1010 | } | ||
1011 | else | ||
1012 | { | ||
1013 | /* FIXME-BUG-MAYBE: ensure that short_fn is UTF-8 encoded */ | ||
1014 | gtk_window_set_title (ctx->edit_publication_window, short_fn); | ||
1015 | GNUNET_free (short_fn); | ||
1016 | } | ||
1017 | return GNUNET_SYSERR; /* only visit top-level item */ | 1046 | return GNUNET_SYSERR; /* only visit top-level item */ |
1018 | } | 1047 | } |
1019 | 1048 | ||
@@ -1118,11 +1147,6 @@ GNUNET_FS_GTK_edit_publish_dialog (GtkWindow * parent, | |||
1118 | GNUNET_FS_GTK_get_anonymity_level_list_store ()); | 1147 | GNUNET_FS_GTK_get_anonymity_level_list_store ()); |
1119 | GNUNET_FS_GTK_setup_expiration_year_adjustment (ctx->builder); | 1148 | GNUNET_FS_GTK_setup_expiration_year_adjustment (ctx->builder); |
1120 | 1149 | ||
1121 | /* FIXME-UNCLEAN: are the following three even required anymore? */ | ||
1122 | gtk_list_store_clear (ctx->keywords_liststore); | ||
1123 | gtk_list_store_clear (ctx->meta_liststore); | ||
1124 | gtk_entry_set_text (ctx->keyword_entry, ""); | ||
1125 | |||
1126 | pubtypes_combo = | 1150 | pubtypes_combo = |
1127 | GTK_COMBO_BOX (gtk_builder_get_object | 1151 | GTK_COMBO_BOX (gtk_builder_get_object |
1128 | (ctx->builder, "GNUNET_GTK_edit_publication_type_combo")); | 1152 | (ctx->builder, "GNUNET_GTK_edit_publication_type_combo")); |