[Xfce4-commits] r23355 - in xarchiver/branches/xarchiver-psybsd: libxarchiver src

Stephan Arts stephan at xfce.org
Wed Oct 11 14:18:07 UTC 2006


Author: stephan
Date: 2006-10-11 14:18:05 +0000 (Wed, 11 Oct 2006)
New Revision: 23355

Modified:
   xarchiver/branches/xarchiver-psybsd/libxarchiver/archive.c
   xarchiver/branches/xarchiver-psybsd/src/archive_store.c
Log:
Applied patch from Peter de Ridder <pc.ridder at zonnet.nl>


Modified: xarchiver/branches/xarchiver-psybsd/libxarchiver/archive.c
===================================================================
--- xarchiver/branches/xarchiver-psybsd/libxarchiver/archive.c	2006-10-11 09:46:25 UTC (rev 23354)
+++ xarchiver/branches/xarchiver-psybsd/libxarchiver/archive.c	2006-10-11 14:18:05 UTC (rev 23355)
@@ -45,6 +45,8 @@
 
 void
 lxa_archive_free_entry(LXAArchive *archive, LXAEntry *entry);
+void
+lxa_archive_free_entry_no_free(LXAArchive *archive, LXAEntry *entry);
 
 void
 lxa_archive_entry_flush_buffer(LXAArchive *, LXAEntry *entry);
@@ -116,7 +118,7 @@
 	LXAArchive *archive = LXA_ARCHIVE(object);
 	if(archive->path)
 		g_free(archive->path);
-	lxa_archive_free_entry(archive, &archive->root_entry);
+	lxa_archive_free_entry_no_free(archive, &archive->root_entry);
 	switch(archive->status)
 	{
 		case(LXA_ARCHIVESTATUS_IDLE):
@@ -213,21 +215,34 @@
 	return tmp_entry;
 }
 
-
 void
 lxa_archive_free_entry(LXAArchive *archive, LXAEntry *entry)
 {
+	lxa_archive_free_entry_no_free(archive, entry);
+	g_free(entry);
+}
+
+void
+lxa_archive_free_entry_no_free(LXAArchive *archive, LXAEntry *entry)
+{
 	gint i = 0; 
 	gpointer props_iter = entry->props;
+	LXASList *buffer_iter = entry->buffer;
 
+	for(; buffer_iter; buffer_iter = buffer_iter->next)
+	{
+		lxa_archive_free_entry(archive, buffer_iter->entry);
+	}
 	lxa_slist_free(entry->buffer);
 	entry->buffer = NULL;
 
 	if(entry->children)
 	{
+		/* first elemant of the array (*entry->children) contains the size of the array */
 		for(i = 1; i <= GPOINTER_TO_INT(*entry->children); i++)
 			lxa_archive_free_entry(archive, entry->children[i]);
 		g_free(entry->children);
+		entry->children = NULL;
 	}
 
 	if(entry->props)
@@ -274,10 +289,12 @@
 lxa_entry_get_child(LXAEntry *entry, const gchar *filename)
 {
 	LXASList *buffer_iter = NULL;
+	/* the first element of the array (*entry->children) contains the size of the array */
 	guint size = entry->children?GPOINTER_TO_INT(*entry->children):0;
 	guint pos = 0;
 	guint begin = 1;
 	gint cmp = 0;
+	/* binary search algoritme */
 	while(size)
 	{
 		pos = (size / 2);
@@ -297,6 +314,7 @@
 		}
 	}
 
+	/* search the buffer */
 	for(buffer_iter = entry->buffer; buffer_iter; buffer_iter = buffer_iter->next)
 	{
 		cmp = strcmp(filename, buffer_iter->entry->filename);
@@ -322,6 +340,7 @@
 	gint cmp = 1;
 	guint old_i = 1;
 	guint new_i = 1;
+	/* the first element of the array (*entry->children) contains the size of the array */
 	guint size = entry->children?GPOINTER_TO_INT(*entry->children):0;
 	gint n_children = size;
 	LXASList *buffer_iter = NULL;
@@ -333,6 +352,7 @@
 	for(buffer_iter = entry->buffer;buffer_iter;buffer_iter = buffer_iter->next)
 	{
 		size = n_children + 1 - begin;
+		/* binary search algoritme */
 		while(size)
 		{
 			pos = (size / 2);
@@ -369,6 +389,7 @@
 		entry->children[new_i++] = children_old[old_i++];
 	}
 	n_children = new_i - 1;
+	/* the first element of the array (*entry->children) contains the size of the array */
 	*entry->children = GINT_TO_POINTER(n_children);
 	
 	lxa_slist_free(entry->buffer);
@@ -381,6 +402,7 @@
 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);
 }
 
@@ -390,6 +412,7 @@
 	g_return_val_if_fail(entry, 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

Modified: xarchiver/branches/xarchiver-psybsd/src/archive_store.c
===================================================================
--- xarchiver/branches/xarchiver-psybsd/src/archive_store.c	2006-10-11 09:46:25 UTC (rev 23354)
+++ xarchiver/branches/xarchiver-psybsd/src/archive_store.c	2006-10-11 14:18:05 UTC (rev 23355)
@@ -234,13 +234,26 @@
 static void
 xa_archive_store_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
 {
+	gint prev_size = 0;
 	switch(prop_id)
 	{
 		case XA_ARCHIVE_STORE_SHOW_ICONS:
-			XA_ARCHIVE_STORE(object)->props._show_icons = g_value_get_boolean(value);
+			if(XA_ARCHIVE_STORE(object)->props._show_icons != g_value_get_boolean(value))
+			{
+				if(XA_ARCHIVE_STORE(object)->current_entry)
+					prev_size = lxa_entry_children_length(((LXAEntry*)XA_ARCHIVE_STORE(object)->current_entry->data));
+				XA_ARCHIVE_STORE(object)->props._show_icons = g_value_get_boolean(value);
+				xa_archive_store_refresh(XA_ARCHIVE_STORE(object), prev_size);
+			}
 			break;
 		case XA_ARCHIVE_STORE_SHOW_UP_DIR:
-			XA_ARCHIVE_STORE(object)->props._show_up_dir = g_value_get_boolean(value);
+			if(XA_ARCHIVE_STORE(object)->props._show_up_dir != g_value_get_boolean(value))
+			{
+				if(XA_ARCHIVE_STORE(object)->current_entry)
+					prev_size = lxa_entry_children_length(((LXAEntry*)XA_ARCHIVE_STORE(object)->current_entry->data));
+				XA_ARCHIVE_STORE(object)->props._show_up_dir = g_value_get_boolean(value);
+				xa_archive_store_refresh(XA_ARCHIVE_STORE(object), prev_size);
+			}
 			break;
 	}
 }
@@ -312,10 +325,10 @@
 	LXAEntry *entry = NULL;
 	if(!store->current_entry)
 		return FALSE;
-	else
-		entry = store->current_entry->data;
 
+	entry = store->current_entry->data;
 
+
 	gint *indices = gtk_tree_path_get_indices(path);
 	gint depth = gtk_tree_path_get_depth(path) - 1;
 
@@ -1000,6 +1013,8 @@
 	LXAEntry *entry = NULL;
 	gint prev_size =  0;
 
+	g_free(store->sort_list);
+
 	if(store->current_entry)
 	{
 		entry = store->current_entry->data;
@@ -1054,46 +1069,7 @@
 
 	g_signal_emit(store, xa_archive_store_signals[0], 0,NULL);
 }
-/*
-gchar *
-xa_archive_store_get_pwd(XAArchiveStore *store)
-{
-	g_return_val_if_fail(store, NULL);
 
-	gint size = 0;
-	gint csize = 0;
-	gchar *path = NULL;
-	gchar *buf = NULL;
-	GSList *iter = store->current_entry;
-
-	while(iter)
-	{
-		size += strlen(((LXAEntry*)iter->data)->filename) + 1;
-		iter = iter->next;
-	}
-
-	if(size)
-	{
-		path = g_new(gchar, size + 1);
-		buf = g_new(gchar, size + 1);
-		path[0] = '\0';
-
-		iter = store->current_entry;
-
-		while(iter)
-		{
-			g_strlcpy(buf, path, size);
-			g_strlcpy(path, ((LXAEntry*)iter->data)->filename, size);
-			csize = g_strlcat(path, buf, size);
-			path[csize] = '/';
-			path[csize+1] = '\0';
-			iter = iter->next;
-		}
-	}
-	g_free(buf);
-	return path;
-}
-*/
 gchar *
 xa_archive_store_get_pwd(XAArchiveStore *store)
 {
@@ -1109,8 +1085,7 @@
 	if(!i)
 		return NULL;
 
-//	if(i==1)
-		i++;
+	i++;
 	
 	buf = g_new(gchar*, i);
 	buf[0] = "";



More information about the Xfce4-commits mailing list