[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r13466 - in gnunet-gtk: contrib src
From: |
gnunet |
Subject: |
[GNUnet-SVN] r13466 - in gnunet-gtk: contrib src |
Date: |
Fri, 29 Oct 2010 17:20:30 +0200 |
Author: grothoff
Date: 2010-10-29 17:20:30 +0200 (Fri, 29 Oct 2010)
New Revision: 13466
Modified:
gnunet-gtk/contrib/publish_edit_dialog.glade
gnunet-gtk/src/edit_publish_dialog.c
Log:
adding preview support
Modified: gnunet-gtk/contrib/publish_edit_dialog.glade
===================================================================
--- gnunet-gtk/contrib/publish_edit_dialog.glade 2010-10-29 14:40:51 UTC
(rev 13465)
+++ gnunet-gtk/contrib/publish_edit_dialog.glade 2010-10-29 15:20:30 UTC
(rev 13466)
@@ -2,27 +2,38 @@
<interface>
<requires lib="gtk+" version="2.20"/>
<!-- interface-naming-policy project-wide -->
- <object class="GtkAdjustment" id="expiration_year_adjustment">
- <property name="upper">9999</property>
+ <object class="GtkAdjustment" id="adjustment2">
+ <property name="upper">100</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
+ <property name="page_size">10</property>
</object>
- <object class="GtkAdjustment" id="priority_adjustment">
- <property name="upper">10000000</property>
- <property name="value">1000</property>
+ <object class="GtkAdjustment" id="adjustment1">
+ <property name="upper">100</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
+ <property name="page_size">10</property>
</object>
- <object class="GtkAdjustment" id="GNUNET_GTK_anonymity_adjustment">
- <property name="upper">100000</property>
- <property name="value">1</property>
- <property name="step_increment">1</property>
- <property name="page_increment">10</property>
+ <object class="GtkListStore" id="GNUNET_GTK_metatype_list_store">
+ <columns>
+ <!-- column-name description -->
+ <column type="gchararray"/>
+ <!-- column-name guint1 -->
+ <column type="guint"/>
+ <!-- column-name helptext -->
+ <column type="gchararray"/>
+ </columns>
</object>
- <object class="GtkListStore" id="GNUNET_GTK_keyword_list_store">
+ <object class="GtkListStore" id="GNUNET_GTK_meta_data_list_store">
<columns>
- <!-- column-name keyword -->
+ <!-- column-name extractor_meta_type -->
+ <column type="guint"/>
+ <!-- column-name extractor_meta_format -->
+ <column type="guint"/>
+ <!-- column-name extractor_meta_type_string -->
<column type="gchararray"/>
+ <!-- column-name extracotr_meta_value -->
+ <column type="gchararray"/>
</columns>
</object>
<object class="GtkDialog" id="GNUNET_GTK_edit_file_information_dialog">
@@ -233,6 +244,7 @@
</child>
<child>
<object class="GtkImage"
id="GNUNET_GTK_edit_file_information_metadata_preview_image">
+ <property name="visible">True</property>
<property name="sensitive">False</property>
<property name="stock">gtk-missing-image</property>
</object>
@@ -242,6 +254,7 @@
</child>
<child>
<object class="GtkFileChooserButton"
id="GNUNET_GTK_edit_file_information_metadata_preview_file_chooser_button">
+ <property name="visible">True</property>
<property name="create_folders">False</property>
<property name="title" translatable="yes">Select
file</property>
<signal name="file-set"
handler="GNUNET_GTK_edit_file_information_metadata_preview_file_chooser_button_file_set_cb"
swapped="no"/>
@@ -678,38 +691,27 @@
<action-widget
response="-5">GNUNET_GTK_edit_file_information_confirm_button</action-widget>
</action-widgets>
</object>
- <object class="GtkListStore" id="GNUNET_GTK_meta_data_list_store">
+ <object class="GtkListStore" id="GNUNET_GTK_keyword_list_store">
<columns>
- <!-- column-name extractor_meta_type -->
- <column type="guint"/>
- <!-- column-name extractor_meta_format -->
- <column type="guint"/>
- <!-- column-name extractor_meta_type_string -->
+ <!-- column-name keyword -->
<column type="gchararray"/>
- <!-- column-name extracotr_meta_value -->
- <column type="gchararray"/>
</columns>
</object>
- <object class="GtkListStore" id="GNUNET_GTK_metatype_list_store">
- <columns>
- <!-- column-name description -->
- <column type="gchararray"/>
- <!-- column-name guint1 -->
- <column type="guint"/>
- <!-- column-name helptext -->
- <column type="gchararray"/>
- </columns>
+ <object class="GtkAdjustment" id="GNUNET_GTK_anonymity_adjustment">
+ <property name="upper">100000</property>
+ <property name="value">1</property>
+ <property name="step_increment">1</property>
+ <property name="page_increment">10</property>
</object>
- <object class="GtkAdjustment" id="adjustment1">
- <property name="upper">100</property>
+ <object class="GtkAdjustment" id="priority_adjustment">
+ <property name="upper">10000000</property>
+ <property name="value">1000</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
- <property name="page_size">10</property>
</object>
- <object class="GtkAdjustment" id="adjustment2">
- <property name="upper">100</property>
+ <object class="GtkAdjustment" id="expiration_year_adjustment">
+ <property name="upper">9999</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
- <property name="page_size">10</property>
</object>
</interface>
Modified: gnunet-gtk/src/edit_publish_dialog.c
===================================================================
--- gnunet-gtk/src/edit_publish_dialog.c 2010-10-29 14:40:51 UTC (rev
13465)
+++ gnunet-gtk/src/edit_publish_dialog.c 2010-10-29 15:20:30 UTC (rev
13466)
@@ -36,6 +36,10 @@
*/
static int is_directory;
+/**
+ * Set to YES if the preview was changed.
+ */
+static int preview_changed;
void
GNUNET_GTK_edit_file_information_keyword_list_normalize_button_clicked_cb ()
@@ -172,11 +176,20 @@
void
-GNUNET_GTK_edit_file_information_metadata_preview_file_chooser_button_file_set_cb
()
+GNUNET_GTK_edit_file_information_metadata_preview_file_chooser_button_file_set_cb
(GtkFileChooserButton *widget,
+
gpointer user_data)
{
- GNUNET_break (0);
+ gchar *fn;
+ GtkImage *image;
+
+ fn = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (widget));
+ image = GTK_IMAGE (gtk_builder_get_object (builder,
+
"GNUNET_GTK_edit_file_information_metadata_preview_image"));
+ gtk_image_set_from_file (image, fn);
+ preview_changed = GNUNET_YES;
}
+
void
GNUNET_GTK_edit_file_information_metadata_delete_button_clicked_cb()
{
@@ -391,6 +404,9 @@
{
GtkImage *img;
GdkPixbuf *pixbuf;
+ struct tm *t;
+ int year;
+ time_t tp;
if (NULL != *uri)
GNUNET_FS_uri_ksk_get_keywords (*uri, &add_keyword, NULL);
@@ -408,8 +424,16 @@
pixbuf);
}
}
- /* FIXME: set expiration time (not yet in dialog!) */
+ tp = expirationTime->abs_value / 1000; /* ms to seconds */
+ t = gmtime (&tp);
+ if (t == NULL)
+ year = 0;
+ else
+ year = t->tm_year + 1900;
gtk_spin_button_set_value (GTK_SPIN_BUTTON (gtk_builder_get_object (builder,
+
"GNUNET_GTK_edit_file_information_expiration_year_spin_button")),
+ year);
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON (gtk_builder_get_object (builder,
"GNUNET_GTK_edit_file_information_anonymity_spin_button")),
*anonymity);
gtk_spin_button_set_value (GTK_SPIN_BUTTON (gtk_builder_get_object (builder,
@@ -490,8 +514,8 @@
case EXTRACTOR_METAFORMAT_UNKNOWN:
break;
case EXTRACTOR_METAFORMAT_BINARY:
- /* FIXME: this is here since we don't have preview support yet */
- keep = GNUNET_YES;
+ if (preview_changed == GNUNET_NO)
+ keep = GNUNET_YES;
break;
default:
GNUNET_break (0);
@@ -543,6 +567,12 @@
guint ntype;
guint nformat;
GtkSpinButton *sb;
+ gchar *fn;
+ char *data;
+ gsize data_size;
+ const char *mime;
+ GFile *f;
+ GFileInfo *finfo;
*anonymity = gtk_spin_button_get_value (GTK_SPIN_BUTTON
(gtk_builder_get_object (builder,
"GNUNET_GTK_edit_file_information_anonymity_spin_button")));
@@ -612,6 +642,33 @@
while (TRUE == gtk_tree_model_iter_next (tm, &iter));
}
GNUNET_CONTAINER_meta_data_merge (meta, nm);
+ if (preview_changed == GNUNET_YES)
+ {
+ fn = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER
(gtk_builder_get_object (builder,
+
"GNUNET_GTK_edit_file_information_metadata_preview_file_chooser_button")));
+ f = g_file_new_for_path (fn);
+ finfo = g_file_query_info (f, G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE, 0,
NULL, NULL);
+ if (FALSE == g_file_load_contents (f, NULL, &data, &data_size, NULL,
NULL))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ _("Could not load preview `%s' into memory\n"),
+ fn);
+ }
+ else
+ {
+ mime = g_file_info_get_attribute_string (finfo,
+
G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE);
+ GNUNET_CONTAINER_meta_data_insert (meta,
+ "<user>",
+ EXTRACTOR_METATYPE_THUMBNAIL,
+ EXTRACTOR_METAFORMAT_BINARY,
+ mime,
+ data,
+ data_size);
+ }
+ g_object_unref (finfo);
+ g_object_unref (f);
+ }
GNUNET_CONTAINER_meta_data_destroy (nm);
/* update short_fn */
@@ -649,6 +706,7 @@
GNUNET_break (0);
return;
}
+ preview_changed = GNUNET_NO;
GNUNET_GTK_setup_expiration_year_adjustment (builder);
if (GNUNET_FS_file_information_is_directory (fip))
{
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r13466 - in gnunet-gtk: contrib src,
gnunet <=