gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r3915 - gnunet-gtk/src/plugins/fs


From: grothoff
Subject: [GNUnet-SVN] r3915 - gnunet-gtk/src/plugins/fs
Date: Sun, 10 Dec 2006 21:16:37 -0800 (PST)

Author: grothoff
Date: 2006-12-10 21:16:35 -0800 (Sun, 10 Dec 2006)
New Revision: 3915

Modified:
   gnunet-gtk/src/plugins/fs/meta.c
   gnunet-gtk/src/plugins/fs/upload.c
Log:
scale

Modified: gnunet-gtk/src/plugins/fs/meta.c
===================================================================
--- gnunet-gtk/src/plugins/fs/meta.c    2006-12-11 02:33:04 UTC (rev 3914)
+++ gnunet-gtk/src/plugins/fs/meta.c    2006-12-11 05:16:35 UTC (rev 3915)
@@ -333,6 +333,9 @@
      NULL);  
 }
 
+#define THUMBSIZE 128
+
+
 struct ECRS_MetaData * getMetaDataFromList(GladeXML * xml,
                                           const char * name,
                                           const char * previewName) {
@@ -343,9 +346,13 @@
   struct ECRS_MetaData * meta;
   EXTRACTOR_KeywordType type;
   GdkPixbuf * pixbuf;
+  GdkPixbuf * out;
   char * mvalue;
+  size_t length;
+  unsigned long width;
+  unsigned long height;
+  char * thumb;
 
-  DEBUG_BEGIN();
   metaList = glade_xml_get_widget(xml,
                                  name);
   metamodel = gtk_tree_view_get_model(GTK_TREE_VIEW(metaList));
@@ -373,10 +380,28 @@
 
   if (GTK_IMAGE_PIXBUF ==
       gtk_image_get_storage_type(GTK_IMAGE(preview))) {
-    size_t length;
-    char * thumb;
-
     pixbuf = gtk_image_get_pixbuf(GTK_IMAGE(preview));
+    if (pixbuf == NULL)
+      return meta;
+    height = gdk_pixbuf_get_height(pixbuf);
+    width = gdk_pixbuf_get_width(pixbuf);
+    if ( (height > THUMBSIZE) || 
+        (width > THUMBSIZE) ) {
+      if (height > THUMBSIZE) {
+       width = width * THUMBSIZE / height;
+       height = THUMBSIZE;
+      }
+      if (width > THUMBSIZE) {
+       height = height * THUMBSIZE / width;
+       width = THUMBSIZE;
+      }
+      out = gdk_pixbuf_scale_simple(pixbuf,
+                                   width,
+                                   height,
+                                   GDK_INTERP_BILINEAR);
+      g_object_unref(pixbuf);
+      pixbuf = out;
+    }
     if (pixbuf != NULL) {
       thumb = NULL;
       if (gdk_pixbuf_save_to_buffer(pixbuf,
@@ -397,7 +422,6 @@
       }
     }
   }
-  DEBUG_END();
   return meta;
 }
 

Modified: gnunet-gtk/src/plugins/fs/upload.c
===================================================================
--- gnunet-gtk/src/plugins/fs/upload.c  2006-12-11 02:33:04 UTC (rev 3914)
+++ gnunet-gtk/src/plugins/fs/upload.c  2006-12-11 05:16:35 UTC (rev 3915)
@@ -348,7 +348,6 @@
   return NULL;
 }
 
-
 void on_fsinsertuploadbutton_clicked_fs(gpointer dummy,
                                        GtkWidget * uploadButton) {
   FSUC fsuc;
@@ -406,8 +405,6 @@
   ECRS_freeUri(keywordURI);
   createMetaTypeComboBox(metaXML,
                         "metaDataDialogMetaTypeComboBox");
-  
-
   
g_signal_connect_data(gtk_tree_view_get_selection(GTK_TREE_VIEW(glade_xml_get_widget(metaXML,
                                                                                
       "metaDataDialogKeywordList"))),
                        "changed",
@@ -422,10 +419,6 @@
                        NULL,
                        NULL,
                        0);
-
-
-
-
   gtk_dialog_set_default_response(GTK_DIALOG(dialog),
                                  GTK_RESPONSE_OK);
   if (gtk_dialog_run(GTK_DIALOG(dialog)) != GTK_RESPONSE_CANCEL) {





reply via email to

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