[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r19683 - gnunet-gtk/src/fs
From: |
gnunet |
Subject: |
[GNUnet-SVN] r19683 - gnunet-gtk/src/fs |
Date: |
Sat, 4 Feb 2012 20:47:27 +0100 |
Author: grothoff
Date: 2012-02-04 20:47:27 +0100 (Sat, 04 Feb 2012)
New Revision: 19683
Modified:
gnunet-gtk/src/fs/gnunet-fs-gtk_event-handler.c
gnunet-gtk/src/fs/gnunet-fs-gtk_event-handler.h
gnunet-gtk/src/fs/gnunet-fs-gtk_open-directory.c
Log:
-simplify code some more
Modified: gnunet-gtk/src/fs/gnunet-fs-gtk_event-handler.c
===================================================================
--- gnunet-gtk/src/fs/gnunet-fs-gtk_event-handler.c 2012-02-04 19:30:06 UTC
(rev 19682)
+++ gnunet-gtk/src/fs/gnunet-fs-gtk_event-handler.c 2012-02-04 19:47:27 UTC
(rev 19683)
@@ -1180,7 +1180,6 @@
* are being opened and if the user manually enters a URI.
*
* @param tab search tab to extend, never NULL
- * @param iter set to position where search result is added (OUT only)
* @param parent_rr reference to parent entry in search tab, NULL for normal
* search results,
* @param uri uri to add, can be NULL for top-level entry of a directory
opened from disk
@@ -1195,7 +1194,6 @@
*/
struct SearchResult *
GNUNET_GTK_add_search_result (struct SearchTab *tab,
- GtkTreeIter *iter,
GtkTreeRowReference *parent_rr,
const struct GNUNET_FS_Uri *uri,
const struct GNUNET_CONTAINER_MetaData *meta,
@@ -1209,6 +1207,7 @@
char *mime;
char *uris;
GdkPixbuf *pixbuf;
+ GtkTreeIter iter;
GtkTreeIter *pitr;
GtkTreeIter pmem;
GtkTreePath *path;
@@ -1276,7 +1275,7 @@
pitr = NULL;
ts = tab->ts;
}
- gtk_tree_store_insert_with_values (ts, iter, pitr, G_MAXINT,
+ gtk_tree_store_insert_with_values (ts, &iter, pitr, G_MAXINT,
0, GNUNET_CONTAINER_meta_data_duplicate
(meta),
1, (uri == NULL) ? NULL :
GNUNET_FS_uri_dup (uri),
2, fsize,
@@ -1302,7 +1301,7 @@
GNUNET_free_non_null (mime);
/* remember in 'sr' where we added the result */
- tp = gtk_tree_model_get_path (GTK_TREE_MODEL (ts), iter);
+ tp = gtk_tree_model_get_path (GTK_TREE_MODEL (ts), &iter);
sr->rr = gtk_tree_row_reference_new (GTK_TREE_MODEL (ts), tp);
gtk_tree_path_free (tp);
@@ -1341,9 +1340,8 @@
uint32_t applicability_rank)
{
struct SearchResult *sr;
- GtkTreeIter iter;
- sr = GNUNET_GTK_add_search_result (tab, &iter,
+ sr = GNUNET_GTK_add_search_result (tab,
(parent != NULL) ? parent->rr : NULL,
uri,
meta, result, applicability_rank);
@@ -1483,14 +1481,12 @@
* Setup a new top-level entry in the URI/orphan tab. If necessary, create
* the URI tab first.
*
- * @param iter set to the new entry (OUT only) -- FIXME: remove, obtainable as
'RETVAL->rr'
* @param meta metadata for the new entry
* @param uri URI for the new entry
* @return the search result that was set up
*/
struct SearchResult *
-GNUNET_GTK_add_to_uri_tab (GtkTreeIter *iter,
- const struct GNUNET_CONTAINER_MetaData *meta,
+GNUNET_GTK_add_to_uri_tab (const struct GNUNET_CONTAINER_MetaData *meta,
const struct GNUNET_FS_Uri *uri)
{
GtkNotebook *notebook;
@@ -1512,7 +1508,7 @@
gtk_notebook_set_current_page (notebook, page);
break;
}
- return GNUNET_GTK_add_search_result (uri_tab, iter, NULL, uri, meta, NULL,
0);
+ return GNUNET_GTK_add_search_result (uri_tab, NULL, uri, meta, NULL, 0);
}
@@ -1660,7 +1656,7 @@
while (TRUE == gtk_tree_model_iter_next (tm, &iter));
}
}
- GNUNET_GTK_add_search_result (ade->tab, &iter, ade->prr, uri, meta, NULL,
+ GNUNET_GTK_add_search_result (ade->tab, ade->prr, uri, meta, NULL,
0);
}
@@ -1918,15 +1914,13 @@
/* first, move the root of the respective 'de'-tree */
rr_old = de->sr->rr;
- de->sr = GNUNET_GTK_add_to_uri_tab (&iter, de->meta, de->uri);
+ de->sr = GNUNET_GTK_add_to_uri_tab (de->meta, de->uri);
de->sr->download = de;
- model = GTK_TREE_MODEL (de->sr->tab->ts);
tm_old = gtk_tree_row_reference_get_model (rr_old);
path = gtk_tree_row_reference_get_path (rr_old);
gtk_tree_row_reference_free (rr_old);
-
if (! gtk_tree_model_get_iter (tm_old, &iter_old, path))
{
GNUNET_break (0);
@@ -1935,6 +1929,16 @@
}
gtk_tree_path_free (path);
+ model = GTK_TREE_MODEL (de->sr->tab->ts);
+ path = gtk_tree_row_reference_get_path (de->sr->rr);
+ if (! gtk_tree_model_get_iter (model, &iter, path))
+ {
+ GNUNET_break (0);
+ gtk_tree_path_free (path);
+ return;
+ }
+ gtk_tree_path_free (path);
+
/* finally, move all children over as well */
copy_children (tm_old, &iter_old, model, &iter);
while (gtk_tree_model_iter_children (model, &child, &iter))
@@ -2003,7 +2007,7 @@
/* Stand-alone download with no 'row'/search result affiliated
with the download so far; create a fresh entry for this
download in the URI tab */
- de->sr = GNUNET_GTK_add_to_uri_tab (&iter, meta, uri);
+ de->sr = GNUNET_GTK_add_to_uri_tab (meta, uri);
de->sr->download = de;
}
path = gtk_tree_row_reference_get_path (de->sr->rr);
@@ -2020,7 +2024,7 @@
size) : 100) /* progress */ ,
6, filename /* filename/description */ ,
8, "blue" /* status colour: pending */ ,
- 9, de->sr,
+ 9, de->sr,
14, completed,
15, de->filename,
16, de->anonymity,
Modified: gnunet-gtk/src/fs/gnunet-fs-gtk_event-handler.h
===================================================================
--- gnunet-gtk/src/fs/gnunet-fs-gtk_event-handler.h 2012-02-04 19:30:06 UTC
(rev 19682)
+++ gnunet-gtk/src/fs/gnunet-fs-gtk_event-handler.h 2012-02-04 19:47:27 UTC
(rev 19683)
@@ -212,14 +212,12 @@
* Setup a new top-level entry in the URI/orphan tab. If necessary, create
* the URI tab first.
*
- * @param iter set to the new entry (OUT only)
* @param meta metadata for the new entry
* @param uri URI for the new entry
* @return the search result that was set up
*/
struct SearchResult *
-GNUNET_GTK_add_to_uri_tab (GtkTreeIter * iter,
- const struct GNUNET_CONTAINER_MetaData *meta,
+GNUNET_GTK_add_to_uri_tab (const struct GNUNET_CONTAINER_MetaData *meta,
const struct GNUNET_FS_Uri *uri);
@@ -227,7 +225,6 @@
* Add a search result to the given search tab.
*
* @param tab search tab to extend, never NULL
- * @param iter set to position where search result is added (OUT only)
* @param parent_rr reference to parent entry in search tab, NULL for normal
* search results,
* @param uri uri to add, can be NULL for top-level entry of a directory
opened from disk
@@ -242,7 +239,6 @@
*/
struct SearchResult *
GNUNET_GTK_add_search_result (struct SearchTab *tab,
- GtkTreeIter *iter,
GtkTreeRowReference *parent_rr,
const struct GNUNET_FS_Uri *uri,
const struct GNUNET_CONTAINER_MetaData *meta,
Modified: gnunet-gtk/src/fs/gnunet-fs-gtk_open-directory.c
===================================================================
--- gnunet-gtk/src/fs/gnunet-fs-gtk_open-directory.c 2012-02-04 19:30:06 UTC
(rev 19682)
+++ gnunet-gtk/src/fs/gnunet-fs-gtk_open-directory.c 2012-02-04 19:47:27 UTC
(rev 19683)
@@ -37,20 +37,10 @@
const char *filename;
/**
- * Tree store where we will add entries.
+ * Reference to the directorie's search result.
*/
- GtkTreeStore *ts;
+ struct SearchResult *sr;
- /**
- * Tab we've opened for the directory.
- */
- struct SearchTab *tab;
-
- /**
- * Row reference to the directorie's parent entry.
- */
- GtkTreeRowReference *prr;
-
};
@@ -76,13 +66,11 @@
const void *data)
{
struct AddChildContext *acc = cls;
- GtkTreeIter iter;
if (NULL == uri)
{
/* directory meta data itself, create parent entry */
struct GNUNET_CONTAINER_MetaData *dmeta;
- GtkTreePath *tp;
dmeta = GNUNET_CONTAINER_meta_data_duplicate (meta);
GNUNET_CONTAINER_meta_data_insert (dmeta, "<user>",
@@ -90,21 +78,19 @@
EXTRACTOR_METAFORMAT_UTF8, "text/plain",
acc->filename,
strlen (acc->filename) + 1);
- acc->tab = GNUNET_GTK_add_to_uri_tab (&iter, dmeta, NULL)->tab;
- tp = gtk_tree_model_get_path (GTK_TREE_MODEL (acc->tab->ts), &iter);
- acc->prr = gtk_tree_row_reference_new (GTK_TREE_MODEL (acc->tab->ts), tp);
- gtk_tree_path_free (tp);
- acc->ts = acc->tab->ts;
+ acc->sr = GNUNET_GTK_add_to_uri_tab (dmeta, NULL);
GNUNET_CONTAINER_meta_data_destroy (dmeta);
return;
}
- if (NULL == acc->ts)
+ if (NULL == acc->sr)
{
GNUNET_break (0);
return;
}
GNUNET_assert (NULL !=
- GNUNET_GTK_add_search_result (acc->tab, &iter, acc->prr, uri,
+ GNUNET_GTK_add_search_result (acc->sr->tab,
+ acc->sr->rr,
+ uri,
meta, NULL, 0));
}
@@ -135,7 +121,7 @@
gtk_widget_destroy (GTK_WIDGET (dialog));
g_object_unref (G_OBJECT (builder));
acc.filename = filename;
- acc.ts = NULL;
+ acc.sr = NULL;
GNUNET_FS_GTK_mmap_and_scan (filename, &add_child, &acc);
g_free (filename);
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r19683 - gnunet-gtk/src/fs,
gnunet <=