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

Stephan Arts stephan at xfce.org
Tue Oct 17 13:10:41 UTC 2006


Author: stephan
Date: 2006-10-17 13:10:39 +0000 (Tue, 17 Oct 2006)
New Revision: 23443

Modified:
   xarchiver/branches/xarchiver-psybsd/configure.in.in
   xarchiver/branches/xarchiver-psybsd/libxarchiver/archive.c
   xarchiver/branches/xarchiver-psybsd/src/Makefile.am
   xarchiver/branches/xarchiver-psybsd/src/archive_store.c
   xarchiver/branches/xarchiver-psybsd/src/main_window.c
   xarchiver/branches/xarchiver-psybsd/src/navigation_bar.c
   xarchiver/branches/xarchiver-psybsd/src/navigation_bar.h
   xarchiver/branches/xarchiver-psybsd/src/path_bar.c
   xarchiver/branches/xarchiver-psybsd/src/path_bar.h
   xarchiver/branches/xarchiver-psybsd/src/tool_bar.c
Log:
It can now be tweaked. :p



Modified: xarchiver/branches/xarchiver-psybsd/configure.in.in
===================================================================
--- xarchiver/branches/xarchiver-psybsd/configure.in.in	2006-10-17 09:11:51 UTC (rev 23442)
+++ xarchiver/branches/xarchiver-psybsd/configure.in.in	2006-10-17 13:10:39 UTC (rev 23443)
@@ -63,6 +63,26 @@
     AC_HELP_STRING([--disable-libxfce4util],
                    [Disable the use of libxfce4util)]))
 
+AC_ARG_ENABLE([pathbar],
+   [AC_HELP_STRING([--disable-pathbar], 
+        [Do not compile support for a PathBar (default=enabled)])],
+        [xa_pathbar=$enableval], 
+        [xa_pathbar=yes])
+if test "$xa_pathbar" = "yes"; then
+	AC_DEFINE([ENABLE_PATHBAR], [1], [Define if we should include pathbar support])
+fi
+AM_CONDITIONAL([ENABLE_PATHBAR], [test "$xa_pathbar" = "yes"])
+
+AC_ARG_ENABLE([toolbar],
+   [AC_HELP_STRING([--disable-toolbar], 
+        [Do not compile support for a ToolBar (default=enabled)])],
+        [xa_toolbar=$enableval], 
+        [xa_toolbar=yes])
+if test "$xa_toolbar" = "yes"; then
+	AC_DEFINE([ENABLE_TOOLBAR], [1], [Define if we should include toolbar support])
+fi
+AM_CONDITIONAL([ENABLE_TOOLBAR], [test "$xa_toolbar" = "yes"])
+
 dnl check for debugging support
 XDT_FEATURE_DEBUG
 

Modified: xarchiver/branches/xarchiver-psybsd/libxarchiver/archive.c
===================================================================
--- xarchiver/branches/xarchiver-psybsd/libxarchiver/archive.c	2006-10-17 09:11:51 UTC (rev 23442)
+++ xarchiver/branches/xarchiver-psybsd/libxarchiver/archive.c	2006-10-17 13:10:39 UTC (rev 23443)
@@ -108,7 +108,7 @@
 lxa_archive_init(LXAArchive *archive)
 {
 	archive->root_entry = g_new0(LXAEntry, 1);
-	archive->root_entry->filename = g_strdup("/");
+	archive->root_entry->filename = NULL;
 	archive->root_entry->children = NULL;
 }
 
@@ -152,9 +152,9 @@
 		archive->mime = lxa_mime_get_mime_type_for_file(archive->path);
 	else
 		archive->mime = g_strdup(mime);
-	
+#ifdef DEBUG	
 	g_debug("Mime-type: %s", archive->mime);
-	
+#endif
 	if(!lxa_get_support_for_mime(archive->mime))
 	{
 		g_object_unref(archive);
@@ -197,12 +197,27 @@
 	LXAEntry *tmp_entry = NULL, *parent = NULL;
 	path_items = g_strsplit_set(path, "/\n", -1);
 	parent = archive->root_entry;
-	for(i = 0; path_items[i]?strlen(path_items[i]):0;i++)
+	if(path_items[i]?strlen(path_items[i])==0:0)
 	{
+		/* has leading / */
 		tmp_entry = lxa_entry_get_child(parent, path_items[i]);
 		if(!tmp_entry)
 		{
 			tmp_entry = g_new0(LXAEntry, 1);
+			tmp_entry->filename = g_strdup("/");
+			lxa_archive_entry_add_child(archive, parent, tmp_entry);
+			if(!parent->mime_type)
+				parent->mime_type = g_strdup("inode/directory");
+		}
+		parent = tmp_entry;
+		++i;
+	}
+	for(; path_items[i]?strlen(path_items[i]):0;++i)
+	{
+		tmp_entry = lxa_entry_get_child(parent, path_items[i]);
+		if(!tmp_entry)
+		{
+			tmp_entry = g_new0(LXAEntry, 1);
 			tmp_entry->filename = g_strdup(path_items[i]);
 			lxa_archive_entry_add_child(archive, parent, tmp_entry);
 			if(!parent->mime_type)

Modified: xarchiver/branches/xarchiver-psybsd/src/Makefile.am
===================================================================
--- xarchiver/branches/xarchiver-psybsd/src/Makefile.am	2006-10-17 09:11:51 UTC (rev 23442)
+++ xarchiver/branches/xarchiver-psybsd/src/Makefile.am	2006-10-17 13:10:39 UTC (rev 23443)
@@ -1,11 +1,24 @@
 bin_PROGRAMS = xarchiver
 
+if ENABLE_PATHBAR
+PATHBAR_FILES = path_bar.c path_bar.h
+else
+PATHBAR_FILES = 
+endif
+
+if ENABLE_TOOLBAR
+TOOLBAR_FILES = tool_bar.c tool_bar.h
+else
+TOOLBAR_FILES =
+endif
+
+
 xarchiver_SOURCES = \
 	main.c main.h \
 	main_window.c main_window.h \
 	navigation_bar.c navigation_bar.h \
-	tool_bar.c tool_bar.h \
-	path_bar.c path_bar.h \
+	$(TOOLBAR_FILES) \
+	$(PATHBAR_FILES) \
 	settings.c settings.h \
 	archive_store.c archive_store.h \
 	preferences_dialog.c preferences_dialog.h \

Modified: xarchiver/branches/xarchiver-psybsd/src/archive_store.c
===================================================================
--- xarchiver/branches/xarchiver-psybsd/src/archive_store.c	2006-10-17 09:11:51 UTC (rev 23442)
+++ xarchiver/branches/xarchiver-psybsd/src/archive_store.c	2006-10-17 13:10:39 UTC (rev 23443)
@@ -624,11 +624,6 @@
 	g_return_val_if_fail(archive, FALSE);
 	g_return_val_if_fail(entry, FALSE);
 	g_return_val_if_fail(iter, FALSE);
-	if(iter->stamp != store->stamp)
-	{
-		/* g_debug("stamp: %d pointer: %x", iter->stamp, iter->user_data); */
-		return FALSE;
-	}
 
 	/* only support lists: parent is always NULL */
 	g_return_val_if_fail(parent == NULL, FALSE);
@@ -1166,13 +1161,11 @@
 	gchar *lastfile = NULL;
 	gint namelen = 0;
 
-	if(!i)
-		return NULL;
+	/* we don't want to include de archive rootentry */
+	if(i<=1)
+		return g_strdup("");
 
-	i++;
-	
 	buf = g_new(gchar*, i);
-	buf[0] = "";
 	i--;
 	buf[i] = NULL;
 
@@ -1199,6 +1192,11 @@
 		}
 	}
 
+	if(buf[0][0] == '/')
+	{
+		buf[0] = "";
+	}
+
 	path = g_strjoinv("/", buf);
 
 	g_free(lastfile);
@@ -1214,8 +1212,12 @@
 
 	GSList *iter = store->current_entry;
 	GSList *path = NULL;
-	
-	while(iter)
+
+	if(!iter)
+		return NULL;
+
+	/* we don't want to include de archive rootentry */
+	while(iter->next)
 	{
 		path = g_slist_prepend(path, g_strdup(((LXAEntry*)iter->data)->filename));
 		iter = iter->next;
@@ -1224,17 +1226,6 @@
 	return path;
 }
 
-gchar *
-xa_archive_store_get_basename(XAArchiveStore *store)
-{
-	g_return_val_if_fail(store, NULL);
-
-	if(!store->current_entry)
-		return NULL;
-
-	return g_strdup(((LXAEntry*)store->current_entry->data)->filename);
-}
-
 gboolean
 xa_archive_store_set_pwd(XAArchiveStore *store, const gchar *path)
 {
@@ -1261,6 +1252,11 @@
 	if(store->props._show_up_dir && store->archive->root_entry != store->current_entry->data)
 		prev_size++;
 
+	if(path[0] == '/' && lxa_entry_get_child(store->archive->root_entry, "/"))
+	{
+		iter[0] = strdup("/");
+	}
+
 	while(*iter)
 	{
 		if((*iter)[0])

Modified: xarchiver/branches/xarchiver-psybsd/src/main_window.c
===================================================================
--- xarchiver/branches/xarchiver-psybsd/src/main_window.c	2006-10-17 09:11:51 UTC (rev 23442)
+++ xarchiver/branches/xarchiver-psybsd/src/main_window.c	2006-10-17 13:10:39 UTC (rev 23443)
@@ -31,8 +31,15 @@
 #include "settings.h"
 #include "archive_store.h"
 #include "navigation_bar.h"
+
+#ifdef ENABLE_TOOLBAR
 #include "tool_bar.h"
+#endif /* ENABLE_TOOLBAR */
+
+#ifdef ENABLE_PATHBAR
 #include "path_bar.h"
+#endif /* ENABLE_PATHBAR */
+
 #include "main_window.h"
 #include "new_dialog.h"
 #include "extract_dialog.h"
@@ -127,10 +134,14 @@
 		xa_settings_write_entry(window->settings, "NavigationBar", "None");
 	else
 	{
+#ifdef ENABLE_PATHBAR
 		if(G_OBJECT_TYPE(window->navigationbar) == XA_TYPE_PATH_BAR)
 			xa_settings_write_entry(window->settings, "NavigationBar", "PathBar");
+#endif
+#ifdef ENABLE_TOOLBAR
 		if(G_OBJECT_TYPE(window->navigationbar) == XA_TYPE_TOOL_BAR)
 			xa_settings_write_entry(window->settings, "NavigationBar", "ToolBar");
+#endif
 	}
 	xa_settings_save(window->settings);
 }
@@ -280,14 +291,16 @@
 
 	xa_settings_set_group(window->settings, "Global");
 	nav_bar = xa_settings_read_entry(window->settings, "NavigationBar", "PathBar");
+	window->navigationbar = NULL;
+#ifdef ENABLE_TOOLBAR
 	if(!strcmp(nav_bar, "ToolBar"))
 		window->navigationbar = xa_tool_bar_new(NULL); 
+#endif
+#ifdef ENABLE_PATHBAR
 	if(!strcmp(nav_bar, "PathBar"))
 		window->navigationbar = xa_path_bar_new(NULL);
-	if(!strcmp(nav_bar, "None"))
-		window->navigationbar = NULL;
+#endif
 
-
 	if(window->navigationbar)
 	{
 		gtk_container_set_border_width(GTK_CONTAINER(window->navigationbar), 3);
@@ -298,6 +311,7 @@
 	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(window->scrollwindow), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
 
 	window->treeview = gtk_tree_view_new();
+	gtk_tree_view_set_rules_hint(window->treeview, TRUE);
 
 	gtk_tree_view_set_enable_search(GTK_TREE_VIEW(window->treeview), TRUE);
 	GtkTreeSelection *selection = gtk_tree_view_get_selection ( GTK_TREE_VIEW (window->treeview) );

Modified: xarchiver/branches/xarchiver-psybsd/src/navigation_bar.c
===================================================================
--- xarchiver/branches/xarchiver-psybsd/src/navigation_bar.c	2006-10-17 09:11:51 UTC (rev 23442)
+++ xarchiver/branches/xarchiver-psybsd/src/navigation_bar.c	2006-10-17 13:10:39 UTC (rev 23443)
@@ -24,7 +24,11 @@
 #include "archive_store.h"
 #include "navigation_bar.h"
 
+#ifndef XA_NAVIGATION_BAR_MAX_HISTORY
+#define XA_NAVIGATION_BAR_MAX_HISTORY 10
+#endif
 
+
 static void
 xa_navigation_bar_class_init(XANavigationBarClass *archive_class);
 
@@ -84,7 +88,7 @@
 		"",
 		0,
 		G_MAXUINT,
-		10,
+		XA_NAVIGATION_BAR_MAX_HISTORY,
 		G_PARAM_READWRITE);
 	g_object_class_install_property(object_class, XA_NAVIGATION_BAR_NAV_HISTORY, pspec);
 }
@@ -93,7 +97,7 @@
 xa_navigation_bar_init(XANavigationBar *navigation_bar)
 {
 	navigation_bar->_cb_pwd_changed = (GCallback)cb_xa_navigation_bar_pwd_changed;
-	navigation_bar->max_history = 10;
+	navigation_bar->max_history = XA_NAVIGATION_BAR_MAX_HISTORY;
 	navigation_bar->pwd = NULL;
 	navigation_bar->history = NULL;
 }
@@ -134,7 +138,7 @@
 }
 
 void
-xa_navigation_bar_history_push(XANavigationBar *nav_bar, gchar *path)
+xa_navigation_bar_history_push(XANavigationBar *nav_bar, const gchar *path)
 {
 	nav_bar->history = g_list_insert_before(nav_bar->history, nav_bar->pwd, g_strdup(path));
 	if(!nav_bar->pwd)

Modified: xarchiver/branches/xarchiver-psybsd/src/navigation_bar.h
===================================================================
--- xarchiver/branches/xarchiver-psybsd/src/navigation_bar.h	2006-10-17 09:11:51 UTC (rev 23442)
+++ xarchiver/branches/xarchiver-psybsd/src/navigation_bar.h	2006-10-17 13:10:39 UTC (rev 23443)
@@ -61,7 +61,7 @@
 
 GType      xa_navigation_bar_get_type();
 GtkWidget *xa_navigation_bar_new();
-void       xa_navigation_bar_history_push(XANavigationBar *nav_bar, gchar *path);
+void       xa_navigation_bar_history_push(XANavigationBar *nav_bar, const gchar *path);
 void       xa_navigation_bar_set_store(XANavigationBar *navigation_bar, XAArchiveStore *store);
 gint       xa_navigation_bar_history_get_length(XANavigationBar *nav_bar);
 gboolean   xa_navigation_bar_history_back(XANavigationBar *nav_bar);

Modified: xarchiver/branches/xarchiver-psybsd/src/path_bar.c
===================================================================
--- xarchiver/branches/xarchiver-psybsd/src/path_bar.c	2006-10-17 09:11:51 UTC (rev 23442)
+++ xarchiver/branches/xarchiver-psybsd/src/path_bar.c	2006-10-17 13:10:39 UTC (rev 23443)
@@ -137,7 +137,15 @@
 	gtk_container_add (GTK_CONTAINER (path_bar->right_button), arrow);
 	gtk_widget_show (arrow);
 
-	path_bar->path_button = NULL;
+	path_bar->home_button = GTK_BUTTON(gtk_radio_button_new(NULL));
+	gtk_container_add(GTK_CONTAINER(path_bar), GTK_WIDGET(path_bar->home_button));
+	g_signal_connect(G_OBJECT(path_bar->home_button), "clicked", (GCallback)cb_xa_path_bar_path_button_clicked, path_bar);
+	gtk_toggle_button_set_mode(GTK_TOGGLE_BUTTON(path_bar->home_button), FALSE);
+	gtk_widget_show(GTK_WIDGET(path_bar->home_button));
+	gtk_widget_ref(GTK_WIDGET(path_bar->home_button));
+
+
+	path_bar->path_button = g_slist_prepend(NULL, path_bar->home_button);
 	path_bar->first_button = NULL;
 
 	gtk_widget_ref(GTK_WIDGET(path_bar));
@@ -233,11 +241,11 @@
 	if(path_bar->path_button && path_bar->path_button->next)
 	{
 		gtk_widget_get_child_requisition(GTK_WIDGET(path_bar->left_button), &child_requisition);
-		requisition->width += child_requisition.width + spacing;
 		requisition->height = MAX(child_requisition.height, requisition->height);
 		gtk_widget_get_child_requisition(GTK_WIDGET(path_bar->right_button), &child_requisition);
-		requisition->width += child_requisition.width;
 		requisition->height = MAX(child_requisition.height, requisition->height);
+
+		requisition->width += (MIN(requisition->height *2/3+5, requisition->height) + spacing) * 2;
 	}
 
 	requisition->width += GTK_CONTAINER(path_bar)->border_width * 2;
@@ -287,12 +295,9 @@
 	/* scroll arrows are needed */
 	if(width > allocation->width)
 	{
-		gtk_widget_get_child_requisition(GTK_WIDGET(path_bar->left_button), &child_requisition);
-		left_width = child_requisition.width;
-		gtk_widget_get_child_requisition(GTK_WIDGET(path_bar->right_button), &child_requisition);
-		right_width = child_requisition.width;
+		right_width = left_width = MIN((allocation->height-(border_width*2))*2/3+5, (allocation->height-(border_width*2)));
 
-		width = left_width + spacing + right_width;
+		width = border_width + left_width + spacing + right_width + border_width;
 
 		if(path_bar->first_button)
 		{
@@ -411,12 +416,15 @@
 {
 	GSList *path = xa_archive_store_get_pwd_list(store);
 	GSList *iter = path;
-	GSList *buttons = path_bar->path_button;
+	GSList *buttons = path_bar->path_button->next;
 	GSList *lastbutton = NULL;
-	GtkRadioButton *button = NULL;
-	const gchar *label = NULL;
+	GtkRadioButton *button = GTK_RADIO_BUTTON(path_bar->home_button);
+	const gchar *label = xa_archive_store_get_pwd(store);
 	gint cmp = 0;
 
+	xa_navigation_bar_history_push(XA_NAVIGATION_BAR(path_bar), label);
+	g_free((gchar*)label);
+
 	while(iter && buttons)
 	{
 		button = GTK_RADIO_BUTTON(buttons->data);
@@ -476,20 +484,29 @@
 static void
 cb_xa_path_bar_path_button_clicked(GtkRadioButton *button, XAPathBar *path_bar)
 {
-	gchar *path = g_strdup("/");
-	gchar *folder = NULL;
+	gchar *path = g_strdup("");
+	gchar *prev = NULL;
+	const gchar *folder = NULL;
 	GSList *iter = path_bar->path_button;
 
 	while(iter->data != (gpointer)button)
 	{
 		iter = iter->next;
-		folder = path;
-		path = g_strconcat(path, gtk_button_get_label(GTK_BUTTON(iter->data)), "/", NULL);
-		g_free(folder);
+		prev = path;
+		folder = gtk_button_get_label(GTK_BUTTON(iter->data));
+		if(folder[0] == '/')
+			path = g_strconcat(path, folder, NULL);
+		else
+			path = g_strconcat(path, folder, "/", NULL);
+		g_free(prev);
 	}
 
 	xa_archive_store_set_pwd_silent(XA_NAVIGATION_BAR(path_bar)->store, path);
 	g_free(path);
+
+	path = xa_archive_store_get_pwd(XA_NAVIGATION_BAR(path_bar)->store);
+	xa_navigation_bar_history_push(XA_NAVIGATION_BAR(path_bar), path);
+	g_free(path);
 }
 
 static void

Modified: xarchiver/branches/xarchiver-psybsd/src/path_bar.h
===================================================================
--- xarchiver/branches/xarchiver-psybsd/src/path_bar.h	2006-10-17 09:11:51 UTC (rev 23442)
+++ xarchiver/branches/xarchiver-psybsd/src/path_bar.h	2006-10-17 13:10:39 UTC (rev 23443)
@@ -47,6 +47,7 @@
 	XANavigationBar parent;
 	GtkButton *left_button;
 	GtkButton *right_button;
+	GtkButton *home_button;
 	GSList *path_button;
 	GSList *first_button;
 };

Modified: xarchiver/branches/xarchiver-psybsd/src/tool_bar.c
===================================================================
--- xarchiver/branches/xarchiver-psybsd/src/tool_bar.c	2006-10-17 09:11:51 UTC (rev 23442)
+++ xarchiver/branches/xarchiver-psybsd/src/tool_bar.c	2006-10-17 13:10:39 UTC (rev 23443)
@@ -219,6 +219,9 @@
 	if(tool_bar->bar && GTK_WIDGET_VISIBLE(tool_bar->bar))
 		gtk_widget_size_request(GTK_WIDGET(tool_bar->bar), requisition);
 
+	if(requisition->width < 400)
+		requisition->width = 400;
+
 	widget->requisition = *requisition;
 }
 



More information about the Xfce4-commits mailing list