json_viewer_gtk3 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/exe/jsonview +1 -1
- data/lib/jsonview/application_window.rb +47 -19
- data/lib/jsonview/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a3f0ed31efa98e74210f28622c365fde69ac46a3440c4b72c0e03316157cd749
|
4
|
+
data.tar.gz: f532776bb68b49ca8f4fcb9b446ddd37afd9c0bc41fb80b9ebd0cc1662123f43
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dcda865a7a45a49b7357ee56bcb54d1df9e13005a8cbc8503f41bc263d443a649fe660877c175e79afbc5db3353f7dc0fb258f0f4f7d646b43221daf0e478b8e
|
7
|
+
data.tar.gz: 5d5f86dbeee47cd09c457cdfb441c4a1333ba2d5e4d91eb1fc6bc0bc0ff18af9b854521f49b3a5b40d4a5b205cd1b38719104998df82095c03415909440cf742
|
data/exe/jsonview
CHANGED
@@ -29,7 +29,7 @@ resource = Gio::Resource.load(resource_bin)
|
|
29
29
|
Gio::Resources.register(resource)
|
30
30
|
|
31
31
|
app.signal_connect :activate do |application|
|
32
|
-
window = JsonView::ApplicationWindow.new application
|
32
|
+
window = JsonView::ApplicationWindow.new application, ARGV
|
33
33
|
window.present
|
34
34
|
end
|
35
35
|
|
@@ -17,12 +17,13 @@ module JsonView
|
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
|
-
def initialize(application)
|
20
|
+
def initialize(application, argv)
|
21
21
|
super application: application
|
22
22
|
set_title 'JsonView'
|
23
23
|
set_icon GdkPixbuf::Pixbuf.new(
|
24
24
|
resource: '/com/github/kojix2/jsonview/ruby.png'
|
25
25
|
)
|
26
|
+
argv[0] && open_json(argv[0])
|
26
27
|
end
|
27
28
|
|
28
29
|
def on_open_clicked
|
@@ -36,6 +37,7 @@ module JsonView
|
|
36
37
|
Gtk::FileFilter.new.tap do |f|
|
37
38
|
f.name = 'Json'
|
38
39
|
f.add_pattern('*.json')
|
40
|
+
f.add_pattern('*.JSON')
|
39
41
|
dialog.add_filter f
|
40
42
|
end
|
41
43
|
Gtk::FileFilter.new.tap do |f|
|
@@ -57,43 +59,69 @@ module JsonView
|
|
57
59
|
data = File.open(filename) do |file|
|
58
60
|
JSON.load(file)
|
59
61
|
end
|
60
|
-
@
|
61
|
-
@
|
62
|
+
@treemodel&.destroy
|
63
|
+
@treemodel = Gtk::TreeStore.new(String, Float, String)
|
62
64
|
create_model(data)
|
63
|
-
treeview.model = @
|
65
|
+
treeview.model = @treemodel
|
64
66
|
|
65
67
|
column = Gtk::TreeViewColumn.new(
|
66
68
|
File.basename(filename),
|
67
69
|
Gtk::CellRendererText.new,
|
68
|
-
{
|
69
|
-
text: 0,
|
70
|
-
scale: 1
|
71
|
-
}
|
70
|
+
{ text: 0, scale: 1, foreground: 2 }
|
72
71
|
)
|
73
72
|
treeview.append_column(column)
|
74
73
|
end
|
75
74
|
|
76
|
-
def create_model(data, parent = nil,
|
77
|
-
parent ||= @
|
75
|
+
def create_model(data, parent = nil, level = 0)
|
76
|
+
parent ||= @treemodel.append(nil)
|
78
77
|
case data
|
79
78
|
when Hash
|
80
79
|
data.each do |key, value|
|
81
|
-
i = @
|
80
|
+
i = @treemodel.append(parent)
|
82
81
|
i[0] = key.to_s
|
83
|
-
i[1] =
|
84
|
-
create_model(value, i,
|
82
|
+
i[1] = 1.0 # drate ** level
|
83
|
+
create_model(value, i, level + 1)
|
85
84
|
end
|
86
85
|
when Array
|
87
86
|
data.each do |value|
|
88
|
-
i = @
|
87
|
+
i = @treemodel.append(parent)
|
89
88
|
i[0] = ''
|
90
|
-
i[1] =
|
91
|
-
create_model(value, i,
|
89
|
+
i[1] = 1.0 # drate ** level
|
90
|
+
create_model(value, i, level + 1)
|
92
91
|
end
|
93
|
-
when String
|
94
|
-
|
92
|
+
when String
|
93
|
+
level += 1
|
94
|
+
@treemodel.append(parent).tap do |j|
|
95
|
+
j[0] = data
|
96
|
+
j[1] = 1.0 # drate ** level
|
97
|
+
end
|
98
|
+
when Numeric, Integer
|
99
|
+
level += 1
|
100
|
+
@treemodel.append(parent).tap do |j|
|
101
|
+
j[0] = data.to_s
|
102
|
+
j[1] = 1.0 # drate ** level
|
103
|
+
j[2] = 'yellow'
|
104
|
+
end
|
105
|
+
when true
|
106
|
+
level += 1
|
107
|
+
@treemodel.append(parent).tap do |j|
|
108
|
+
j[0] = data.to_s
|
109
|
+
j[1] = 1.0 # drate ** level
|
110
|
+
j[2] = 'magenta'
|
111
|
+
end
|
112
|
+
when false
|
113
|
+
level += 1
|
114
|
+
@treemodel.append(parent).tap do |j|
|
115
|
+
j[0] = data.to_s
|
116
|
+
j[1] = 1.0 # drate ** level
|
117
|
+
j[2] = 'cyan'
|
118
|
+
end
|
119
|
+
else
|
120
|
+
level += 1
|
121
|
+
@treemodel.append(parent).tap do |j|
|
95
122
|
j[0] = data.to_s
|
96
|
-
j[1] =
|
123
|
+
j[1] = 1.0 # drate ** level
|
124
|
+
j[2] = 'lime'
|
97
125
|
end
|
98
126
|
end
|
99
127
|
end
|
data/lib/jsonview/version.rb
CHANGED