[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r11970 - in gnunet-gtk: contrib src
From: |
gnunet |
Subject: |
[GNUnet-SVN] r11970 - in gnunet-gtk: contrib src |
Date: |
Sun, 27 Jun 2010 13:14:37 +0200 |
Author: grothoff
Date: 2010-06-27 13:14:37 +0200 (Sun, 27 Jun 2010)
New Revision: 11970
Modified:
gnunet-gtk/contrib/open_url_dialog.glade
gnunet-gtk/contrib/search_tab.glade
gnunet-gtk/src/fs_event_handler.c
gnunet-gtk/src/fs_event_handler.h
gnunet-gtk/src/main_window_open_directory.c
Log:
handling lost parent
Modified: gnunet-gtk/contrib/open_url_dialog.glade
===================================================================
--- gnunet-gtk/contrib/open_url_dialog.glade 2010-06-27 11:11:54 UTC (rev
11969)
+++ gnunet-gtk/contrib/open_url_dialog.glade 2010-06-27 11:14:37 UTC (rev
11970)
@@ -2,9 +2,19 @@
<interface>
<requires lib="gtk+" version="2.20"/>
<!-- interface-naming-policy project-wide -->
+ <object class="GtkImage" id="execute_stock_image">
+ <property name="visible">True</property>
+ <property name="stock">gtk-execute</property>
+ </object>
+ <object class="GtkAdjustment" id="GNUNET_GTK_open_url_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="GtkDialog" id="GNUNET_GTK_open_url_dialog">
<property name="width_request">500</property>
- <property name="height_request">350</property>
+ <property name="height_request">100</property>
<property name="border_width">5</property>
<property name="title" translatable="yes">Download from URI</property>
<property name="modal">True</property>
@@ -77,6 +87,8 @@
<signal name="value-changed"
handler="GNUNET_GTK_anonymity_spin_button_value_changed_cb" swapped="no"/>
</object>
<packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
<property name="position">3</property>
</packing>
</child>
@@ -138,14 +150,4 @@
<action-widget
response="-5">GNUNET_GTK_open_url_dialog_execute_button</action-widget>
</action-widgets>
</object>
- <object class="GtkAdjustment" id="GNUNET_GTK_open_url_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="GtkImage" id="execute_stock_image">
- <property name="visible">True</property>
- <property name="stock">gtk-execute</property>
- </object>
</interface>
Modified: gnunet-gtk/contrib/search_tab.glade
===================================================================
--- gnunet-gtk/contrib/search_tab.glade 2010-06-27 11:11:54 UTC (rev 11969)
+++ gnunet-gtk/contrib/search_tab.glade 2010-06-27 11:14:37 UTC (rev 11970)
@@ -2,37 +2,105 @@
<interface>
<requires lib="gtk+" version="2.20"/>
<!-- interface-naming-policy project-wide -->
- <object class="GtkTreeStore" id="GNUNET_GTK_file_sharing_result_tree_store">
- <columns>
- <!-- column-name metadata -->
- <column type="gpointer"/>
- <!-- column-name uri -->
- <column type="gpointer"/>
- <!-- column-name filesize -->
- <column type="guint64"/>
- <!-- column-name preview -->
- <column type="GdkPixbuf"/>
- <!-- column-name percent_progress -->
- <column type="guint"/>
- <!-- column-name percent_availability -->
- <column type="guint"/>
- <!-- column-name filename -->
- <column type="gchararray"/>
- <!-- column-name uri_as_string -->
- <column type="gchararray"/>
- <!-- column-name status_colour -->
- <column type="gchararray"/>
- <!-- column-name struct_search_result -->
- <column type="gpointer"/>
- <!-- column-name mimetype -->
- <column type="gchararray"/>
- <!-- column-name applicability_rank -->
- <column type="guint"/>
- <!-- column-name availability_certainty -->
- <column type="guint"/>
- <!-- column-name availability_rank -->
- <column type="gint"/>
- </columns>
+ <object class="GtkWindow" id="_search_result_label_window">
+ <child>
+ <object class="GtkHBox" id="_search_result_label_hbox">
+ <property name="visible">True</property>
+ <property name="border_width">5</property>
+ <child>
+ <object class="GtkLabel" id="_search_result_label_window_label">
+ <property name="height_request">30</property>
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">query</property>
+ </object>
+ <packing>
+ <property name="fill">False</property>
+ <property name="padding">5</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="_search_result_label_play_button">
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_action_appearance">False</property>
+ <child>
+ <object class="GtkImage" id="play_icon_stock_image">
+ <property name="visible">True</property>
+ <property name="stock">gtk-media-play</property>
+ <property name="icon-size">2</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="_search_result_label_pause_button">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_action_appearance">False</property>
+ <child>
+ <object class="GtkImage" id="pause_icon_stock_image">
+ <property name="visible">True</property>
+ <property name="stock">gtk-media-pause</property>
+ <property name="icon-size">2</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="_search_result_label_clear_button">
+ <property name="sensitive">False</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_action_appearance">False</property>
+ <child>
+ <object class="GtkImage" id="clear_icon_stock_image">
+ <property name="visible">True</property>
+ <property name="stock">gtk-clear</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="padding">5</property>
+ <property name="position">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="_search_result_label_close_button">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_action_appearance">False</property>
+ <property name="relief">half</property>
+ <child>
+ <object class="GtkImage" id="close_icon_stock_image">
+ <property name="visible">True</property>
+ <property name="stock">gtk-close</property>
+ <property name="icon-size">2</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">4</property>
+ </packing>
+ </child>
+ </object>
+ </child>
</object>
<object class="GtkWindow" id="_search_result_frame_window">
<property name="title">You should never see this</property>
@@ -132,84 +200,36 @@
</object>
</child>
</object>
- <object class="GtkWindow" id="_search_result_label_window">
- <child>
- <object class="GtkHBox" id="_search_result_label_hbox">
- <property name="visible">True</property>
- <property name="border_width">5</property>
- <child>
- <object class="GtkLabel" id="_search_result_label_window_label">
- <property name="height_request">30</property>
- <property name="visible">True</property>
- <property name="label" translatable="yes">query</property>
- </object>
- <packing>
- <property name="fill">False</property>
- <property name="padding">5</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkButton" id="_search_result_label_close_button">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="use_action_appearance">False</property>
- <property name="relief">half</property>
- <child>
- <object class="GtkImage" id="close_icon_stock_image">
- <property name="visible">True</property>
- <property name="stock">gtk-close</property>
- <property name="icon-size">2</property>
- </object>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkButton" id="_search_result_label_play_button">
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="use_action_appearance">False</property>
- <child>
- <object class="GtkImage" id="play_icon_stock_image">
- <property name="visible">True</property>
- <property name="stock">gtk-media-play</property>
- <property name="icon-size">2</property>
- </object>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">2</property>
- </packing>
- </child>
- <child>
- <object class="GtkButton" id="_search_result_label_pause_button">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="use_action_appearance">False</property>
- <child>
- <object class="GtkImage" id="pause_icon_stock_image">
- <property name="visible">True</property>
- <property name="stock">gtk-media-pause</property>
- <property name="icon-size">2</property>
- </object>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">3</property>
- </packing>
- </child>
- </object>
- </child>
+ <object class="GtkTreeStore" id="GNUNET_GTK_file_sharing_result_tree_store">
+ <columns>
+ <!-- column-name metadata -->
+ <column type="gpointer"/>
+ <!-- column-name uri -->
+ <column type="gpointer"/>
+ <!-- column-name filesize -->
+ <column type="guint64"/>
+ <!-- column-name preview -->
+ <column type="GdkPixbuf"/>
+ <!-- column-name percent_progress -->
+ <column type="guint"/>
+ <!-- column-name percent_availability -->
+ <column type="guint"/>
+ <!-- column-name filename -->
+ <column type="gchararray"/>
+ <!-- column-name uri_as_string -->
+ <column type="gchararray"/>
+ <!-- column-name status_colour -->
+ <column type="gchararray"/>
+ <!-- column-name struct_search_result -->
+ <column type="gpointer"/>
+ <!-- column-name mimetype -->
+ <column type="gchararray"/>
+ <!-- column-name applicability_rank -->
+ <column type="guint"/>
+ <!-- column-name availability_certainty -->
+ <column type="guint"/>
+ <!-- column-name availability_rank -->
+ <column type="gint"/>
+ </columns>
</object>
</interface>
Modified: gnunet-gtk/src/fs_event_handler.c
===================================================================
--- gnunet-gtk/src/fs_event_handler.c 2010-06-27 11:11:54 UTC (rev 11969)
+++ gnunet-gtk/src/fs_event_handler.c 2010-06-27 11:14:37 UTC (rev 11970)
@@ -25,6 +25,7 @@
*/
#include "common.h"
#include "download.h"
+#include "fs_event_handler.h"
#include <string.h>
@@ -215,6 +216,39 @@
/**
+ * Handle the case where an active download lost its
+ * search parent by moving it to the URI tab.
+ */
+static struct DownloadEntry *
+download_lost_parent (struct DownloadEntry *de,
+ uint64_t size,
+ uint64_t completed,
+ int is_active)
+{
+ GtkTreeIter iter;
+
+ gtk_tree_row_reference_free (de->rr);
+ de->sr = NULL;
+ de->ts = GNUNET_GTK_add_to_uri_tab (&iter,
+ de->meta,
+ de->uri);
+ mark_download_progress (de, size, completed);
+ if (size > completed)
+ {
+ if (is_active)
+ change_download_colour (de, "yellow");
+ else
+ change_download_colour (de, "blue");
+ }
+ else
+ {
+ change_download_colour (de, "green");
+ }
+ return de;
+}
+
+
+/**
* Setup a new download entry.
*
* @param pde parent download entry, or NULL
@@ -259,10 +293,14 @@
}
else
{
- /* FIXME: find or create tab with just download results and
- create new entry! */
- GNUNET_break (0);
- return de;
+ de->ts = GNUNET_GTK_add_to_uri_tab (&iter,
+ meta,
+ uri);
+ path = gtk_tree_model_get_path (GTK_TREE_MODEL (de->ts),
+ &iter);
+ de->rr = gtk_tree_row_reference_new (GTK_TREE_MODEL (de->ts),
+ path);
+ gtk_tree_path_free (path);
}
path = gtk_tree_row_reference_get_path (de->rr);
if (TRUE != gtk_tree_model_get_iter (GTK_TREE_MODEL (de->ts),
@@ -627,8 +665,7 @@
*/
static struct SearchTab *
setup_search (struct GNUNET_FS_SearchContext *sc,
- const struct GNUNET_FS_Uri *query,
- uint32_t anonymity)
+ const struct GNUNET_FS_Uri *query)
{
struct SearchTab *tab;
GtkTreeView *tv;
@@ -641,10 +678,17 @@
search_tab_tail,
tab);
tab->sc = sc;
- if (GNUNET_FS_uri_test_ksk (query))
- tab->query_txt = GNUNET_FS_uri_ksk_to_string_fancy (query);
+ if (query == NULL)
+ {
+ tab->query_txt = GNUNET_strdup ("*");
+ }
else
- tab->query_txt = GNUNET_FS_uri_to_string (query);
+ {
+ if (GNUNET_FS_uri_test_ksk (query))
+ tab->query_txt = GNUNET_FS_uri_ksk_to_string_fancy (query);
+ else
+ tab->query_txt = GNUNET_FS_uri_to_string (query);
+ }
tab->builder = GNUNET_GTK_get_new_builder ("search_tab.glade");
/* load frame */
@@ -709,18 +753,16 @@
}
-
static struct SearchResult *
-process_search_result (void *cls,
- void *parent,
- const struct GNUNET_FS_Uri *uri,
- const struct GNUNET_CONTAINER_MetaData *meta,
- struct GNUNET_FS_SearchResult *result,
- uint32_t applicability_rank)
+add_search_result (struct SearchTab *tab,
+ GtkTreeIter *iter,
+ void *parent,
+ const struct GNUNET_FS_Uri *uri,
+ const struct GNUNET_CONTAINER_MetaData *meta,
+ struct GNUNET_FS_SearchResult *result,
+ uint32_t applicability_rank)
{
- struct SearchTab *tab = cls;
struct SearchResult *sr;
- GtkTreeIter iter;
GtkTreePath *tp;
GtkTreeStore *ts;
char *desc;
@@ -761,7 +803,7 @@
ts = GTK_TREE_STORE (gtk_builder_get_object (tab->builder,
"GNUNET_GTK_file_sharing_result_tree_store"));
gtk_tree_store_insert_with_values (ts,
- &iter,
+ iter,
NULL,
G_MAXINT,
0, GNUNET_CONTAINER_meta_data_duplicate
(meta),
@@ -780,14 +822,13 @@
13, 0 /* avail-rank */,
-1);
tab->num_results++;
- update_search_label (tab);
if (pixbuf != NULL)
g_object_unref (pixbuf);
GNUNET_free (uris);
GNUNET_free (desc);
GNUNET_free_non_null (mime);
tp = gtk_tree_model_get_path (GTK_TREE_MODEL (ts),
- &iter);
+ iter);
sr->rr = gtk_tree_row_reference_new (GTK_TREE_MODEL (ts),
tp);
gtk_tree_path_free (tp);
@@ -796,6 +837,65 @@
static struct SearchResult *
+process_search_result (void *cls,
+ void *parent,
+ const struct GNUNET_FS_Uri *uri,
+ const struct GNUNET_CONTAINER_MetaData *meta,
+ struct GNUNET_FS_SearchResult *result,
+ uint32_t applicability_rank)
+{
+ struct SearchTab *tab = cls;
+ struct SearchResult *sr;
+ GtkTreeIter iter;
+
+ sr = add_search_result (tab, &iter, parent, uri,
+ meta, result, applicability_rank);
+ update_search_label (tab);
+ return sr;
+}
+
+
+/**
+ * Setup a new top-level entry in the URI tab. If necessary, create
+ * the URI tab first.
+ *
+ * @param iter set to the new entry
+ * @param meta metadata for the new entry
+ * @param uri URI for the new entry
+ * @return NULL on error, otherwise tree store matching iter
+ */
+GtkTreeStore *
+GNUNET_GTK_add_to_uri_tab (GtkTreeIter *iter,
+ const struct GNUNET_CONTAINER_MetaData *meta,
+ const struct GNUNET_FS_Uri *uri)
+{
+ struct SearchTab *utab;
+ struct SearchResult *sr;
+
+ utab = search_tab_head;
+ while (utab != NULL)
+ {
+ if (utab->sc != NULL)
+ utab = utab->next;
+ }
+ if (utab == NULL)
+ {
+ utab = setup_search (NULL, NULL);
+ }
+ else
+ {
+ /* FIXME: make 'utab' the current page */
+ GNUNET_break (0);
+ }
+ sr = add_search_result (utab, iter,
+ NULL, uri, meta,
+ NULL, 0);
+ return GTK_TREE_STORE (gtk_builder_get_object (utab->builder,
+
"GNUNET_GTK_file_sharing_result_tree_store"));
+}
+
+
+static struct SearchResult *
update_search_result (struct SearchResult *sr,
const struct GNUNET_CONTAINER_MetaData *meta,
int32_t availability_rank,
@@ -1107,15 +1207,10 @@
return change_download_colour (info->value.download.cctx,
"blue");
case GNUNET_FS_STATUS_DOWNLOAD_LOST_PARENT:
- /* FIXME: keep entry (especially if download is not
- done!?) ? */
- /* FIXME: if we do not stop here, we currently crash on exit;
- I think this is because somehow fs-lib fails to handle
- LOST_PARENT correctly and does not generate the necessary
- suspend event in this case */
- stop_download (info->value.download.cctx,
- GNUNET_YES);
- break;
+ return download_lost_parent (info->value.download.cctx,
+ info->value.download.size,
+ info->value.download.completed,
+ info->value.download.is_active);
case GNUNET_FS_STATUS_SEARCH_START:
fprintf (stderr,
"Search started!\n");
@@ -1125,8 +1220,7 @@
break;
}
return setup_search (info->value.search.sc,
- info->value.search.query,
- info->value.search.anonymity);
+ info->value.search.query);
case GNUNET_FS_STATUS_SEARCH_RESUME:
GNUNET_break (0);
break;
Modified: gnunet-gtk/src/fs_event_handler.h
===================================================================
--- gnunet-gtk/src/fs_event_handler.h 2010-06-27 11:11:54 UTC (rev 11969)
+++ gnunet-gtk/src/fs_event_handler.h 2010-06-27 11:14:37 UTC (rev 11970)
@@ -25,7 +25,23 @@
*/
#include "common.h"
+
/**
+ * Setup a new top-level entry in the URI tab. If necessary, create
+ * the URI tab first.
+ *
+ * @param iter set to the new entry
+ * @param meta metadata for the new entry
+ * @param uri URI for the new entry
+ * @return NULL on error, otherwise tree store matching iter
+ */
+GtkTreeStore *
+GNUNET_GTK_add_to_uri_tab (GtkTreeIter *iter,
+ const struct GNUNET_CONTAINER_MetaData *meta,
+ const struct GNUNET_FS_Uri *uri);
+
+
+/**
* Notification of FS to a client about the progress of an
* operation. Callbacks of this type will be used for uploads,
* downloads and searches. Some of the arguments depend a bit
Modified: gnunet-gtk/src/main_window_open_directory.c
===================================================================
--- gnunet-gtk/src/main_window_open_directory.c 2010-06-27 11:11:54 UTC (rev
11969)
+++ gnunet-gtk/src/main_window_open_directory.c 2010-06-27 11:14:37 UTC (rev
11970)
@@ -53,8 +53,19 @@
filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER(ad));
gtk_widget_destroy (ad);
g_object_unref (G_OBJECT (builder));
+#if 0
+ open_directory;
+ uri = compute_uri_from_file (filename);
+ meta = new;
+ meta_make_directory ();
+ meta_add (filename);
+ ts = setup_entry_in_uri_tab (&iter,
+ meta,
+ uri);
+ directory_iterate (add_child, ts, &iter);
GNUNET_break (0);
+#endif
g_free (filename);
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r11970 - in gnunet-gtk: contrib src,
gnunet <=