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

Stephan Arts stephan at xfce.org
Tue Oct 10 15:59:41 UTC 2006


Author: stephan
Date: 2006-10-10 15:59:41 +0000 (Tue, 10 Oct 2006)
New Revision: 23338

Modified:
   xarchiver/branches/xarchiver-psybsd/libxarchiver/archive.c
   xarchiver/branches/xarchiver-psybsd/libxarchiver/archive.h
   xarchiver/branches/xarchiver-psybsd/libxarchiver/slist.c
   xarchiver/branches/xarchiver-psybsd/src/archive_store.c
   xarchiver/branches/xarchiver-psybsd/src/archive_tree_store.c
   xarchiver/branches/xarchiver-psybsd/src/main_window.c
Log:
Fixed stuff


Modified: xarchiver/branches/xarchiver-psybsd/libxarchiver/archive.c
===================================================================
--- xarchiver/branches/xarchiver-psybsd/libxarchiver/archive.c	2006-10-10 13:32:20 UTC (rev 23337)
+++ xarchiver/branches/xarchiver-psybsd/libxarchiver/archive.c	2006-10-10 15:59:41 UTC (rev 23338)
@@ -44,9 +44,12 @@
 lxa_archive_finalize(GObject *object);
 
 void
-lxa_archive_free_entry(LXAEntry *entry, LXAArchive *archive);
+lxa_archive_free_entry(LXAArchive *archive, LXAEntry *entry);
 
+void
+lxa_archive_entry_flush_buffer(LXAArchive *, LXAEntry *entry);
 
+
 gint
 lxa_archive_sort_entry_buffer(LXAEntry *entry1, LXAEntry *entry2)
 {
@@ -113,7 +116,8 @@
 	LXAArchive *archive = LXA_ARCHIVE(object);
 	if(archive->path)
 		g_free(archive->path);
-	lxa_archive_free_entry(&archive->root_entry, archive);
+	g_print("%u\n", sizeof(LXAEntry));
+	lxa_archive_free_entry(archive, &archive->root_entry);
 	switch(archive->status)
 	{
 		case(LXA_ARCHIVESTATUS_IDLE):
@@ -196,7 +200,7 @@
 		{
 			tmp_entry = g_new0(LXAEntry, 1);
 			tmp_entry->filename = g_strdup(path_items[i]);
-			lxa_entry_add_child(parent, tmp_entry);
+			lxa_archive_entry_add_child(archive, parent, tmp_entry);
 			if(path[strlen(path)-1] == '/')
 			{
 				tmp_entry->mime_type = "inode/directory";
@@ -212,7 +216,7 @@
 
 
 void
-lxa_archive_free_entry(LXAEntry *entry, LXAArchive *archive)
+lxa_archive_free_entry(LXAArchive *archive, LXAEntry *entry)
 {
 	gint i = 0; 
 	gpointer props_iter = entry->props;
@@ -223,7 +227,7 @@
 	if(entry->children)
 	{
 		for(i = 1; i <= GPOINTER_TO_INT(*entry->children); i++)
-			lxa_archive_free_entry(entry->children[i], archive);
+			lxa_archive_free_entry(archive, entry->children[i]);
 		g_free(entry->children);
 	}
 
@@ -259,12 +263,12 @@
 
 //TODO: why does this have a return value?
 gboolean
-lxa_entry_add_child(LXAEntry *parent, LXAEntry *child)
+lxa_archive_entry_add_child(LXAArchive *archive, LXAEntry *parent, LXAEntry *child)
 {
 	parent->buffer = lxa_slist_insert_sorted_single(parent->buffer, child);
 
 	if(lxa_slist_length(parent->buffer) == LXA_ENTRY_CHILD_BUFFER_SIZE)
-		lxa_entry_flush_buffer(parent);
+		lxa_archive_entry_flush_buffer(archive, parent);
 }
 
 LXAEntry *
@@ -308,7 +312,7 @@
 }
 
 void
-lxa_entry_flush_buffer(LXAEntry *entry)
+lxa_archive_entry_flush_buffer(LXAArchive *archive, LXAEntry *entry)
 {
 	if(!entry->buffer)
 		return;
@@ -350,7 +354,7 @@
 		}
 		if(!cmp)
 		{
-			/* TODO: F*** (aka merge) */
+			g_critical("THIS SHOULD NOT HAPPEN!!! (the universe has just collapsed)");
 		}
 		else
 		{
@@ -374,16 +378,18 @@
 	g_free(children_old);
 }
 
-guint lxa_entry_children_length(LXAEntry *entry)
+guint
+lxa_entry_children_length(LXAEntry *entry)
 {
 	g_return_val_if_fail(entry, 0);
 	return entry->children?GPOINTER_TO_INT(*entry->children):0 + lxa_slist_length(entry->buffer);
 }
 
-LXAEntry *lxa_entry_children_nth_data(LXAEntry *entry, guint n)
+LXAEntry *
+lxa_entry_children_nth_data(LXAArchive *archive, LXAEntry *entry, guint n)
 {
 	g_return_val_if_fail(entry, NULL);
-	lxa_entry_flush_buffer(entry);
+	lxa_archive_entry_flush_buffer(archive, entry);
 	n++;
 	if(entry->children && n > 0 && n <= GPOINTER_TO_INT(*entry->children))
 		return entry->children[n];

Modified: xarchiver/branches/xarchiver-psybsd/libxarchiver/archive.h
===================================================================
--- xarchiver/branches/xarchiver-psybsd/libxarchiver/archive.h	2006-10-10 13:32:20 UTC (rev 23337)
+++ xarchiver/branches/xarchiver-psybsd/libxarchiver/archive.h	2006-10-10 15:59:41 UTC (rev 23338)
@@ -106,9 +106,8 @@
 GSList            *lxa_archive_get_children(LXAArchive *archive, gchar *path);
 LXAEntry          *lxa_entry_get_child(LXAEntry *, const gchar *);
 gboolean           lxa_entry_add_child(LXAEntry *parent, LXAEntry *child);
-void               lxa_entry_flush_buffer(LXAEntry *entry);
 guint              lxa_entry_children_length(LXAEntry *entry);
-LXAEntry          *lxa_entry_children_nth_data(LXAEntry *entry, guint n);
+LXAEntry          *lxa_entry_children_nth_data(LXAArchive *archive, LXAEntry *entry, guint n);
 //gint               lxa_entry_children_index(LXAEntry *entry, LXAEntry *find);
 
 

Modified: xarchiver/branches/xarchiver-psybsd/libxarchiver/slist.c
===================================================================
--- xarchiver/branches/xarchiver-psybsd/libxarchiver/slist.c	2006-10-10 13:32:20 UTC (rev 23337)
+++ xarchiver/branches/xarchiver-psybsd/libxarchiver/slist.c	2006-10-10 15:59:41 UTC (rev 23338)
@@ -18,7 +18,7 @@
 
 		if(!cmp)
 		{
-			/* TODO: merge same as in flush */
+			g_critical("THIS SHOULD NOT HAPPEN!!! (the universe has just collapsed)");
 			return;
 		}
 		if(cmp < 0)

Modified: xarchiver/branches/xarchiver-psybsd/src/archive_store.c
===================================================================
--- xarchiver/branches/xarchiver-psybsd/src/archive_store.c	2006-10-10 13:32:20 UTC (rev 23337)
+++ xarchiver/branches/xarchiver-psybsd/src/archive_store.c	2006-10-10 15:59:41 UTC (rev 23338)
@@ -337,7 +337,7 @@
 		if(store->sort_list)
 			entry = store->sort_list[index];
 		else
-			entry = lxa_entry_children_nth_data(entry, index);
+			entry = lxa_entry_children_nth_data(archive, entry, index);
 
 		g_return_val_if_fail(entry, FALSE);
 
@@ -478,7 +478,7 @@
 	if(store->sort_list)
 		entry = store->sort_list[pos];
 	else
-		entry = lxa_entry_children_nth_data(entry, pos);
+		entry = lxa_entry_children_nth_data(store->archive, entry, pos);
 
 	if(!entry)
 		return FALSE;
@@ -515,7 +515,7 @@
 		if(store->sort_list)
 			entry = store->sort_list[0];
 		else
-			entry = lxa_entry_children_nth_data(entry, 0);
+			entry = lxa_entry_children_nth_data(archive, entry, 0);
 	
 		g_return_val_if_fail(entry, FALSE);
 	
@@ -580,7 +580,7 @@
 		if(store->sort_list)
 			entry = store->sort_list[n];
 		else
-			entry = lxa_entry_children_nth_data(entry, n);
+			entry = lxa_entry_children_nth_data(archive, entry, n);
 	
 		g_return_val_if_fail(entry, FALSE);
 	}
@@ -746,7 +746,7 @@
 
 	for(i = 0; i < psize; i++)
 	{
-		store->sort_list[i] = lxa_entry_children_nth_data(pentry, i);
+		store->sort_list[i] = lxa_entry_children_nth_data(store->archive, pentry, i);
 	}
 	xa_archive_quicksort(store, 0, psize-1);
 	xa_archive_insertionsort(store, 0, psize-1);
@@ -881,7 +881,7 @@
 		if(store->sort_list)
 			iter.user_data = store->sort_list[i];
 		else
-			iter.user_data = lxa_entry_children_nth_data(&archive->root_entry, i);
+			iter.user_data = lxa_entry_children_nth_data(archive, &archive->root_entry, i);
 		iter.user_data2 = entry;
 		iter.user_data3 = GINT_TO_POINTER(index);
 
@@ -907,8 +907,11 @@
 cb_xa_archive_store_row_activated(GtkTreeView *treeview, GtkTreePath *path, GtkTreeViewColumn *column, gpointer user_data)
 {
 	g_return_if_fail(XA_IS_ARCHIVE_STORE(user_data));	
+	XAArchiveStore *store = XA_ARCHIVE_STORE(user_data);
 
-	XAArchiveStore *store = XA_ARCHIVE_STORE(user_data);
+	g_return_if_fail(store->current_entry);
+
+
 	LXAArchive *archive = store->archive;
 	LXAEntry *entry = store->current_entry->data;
 
@@ -940,7 +943,7 @@
 		if(store->sort_list)
 			entry = store->sort_list[index];
 		else
-			entry = lxa_entry_children_nth_data(entry, index);
+			entry = lxa_entry_children_nth_data(archive, entry, index);
 
 		g_return_if_fail(entry);
 
@@ -1038,7 +1041,7 @@
 		if(store->sort_list)
 			iter.user_data = store->sort_list[i];
 		else
-			iter.user_data = lxa_entry_children_nth_data(&archive->root_entry, i);
+			iter.user_data = lxa_entry_children_nth_data(archive, &archive->root_entry, i);
 		iter.user_data2 = &archive->root_entry;
 		iter.user_data3 = GINT_TO_POINTER(i);
 
@@ -1098,22 +1101,43 @@
 	gchar **buf = NULL;
 	GSList *iter = store->current_entry;
 	gint i = g_slist_length(iter);
+	gchar *lastfile = NULL;
+	gint namelen = 0;
 
 	if(!i)
 		return NULL;
 
-	buf = g_new(gchar*, i+1);
+	if(i==1)
+		i++;
+	
+	buf = g_new(gchar*, i);
+	i--;
 	buf[i] = NULL;
 
-	while(iter)
+	namelen = strlen(((LXAEntry*)iter->data)->filename);
+	lastfile = g_new(gchar, namelen+2);
+	strcpy(lastfile, ((LXAEntry*)iter->data)->filename);
+	if(lastfile[namelen-1] != '/')
 	{
-		--i;
-		buf[i] = ((LXAEntry*)iter->data)->filename;
-		iter = iter->next;
+		lastfile[namelen] = '/';
+		lastfile[namelen+1] = '\0';
 	}
 
+	i--;
+	iter = iter->next;
+	if(iter)
+	{
+		while(iter->next)
+		{
+			--i;
+			buf[i] = ((LXAEntry*)iter->data)->filename;
+			iter = iter->next;
+		}
+	}
+
 	path = g_strjoinv("/", buf);
 
+	g_free(lastfile);
 	g_free(buf);
 
 	return path;

Modified: xarchiver/branches/xarchiver-psybsd/src/archive_tree_store.c
===================================================================
--- xarchiver/branches/xarchiver-psybsd/src/archive_tree_store.c	2006-10-10 13:32:20 UTC (rev 23337)
+++ xarchiver/branches/xarchiver-psybsd/src/archive_tree_store.c	2006-10-10 15:59:41 UTC (rev 23338)
@@ -334,7 +334,7 @@
 		index = indices[i];
 
 		pentry = entry;
-		entry = lxa_entry_children_nth_data(pentry, index);
+		entry = lxa_entry_children_nth_data(archive, pentry, index);
 
 		g_return_val_if_fail(entry, FALSE);
 
@@ -471,7 +471,7 @@
 	gint pos = GPOINTER_TO_INT(iter->user_data3);
 	pos++;
 
-	entry = lxa_entry_children_nth_data(entry, pos);
+	entry = lxa_entry_children_nth_data(store->archive, entry, pos);
 
 	if(!entry)
 		return FALSE;
@@ -538,7 +538,7 @@
 		ppos = GPOINTER_TO_INT(parent->user_data3);
 	}
 
-	entry = lxa_entry_children_nth_data(pentry, n);
+	entry = lxa_entry_children_nth_data(archive, pentry, n);
 
 	g_return_val_if_fail(entry, FALSE);
 
@@ -910,7 +910,7 @@
 	for(i = 0; i < depth; i++)
 	{
 		pentry = entry;
-		entry = lxa_entry_children_nth_data(pentry, indices[i]);
+		entry = lxa_entry_children_nth_data(archive, pentry, indices[i]);
 
 		g_return_if_fail(entry);
 	}
@@ -933,7 +933,7 @@
 		path_ = gtk_tree_path_copy(path);
 		gtk_tree_path_append_index(path_, i);
 
-		entry = lxa_entry_children_nth_data(ptree->entry, i);
+		entry = lxa_entry_children_nth_data(store->archive, ptree->entry, i);
 		iter.stamp = store->stamp;
 		iter.user_data = entry;
 		iter.user_data2 = ptree;

Modified: xarchiver/branches/xarchiver-psybsd/src/main_window.c
===================================================================
--- xarchiver/branches/xarchiver-psybsd/src/main_window.c	2006-10-10 13:32:20 UTC (rev 23337)
+++ xarchiver/branches/xarchiver-psybsd/src/main_window.c	2006-10-10 15:59:41 UTC (rev 23338)
@@ -253,7 +253,7 @@
 
 	g_signal_connect(G_OBJECT(window->toolbar.tool_item_stop), "clicked", G_CALLBACK(cb_xa_main_stop_archive), window);
 
-/*	window->navigationbar = xa_tool_bar_new(NULL);*/
+	/*window->navigationbar = xa_tool_bar_new(NULL);*/
 
 /* main view */
 	window->scrollwindow = gtk_scrolled_window_new(NULL, NULL);
@@ -418,7 +418,10 @@
 void
 cb_xa_main_close_archive(GtkWidget *widget, gpointer userdata)
 {
-	g_object_unref(XA_MAIN_WINDOW(userdata)->lp_xa_archive);
+	XAMainWindow *window = XA_MAIN_WINDOW(userdata);
+	xa_archive_store_set_contents(XA_ARCHIVE_STORE(window->treemodel), NULL);
+	g_object_unref(window->lp_xa_archive);
+	window->lp_xa_archive = NULL;
 }
 
 void



More information about the Xfce4-commits mailing list