fluxbox_apps_menu 1.1.2 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d0396fb427fa3641352a8803e034f697afac4d60
4
+ data.tar.gz: 7b53ce6ad5c763e07cd42706933320dd6bbcbe6d
5
+ SHA512:
6
+ metadata.gz: 883eaeab6f1e6f6e8b76b5c1783856065c64d9923cb2a83b39ef8e9310934da7d977e00b6202da034643975bad3395cec7571cd0302cc510ccf066af9b9545cd
7
+ data.tar.gz: 020895fcbc7c2527015bb3c5e672d830bb9286933870802e4e99fd0f277cd222a805ca2cb01a82db9382fbeb341126c491f92ebc787bccdb9fec934d84e8258c
data/Gemfile.lock CHANGED
@@ -9,7 +9,7 @@ GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
11
  inifile (3.0.0)
12
- rake (10.1.1)
12
+ rake (10.1.0)
13
13
  thor (0.19.1)
14
14
 
15
15
  PLATFORMS
@@ -56,26 +56,32 @@ module FluxboxAppsMenu
56
56
  name = ini.name
57
57
 
58
58
  if ini.hidden?
59
- puts '[Hidden] '.bold.green + "The application #{name} is hidden" unless @silent
59
+ puts '[Hidden] '.bold.green + "The application \"#{name}\" is hidden" unless @silent
60
60
  next
61
61
  end
62
62
 
63
63
  cat = ini.categories
64
64
  if cat.nil?
65
- puts '[No Category] '.bold.red + "The application #{name} doesn't have any category" unless @silent
65
+ puts '[No Category] '.bold.red + "The application \"#{name}\" doesn't have any category" unless @silent
66
66
  next
67
67
  end
68
68
 
69
- submenu = @fmenu.assign_menu(cat, name)
69
+ begin
70
+ submenu = @fmenu.assign_menu(cat, name)
71
+ rescue NoCategoriesError => e
72
+ puts '[No category] '.bold.red + "The \"#{e.message}\" menu item doesn't have any categoty, check your \"fluxbox_menu_apps.yaml\""
73
+ exit
74
+ end
75
+
70
76
  unless submenu.nil?
71
77
  icon = ini.icon
72
78
  if icon.nil?
73
- puts '[No Icon] '.bold.yellow + "#{name} doesn't have any icon" unless @silent
79
+ puts '[No Icon] '.bold.yellow + "The application \"#{name}\" doesn't have any icon" unless @silent
74
80
  end
75
81
 
76
82
  submenu[name] = @fmenu.item_exec(name, icon, ini.exec)
77
83
  else
78
- puts "[No mapped category] #{name} doesn't have any mapped category within the menu".bold.red unless @silent
84
+ puts '[No mapped category] '.bold.red + "The application \"#{name}\" doesn't have any mapped category among: #{ini.categories.join(', ')}" unless @silent
79
85
  end
80
86
  end
81
87
  end
@@ -14,6 +14,8 @@
14
14
  - /usr/share/pixmaps
15
15
  - /usr/share/icons/hicolor/32x32/apps
16
16
  - /usr/share/icons/oxygen/16x16/categories
17
+ - /usr/share/icons/oxygen/16x16/status
18
+ - /usr/share/icons/oxygen/16x16/devices
17
19
  - /usr/share/icons/hicolor/48x48/apps
18
20
  - /usr/share/icons/hicolor/128x128/apps
19
21
  :app_paths:
@@ -68,8 +70,26 @@
68
70
  - System
69
71
  - DesktopSettings
70
72
  - Documentation
73
+ '. / Gnome /':
74
+ :icon:
75
+ :mandatory_categories:
76
+ - X-GNOME-Settings-Panel
77
+ :categories:
78
+ - X-GNOME-Settings-Panel
79
+ Desktop:
80
+ :icon:
81
+ :categories:
82
+ - X-GNOME-PersonalSettings
83
+ Hardware:
84
+ :categories:
85
+ - HardwareSettings
86
+ System:
87
+ :categories:
88
+ - X-GNOME-SystemSettings
71
89
  '. / Yast /':
72
- :icon: yast-mascot
90
+ :icon: yast
91
+ :mandatory_categories:
92
+ - X-SuSE-YaST
73
93
  :categories:
74
94
  - Yast
75
95
  Hardware:
@@ -109,6 +129,17 @@
109
129
  :categories:
110
130
  - Archiving
111
131
  - Utility
132
+ '. / Emulators /':
133
+ :icon: cpu
134
+ :categories:
135
+ -
136
+ -
137
+ - Emulator
138
+ Wine:
139
+ :icon: wine
140
+ :categories:
141
+ - Wine
142
+ - Wine-Programs-Accessories
112
143
  '. / Text Files /':
113
144
  :icon: accessories-text-editor
114
145
  :categories:
@@ -22,7 +22,7 @@ module FluxboxAppsMenu
22
22
  end
23
23
 
24
24
  def hidden?
25
- @ini['Desktop Entry']['NoDisplay'] == true
25
+ %w(true 1).include? @ini['Desktop Entry']['NoDisplay'].to_s
26
26
  end
27
27
 
28
28
  def banned_file?
@@ -31,20 +31,6 @@ module FluxboxAppsMenu
31
31
  end
32
32
 
33
33
  def icon
34
- =begin
35
- iname = @cfg.icons[name(false)]
36
- iname = @ini['Desktop Entry']['Icon'] if iname.nil?
37
-
38
- return nil if iname.to_s.empty?
39
- return iname if iname.to_s.match('/') && File.exists?(iname)
40
-
41
- iname.gsub!(/\.png$/, '')
42
-
43
- @cfg.icon_paths.each do |p|
44
- return "#{p}/#{iname}.png" if File.exists?("#{p}/#{iname}.png")
45
- end
46
- return nil
47
- =end
48
34
  @cfg.expand_icon(name(false), @ini['Desktop Entry']['Icon'])
49
35
  end
50
36
 
@@ -60,7 +46,7 @@ module FluxboxAppsMenu
60
46
  def exec
61
47
  com = @ini['Desktop Entry']['Exec'].to_s.gsub('%c', name).gsub('%F', '')
62
48
  .gsub('%i', '').gsub('%U', '').gsub('%f', '').gsub('%m', '')
63
- .gsub('%u', '').gsub(/[ ]{2,}/, ' ').gsub(/\ }/, '}')
49
+ .gsub('%u', '').gsub(/[ ]{2,}/, ' ').gsub(/\ }/, '}').strip
64
50
 
65
51
  terminal? ? @cfg.terminal + ' ' + com : com
66
52
  end
@@ -7,7 +7,7 @@ module FluxboxAppsMenu
7
7
  end
8
8
 
9
9
  def assign_menu(cat, label)
10
- traverse_menu(@cfg.menu, cat, label)[0]
10
+ traverse_menu(@cfg.menu, cat.map(&:downcase), label)[0]
11
11
  end
12
12
 
13
13
  def render
@@ -36,7 +36,6 @@ module FluxboxAppsMenu
36
36
  str << "{#{command}}" unless command.nil?
37
37
  str << "<#{icon}>" unless icon.to_s.empty?
38
38
 
39
- # "[#{type}]#{label}#{command}#{icon}"
40
39
  str.join(' ')
41
40
  end
42
41
 
@@ -54,20 +53,30 @@ module FluxboxAppsMenu
54
53
  # when a label is set the path has high priority
55
54
  return [info, 0] if info.has_key?(label)
56
55
 
56
+ if info.has_key? :mandatory_categories
57
+ info[:mandatory_categories] = info[:mandatory_categories].map(&:downcase)
58
+ next unless (info[:mandatory_categories] & cat) == info[:mandatory_categories]
59
+ end
60
+
57
61
  unless subitems.to_hash.empty?
58
- result, index = traverse_menu(subitems, cat, label, selected_index)
59
- selected, selected_index = result, index unless result.nil?
62
+ result, index = traverse_menu(subitems, cat, label, selected_index)
63
+ selected, selected_index = result, index unless result.nil?
60
64
  end
61
65
 
66
+ raise NoCategoriesError, key unless info.has_key? :categories
67
+
68
+ categories = info[:categories].map { |s| s.downcase unless s.nil? }
69
+
62
70
  cat.each do |c|
63
- if info[:categories].include?(c.strip)
64
- i = info[:categories].index(c)
71
+ if categories.include?(c.strip)
72
+ i = categories.index(c)
65
73
  if i < selected_index
66
74
  selected = info
67
75
  selected_index = i
68
76
  end
69
77
  end
70
- end if info.has_key? :categories
78
+ end
79
+
71
80
  end
72
81
  end
73
82
 
@@ -82,22 +91,21 @@ module FluxboxAppsMenu
82
91
  menu = menu.select { |k, v| k.class == String }.sort_by { |k, v| v.class == String ? k.downcase : '' }
83
92
  menu.each do |name, items|
84
93
  if items.class.to_s == 'Hash'
85
- text += prefix + item_submenu(name, @cfg.expand_icon(nil, items[:icon])) + "\n"
86
-
94
+ icon = items[:icon]
87
95
  items = items.select { |k, v| k.class == String }
96
+ subitems = render_menu(items, level + 1)
88
97
 
89
- text += render_menu(items, level + 1)
98
+ unless subitems.empty?
99
+ text += "#{prefix}#{item_submenu(name, @cfg.expand_icon(nil, icon))}\n#{subitems}#{prefix}[end]\n"
100
+ end
90
101
 
91
- text += "#{prefix}[end]\n"
92
102
  elsif items.class.to_s == 'String'
93
103
  text += prefix + items + "\n"
94
104
  end
95
105
  end
96
106
 
97
107
  text
98
-
99
108
  end
100
109
 
101
110
  end
102
-
103
111
  end
@@ -19,3 +19,6 @@ class String
19
19
  def reverse_color; "\033[7m#{self}\033[27m" end
20
20
  end
21
21
 
22
+ class NoCategoriesError < StandardError
23
+
24
+ end
@@ -1,3 +1,3 @@
1
1
  module FluxboxAppsMenu
2
- VERSION = "1.1.2"
2
+ VERSION = "1.2.0"
3
3
  end
metadata CHANGED
@@ -1,78 +1,69 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluxbox_apps_menu
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
5
- prerelease:
4
+ version: 1.2.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Fabio Mucciante
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2015-02-08 00:00:00.000000000 Z
11
+ date: 2015-06-13 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: bundler
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ~>
17
+ - - "~>"
20
18
  - !ruby/object:Gem::Version
21
19
  version: '1.6'
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ~>
24
+ - - "~>"
28
25
  - !ruby/object:Gem::Version
29
26
  version: '1.6'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rake
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - ">="
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - ">="
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: inifile
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ~>
45
+ - - "~>"
52
46
  - !ruby/object:Gem::Version
53
47
  version: '3.0'
54
48
  type: :runtime
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ~>
52
+ - - "~>"
60
53
  - !ruby/object:Gem::Version
61
54
  version: '3.0'
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: thor
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ! '>='
59
+ - - ">="
68
60
  - !ruby/object:Gem::Version
69
61
  version: '0'
70
62
  type: :runtime
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ! '>='
66
+ - - ">="
76
67
  - !ruby/object:Gem::Version
77
68
  version: '0'
78
69
  description: This script reads the .desktop files installed and build the application's
@@ -102,26 +93,25 @@ files:
102
93
  homepage: https://github.com/fabiomux/fluxbox_apps_menu
103
94
  licenses:
104
95
  - GPL v.3
96
+ metadata: {}
105
97
  post_install_message:
106
98
  rdoc_options: []
107
99
  require_paths:
108
100
  - lib
109
101
  required_ruby_version: !ruby/object:Gem::Requirement
110
- none: false
111
102
  requirements:
112
- - - ! '>='
103
+ - - ">="
113
104
  - !ruby/object:Gem::Version
114
105
  version: '0'
115
106
  required_rubygems_version: !ruby/object:Gem::Requirement
116
- none: false
117
107
  requirements:
118
- - - ! '>='
108
+ - - ">="
119
109
  - !ruby/object:Gem::Version
120
110
  version: '0'
121
111
  requirements: []
122
112
  rubyforge_project:
123
- rubygems_version: 1.8.23
113
+ rubygems_version: 2.2.2
124
114
  signing_key:
125
- specification_version: 3
115
+ specification_version: 4
126
116
  summary: Build the Fluxbox apps menu.
127
117
  test_files: []