[Xfce4-commits] r27199 - xarchiver/trunk/src

Giuseppe Torelli colossus at xfce.org
Thu Jul 3 08:37:28 CEST 2008


Author: colossus
Date: 2008-07-03 06:37:28 +0000 (Thu, 03 Jul 2008)
New Revision: 27199

Modified:
   xarchiver/trunk/src/archive.c
   xarchiver/trunk/src/archive.h
   xarchiver/trunk/src/interface.c
   xarchiver/trunk/src/string_utils.c
   xarchiver/trunk/src/string_utils.h
   xarchiver/trunk/src/window.c
Log:
Double clicking on the directories in the main window now expands and selects the corresponding entries in the sidepane.


Modified: xarchiver/trunk/src/archive.c
===================================================================
--- xarchiver/trunk/src/archive.c	2008-07-03 00:19:22 UTC (rev 27198)
+++ xarchiver/trunk/src/archive.c	2008-07-03 06:37:28 UTC (rev 27199)
@@ -32,6 +32,8 @@
 extern gboolean batch_mode;
 
 static gboolean xa_process_output (GIOChannel *ioc, GIOCondition cond, gpointer data);
+void xa_sidepane_select_row(XEntry *entry);
+gboolean _xa_sidepane_select_row(GtkTreeModel *model,GtkTreePath *path,GtkTreeIter *iter,gpointer data);
 
 XArchive *xa_init_archive_structure(gint type)
 {
@@ -613,7 +615,7 @@
 		}
 		entry = entry->next;
 	}
-	xa_fill_dir_sidebar(archive);
+	xa_fill_dir_sidebar(archive,FALSE);
 }
 
 XEntry* xa_find_entry_from_path (XEntry *root_entry,const gchar *fullpathname)
@@ -827,11 +829,11 @@
 
 }
 
-void xa_fill_dir_sidebar(XArchive *archive)
+void xa_fill_dir_sidebar(XArchive *archive,gboolean force_reload)
 {
 	GtkTreeIter iter;
 
-	if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(archive_dir_model),&iter))
+	if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(archive_dir_model),&iter) && force_reload == FALSE)
 		return;
 
 	gtk_tree_store_clear(GTK_TREE_STORE(archive_dir_model));
@@ -874,3 +876,33 @@
 		xa_update_window_with_archive_entries(archive[idx],entry);
 	}
 }
+
+void xa_sidepane_select_row(XEntry *entry)
+{
+	gtk_tree_model_foreach(GTK_TREE_MODEL(archive_dir_model),(GtkTreeModelForeachFunc)_xa_sidepane_select_row,entry);
+}
+
+gboolean _xa_sidepane_select_row(GtkTreeModel *model,GtkTreePath *path,GtkTreeIter *iter,gpointer data)
+{
+	XEntry *entry = data;
+	XEntry *entry2;
+	GtkTreeIter parent;
+
+	gtk_tree_model_get (model,iter,2,&entry2,-1);
+	
+	if (entry == entry2)
+	{
+		gtk_tree_model_iter_parent(model,&parent,iter);
+		if ( ! gtk_tree_view_row_expanded(GTK_TREE_VIEW(archive_dir_treeview),path))
+			gtk_tree_view_expand_to_path(GTK_TREE_VIEW(archive_dir_treeview),path);
+
+		gtk_tree_selection_select_iter(gtk_tree_view_get_selection (GTK_TREE_VIEW (archive_dir_treeview)),iter);
+	}
+	else
+	{
+		return FALSE;
+		gtk_tree_selection_unselect_iter(gtk_tree_view_get_selection (GTK_TREE_VIEW (archive_dir_treeview)),iter);
+	}
+
+	return FALSE;
+}

Modified: xarchiver/trunk/src/archive.h
===================================================================
--- xarchiver/trunk/src/archive.h	2008-07-03 00:19:22 UTC (rev 27198)
+++ xarchiver/trunk/src/archive.h	2008-07-03 06:37:28 UTC (rev 27199)
@@ -143,7 +143,7 @@
 void xa_entries_to_filelist(XEntry *, GString **, gchar *);
 gboolean xa_detect_encrypted_archive (XArchive *archive);
 void xa_browse_dir_sidebar (XEntry *, GtkTreeStore *,gchar *,GtkTreeIter *);
-void xa_fill_dir_sidebar(XArchive *);
+void xa_fill_dir_sidebar(XArchive *,gboolean);
 void xa_sidepane_row_selected(GtkTreeSelection *selection, gpointer data);
 XArchive *archive[100];
 #endif

Modified: xarchiver/trunk/src/interface.c
===================================================================
--- xarchiver/trunk/src/interface.c	2008-07-03 00:19:22 UTC (rev 27198)
+++ xarchiver/trunk/src/interface.c	2008-07-03 06:37:28 UTC (rev 27199)
@@ -546,6 +546,7 @@
 			gtk_entry_set_text(GTK_ENTRY(location_entry),"\0");
 
 		gtk_widget_grab_focus (GTK_WIDGET(archive[id]->treeview));
+		xa_fill_dir_sidebar(archive[id],TRUE);
 	}
 }
 

Modified: xarchiver/trunk/src/string_utils.c
===================================================================
--- xarchiver/trunk/src/string_utils.c	2008-07-03 00:19:22 UTC (rev 27198)
+++ xarchiver/trunk/src/string_utils.c	2008-07-03 06:37:28 UTC (rev 27199)
@@ -92,59 +92,8 @@
 	return xa_escape_common_chars (string, pattern, '\\', 0);
 }
 
-gchar *JoinPathArchiveName ( const gchar *extract_path , gchar *path )
-{
-	return g_strconcat (extract_path , path , NULL);
-}
-
-int CountCharacter ( gchar *string , int chr )
-{
-    int n = 0;
-    while ( *string )
-    {
-        if ( *string == chr ) n++;
-        string++;
-    }
-    return n;
-}
-
-gchar *RemoveBackSlashes ( gchar *name)
-{
-    gchar *nome, *q;
-    int x = CountCharacter ( name , '\\' );
-    nome = (char *) g_malloc (strlen(name) - x + 1);
-    q = nome;
-    while ( *name )
-    {
-        if ( *name == '\\' ) name++;
-        *q++ = *name++;
-    }
-    *q = '\000';
-    return nome;
-}
-
 /* These functions are from File-Roller code */
-char *get_last_field (char *line,int last_field)
-{
-	char *field;
-	int i;
 
-	if (line == NULL)
-		return NULL;
-
-	last_field--;
-	field = eat_spaces (line);
-	for (i = 0; i < last_field; i++) {
-		if (field == NULL)
-			return NULL;
-		field = strchr (field, ' ');
-		field = eat_spaces (field);
-	}
-	//The following line is mine, I replace the \n with the null terminated
-    if (field != NULL) field [ strlen(field) -1 ] = '\0';
-	return field;
-}
-
 static int count_chars_to_escape (const char *str, const char *meta_chars)
 {
 	int meta_chars_n = strlen (meta_chars);
@@ -199,15 +148,6 @@
         return escaped;
 }
 
-char *eat_spaces (char *line)
-{
-	if (line == NULL)
-		return NULL;
-	while ((*line == ' ') && (*line != 0))
-		line++;
-	return line;
-}
-
 gchar *remove_level_from_path (const gchar *path)
 {
 	return g_path_get_dirname(path);
@@ -237,37 +177,6 @@
     return local_escaped_path;
 }
 
-gchar *xa_get_parent_dir (const gchar *current_dir)
-{
-	gchar *first_slash = NULL;
-	gchar *second_slash = NULL;
-	gchar *reverse = NULL;
-	gchar *retval = NULL;
-
-	reverse = g_strdup (current_dir);
-	g_strreverse (reverse);
-
-	first_slash = strchr(reverse,'/');
-	if (first_slash == NULL)
-	{
-		retval = g_strdup("/");
-		goto here;
-	}
-	first_slash++;
-	second_slash = strchr(first_slash,'/');
-
-	if (second_slash == NULL)
-		retval = g_strdup(first_slash);
-	else
-		retval = g_strndup(first_slash, (second_slash - first_slash) );
-
-	g_strreverse(retval);
-
-here:
-	g_free (reverse);
-	return retval;
-}
-
 void xa_set_window_title (GtkWidget *window,gchar *title)
 {
 	gchar *x 	= NULL;

Modified: xarchiver/trunk/src/string_utils.h
===================================================================
--- xarchiver/trunk/src/string_utils.h	2008-07-03 00:19:22 UTC (rev 27198)
+++ xarchiver/trunk/src/string_utils.h	2008-07-03 06:37:28 UTC (rev 27199)
@@ -30,13 +30,7 @@
 char *mkdtemp (gchar *tmpl);
 #endif
 gchar *xa_escape_bad_chars ( gchar *string , gchar *pattern);
-gchar *JoinPathArchiveName ( const gchar *extract_path , gchar *path );
-int CountCharacter ( gchar *string , int chr );
-gchar *RemoveBackSlashes ( gchar *name);
-char *get_last_field (char *line,int last_field);
 char *xa_escape_common_chars (const char *str, const char *meta_chars, const char  prefix, const char  postfix);
-char *eat_spaces (char *line);
-gchar *xa_get_parent_dir (const gchar *current_dir);
 gchar *remove_level_from_path (const gchar *path);
 gboolean file_extension_is (const char *filename, const char *ext);
 gchar *extract_local_path (gchar *path);

Modified: xarchiver/trunk/src/window.c
===================================================================
--- xarchiver/trunk/src/window.c	2008-07-03 00:19:22 UTC (rev 27198)
+++ xarchiver/trunk/src/window.c	2008-07-03 06:37:28 UTC (rev 27199)
@@ -175,6 +175,7 @@
 			break;
 		}
 	}
+	xa_fill_dir_sidebar(archive,TRUE);
 }
 
 void xa_watch_child (GPid pid,gint status,gpointer data)
@@ -410,6 +411,7 @@
 		break;
 	}
 	archive[current_page]->passwd = NULL;
+	xa_fill_dir_sidebar(archive[current_page],TRUE);
 }
 
 void xa_test_archive (GtkMenuItem *menuitem, gpointer user_data)
@@ -2005,5 +2007,6 @@
 	else
 		archive->back = g_slist_prepend(archive->back,NULL);
 
+	xa_sidepane_select_row(entry);
 	xa_update_window_with_archive_entries(archive,entry);
 }



More information about the Xfce4-commits mailing list