Author: peter
Date: 2006-11-14 22:41:35 +0000 (Tue, 14 Nov 2006)
New Revision: 23882

Modified:
   xarchiver/branches/xarchiver-psybsd/TODO
   xarchiver/branches/xarchiver-psybsd/libxarchiver/archive.c
   xarchiver/branches/xarchiver-psybsd/libxarchiver/archive.h
   xarchiver/branches/xarchiver-psybsd/src/archive_store.c
   xarchiver/branches/xarchiver-psybsd/src/archive_store.h
   xarchiver/branches/xarchiver-psybsd/src/tool_bar.c
Log:
The archive_store checks the archive status



Modified: xarchiver/branches/xarchiver-psybsd/TODO
===================================================================
--- xarchiver/branches/xarchiver-psybsd/TODO    2006-11-14 21:44:38 UTC (rev 
23881)
+++ xarchiver/branches/xarchiver-psybsd/TODO    2006-11-14 22:41:35 UTC (rev 
23882)
@@ -40,4 +40,10 @@
 
   Implement multi-threading (for libarchive support)
 
+       In archive store, on delete in parent dir of current entry, check if 
map still exists, if not move to the ancestor that still exists
+
+       Save trailing folders for path_bar
+
+       In treeview, when going to up dir, select the dir you came from
+
   ... Complete TODO-file

Modified: xarchiver/branches/xarchiver-psybsd/libxarchiver/archive.c
===================================================================
--- xarchiver/branches/xarchiver-psybsd/libxarchiver/archive.c  2006-11-14 
21:44:38 UTC (rev 23881)
+++ xarchiver/branches/xarchiver-psybsd/libxarchiver/archive.c  2006-11-14 
22:41:35 UTC (rev 23882)
@@ -189,6 +189,8 @@
 lxa_archive_init(LXAArchive *archive)
 {
        archive->root_entry = LXA_NEW0(LXAEntry, 1);
+       archive->status = LXA_ARCHIVESTATUS_INIT;
+       archive->old_status = LXA_ARCHIVESTATUS_INIT;
 #ifdef LXA_THREADSAFE
        g_static_rw_lock_init(&archive->rw_lock);
 #endif /* LXA_THREADSAFE */

Modified: xarchiver/branches/xarchiver-psybsd/libxarchiver/archive.h
===================================================================
--- xarchiver/branches/xarchiver-psybsd/libxarchiver/archive.h  2006-11-14 
21:44:38 UTC (rev 23881)
+++ xarchiver/branches/xarchiver-psybsd/libxarchiver/archive.h  2006-11-14 
22:41:35 UTC (rev 23882)
@@ -21,8 +21,8 @@
 
 typedef enum
 {
-       LXA_ARCHIVESTATUS_IDLE = 0,
-       LXA_ARCHIVESTATUS_INIT,
+       LXA_ARCHIVESTATUS_INIT = 0,
+       LXA_ARCHIVESTATUS_IDLE,
        LXA_ARCHIVESTATUS_ADD,
        LXA_ARCHIVESTATUS_EXTRACT,
        LXA_ARCHIVESTATUS_REMOVE,

Modified: xarchiver/branches/xarchiver-psybsd/src/archive_store.c
===================================================================
--- xarchiver/branches/xarchiver-psybsd/src/archive_store.c     2006-11-14 
21:44:38 UTC (rev 23881)
+++ xarchiver/branches/xarchiver-psybsd/src/archive_store.c     2006-11-14 
22:41:35 UTC (rev 23882)
@@ -90,7 +90,7 @@
 static gboolean
 xa_archive_store_iter_parent (GtkTreeModel *tree_model, GtkTreeIter *iter, 
GtkTreeIter *child);
 static void
-xa_archive_store_refresh(XAArchiveStore *store, gint prev_size);
+xa_archive_store_refresh(XAArchiveStore *store);
 
 static void
 xa_archive_store_file_activated(XAArchiveStore *store, GtkTreePath *path);
@@ -123,6 +123,9 @@
 static void
 xa_archive_store_append_history(XAArchiveStore *store, GSList *entry);
 
+static void
+cb_xa_archive_store_archive_refreshed(LXAArchive *archive, gpointer user_data);
+
 GType
 xa_archive_store_get_type()
 {
@@ -202,13 +205,16 @@
 {
        as->stamp = g_random_int();
        as->archive = NULL;
+       as->support = NULL;
+       as->sort_column = GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID;
+       as->sort_order = GTK_SORT_ASCENDING;
+       as->sort_list = NULL;
+       as->list_size = 0;
+       as->icon_theme = NULL;
        as->props._show_icons = 0;
        as->props._show_up_dir = 1;
        as->props._sort_folders_first = 1;
        as->props._sort_case_sensitive = 1;
-       as->sort_column = GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID;
-       as->sort_order = GTK_SORT_ASCENDING;
-       as->sort_list = NULL;
        as->navigation.history = NULL;
        as->navigation.present = NULL;
        as->navigation.maxhistory = XA_ARCHIVE_STORE_MAX_HISTORY;
@@ -283,42 +289,37 @@
 static void
 xa_archive_store_set_property(GObject *object, guint prop_id, const GValue 
*value, GParamSpec *pspec)
 {
-       gint prev_size = 0;
        XAArchiveStore *store = XA_ARCHIVE_STORE(object);
        switch(prop_id)
        {
                case XA_ARCHIVE_STORE_SHOW_ICONS:
-                       if(XA_ARCHIVE_STORE(object)->props._show_icons != 
g_value_get_boolean(value)?1:0)
+                       if(store->props._show_icons != 
g_value_get_boolean(value)?1:0)
                        {
-                               if(store->navigation.present)
-                                       prev_size = 
lxa_archive_iter_n_children(store->archive, 
(LXAArchiveIter*)((GSList*)store->navigation.present->data)->data);
-                               XA_ARCHIVE_STORE(object)->props._show_icons = 
g_value_get_boolean(value)?1:0;
-                               
xa_archive_store_refresh(XA_ARCHIVE_STORE(object), prev_size);
+                               store->props._show_icons = 
g_value_get_boolean(value)?1:0;
+                               xa_archive_store_refresh(store);
                        }
                        break;
                case XA_ARCHIVE_STORE_SHOW_UP_DIR:
-                       if(XA_ARCHIVE_STORE(object)->props._show_up_dir != 
g_value_get_boolean(value)?1:0)
+                       if(store->props._show_up_dir != 
g_value_get_boolean(value)?1:0)
                        {
-                               if(store->navigation.present)
-                                       prev_size = 
lxa_archive_iter_n_children(store->archive, 
(LXAArchiveIter*)((GSList*)store->navigation.present->data)->data);
-                               XA_ARCHIVE_STORE(object)->props._show_up_dir = 
g_value_get_boolean(value)?1:0;
-                               
xa_archive_store_refresh(XA_ARCHIVE_STORE(object), prev_size);
+                               store->props._show_up_dir = 
g_value_get_boolean(value)?1:0;
+                               xa_archive_store_refresh(store);
                        }
                        break;
                case XA_ARCHIVE_STORE_SORT_FOLDERS_FIRST:
-                       if(XA_ARCHIVE_STORE(object)->props._sort_folders_first 
!= g_value_get_boolean(value)?1:0)
+                       if(store->props._sort_folders_first != 
g_value_get_boolean(value)?1:0)
                        {
-                               
XA_ARCHIVE_STORE(object)->props._sort_folders_first = 
g_value_get_boolean(value)?1:0;
-                               if(XA_ARCHIVE_STORE(object)->sort_column < 0)
-                                       XA_ARCHIVE_STORE(object)->sort_column = 
1;
-                               xa_archive_store_sort(XA_ARCHIVE_STORE(object));
+                               store->props._sort_folders_first = 
g_value_get_boolean(value)?1:0;
+                               if(store->sort_column < 0)
+                                       store->sort_column = 1;
+                               xa_archive_store_sort(store);
                        }
                        break;
                case XA_ARCHIVE_STORE_SORT_CASE_SENSITIVE:
-                       if(XA_ARCHIVE_STORE(object)->props._sort_case_sensitive 
!= g_value_get_boolean(value)?1:0)
+                       if(store->props._sort_case_sensitive != 
g_value_get_boolean(value)?1:0)
                        {
-                               
XA_ARCHIVE_STORE(object)->props._sort_case_sensitive = 
g_value_get_boolean(value)?1:0;
-                               xa_archive_store_sort(XA_ARCHIVE_STORE(object));
+                               store->props._sort_case_sensitive = 
g_value_get_boolean(value)?1:0;
+                               xa_archive_store_sort(store);
                        }
                        break;
        }
@@ -394,16 +395,20 @@
 static gboolean
 xa_archive_store_get_iter(GtkTreeModel *tree_model, GtkTreeIter *iter, 
GtkTreePath *path)
 {
+#ifdef DEBUG
        g_return_val_if_fail(XA_IS_ARCHIVE_STORE(tree_model), FALSE);   
+#endif
 
        XAArchiveStore *store = XA_ARCHIVE_STORE(tree_model);
        LXAArchive *archive = store->archive;
 
-       LXAArchiveIter *entry = NULL;
        if(!store->navigation.present)
                return FALSE;
+#ifdef DEBUG
+       g_return_val_if_fail(store->navigation.present->data, FALSE);
+#endif
 
-       entry = ((GSList*)store->navigation.present->data)->data;
+       LXAArchiveIter *entry = 
((GSList*)store->navigation.present->data)->data;
 
 
        gint *indices = gtk_tree_path_get_indices(path);
@@ -428,8 +433,8 @@
                        entry = store->sort_list[index];
                else
                        entry = lxa_archive_iter_nth_child(archive, entry, 
index);
+
                g_return_val_if_fail(entry, FALSE);
-
        }
 
        iter->stamp = store->stamp;
@@ -547,14 +552,24 @@
 static gboolean
 xa_archive_store_iter_children (GtkTreeModel *tree_model, GtkTreeIter *iter, 
GtkTreeIter *parent)
 {
+#ifdef DEBUG
        g_return_val_if_fail(XA_IS_ARCHIVE_STORE(tree_model), FALSE);
+#endif
 
        XAArchiveStore *store = XA_ARCHIVE_STORE(tree_model);
        LXAArchive *archive = store->archive;
+
+#ifdef DEBUG
+       g_return_val_if_fail(store->navigation.present, FALSE);
+       g_return_val_if_fail(store->navigation.present->data, FALSE);
+#endif
+
        LXAArchiveIter *entry = 
((GSList*)store->navigation.present->data)->data;
 
+#ifdef DEBUG
        g_return_val_if_fail(archive, FALSE);
        g_return_val_if_fail(entry, FALSE);
+#endif
 
        /* only support lists: parent is always NULL */
        g_return_val_if_fail(parent == NULL, FALSE);
@@ -592,14 +607,24 @@
 static gint
 xa_archive_store_iter_n_children (GtkTreeModel *tree_model, GtkTreeIter *iter)
 {
+#ifdef DEBUG
        g_return_val_if_fail(XA_IS_ARCHIVE_STORE(tree_model), 0);
+#endif
 
        XAArchiveStore *store = XA_ARCHIVE_STORE(tree_model);
        LXAArchive *archive = store->archive;
+
+#ifdef DEBUG
+       g_return_val_if_fail(store->navigation.present, 0);
+       g_return_val_if_fail(store->navigation.present->data, 0);
+#endif
+
        LXAArchiveIter *entry = 
((GSList*)store->navigation.present->data)->data;
 
+#ifdef DEBUG
        g_return_val_if_fail(archive, 0);
        g_return_val_if_fail(entry, 0);
+#endif
 
        /* only support lists: iter is always NULL */
        g_return_val_if_fail(iter == NULL, FALSE);
@@ -610,15 +635,25 @@
 static gboolean 
 xa_archive_store_iter_nth_child (GtkTreeModel *tree_model, GtkTreeIter *iter, 
GtkTreeIter *parent, gint n)
 {
+#ifdef DEBUG
        g_return_val_if_fail(XA_IS_ARCHIVE_STORE(tree_model), FALSE);
+#endif
 
        XAArchiveStore *store = XA_ARCHIVE_STORE(tree_model);
        LXAArchive *archive = store->archive;
+
+#ifdef DEBUG
+       g_return_val_if_fail(store->navigation.present, FALSE);
+       g_return_val_if_fail(store->navigation.present->data, FALSE);
+#endif
+
        LXAArchiveIter *entry = 
((GSList*)store->navigation.present->data)->data;
 
+#ifdef DEBUG
        g_return_val_if_fail(archive, FALSE);
        g_return_val_if_fail(entry, FALSE);
        g_return_val_if_fail(iter, FALSE);
+#endif
 
        /* only support lists: parent is always NULL */
        g_return_val_if_fail(parent == NULL, FALSE);
@@ -792,6 +827,11 @@
        if(store->sort_column < 0)
                return;
 
+#ifdef DEBUG
+       g_return_if_fail(store->navigation.present);
+       g_return_if_fail(store->navigation.present->data);
+#endif
+
        LXAArchiveIter *pentry = 
(LXAArchiveIter*)((GSList*)store->navigation.present->data)->data;
        gint psize = lxa_archive_iter_n_children(store->archive, pentry);
        gint i = 0;
@@ -898,9 +938,16 @@
 }
 
 static void
-xa_archive_store_refresh(XAArchiveStore *store, gint prev_size)
+xa_archive_store_refresh(XAArchiveStore *store)
 {
+       guint prev_size = store->list_size;
        LXAArchive *archive = store->archive;
+
+#ifdef DEBUG
+       g_return_if_fail(store->navigation.present);
+       g_return_if_fail(store->navigation.present->data);
+#endif
+
        LXAArchiveIter *entry = 
((GSList*)store->navigation.present->data)->data;
 
        g_return_if_fail(archive);
@@ -950,6 +997,7 @@
 
                gtk_tree_path_free(path_);
        }
+
        for(index = prev_size - 1; index >= i; index--)
        {
                path_ = gtk_tree_path_new();
@@ -959,6 +1007,11 @@
 
                gtk_tree_path_free(path_);
        }
+
+       if(store->props._show_up_dir && lxa_archive_get_iter(archive, NULL) != 
entry)
+               new_size++;
+
+       store->list_size = new_size;
 }
 
 static void
@@ -970,6 +1023,7 @@
 static void
 xa_archive_store_file_activated(XAArchiveStore *store, GtkTreePath *path)
 {
+       g_return_if_fail(store->navigation.present);
        g_return_if_fail(store->navigation.present->data);
 
        LXAArchive *archive = store->archive;
@@ -984,16 +1038,12 @@
        /* only support list: depth is always 0 */
        g_return_if_fail(depth == 0);
 
-       gint prev_size = lxa_archive_iter_n_children(archive, entry);
        gint index = indices[depth];
 
        GSList *current_entry = store->navigation.present->data;
 
        if(store->props._show_up_dir && lxa_archive_get_iter(archive, NULL) != 
entry)
-       {
-               prev_size++;
                index--;
-       }
 
        if(index == -1)
        {
@@ -1025,7 +1075,7 @@
 
        xa_archive_store_sort(store);
 
-       xa_archive_store_refresh(store, prev_size);
+       xa_archive_store_refresh(store);
        g_signal_emit(store, 
xa_archive_store_signals[XA_ARCHIVE_STORE_SIGNAL_PWD_CHANGED], 0,NULL);
 }
 
@@ -1033,20 +1083,19 @@
 xa_archive_store_go_up(XAArchiveStore *store)
 {
        LXAArchive *archive = store->archive;
+
+#ifdef DEBUG
+       g_return_if_fail(store->navigation.present);
+       g_return_if_fail(store->navigation.present->data);
+#endif
+
        LXAArchiveIter *entry = 
((GSList*)store->navigation.present->data)->data;
 
        g_return_if_fail(archive);
        g_return_if_fail(entry);
 
-       gint prev_size = lxa_archive_iter_n_children(archive, entry);
-
        GSList *current_entry = store->navigation.present->data;
 
-       if(store->props._show_up_dir && lxa_archive_get_iter(archive, NULL) != 
entry)
-       {
-               prev_size++;
-       }
-
        g_return_if_fail(((GSList*)store->navigation.present->data)->next);
 
        current_entry = g_slist_copy(current_entry->next);
@@ -1054,7 +1103,7 @@
 
        xa_archive_store_sort(store);
 
-       xa_archive_store_refresh(store, prev_size);
+       xa_archive_store_refresh(store);
        g_signal_emit(store, 
xa_archive_store_signals[XA_ARCHIVE_STORE_SIGNAL_PWD_CHANGED], 0,NULL);
 }
 
@@ -1069,9 +1118,8 @@
        LXAArchiveIter *entry = NULL;
        gint prev_size =  0;
        GList *list_iter;
+       GSList *current_entry;
 
-       GSList *current_entry = store->navigation.present->data;
-
        if(store->sort_list)
        {
                g_free(store->sort_list);
@@ -1097,8 +1145,13 @@
                gtk_tree_path_free(path_);
        }
 
+       store->list_size = 0;
+
        if(store->archive)
+       {
+               g_signal_handlers_disconnect_by_func(store->archive, 
cb_xa_archive_store_archive_refreshed, store);
                g_object_unref(store->archive);
+       }
 
        for(list_iter = store->navigation.history; list_iter; list_iter = 
list_iter->next)
                g_slist_free(list_iter->data);
@@ -1118,38 +1171,51 @@
 
        g_object_ref(archive);
        store->archive = archive;
-       current_entry = g_slist_prepend(NULL, lxa_archive_get_iter(archive, 
NULL));
 
-       xa_archive_store_append_history(store, current_entry);
+       if(lxa_archive_get_status(archive) == LXA_ARCHIVESTATUS_IDLE)
+       {
+               current_entry = g_slist_prepend(NULL, 
lxa_archive_get_iter(archive, NULL));
 
-       xa_archive_store_sort(store);
+               xa_archive_store_append_history(store, current_entry);
 
-       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);
+               xa_archive_store_sort(store);
 
-               iter.stamp = store->stamp;
-               if(store->sort_list)
-                       iter.user_data = store->sort_list[i];
-               else
-                       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);
+               store->list_size = lxa_archive_iter_n_children(archive, 
lxa_archive_get_iter(archive, NULL));
 
-               gtk_tree_model_row_inserted(GTK_TREE_MODEL(store), path_, 
&iter);
+               for(i = 0; i < store->list_size; i++)
+               {
+                       path_ = gtk_tree_path_new();
+                       gtk_tree_path_append_index(path_, i);
 
-               gtk_tree_path_free(path_);
+                       iter.stamp = store->stamp;
+                       if(store->sort_list)
+                               iter.user_data = store->sort_list[i];
+                       else
+                               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);
+
+                       gtk_tree_path_free(path_);
+               }
        }
 
+       g_signal_connect(store->archive, "lxa_status_changed", 
G_CALLBACK(cb_xa_archive_store_archive_refreshed), store);
+
        g_signal_emit(store, 
xa_archive_store_signals[XA_ARCHIVE_STORE_SIGNAL_NEW_ARCHIVE], 0,NULL);
 }
 
 gchar *
 xa_archive_store_get_pwd(XAArchiveStore *store)
 {
+#ifdef DEBUG
        g_return_val_if_fail(store, NULL);
+#endif
 
+       if(!store->navigation.present)
+               return NULL;
+
        GValue *basename = g_new0(GValue, 1);
        gchar *path = NULL;
        gchar **buf = NULL;
@@ -1209,7 +1275,10 @@
 GSList *
 xa_archive_store_get_pwd_list(XAArchiveStore *store)
 {
+#ifdef DEBUG
        g_return_val_if_fail(store, NULL);
+#endif
+
        if(!store->navigation.present)
                return NULL;
 
@@ -1235,29 +1304,23 @@
 }
 
 gboolean
-xa_archive_store_set_pwd_silent(XAArchiveStore *store, const gchar *path)
-{
-       g_critical("depricated %s", __FUNCTION__);
-       return FALSE;
-}
-
-gboolean
 xa_archive_store_set_pwd(XAArchiveStore *store, const gchar *path)
 {
-       g_return_val_if_fail(store, -1);
+       g_return_val_if_fail(store, FALSE);
 
        if(!store->archive)
                return FALSE;
 
+#ifdef DEBUG
+       g_return_val_if_fail(store->navigation.present, FALSE);
+       g_return_val_if_fail(store->navigation.present->data, FALSE);
+#endif
+
        gchar **buf = g_strsplit_set(path, "/\n", -1);
        gchar **iter = buf;
        LXAArchiveIter *entry = lxa_archive_get_iter(store->archive, NULL);
        GSList *stack = g_slist_prepend(NULL, entry);
-       gint prev_size = lxa_archive_iter_n_children(store->archive, 
(LXAArchiveIter*)((GSList*)store->navigation.present->data)->data);
 
-       if(store->props._show_up_dir && lxa_archive_get_iter(store->archive, 
NULL) != ((GSList*)store->navigation.present->data)->data)
-               prev_size++;
-
        if(path[0] == '/' && lxa_archive_iter_get_child(store->archive, entry, 
"/"))
        {
                iter[0] = strdup("/");
@@ -1285,7 +1348,7 @@
 
        xa_archive_store_sort(store);
 
-       xa_archive_store_refresh(store, prev_size);
+       xa_archive_store_refresh(store);
 
        g_signal_emit(store, 
xa_archive_store_signals[XA_ARCHIVE_STORE_SIGNAL_PWD_CHANGED], 0,NULL);
        return TRUE;
@@ -1319,9 +1382,13 @@
 void
 xa_archive_store_set_show_icons(XAArchiveStore *store, gboolean show)
 {
+#ifdef DEBUG
+       g_return_if_fail(store->navigation.present);
+       g_return_if_fail(store->navigation.present->data);
+#endif
+
        GtkSortType sort_order;
        gint sort_col = 0;
-       gint prev_size = lxa_archive_iter_n_children(store->archive, 
(LXAArchiveIter*)((GSList*)store->navigation.present->data)->data);
        store->props._show_icons = show?1:0;
        if(show)
        {
@@ -1333,7 +1400,7 @@
                xa_archive_store_get_sort_column_id(GTK_TREE_SORTABLE(store), 
&sort_col, &sort_order);
                xa_archive_store_set_sort_column_id(GTK_TREE_SORTABLE(store), 
sort_col-1, sort_order);
        }
-       xa_archive_store_refresh(store, prev_size);
+       xa_archive_store_refresh(store);
 }
 
 void
@@ -1341,11 +1408,13 @@
 {
        store->props._sort_case_sensitive= sort?1:0;
 
+#ifdef DEBUG
+       g_return_if_fail(store->navigation.present);
+       g_return_if_fail(store->navigation.present->data);
+#endif
+
        if(store->archive)
-       {
-               gint prev_size = lxa_archive_iter_n_children(store->archive, 
(LXAArchiveIter*)((GSList*)store->navigation.present->data)->data);
-               xa_archive_store_refresh(store, prev_size);
-       }
+               xa_archive_store_refresh(store);
 }
 
 void
@@ -1353,11 +1422,13 @@
 {
        store->props._sort_folders_first = sort?1:0;
 
+#ifdef DEBUG
+       g_return_if_fail(store->navigation.present);
+       g_return_if_fail(store->navigation.present->data);
+#endif
+
        if(store->archive)
-       {
-               gint prev_size = lxa_archive_iter_n_children(store->archive, 
(LXAArchiveIter*)((GSList*)store->navigation.present->data)->data);
-               xa_archive_store_refresh(store, prev_size);
-       }
+               xa_archive_store_refresh(store);
 }
 
 gchar *
@@ -1375,29 +1446,19 @@
                return g_value_dup_string(value);
 }
 
-void
-xa_archive_store_set_history(XAArchiveStore *store, GList *history, GList *pwd)
-{
-       store->navigation.history = history;
-       store->navigation.present = pwd;
-}
-
-void
-xa_archive_store_get_history(XAArchiveStore *store, GList **history, GList 
**pwd)
-{
-       (*history)=store->navigation.history;
-       (*pwd) = store->navigation.present;
-}
-
 gboolean
 xa_archive_store_has_history(XAArchiveStore *store)
 {
+       if(!store->navigation.present)
+               return FALSE;
        return store->navigation.present->prev?TRUE:FALSE;
 }
 
 gboolean
 xa_archive_store_has_future(XAArchiveStore *store)
 {
+       if(!store->navigation.present)
+               return FALSE;
        return store->navigation.present->next?TRUE:FALSE;
 }
 
@@ -1405,24 +1466,23 @@
 xa_archive_store_go_back(XAArchiveStore *store)
 {
        LXAArchive *archive = store->archive;
+
+#ifdef DEBUG
+       g_return_if_fail(store->navigation.present);
+       g_return_if_fail(store->navigation.present->data);
+#endif
+
        LXAArchiveIter *entry = 
((GSList*)store->navigation.present->data)->data;
 
        g_return_if_fail(archive);
        g_return_if_fail(entry);
 
-       gint prev_size = lxa_archive_iter_n_children(archive, entry);
-
        if(xa_archive_store_has_history(store))
                store->navigation.present = store->navigation.present->prev;
 
-       if(store->props._show_up_dir && lxa_archive_get_iter(archive, NULL) != 
entry)
-       {
-               prev_size++;
-       }
-
        xa_archive_store_sort(store);
 
-       xa_archive_store_refresh(store, prev_size);
+       xa_archive_store_refresh(store);
 
        g_signal_emit(store, 
xa_archive_store_signals[XA_ARCHIVE_STORE_SIGNAL_PWD_CHANGED], 0,NULL);
 }
@@ -1431,24 +1491,23 @@
 xa_archive_store_go_forward(XAArchiveStore *store)
 {
        LXAArchive *archive = store->archive;
+
+#ifdef DEBUG
+       g_return_if_fail(store->navigation.present);
+       g_return_if_fail(store->navigation.present->data);
+#endif
+
        LXAArchiveIter *entry = 
((GSList*)store->navigation.present->data)->data;
 
        g_return_if_fail(archive);
        g_return_if_fail(entry);
 
-       gint prev_size = lxa_archive_iter_n_children(archive, entry);
-
        if(xa_archive_store_has_future(store))
                store->navigation.present = store->navigation.present->next;
 
-       if(store->props._show_up_dir && lxa_archive_get_iter(archive, NULL) != 
entry)
-       {
-               prev_size++;
-       }
-
        xa_archive_store_sort(store);
 
-       xa_archive_store_refresh(store, prev_size);
+       xa_archive_store_refresh(store);
 
        g_signal_emit(store, 
xa_archive_store_signals[XA_ARCHIVE_STORE_SIGNAL_PWD_CHANGED], 0,NULL);
 }
@@ -1456,6 +1515,9 @@
 static void
 xa_archive_store_append_history(XAArchiveStore *store, GSList *entry)
 {
+       if(lxa_archive_get_status(store->archive) != LXA_ARCHIVESTATUS_IDLE)
+               return;
+
        GList *iter = store->navigation.present;
 
        if(store->navigation.present)
@@ -1481,6 +1543,20 @@
        }
 }
 
+static void
+cb_xa_archive_store_archive_refreshed(LXAArchive *archive, gpointer user_data)
+{
+       XAArchiveStore *store = XA_ARCHIVE_STORE(user_data);
+
+       g_return_if_fail(store->archive == archive);
+
+       if(lxa_archive_get_status(archive) == LXA_ARCHIVESTATUS_IDLE)
+       {
+               if(!store->navigation.present)
+                       xa_archive_store_append_history(store, 
g_slist_prepend(NULL, lxa_archive_get_iter(archive, NULL)));
+       }
+}
+
 LXAArchive *
 xa_archive_store_get_archive(XAArchiveStore *archive_store)
 {

Modified: xarchiver/branches/xarchiver-psybsd/src/archive_store.h
===================================================================
--- xarchiver/branches/xarchiver-psybsd/src/archive_store.h     2006-11-14 
21:44:38 UTC (rev 23881)
+++ xarchiver/branches/xarchiver-psybsd/src/archive_store.h     2006-11-14 
22:41:35 UTC (rev 23882)
@@ -49,6 +49,7 @@
        gint sort_column;
        GtkSortType sort_order;
        LXAEntry **sort_list;
+       guint list_size;
        GtkIconTheme *icon_theme;
        struct {
                guint _show_icons : 1;
@@ -80,7 +81,6 @@
 GSList * xa_archive_store_get_pwd_list(XAArchiveStore *store);
 gchar * xa_archive_store_get_basename(XAArchiveStore *store);
 gboolean xa_archive_store_set_pwd(XAArchiveStore *store, const gchar *path);
-/* depricated */gboolean xa_archive_store_set_pwd_silent(XAArchiveStore 
*store, const gchar *path);
 void xa_archive_store_set_icon_theme(XAArchiveStore *store, GtkIconTheme 
*icon_theme);
 
 gboolean xa_archive_store_get_show_icons(XAArchiveStore *store);

Modified: xarchiver/branches/xarchiver-psybsd/src/tool_bar.c
===================================================================
--- xarchiver/branches/xarchiver-psybsd/src/tool_bar.c  2006-11-14 21:44:38 UTC 
(rev 23881)
+++ xarchiver/branches/xarchiver-psybsd/src/tool_bar.c  2006-11-14 22:41:35 UTC 
(rev 23882)
@@ -303,7 +303,8 @@
 {
        XAToolBar *tool_bar = XA_TOOL_BAR(bar);
        gchar *path= xa_archive_store_get_pwd(store);
-
+       if(!path)
+               path = g_strdup("");
        xa_tool_bar_refresh(tool_bar, path);
        g_free(path);
        gtk_widget_set_sensitive(GTK_WIDGET(tool_bar->hbox), TRUE);
@@ -326,6 +327,8 @@
 {
        xa_archive_store_go_back(XA_NAVIGATION_BAR(tool_bar)->store);
        gchar *path= 
xa_archive_store_get_pwd(XA_NAVIGATION_BAR(tool_bar)->store);
+       if(!path)
+               path = g_strdup("");
        xa_tool_bar_refresh(tool_bar, path);
        g_free(path);
 }
@@ -335,6 +338,8 @@
 {
        xa_archive_store_go_forward(XA_NAVIGATION_BAR(tool_bar)->store);
        gchar *path= 
xa_archive_store_get_pwd(XA_NAVIGATION_BAR(tool_bar)->store);
+       if(!path)
+               path = g_strdup("");
        xa_tool_bar_refresh(tool_bar, path);
        g_free(path);
 }
@@ -366,6 +371,8 @@
        if(bar->store)
        {
                gchar *path= xa_archive_store_get_pwd(bar->store);
+               if(!path)
+                       path = g_strdup("");
                xa_tool_bar_refresh(tool_bar, path);
                gtk_widget_set_sensitive(GTK_WIDGET(tool_bar->hbox), TRUE);
                g_free(path);

_______________________________________________
Xfce4-commits mailing list
Xfce4-commits@xfce.org
http://foo-projects.org/mailman/listinfo/xfce4-commits

Reply via email to