[Xfce4-commits] r23296 - in xarchiver/branches/xarchiver-psybsd: libxarchiver src
Stephan Arts
stephan at xfce.org
Fri Oct 6 09:54:44 UTC 2006
Author: stephan
Date: 2006-10-06 09:54:42 +0000 (Fri, 06 Oct 2006)
New Revision: 23296
Modified:
xarchiver/branches/xarchiver-psybsd/libxarchiver/archive-support-gnu-tar.c
xarchiver/branches/xarchiver-psybsd/libxarchiver/archive-support-zip.c
xarchiver/branches/xarchiver-psybsd/libxarchiver/archive-support-zip.h
xarchiver/branches/xarchiver-psybsd/src/archive_store.c
xarchiver/branches/xarchiver-psybsd/src/archive_store.h
xarchiver/branches/xarchiver-psybsd/src/main_window.c
Log:
Fixed segfault.
added props to archive-store.
Modified: xarchiver/branches/xarchiver-psybsd/libxarchiver/archive-support-gnu-tar.c
===================================================================
--- xarchiver/branches/xarchiver-psybsd/libxarchiver/archive-support-gnu-tar.c 2006-10-05 22:27:00 UTC (rev 23295)
+++ xarchiver/branches/xarchiver-psybsd/libxarchiver/archive-support-gnu-tar.c 2006-10-06 09:54:42 UTC (rev 23296)
@@ -403,34 +403,34 @@
archive->column_names = g_new0(gchar *, archive->column_number);
archive->column_types[0] = G_TYPE_STRING;
- archive->column_names[0] = g_strdup("Filename");
+ archive->column_names[0] = g_strdup(_("Filename"));
if(LXA_ARCHIVE_SUPPORT_GNU_TAR(archive->support)->_view_rights) {
archive->column_types[i] = G_TYPE_STRING;
- archive->column_names[i] = g_strdup("Rights");
+ archive->column_names[i] = g_strdup(_("Permissions"));
i++;
archive->entry_props_size += sizeof(gchar *);
}
if(LXA_ARCHIVE_SUPPORT_GNU_TAR(archive->support)->_view_owner) {
archive->column_types[i] = G_TYPE_STRING;
- archive->column_names[i] = g_strdup("Owner");
+ archive->column_names[i] = g_strdup(_("Owner/Group"));
i++;
archive->entry_props_size += sizeof(gchar *);
}
if(LXA_ARCHIVE_SUPPORT_GNU_TAR(archive->support)->_view_size) {
archive->column_types[i] = G_TYPE_UINT64;
- archive->column_names[i] = g_strdup("Size");
+ archive->column_names[i] = g_strdup(_("Size"));
i++;
archive->entry_props_size += sizeof(guint64);
}
if(LXA_ARCHIVE_SUPPORT_GNU_TAR(archive->support)->_view_date) {
archive->column_types[i] = G_TYPE_STRING;
- archive->column_names[i] = g_strdup("Date");
+ archive->column_names[i] = g_strdup(_("Date"));
i++;
archive->entry_props_size += sizeof(gchar *);
}
if(LXA_ARCHIVE_SUPPORT_GNU_TAR(archive->support)->_view_time) {
archive->column_types[i] = G_TYPE_STRING;
- archive->column_names[i] = g_strdup("Time");
+ archive->column_names[i] = g_strdup(_("Time"));
i++;
archive->entry_props_size += sizeof(gchar *);
}
@@ -562,6 +562,7 @@
entry = lxa_archive_add_file(archive, temp_filename);
entry->props = props;
g_free(line);
+ g_free(temp_filename);
}
}
if(cond & (G_IO_ERR | G_IO_HUP | G_IO_NVAL) )
@@ -691,6 +692,7 @@
LXA_ARCHIVE_SUPPORT_GNU_TAR(object)->_extr_strip = g_value_get_uint(value);
break;
+/* */
case LXA_ARCHIVE_SUPPORT_GNU_TAR_VIEW_SIZE:
LXA_ARCHIVE_SUPPORT_GNU_TAR(object)->_view_size = g_value_get_boolean(value);
break;
Modified: xarchiver/branches/xarchiver-psybsd/libxarchiver/archive-support-zip.c
===================================================================
--- xarchiver/branches/xarchiver-psybsd/libxarchiver/archive-support-zip.c 2006-10-05 22:27:00 UTC (rev 23295)
+++ xarchiver/branches/xarchiver-psybsd/libxarchiver/archive-support-zip.c 2006-10-06 09:54:42 UTC (rev 23296)
@@ -48,6 +48,9 @@
void
lxa_archive_support_zip_class_init(LXAArchiveSupportZipClass *supportclass);
+gboolean
+lxa_archive_support_zip_refresh_parse_output(GIOChannel *ioc, GIOCondition cond, gpointer data);
+
void
lxa_archive_support_zip_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
void
@@ -90,6 +93,8 @@
archive_support->add = lxa_archive_support_zip_add;
archive_support->extract = lxa_archive_support_zip_extract;
+ archive_support->remove = lxa_archive_support_zip_remove;
+ archive_support->refresh = lxa_archive_support_zip_refresh;
}
void
@@ -114,6 +119,56 @@
FALSE,
G_PARAM_READWRITE);
g_object_class_install_property(object_class, LXA_ARCHIVE_SUPPORT_ZIP_EXTRACT_OVERWRITE, pspec);
+
+ pspec = g_param_spec_boolean("view-size",
+ "View file-size",
+ "View file-size",
+ FALSE,
+ G_PARAM_READWRITE);
+ g_object_class_install_property(object_class, LXA_ARCHIVE_SUPPORT_ZIP_VIEW_SIZE, pspec);
+
+ pspec = g_param_spec_boolean("view-time",
+ "View time",
+ "View time",
+ FALSE,
+ G_PARAM_READWRITE);
+ g_object_class_install_property(object_class, LXA_ARCHIVE_SUPPORT_ZIP_VIEW_TIME, pspec);
+
+ pspec = g_param_spec_boolean("view-date",
+ "View date",
+ "View date",
+ FALSE,
+ G_PARAM_READWRITE);
+ g_object_class_install_property(object_class, LXA_ARCHIVE_SUPPORT_ZIP_VIEW_DATE, pspec);
+
+ pspec = g_param_spec_boolean("view-ratio",
+ "View ratio",
+ "View ratio",
+ FALSE,
+ G_PARAM_READWRITE);
+ g_object_class_install_property(object_class, LXA_ARCHIVE_SUPPORT_ZIP_VIEW_RATIO, pspec);
+
+ pspec = g_param_spec_boolean("view-length",
+ "View length",
+ "View length",
+ FALSE,
+ G_PARAM_READWRITE);
+ g_object_class_install_property(object_class, LXA_ARCHIVE_SUPPORT_ZIP_VIEW_LENGTH, pspec);
+
+ pspec = g_param_spec_boolean("view-method",
+ "View method",
+ "View method",
+ FALSE,
+ G_PARAM_READWRITE);
+ g_object_class_install_property(object_class, LXA_ARCHIVE_SUPPORT_ZIP_VIEW_METHOD, pspec);
+
+ pspec = g_param_spec_boolean("view-crc32",
+ "View CRC-32",
+ "View CRC-32",
+ FALSE,
+ G_PARAM_READWRITE);
+ g_object_class_install_property(object_class, LXA_ARCHIVE_SUPPORT_ZIP_VIEW_CRC_32, pspec);
+
}
LXAArchiveSupport*
@@ -121,7 +176,11 @@
{
LXAArchiveSupportZip *support;
- support = g_object_new(LXA_TYPE_ARCHIVE_SUPPORT_ZIP, NULL);
+ support = g_object_new(LXA_TYPE_ARCHIVE_SUPPORT_ZIP,
+ "view-size", TRUE,
+ "view-time", TRUE,
+ "view-date", TRUE,
+ NULL);
return LXA_ARCHIVE_SUPPORT(support);
}
@@ -212,6 +271,171 @@
return 0;
}
+gint
+lxa_archive_support_zip_refresh(LXAArchive *archive)
+{
+ guint i = 1;
+ if(!LXA_IS_ARCHIVE_SUPPORT_ZIP(archive->support))
+ {
+ g_critical("Support is not Zip");
+ return -1;
+ }
+
+ if(!lxa_archive_support_mime_supported(archive->support, archive->mime))
+ {
+ return 1;
+ }
+ else
+ {
+ archive->column_number = 1;
+ archive->entry_props_size = 0;
+
+ if(LXA_ARCHIVE_SUPPORT_ZIP(archive->support)->_view_size)
+ archive->column_number++;
+ if(LXA_ARCHIVE_SUPPORT_ZIP(archive->support)->_view_length)
+ archive->column_number++;
+ if(LXA_ARCHIVE_SUPPORT_ZIP(archive->support)->_view_ratio)
+ archive->column_number++;
+ if(LXA_ARCHIVE_SUPPORT_ZIP(archive->support)->_view_crc_32)
+ archive->column_number++;
+ if(LXA_ARCHIVE_SUPPORT_ZIP(archive->support)->_view_date)
+ archive->column_number++;
+ if(LXA_ARCHIVE_SUPPORT_ZIP(archive->support)->_view_time)
+ archive->column_number++;
+
+ archive->column_types = g_new0(GType, archive->column_number);
+ archive->column_names = g_new0(gchar *, archive->column_number);
+
+ archive->column_types[0] = G_TYPE_STRING;
+ archive->column_names[0] = g_strdup(_("Filename"));
+ if(LXA_ARCHIVE_SUPPORT_ZIP(archive->support)->_view_method) {
+ archive->column_types[i] = G_TYPE_STRING;
+ archive->column_names[i] = g_strdup(_("Compression method"));
+ i++;
+ archive->entry_props_size += sizeof(gchar *);
+ }
+ if(LXA_ARCHIVE_SUPPORT_ZIP(archive->support)->_view_ratio) {
+ archive->column_types[i] = G_TYPE_STRING;
+ archive->column_names[i] = g_strdup("Ratio");
+ i++;
+ archive->entry_props_size += sizeof(gchar *);
+ }
+ if(LXA_ARCHIVE_SUPPORT_ZIP(archive->support)->_view_size) {
+ archive->column_types[i] = G_TYPE_UINT64;
+ archive->column_names[i] = g_strdup(_("Size"));
+ i++;
+ archive->entry_props_size += sizeof(guint64);
+ }
+ if(LXA_ARCHIVE_SUPPORT_ZIP(archive->support)->_view_length) {
+ archive->column_types[i] = G_TYPE_UINT64;
+ archive->column_names[i] = g_strdup(_("Length"));
+ i++;
+ archive->entry_props_size += sizeof(guint64);
+ }
+ if(LXA_ARCHIVE_SUPPORT_ZIP(archive->support)->_view_date) {
+ archive->column_types[i] = G_TYPE_STRING;
+ archive->column_names[i] = g_strdup(_("Date"));
+ i++;
+ archive->entry_props_size += sizeof(gchar *);
+ }
+ if(LXA_ARCHIVE_SUPPORT_ZIP(archive->support)->_view_time) {
+ archive->column_types[i] = G_TYPE_STRING;
+ archive->column_names[i] = g_strdup(_("Time"));
+ i++;
+ archive->entry_props_size += sizeof(gchar *);
+ }
+ if(LXA_ARCHIVE_SUPPORT_ZIP(archive->support)->_view_crc_32) {
+ archive->column_types[i] = G_TYPE_STRING;
+ archive->column_names[i] = g_strdup("CRC-32");
+ i++;
+ archive->entry_props_size += sizeof(gchar *);
+ }
+
+ gchar *command = g_strconcat("unzip -lv -qq " , archive->path, NULL);
+ lxa_execute(command, archive, NULL, NULL, lxa_archive_support_zip_refresh_parse_output, NULL);
+ g_free(command);
+ }
+}
+
+gboolean
+lxa_archive_support_zip_refresh_parse_output(GIOChannel *ioc, GIOCondition cond, gpointer data)
+{
+ GIOStatus status = G_IO_STATUS_NORMAL;
+ LXAArchive *archive = data;
+ gchar *line = NULL;
+ LXAEntry *entry;
+
+ gpointer props = NULL;
+ gpointer props_iter = NULL;
+ gint n = 0, a = 0, i = 0, o = 0;
+ gchar *temp_filename = NULL;
+ gchar *_size = NULL;
+
+ if(!LXA_IS_ARCHIVE(archive))
+ return FALSE;
+
+
+ if(cond & (G_IO_PRI | G_IO_IN))
+ {
+ for(o = 0; o < 500; o++)
+ {
+ i = 0;
+
+ status = g_io_channel_read_line(ioc, &line, NULL,NULL,NULL);
+ if (line == NULL)
+ break;
+ /* length, method , size, ratio, date, time, crc-32, filename*/
+
+ props = g_malloc0(archive->entry_props_size);
+ props_iter = props;
+
+ if(LXA_ARCHIVE_SUPPORT_ZIP(archive->support)->_view_length)
+ {
+
+ }
+ if(LXA_ARCHIVE_SUPPORT_ZIP(archive->support)->_view_method)
+ {
+
+ }
+ if(LXA_ARCHIVE_SUPPORT_ZIP(archive->support)->_view_size)
+ {
+
+ }
+ if(LXA_ARCHIVE_SUPPORT_ZIP(archive->support)->_view_ratio)
+ {
+
+ }
+ if(LXA_ARCHIVE_SUPPORT_ZIP(archive->support)->_view_date)
+ {
+
+ }
+ if(LXA_ARCHIVE_SUPPORT_ZIP(archive->support)->_view_time)
+ {
+
+ }
+ if(LXA_ARCHIVE_SUPPORT_ZIP(archive->support)->_view_crc_32)
+ {
+
+ }
+
+ entry = lxa_archive_add_file(archive, temp_filename);
+ entry->props = props;
+ g_free(line);
+ }
+ }
+ if(cond & (G_IO_ERR | G_IO_HUP | G_IO_NVAL) )
+ {
+#ifdef DEBUG
+ g_debug("shutting down ioc");
+#endif
+ g_io_channel_shutdown ( ioc,TRUE,NULL );
+ g_io_channel_unref (ioc);
+ lxa_archive_set_status(archive, LXA_ARCHIVESTATUS_IDLE);
+ return FALSE;
+ }
+ return TRUE;
+}
+
void
lxa_archive_support_zip_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
{
Modified: xarchiver/branches/xarchiver-psybsd/libxarchiver/archive-support-zip.h
===================================================================
--- xarchiver/branches/xarchiver-psybsd/libxarchiver/archive-support-zip.h 2006-10-05 22:27:00 UTC (rev 23295)
+++ xarchiver/branches/xarchiver-psybsd/libxarchiver/archive-support-zip.h 2006-10-06 09:54:42 UTC (rev 23296)
@@ -71,6 +71,7 @@
gint lxa_archive_support_zip_add(LXAArchive *, GSList *);
gint lxa_archive_support_zip_extract(LXAArchive *, gchar *, GSList *);
gint lxa_archive_support_zip_remove(LXAArchive *, GSList *);
+gint lxa_archive_support_zip_refresh(LXAArchive *);
G_END_DECLS
Modified: xarchiver/branches/xarchiver-psybsd/src/archive_store.c
===================================================================
--- xarchiver/branches/xarchiver-psybsd/src/archive_store.c 2006-10-05 22:27:00 UTC (rev 23295)
+++ xarchiver/branches/xarchiver-psybsd/src/archive_store.c 2006-10-06 09:54:42 UTC (rev 23296)
@@ -35,6 +35,17 @@
static void
xa_archive_tree_sartable_init(GtkTreeSortableIface *ts_interface);
+/* properties */
+enum {
+ XA_ARCHIVE_STORE_SHOW_ICONS = 1,
+ XA_ARCHIVE_STORE_SHOW_UP_DIR
+};
+
+static void
+xa_archive_store_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
+static void
+xa_archive_store_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
+
/* tree model */
static GtkTreeModelFlags
xa_archive_store_get_flags(GtkTreeModel *tree_model);
@@ -132,15 +143,63 @@
as->archive = NULL;
as->current_entry = NULL;
as->props._show_icons = FALSE;
+ as->props._show_up_dir = TRUE;
+ as->up_entry.filename = "..";
+ as->up_entry.props = NULL;
}
static void
xa_archive_store_class_init(XAArchiveStoreClass *as_class)
{
+ GObjectClass *object_class = G_OBJECT_CLASS (as_class);
+ GParamSpec *pspec = NULL;
+ object_class->set_property = xa_archive_store_set_property;
+ object_class->get_property = xa_archive_store_get_property;
+
+ pspec = g_param_spec_boolean("show_icons",
+ _("Show mime icons"),
+ _("Show the mime type icons for each entry"),
+ FALSE,
+ G_PARAM_READWRITE);
+ g_object_class_install_property(object_class, XA_ARCHIVE_STORE_SHOW_ICONS, pspec);
+
+ pspec = g_param_spec_boolean("show_up_dir",
+ _("Show up dir entry"),
+ _("Show \'..\' to go to the parent directory"),
+ TRUE,
+ G_PARAM_READWRITE);
+ g_object_class_install_property(object_class, XA_ARCHIVE_STORE_SHOW_UP_DIR, pspec);
}
+static void
+xa_archive_store_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+{
+ switch(prop_id)
+ {
+ case XA_ARCHIVE_STORE_SHOW_ICONS:
+ XA_ARCHIVE_STORE(object)->props._show_icons = g_value_get_boolean(value);
+ break;
+ case XA_ARCHIVE_STORE_SHOW_UP_DIR:
+ XA_ARCHIVE_STORE(object)->props._show_up_dir = g_value_get_boolean(value);
+ break;
+ }
+}
+static void
+xa_archive_store_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+{
+ switch(prop_id)
+ {
+ case XA_ARCHIVE_STORE_SHOW_ICONS:
+ g_value_set_boolean(value, XA_ARCHIVE_STORE(object)->props._show_icons);
+ break;
+ case XA_ARCHIVE_STORE_SHOW_UP_DIR:
+ g_value_set_boolean(value, XA_ARCHIVE_STORE(object)->props._show_up_dir);
+ break;
+ }
+}
+
static GtkTreeModelFlags
xa_archive_store_get_flags(GtkTreeModel *tree_model)
{
@@ -209,7 +268,7 @@
gint index = indices[depth];
- if(&archive->root_entry != entry)
+ if(store->props._show_up_dir && &archive->root_entry != entry)
index--;
if(index == -1)
@@ -248,7 +307,7 @@
// gint pos = lxa_entry_children_index(store->current_entry, iter->user_data);
gint pos = GPOINTER_TO_INT(iter->user_data3);
- if(&archive->root_entry != entry)
+ if(store->props._show_up_dir && &archive->root_entry != entry)
pos++;
GtkTreePath *path = gtk_tree_path_new();
@@ -282,19 +341,19 @@
gpointer props_iter = entry->props;
gint i = 1;
- if(strcmp(entry->filename, "..") == 0)
+ if(column == -1)
{
- if(column == -1)
+ g_value_init(value, G_TYPE_STRING);
+ g_value_set_string(value, (strcmp(entry->filename, ".."))?entry->is_folder?"folder":"unknown":"go-up");
+ }
+ else if(column == 0)
+ {
+ g_value_set_string(value, (strcmp(entry->filename, ".."))?entry->filename:"..");
+ }
+ else
+ {
+ if(!props_iter)
{
- g_value_init(value, G_TYPE_STRING);
- g_value_set_string(value, "go-up");
- }
- else if(column == 0)
- {
- g_value_set_string(value, "..");
- }
- else
- {
switch(archive->column_types[column])
{
case G_TYPE_STRING:
@@ -308,18 +367,6 @@
break;
}
}
- }
- else
- {
- if(column == -1)
- {
- g_value_init(value, G_TYPE_STRING);
- g_value_set_string(value, entry->is_folder?"folder":"unknown");
- }
- else if(column == 0)
- {
- g_value_set_string(value, entry->filename);
- }
else
{
for(;i<column;i++)
@@ -391,7 +438,7 @@
/* only support lists: parent is always NULL */
g_return_val_if_fail(parent == NULL, FALSE);
- if(&archive->root_entry != entry)
+ if(store->props._show_up_dir && &archive->root_entry != entry)
{
entry = &store->up_entry;
iter->user_data3 = GINT_TO_POINTER(-1);
@@ -452,7 +499,7 @@
/* only support lists: parent is always NULL */
g_return_val_if_fail(parent == NULL, FALSE);
- if(&archive->root_entry != entry)
+ if(store->props._show_up_dir && &archive->root_entry != entry)
n--;
if(n == -1)
@@ -482,7 +529,7 @@
GtkTreeModel *
-xa_archive_store_new(LXAArchive *archive, gboolean show_icons)
+xa_archive_store_new(LXAArchive *archive, gboolean show_icons, gboolean show_up_dir)
{
XAArchiveStore *tree_model;
GType *column_types;
@@ -512,6 +559,7 @@
tree_model->column_types = archive->column_types;
*/
tree_model->props._show_icons = show_icons;
+ tree_model->props._show_up_dir = show_up_dir;
xa_archive_store_set_contents(tree_model, archive);
@@ -549,7 +597,7 @@
GtkTreePath *path_ = NULL;
GtkTreeIter iter;
- if(&archive->root_entry != entry)
+ if(store->props._show_up_dir && &archive->root_entry != entry)
{
prev_size++;
index--;
@@ -572,7 +620,7 @@
new_size = lxa_entry_children_length(entry);
- if(&archive->root_entry != entry) {
+ if(store->props._show_up_dir && &archive->root_entry != entry) {
path_ = gtk_tree_path_new();
gtk_tree_path_append_index(path_, 0);
@@ -651,7 +699,7 @@
prev_size = lxa_entry_children_length(entry);
- if(&store->archive->root_entry != entry)
+ if(store->props._show_up_dir && &store->archive->root_entry != entry)
prev_size++;
}
@@ -676,8 +724,6 @@
store->archive = archive;
store->current_entry = g_slist_prepend(NULL, &archive->root_entry);
- store->up_entry.filename = "..";
-
for(i = 0; i < lxa_entry_children_length(&archive->root_entry); i++)
{
path_ = gtk_tree_path_new();
Modified: xarchiver/branches/xarchiver-psybsd/src/archive_store.h
===================================================================
--- xarchiver/branches/xarchiver-psybsd/src/archive_store.h 2006-10-05 22:27:00 UTC (rev 23295)
+++ xarchiver/branches/xarchiver-psybsd/src/archive_store.h 2006-10-06 09:54:42 UTC (rev 23296)
@@ -49,6 +49,7 @@
LXAEntry up_entry;
struct {
gboolean _show_icons;
+ gboolean _show_up_dir;
} props;
};
@@ -63,7 +64,7 @@
GType
xa_archive_store_get_type();
GtkTreeModel *
-xa_archive_store_new(LXAArchive *archive, gboolean show_icons);
+xa_archive_store_new(LXAArchive *archive, gboolean show_icons, gboolean show_up_dir);
void
xa_archive_store_set_contents(XAArchiveStore *archive_store, LXAArchive *archive);
void
Modified: xarchiver/branches/xarchiver-psybsd/src/main_window.c
===================================================================
--- xarchiver/branches/xarchiver-psybsd/src/main_window.c 2006-10-05 22:27:00 UTC (rev 23295)
+++ xarchiver/branches/xarchiver-psybsd/src/main_window.c 2006-10-06 09:54:42 UTC (rev 23296)
@@ -729,7 +729,7 @@
}
column_types[0] = G_TYPE_STRING;
//liststore = gtk_list_store_newv(archive->column_number+1, column_types);
- liststore = xa_archive_store_new(archive, TRUE);
+ liststore = xa_archive_store_new(archive, TRUE, TRUE);
renderer = gtk_cell_renderer_pixbuf_new();
column = gtk_tree_view_column_new_with_attributes("", renderer, "icon-name", 0, NULL);
@@ -754,7 +754,7 @@
} else
{
//liststore = gtk_list_store_newv(archive->column_number, archive->column_types);
- liststore = xa_archive_store_new(archive, FALSE);
+ liststore = xa_archive_store_new(archive, FALSE, TRUE);
for(x = 0; x < archive->column_number; x++)
{
switch(archive->column_types[x])
More information about the Xfce4-commits
mailing list