This commit is contained in:
Glenn Y. Rolland 2011-09-10 13:37:01 +02:00
commit e1fd3ad761
4 changed files with 39 additions and 23 deletions

View file

@ -7,6 +7,7 @@ $VERBOSE = true
require 'pp'
require 'set'
require 'fcntl'
QASIM_INCLUDE_DIR = "."
$:.push QASIM_INCLUDE_DIR
@ -143,13 +144,13 @@ module Qasim
@context_menu = Qt::Menu.new
act_pref = Qt::Action.new _('&Preferences'), @context_menu
act_pref.setIcon( Qt::Icon::fromTheme("configure") )
act_pref.setIcon( Qt::Icon::fromTheme("configure") ) rescue nil
act_pref.setIconVisibleInMenu true
act_pref.setEnabled false
@context_menu.addAction act_pref;
act_about = Qt::Action.new '&About', @context_menu
act_about.setIcon( Qt::Icon::fromTheme("help-about") )
act_about.setIcon( Qt::Icon::fromTheme("help-about") ) rescue nil
act_about.setIconVisibleInMenu true
act_about.setEnabled false
@context_menu.addAction act_about;
@ -157,7 +158,7 @@ module Qasim
@context_menu.addSeparator
act_quit = Qt::Action.new _('Quit'), @context_menu
act_quit.setIcon( Qt::Icon::fromTheme("application-exit") )
act_quit.setIcon( Qt::Icon::fromTheme("application-exit") ) rescue nil
act_quit.setIconVisibleInMenu true
act_quit.connect(SIGNAL(:triggered)) { @app.quit }
@context_menu.addAction act_quit
@ -209,7 +210,25 @@ module Qasim
#
#
def run
# create lock
have_lock = true
FileUtils.mkdir_p APP_CONFIG_DIR unless File.exist? APP_CONFIG_DIR
lockfname = File.join APP_CONFIG_DIR, "lock"
fd = IO::sysopen( lockfname,
Fcntl::O_WRONLY | Fcntl::O_EXCL | Fcntl::O_CREAT)
f = IO.open(fd)
f.syswrite( "Process.pid\n" )
f.close
@app.exec
rescue Errno::EEXIST => e
warn "error: Another instance of %s is already running." % APP_NAME
exit 1
ensure
masterpid = File.read(lockfname).strip
if masterpid == Process.pid then
FileUtils.rm lockfname
end
end

7
debian/changelog vendored
View file

@ -1,3 +1,10 @@
qasim (0.1.6) unstable; urgency=low
* qasim-gui: handle QIcon::fromTheme NoMethodError exception when needed.
* qasim-gui: added single instance lock.
-- Glenn Y. Rolland <glenux@glenux.net> Wed, 07 Sep 2011 01:08:48 +0200
qasim (0.1.5) unstable; urgency=low
* map: Added missing require for fileutils.

View file

@ -20,27 +20,10 @@ module Qasim
def initialize
user = if ENV['USER'] then
ENV['USER']
else
raise "Environment variable 'USER' is missing!"
end
home_dir = if ENV['HOME'] then
ENV['HOME']
else
"/home/" + user
end
@mnt_dir = File.join ENV['HOME'], "mnt"
xdg_dir = if ENV['XDG_CONFIG_HOME'] then
ENV['XDG_CONFIG_HOME']
else
home_dir + '/.config'
end
@mnt_dir = File.join home_dir, "mnt"
@config_dir = xdg_dir + '/sshfs-mapper'
@config_dir = APP_CONFIG_DIR
@config_file = nil
@maps = []
@initialize_enable = false

View file

@ -1,6 +1,13 @@
module Qasim
APP_ICON_PATH = File.join QASIM_INCLUDE_DIR, "icons"
APP_SYSCONFIG_DIR = "/etc/qasim/maps.d"
APP_NAME = "Qasim"
APP_VERSION = "0.1"
APP_SYSCONFIG_DIR = "/etc/qasim/maps.d"
APP_CONFIG_DIR = if ENV['XDG_CONFIG_HOME'] then
File.join ENV['XDG_CONFIG_HOME'], 'qasim'
else
File.join ENV['HOME'], '.config', 'qasim'
end
end