[Xfce4-commits] r23477 - in xarchiver/branches/xarchiver-psybsd: libxarchiver src
Stephan Arts
stephan at xfce.org
Thu Oct 19 23:00:44 UTC 2006
Author: stephan
Date: 2006-10-19 23:00:42 +0000 (Thu, 19 Oct 2006)
New Revision: 23477
Modified:
xarchiver/branches/xarchiver-psybsd/libxarchiver/archive-support-gnu-tar.c
xarchiver/branches/xarchiver-psybsd/libxarchiver/archive.c
xarchiver/branches/xarchiver-psybsd/src/archive_store.c
xarchiver/branches/xarchiver-psybsd/src/main_window.c
xarchiver/branches/xarchiver-psybsd/src/main_window.h
Log:
Applied patch from Peter de Ridder <pc.ridder at zonnet.nl>
Fixes gnu-tar
Modified: xarchiver/branches/xarchiver-psybsd/libxarchiver/archive-support-gnu-tar.c
===================================================================
--- xarchiver/branches/xarchiver-psybsd/libxarchiver/archive-support-gnu-tar.c 2006-10-19 19:23:28 UTC (rev 23476)
+++ xarchiver/branches/xarchiver-psybsd/libxarchiver/archive-support-gnu-tar.c 2006-10-19 23:00:42 UTC (rev 23477)
@@ -197,7 +197,7 @@
{
LXAArchiveSupportGnuTar *support;
- /*
+ /**/
support = g_object_new(LXA_TYPE_ARCHIVE_SUPPORT_GNU_TAR,
"view-time", TRUE,
"view-date", TRUE,
@@ -205,7 +205,7 @@
"view-rights", TRUE,
"view-size", TRUE,
NULL);
- */
+ /*/
support = g_object_new(LXA_TYPE_ARCHIVE_SUPPORT_GNU_TAR,
"view-time", FALSE,
"view-date", FALSE,
@@ -213,6 +213,7 @@
"view-rights", FALSE,
"view-size", FALSE,
NULL);
+ */
return LXA_ARCHIVE_SUPPORT(support);
}
@@ -411,52 +412,26 @@
}
else
{
- archive->n_property = 0;
- archive->entry_props_size = 0;
-
- if(LXA_ARCHIVE_SUPPORT_GNU_TAR(archive->support)->_view_rights)
- archive->n_property++;
- if(LXA_ARCHIVE_SUPPORT_GNU_TAR(archive->support)->_view_owner)
- archive->n_property++;
- if(LXA_ARCHIVE_SUPPORT_GNU_TAR(archive->support)->_view_date)
- archive->n_property++;
- if(LXA_ARCHIVE_SUPPORT_GNU_TAR(archive->support)->_view_time)
- archive->n_property++;
- if(LXA_ARCHIVE_SUPPORT_GNU_TAR(archive->support)->_view_size)
- archive->n_property++;
-
- archive->property_types = g_new0(GType, archive->n_property);
- archive->property_names = g_new0(gchar *, archive->n_property);
-
+ i = LXA_ARCHIVE_PROP_USER;
if(LXA_ARCHIVE_SUPPORT_GNU_TAR(archive->support)->_view_rights) {
- archive->property_types[i] = G_TYPE_STRING;
- archive->property_names[i] = g_strdup(_("Permissions"));
+ lxa_archive_set_property_type(archive, i, G_TYPE_STRING, _("Permissions"));
i++;
- archive->entry_props_size += sizeof(gchar *);
}
if(LXA_ARCHIVE_SUPPORT_GNU_TAR(archive->support)->_view_owner) {
- archive->property_types[i] = G_TYPE_STRING;
- archive->property_names[i] = g_strdup(_("Owner/Group"));
+ lxa_archive_set_property_type(archive, i, G_TYPE_STRING,_("Owner/Group"));
i++;
- archive->entry_props_size += sizeof(gchar *);
}
if(LXA_ARCHIVE_SUPPORT_GNU_TAR(archive->support)->_view_size) {
- archive->property_types[i] = G_TYPE_UINT64;
- archive->property_names[i] = g_strdup(_("Size"));
+ lxa_archive_set_property_type(archive, i, G_TYPE_UINT64, _("Size"));
i++;
- archive->entry_props_size += sizeof(guint64);
}
if(LXA_ARCHIVE_SUPPORT_GNU_TAR(archive->support)->_view_date) {
- archive->property_types[i] = G_TYPE_STRING;
- archive->property_names[i] = g_strdup(_("Date"));
+ lxa_archive_set_property_type(archive, i, G_TYPE_STRING, _("Date"));
i++;
- archive->entry_props_size += sizeof(gchar *);
}
if(LXA_ARCHIVE_SUPPORT_GNU_TAR(archive->support)->_view_time) {
- archive->property_types[i] = G_TYPE_STRING;
- archive->property_names[i] = g_strdup(_("Time"));
+ lxa_archive_set_property_type(archive, i, G_TYPE_STRING, _("Time"));
i++;
- archive->entry_props_size += sizeof(gchar *);
}
if(!g_strcasecmp((gchar *)archive->mime, "application/x-tzo"))
command = g_strconcat(LXA_ARCHIVE_SUPPORT_GNU_TAR(archive->support)->app_name, " --use-compress-program=lzop -tvf " , archive->path, NULL);
@@ -500,7 +475,10 @@
LXAArchive *archive = data;
gchar *line = NULL;
LXAEntry *entry;
+ gpointer props[6];
+ guint64 size;
+ guint linesize;
gint n = 0, a = 0, i = 0, o = 0;
gchar *temp_filename = NULL;
@@ -518,82 +496,78 @@
if (line == NULL)
break;
+ linesize = strlen(line);
+
if(LXA_ARCHIVE_SUPPORT_GNU_TAR(archive->support)->_view_rights)
{
- /*
- (*(gchar **)props_iter) = g_strndup (line, 10);
- props_iter += sizeof(gchar *);
- */
+ line[10] = '\0';
+ props[i] = line;
+ i++;
}
- for(n=13; n < strlen(line); n++)
+ for(n=13; n < linesize; ++n)
if(line[n] == ' ') break;
if(LXA_ARCHIVE_SUPPORT_GNU_TAR(archive->support)->_view_owner)
{
- /*
- (*(gchar **)props_iter) = g_strndup (&line[11], n-11);
- props_iter += sizeof(gchar *);
- */
+ line[n] = '\0';
+ props[i] = line+11;
+ i++;
}
- for(; n < strlen(line); n++)
+ for(++n; n < linesize; ++n)
if(line[n] >= '0' && line[n] <= '9') break;
- a = ++n;
+ a = n;
- for(; n < strlen(line); n++)
+ for(; n < linesize; ++n)
if(line[n] == ' ') break;
if(LXA_ARCHIVE_SUPPORT_GNU_TAR(archive->support)->_view_size)
{
- /*
- _size = g_strndup(&line[a], n-a);
- (*((guint64 *)props_iter)) = g_ascii_strtoull( _size, NULL, 0);
- g_free (_size);
- props_iter += sizeof(guint64);
- */
+ line[n] = '\0';
+ size = g_ascii_strtoll(line + a, NULL, 0);
+ props[i] = &size;
+ i++;
}
a = ++n;
- for(; n < strlen(line); n++) // DATE
+ for(; n < linesize; n++) // DATE
if(line[n] == ' ') break;
if(LXA_ARCHIVE_SUPPORT_GNU_TAR(archive->support)->_view_date)
{
- /*
- (*(gchar **)props_iter) = g_strndup (&line[a], n-a);
- props_iter += sizeof(gchar *);
- */
+ line[n] = '\0';
+ props[i] = line + a;
+ i++;
}
a = ++n;
- for (; n < strlen(line); n++) // TIME
+ for (; n < linesize; n++) // TIME
if (line[n] == ' ') break;
if(LXA_ARCHIVE_SUPPORT_GNU_TAR(archive->support)->_view_time)
{
- /*
- (*(gchar **)props_iter) = g_strndup (&line[a], n-a);
- props_iter += sizeof(gchar *);
- */
+ line[n] = '\0';
+ props[i] = line + a;
+ i++;
}
+ n++;
+
gchar *temp = g_strrstr (&line[n],"->");
if (temp )
{
- temp_filename = g_strstrip(g_strndup(&line[n], strlen(line) - strlen(temp) - n ));
+ temp[0] = '\0';
}
- else
- {
- temp_filename = g_strstrip(g_strndup(&line[n], strlen(line)-n-1));
- }
+
+ temp_filename = g_strchomp(line + n);
entry = lxa_archive_add_file(archive, temp_filename);
+ lxa_archive_iter_set_propsv(archive, entry, (gconstpointer*)props);
g_free(line);
- g_free(temp_filename);
}
}
if(cond & (G_IO_ERR | G_IO_HUP | G_IO_NVAL) )
Modified: xarchiver/branches/xarchiver-psybsd/libxarchiver/archive.c
===================================================================
--- xarchiver/branches/xarchiver-psybsd/libxarchiver/archive.c 2006-10-19 19:23:28 UTC (rev 23476)
+++ xarchiver/branches/xarchiver-psybsd/libxarchiver/archive.c 2006-10-19 23:00:42 UTC (rev 23477)
@@ -22,6 +22,7 @@
#include <signal.h>
#include <sys/wait.h>
#include <sys/types.h>
+#include <gettext.h>
#include "mime.h"
@@ -315,13 +316,36 @@
return G_TYPE_STRING;
case LXA_ARCHIVE_PROP_MIME_TYPE:
return G_TYPE_STRING;
- case LXA_ARCHIVE_PROP_USER:
+ default:
return archive->property_types[i - LXA_ARCHIVE_PROP_USER];
}
- return G_TYPE_NONE;
+ g_return_val_if_reached(G_TYPE_NONE);
}
/*
+ * const gchar *
+ * lxa_archive_get_property_name(LXAArchive *, guint)
+ *
+ */
+const gchar *
+lxa_archive_get_property_name(LXAArchive *archive, guint i)
+{
+#ifdef DEBUG /* n_property + 2, filename and MIME */
+ g_return_val_if_fail(i < (archive->n_property+LXA_ARCHIVE_PROP_USER), NULL);
+#endif
+ switch(i)
+ {
+ case LXA_ARCHIVE_PROP_FILENAME:
+ return _("Filename");
+ case LXA_ARCHIVE_PROP_MIME_TYPE:
+ return _("Mime type");
+ default:
+ return archive->property_names[i - LXA_ARCHIVE_PROP_USER];
+ }
+ g_return_val_if_reached(NULL);
+}
+
+/*
* void
* lxa_archive_set_property_type(LXAArchive *archive, guint i, GType *, const gchar *)
*
@@ -702,8 +726,10 @@
{
#ifdef DEBUG
g_return_val_if_fail(n >= 0, NULL);
- g_return_val_if_fail(n < lxa_archive_iter_n_children(archive, iter), NULL);
#endif
+ if(n >= lxa_archive_iter_n_children(archive, iter))
+ return NULL;
+
lxa_archive_entry_flush_buffer(archive, (LXAEntry *)iter);
/* the first element of the array (*iter->children) contains the size of the array */
return ((LXAEntry *)iter->children[n+1]);
@@ -982,11 +1008,11 @@
props_iter += sizeof(gchar *);
break;
case G_TYPE_UINT:
- (*((guint *)props_iter)) = ((const guint)props[i]);
+ (*((guint *)props_iter)) = *((const guint*)props[i]);
props_iter += sizeof(guint);
break;
case G_TYPE_UINT64:
- (*((guint64 *)props_iter)) = ((const guint)props[i]);
+ (*((guint64 *)props_iter)) = *((const guint*)props[i]);
props_iter += sizeof(guint64);
break;
}
@@ -1142,31 +1168,3 @@
return (*((guint64 *)props_iter));
}
-
-/**************
- * Depricated *
- **************/
-
-LXAEntry *
-lxa_entry_children_nth_data(LXAArchive *archive, LXAEntry *entry, guint n)
-{
- if(entry == NULL)
- return NULL;
- lxa_archive_entry_flush_buffer(archive, entry);
- n++;
- /* the first element of the array (*entry->children) contains the size of the array */
- if(entry->children && n > 0 && n <= GPOINTER_TO_INT(*entry->children))
- return entry->children[n];
- else
- return NULL;
-}
-
-guint
-lxa_entry_children_length(LXAEntry *entry)
-{
- g_return_val_if_fail(entry, 0);
- /* the first element of the array (*entry->children) contains the size of the array */
- return entry->children?GPOINTER_TO_INT(*entry->children):0 + lxa_slist_length(entry->buffer);
-}
-
-
Modified: xarchiver/branches/xarchiver-psybsd/src/archive_store.c
===================================================================
--- xarchiver/branches/xarchiver-psybsd/src/archive_store.c 2006-10-19 19:23:28 UTC (rev 23476)
+++ xarchiver/branches/xarchiver-psybsd/src/archive_store.c 2006-10-19 23:00:42 UTC (rev 23477)
@@ -350,7 +350,7 @@
if(!archive)
return 0;
- return archive->n_property + 1;
+ return lxa_archive_n_property(archive) + 1;
}
static GType
@@ -395,7 +395,7 @@
gint index = indices[depth];
- if(store->props._show_up_dir && archive->root_entry != entry)
+ if(store->props._show_up_dir && lxa_archive_get_iter(archive, NULL) != entry)
index--;
if(index == -1)
@@ -435,7 +435,7 @@
LXAArchiveIter *entry = (LXAArchiveIter*)iter->user_data2;
gint pos = GPOINTER_TO_INT(iter->user_data3);
- if(store->props._show_up_dir && archive->root_entry != entry)
+ if(store->props._show_up_dir && lxa_archive_get_iter(archive, NULL) != entry)
pos++;
GtkTreePath *path = gtk_tree_path_new();
@@ -537,7 +537,7 @@
/* only support lists: parent is always NULL */
g_return_val_if_fail(parent == NULL, FALSE);
- if(store->props._show_up_dir && archive->root_entry != entry)
+ if(store->props._show_up_dir && lxa_archive_get_iter(archive, NULL) != entry)
{
entry = NULL;
iter->user_data3 = GINT_TO_POINTER(-1);
@@ -582,7 +582,7 @@
/* only support lists: iter is always NULL */
g_return_val_if_fail(iter == NULL, FALSE);
- return lxa_archive_iter_n_children(archive, entry) + (archive->root_entry == entry)?0:1;
+ return lxa_archive_iter_n_children(archive, entry) + (lxa_archive_get_iter(archive, NULL) == entry)?0:1;
}
static gboolean
@@ -601,7 +601,7 @@
/* only support lists: parent is always NULL */
g_return_val_if_fail(parent == NULL, FALSE);
- if(store->props._show_up_dir && archive->root_entry != entry)
+ if(store->props._show_up_dir && lxa_archive_get_iter(archive, NULL) != entry)
n--;
if(n == -1)
@@ -868,7 +868,7 @@
GtkTreePath *path_ = NULL;
GtkTreeIter iter;
- if(store->props._show_up_dir && archive->root_entry != entry) {
+ if(store->props._show_up_dir && lxa_archive_get_iter(archive, NULL) != entry) {
path_ = gtk_tree_path_new();
gtk_tree_path_append_index(path_, 0);
@@ -895,7 +895,7 @@
if(store->sort_list)
iter.user_data = store->sort_list[i];
else
- iter.user_data = lxa_archive_iter_nth_child(archive, archive->root_entry, i);
+ iter.user_data = lxa_archive_iter_nth_child(archive, lxa_archive_get_iter(archive, NULL), i);
iter.user_data2 = entry;
iter.user_data3 = GINT_TO_POINTER(index);
@@ -941,7 +941,7 @@
gint prev_size = lxa_archive_iter_n_children(archive, entry);
gint index = indices[depth];
- if(store->props._show_up_dir && archive->root_entry != entry)
+ if(store->props._show_up_dir && lxa_archive_get_iter(archive, NULL) != entry)
{
prev_size++;
index--;
@@ -990,7 +990,7 @@
gint prev_size = lxa_archive_iter_n_children(archive, entry);
- if(store->props._show_up_dir && archive->root_entry != entry)
+ if(store->props._show_up_dir && lxa_archive_get_iter(archive, NULL) != entry)
{
prev_size++;
}
@@ -1030,7 +1030,7 @@
prev_size = lxa_archive_iter_n_children(archive, entry);
- if(store->props._show_up_dir && store->archive->root_entry != entry)
+ if(store->props._show_up_dir && lxa_archive_get_iter(store->archive, NULL) != entry)
prev_size++;
g_slist_free(store->current_entry);
@@ -1059,11 +1059,11 @@
g_object_ref(archive);
store->archive = archive;
- store->current_entry = g_slist_prepend(NULL, archive->root_entry);
+ store->current_entry = g_slist_prepend(NULL, lxa_archive_get_iter(archive, NULL));
xa_archive_store_sort(store);
- for(i = 0; i < lxa_archive_iter_n_children(archive, archive->root_entry); i++)
+ for(i = 0; i < lxa_archive_iter_n_children(archive, lxa_archive_get_iter(archive, NULL)); i++)
{
path_ = gtk_tree_path_new();
gtk_tree_path_append_index(path_, i);
@@ -1072,8 +1072,8 @@
if(store->sort_list)
iter.user_data = store->sort_list[i];
else
- iter.user_data = lxa_archive_iter_nth_child(archive, archive->root_entry, i);
- iter.user_data2 = archive->root_entry;
+ iter.user_data = lxa_archive_iter_nth_child(archive, lxa_archive_get_iter(archive, NULL), i);
+ iter.user_data2 = lxa_archive_get_iter(archive, NULL);
iter.user_data3 = GINT_TO_POINTER(i);
gtk_tree_model_row_inserted(GTK_TREE_MODEL(store), path_, &iter);
@@ -1186,7 +1186,7 @@
GSList *stack = g_slist_prepend(NULL, entry);
gint prev_size = lxa_archive_iter_n_children(store->archive, ((LXAArchiveIter*)store->current_entry->data));
- if(store->props._show_up_dir && store->archive->root_entry != store->current_entry->data)
+ if(store->props._show_up_dir && lxa_archive_get_iter(store->archive, NULL) != store->current_entry->data)
prev_size++;
if(path[0] == '/' && lxa_archive_iter_get_child(store->archive, entry, "/"))
Modified: xarchiver/branches/xarchiver-psybsd/src/main_window.c
===================================================================
--- xarchiver/branches/xarchiver-psybsd/src/main_window.c 2006-10-19 19:23:28 UTC (rev 23476)
+++ xarchiver/branches/xarchiver-psybsd/src/main_window.c 2006-10-19 23:00:42 UTC (rev 23477)
@@ -169,11 +169,6 @@
const gchar *nav_bar;
gboolean up_dir = TRUE;
- window->working_node = NULL;
- window->parent_node = g_new0(GValue, 1);
- window->parent_node = g_value_init(window->parent_node, G_TYPE_STRING);
- g_value_set_string(window->parent_node, "..");
-
window->settings = xa_settings_new(NULL);
main_vbox = gtk_vbox_new(FALSE, 0);
@@ -478,8 +473,6 @@
{
g_debug("Archive opened");
g_signal_connect(G_OBJECT(window->lp_xa_archive), "lxa_status_changed", G_CALLBACK(xa_main_window_archive_status_changed), window);
- g_slist_free(window->working_node);
- window->working_node = NULL;
lp_support = lxa_get_support_for_mime(window->lp_xa_archive->mime);
gtk_widget_set_sensitive(GTK_WIDGET(window->menubar.menu_item_close), TRUE);
@@ -592,7 +585,6 @@
{
GList *rows = gtk_tree_selection_get_selected_rows(selection, &treemodel);
GList *_rows = rows;
- gchar *working_dir = xa_main_window_get_working_dir(window);
while(_rows)
{
gtk_tree_model_get_iter(GTK_TREE_MODEL(treemodel), &iter, _rows->data);
@@ -601,11 +593,9 @@
else
gtk_tree_model_get_value(GTK_TREE_MODEL(treemodel), &iter, 0, value);
- filenames = g_slist_prepend(filenames, g_strconcat(working_dir, "/", g_value_get_string(value), NULL));
g_value_unset(value);
_rows = _rows->next;
}
- g_free(working_dir);
g_list_free(rows);
}
lxa_archive_support_extract(lp_support, window->lp_xa_archive, extract_archive_path, filenames);
@@ -666,8 +656,6 @@
if(!lxa_open_archive(archive_path, &window->lp_xa_archive))
{
g_signal_connect(G_OBJECT(window->lp_xa_archive), "lxa_status_changed", G_CALLBACK(xa_main_window_archive_status_changed), window);
- g_slist_free(window->working_node);
- window->working_node = NULL;
lp_support = lxa_get_support_for_mime(window->lp_xa_archive->mime);
lxa_archive_support_refresh(lp_support, window->lp_xa_archive);
@@ -718,7 +706,6 @@
case(LXA_ARCHIVESTATUS_REFRESH):
xa_main_window_reset_columns(main_window);
- main_window->working_node = g_slist_prepend(main_window->working_node, &(archive->root_entry));
xa_main_window_set_contents(main_window, archive);
case(LXA_ARCHIVESTATUS_EXTRACT):
gtk_widget_set_sensitive(GTK_WIDGET(main_window->menubar.menu_item_add), TRUE);
@@ -793,27 +780,27 @@
renderer = gtk_cell_renderer_text_new();
gtk_tree_view_column_pack_start(column, renderer, TRUE);
- gtk_tree_view_column_set_attributes(column, renderer, "text", 1, NULL);
+ gtk_tree_view_column_set_attributes(column, renderer, "text", LXA_ARCHIVE_PROP_FILENAME + 1, NULL);
gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
- gtk_tree_view_column_set_sort_column_id(column, 1);
- gtk_tree_view_column_set_title(column, "Filename");
+ gtk_tree_view_column_set_sort_column_id(column, LXA_ARCHIVE_PROP_FILENAME + 1);
+ gtk_tree_view_column_set_title(column, lxa_archive_get_property_name(archive, LXA_ARCHIVE_PROP_FILENAME));
gtk_tree_view_append_column(GTK_TREE_VIEW(window->treeview), column);
if(!show_only_filenames)
{
- for(x = 0; x < archive->n_property; x++)
+ for(x = LXA_ARCHIVE_PROP_USER; x < lxa_archive_n_property(archive); ++x)
{
- switch(archive->property_types[x])
+ switch(lxa_archive_get_property_type(archive, x))
{
case(G_TYPE_STRING):
case(G_TYPE_UINT64):
renderer = gtk_cell_renderer_text_new();
- column = gtk_tree_view_column_new_with_attributes(archive->property_names[x], renderer, "text", x+3, NULL);
+ column = gtk_tree_view_column_new_with_attributes(lxa_archive_get_property_name(archive, x), renderer, "text", x+1, NULL);
break;
}
gtk_tree_view_column_set_resizable(column, TRUE);
- gtk_tree_view_column_set_sort_column_id(column, x+3);
+ gtk_tree_view_column_set_sort_column_id(column, x+1);
gtk_tree_view_append_column(GTK_TREE_VIEW(window->treeview), column);
}
}
@@ -834,21 +821,3 @@
gtk_tree_view_set_model(GTK_TREE_VIEW(main_window->treeview), GTK_TREE_MODEL(liststore));
}
-gchar *
-xa_main_window_get_working_dir(XAMainWindow *window)
-{
- const gchar *temp = lxa_archive_iter_get_filename(window->lp_xa_archive, (LXAArchiveIter *)window->working_node->data);
- gchar *path = g_strdup(temp), *_temp = NULL;
- GSList *_path = window->working_node->next;
- while(_path)
- {
- if((lxa_archive_iter_get_filename(window->lp_xa_archive, (LXAArchiveIter *)_path->data)[0] != '/'))
- {
- _temp = path;
- path = g_strconcat(lxa_archive_iter_get_filename(window->lp_xa_archive, (LXAArchiveIter *)_path->data), "/", _temp,NULL);
- g_free(_temp);
- }
- _path = _path->next;
- }
- return path;
-}
Modified: xarchiver/branches/xarchiver-psybsd/src/main_window.h
===================================================================
--- xarchiver/branches/xarchiver-psybsd/src/main_window.h 2006-10-19 19:23:28 UTC (rev 23476)
+++ xarchiver/branches/xarchiver-psybsd/src/main_window.h 2006-10-19 23:00:42 UTC (rev 23477)
@@ -100,8 +100,6 @@
} toolbar;
GtkIconTheme *icon_theme;
LXAArchive *lp_xa_archive;
- GValue *parent_node;
- GSList *working_node;
struct {
gboolean _show_icons;
} props;
More information about the Xfce4-commits
mailing list