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

Stephan Arts stephan at xfce.org
Mon Sep 25 14:27:02 UTC 2006


Author: stephan
Date: 2006-09-25 14:27:01 +0000 (Mon, 25 Sep 2006)
New Revision: 23205

Modified:
   xarchiver/branches/xarchiver-psybsd/libxarchiver/archive.c
   xarchiver/branches/xarchiver-psybsd/libxarchiver/archive.h
   xarchiver/branches/xarchiver-psybsd/src/main.c
   xarchiver/branches/xarchiver-psybsd/src/main_window.c
   xarchiver/branches/xarchiver-psybsd/src/main_window.h
Log:
Added icons in treeview (this is just a proof-of-concept for now)



Modified: xarchiver/branches/xarchiver-psybsd/libxarchiver/archive.c
===================================================================
--- xarchiver/branches/xarchiver-psybsd/libxarchiver/archive.c	2006-09-25 13:23:21 UTC (rev 23204)
+++ xarchiver/branches/xarchiver-psybsd/libxarchiver/archive.c	2006-09-25 14:27:01 UTC (rev 23205)
@@ -184,6 +184,10 @@
 	{
 		tmp_entry = g_new0(LXAEntry, 1);
 		tmp_entry->filename = g_strdup(path_items[0]);
+		if(path[strlen(path)-1] == '/')
+			tmp_entry->is_folder = TRUE;
+		else
+			tmp_entry->is_folder = FALSE;
 		archive->root_entry.children = g_slist_prepend(archive->root_entry.children, tmp_entry);
 		tmp_list = archive->root_entry.children;
 	}
@@ -194,6 +198,10 @@
 		{
 			tmp_entry = g_new0(LXAEntry, 1);
 			tmp_entry->filename = g_strdup(path_items[i]);
+			if(path[strlen(path)-1] == '/')
+				tmp_entry->is_folder = TRUE;
+			else
+				tmp_entry->is_folder = FALSE;
 			((LXAEntry *)tmp_list->data)->children = g_slist_prepend(((LXAEntry *)tmp_list->data)->children, tmp_entry);
 			tmp_list_children = ((LXAEntry *)tmp_list->data)->children;
 		}

Modified: xarchiver/branches/xarchiver-psybsd/libxarchiver/archive.h
===================================================================
--- xarchiver/branches/xarchiver-psybsd/libxarchiver/archive.h	2006-09-25 13:23:21 UTC (rev 23204)
+++ xarchiver/branches/xarchiver-psybsd/libxarchiver/archive.h	2006-09-25 14:27:01 UTC (rev 23205)
@@ -34,6 +34,7 @@
 typedef struct {
 	gchar *filename;
 	GSList *children;
+	gboolean is_folder;
 	gpointer props;
 } LXAEntry;
 

Modified: xarchiver/branches/xarchiver-psybsd/src/main.c
===================================================================
--- xarchiver/branches/xarchiver-psybsd/src/main.c	2006-09-25 13:23:21 UTC (rev 23204)
+++ xarchiver/branches/xarchiver-psybsd/src/main.c	2006-09-25 14:27:01 UTC (rev 23205)
@@ -107,7 +107,7 @@
 	GtkWidget *main_window = NULL;
 	LXAArchive *lp_archive;
 	LXAArchiveSupport *lpSupport;
-	GtkIconTheme *icon_theme = NULL;
+	GtkIconTheme *xa_icon_theme;
 	GError *cli_error = NULL;
 	gint i = 0;
 
@@ -233,14 +233,14 @@
 	if(!new_archive && !add_archive_path && !extract_archive && !extract_archive_path)
 	{
 		
-		icon_theme = gtk_icon_theme_get_default();
+		xa_icon_theme = gtk_icon_theme_get_default();
 		if(argc > 1)
 		{
 			opened_archives++;
 			for(i = 1; i < argc; i++)
 			{
 				/* Show main window */
-				main_window = xa_main_window_new(icon_theme);
+				main_window = xa_main_window_new(xa_icon_theme);
 				g_signal_connect(G_OBJECT(main_window), "destroy", G_CALLBACK(cb_main_window_destroy), NULL);
 
 				if(!xa_main_window_open_archive(XA_MAIN_WINDOW(main_window), argv[i]))
@@ -259,7 +259,7 @@
 		} else
 		{
 			/* Show main window */
-			main_window = xa_main_window_new(icon_theme);
+			main_window = xa_main_window_new(xa_icon_theme);
 			g_signal_connect(G_OBJECT(main_window), "destroy", G_CALLBACK(cb_main_window_destroy), NULL);
 			gtk_widget_set_size_request(main_window, 500, 350);
 			gtk_widget_show_all(main_window);

Modified: xarchiver/branches/xarchiver-psybsd/src/main_window.c
===================================================================
--- xarchiver/branches/xarchiver-psybsd/src/main_window.c	2006-09-25 13:23:21 UTC (rev 23204)
+++ xarchiver/branches/xarchiver-psybsd/src/main_window.c	2006-09-25 14:27:01 UTC (rev 23205)
@@ -279,8 +279,11 @@
 
 	window = g_object_new(xa_main_window_get_type(),
 			"title", "Xarchiver " PACKAGE_VERSION,
+			"show-icons", TRUE,
 			NULL);
 	
+	XA_MAIN_WINDOW(window)->icon_theme = icon_theme;
+	
 	gtk_window_set_icon(GTK_WINDOW(window), icon);
 	
 
@@ -604,21 +607,53 @@
 					columns = columns->next;
 				}
 				g_list_free(columns);
-				liststore = gtk_list_store_newv(archive->column_number, archive->column_types); 
 	
-				for(x = 0; x < archive->column_number; x++)
+				if(main_window->props._show_icons)
 				{
-					switch(archive->column_types[x])
+					GType *column_types = g_new0(GType, archive->column_number+1);
+					for(x = 0; x < archive->column_number; x++)
 					{
-						case(G_TYPE_STRING):
-						case(G_TYPE_UINT64):
-							renderer = gtk_cell_renderer_text_new();
-							column = gtk_tree_view_column_new_with_attributes(archive->column_names[x], renderer, "text", x, NULL);
-							break;
+						column_types[x+1] = archive->column_types[x];
 					}
+					column_types[0] = G_TYPE_STRING;
+					liststore = gtk_list_store_newv(archive->column_number+1, column_types); 
+
+					renderer = gtk_cell_renderer_pixbuf_new();
+					column = gtk_tree_view_column_new_with_attributes("", renderer, "icon-name", 0, NULL);
 					gtk_tree_view_column_set_resizable(column, TRUE);
-					gtk_tree_view_column_set_sort_column_id(column, x);
+					gtk_tree_view_column_set_sort_column_id(column, 0);
 					gtk_tree_view_append_column(GTK_TREE_VIEW(main_window->treeview), column);
+					for(x = 0; x < archive->column_number; x++)
+					{
+						switch(archive->column_types[x])
+						{
+							case(G_TYPE_STRING):
+							case(G_TYPE_UINT64):
+								renderer = gtk_cell_renderer_text_new();
+								column = gtk_tree_view_column_new_with_attributes(archive->column_names[x], renderer, "text", x+1, NULL);
+								break;
+						}
+						gtk_tree_view_column_set_resizable(column, TRUE);
+						gtk_tree_view_column_set_sort_column_id(column, x+1);
+						gtk_tree_view_append_column(GTK_TREE_VIEW(main_window->treeview), column);
+					}
+				} else
+				{
+					liststore = gtk_list_store_newv(archive->column_number, archive->column_types); 
+					for(x = 0; x < archive->column_number; x++)
+					{
+						switch(archive->column_types[x])
+						{
+							case(G_TYPE_STRING):
+							case(G_TYPE_UINT64):
+								renderer = gtk_cell_renderer_text_new();
+								column = gtk_tree_view_column_new_with_attributes(archive->column_names[x], renderer, "text", x, NULL);
+								break;
+						}
+						gtk_tree_view_column_set_resizable(column, TRUE);
+						gtk_tree_view_column_set_sort_column_id(column, x);
+						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));
 				main_window->working_node = g_slist_prepend(main_window->working_node, &(archive->root_entry));
@@ -672,17 +707,29 @@
 
 	while(items)
 	{
+		i = 0;
 		gtk_list_store_append(GTK_LIST_STORE(liststore), &iter);
+		if(main_window->props._show_icons)
+		{
+			tmp_value = g_new0(GValue, 1);
+			tmp_value = g_value_init(tmp_value, G_TYPE_STRING);
+			if(((LXAEntry *)items->data)->is_folder)
+				g_value_set_string(tmp_value, "folder");
+			else
+				g_value_set_string(tmp_value, "unknown");
+			gtk_list_store_set_value(GTK_LIST_STORE(liststore), &iter, i, tmp_value);
+			i++;
+		}
 		tmp_value = g_new0(GValue, 1);
 		tmp_value = g_value_init(tmp_value, G_TYPE_STRING);
 		g_value_set_string(tmp_value, ((LXAEntry *)items->data)->filename);
-		gtk_list_store_set_value(GTK_LIST_STORE(liststore), &iter, 0, tmp_value);
+		gtk_list_store_set_value(GTK_LIST_STORE(liststore), &iter, i, tmp_value);
 
 		props = ((LXAEntry *)items->data)->props;
 		if(props)
 		{
 			props_iter = props;
-			for(i = 0; i < archive->column_number-1; i++)
+			for(; i < archive->column_number-1; i++)
 			{
 				tmp_value = g_new0(GValue, 1);
 				tmp_value = g_value_init(tmp_value, archive->column_types[i]);
@@ -710,7 +757,10 @@
 	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);
+		if(main_window->props._show_icons)
+			gtk_list_store_set_value(GTK_LIST_STORE(liststore), &iter, 1, main_window->parent_node);
+		else
+			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));
 }
@@ -726,7 +776,10 @@
 	GtkTreeModel *tree_model = gtk_tree_view_get_model(treeview);
 
 	gtk_tree_model_get_iter(tree_model, &iter, treepath);
-	gtk_tree_model_get_value(tree_model, &iter, 0, value);
+	if(main_window->props._show_icons)
+		gtk_tree_model_get_value(tree_model, &iter, 1, value);
+	else
+		gtk_tree_model_get_value(tree_model, &iter, 0, value);
 
 	const gchar *item_filename = g_value_get_string(value);
 	if(!strcmp(item_filename, "..")) /* pop */

Modified: xarchiver/branches/xarchiver-psybsd/src/main_window.h
===================================================================
--- xarchiver/branches/xarchiver-psybsd/src/main_window.h	2006-09-25 13:23:21 UTC (rev 23204)
+++ xarchiver/branches/xarchiver-psybsd/src/main_window.h	2006-09-25 14:27:01 UTC (rev 23205)
@@ -91,6 +91,7 @@
 		GtkToolItem *tool_item_remove;
 		GtkToolItem *tool_item_stop;
 	} toolbar;
+	GtkIconTheme *icon_theme;
 	LXAArchive *lp_xa_archive;
 	GValue *parent_node;
 	GSList *working_node;



More information about the Xfce4-commits mailing list