[Xfce4-commits] <squeeze:stephan/new-ui> Strip stuff from archive-store

Stephan Arts noreply at xfce.org
Fri May 10 13:08:03 CEST 2013


Updating branch refs/heads/stephan/new-ui
         to 5618f356820490d680416df05800b9fb00950b9b (commit)
       from fa6c69492f5f027fad5f89c742686f9fcc7acaea (commit)

commit 5618f356820490d680416df05800b9fb00950b9b
Author: Stephan Arts <stephan at xfce.org>
Date:   Fri May 10 13:07:38 2013 +0200

    Strip stuff from archive-store

 src/Makefile.am     |    3 +-
 src/archive_store.c |  473 +++++----------------------------------------------
 src/archive_store.h |   12 +-
 src/main_window.c   |   76 ++++++++-
 4 files changed, 119 insertions(+), 445 deletions(-)

diff --git a/src/Makefile.am b/src/Makefile.am
index 8c7cd67..43be2d0 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -2,7 +2,8 @@ bin_PROGRAMS = squeeze
 
 squeeze_SOURCES = \
 	main.c main.h \
-	main_window.c main_window.h
+	main_window.c main_window.h \
+	archive_store.c archive_store.h
 
 squeeze_CFLAGS = \
 	-DDATADIR=\"$(datadir)\" \
diff --git a/src/archive_store.c b/src/archive_store.c
index 63614de..8a14310 100644
--- a/src/archive_store.c
+++ b/src/archive_store.c
@@ -26,10 +26,6 @@
 
 #include "archive_store.h"
 
-#ifndef SQ_ARCHIVE_STORE_MAX_HISTORY
-#define SQ_ARCHIVE_STORE_MAX_HISTORY 10
-#endif
-
 static void
 sq_archive_store_class_init(SQArchiveStoreClass *as_class);
 
@@ -47,9 +43,7 @@ sq_archive_store_dispose(GObject *object);
 
 /* properties */
 enum {
-	SQ_ARCHIVE_STORE_SHOW_FULL_PATH = 1, 
-	SQ_ARCHIVE_STORE_SHOW_ICONS, 
-	SQ_ARCHIVE_STORE_SHOW_UP_DIR,
+	SQ_ARCHIVE_STORE_SHOW_ICONS = 1
 	SQ_ARCHIVE_STORE_SORT_FOLDERS_FIRST,
 	SQ_ARCHIVE_STORE_SORT_CASE_SENSITIVE
 };
@@ -107,10 +101,6 @@ static gboolean
 sq_archive_store_get_sort_column_id(GtkTreeSortable *sortable, gint *sort_col_id, GtkSortType *order);
 static void
 sq_archive_store_set_sort_column_id(GtkTreeSortable *sortable, gint sort_col_id, GtkSortType order);
-static void
-sq_archive_store_set_sort_func(GtkTreeSortable *, gint, GtkTreeIterCompareFunc, gpointer, GtkDestroyNotify);
-static void
-sq_archive_store_set_default_sort_func(GtkTreeSortable *, GtkTreeIterCompareFunc, gpointer, GtkDestroyNotify);
 static gboolean
 sq_archive_store_has_default_sort_func(GtkTreeSortable *);
 
@@ -128,9 +118,6 @@ static GIcon *
 sq_archive_store_get_icon_name_for_iter(SQArchiveStore *store, LSQArchiveIter *iter);
 
 static void
-sq_archive_store_append_history(SQArchiveStore *store, LSQArchiveIter *entry);
-
-static void
 sq_archive_store_check_trailing(SQArchiveStore *store);
 
 static void
@@ -138,8 +125,6 @@ sq_archive_store_refresh(SQArchiveStore *store);
 
 static void
 cb_sq_archive_store_archive_refreshed(LSQArchive *archive, gpointer user_data);
-/* static void																						   */
-/* cb_sq_archive_store_archive_path_changed(LSQArchive *archive, const gchar *path, gpointer user_data); */
 
 GType
 sq_archive_store_get_type(void)
@@ -209,8 +194,10 @@ sq_archive_tree_sortable_init(GtkTreeSortableIface *iface)
 {
 	iface->get_sort_column_id	= sq_archive_store_get_sort_column_id;
 	iface->set_sort_column_id	= sq_archive_store_set_sort_column_id;
+#if 0
 	iface->set_sort_func		 = sq_archive_store_set_sort_func;			/*NOT SUPPORTED*/
 	iface->set_default_sort_func = sq_archive_store_set_default_sort_func;	/*NOT SUPPORTED*/
+#endif
 	iface->has_default_sort_func = sq_archive_store_has_default_sort_func;
 }
 
@@ -222,16 +209,9 @@ sq_archive_store_init(SQArchiveStore *as)
 	as->sort_column = GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID;
 	as->sort_order = GTK_SORT_ASCENDING;
 	as->sort_list = NULL;
-	as->icon_theme = NULL;
-	as->props._show_full_path = 0;
 	as->props._show_icons = 0;
-	as->props._show_up_dir = 1;
 	as->props._sort_folders_first = 1;
 	as->props._sort_case_sensitive = 1;
-	as->navigation.history = NULL;
-	as->navigation.present = NULL;
-	as->navigation.maxhistory = SQ_ARCHIVE_STORE_MAX_HISTORY;
-	as->navigation.trailing = NULL;
 }
 
 static void
@@ -244,14 +224,7 @@ sq_archive_store_class_init(SQArchiveStoreClass *as_class)
 	object_class->get_property = sq_archive_store_get_property;
 	object_class->dispose = sq_archive_store_dispose;
 
-	parent_class = gtk_type_class (G_TYPE_OBJECT);
-
-	pspec = g_param_spec_boolean("show-full-path",
-		_("Show full path"),
-		_("Show the full path strings for each entry"),
-		FALSE,
-		G_PARAM_READWRITE);
-	g_object_class_install_property(object_class, SQ_ARCHIVE_STORE_SHOW_ICONS, pspec);
+    parent_class = g_type_class_peek_parent(as_class);
 
 	pspec = g_param_spec_boolean("show-icons",
 		_("Show mime icons"),
@@ -260,13 +233,6 @@ sq_archive_store_class_init(SQArchiveStoreClass *as_class)
 		G_PARAM_READWRITE);
 	g_object_class_install_property(object_class, SQ_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, SQ_ARCHIVE_STORE_SHOW_UP_DIR, pspec);
-
 	pspec = g_param_spec_boolean("sort-folders-first",
 		_("Sort folders before files"),
 		_("The folders will be put at the top of the list"),
@@ -280,41 +246,6 @@ sq_archive_store_class_init(SQArchiveStoreClass *as_class)
 		TRUE,
 		G_PARAM_READWRITE);
 	g_object_class_install_property(object_class, SQ_ARCHIVE_STORE_SORT_CASE_SENSITIVE, pspec);
-
-	sq_archive_store_signals[SQ_ARCHIVE_STORE_SIGNAL_PWD_CHANGED] = g_signal_new("sq-pwd-changed",
-	   G_TYPE_FROM_CLASS(as_class),
-		 G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
-		 0,
-		 NULL,
-		 NULL,
-		 g_cclosure_marshal_VOID__POINTER,
-		 G_TYPE_NONE,
-		 1, 
-		 G_TYPE_POINTER,
-		 NULL);
-
-	sq_archive_store_signals[SQ_ARCHIVE_STORE_SIGNAL_NEW_ARCHIVE] = g_signal_new("sq-new-archive",
-	   G_TYPE_FROM_CLASS(as_class),
-		 G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
-		 0,
-		 NULL,
-		 NULL,
-		 g_cclosure_marshal_VOID__VOID,
-		 G_TYPE_NONE,
-		 0,
-		 NULL);
-
-	sq_archive_store_signals[SQ_ARCHIVE_STORE_SIGNAL_FILE_ACTIVATED] = g_signal_new("file-activated",
-	   G_TYPE_FROM_CLASS(as_class),
-		 G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
-		 0,
-		 NULL,
-		 NULL,
-		 g_cclosure_marshal_VOID__POINTER,
-		 G_TYPE_NONE,
-		 1,
-		 G_TYPE_POINTER,
-		 NULL);
 }
 
 static void
@@ -323,19 +254,9 @@ sq_archive_store_set_property(GObject *object, guint prop_id, const GValue *valu
 	SQArchiveStore *store = SQ_ARCHIVE_STORE(object);
 	switch(prop_id)
 	{
-		case SQ_ARCHIVE_STORE_SHOW_FULL_PATH:
-			sq_archive_store_set_show_full_path(store, g_value_get_boolean(value));
-			break;
 		case SQ_ARCHIVE_STORE_SHOW_ICONS:
 			sq_archive_store_set_show_icons(store, g_value_get_boolean(value));
 			break;
-		case SQ_ARCHIVE_STORE_SHOW_UP_DIR:
-			if(store->props._show_up_dir != g_value_get_boolean(value)?1:0)
-			{
-				store->props._show_up_dir = g_value_get_boolean(value)?1:0;
-				sq_archive_store_refresh(store);
-			}
-			break;
 		case SQ_ARCHIVE_STORE_SORT_FOLDERS_FIRST:
 			sq_archive_store_set_sort_folders_first(store, g_value_get_boolean(value));
 			break;
@@ -350,15 +271,9 @@ sq_archive_store_get_property(GObject *object, guint prop_id, GValue *value, GPa
 {
 	switch(prop_id)
 	{
-		case SQ_ARCHIVE_STORE_SHOW_FULL_PATH:
-			g_value_set_boolean(value, SQ_ARCHIVE_STORE(object)->props._show_full_path?TRUE:FALSE);
-			break;
 		case SQ_ARCHIVE_STORE_SHOW_ICONS:
 			g_value_set_boolean(value, SQ_ARCHIVE_STORE(object)->props._show_icons?TRUE:FALSE);
 			break;
-		case SQ_ARCHIVE_STORE_SHOW_UP_DIR:
-			g_value_set_boolean(value, SQ_ARCHIVE_STORE(object)->props._show_up_dir?TRUE:FALSE);
-			break;
 		case SQ_ARCHIVE_STORE_SORT_FOLDERS_FIRST:
 			g_value_set_boolean(value, SQ_ARCHIVE_STORE(object)->props._sort_folders_first?TRUE:FALSE);
 			break;
@@ -381,6 +296,7 @@ sq_archive_store_get_n_columns(GtkTreeModel *tree_model)
 {
 	SQArchiveStore *store;
 	LSQArchive *archive;
+    g_debug("%s\n", __FUNCTION__);
 
 	g_return_val_if_fail(SQ_IS_ARCHIVE_STORE(tree_model), 0);
 
@@ -398,6 +314,7 @@ sq_archive_store_get_column_type(GtkTreeModel *tree_model, gint index_)
 {
 	SQArchiveStore *store;
 	LSQArchive *archive;
+    g_debug("%s\n", __FUNCTION__);
 
 	g_return_val_if_fail(SQ_IS_ARCHIVE_STORE(tree_model), G_TYPE_INVALID);	
 
@@ -428,6 +345,8 @@ sq_archive_store_get_iter(GtkTreeModel *tree_model, GtkTreeIter *iter, GtkTreePa
 	gint depth;
 	gint index_;
 
+    g_debug("%s\n", __FUNCTION__);
+
 
 #ifdef DEBUG
 	g_return_val_if_fail(SQ_IS_ARCHIVE_STORE(tree_model), FALSE);	
@@ -435,15 +354,6 @@ sq_archive_store_get_iter(GtkTreeModel *tree_model, GtkTreeIter *iter, GtkTreePa
 
 	store = SQ_ARCHIVE_STORE(tree_model);
 
-	if(!store->navigation.present)
-		return FALSE;
-#ifdef DEBUG
-	g_return_val_if_fail(store->navigation.present->data, FALSE);
-#endif
-
-	/* get the present history */
-	entry = store->navigation.present->data;
-
 	indices = gtk_tree_path_get_indices(path);
 	depth = gtk_tree_path_get_depth(path) - 1;
 
@@ -452,26 +362,14 @@ sq_archive_store_get_iter(GtkTreeModel *tree_model, GtkTreeIter *iter, GtkTreePa
 
 	index_ = indices[depth];
 
-	/* if this is the root entry we don't need the ".." */
-	if(store->props._show_up_dir && lsq_archive_iter_has_parent(entry))
-		index_--;
+    /* as long as it is a list depth is 0 other wise current_entry should be synced ? */
+    if(store->sort_list)
+        entry = store->sort_list[index_];
+    else
+        entry = NULL;
 
-	if(index_ == -1)
-	{
-		/* it is the ".." */
-		entry = NULL;
-	}
-	else
-	{
-		/* as long as it is a list depth is 0 other wise current_entry should be synced ? */
-		if(store->sort_list)
-			entry = store->sort_list[index_];
-		else
-			entry = NULL;
-
-		if(!entry)
-			return FALSE;
-	}
+    if(!entry)
+        return FALSE;
 
 	iter->stamp = store->stamp;
 	iter->user_data = entry;
@@ -516,6 +414,7 @@ sq_archive_store_get_value (GtkTreeModel *tree_model, GtkTreeIter *iter, gint co
 	SQArchiveStore *store;
 	LSQArchive *archive;
 	LSQArchiveIter *parent, *entry;
+    g_debug("%s\n", __FUNCTION__);
 
 	g_return_if_fail (SQ_IS_ARCHIVE_STORE (tree_model));
 
@@ -587,6 +486,7 @@ sq_archive_store_iter_next (GtkTreeModel *tree_model, GtkTreeIter *iter)
 	SQArchiveStore *store;
 	LSQArchiveIter *entry;
 	gint pos;
+    g_debug("%s\n", __FUNCTION__);
 
 	g_return_val_if_fail(SQ_IS_ARCHIVE_STORE(tree_model), FALSE);
 	
@@ -619,6 +519,7 @@ sq_archive_store_iter_children (GtkTreeModel *tree_model, GtkTreeIter *iter, Gtk
 	SQArchiveStore *store;
 	LSQArchive *archive;
 	LSQArchiveIter *entry;
+    g_debug("%s\n", __FUNCTION__);
 
 #ifdef DEBUG
 	g_return_val_if_fail(SQ_IS_ARCHIVE_STORE(tree_model), FALSE);
@@ -628,13 +529,6 @@ sq_archive_store_iter_children (GtkTreeModel *tree_model, GtkTreeIter *iter, Gtk
 	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
-
-	entry = store->navigation.present->data;
-
-#ifdef DEBUG
 	g_return_val_if_fail(archive, FALSE);
 	g_return_val_if_fail(entry, FALSE);
 #endif
@@ -668,6 +562,7 @@ sq_archive_store_iter_children (GtkTreeModel *tree_model, GtkTreeIter *iter, Gtk
 static gboolean
 sq_archive_store_iter_has_child (GtkTreeModel *tree_model, GtkTreeIter *iter)
 {
+    g_debug("%s\n", __FUNCTION__);
 	return FALSE;
 }
 
@@ -678,6 +573,8 @@ sq_archive_store_iter_n_children (GtkTreeModel *tree_model, GtkTreeIter *iter)
 	LSQArchive *archive;
 	LSQArchiveIter *entry;
 
+    g_debug("%s\n", __FUNCTION__);
+
 #ifdef DEBUG
 	g_return_val_if_fail(SQ_IS_ARCHIVE_STORE(tree_model), 0);
 #endif
@@ -686,13 +583,6 @@ sq_archive_store_iter_n_children (GtkTreeModel *tree_model, GtkTreeIter *iter)
 	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
-
-	entry = store->navigation.present->data;
-
-#ifdef DEBUG
 	g_return_val_if_fail(archive, 0);
 	g_return_val_if_fail(entry, 0);
 #endif
@@ -700,7 +590,7 @@ sq_archive_store_iter_n_children (GtkTreeModel *tree_model, GtkTreeIter *iter)
 	/* only support lists: iter is always NULL */
 	g_return_val_if_fail(iter == NULL, FALSE);
 
-	return store->list_size + (lsq_archive_iter_has_parent(entry)?1:0);
+	return store->list_size;
 }
 
 static gboolean 
@@ -709,6 +599,7 @@ sq_archive_store_iter_nth_child (GtkTreeModel *tree_model, GtkTreeIter *iter, Gt
 	SQArchiveStore *store;
 	LSQArchive *archive;
 	LSQArchiveIter *entry;
+    g_debug("%s\n", __FUNCTION__);
 
 #ifdef DEBUG
 	g_return_val_if_fail(SQ_IS_ARCHIVE_STORE(tree_model), FALSE);
@@ -718,13 +609,6 @@ sq_archive_store_iter_nth_child (GtkTreeModel *tree_model, GtkTreeIter *iter, Gt
 	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
-
-	entry = store->navigation.present->data;
-
-#ifdef DEBUG
 	g_return_val_if_fail(archive, FALSE);
 	g_return_val_if_fail(entry, FALSE);
 	g_return_val_if_fail(iter, FALSE);
@@ -761,6 +645,7 @@ sq_archive_store_iter_nth_child (GtkTreeModel *tree_model, GtkTreeIter *iter, Gt
 static gboolean
 sq_archive_store_iter_parent (GtkTreeModel *tree_model, GtkTreeIter *iter, GtkTreeIter *child)
 {
+    g_debug("%s\n", __FUNCTION__);
 	return FALSE;
 }
 
@@ -769,6 +654,7 @@ static gboolean
 sq_archive_store_get_sort_column_id(GtkTreeSortable *sortable, gint *sort_col_id, GtkSortType *order)
 {
 	SQArchiveStore *store;
+    g_debug("%s\n", __FUNCTION__);
 
 	g_return_val_if_fail(SQ_IS_ARCHIVE_STORE(sortable), FALSE);
 
@@ -787,6 +673,7 @@ static void
 sq_archive_store_set_sort_column_id(GtkTreeSortable *sortable, gint sort_col_id, GtkSortType order)
 {
 	SQArchiveStore *store;
+    g_debug("%s\n", __FUNCTION__);
 
 	g_return_if_fail(SQ_IS_ARCHIVE_STORE(sortable));
 
@@ -807,6 +694,7 @@ sq_archive_store_set_sort_column_id(GtkTreeSortable *sortable, gint sort_col_id,
 	gtk_tree_sortable_sort_column_changed(sortable);
 }
 
+#if 0
 static void
 sq_archive_store_set_sort_func(GtkTreeSortable *s, gint i, GtkTreeIterCompareFunc f, gpointer p, GtkDestroyNotify d)
 {
@@ -818,6 +706,7 @@ sq_archive_store_set_default_sort_func(GtkTreeSortable *s, GtkTreeIterCompareFun
 {
 	g_warning("%s is not supported by the SQArchiveStore model", __FUNCTION__);
 }
+#endif
 
 static gboolean
 sq_archive_store_has_default_sort_func(GtkTreeSortable *s)
@@ -922,14 +811,6 @@ sq_archive_store_sort(SQArchiveStore *store)
 		store->sort_list = NULL;
 	}
 
-#ifdef DEBUG
-	g_return_if_fail(store->navigation.present);
-	g_return_if_fail(store->navigation.present->data);
-#endif
-
-	pentry = store->navigation.present->data;
-	psize = lsq_archive_iter_n_children(pentry);
-
 	store->sort_list = g_new(LSQArchiveIter *, psize+1);
 
 	for(i = 0; i < psize; ++i)
@@ -1018,7 +899,7 @@ sq_archive_store_get_icon_name_for_iter(SQArchiveStore *store, LSQArchiveIter *i
 }
 
 GtkTreeModel *
-sq_archive_store_new(LSQArchive *archive, gboolean show_icons, gboolean show_up_dir, GtkIconTheme *icon_theme)
+sq_archive_store_new(gboolean show_icons, gboolean show_up_dir)
 {
 	SQArchiveStore *tree_model;
 
@@ -1026,13 +907,10 @@ sq_archive_store_new(LSQArchive *archive, gboolean show_icons, gboolean show_up_
 
 	tree_model->props._show_icons = show_icons?1:0;
 	tree_model->props._show_up_dir = show_up_dir?1:0;
-	tree_model->icon_theme = icon_theme;
 
 	if(tree_model->props._sort_folders_first)
 		tree_model->sort_column = SQ_ARCHIVE_STORE_EXTRA_PROP_COUNT + LSQ_ARCHIVE_PROP_FILENAME;
 
-	sq_archive_store_set_archive(tree_model, archive);
-
 	return GTK_TREE_MODEL(tree_model);
 }
 
@@ -1054,13 +932,7 @@ sq_archive_store_refresh(SQArchiveStore *store)
 	GtkTreePath *path_ = NULL;
 	GtkTreeIter iter;
 
-	if(!store->navigation.present)
-		return;
-#ifdef DEBUG
-	g_return_if_fail(store->navigation.present->data);
-#endif
-
-	entry = store->navigation.present->data;
+    entry = lsq_archive_get_iter( archive, NULL );
 
 	g_return_if_fail(archive);
 	g_return_if_fail(entry);
@@ -1070,27 +942,6 @@ sq_archive_store_refresh(SQArchiveStore *store)
 
 	/* if(store->treeview) */
 	{
-		/* we need to add up dir .. */
-		if(store->props._show_up_dir && lsq_archive_iter_has_parent(entry))
-		{ 
-			/* use a hack like in thunar-list-model to prevent re-allocating */
-			path_ = gtk_tree_path_new();
-			gtk_tree_path_append_index(path_, 0);
-
-			iter.stamp = store->stamp;
-			iter.user_data = NULL;
-			iter.user_data3 = GINT_TO_POINTER(-1);
-
-			if(0 < prev_size)
-				gtk_tree_model_row_changed(GTK_TREE_MODEL(store), path_, &iter);
-			else
-				gtk_tree_model_row_inserted(GTK_TREE_MODEL(store), path_, &iter);
-
-			gtk_tree_path_free(path_);
-			i=1;
-			new_size++;
-		}
-
 		if(store->sort_list)
 		{
 			/* notify the tree view that we have rows */
@@ -1129,6 +980,9 @@ sq_archive_store_refresh(SQArchiveStore *store)
 	}
 
 	store->list_size = new_size;
+
+    printf("> %d\n", new_size);
+
 }
 
 static void
@@ -1146,11 +1000,7 @@ sq_archive_store_file_activated(SQArchiveStore *store, GtkTreePath *path)
 	gint depth;
 	gint index_;
 
-	g_return_if_fail(store->navigation.present);
-	g_return_if_fail(store->navigation.present->data);
-
 	archive = store->archive;
-	entry = store->navigation.present->data;
 
 	g_return_if_fail(archive);
 	g_return_if_fail(entry);
@@ -1169,7 +1019,6 @@ sq_archive_store_file_activated(SQArchiveStore *store, GtkTreePath *path)
 	if(index_ == -1)
 	{
 		entry = lsq_archive_iter_get_parent(entry);
-		sq_archive_store_append_history(store, entry);
 	}
 	else
 	{
@@ -1189,13 +1038,11 @@ sq_archive_store_file_activated(SQArchiveStore *store, GtkTreePath *path)
 			g_signal_emit(store, sq_archive_store_signals[SQ_ARCHIVE_STORE_SIGNAL_FILE_ACTIVATED], 0, entry, NULL); 
 			return;
 		}
-
-		sq_archive_store_append_history(store, lsq_archive_iter_ref(entry));
 	}
 
 	sq_archive_store_sort(store);
 	sq_archive_store_refresh(store);
-	g_signal_emit(store, sq_archive_store_signals[SQ_ARCHIVE_STORE_SIGNAL_PWD_CHANGED], 0, entry, NULL);
+	//g_signal_emit(store, sq_archive_store_signals[SQ_ARCHIVE_STORE_SIGNAL_PWD_CHANGED], 0, entry, NULL);
 }
 
 void
@@ -1204,23 +1051,14 @@ sq_archive_store_go_up(SQArchiveStore *store)
 	LSQArchive *archive = store->archive;
 	LSQArchiveIter *entry;
 
-#ifdef DEBUG
-	g_return_if_fail(store->navigation.present);
-	g_return_if_fail(store->navigation.present->data);
-#endif
-
-	entry = store->navigation.present->data;
-
 	g_return_if_fail(archive);
 	g_return_if_fail(entry);
 
 	g_return_if_fail((entry = lsq_archive_iter_get_parent(entry)));
 
-	sq_archive_store_append_history(store, entry);
-
 	sq_archive_store_sort(store);
 	sq_archive_store_refresh(store);
-	g_signal_emit(store, sq_archive_store_signals[SQ_ARCHIVE_STORE_SIGNAL_PWD_CHANGED], 0, entry, NULL);
+	//g_signal_emit(store, sq_archive_store_signals[SQ_ARCHIVE_STORE_SIGNAL_PWD_CHANGED], 0, entry, NULL);
 }
 
 void
@@ -1265,18 +1103,6 @@ sq_archive_store_set_archive(SQArchiveStore *store, LSQArchive *archive)
 
 	store->list_size = 0;
 
-	/* clear the history */
-	for(list_iter = store->navigation.history; list_iter; list_iter = list_iter->next)
-		lsq_archive_iter_unref(list_iter->data);
-
-	g_list_free(store->navigation.history);
-	if(store->navigation.trailing)
-		lsq_archive_iter_unref(store->navigation.trailing);
-
-	store->navigation.history = NULL;
-	store->navigation.present = NULL;
-	store->navigation.trailing = NULL;
-
 	/* disconnect from the archive */
 	if(store->archive)
 	{
@@ -1289,48 +1115,18 @@ sq_archive_store_set_archive(SQArchiveStore *store, LSQArchive *archive)
 	/* notify all that we have a new NULL archive */
 	if(!archive)
 	{
-		g_signal_emit(store, sq_archive_store_signals[SQ_ARCHIVE_STORE_SIGNAL_NEW_ARCHIVE], 0, NULL);
+		//g_signal_emit(store, sq_archive_store_signals[SQ_ARCHIVE_STORE_SIGNAL_NEW_ARCHIVE], 0, NULL);
 		return;
 	}
 
 	/* take a ownership of the archive */
 	g_object_ref(archive);
 	store->archive = archive;
+    store->entry = lsq_archive_get_iter(archive, NULL);
 
-	/* only update if we are not busy */
-	/* if(lsq_archive_get_status(archive) == NULL) */
-	{
-		root_entry = lsq_archive_get_iter(archive, NULL);
-
-		sq_archive_store_append_history(store, root_entry);
-
-		sq_archive_store_sort(store);
-
-		/* lets notify the tree view we have new rows */
-		store->list_size = lsq_archive_iter_n_children(root_entry);
-
-		if(store->sort_list)
-		{
-			for(i = 0; i < store->list_size; ++i)
-			{
-				/* use a hack like in thunar-list-model to prevent re-allocating */
-				path_ = gtk_tree_path_new();
-				gtk_tree_path_append_index(path_, i);
-
-				iter.stamp = store->stamp;
-				iter.user_data = store->sort_list[i];
-				iter.user_data3 = GINT_TO_POINTER(i);
-
-				gtk_tree_model_row_inserted(GTK_TREE_MODEL(store), path_, &iter);
-
-				gtk_tree_path_free(path_);
-			}
-		}
-	}
-
-	/* notify all we have a new archive and connect with the archive */
-	g_signal_emit(store, sq_archive_store_signals[SQ_ARCHIVE_STORE_SIGNAL_NEW_ARCHIVE], 0, NULL);
 	g_signal_connect(store->archive, "refreshed", G_CALLBACK(cb_sq_archive_store_archive_refreshed), store);
+    lsq_archive_operate( store->archive, LSQ_COMMAND_TYPE_REFRESH, NULL, NULL, NULL, NULL );
+
 }
 
 LSQArchiveIter *
@@ -1343,12 +1139,7 @@ sq_archive_store_get_pwd(SQArchiveStore *store)
 	g_return_val_if_fail(SQ_IS_ARCHIVE_STORE(store), NULL);
 #endif
 
-	if(!store->navigation.present)
-		return NULL;
-
-	iter = store->navigation.present->data;
-
-	return lsq_archive_iter_ref(iter);
+	return NULL;
 }
 
 gboolean
@@ -1361,15 +1152,8 @@ sq_archive_store_set_pwd(SQArchiveStore *store, LSQArchiveIter *path)
 	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
-
 	if(lsq_archive_iter_is_directory(path))
 	{
-		sq_archive_store_append_history(store, lsq_archive_iter_ref(path));
-
 		sq_archive_store_sort(store);
 		sq_archive_store_refresh(store);
 
@@ -1387,19 +1171,6 @@ sq_archive_store_set_pwd(SQArchiveStore *store, LSQArchiveIter *path)
 	return FALSE;
 }
 
-void
-sq_archive_store_set_icon_theme(SQArchiveStore *store, GtkIconTheme *icon_theme)
-{
-	if(store)
-		store->icon_theme = icon_theme;
-}
-
-gboolean
-sq_archive_store_get_show_full_path(SQArchiveStore *store)
-{
-	return store->props._show_full_path;
-}
-
 gboolean
 sq_archive_store_get_show_icons(SQArchiveStore *store)
 {
@@ -1419,20 +1190,6 @@ sq_archive_store_get_sort_folders_first(SQArchiveStore *store)
 }
 
 void
-sq_archive_store_set_show_full_path(SQArchiveStore *store, gboolean show)
-{
-	show = show?1:0;
-
-	if(store->props._show_full_path != show)
-	{
-		store->props._show_full_path = show;
-		if(store->archive)
-			sq_archive_store_refresh(store);
-		g_object_notify(G_OBJECT(store), "show-full-path");
-	}
-}
-
-void
 sq_archive_store_set_show_icons(SQArchiveStore *store, gboolean show)
 {
 	show = show?1:0;
@@ -1486,149 +1243,6 @@ sq_archive_store_set_sort_folders_first(SQArchiveStore *store, gboolean sort)
 	}
 }
 
-gboolean
-sq_archive_store_has_history(SQArchiveStore *store)
-{
-	if(!store->navigation.present)
-		return FALSE;
-	return store->navigation.present->prev?TRUE:FALSE;
-}
-
-gboolean
-sq_archive_store_has_future(SQArchiveStore *store)
-{
-	if(!store->navigation.present)
-		return FALSE;
-	return store->navigation.present->next?TRUE:FALSE;
-}
-
-void
-sq_archive_store_go_back(SQArchiveStore *store)
-{
-	LSQArchive *archive = store->archive;
-
-#ifdef DEBUG
-	g_return_if_fail(store->navigation.present);
-	g_return_if_fail(store->navigation.present->data);
-#endif
-
-	g_return_if_fail(archive);
-
-	if(sq_archive_store_has_history(store))
-		store->navigation.present = store->navigation.present->prev;
-
-	sq_archive_store_sort(store);
-	sq_archive_store_refresh(store);
-
-	sq_archive_store_check_trailing(store);
-
-	g_signal_emit(store, sq_archive_store_signals[SQ_ARCHIVE_STORE_SIGNAL_PWD_CHANGED], 0, store->navigation.present->data, NULL);
-}
-
-void
-sq_archive_store_go_forward(SQArchiveStore *store)
-{
-	LSQArchive *archive = store->archive;
-
-#ifdef DEBUG
-	g_return_if_fail(store->navigation.present);
-	g_return_if_fail(store->navigation.present->data);
-#endif
-
-	g_return_if_fail(archive);
-
-	if(sq_archive_store_has_future(store))
-		store->navigation.present = store->navigation.present->next;
-
-	sq_archive_store_sort(store);
-	sq_archive_store_refresh(store);
-
-	sq_archive_store_check_trailing(store);
-
-	g_signal_emit(store, sq_archive_store_signals[SQ_ARCHIVE_STORE_SIGNAL_PWD_CHANGED], 0, store->navigation.present->data, NULL);
-}
-
-static void
-sq_archive_store_append_history(SQArchiveStore *store, LSQArchiveIter *entry)
-{
-	/*
-	if(lsq_archive_get_status(store->archive) != NULL)
-		return;
-	*/
-
-	GList *iter = store->navigation.present;
-
-	if(store->navigation.present)
-	{
-		if(store->navigation.present->next)
-			store->navigation.present->next->prev = NULL;
-
-		while((iter = iter->next))
-			lsq_archive_iter_unref(iter->data);
-
-		g_list_free(store->navigation.present->next);
-
-		store->navigation.present->next = NULL;
-	}
-
-	store->navigation.history = g_list_append(store->navigation.history, entry);
-	store->navigation.present = g_list_last(store->navigation.history);
-
-	while(g_list_length(store->navigation.history) > store->navigation.maxhistory)
-	{
-		lsq_archive_iter_unref(g_list_first(store->navigation.history)->data);
-		store->navigation.history = g_list_delete_link(store->navigation.history, g_list_first(store->navigation.history));
-	}
-
-	sq_archive_store_check_trailing(store);
-}
-
-static void
-sq_archive_store_check_trailing(SQArchiveStore *store)
-{
-	LSQArchiveIter *piter = store->navigation.present->data;
-	LSQArchiveIter *titer = store->navigation.trailing;
-	LSQArchiveIter *child = NULL;
-
-	if(titer)
-	{
-		while(titer)
-		{
-			if(titer == piter)
-			{
-				if(child)
-					lsq_archive_iter_unref(child);
-				return;
-			}
-
-			titer = lsq_archive_iter_get_parent(titer);
-			if(child)
-				lsq_archive_iter_unref(child);
-			child = titer;
-		}
-		if(child)
-			lsq_archive_iter_unref(child);
-
-		lsq_archive_iter_unref(store->navigation.trailing);
-	}
-	store->navigation.trailing = lsq_archive_iter_ref(piter);
-}
-
-LSQArchiveIter *
-sq_archive_store_get_trailing(SQArchiveStore *store)
-{
-	LSQArchiveIter *iter;
-
-#ifdef DEBUG
-	g_return_val_if_fail(store, NULL);
-	g_return_val_if_fail(SQ_IS_ARCHIVE_STORE(store), NULL);
-#endif
-
-	iter = store->navigation.trailing;
-
-	return lsq_archive_iter_ref(iter);
-}
-
 LSQArchive *
 sq_archive_store_get_archive(SQArchiveStore *archive_store)
 {
@@ -1656,16 +1270,9 @@ cb_sq_archive_store_archive_refreshed(LSQArchive *archive, gpointer user_data)
 	GList *iter;
 	LSQArchiveIter *aIter;
 
-	for(iter = store->navigation.history; iter; iter = g_list_next(iter))
-	{
-		aIter = lsq_archive_iter_get_real_parent(iter->data);
-		lsq_archive_iter_unref(iter->data);
-		iter->data = aIter;
-	}
 
 	sq_archive_store_sort(store);
 	sq_archive_store_refresh(store);
-	g_signal_emit(store, sq_archive_store_signals[SQ_ARCHIVE_STORE_SIGNAL_PWD_CHANGED], 0, store->navigation.present->data, NULL);
 }
 
 
diff --git a/src/archive_store.h b/src/archive_store.h
index 9770373..191e626 100644
--- a/src/archive_store.h
+++ b/src/archive_store.h
@@ -43,11 +43,12 @@ struct _SQArchiveStore
 	GObject parent;
 	gint stamp;
 	LSQArchive *archive;
+    LSQArchiveIter *entry;
+
 	gint sort_column;
 	GtkSortType sort_order;
 	LSQArchiveIter **sort_list;
 	guint list_size;
-	GtkIconTheme *icon_theme;
 	GtkTreeView *treeview;
 	struct {
 		guint _show_full_path :1;
@@ -56,12 +57,6 @@ struct _SQArchiveStore
 		guint _sort_folders_first : 1;
 		guint _sort_case_sensitive : 1;
 	} props;
-	struct {
-		GList *history;
-		GList *present;
-		guint maxhistory;
-		LSQArchiveIter *trailing;
-	} navigation;
 };
 
 typedef struct _SQArchiveStoreClass SQArchiveStoreClass;
@@ -79,7 +74,8 @@ enum {
 };
 
 GType sq_archive_store_get_type();
-GtkTreeModel * sq_archive_store_new(LSQArchive *archive, gboolean show_icons, gboolean show_up_dir, GtkIconTheme *icon_theme);
+GtkTreeModel *
+sq_archive_store_new (gboolean show_icons, gboolean show_up_dir);
 void sq_archive_store_connect_treeview(SQArchiveStore *store, GtkTreeView *treeview);
 void sq_archive_store_connect_iconview(SQArchiveStore *store, GtkIconView *iconview);
 void sq_archive_store_go_up(SQArchiveStore *store);
diff --git a/src/main_window.c b/src/main_window.c
index 25375b9..52ca797 100644
--- a/src/main_window.c
+++ b/src/main_window.c
@@ -1,6 +1,4 @@
 /*
- *  Copyright (c) 2006 Stephan Arts <stephan at xfce.org>
- *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
  *  the Free Software Foundation; either version 2 of the License, or
@@ -29,6 +27,8 @@
 #include "main_window.h"
 #include "main_window_ui.h"
 
+#include "archive_store.h"
+
 #ifndef SQUEEZE_APP_TITLE
 #define SQUEEZE_APP_TITLE _("Archive Manager")
 #endif
@@ -172,6 +172,8 @@ struct _SQMainWindowPriv
     GtkActionGroup        *action_group;
     GtkUIManager          *ui_manager;
     GtkRecentManager      *recent_manager;
+
+    GtkTreeModel          *archive_store;
 };
 
 GType
@@ -233,7 +235,11 @@ static void
 sq_main_window_init(SQMainWindow *window)
 {
     GtkAccelGroup   *accel_group;
-    GtkWidget       *main_vbox = gtk_vbox_new (FALSE, 0);
+    GtkWidget       *main_vbox;
+    GtkWidget       *scrolled_window;
+    GtkWidget       *tree_view;
+
+    main_vbox = gtk_vbox_new (FALSE, 0);
 
     gtk_window_set_title (GTK_WINDOW (window), SQUEEZE_APP_TITLE);
 
@@ -269,6 +275,26 @@ sq_main_window_init(SQMainWindow *window)
 
     gtk_container_add (GTK_CONTAINER (window), main_vbox);
     gtk_box_pack_start(GTK_BOX(main_vbox), window->priv->menubar, FALSE, FALSE, 0);
+
+    scrolled_window = gtk_scrolled_window_new (NULL, NULL);
+    gtk_scrolled_window_set_policy (
+            GTK_SCROLLED_WINDOW (scrolled_window),
+            GTK_POLICY_AUTOMATIC,
+            GTK_POLICY_AUTOMATIC);
+    gtk_scrolled_window_set_shadow_type (
+            GTK_SCROLLED_WINDOW (scrolled_window),
+            GTK_SHADOW_IN);
+
+    gtk_box_pack_start(GTK_BOX(main_vbox), scrolled_window, FALSE, FALSE, 0);
+    tree_view = gtk_tree_view_new ();
+
+    window->priv->archive_store = sq_archive_store_new (TRUE, TRUE);
+
+    gtk_tree_view_set_model (
+            GTK_TREE_VIEW (tree_view),
+            GTK_TREE_MODEL (window->priv->archive_store));
+
+    gtk_container_add (GTK_CONTAINER (scrolled_window), tree_view);
 }
 
 GtkWidget *
@@ -296,6 +322,50 @@ cb_sq_main_window_open_archive (
         gpointer   user_data
     )
 {
+    SQMainWindow *window = SQ_MAIN_WINDOW (user_data);
+
+    GtkWidget     *dialog, *err_dialog;
+    GtkFileFilter *filter;
+    GFile         *file;
+    LSQArchive    *archive;
+
+    gint response;
+
+    filter = gtk_file_filter_new();
+
+    dialog = gtk_file_chooser_dialog_new(_("Open archive"),
+                                         GTK_WINDOW(window),
+                                         GTK_FILE_CHOOSER_ACTION_OPEN,
+                                         GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+                                         GTK_STOCK_OPEN, GTK_RESPONSE_OK,
+                                         NULL);
+
+    gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (dialog), FALSE);
+
+    response = gtk_dialog_run(GTK_DIALOG(dialog));
+    gtk_widget_hide (dialog);
+    if(response == GTK_RESPONSE_OK)
+    {
+        file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (dialog));
+        if ( file != NULL )
+        {
+            archive = lsq_open_archive (file, NULL);
+            if (archive == NULL)
+            {
+                err_dialog = gtk_message_dialog_new(GTK_WINDOW(window),
+                                                GTK_DIALOG_MODAL,
+                                                GTK_MESSAGE_ERROR,
+                                                GTK_BUTTONS_OK,
+                                                _("Could not open file"));
+                gtk_dialog_run(GTK_DIALOG(err_dialog));
+                gtk_widget_destroy(err_dialog);
+                return;
+            }
+             
+            /** Set tree-store with archive */
+            sq_archive_store_set_archive (window->priv->archive_store, archive);
+        }
+    }
     return;
 }
 


More information about the Xfce4-commits mailing list