gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r19671 - gnunet-gtk/src/fs


From: gnunet
Subject: [GNUnet-SVN] r19671 - gnunet-gtk/src/fs
Date: Fri, 3 Feb 2012 16:17:31 +0100

Author: grothoff
Date: 2012-02-03 16:17:31 +0100 (Fri, 03 Feb 2012)
New Revision: 19671

Modified:
   gnunet-gtk/src/fs/gnunet-fs-gtk_publish-edit-dialog.c
Log:
-convert to UTF-8 if needed

Modified: gnunet-gtk/src/fs/gnunet-fs-gtk_publish-edit-dialog.c
===================================================================
--- gnunet-gtk/src/fs/gnunet-fs-gtk_publish-edit-dialog.c       2012-02-03 
13:10:01 UTC (rev 19670)
+++ gnunet-gtk/src/fs/gnunet-fs-gtk_publish-edit-dialog.c       2012-02-03 
15:17:31 UTC (rev 19671)
@@ -947,6 +947,45 @@
 
 
 /**
+ * Set the title of the window based on the filename in the meta data.
+ *
+ * @param cls the window
+ * @param plugin_name name of the plugin that produced this value;
+ *        special values can be used (i.e. '<zlib>' for zlib being
+ *        used in the main libextractor library and yielding
+ *        meta data).
+ * @param type libextractor-type describing the meta data
+ * @param format basic format information about data 
+ * @param data_mime_type mime-type of data (not of the original file);
+ *        can be NULL (if mime-type is not known)
+ * @param data actual meta-data found
+ * @param data_len number of bytes in data
+ * @return 0 to continue extracting, 1 to abort
+ */ 
+static int
+set_window_title_to_filename (void *cls,
+                             const char *plugin_name,
+                             enum EXTRACTOR_MetaType type,
+                             enum EXTRACTOR_MetaFormat format,
+                             const char *data_mime_type,
+                             const char *data,
+                             size_t data_len)
+{
+  char *utf8;
+
+  if (EXTRACTOR_METATYPE_FILENAME != type)
+    return 0;
+  utf8 = GNUNET_FS_GTK_dubious_meta_to_utf8 (format,
+                                            data, data_len);
+  if (NULL == utf8)
+    return 0;
+  gtk_window_set_title (GTK_WINDOW (cls), utf8);
+  GNUNET_free (utf8);
+  return 1;
+}
+
+
+/**
  * Function called to extract the information from FI to populate the edit 
dialog.
  *
  * @param cls the 'struct EditPublicationDialogContext'
@@ -970,7 +1009,6 @@
 {
   struct EditPublicationDialogContext *ctx = cls;
   GdkPixbuf *pixbuf;
-  char *short_fn;
   int year;
 
   /* import options */
@@ -1001,19 +1039,10 @@
   }
   
   /* Also update window title based on filename */
-  short_fn = GNUNET_CONTAINER_meta_data_get_first_by_types (meta,
-                                                           
EXTRACTOR_METATYPE_FILENAME,
-                                                           -1);
-  if (NULL == short_fn)
-  {
-    gtk_window_set_title (ctx->edit_publication_window, _("<unnamed>"));
-  }
-  else
-  {
-    /* FIXME-BUG-MAYBE: ensure that short_fn is UTF-8 encoded */
-    gtk_window_set_title (ctx->edit_publication_window, short_fn);
-    GNUNET_free (short_fn);
-  }
+  gtk_window_set_title (ctx->edit_publication_window, _("<unnamed>"));
+  GNUNET_CONTAINER_meta_data_iterate (meta,
+                                     &set_window_title_to_filename,
+                                     ctx->edit_publication_window);
   return GNUNET_SYSERR;         /* only visit top-level item */
 }
 
@@ -1118,11 +1147,6 @@
                           GNUNET_FS_GTK_get_anonymity_level_list_store ());
   GNUNET_FS_GTK_setup_expiration_year_adjustment (ctx->builder);
 
-  /* FIXME-UNCLEAN: are the following three even required anymore? */
-  gtk_list_store_clear (ctx->keywords_liststore);
-  gtk_list_store_clear (ctx->meta_liststore);
-  gtk_entry_set_text (ctx->keyword_entry, "");
-
   pubtypes_combo =
       GTK_COMBO_BOX (gtk_builder_get_object
                      (ctx->builder, "GNUNET_GTK_edit_publication_type_combo"));




reply via email to

[Prev in Thread] Current Thread [Next in Thread]