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

Stephan Arts stephan at xfce.org
Fri Oct 6 13:11:02 UTC 2006


Author: stephan
Date: 2006-10-06 13:11:01 +0000 (Fri, 06 Oct 2006)
New Revision: 23298

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

Added TreeModel Sorting interface.

Added template for Rar Support.

(added 'up' button in GUI for testing)



Modified: xarchiver/branches/xarchiver-psybsd/libxarchiver/Makefile.am
===================================================================
--- xarchiver/branches/xarchiver-psybsd/libxarchiver/Makefile.am	2006-10-06 12:37:05 UTC (rev 23297)
+++ xarchiver/branches/xarchiver-psybsd/libxarchiver/Makefile.am	2006-10-06 13:11:01 UTC (rev 23298)
@@ -7,7 +7,8 @@
 	archive.c archive.h \
 	archive-support.c archive-support.h \
   archive-support-zip.c archive-support-zip.h \
-	archive-support-gnu-tar.c archive-support-gnu-tar.h
+	archive-support-gnu-tar.c archive-support-gnu-tar.h \
+  archive-support-rar.c archive-support-rar.h
 
 libxarchiver_a_CFLAGS = \
 	$(GLIB_CFLAGS)  \

Modified: xarchiver/branches/xarchiver-psybsd/libxarchiver/archive-support-zip.c
===================================================================
--- xarchiver/branches/xarchiver-psybsd/libxarchiver/archive-support-zip.c	2006-10-06 12:37:05 UTC (rev 23297)
+++ xarchiver/branches/xarchiver-psybsd/libxarchiver/archive-support-zip.c	2006-10-06 13:11:01 UTC (rev 23298)
@@ -181,10 +181,7 @@
 	                       "view-size", TRUE,
 												 "view-time", TRUE,
 												 "view-date", TRUE,
-												 "view-method", TRUE,
 												 "view-ratio", TRUE,
-												 "view-length", TRUE,
-												 "view-crc32", TRUE,
 												 NULL);
 	
 	return LXA_ARCHIVE_SUPPORT(support);

Modified: xarchiver/branches/xarchiver-psybsd/libxarchiver/archive-support.h
===================================================================
--- xarchiver/branches/xarchiver-psybsd/libxarchiver/archive-support.h	2006-10-06 12:37:05 UTC (rev 23297)
+++ xarchiver/branches/xarchiver-psybsd/libxarchiver/archive-support.h	2006-10-06 13:11:01 UTC (rev 23298)
@@ -54,6 +54,8 @@
  *
  * lxa_archive_support_add()
  * lxa_archive_support_extract()
+ * lxa_archive_support_remove()
+ * lxa_archive_support_refresh()
  * 
  * should be called instead.
  */

Modified: xarchiver/branches/xarchiver-psybsd/libxarchiver/libxarchiver.c
===================================================================
--- xarchiver/branches/xarchiver-psybsd/libxarchiver/libxarchiver.c	2006-10-06 12:37:05 UTC (rev 23297)
+++ xarchiver/branches/xarchiver-psybsd/libxarchiver/libxarchiver.c	2006-10-06 13:11:01 UTC (rev 23298)
@@ -37,11 +37,11 @@
 	lxa_mime_database = thunar_vfs_mime_database_get_default();
 
 	lxa_register_support(lxa_archive_support_zip_new());
+	lxa_register_support(lxa_archive_support_gnu_tar_new());
 	/* TODO: Implement right commands in unrar
 	lxa_register_support(lxa_archive_support_rar_new());
 	lxa_register_support(lxa_archive_support_unrar_new());
 	*/
-	lxa_register_support(lxa_archive_support_gnu_tar_new());
 }
 
 void

Modified: xarchiver/branches/xarchiver-psybsd/src/archive_store.c
===================================================================
--- xarchiver/branches/xarchiver-psybsd/src/archive_store.c	2006-10-06 12:37:05 UTC (rev 23297)
+++ xarchiver/branches/xarchiver-psybsd/src/archive_store.c	2006-10-06 13:11:01 UTC (rev 23298)
@@ -33,7 +33,7 @@
 xa_archive_tree_model_init(GtkTreeModelIface *tm_interface);
 
 static void
-xa_archive_tree_sartable_init(GtkTreeSortableIface *ts_interface);
+xa_archive_tree_sortable_init(GtkTreeSortableIface *ts_interface);
 
 /* properties */
 enum {
@@ -71,6 +71,8 @@
 xa_archive_store_iter_nth_child (GtkTreeModel *tree_model, GtkTreeIter *iter, GtkTreeIter *parent, gint n);
 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);
 
 static void
 cb_xa_archive_store_row_activated(GtkTreeView *treeview, GtkTreePath *path, GtkTreeViewColumn *column, gpointer user_data);
@@ -80,8 +82,13 @@
 xa_archive_store_get_sort_column_id(GtkTreeSortable *sortable, gint *sort_col_id, GtkSortType *order);
 static void
 xa_archive_store_set_sort_column_id(GtkTreeSortable *sortable, gint sort_col_id, GtkSortType order);
+static void
+xa_archive_store_set_sort_func(GtkTreeSortable *, gint, GtkTreeIterCompareFunc, gpointer, GtkDestroyNotify);
+static void
+xa_archive_store_set_default_sort_func(GtkTreeSortable *, GtkTreeIterCompareFunc, gpointer, GtkDestroyNotify);
+static gboolean
+xa_archive_store_has_default_sort_func(GtkTreeSortable *);
 
-
 GType
 xa_archive_store_get_type()
 {
@@ -116,6 +123,16 @@
 	};
 
 	g_type_add_interface_static (xa_archive_store_type, GTK_TYPE_TREE_MODEL, &tree_model_info);
+
+	static const GInterfaceInfo tree_sort_info =
+	{
+		(GInterfaceInitFunc) xa_archive_tree_sortable_init,
+			NULL,
+			NULL
+	};
+
+	g_type_add_interface_static (xa_archive_store_type, GTK_TYPE_TREE_SORTABLE, &tree_sort_info);
+
 	return xa_archive_store_type;
 }
 
@@ -137,6 +154,16 @@
 }
 
 static void
+xa_archive_tree_sortable_init(GtkTreeSortableIface *iface)
+{
+	iface->get_sort_column_id    = xa_archive_store_get_sort_column_id;
+	iface->set_sort_column_id    = xa_archive_store_set_sort_column_id;
+	iface->set_sort_func         = xa_archive_store_set_sort_func;        	/*NOT SUPPORTED*/
+	iface->set_default_sort_func = xa_archive_store_set_default_sort_func;	/*NOT SUPPORTED*/
+	iface->has_default_sort_func = xa_archive_store_has_default_sort_func;
+}
+
+static void
 xa_archive_store_init(XAArchiveStore *as)
 {
 	as->stamp = g_random_int();
@@ -146,6 +173,9 @@
 	as->props._show_up_dir = TRUE;
 	as->up_entry.filename = "..";
 	as->up_entry.props = NULL;
+	as->sort_column = GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID;
+	as->sort_order = GTK_SORT_ASCENDING;
+	as->sort_list = NULL;
 }
 
 static void
@@ -528,6 +558,55 @@
 }
 
 
+static gboolean
+xa_archive_store_get_sort_column_id(GtkTreeSortable *sortable, gint *sort_col_id, GtkSortType *order)
+{
+	g_return_val_if_fail(XA_IS_ARCHIVE_STORE(sortable), FALSE);
+
+	XAArchiveStore *store = XA_ARCHIVE_STORE(sortable);
+
+	if(sort_col_id)
+		*sort_col_id = store->sort_column;
+
+	if(order)
+		*order = store->sort_order;
+
+	return store->sort_order >= 0;
+}
+
+static void
+xa_archive_store_set_sort_column_id(GtkTreeSortable *sortable, gint sort_col_id, GtkSortType order)
+{
+	g_return_if_fail(XA_IS_ARCHIVE_STORE(sortable));
+
+	XAArchiveStore *store = XA_ARCHIVE_STORE(sortable);
+
+	if(store->sort_column == sort_col_id && store->sort_order == order)
+		return;
+
+	store->sort_column = sort_col_id;
+	store->sort_order = order;
+}
+
+static void
+xa_archive_store_set_sort_func(GtkTreeSortable *s, gint i, GtkTreeIterCompareFunc f, gpointer p, GtkDestroyNotify d)
+{
+	g_warning("%s is not supported by the XAArchiveStore model", __FUNCTION__);
+}
+
+static void
+xa_archive_store_set_default_sort_func(GtkTreeSortable *s, GtkTreeIterCompareFunc f, gpointer p, GtkDestroyNotify d)
+{
+	g_warning("%s is not supported by the XAArchiveStore model", __FUNCTION__);
+}
+
+static gboolean
+xa_archive_store_has_default_sort_func(GtkTreeSortable *s)
+{
+	return TRUE;
+}
+
+
 GtkTreeModel *
 xa_archive_store_new(LXAArchive *archive, gboolean show_icons, gboolean show_up_dir)
 {
@@ -573,53 +652,20 @@
 }
 
 static void
-cb_xa_archive_store_row_activated(GtkTreeView *treeview, GtkTreePath *path, GtkTreeViewColumn *column, gpointer user_data)
+xa_archive_store_refresh(XAArchiveStore *store, gint prev_size)
 {
-	g_return_if_fail(XA_IS_ARCHIVE_STORE(user_data));	
-
-	XAArchiveStore *store = XA_ARCHIVE_STORE(user_data);
 	LXAArchive *archive = store->archive;
 	LXAEntry *entry = store->current_entry->data;
 
 	g_return_if_fail(archive);
 	g_return_if_fail(entry);
 
-	gint *indices = gtk_tree_path_get_indices(path);
-	gint depth = gtk_tree_path_get_depth(path) - 1;
-
-	/* only support list: depth is always 0 */
-	g_return_if_fail(depth == 0);
-
-	gint prev_size = lxa_entry_children_length(entry);
-	gint new_size = 0;
-	gint index = indices[depth];
+	gint new_size = lxa_entry_children_length(entry);
 	gint i = 0;
+	gint index = 0;
 	GtkTreePath *path_ = NULL;
 	GtkTreeIter iter;
 
-	if(store->props._show_up_dir && &archive->root_entry != entry)
-	{
-		prev_size++;
-		index--;
-	}
-
-	if(index == -1)
-	{
-		store->current_entry = g_slist_delete_link(store->current_entry, store->current_entry);
-		entry = store->current_entry->data;
-	}
-	else
-	{
-		entry = lxa_entry_children_nth_data(entry, index);
-
-		g_return_if_fail(entry);
-		g_return_if_fail(entry->is_folder);
-
-		store->current_entry = g_slist_prepend(store->current_entry, entry);
-	}
-
-	new_size = lxa_entry_children_length(entry);
-
 	if(store->props._show_up_dir && &archive->root_entry != entry) { 
 		path_ = gtk_tree_path_new();
 		gtk_tree_path_append_index(path_, 0);
@@ -666,6 +712,76 @@
 	}
 }
 
+static void
+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);
+	LXAArchive *archive = store->archive;
+	LXAEntry *entry = store->current_entry->data;
+
+	g_return_if_fail(archive);
+	g_return_if_fail(entry);
+
+	gint *indices = gtk_tree_path_get_indices(path);
+	gint depth = gtk_tree_path_get_depth(path) - 1;
+
+	/* only support list: depth is always 0 */
+	g_return_if_fail(depth == 0);
+
+	gint prev_size = lxa_entry_children_length(entry);
+	gint index = indices[depth];
+
+	if(store->props._show_up_dir && &archive->root_entry != entry)
+	{
+		prev_size++;
+		index--;
+	}
+
+	if(index == -1)
+	{
+		store->current_entry = g_slist_delete_link(store->current_entry, store->current_entry);
+		entry = store->current_entry->data;
+	}
+	else
+	{
+		entry = lxa_entry_children_nth_data(entry, index);
+
+		g_return_if_fail(entry);
+		g_return_if_fail(entry->is_folder);
+
+		store->current_entry = g_slist_prepend(store->current_entry, entry);
+	}
+
+	xa_archive_store_refresh(store, prev_size);
+}
+
+void
+xa_archive_store_go_up(XAArchiveStore *store)
+{
+	LXAArchive *archive = store->archive;
+	LXAEntry *entry = store->current_entry->data;
+
+	g_return_if_fail(archive);
+	g_return_if_fail(entry);
+
+	gint prev_size = lxa_entry_children_length(entry);
+
+	if(store->props._show_up_dir && &archive->root_entry != entry)
+	{
+		prev_size++;
+	}
+
+	store->current_entry = g_slist_delete_link(store->current_entry, store->current_entry);
+	entry = store->current_entry->data;
+
+	// TODO: signal or something
+	g_return_if_fail(entry);
+
+	xa_archive_store_refresh(store, prev_size);
+}
+
 /*
 gboolean
 xa_archive_store_add_item(gpointer key, gpointer value, gpointer data)

Modified: xarchiver/branches/xarchiver-psybsd/src/archive_store.h
===================================================================
--- xarchiver/branches/xarchiver-psybsd/src/archive_store.h	2006-10-06 12:37:05 UTC (rev 23297)
+++ xarchiver/branches/xarchiver-psybsd/src/archive_store.h	2006-10-06 13:11:01 UTC (rev 23298)
@@ -47,6 +47,9 @@
 	LXAArchive *archive;
 	GSList *current_entry;
 	LXAEntry up_entry;
+	gint sort_column;
+	GtkSortType sort_order;
+	LXAEntry **sort_list;
 	struct {
 		gboolean _show_icons;
 		gboolean _show_up_dir;
@@ -69,5 +72,7 @@
 xa_archive_store_set_contents(XAArchiveStore *archive_store, LXAArchive *archive);
 void
 xa_archive_store_connect_treeview(XAArchiveStore *store, GtkTreeView *treeview);
+void
+xa_archive_store_go_up(XAArchiveStore *store);
 
 #endif /* __XARCHIVER_ARCHIVE_STORE_H__ */

Modified: xarchiver/branches/xarchiver-psybsd/src/main_window.c
===================================================================
--- xarchiver/branches/xarchiver-psybsd/src/main_window.c	2006-10-06 12:37:05 UTC (rev 23297)
+++ xarchiver/branches/xarchiver-psybsd/src/main_window.c	2006-10-06 13:11:01 UTC (rev 23298)
@@ -222,8 +222,7 @@
 	g_signal_connect(G_OBJECT(window->toolbar.tool_item_open), "clicked", G_CALLBACK(cb_xa_main_open_archive), window);
 
 /* Action pane */
-	tmp_image = xa_main_window_find_image("add.png", GTK_ICON_SIZE_LARGE_TOOLBAR);
-	window->toolbar.tool_item_add = gtk_tool_button_new(tmp_image, _("Add"));
+	window->toolbar.tool_item_add = gtk_tool_button_new_from_stock("gtk-go-up");
 	gtk_widget_set_sensitive(GTK_WIDGET(window->toolbar.tool_item_add), FALSE);
 
 	tmp_image = xa_main_window_find_image("extract.png", GTK_ICON_SIZE_LARGE_TOOLBAR);
@@ -488,21 +487,8 @@
 void
 cb_xa_main_add_to_archive(GtkWidget *widget, gpointer userdata)
 {
-	GtkWidget *dialog = NULL;
-	gint result = 0;
 	XAMainWindow *window = XA_MAIN_WINDOW(userdata);
-	LXAArchiveSupport *lp_support = NULL;
-
-	lp_support = lxa_get_support_for_mime(window->lp_xa_archive->mime);
-
-	dialog = xa_add_dialog_new(lp_support, window->lp_xa_archive, FALSE);
-	result = gtk_dialog_run (GTK_DIALOG (dialog) );
-	if(result == GTK_RESPONSE_OK)
-	{
-		gtk_widget_hide(GTK_WIDGET(dialog));
-	}
-	gtk_widget_destroy (GTK_WIDGET (dialog) );
-
+	xa_archive_store_go_up(XA_ARCHIVE_STORE(window->treemodel));
 }
 
 void



More information about the Xfce4-commits mailing list