From ac9f89c6deeb6c4b2ee2f01e797ddcddc633b8e5 Mon Sep 17 00:00:00 2001 From: "Glenn Y. Rolland" Date: Wed, 2 Sep 2015 16:38:09 +0200 Subject: [PATCH] Restore GUI comportement. --- lib/qasim/cli.rb | 1 + lib/qasim/gui.rb | 22 +++++++++++----------- lib/qasim/map_manager.rb | 18 +++++++++--------- 3 files changed, 21 insertions(+), 20 deletions(-) diff --git a/lib/qasim/cli.rb b/lib/qasim/cli.rb index 02ed53c..df9d279 100644 --- a/lib/qasim/cli.rb +++ b/lib/qasim/cli.rb @@ -66,6 +66,7 @@ module Qasim super @active_maps = nil @config = Config.new + #@config.parse @map_manager = MapManager.new @config @map_manager.parse_maps end diff --git a/lib/qasim/gui.rb b/lib/qasim/gui.rb index 318d496..72511bc 100644 --- a/lib/qasim/gui.rb +++ b/lib/qasim/gui.rb @@ -12,7 +12,7 @@ module Qasim def initialize @config = Config.new - #@config.parse_cmd_line ARGV + @map_manager = MapManager.new @config @map_menu = nil @context_menu = nil @@ -38,7 +38,7 @@ module Qasim ) msg.arguments = [ APP_NAME, Qt::Variant.from_value( 0, "unsigned int" ), icon, title, body, [], {}, -1 ] - rep = bus.call( msg ) + _rep = bus.call( msg ) # if rep.type == Qt::DBusMessage # si.showMessage("Qasim", @@ -51,12 +51,12 @@ module Qasim # def build_map_menu # reload maps dynamically - @config.parse_maps + @map_manager.parse_maps @map_menu ||= Qt::Menu.new @map_menu.clear previous_host = nil - @config.maps.sort do |mx,my| + @map_manager.sort do |mx,my| mx.host <=> my.host end.each do |map| if map.host != previous_host and not previous_host.nil? then @@ -64,7 +64,7 @@ module Qasim end itemx = Qt::Action.new(map.name, @map_menu) itemx.setCheckable true; - if map.connected? then + if map.mounted? then itemx.setChecked true end itemx.connect(SIGNAL(:triggered)) do @@ -131,7 +131,7 @@ module Qasim act_pref.setIconVisibleInMenu true act_pref.setEnabled false act_pref.connect(SIGNAL(:triggered)) do - res = @pref_dialog.show + _res = @pref_dialog.show end @context_menu.addAction act_pref; @@ -140,7 +140,7 @@ module Qasim act_about.setIconVisibleInMenu true #act_about.setEnabled true act_about.connect(SIGNAL(:triggered)) do - res = @about_dialog.show + _res = @about_dialog.show end @context_menu.addAction act_about; @@ -170,8 +170,8 @@ module Qasim @pref_dialog = Qasim::Ui::Preferences.new @main_win std_icon = Qt::Icon.new( ":/qasim/qasim-icon" ) - alt_icon = Qt::Icon.new - blinking = false + _alt_icon = Qt::Icon.new + _blinking = false @systray.icon = std_icon @systray.show @@ -205,7 +205,7 @@ module Qasim def lock_set begin # create an exclusive lock file - have_lock = true + _have_lock = true FileUtils.mkdir_p APP_CONFIG_DIR unless File.exist? APP_CONFIG_DIR lockfname = File.join APP_CONFIG_DIR, "lock" @@ -214,7 +214,7 @@ module Qasim f = IO.open(fd) f.syswrite( "#{Process.pid}\n" ) f.close - rescue Errno::EEXIST => e + rescue Errno::EEXIST => _e # test if the other process still exist masterpid = File.read(lockfname).strip other_path = "/proc/#{masterpid.to_i}" diff --git a/lib/qasim/map_manager.rb b/lib/qasim/map_manager.rb index 5e60f38..b53e93e 100644 --- a/lib/qasim/map_manager.rb +++ b/lib/qasim/map_manager.rb @@ -1,28 +1,28 @@ class Qasim::MapManager # FIXME: move out of config - def initialize config + def initialize config @maps = [] @config = config end - + def sort &blk - @maps.sort &blk + @maps.sort(&blk) end def select &blk - @maps.select &blk + @maps.select(&blk) end def each &blk - @maps.each &blk + @maps.each blk end def parse_maps &blk @maps = [] - map_dirs = [@config.config_dir, Qasim::APP_SYSCONFIG_DIR].select{ |d| + map_dirs = [@config.config_dir, Qasim::APP_SYSCONFIG_DIR].select do |d| File.exist? d and File.directory? d - } + end Find.find(*map_dirs) do |path| # Skip unwanted files fast @@ -30,12 +30,12 @@ class Qasim::MapManager next unless File.basename(path) =~ /.map$/ begin - map = Qasim::Map.from_file self, path + map = Qasim::Map.from_file @config, path yield map if block_given? @maps.push map rescue Qasim::Map::ParseError raise RuntimeError, "Error while parsing map file" end end - end + end end