[Xfce4-commits] r23154 - in xarchiver/branches/xarchiver-psybsd: libxarchiver src
Stephan Arts
stephan at xfce.org
Thu Sep 14 11:28:44 UTC 2006
Author: stephan
Date: 2006-09-14 11:28:44 +0000 (Thu, 14 Sep 2006)
New Revision: 23154
Modified:
xarchiver/branches/xarchiver-psybsd/libxarchiver/archive.c
xarchiver/branches/xarchiver-psybsd/libxarchiver/archive.h
xarchiver/branches/xarchiver-psybsd/src/main.h
xarchiver/branches/xarchiver-psybsd/src/main_window.c
xarchiver/branches/xarchiver-psybsd/src/main_window.h
Log:
archive navigation works :)
Modified: xarchiver/branches/xarchiver-psybsd/libxarchiver/archive.c
===================================================================
--- xarchiver/branches/xarchiver-psybsd/libxarchiver/archive.c 2006-09-14 10:02:11 UTC (rev 23153)
+++ xarchiver/branches/xarchiver-psybsd/libxarchiver/archive.c 2006-09-14 11:28:44 UTC (rev 23154)
@@ -89,6 +89,9 @@
static void
lxa_archive_init(LXAArchive *archive)
{
+ archive->root_entry.filename = g_new0(GValue, 1);
+ archive->root_entry.filename = g_value_init(archive->root_entry.filename, G_TYPE_STRING);
+ g_value_set_string(archive->root_entry.filename, "/");
}
static void
@@ -97,6 +100,7 @@
LXAArchive *archive = LXA_ARCHIVE(object);
if(archive->path)
g_free(archive->path);
+ g_free(archive->root_entry.filename);
}
LXAArchive *
@@ -159,15 +163,15 @@
gchar **path_items;
LXAEntry *tmp_entry = NULL;
path_items = g_strsplit_set(path, "/\n", -1);
- tmp_list = g_slist_find_custom(archive->root_entries, path_items[0], (GCompareFunc)lxa_archive_lookup_dir);
+ tmp_list = g_slist_find_custom(archive->root_entry.children, path_items[0], (GCompareFunc)lxa_archive_lookup_dir);
if(!tmp_list)
{
tmp_entry = g_new0(LXAEntry, 1);
tmp_entry->filename = g_new0(GValue, 1);
tmp_entry->filename = g_value_init(tmp_entry->filename, G_TYPE_STRING);
g_value_set_string(tmp_entry->filename, path_items[0]);
- archive->root_entries = g_slist_prepend(archive->root_entries, tmp_entry);
- tmp_list = archive->root_entries;
+ archive->root_entry.children = g_slist_prepend(archive->root_entry.children, tmp_entry);
+ tmp_list = archive->root_entry.children;
}
for(i = 1; path_items[i]?strlen(path_items[i]):0;i++)
{
@@ -175,7 +179,7 @@
if(!tmp_list_children)
{
tmp_entry = g_new0(LXAEntry, 1);
- tmp_entry->filename = g_new0(GValue, 1);
+ tmp_entry->filename = g_new0(GValue, 1);
tmp_entry->filename = g_value_init(tmp_entry->filename, G_TYPE_STRING);
g_value_set_string(tmp_entry->filename, path_items[i]);
((LXAEntry *)tmp_list->data)->children = g_slist_prepend(((LXAEntry *)tmp_list->data)->children, tmp_entry);
@@ -187,22 +191,9 @@
return tmp_entry;
}
-/* FIXME: ***HACK*** ***HACK*** */
-GSList *
-lxa_archive_get_children(LXAArchive *archive, gchar *path)
+LXAEntry *
+lxa_entry_get_child(LXAEntry *entry, const gchar *filename)
{
- gint i = 0;
- GSList *tmp_list = archive->root_entries;
- if(path[0] == '/')
- i++;
- gchar **path_items = g_strsplit_set(&path[i], "/\n", -1);
- for(i = 0; path_items[i]?strlen(path_items[i]):0; i++)
- {
- tmp_list = g_slist_find_custom(tmp_list, path_items[i], (GCompareFunc)lxa_archive_lookup_dir);
- if(!tmp_list)
- break;
- tmp_list = ((LXAEntry *)tmp_list->data)->children;
- }
- g_strfreev(path_items);
- return tmp_list;
+ GSList *list = g_slist_find_custom(entry->children, filename,(GCompareFunc)lxa_archive_lookup_dir);
+ return (LXAEntry *)list->data;
}
Modified: xarchiver/branches/xarchiver-psybsd/libxarchiver/archive.h
===================================================================
--- xarchiver/branches/xarchiver-psybsd/libxarchiver/archive.h 2006-09-14 10:02:11 UTC (rev 23153)
+++ xarchiver/branches/xarchiver-psybsd/libxarchiver/archive.h 2006-09-14 11:28:44 UTC (rev 23154)
@@ -69,13 +69,13 @@
LXAArchiveStatus old_status;
GPid child_pid;
gpointer support;
- GSList *root_entries;
gchar *tmp_file;
gchar *files;
gboolean has_passwd;
gint column_number;
GType *column_types;
gchar **column_names;
+ LXAEntry root_entry;
};
typedef struct _LXAArchiveClass LXAArchiveClass;
@@ -93,6 +93,7 @@
gint lxa_archive_lookup_dir(gpointer entry, gconstpointer filename);
LXAEntry *lxa_archive_add_file(LXAArchive *archive, gchar *path);
GSList *lxa_archive_get_children(LXAArchive *archive, gchar *path);
+LXAEntry *lxa_entry_get_child(LXAEntry *, const gchar *);
G_END_DECLS
Modified: xarchiver/branches/xarchiver-psybsd/src/main.h
===================================================================
--- xarchiver/branches/xarchiver-psybsd/src/main.h 2006-09-14 10:02:11 UTC (rev 23153)
+++ xarchiver/branches/xarchiver-psybsd/src/main.h 2006-09-14 11:28:44 UTC (rev 23154)
@@ -1,2 +1 @@
static LXAArchive *lp_xa_archive = NULL;
-
Modified: xarchiver/branches/xarchiver-psybsd/src/main_window.c
===================================================================
--- xarchiver/branches/xarchiver-psybsd/src/main_window.c 2006-09-14 10:02:11 UTC (rev 23153)
+++ xarchiver/branches/xarchiver-psybsd/src/main_window.c 2006-09-14 11:28:44 UTC (rev 23154)
@@ -17,6 +17,7 @@
*/
#include <config.h>
+#include <string.h>
#include <glib.h>
#include <gtk/gtk.h>
#include <libxarchiver/libxarchiver.h>
@@ -34,6 +35,9 @@
void
cb_xa_main_item_activated(GtkTreeView *treeview, GtkTreePath *treepath, GtkTreeViewColumn *column, gpointer userdata);
+void
+xa_main_window_set_contents(XAMainWindow *, LXAArchive *, GSList *);
+
GType
xa_main_window_get_type ()
{
@@ -75,7 +79,10 @@
GtkWidget *tmp_image;
GtkAccelGroup *accel_group = gtk_accel_group_new();
- window->working_dir = NULL;
+ 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, "..");
gtk_window_set_default_icon_from_file(DATADIR "/pixmaps/xarchiver.png", NULL);
main_vbox = gtk_vbox_new(FALSE, 0);
@@ -352,8 +359,8 @@
gtk_tree_view_append_column(GTK_TREE_VIEW(main_window->treeview), column);
}
gtk_tree_view_set_model(GTK_TREE_VIEW(main_window->treeview), GTK_TREE_MODEL(liststore));
- GSList *items = lxa_archive_get_children(archive, "");
- xa_main_window_set_contents(main_window, archive, items, "");
+ main_window->working_node = g_slist_prepend(main_window->working_node, &(archive->root_entry));
+ xa_main_window_set_contents(main_window, archive, archive->root_entry.children);
}
}
@@ -364,21 +371,24 @@
}
void
-xa_main_window_set_contents(XAMainWindow *main_window, LXAArchive *archive, GSList *items, gchar *path)
+xa_main_window_set_contents(XAMainWindow *main_window, LXAArchive *archive, GSList *items)
{
GtkTreeIter iter;
GtkTreeModel *liststore = gtk_tree_view_get_model(GTK_TREE_VIEW(main_window->treeview));
gtk_list_store_clear(GTK_LIST_STORE(liststore));
- main_window->working_dir = path;
-
while(items)
{
gtk_list_store_append(GTK_LIST_STORE(liststore), &iter);
gtk_list_store_set_value(GTK_LIST_STORE(liststore), &iter, 0, ((LXAEntry *)items->data)->filename);
items = items->next;
}
+ if(g_slist_length(main_window->working_node) > 1)
+ {
+ gtk_list_store_prepend(GTK_LIST_STORE(liststore), &iter);
+ gtk_list_store_set_value(GTK_LIST_STORE(liststore), &iter, 0, main_window->parent_node);
+ }
gtk_tree_view_set_model(GTK_TREE_VIEW(main_window->treeview), GTK_TREE_MODEL(liststore));
}
@@ -386,6 +396,7 @@
cb_xa_main_item_activated(GtkTreeView *treeview, GtkTreePath *treepath, GtkTreeViewColumn *column, gpointer userdata)
{
GtkTreeIter iter;
+ GSList *items = NULL;
GValue *value = g_new0(GValue, 1);
XAMainWindow *main_window = userdata;
@@ -394,13 +405,25 @@
gtk_tree_model_get_iter(tree_model, &iter, treepath);
gtk_tree_model_get_value(tree_model, &iter, 0, value);
- gchar *path = g_strconcat(main_window->working_dir, "/", g_value_get_string(value), NULL);
+ const gchar *item_filename = g_value_get_string(value);
+ if(!strcmp(item_filename, "..")) /* pop */
+ {
+ main_window->working_node = g_slist_delete_link(main_window->working_node, main_window->working_node);
+ }
+ else
+ {
+ LXAEntry *entry = lxa_entry_get_child(((LXAEntry *)main_window->working_node->data), item_filename);
+ if(g_slist_length(entry->children))
+ {
+ main_window->working_node = g_slist_prepend(main_window->working_node, entry);
+ }
+ else
+ { }
+ }
+ items = ((LXAEntry *)main_window->working_node->data)->children;
- g_debug("%s\n", path);
-
- GSList *items = lxa_archive_get_children(lp_xa_archive, path);
if(items)
- xa_main_window_set_contents(main_window, lp_xa_archive, items, path);
+ xa_main_window_set_contents(main_window, lp_xa_archive, items);
/* else*/
/* 'view' */
Modified: xarchiver/branches/xarchiver-psybsd/src/main_window.h
===================================================================
--- xarchiver/branches/xarchiver-psybsd/src/main_window.h 2006-09-14 10:02:11 UTC (rev 23153)
+++ xarchiver/branches/xarchiver-psybsd/src/main_window.h 2006-09-14 11:28:44 UTC (rev 23154)
@@ -88,7 +88,8 @@
GtkToolItem *tool_item_extract;
GtkToolItem *tool_item_remove;
} toolbar;
- gchar *working_dir;
+ GValue *parent_node;
+ GSList *working_node;
};
typedef struct _XAMainWindowClass XAMainWindowClass;
@@ -106,7 +107,6 @@
void cb_xa_main_extract_archive(GtkWidget *widget, gpointer userdata);
void xa_main_window_archive_status_changed(LXAArchive *archive, gpointer userdata);
-void xa_main_window_set_contents(XAMainWindow *, LXAArchive *, GSList *, gchar *);
G_END_DECLS
#endif /* __XARCHIVER_MAIN_WINDOW_H__ */
More information about the Xfce4-commits
mailing list