about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2009-07-20 23:52:58 +0200
committerhut <hut@lavabit.com>2009-07-20 23:52:58 +0200
commite805ddb1fc16736a8735bbda16ee094f4c59e182 (patch)
treeb0fd78927f35220608170612c94c2728d16c7171
parentce16309481e03604199470dea8b5aaef9dd0e282 (diff)
downloadranger-e805ddb1fc16736a8735bbda16ee094f4c59e182.tar.gz
fixed #11 (specify flags at data/types.rb)
-rw-r--r--code/entry.rb20
-rw-r--r--code/runcontext.rb8
-rw-r--r--data/apps.rb5
-rw-r--r--data/types.rb2
4 files changed, 25 insertions, 10 deletions
diff --git a/code/entry.rb b/code/entry.rb
index 3b08c54a..1849bad1 100644
--- a/code/entry.rb
+++ b/code/entry.rb
@@ -12,8 +12,12 @@ class Directory::Entry
 	## wrapper
 	def use() Use end
 	module Use
-		def self.method_missing(app,*_) throw(:use, app) end
-		def self.no_handler()           throw(:use, nil) end
+		def self.no_handler()
+			throw(:use, [nil, ''])
+		end
+		def self.method_missing(app, baseflags = '', *_)
+			throw(:use, [app, baseflags])
+		end
 	end
 
 	def initialize(dirname, basename=nil)
@@ -78,9 +82,19 @@ class Directory::Entry
 
 	def handler()
 		## get_handler has to be defined in another file
-		@handler ||= catch(:use) do
+		return @handler if @handler
+		@handler, @baseflags = catch(:use) do
+			get_handler
+		end
+		@handler
+	end
+
+	def baseflags()
+		return @baseflags if @baseflags
+		@handler, @baseflags = catch(:use) do
 			get_handler
 		end
+		@baseflags
 	end
 
 	def delete!
diff --git a/code/runcontext.rb b/code/runcontext.rb
index 882a10ef..aaccec9f 100644
--- a/code/runcontext.rb
+++ b/code/runcontext.rb
@@ -51,7 +51,13 @@ class RunContext
 		}
 		@handlers = @files.map {|file| file.handler}
 		@paths = @files.map {|file| file.path}
-		@handler = preferred_app || @handlers.first
+
+		if preferred_app
+			@handler = preferred_app
+		else
+			@handler = @handlers.first
+			self.base_flags = @files.first.baseflags
+		end
 
 		@multi = (@files.size > 1 and @handlers.uniq.size == 1)
 
diff --git a/data/apps.rb b/data/apps.rb
index 6a906e9d..089aba40 100644
--- a/data/apps.rb
+++ b/data/apps.rb
@@ -57,11 +57,6 @@ module Application
 		else nil end
 	end
 
-	def mplayer_detached(files)
-		files.base_flags = 'd'
-		mplayer(files)
-	end
-
 	def evince(files)
 		"evince #{files}"
 	end
diff --git a/data/types.rb b/data/types.rb
index 1755c9d3..6efc189c 100644
--- a/data/types.rb
+++ b/data/types.rb
@@ -31,7 +31,7 @@ class Directory::Entry
 		## then look at the mime-type
 		case @mimetype
 		when /^video/
-			use.mplayer_detached
+			use.mplayer "d"
 
 		when /^audio/
 			use.mplayer