gtk2checkboxes 3.0.210824

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
+ SHA256:
3
+ metadata.gz: 3a3aa0e1c6fc4ebeceadfdb2c66cd1854f1080705e0c1f55ab5b9da208df1fb8
4
+ data.tar.gz: 5bda88fc508e53bf1073b8b1189ace648897d934d8d9cc9e55495a6ed73bd99b
5
+ SHA512:
6
+ metadata.gz: dff60370ab48dcb29c090c9f96684a17e3276c54b7b131d9fcb00ada0b5287c9e0101354fb896431312622970250b8bbb1560b26adb29a934576473cffacf669
7
+ data.tar.gz: a46fd4cc94ce02045aad78650ed556f6bfba8545b70cf015fbdcfcfd0cd3cb0a081b12090ddd37d46fab0e5812d320904b33cc7d3e76b6e7813e928b40712fc2
data/README.md ADDED
@@ -0,0 +1,79 @@
1
+ # Ruby-Gnome CheckBoxes
2
+
3
+ * [VERSION 3.0.210824](https://github.com/carlosjhr64/gtk2checkboxes/releases)
4
+ * [github](https://www.github.com/carlosjhr64/gtk2checkboxes)
5
+ * [rubygems](https://rubygems.org/gems/gtk2checkboxes)
6
+
7
+ ![Day Mode](img/snapshot.png)
8
+
9
+ ## DESCRIPTION
10
+
11
+ Create a simple shopping list.
12
+ Maintain a check list of reacuring chores.
13
+ Anything that one would make a check list for.
14
+
15
+ Just a really simple app.
16
+ Allows for multiple lists.
17
+
18
+ ## INSTALL
19
+ ```shell
20
+ gem install gtk2checkboxes
21
+ ```
22
+ ## HELP
23
+ ```shell
24
+ $ gtk2checkboxes --help
25
+ Usage:
26
+ gtk2checkboxes [:options+]
27
+ Options:
28
+ -h --help
29
+ -v --version
30
+ --minime Real minime
31
+ --notoggle Minime wont toggle decorated and keep above
32
+ --notdecorated Dont decorate window
33
+ ```
34
+ ## More
35
+
36
+ * Mouse button 1 on logo: minime
37
+ * Mouse button 2 on logo: app menu
38
+ * Toolbar "Edit" button opens the tasks markdown file with `gedit` by default
39
+ * Configuration file: `~/.config/gtk3app/gtk2checkboxes/config-*.rbon`
40
+
41
+ You can change your editor from `gedit` to something else in the configuration
42
+ file. The process should not detach(go to background). For example, I edited
43
+ my `Editor:` key from:
44
+
45
+ Editor: "gedit $cachefile",
46
+
47
+ to:
48
+
49
+ Editor: "foot -W 80x13 nvim $cachefile 2>/dev/null",
50
+
51
+ Note that the tasks cache file is markdown.
52
+ Any line that matches `/^- \[x| \] /` is considered to be a check box and
53
+ should be followed by an item to be checked off.
54
+ All other lines are ignored by the application.
55
+
56
+ ## LICENSE
57
+
58
+ (The MIT License)
59
+
60
+ Copyright (c) 2021 CarlosJHR64
61
+
62
+ Permission is hereby granted, free of charge, to any person obtaining
63
+ a copy of this software and associated documentation files (the
64
+ 'Software'), to deal in the Software without restriction, including
65
+ without limitation the rights to use, copy, modify, merge, publish,
66
+ distribute, sublicense, and/or sell copies of the Software, and to
67
+ permit persons to whom the Software is furnished to do so, subject to
68
+ the following conditions:
69
+
70
+ The above copyright notice and this permission notice shall be
71
+ included in all copies or substantial portions of the Software.
72
+
73
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
74
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
75
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
76
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
77
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
78
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
79
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env ruby
2
+ require 'gtk2checkboxes'
3
+
4
+ case ARGV
5
+ in [/^(-v)|(--version)$/]
6
+ puts Gtk2CheckBoxes::VERSION
7
+ in [/^(-h)|(--help)$/]
8
+ puts Gtk2CheckBoxes::HELP
9
+ else
10
+ Gtk2CheckBoxes.run
11
+ end
12
+ exit
data/data/logo.png ADDED
Binary file
@@ -0,0 +1,105 @@
1
+ class Gtk2CheckBoxes
2
+ using Rafini::String # String#semantic
3
+ extend Rafini::Empty # a0 and h0
4
+
5
+ CACHE = File.join UserSpace::XDG['cache'], 'gtk3app', 'gtk2checkboxes'
6
+ DATA_DIR = File.join UserSpace::XDG['data'], 'gtk3app', 'gtk2checkboxes'
7
+
8
+ CONFIG = {
9
+ DefaultTab: 'TODO',
10
+ Editor: 'gedit $cachefile',
11
+ HelpFile: 'https://github.com/carlosjhr64/gtk2checkboxes',
12
+ Logo: "#{DATA_DIR}/logo.png",
13
+
14
+ about_dialog: {
15
+ set_program_name: 'Gtk2CheckBoxes',
16
+ set_version: VERSION.semantic(0..1),
17
+ set_copyright: '(c) 2021 CarlosJHR64',
18
+ set_comments: 'A Ruby Gtk3App With Check-Boxes',
19
+ set_website: 'https://github.com/carlosjhr64/gtk2checkboxes',
20
+ set_website_label: 'See it at GitHub!',
21
+ },
22
+
23
+ DIALOG_ENTRY: a0,
24
+ dialog_entry: h0,
25
+ dialog_entry!: [:DIALOG_ENTRY, :dialog_entry],
26
+
27
+ ITEM_DIALOG: [title: 'Append Item'],
28
+ item_dialog: h0,
29
+ item_dialog!: [:ITEM_DIALOG, :item_dialog],
30
+
31
+ RENAME_DIALOG: [title: 'Raname Page'],
32
+ rename_dialog: h0,
33
+ rename_dialog!: [:RENAME_DIALOG, :rename_dialog],
34
+
35
+ ADD_DIALOG: [title: 'Add Page'],
36
+ add_dialog: h0,
37
+ add_dialog!: [:ADD_DIALOG, :add_dialog],
38
+
39
+ UNIQ_NAME: [title: 'Need one unique word:'],
40
+ uniq_name: h0,
41
+ uniq_name!: [:UNIQ_NAME, :uniq_name],
42
+
43
+ UNIQ_ITEM: [title: 'Need unique item:'],
44
+ uniq_item: h0,
45
+ uniq_item!: [:UNIQ_ITEM, :uniq_item],
46
+
47
+ DELETE_DIALOG: [title: 'Detete Page'],
48
+ delete_dialog: h0,
49
+ delete_dialog!: [:DELETE_DIALOG, :delete_dialog],
50
+
51
+ DELETE_LABEL: ['Are you sure?'],
52
+ delete_label: h0,
53
+ delete_label!: [:DELETE_LABEL, :delete_label],
54
+
55
+ window: {
56
+ set_title: 'Gtk2CheckBoxes',
57
+ set_window_position: :center,
58
+ },
59
+
60
+ NOTEBOOK: a0,
61
+ notebook: h0,
62
+ notebook!: [:NOTEBOOK, :notebook],
63
+
64
+ tab_label: h0,
65
+
66
+ VBOX: [:vertical],
67
+ vbox: {
68
+ into: [:append_page],
69
+ show: a0,
70
+ },
71
+ vbox!: [:VBOX, :vbox],
72
+
73
+ CHECKBUTTON: a0,
74
+ checkbutton: {show: a0},
75
+ checkbutton!: [:CHECKBUTTON, :checkbutton],
76
+
77
+ HBOX: [:horizontal],
78
+ hbox: h0,
79
+ hbox!: [:HBOX, :hbox],
80
+
81
+ APPEND_ITEM: [label: 'Append item'],
82
+ append_item: h0,
83
+ append_item!: [:APPEND_ITEM, :append_item],
84
+
85
+ EDIT_PAGE: [label: 'Edit'],
86
+ edit_page: h0,
87
+ edit_page!: [:EDIT_PAGE, :edit_page],
88
+
89
+ ADD_PAGE: [label: 'Add'],
90
+ add_page: h0,
91
+ add_page!: [:ADD_PAGE, :add_page],
92
+
93
+ RENAME_PAGE: [label: 'Rename'],
94
+ rename_page: h0,
95
+ rename_page!: [:RENAME_PAGE, :rename_page],
96
+
97
+ DELETE_PAGE: [label: 'Delete'],
98
+ delete_page: h0,
99
+ delete_page!: [:DELETE_PAGE, :delete_page],
100
+
101
+ app_menu: {
102
+ add_menu_item: [:minime!, :help!, :about!, :quit!],
103
+ },
104
+ }
105
+ end
@@ -0,0 +1,216 @@
1
+ class Gtk2CheckBoxes
2
+ class YesNo < Such::Dialog
3
+ def initialize(*par)
4
+ super(*par)
5
+ add_button Gtk::Stock::NO, Gtk::ResponseType::CANCEL
6
+ add_button Gtk::Stock::YES, Gtk::ResponseType::OK
7
+ end
8
+
9
+ def label(*par)
10
+ Such::Label.new child, *par
11
+ end
12
+
13
+ def yes?
14
+ show_all
15
+ response = run
16
+ destroy
17
+ response == Gtk::ResponseType::OK
18
+ end
19
+ end
20
+
21
+ class EntryDialog < Such::Dialog
22
+ def initialize(*par)
23
+ super(*par)
24
+ add_button Gtk::Stock::CANCEL, Gtk::ResponseType::CANCEL
25
+ add_button Gtk::Stock::OK, Gtk::ResponseType::OK
26
+ end
27
+
28
+ def entry(*par)
29
+ @entry = Such::Entry.new child, *par
30
+ end
31
+
32
+ def text
33
+ show_all
34
+ text = (run == Gtk::ResponseType::OK)? @entry.text : nil
35
+ destroy
36
+ text
37
+ end
38
+ end
39
+
40
+ def page
41
+ @notebook.children[@notebook.page]
42
+ end
43
+
44
+ def tab
45
+ @notebook.get_tab_label(page).text
46
+ end
47
+
48
+ def cachefile
49
+ File.join CACHE, tab+'.md'
50
+ end
51
+
52
+ def add_check_button(vbox, text, status)
53
+ checkbutton = Such::CheckButton.new(
54
+ vbox,
55
+ {set_label: text, set_active: status},
56
+ :checkbutton!,
57
+ 'toggled'
58
+ ) do
59
+ x = checkbutton.active? ? 'x' : ' '
60
+ # Note that x was toggled, so the xbox is inverted for the matcher.
61
+ xbox = checkbutton.active? ? '- [ ]' : '- [x]'
62
+ matcher = "#{xbox} #{checkbutton.label}"
63
+ File.open(cachefile, 'r+') do |fh|
64
+ fh.each_line do |line|
65
+ if matcher == line.chomp
66
+ fh.seek(3-line.length, IO::SEEK_CUR)
67
+ fh.write x
68
+ break
69
+ end
70
+ end
71
+ end
72
+ end
73
+ end
74
+
75
+ def populate_page(fn=cachefile, vbox=page)
76
+ File.open(fn, 'r') do |fh|
77
+ fh.each do |line|
78
+ line.chomp!
79
+ case line
80
+ when %r{^\- \[ \] (.*)$}
81
+ add_check_button vbox, $1, false
82
+ when %r{^\- \[x\] (.*)$}
83
+ add_check_button vbox, $1, true
84
+ end
85
+ end
86
+ end
87
+ end
88
+
89
+ def clear
90
+ page.each do |item|
91
+ page.remove item
92
+ item.destroy
93
+ end
94
+ end
95
+
96
+ def reload
97
+ clear
98
+ populate_page
99
+ end
100
+
101
+ def delete
102
+ clear
103
+ # Notebook requires at least one page
104
+ if @notebook.children.length > 1
105
+ @notebook.remove_page @notebook.page
106
+ else
107
+ FileUtils.touch cachefile
108
+ end
109
+ end
110
+
111
+ def set_tab_text(text)
112
+ @notebook.get_tab_label(page).set_text text
113
+ end
114
+
115
+ def tab_exist?(text)
116
+ @notebook.children.each do |page|
117
+ return true if text == @notebook.get_tab_label(page).text
118
+ end
119
+ return false
120
+ end
121
+
122
+ def get_new_page_name(dialog_key)
123
+ loop do
124
+ dialog = EntryDialog.new dialog_key
125
+ dialog.entry :dialog_entry!
126
+ Gtk3App.transient dialog
127
+ text = dialog.text
128
+ return text if text.nil? or (/^\w+$/.match? text and not tab_exist? text)
129
+ dialog_key = :uniq_name!
130
+ end
131
+ end
132
+
133
+ def item_exist?(text)
134
+ page.each do |checkbutton|
135
+ return true if checkbutton.label == text
136
+ end
137
+ return false
138
+ end
139
+
140
+ def get_new_item(dialog_key)
141
+ loop do
142
+ dialog = EntryDialog.new dialog_key
143
+ dialog.entry :dialog_entry!
144
+ Gtk3App.transient dialog
145
+ text = dialog.text
146
+ return text unless item_exist? text
147
+ dialog_key = :uniq_item!
148
+ end
149
+ end
150
+
151
+ def append(text)
152
+ File.open(cachefile, 'a'){_1.puts '- [ ] '+text}
153
+ end
154
+
155
+ def add_page(fn, populate:false, touch:false)
156
+ label = File.basename fn, '.*'
157
+ vbox = Such::Box.new @notebook, :vbox!
158
+ @notebook.set_tab_label vbox, Such::Label.new([label], :tab_label)
159
+ populate_page(fn, vbox) if populate and File.exist? fn
160
+ FileUtils.touch File.join(CACHE, label+'.md') if touch
161
+ end
162
+
163
+ def initialize(stage, toolbar, options)
164
+ @notebook = Such::Notebook.new stage, :notebook!
165
+ Find.find(CACHE) do |fn|
166
+ Find.prune if !(fn==CACHE) && File.directory?(fn)
167
+ case fn
168
+ when %r{/\w+\.md$}
169
+ add_page fn, populate:true
170
+ when %r{/\w+\.md\.bak$}
171
+ File.unlink fn
172
+ end
173
+ end
174
+ add_page CONFIG[:DefaultTab], touch:true if @notebook.children.empty?
175
+ @tools = Such::Box.new toolbar, :hbox!
176
+ Such::Button.new @tools, :append_item! do
177
+ if item = get_new_item(:item_dialog!)
178
+ append item
179
+ add_check_button page, item, false
180
+ end
181
+ end
182
+ Such::Button.new @tools, :edit_page! do
183
+ start = Time.now
184
+ system CONFIG[:Editor].sub('$cachefile', cachefile)
185
+ reload if File.mtime(cachefile) > start
186
+ end
187
+ Such::Button.new @tools, :rename_page! do
188
+ if text = get_new_page_name(:rename_dialog!)
189
+ File.rename cachefile, File.join(CACHE, text+'.md')
190
+ set_tab_text text
191
+ end
192
+ end
193
+ Such::Button.new @tools, :add_page! do
194
+ if text = get_new_page_name(:add_dialog!)
195
+ add_page text, touch:true
196
+ end
197
+ end
198
+ Such::Button.new @tools, :delete_page! do
199
+ dialog = YesNo.new :delete_dialog!
200
+ dialog.label :delete_label!
201
+ Gtk3App.transient dialog
202
+ if dialog.yes?
203
+ File.rename cachefile, cachefile+'.bak'
204
+ delete
205
+ end
206
+ end
207
+ Gtk3App.logo_press_event do |button|
208
+ case button
209
+ when 1
210
+ Gtk3App.minime!
211
+ # When 2 Nothing
212
+ # When 3 gets captured by Gtk3App's main menu
213
+ end
214
+ end
215
+ end
216
+ end
@@ -0,0 +1,29 @@
1
+ class Gtk2CheckBoxes
2
+ HELP = <<~HELP
3
+ Usage:
4
+ gtk2checkboxes [:options+]
5
+ Options:
6
+ -h --help
7
+ -v --version
8
+ --minime \t Real minime
9
+ --notoggle \t Minime wont toggle decorated and keep above
10
+ --notdecorated\t Dont decorate window
11
+ HELP
12
+ VERSION = '3.0.210824'
13
+
14
+ def self.run
15
+ # StdLib
16
+ require 'find'
17
+ require 'fileutils'
18
+ # Gems
19
+ require 'gtk3app'
20
+ # This Gem
21
+ require_relative 'gtk2checkboxes/config.rb'
22
+ require_relative 'gtk2checkboxes/gtk2checkboxes.rb'
23
+ # Run
24
+ Gtk3App.run(klass:Gtk2CheckBoxes)
25
+ end
26
+ end
27
+ # Requires:
28
+ #`ruby`
29
+ #`gedit`
metadata ADDED
@@ -0,0 +1,78 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gtk2checkboxes
3
+ version: !ruby/object:Gem::Version
4
+ version: 3.0.210824
5
+ platform: ruby
6
+ authors:
7
+ - carlosjhr64
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2021-08-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: gtk3app
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '5.1'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 5.1.210203
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '5.1'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 5.1.210203
33
+ description: |
34
+ Create a simple shopping list.
35
+ Maintain a check list of reacuring chores.
36
+ Anything that one would make a check list for.
37
+
38
+ Just a really simple app.
39
+ Allows for multiple lists.
40
+ email: carlosjhr64@gmail.com
41
+ executables:
42
+ - gtk2checkboxes
43
+ extensions: []
44
+ extra_rdoc_files: []
45
+ files:
46
+ - README.md
47
+ - bin/gtk2checkboxes
48
+ - data/logo.png
49
+ - lib/gtk2checkboxes.rb
50
+ - lib/gtk2checkboxes/config.rb
51
+ - lib/gtk2checkboxes/gtk2checkboxes.rb
52
+ homepage: https://github.com/carlosjhr64/gtk2checkboxes
53
+ licenses:
54
+ - MIT
55
+ metadata: {}
56
+ post_install_message:
57
+ rdoc_options: []
58
+ require_paths:
59
+ - lib
60
+ required_ruby_version: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: '0'
65
+ required_rubygems_version: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ requirements:
71
+ - 'ruby: ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [x86_64-linux]'
72
+ - 'gedit: gedit - Version 40.1'
73
+ rubygems_version: 3.2.22
74
+ signing_key:
75
+ specification_version: 4
76
+ summary: Create a simple shopping list. Maintain a check list of reacuring chores.
77
+ Anything that one would make a check list for.
78
+ test_files: []