[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r2721 - gnunet-gtk/src/plugins/fs
From: |
grothoff |
Subject: |
[GNUnet-SVN] r2721 - gnunet-gtk/src/plugins/fs |
Date: |
Wed, 3 May 2006 13:12:51 -0700 (PDT) |
Author: grothoff
Date: 2006-05-03 13:12:47 -0700 (Wed, 03 May 2006)
New Revision: 2721
Modified:
gnunet-gtk/src/plugins/fs/download.c
gnunet-gtk/src/plugins/fs/fs.h
gnunet-gtk/src/plugins/fs/namespace.c
gnunet-gtk/src/plugins/fs/search.c
Log:
human readable
Modified: gnunet-gtk/src/plugins/fs/download.c
===================================================================
--- gnunet-gtk/src/plugins/fs/download.c 2006-05-03 20:00:11 UTC (rev
2720)
+++ gnunet-gtk/src/plugins/fs/download.c 2006-05-03 20:12:47 UTC (rev
2721)
@@ -126,6 +126,8 @@
GtkTreePath *dirTreePath;
char *dirPath;
unsigned int dirPathLen;
+ char * size_h;
+ unsigned long long size;
#ifdef WINDOWS
char *filehash = NULL;
#endif
@@ -289,7 +291,7 @@
}
list->uri = ECRS_dupUri(uri);
list->filename = final_download_destination;
- list->finalName = MALLOC(strlen(final_download_dir) + strlen(dirPath) +
strlen(name) + 2);
+ list->finalName = MALLOC(strlen(final_download_dir) + strlen(dirPath) +
strlen(name) + 2);
strcpy(list->finalName, final_download_dir);
if (final_download_dir[strlen(final_download_dir)-1] != DIR_SEPARATOR)
strcat(list->finalName, DIR_SEPARATOR_STR);
@@ -297,6 +299,8 @@
mkdirp(list->finalName);
strcat(list->finalName, name);
head = list;
+ size = ECRS_fileSize(uri);
+ size_h = getHumanSize(size);
gtk_tree_store_insert(summary,
&iiter,
NULL,
@@ -305,13 +309,15 @@
&iiter,
DOWNLOAD_FILENAME, final_download_destination,
DOWNLOAD_SHORTNAME, name,
- DOWNLOAD_SIZE, ECRS_fileSize(uri),
+ DOWNLOAD_SIZE, size,
+ DOWNLOAD_HSIZE, size_h,
DOWNLOAD_PROGRESS, 0, /* progress */
DOWNLOAD_URISTRING, uri_name,
DOWNLOAD_URI, ECRS_dupUri(uri),
DOWNLOAD_TREEPATH, list->rr, /* internal: row reference!
*/
DOWNLOAD_DIRPATH, dirPath,
-1);
+ FREE(size_h);
FREE(uri_name);
FREE(dirPath);
FREENONNULL(final_download_dir);
@@ -354,6 +360,7 @@
void on_statusDownloadURIEntry_editing_done(GtkWidget * entry,
GtkWidget * downloadButton) {
const char * uris;
+ char * urid;
struct ECRS_URI * uri;
unsigned int anon;
GtkWidget * spin;
@@ -362,23 +369,27 @@
const char * dname;
DownloadList * list;
GtkTreeIter iiter;
+ char * size_h;
uris = gtk_entry_get_text(GTK_ENTRY(entry));
- uris = STRDUP(uris);
+ urid = STRDUP(uris);
gtk_entry_set_text(GTK_ENTRY(entry),
ECRS_URI_PREFIX);
- uri = ECRS_stringToUri(uris);
+ uri = ECRS_stringToUri(urid);
if (uri == NULL) {
- addLogEntry(_("Invalid URI `%s'"), uris);
+ addLogEntry(_("Invalid URI `%s'"), urid);
+ FREE(urid);
return;
}
if (ECRS_isKeywordUri(uri)) {
addLogEntry(_("Please use the search function for keyword (KSK) URIs!"));
- FREE(uris);
+ FREE(urid);
+ ECRS_freeUri(uri);
return;
} else if (ECRS_isLocationUri(uri)) {
addLogEntry(_("Location URIs are not yet supported"));
- FREE(uris);
+ FREE(urid);
+ ECRS_freeUri(uri);
return;
}
@@ -404,6 +415,7 @@
list->filename = tmp;
list->finalName = STRDUP(tmp);
head = list;
+ size_h = getHumanSize(ECRS_fileSize(uri));
gtk_tree_store_insert(summary,
&iiter,
NULL,
@@ -413,13 +425,14 @@
DOWNLOAD_FILENAME, tmp,
DOWNLOAD_SHORTNAME, uris,
DOWNLOAD_SIZE, ECRS_fileSize(uri),
+ DOWNLOAD_HSIZE, size_h,
DOWNLOAD_PROGRESS, 0, /* progress */
DOWNLOAD_URISTRING, uris,
DOWNLOAD_URI, ECRS_dupUri(uri),
DOWNLOAD_TREEPATH, NULL, /* internal: row reference! */
DOWNLOAD_DIRPATH, "",
-1);
-
+ FREE(size_h);
/* get anonymity level */
spin = glade_xml_get_widget(getMainXML(),
"fsstatusAnonymitySpin");
@@ -435,7 +448,7 @@
anon,
uri,
tmp);
- FREE(uris);
+ FREE(urid);
}
@@ -659,6 +672,7 @@
int progress;
char * uriname;
const char * sname;
+ char * size_h;
DEBUG_BEGIN();
if (filesize != 0)
@@ -675,16 +689,19 @@
(sname[-1] != '/') &&
(sname[-1] != '\\') )
sname--;
+ size_h = getHumanSize(filesize);
gtk_tree_store_set(summary,
&iiter,
DOWNLOAD_FILENAME, filename,
DOWNLOAD_SHORTNAME, sname,
DOWNLOAD_SIZE, filesize,
+ DOWNLOAD_HSIZE, size_h,
DOWNLOAD_PROGRESS, progress,
DOWNLOAD_URISTRING, uriname,
DOWNLOAD_URI, ECRS_dupUri(uri),
DOWNLOAD_TREEPATH, NULL,
-1);
+ FREE(size_h);
FREE(uriname);
DEBUG_END();
return OK;
@@ -705,6 +722,7 @@
G_TYPE_STRING, /* name (full-path file name) */
G_TYPE_STRING, /* name (user-friendly name) */
G_TYPE_UINT64, /* size */
+ G_TYPE_STRING, /* human readable size */
G_TYPE_INT, /* progress */
G_TYPE_STRING, /* uri */
G_TYPE_POINTER, /* url */
@@ -731,12 +749,14 @@
col - 1),
TRUE);
renderer = gtk_cell_renderer_text_new();
+ g_object_set (renderer, "xalign", 1.00, NULL);
col =
gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(downloadList),
-1,
_("Size"),
renderer,
- "text", DOWNLOAD_SIZE,
+ "text", DOWNLOAD_HSIZE,
NULL);
+
column = gtk_tree_view_get_column(GTK_TREE_VIEW(downloadList),
col - 1);
gtk_tree_view_column_set_resizable(column, TRUE);
Modified: gnunet-gtk/src/plugins/fs/fs.h
===================================================================
--- gnunet-gtk/src/plugins/fs/fs.h 2006-05-03 20:00:11 UTC (rev 2720)
+++ gnunet-gtk/src/plugins/fs/fs.h 2006-05-03 20:12:47 UTC (rev 2721)
@@ -33,6 +33,7 @@
enum {
SEARCH_NAME = 0,
SEARCH_SIZE,
+ SEARCH_HSIZE,
SEARCH_MIME,
SEARCH_DESC,
SEARCH_PIXBUF,
@@ -61,6 +62,7 @@
DOWNLOAD_FILENAME = 0,
DOWNLOAD_SHORTNAME,
DOWNLOAD_SIZE,
+ DOWNLOAD_HSIZE,
DOWNLOAD_PROGRESS,
DOWNLOAD_URISTRING,
DOWNLOAD_URI,
@@ -72,6 +74,7 @@
enum {
NAMESPACE_FILENAME = 0,
NAMESPACE_SIZE,
+ NAMESPACE_HSIZE,
NAMESPACE_URISTRING,
NAMESPACE_URI,
NAMESPACE_META,
@@ -81,6 +84,7 @@
enum {
IN_NAMESPACE_FILENAME = 0,
IN_NAMESPACE_SIZE,
+ IN_NAMESPACE_HSIZE,
IN_NAMESPACE_DESCRIPTION,
IN_NAMESPACE_MIMETYPE,
IN_NAMESPACE_LAST_STRING,
Modified: gnunet-gtk/src/plugins/fs/namespace.c
===================================================================
--- gnunet-gtk/src/plugins/fs/namespace.c 2006-05-03 20:00:11 UTC (rev
2720)
+++ gnunet-gtk/src/plugins/fs/namespace.c 2006-05-03 20:12:47 UTC (rev
2721)
@@ -81,6 +81,7 @@
gtk_list_store_new(IN_NAMESPACE_NUM,
G_TYPE_STRING, /* (file)name */
G_TYPE_UINT64, /* size */
+ G_TYPE_STRING, /* human-readable size */
G_TYPE_STRING, /* description */
G_TYPE_STRING, /* mime-type */
G_TYPE_STRING, /* last-ID */
@@ -110,11 +111,12 @@
col - 1),
TRUE);
renderer = gtk_cell_renderer_text_new();
+ g_object_set (renderer, "xalign", 1.00, NULL);
col = gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(resultList),
-1,
_("Filesize"),
renderer,
- "text", IN_NAMESPACE_SIZE,
+ "text", IN_NAMESPACE_HSIZE,
NULL);
column = gtk_tree_view_get_column(GTK_TREE_VIEW(resultList),
col - 1);
@@ -248,6 +250,7 @@
char * filename;
char * uriString;
unsigned long long size;
+ char * size_h;
DEBUG_BEGIN();
if (gtk_tree_model_get_iter_first(model,
@@ -292,14 +295,17 @@
uriString = ECRS_uriToString(fi->uri);
gtk_list_store_append(GTK_LIST_STORE(model),
&iter);
+ size_h = getHumanSize(size);
gtk_list_store_set(GTK_LIST_STORE(model),
&iter,
NAMESPACE_FILENAME, filename,
NAMESPACE_SIZE, size,
+ NAMESPACE_HSIZE, size_h,
NAMESPACE_URISTRING, uriString,
NAMESPACE_URI, ECRS_dupUri(fi->uri),
NAMESPACE_META, ECRS_dupMetaData(fi->meta),
-1);
+ FREE(size_h);
FREE(filename);
FREE(uriString);
DEBUG_END();
@@ -390,6 +396,7 @@
char * freq;
char * date;
unsigned long long size;
+ char * size_h;
DEBUG_BEGIN();
filename = ECRS_getFirstFromMetaData(fi->meta,
@@ -444,12 +451,14 @@
date = GN_CTIME(&nextPublicationTime);
freq = updateIntervalToString(publicationFrequency);
+ size_h = getHumanSize(size);
gtk_list_store_append(model,
&iter);
gtk_list_store_set(model,
&iter,
IN_NAMESPACE_FILENAME, filename,
IN_NAMESPACE_SIZE, size,
+ IN_NAMESPACE_HSIZE, size_h,
IN_NAMESPACE_DESCRIPTION, desc,
IN_NAMESPACE_MIMETYPE, mime,
IN_NAMESPACE_LAST_STRING, &last,
@@ -459,6 +468,7 @@
IN_NAMESPACE_URI, ECRS_dupUri(fi->uri),
IN_NAMESPACE_META, ECRS_dupMetaData(fi->meta),
-1);
+ FREE(size_h);
FREE(filename);
FREE(uriString);
FREE(freq);
@@ -1197,6 +1207,7 @@
model = gtk_list_store_new(NAMESPACE_NUM,
G_TYPE_STRING, /* name */
G_TYPE_UINT64, /* size */
+ G_TYPE_STRING, /* human-readable size */
G_TYPE_STRING, /* uri-string */
G_TYPE_POINTER,
G_TYPE_POINTER); /* uri */
@@ -1221,11 +1232,12 @@
col - 1),
TRUE);
renderer = gtk_cell_renderer_text_new();
+ g_object_set (renderer, "xalign", 1.00, NULL);
col = gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(contentList),
-1,
_("Filesize"),
renderer,
- "text", NAMESPACE_SIZE,
+ "text", NAMESPACE_HSIZE,
NULL);
column = gtk_tree_view_get_column(GTK_TREE_VIEW(contentList),
col - 1);
Modified: gnunet-gtk/src/plugins/fs/search.c
===================================================================
--- gnunet-gtk/src/plugins/fs/search.c 2006-05-03 20:00:11 UTC (rev 2720)
+++ gnunet-gtk/src/plugins/fs/search.c 2006-05-03 20:12:47 UTC (rev 2721)
@@ -70,6 +70,7 @@
GdkPixbuf * pixbuf;
GdkPixbufLoader * loader;
unsigned long long size;
+ char * size_h;
DEBUG_BEGIN();
mime = ECRS_getFromMetaData(meta,
@@ -133,10 +134,12 @@
} else {
pixbuf = NULL;
}
+ size_h = getHumanSize(size);
gtk_tree_store_set(model,
pos,
SEARCH_NAME, name,
SEARCH_SIZE, size,
+ SEARCH_HSIZE, size_h,
SEARCH_MIME, mime,
SEARCH_DESC, desc,
SEARCH_PIXBUF, pixbuf,
@@ -144,6 +147,7 @@
SEARCH_META, ECRS_dupMetaData(meta),
SEARCH_INTERNAL, NULL, /* internal */
-1);
+ FREE(size_h);
FREE(mime);
FREE(desc);
FREE(name);
@@ -607,6 +611,7 @@
gtk_tree_store_new(SEARCH_NUM,
G_TYPE_STRING, /* name */
G_TYPE_UINT64, /* size */
+ G_TYPE_STRING, /* human-readable size */
G_TYPE_STRING, /* mime-type */
G_TYPE_STRING, /* meta-data (some) */
GDK_TYPE_PIXBUF, /* preview */
@@ -634,11 +639,12 @@
col - 1),
TRUE);
renderer = gtk_cell_renderer_text_new();
+ g_object_set (renderer, "xalign", 1.00, NULL);
col = gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(resultList),
-1,
_("Size"),
renderer,
- "text", SEARCH_SIZE,
+ "text", SEARCH_HSIZE,
NULL);
column = gtk_tree_view_get_column(GTK_TREE_VIEW(resultList),
col - 1);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r2721 - gnunet-gtk/src/plugins/fs,
grothoff <=