Patches & SendTo for regular files

Bernard Jungen <[email protected]> Wed, 22 Apr 2009 17:58:12 +0200
Newsgroups gmane.comp.desktop.rox.devel
Message-ID <[email protected]>
Hi list,

I've been playing with rox source code lately and came up with 3 patches to be
found as attachments. These have been generated from my local git repo, having
failed to generate a useable fork at repo.or.cz.

Included in one patch is the ability to make SendTo items for regular files
only, as is done for "grouped" files. There doesn't seem to be any other way
to do it.

Cheers,

Bernard.

------------------------------------------------------------------------------
Stay on top of everything new and different, both inside and 
around Java (TM) technology - register by April 22, and save
$200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco.
300 plus technical and hands-on sessions. Register today. 
Use priority code J9JMT32. http://p.sf.net/sfu/p

_______________________________________________
rox-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rox-devel
0001-Add-Compile-run-option-to-main-application-menu.patch (text/x-diff, 1.8 KB)
>From 55a389afcee77d017cc1988cc4e3ea9ddec9a729 Mon Sep 17 00:00:00 2001
From: Bernard Jungen <[email protected]>
Date: Sat, 18 Apr 2009 17:11:43 +0200
Subject: [PATCH 1/3] Add "Compile & run" option to main application menu

This allows a developer to quickly test his changes without using the CLI.
---
 ROX-Filer/AppInfo.xml |    3 +++
 ROX-Filer/AppRun      |   11 +++++++++--
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/ROX-Filer/AppInfo.xml b/ROX-Filer/AppInfo.xml
index 2b7ab46..c77f1de 100644
--- a/ROX-Filer/AppInfo.xml
+++ b/ROX-Filer/AppInfo.xml
@@ -97,5 +97,8 @@
       <Label xml:lang="zh_TW">停用桌面功能</Label>
 	<Label xml:lang="gl">Desactivar o taboleiro</Label>
     </Item>
+    <Item option="--xmake-and-run-new">
+      <Label>Compile &amp; run</Label>
+    </Item>
   </AppMenu>
 </AppInfo>
diff --git a/ROX-Filer/AppRun b/ROX-Filer/AppRun
index 063ba6b..32e000c 100755
--- a/ROX-Filer/AppRun
+++ b/ROX-Filer/AppRun
@@ -11,6 +11,8 @@ if [ "x$MAKE" = x ]; then
   MAKE=make export MAKE
 fi
 
+BIN="$APP_DIR/$PROG"
+
 case $1 in
 	--debug) shift ;
 		if [ "$#" = 0 ] ; then
@@ -22,6 +24,13 @@ case $1 in
 	--massif) shift ; DEBUGGER="valgrind --tool=massif --alloc-fn=g_malloc --alloc-fn=g_realloc --alloc-fn=g_malloc0 --alloc-fn=g_try_malloc --alloc-fn=g_mem_chunk_alloc";;
 	--calltree) shift ; DEBUGGER="calltree";;
 	--leaks) shift ; DEBUGGER="valgrind --num-callers=8 --leak-check=yes";;
+	--xmake-and-run-new)
+		if [ -x "$BIN" ]; then
+			cd "$APP_DIR/src" && xterm -hold -e $MAKE
+		else
+			xterm -hold -e "$0" --compile
+		fi
+		exec "$BIN" -n ~ ;;
 	--compile)
 		shift
 		if [ ! -d "$APP_DIR/src" ] ; then
@@ -46,8 +55,6 @@ case $1 in
 		exit 1
 esac
 
-BIN="$APP_DIR/$PROG"
-
 if [ -x "$BIN" ]; then
   exec $DEBUGGER "$BIN" $DEBUG_OPTIONS "$@"
 else
-- 
1.6.2.1
0002-Save-display-settings-properties-preset-bug-fix.patch (text/x-diff, 3.2 KB)
>From 379ae8c02bf36a4685531611caad1d6fc100e037 Mon Sep 17 00:00:00 2001
From: Bernard Jungen <[email protected]>
Date: Sat, 18 Apr 2009 19:06:28 +0200
Subject: [PATCH 2/3] Save display settings: properties preset + bug fix + remove path

Toggle properties in save window according to those saved for the current path, or to the last ones used.
Fixed bug where thumbnail setting was saved only if display style was selected.
Remove path where no property at all is selected.
---
 ROX-Filer/src/filer.c |   22 ++++++++++------------
 1 files changed, 10 insertions(+), 12 deletions(-)

diff --git a/ROX-Filer/src/filer.c b/ROX-Filer/src/filer.c
index 8381c4c..2123913 100644
--- a/ROX-Filer/src/filer.c
+++ b/ROX-Filer/src/filer.c
@@ -118,6 +118,7 @@ enum settings_flags{
 	SET_DETAILS=32,   /* view_type, details_type */
 	SET_THUMBS=64,    /* show_thumbs */
 	SET_FILTER=128,   /* filter_type, filter */
+	SET_ALL=255	  /* all flags */
 };
 
 /* Static prototypes */
@@ -3061,7 +3062,8 @@ static void store_settings(Settings *set)
 		settings_free(old);
 	}
 
-	g_hash_table_insert(settings_table, set->path, set);
+	if (set->flags & SET_ALL)
+		g_hash_table_insert(settings_table, set->path, set);
 }
 
 /* TODO: use symbolic names in the XML file where possible */
@@ -3220,7 +3222,7 @@ static void add_nodes(gpointer key, gpointer value, gpointer data)
 		xmlNewChild(sub, NULL, "DetailsType", tmp);
 		g_free(tmp);
 	}
-	if(set->flags & SET_STYLE) {
+	if(set->flags & SET_THUMBS) {
 		tmp=g_strdup_printf("%d", set->show_thumbs);
 		xmlNewChild(sub, NULL, "ShowThumbs", tmp);
 		g_free(tmp);
@@ -3322,6 +3324,7 @@ typedef struct settings_window {
 	Settings *set;
 } SettingsWindow;
 
+static gint last_display_settings_flags = ~0;
 
 static void settings_response(GtkWidget *window, gint response,
 			      SettingsWindow *set_win)
@@ -3346,7 +3349,7 @@ static void settings_response(GtkWidget *window, gint response,
 		if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(set_win->filter)))
 			flags|=SET_FILTER;
 
-		set_win->set->flags=flags;
+		set_win->set->flags = last_display_settings_flags = flags;
 		store_settings(set_win->set);
 		save_settings();
 	}
@@ -3361,36 +3364,31 @@ void filer_save_settings(FilerWindow *fwin)
 	GtkWidget *path, *lbl;
 	gint x, y;
 	
-	Settings *set=settings_new(fwin->sym_path);
+	Settings *old, *set=settings_new(fwin->sym_path);
+
+	old = g_hash_table_lookup(settings_table, fwin->sym_path);
+	set->flags = old ? old->flags : last_display_settings_flags;
 
 	gtk_window_get_position(GTK_WINDOW(fwin->window),&x, &y);
-	set->flags|=SET_POSITION;
 	set->x=x;
 	set->y=y;
 
 	gtk_window_get_size(GTK_WINDOW(fwin->window),&x, &y);
-	set->flags|=SET_SIZE;
 	set->width=x;
 	set->height=y;
 
-	set->flags|=SET_HIDDEN;
 	set->show_hidden=fwin->show_hidden;
 
-	set->flags|=SET_STYLE;
 	set->display_style=fwin->display_style;
 
-	set->flags|=SET_SORT;
 	set->sort_type=fwin->sort_type;
 	set->sort_order=fwin->sort_order;
 
-	set->flags|=SET_DETAILS;
 	set->view_type=fwin->view_type;
 	set->details_type=fwin->details_type;
 
-	set->flags|=SET_THUMBS;
 	set->show_thumbs=fwin->show_thumbs;
 
-	set->flags|=SET_FILTER;
 	set->filter_type=fwin->filter;
 	if(fwin->filter_string)
 		set->filter=g_strdup(fwin->filter_string);
-- 
1.6.2.1
0003-Fixed-and-improved-SendTo-menus-creation.patch (text/x-diff, 3.9 KB)
>From f63f5e2924ad0f14aa1526be43c73821ee9928bc Mon Sep 17 00:00:00 2001
From: Bernard Jungen <[email protected]>
Date: Sun, 19 Apr 2009 19:04:06 +0200
Subject: [PATCH 3/3] Fixed and improved SendTo menus creation

Better filter: ignore regular directories when appropriate and special files
Memory leaks fixes
Small optimisation and cleanup
Added '.regular' category for regular files
---
 ROX-Filer/src/appmenu.c |   14 ++++++++++++--
 ROX-Filer/src/menu.c    |   29 +++++++++++++++++++++--------
 2 files changed, 33 insertions(+), 10 deletions(-)

diff --git a/ROX-Filer/src/appmenu.c b/ROX-Filer/src/appmenu.c
index a16c674..23fe9b9 100644
--- a/ROX-Filer/src/appmenu.c
+++ b/ROX-Filer/src/appmenu.c
@@ -347,16 +347,26 @@ static void build_menu_for_type(MIME_type *type)
 
 		full_path = g_build_filename(path, leaf, NULL);
 		diritem_restat(full_path, ditem, NULL);
-		
+
+		if (ditem->base_type != TYPE_FILE
+		    && (ditem->base_type != TYPE_DIRECTORY
+			|| !(ditem->flags & ITEM_FLAG_APPDIR)))
+		{
+			g_free(full_path);
+			goto end_names_loop;
+		}
+
 		item = make_send_to_item(ditem, leaf, MIS_SMALL);
 		current_items = g_list_prepend(current_items, item);
 		gtk_widget_show(item);
 		g_signal_connect_data(item, "activate", G_CALLBACK(send_to),
 				full_path, (GClosureNotify) g_free, 0);
+	end_names_loop:
+		g_free(leaf);
 	}
 
+	diritem_free(ditem);
 	g_ptr_array_free(names, TRUE);
-
 	g_free(path);
 
 out:
diff --git a/ROX-Filer/src/menu.c b/ROX-Filer/src/menu.c
index 611918d..28b029e 100644
--- a/ROX-Filer/src/menu.c
+++ b/ROX-Filer/src/menu.c
@@ -494,6 +494,8 @@ static GList *menu_from_dir(GtkWidget *menu, const gchar *dir_name,
 	if (!names)
 		goto out;
 
+	ditem = diritem_new("");
+
 	for (i = 0; i < names->len; i++)
 	{
 		char	*leaf = names->pdata[i];
@@ -507,7 +509,7 @@ static GList *menu_from_dir(GtkWidget *menu, const gchar *dir_name,
 			separator = FALSE;
 		}
 
-		fname = g_strconcat(dname, "/", leaf, NULL);
+		fname = g_build_filename(dname, leaf, NULL);
 
 		/* Strip off extension, if any */
 		if (strip_ext)
@@ -518,12 +520,17 @@ static GList *menu_from_dir(GtkWidget *menu, const gchar *dir_name,
 				*dot = '\0';
 		}
 
-		ditem = diritem_new("");
 		diritem_restat(fname, ditem, NULL);
 
-		item = make_send_to_item(ditem, leaf, style);
+		if (ditem->base_type != TYPE_FILE
+		    && (ditem->base_type != TYPE_DIRECTORY
+			|| (!recurse && !(ditem->flags & ITEM_FLAG_APPDIR))))
+		{
+			g_free(fname);
+			goto end_names_loop;
+		}
 
-		g_free(leaf);
+		item = make_send_to_item(ditem, leaf, style);
 
 		/* If it is a directory (but NOT an AppDir) and we are
 		 * recursing then set up a sub menu.
@@ -544,15 +551,17 @@ static GList *menu_from_dir(GtkWidget *menu, const gchar *dir_name,
 			g_signal_connect_swapped(item, "activate",
 					G_CALLBACK(func), fname);
 
-		diritem_free(ditem);
-
 		gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
 		g_signal_connect_swapped(item, "destroy",
 				G_CALLBACK(g_free), fname);
 
 		widgets = g_list_append(widgets, item);
+
+	end_names_loop:
+		g_free(leaf);
 	}
 
+	diritem_free(ditem);
 	g_ptr_array_free(names, TRUE);
 out:
 	g_free(dname);
@@ -1504,7 +1513,8 @@ static void customise_send_to(gpointer data)
 		"You can also create subdirectories called "
 		"`.text_html', `.text', etc which will only be "
 		"shown for files of that type. `.group' is shown "
-		"only when multiple files are selected."),
+		"only when multiple files are selected. `.regular' "
+		"is shown only for regular files."),
 		dirs->str,
 		save ? _("I'll show you your SendTo directory now; you should "
 			"symlink (Ctrl+Shift drag) any applications you want "
@@ -1618,7 +1628,10 @@ static void show_send_to_menu(GList *paths, GdkEvent *event)
 			   item->mime_type->subtype);
 
 		add_sendto(menu, item->mime_type->media_type, NULL);
-		
+
+		if (item->base_type == TYPE_FILE)
+			add_sendto(menu, "regular", NULL);
+
 		diritem_free(item);
 	}
 	else
-- 
1.6.2.1