manabu-desktop 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: c5463ef8c2c2183a6bf22dc0c42d2524657b3c97
4
- data.tar.gz: 440212f0b9c492583bf6a7d0bb191e25fdc71e2c
2
+ SHA256:
3
+ metadata.gz: 32c069cc51203938eb8b46ae1561264d5da3927692b167f6d12149252d7e586e
4
+ data.tar.gz: 6c2c03b13a2aa3569587cd76bc51fec154fcfe772f50fa6a3ab515eacd469ba8
5
5
  SHA512:
6
- metadata.gz: 1588d5019fd78bd3b65b5b9afcadc63d07621d3018a015c25ba9a22cfa5f8e80a176c018d0eef38352c47197d968772787cba6e121ffe5ff6ccbf432e2501697
7
- data.tar.gz: 57ff51c12098636fb8091ba63c2f1885ed94efaae3d76f7da0e945134671640e5c50b6d6ec3a619e675d7feded698a31e6e41ce90cdf6e906bb8dd39ee71aa43
6
+ metadata.gz: e6cac67f7b105351f6394109efe0beecf3bd6015faccc9f1218ac4d990e638231468c6c6c4e00489555f5c5e1f7f784642181304b05a06bad95d6a58b7843142
7
+ data.tar.gz: 9744817f5210f46a6f09fc869c05ac8d39ff83a135992966239d06fb713cbb3f5900ed6995f1ed91482a49cc32d85f7218df06f3e3acc780239c6b0fa8b5d981
data/layouts/login.glade CHANGED
@@ -2,6 +2,11 @@
2
2
  <!-- Generated with glade 3.20.0 -->
3
3
  <interface>
4
4
  <requires lib="gtk+" version="3.20"/>
5
+ <object class="GtkImage" id="engage.icon">
6
+ <property name="visible">True</property>
7
+ <property name="can_focus">False</property>
8
+ <property name="stock">gtk-dialog-authentication</property>
9
+ </object>
5
10
  <object class="GtkWindow" id="login.window">
6
11
  <property name="can_focus">False</property>
7
12
  <child>
@@ -9,11 +14,12 @@
9
14
  <property name="visible">True</property>
10
15
  <property name="can_focus">False</property>
11
16
  <property name="orientation">vertical</property>
17
+ <property name="spacing">6</property>
12
18
  <child>
13
19
  <object class="GtkImage" id="logo.image">
14
20
  <property name="visible">True</property>
15
21
  <property name="can_focus">False</property>
16
- <property name="pixbuf">./img/gaku-logo-128.png</property>
22
+ <property name="pixbuf">img/gaku-logo-128.png</property>
17
23
  </object>
18
24
  <packing>
19
25
  <property name="expand">False</property>
@@ -22,15 +28,15 @@
22
28
  </packing>
23
29
  </child>
24
30
  <child>
25
- <object class="GtkBox" id="login.server.box">
31
+ <object class="GtkBox" id="server.box">
26
32
  <property name="visible">True</property>
27
33
  <property name="can_focus">False</property>
28
34
  <property name="homogeneous">True</property>
29
35
  <child>
30
- <object class="GtkLabel" id="login.server.label">
36
+ <object class="GtkLabel" id="server.label">
31
37
  <property name="visible">True</property>
32
38
  <property name="can_focus">False</property>
33
- <property name="label" translatable="yes">login.server</property>
39
+ <property name="label" translatable="yes">server.label</property>
34
40
  </object>
35
41
  <packing>
36
42
  <property name="expand">False</property>
@@ -39,13 +45,16 @@
39
45
  </packing>
40
46
  </child>
41
47
  <child>
42
- <object class="GtkComboBoxText" id="login.server.dropdown">
48
+ <object class="GtkComboBoxText" id="server.comboboxtext">
43
49
  <property name="visible">True</property>
44
50
  <property name="can_focus">False</property>
45
51
  <property name="has_entry">True</property>
46
52
  <child internal-child="entry">
47
- <object class="GtkEntry">
48
- <property name="can_focus">False</property>
53
+ <object class="GtkEntry" id="server.entry">
54
+ <property name="visible">True</property>
55
+ <property name="can_focus">True</property>
56
+ <property name="caps_lock_warning">False</property>
57
+ <property name="input_purpose">url</property>
49
58
  </object>
50
59
  </child>
51
60
  </object>
@@ -63,15 +72,15 @@
63
72
  </packing>
64
73
  </child>
65
74
  <child>
66
- <object class="GtkBox" id="login.user.box">
75
+ <object class="GtkBox" id="secure.box">
67
76
  <property name="visible">True</property>
68
77
  <property name="can_focus">False</property>
69
78
  <property name="homogeneous">True</property>
70
79
  <child>
71
- <object class="GtkLabel" id="login.user.label">
80
+ <object class="GtkLabel" id="secure.label">
72
81
  <property name="visible">True</property>
73
82
  <property name="can_focus">False</property>
74
- <property name="label" translatable="yes">login.user</property>
83
+ <property name="label" translatable="yes">secure.label</property>
75
84
  </object>
76
85
  <packing>
77
86
  <property name="expand">False</property>
@@ -80,9 +89,10 @@
80
89
  </packing>
81
90
  </child>
82
91
  <child>
83
- <object class="GtkEntry">
92
+ <object class="GtkSwitch" id="secure.switch">
84
93
  <property name="visible">True</property>
85
94
  <property name="can_focus">True</property>
95
+ <property name="active">True</property>
86
96
  </object>
87
97
  <packing>
88
98
  <property name="expand">False</property>
@@ -98,15 +108,15 @@
98
108
  </packing>
99
109
  </child>
100
110
  <child>
101
- <object class="GtkBox" id="login.pass.box">
111
+ <object class="GtkBox" id="user.box">
102
112
  <property name="visible">True</property>
103
113
  <property name="can_focus">False</property>
104
114
  <property name="homogeneous">True</property>
105
115
  <child>
106
- <object class="GtkLabel" id="login.pass.label">
116
+ <object class="GtkLabel" id="user.label">
107
117
  <property name="visible">True</property>
108
118
  <property name="can_focus">False</property>
109
- <property name="label" translatable="yes">login.pass</property>
119
+ <property name="label" translatable="yes">user.label</property>
110
120
  </object>
111
121
  <packing>
112
122
  <property name="expand">False</property>
@@ -115,7 +125,7 @@
115
125
  </packing>
116
126
  </child>
117
127
  <child>
118
- <object class="GtkEntry">
128
+ <object class="GtkEntry" id="user.entry">
119
129
  <property name="visible">True</property>
120
130
  <property name="can_focus">True</property>
121
131
  </object>
@@ -133,18 +143,58 @@
133
143
  </packing>
134
144
  </child>
135
145
  <child>
136
- <object class="GtkButton" id="login.button">
137
- <property name="label" translatable="yes">login.button</property>
146
+ <object class="GtkBox" id="password.box">
147
+ <property name="visible">True</property>
148
+ <property name="can_focus">False</property>
149
+ <property name="homogeneous">True</property>
150
+ <child>
151
+ <object class="GtkLabel" id="password.label">
152
+ <property name="visible">True</property>
153
+ <property name="can_focus">False</property>
154
+ <property name="label" translatable="yes">password.label</property>
155
+ </object>
156
+ <packing>
157
+ <property name="expand">False</property>
158
+ <property name="fill">True</property>
159
+ <property name="position">0</property>
160
+ </packing>
161
+ </child>
162
+ <child>
163
+ <object class="GtkEntry" id="password.entry">
164
+ <property name="visible">True</property>
165
+ <property name="can_focus">True</property>
166
+ <property name="visibility">False</property>
167
+ <property name="invisible_char">*</property>
168
+ <property name="input_purpose">password</property>
169
+ </object>
170
+ <packing>
171
+ <property name="expand">False</property>
172
+ <property name="fill">True</property>
173
+ <property name="position">1</property>
174
+ </packing>
175
+ </child>
176
+ </object>
177
+ <packing>
178
+ <property name="expand">False</property>
179
+ <property name="fill">True</property>
180
+ <property name="position">4</property>
181
+ </packing>
182
+ </child>
183
+ <child>
184
+ <object class="GtkButton" id="engage.button">
185
+ <property name="label" translatable="yes">engage.button</property>
138
186
  <property name="visible">True</property>
139
187
  <property name="can_focus">True</property>
140
188
  <property name="receives_default">True</property>
189
+ <property name="image">engage.icon</property>
190
+ <property name="always_show_image">True</property>
141
191
  </object>
142
192
  <packing>
143
193
  <property name="expand">False</property>
144
194
  <property name="fill">True</property>
145
195
  <property name="padding">2</property>
146
196
  <property name="pack_type">end</property>
147
- <property name="position">4</property>
197
+ <property name="position">5</property>
148
198
  </packing>
149
199
  </child>
150
200
  </object>
@@ -88,6 +88,17 @@
88
88
  <property name="position">3</property>
89
89
  </packing>
90
90
  </child>
91
+ <child>
92
+ <object class="GtkListBox" id="connection.list">
93
+ <property name="visible">True</property>
94
+ <property name="can_focus">False</property>
95
+ </object>
96
+ <packing>
97
+ <property name="expand">False</property>
98
+ <property name="fill">True</property>
99
+ <property name="position">4</property>
100
+ </packing>
101
+ </child>
91
102
  <child>
92
103
  <object class="GtkStatusbar" id="status.bar">
93
104
  <property name="visible">True</property>
@@ -104,7 +115,7 @@
104
115
  <packing>
105
116
  <property name="expand">False</property>
106
117
  <property name="fill">True</property>
107
- <property name="position">4</property>
118
+ <property name="position">5</property>
108
119
  </packing>
109
120
  </child>
110
121
  </object>
@@ -0,0 +1,51 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!-- Generated with glade 3.20.0 -->
3
+ <interface>
4
+ <requires lib="gtk+" version="3.20"/>
5
+ <object class="GtkWindow" id="roster.window">
6
+ <property name="can_focus">False</property>
7
+ <child>
8
+ <object class="GtkBox" id="roster.box">
9
+ <property name="visible">True</property>
10
+ <property name="can_focus">False</property>
11
+ <property name="orientation">vertical</property>
12
+ <child>
13
+ <object class="GtkToolbar" id="roster.toolbar">
14
+ <property name="visible">True</property>
15
+ <property name="can_focus">False</property>
16
+ </object>
17
+ <packing>
18
+ <property name="expand">False</property>
19
+ <property name="fill">True</property>
20
+ <property name="position">0</property>
21
+ </packing>
22
+ </child>
23
+ <child>
24
+ <object class="GtkScrolledWindow" id="roster.scrolledwindow">
25
+ <property name="visible">True</property>
26
+ <property name="can_focus">True</property>
27
+ <property name="shadow_type">in</property>
28
+ <property name="min_content_width">756</property>
29
+ <property name="min_content_height">480</property>
30
+ <property name="propagate_natural_width">True</property>
31
+ <property name="propagate_natural_height">True</property>
32
+ <child>
33
+ <object class="GtkTreeView" id="roster.treeview">
34
+ <property name="visible">True</property>
35
+ <property name="can_focus">True</property>
36
+ <child internal-child="selection">
37
+ <object class="GtkTreeSelection"/>
38
+ </child>
39
+ </object>
40
+ </child>
41
+ </object>
42
+ <packing>
43
+ <property name="expand">False</property>
44
+ <property name="fill">True</property>
45
+ <property name="position">1</property>
46
+ </packing>
47
+ </child>
48
+ </object>
49
+ </child>
50
+ </object>
51
+ </interface>
@@ -0,0 +1,224 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!-- Generated with glade 3.20.0 -->
3
+ <interface>
4
+ <requires lib="gtk+" version="3.20"/>
5
+ <object class="GtkWindow" id="student_registration.window">
6
+ <property name="can_focus">False</property>
7
+ <child>
8
+ <object class="GtkBox">
9
+ <property name="visible">True</property>
10
+ <property name="can_focus">False</property>
11
+ <property name="orientation">vertical</property>
12
+ <child>
13
+ <object class="GtkGrid" id="name.grid">
14
+ <property name="visible">True</property>
15
+ <property name="can_focus">False</property>
16
+ <child>
17
+ <object class="GtkLabel" id="surname.label">
18
+ <property name="visible">True</property>
19
+ <property name="can_focus">False</property>
20
+ <property name="label" translatable="yes">surname</property>
21
+ </object>
22
+ <packing>
23
+ <property name="left_attach">0</property>
24
+ <property name="top_attach">0</property>
25
+ </packing>
26
+ </child>
27
+ <child>
28
+ <object class="GtkLabel" id="name.label">
29
+ <property name="visible">True</property>
30
+ <property name="can_focus">False</property>
31
+ <property name="label" translatable="yes">name</property>
32
+ </object>
33
+ <packing>
34
+ <property name="left_attach">1</property>
35
+ <property name="top_attach">0</property>
36
+ </packing>
37
+ </child>
38
+ <child>
39
+ <object class="GtkLabel" id="middle_name.label">
40
+ <property name="visible">True</property>
41
+ <property name="can_focus">False</property>
42
+ <property name="label" translatable="yes">middle_name</property>
43
+ </object>
44
+ <packing>
45
+ <property name="left_attach">2</property>
46
+ <property name="top_attach">0</property>
47
+ </packing>
48
+ </child>
49
+ <child>
50
+ <object class="GtkEntry" id="surname.entry">
51
+ <property name="visible">True</property>
52
+ <property name="can_focus">True</property>
53
+ </object>
54
+ <packing>
55
+ <property name="left_attach">0</property>
56
+ <property name="top_attach">1</property>
57
+ </packing>
58
+ </child>
59
+ <child>
60
+ <object class="GtkEntry" id="name.entry">
61
+ <property name="visible">True</property>
62
+ <property name="can_focus">True</property>
63
+ </object>
64
+ <packing>
65
+ <property name="left_attach">1</property>
66
+ <property name="top_attach">1</property>
67
+ </packing>
68
+ </child>
69
+ <child>
70
+ <object class="GtkEntry" id="middle_name.entry">
71
+ <property name="visible">True</property>
72
+ <property name="can_focus">True</property>
73
+ </object>
74
+ <packing>
75
+ <property name="left_attach">2</property>
76
+ <property name="top_attach">1</property>
77
+ </packing>
78
+ </child>
79
+ <child>
80
+ <object class="GtkLabel" id="surname_reading.label">
81
+ <property name="visible">True</property>
82
+ <property name="can_focus">False</property>
83
+ <property name="label" translatable="yes">surname_reading</property>
84
+ </object>
85
+ <packing>
86
+ <property name="left_attach">0</property>
87
+ <property name="top_attach">2</property>
88
+ </packing>
89
+ </child>
90
+ <child>
91
+ <object class="GtkLabel" id="name_reading.label">
92
+ <property name="visible">True</property>
93
+ <property name="can_focus">False</property>
94
+ <property name="label" translatable="yes">name_reading</property>
95
+ </object>
96
+ <packing>
97
+ <property name="left_attach">1</property>
98
+ <property name="top_attach">2</property>
99
+ </packing>
100
+ </child>
101
+ <child>
102
+ <object class="GtkLabel" id="middle_name_reading.label">
103
+ <property name="visible">True</property>
104
+ <property name="can_focus">False</property>
105
+ <property name="label" translatable="yes">middle_name_reading</property>
106
+ </object>
107
+ <packing>
108
+ <property name="left_attach">2</property>
109
+ <property name="top_attach">2</property>
110
+ </packing>
111
+ </child>
112
+ <child>
113
+ <object class="GtkEntry" id="surname_reading.entry">
114
+ <property name="visible">True</property>
115
+ <property name="can_focus">True</property>
116
+ </object>
117
+ <packing>
118
+ <property name="left_attach">0</property>
119
+ <property name="top_attach">3</property>
120
+ </packing>
121
+ </child>
122
+ <child>
123
+ <object class="GtkEntry" id="name_reading.entry">
124
+ <property name="visible">True</property>
125
+ <property name="can_focus">True</property>
126
+ </object>
127
+ <packing>
128
+ <property name="left_attach">1</property>
129
+ <property name="top_attach">3</property>
130
+ </packing>
131
+ </child>
132
+ <child>
133
+ <object class="GtkEntry" id="middle_name_reading.entry">
134
+ <property name="visible">True</property>
135
+ <property name="can_focus">True</property>
136
+ </object>
137
+ <packing>
138
+ <property name="left_attach">2</property>
139
+ <property name="top_attach">3</property>
140
+ </packing>
141
+ </child>
142
+ </object>
143
+ <packing>
144
+ <property name="expand">False</property>
145
+ <property name="fill">True</property>
146
+ <property name="position">0</property>
147
+ </packing>
148
+ </child>
149
+ <child>
150
+ <object class="GtkGrid" id="student_details.grid">
151
+ <property name="visible">True</property>
152
+ <property name="can_focus">False</property>
153
+ <child>
154
+ <object class="GtkLabel" id="sex.label">
155
+ <property name="visible">True</property>
156
+ <property name="can_focus">False</property>
157
+ <property name="label" translatable="yes">sex</property>
158
+ </object>
159
+ <packing>
160
+ <property name="left_attach">0</property>
161
+ <property name="top_attach">0</property>
162
+ </packing>
163
+ </child>
164
+ <child>
165
+ <object class="GtkLabel" id="birth_date.label">
166
+ <property name="visible">True</property>
167
+ <property name="can_focus">False</property>
168
+ <property name="label" translatable="yes">birth_date</property>
169
+ </object>
170
+ <packing>
171
+ <property name="left_attach">1</property>
172
+ <property name="top_attach">0</property>
173
+ </packing>
174
+ </child>
175
+ <child>
176
+ <object class="GtkEntry" id="birth_date.entry">
177
+ <property name="visible">True</property>
178
+ <property name="can_focus">True</property>
179
+ </object>
180
+ <packing>
181
+ <property name="left_attach">1</property>
182
+ <property name="top_attach">1</property>
183
+ </packing>
184
+ </child>
185
+ <child>
186
+ <object class="GtkComboBoxText" id="sex.comboboxtext">
187
+ <property name="visible">True</property>
188
+ <property name="can_focus">False</property>
189
+ </object>
190
+ <packing>
191
+ <property name="left_attach">0</property>
192
+ <property name="top_attach">1</property>
193
+ </packing>
194
+ </child>
195
+ <child>
196
+ <placeholder/>
197
+ </child>
198
+ <child>
199
+ <placeholder/>
200
+ </child>
201
+ </object>
202
+ <packing>
203
+ <property name="expand">False</property>
204
+ <property name="fill">True</property>
205
+ <property name="position">1</property>
206
+ </packing>
207
+ </child>
208
+ <child>
209
+ <object class="GtkButton" id="register.button">
210
+ <property name="label" translatable="yes">register</property>
211
+ <property name="visible">True</property>
212
+ <property name="can_focus">True</property>
213
+ <property name="receives_default">True</property>
214
+ </object>
215
+ <packing>
216
+ <property name="expand">False</property>
217
+ <property name="fill">True</property>
218
+ <property name="position">2</property>
219
+ </packing>
220
+ </child>
221
+ </object>
222
+ </child>
223
+ </object>
224
+ </interface>
@@ -0,0 +1,15 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!-- Generated with glade 3.20.0 -->
3
+ <interface>
4
+ <requires lib="gtk+" version="3.20"/>
5
+ <object class="GtkWindow" id="toolbox.window">
6
+ <property name="can_focus">False</property>
7
+ <child>
8
+ <object class="GtkIconView" id="tools.icons">
9
+ <property name="visible">True</property>
10
+ <property name="can_focus">True</property>
11
+ <property name="margin">6</property>
12
+ </object>
13
+ </child>
14
+ </object>
15
+ </interface>
data/lib/screens/base.rb CHANGED
@@ -1,4 +1,4 @@
1
- require_relative '../toolbox'
1
+ require_relative '../tools'
2
2
  require 'gtk3'
3
3
 
4
4
  module ManabuDesktop
@@ -6,7 +6,7 @@ module ManabuDesktop
6
6
  class Base
7
7
  attr_accessor :window, :builder
8
8
 
9
- def initialize(layout)
9
+ def initialize(layout, locale = :c)
10
10
  @builder = Gtk::Builder.new()
11
11
  @builder.add_from_file("#{__dir__}/../../layouts/#{layout}.glade")
12
12
 
@@ -20,12 +20,14 @@ module ManabuDesktop
20
20
  end
21
21
 
22
22
  @window = builder.get_object("#{layout}.window")
23
- @window.signal_connect('delete-event') { |_widget| Gtk.main_quit }
23
+ @window.signal_connect('delete-event') do |_widget|
24
+ @window.destroy()
25
+ Gtk.main_quit()
26
+ end
24
27
  end
25
28
 
26
29
  def _show()
27
30
  @window.show()
28
-
29
31
  Gtk.main()
30
32
  end
31
33
  end
data/lib/screens/login.rb CHANGED
@@ -1,14 +1,84 @@
1
- require_relative "base"
1
+ require_relative 'base'
2
+ require_relative 'toolbox'
3
+ require_relative '../util/cache'
4
+ require_relative '../sessions'
5
+ require 'manabu/client'
2
6
 
3
7
  module ManabuDesktop
4
8
  module Screens
5
9
  class Login < ManabuDesktop::Screens::Base
6
- attr_accessor :window
10
+ attr_accessor :cache_info, :client
11
+
12
+ CACHE_FILE_NAME = "login_cache.manabu"
7
13
 
8
14
  def initialize()
9
15
  super('login')
16
+
17
+ _load_cache()
18
+
19
+ @window.resizable = false
20
+
21
+ @builder.get_object('server.label').set_label(I18n.t('login.server'))
22
+ @builder.get_object('secure.label').set_label(I18n.t('login.secure'))
23
+ @server_comboboxtext = @builder.get_object('server.comboboxtext')
24
+ @server_secure_switch = @builder.get_object('secure.switch')
25
+ @cache_info[:servers].each{ |server| @server_comboboxtext.append_text(server[:addr])}
26
+ if (@cache_info[:servers].length > 0)
27
+ @server_comboboxtext.set_active(0)
28
+ @server_secure_switch.active = @cache_info[:servers][0][:secure]
29
+ end
30
+ # TODO: set server details when selection is changed
31
+ # TODO: allow deletion of a server entry
32
+ # TODO: save new servers
33
+
34
+ @builder.get_object('user.label').set_label(I18n.t('login.user'))
35
+ @user_entry = @builder.get_object('user.entry')
36
+ @builder.get_object('password.label').set_label(I18n.t('login.password'))
37
+ @password_entry = @builder.get_object('password.entry')
38
+
39
+ engage_button = @builder.get_object('engage.button')
40
+ engage_button.set_label(I18n.t('login.engage'))
41
+ engage_button.signal_connect('clicked') {
42
+ _engage(@server_comboboxtext.active_text, @server_secure_switch.active?,
43
+ @user_entry.text, @password_entry.text)
44
+ }
45
+
10
46
  _show()
11
47
  end
48
+
49
+ def _load_cache()
50
+ @cache_info = ManabuDesktop::Util::Cache.load(CACHE_FILE_NAME)
51
+ if (@cache_info === {} || !@cache_info.includes?(:servers) ||
52
+ !@cache_info[:servers].instance_of?(Array))
53
+ @cache_info = {
54
+ servers: [{addr: 'localhost:9000', secure: false}]
55
+ }
56
+ end
57
+ end
58
+
59
+ def _save_cache()
60
+
61
+ end
62
+
63
+ def _engage(server, secure, user, password)
64
+ addr = /^[^:|^\/]*[^:|^\/]/.match(server) # server part
65
+ port = /[^:]\d[^\D]*/.match(server).to_s.to_i # port part
66
+ port = 80 if (port == 0)
67
+ route = /\/.*$/.match(server) #route part
68
+ @client = Manabu::Client.new(user, password, "#{addr}#{route}", port,
69
+ force_secure_connection: secure)
70
+ if @client.status == :connected
71
+ _open_toolbox(@client)
72
+ end
73
+ end
74
+
75
+ def _open_toolbox(client)
76
+ @window.destroy
77
+ ManabuDesktop::Screens::ToolBox.new(client)
78
+ end
79
+
80
+ def _update_server_list()
81
+ end
12
82
  end
13
83
  end
14
84
  end
@@ -8,13 +8,19 @@ module ManabuDesktop
8
8
  super('main_menu')
9
9
 
10
10
  connect_button = @builder.get_object('connect.button')
11
+ connect_button.set_label(I18n.t('main_menu.connect'))
11
12
  connect_button.signal_connect('clicked') { ManabuDesktop::Screens::Login.new }
12
13
 
13
14
  settings_button = @builder.get_object('settings.button')
15
+ settings_button.set_label(I18n.t('main_menu.settings'))
14
16
  settings_button.signal_connect('clicked') { puts 'Settings coming soon' }
15
17
 
16
18
  exit_button = @builder.get_object('exit.button')
17
- exit_button.signal_connect('clicked') { |_widget| Gtk.main_quit }
19
+ exit_button.set_label(I18n.t('main_menu.exit'))
20
+ exit_button.signal_connect('clicked') do |_widget|
21
+ Gtk.main_quit()
22
+ @window.destroy()
23
+ end
18
24
  _show()
19
25
  end
20
26
  end
@@ -0,0 +1,106 @@
1
+ require_relative 'base'
2
+ require_relative 'student/registration'
3
+ require 'manabu/client'
4
+ require 'manabu/students'
5
+
6
+ module ManabuDesktop
7
+ module Screens
8
+ class Roster < ManabuDesktop::Screens::Base
9
+
10
+ COLUMN_SELECT = 0
11
+ COLUMN_ID = 1
12
+ COLUMN_SURNAME = 2
13
+ COLUMN_NAME = 3
14
+ COLUMN_DOB = 4
15
+ COLUMN_SEX = 5
16
+
17
+ def initialize(client)
18
+ @client = client
19
+ super('roster')
20
+
21
+ treeview = @builder.get_object('roster.treeview')
22
+ toolbar = @builder.get_object('roster.toolbar')
23
+
24
+ _create_model()
25
+ treeview.set_model(@model)
26
+ _create_columns(treeview)
27
+
28
+ _setup_toolbar(toolbar)
29
+
30
+ @window.show_all
31
+ _show()
32
+ end
33
+
34
+ def _create_model()
35
+ @model = Gtk::ListStore.new(TrueClass, Integer, String, String, String, String)
36
+
37
+ students = Manabu::Students.new(@client)
38
+ students.roster.each_with_index do |student|
39
+ iter = @model.append()
40
+ iter.set_values([false, student.id, student.surname, student.name,
41
+ # #student.surname_reading, student.name_reading,
42
+ student.birth_date, student.gender])
43
+ end
44
+ end
45
+
46
+ def _create_columns(treeview)
47
+ renderer = Gtk::CellRendererToggle.new
48
+ renderer.signal_connect("toggled") { |_cell, path| _student_select(path) }
49
+ column = Gtk::TreeViewColumn.new(I18n.t("g.select"), renderer,
50
+ "active" => COLUMN_SELECT)
51
+ column.sort_column_id = COLUMN_SELECT
52
+ treeview.append_column(column)
53
+
54
+ renderer = Gtk::CellRendererText.new()
55
+ column = Gtk::TreeViewColumn.new(I18n.t("student.id"), renderer,
56
+ "text" => COLUMN_ID)
57
+ column.sort_column_id = COLUMN_ID
58
+ treeview.append_column(column)
59
+
60
+ renderer = Gtk::CellRendererText.new()
61
+ column = Gtk::TreeViewColumn.new(I18n.t("student.surname"), renderer,
62
+ "text" => COLUMN_SURNAME)
63
+ column.sort_column_id = COLUMN_SURNAME
64
+ treeview.append_column(column)
65
+
66
+ renderer = Gtk::CellRendererText.new()
67
+ column = Gtk::TreeViewColumn.new(I18n.t("student.name"), renderer,
68
+ "text" => COLUMN_NAME)
69
+ column.sort_column_id = COLUMN_NAME
70
+ treeview.append_column(column)
71
+
72
+ renderer = Gtk::CellRendererText.new()
73
+ column = Gtk::TreeViewColumn.new(I18n.t("student.dob"), renderer,
74
+ "text" => COLUMN_DOB)
75
+ column.sort_column_id = COLUMN_DOB
76
+ treeview.append_column(column)
77
+
78
+ renderer = Gtk::CellRendererText.new()
79
+ column = Gtk::TreeViewColumn.new(I18n.t("student.sex"), renderer,
80
+ "text" => COLUMN_SEX)
81
+ column.sort_column_id = COLUMN_SEX
82
+ treeview.append_column(column)
83
+ end
84
+
85
+ def _student_select(path_str)
86
+ path = Gtk::TreePath.new(path_str)
87
+ iter = @model.get_iter(path)
88
+ fixed = iter[COLUMN_SELECT]
89
+ # TODO: get student record and put in or remove from collection
90
+ fixed ^= 1
91
+ iter[COLUMN_SELECT] = fixed
92
+ end
93
+
94
+ def _setup_toolbar(toolbar)
95
+ register_student_button = Gtk::ToolButton.new(:stock_id => Gtk::Stock::NEW)
96
+ register_student_button.label = I18n.t('student.register')
97
+ register_student_button.signal_connect "clicked" do
98
+ ManabuDesktop::Screens::Student::Registration.new(@client, self)
99
+ end
100
+ sep = Gtk::SeparatorToolItem.new
101
+ toolbar.insert(register_student_button, 0)
102
+ toolbar.insert(sep, 1)
103
+ end
104
+ end
105
+ end
106
+ end
@@ -0,0 +1,42 @@
1
+ require_relative '../base'
2
+ require 'manabu/client'
3
+ require 'manabu/student'
4
+
5
+ module ManabuDesktop
6
+ module Screens
7
+ module Student
8
+ class Registration < ManabuDesktop::Screens::Base
9
+
10
+ def initialize(client, parent)
11
+ @client = client
12
+ @parent = parent
13
+
14
+ super('student_registration')
15
+
16
+ @builder.get_object('surname.label').set_label(
17
+ I18n.t('student.surname'))
18
+ @builder.get_object('name.label').set_label(
19
+ I18n.t('student.name'))
20
+ @builder.get_object('middle_name.label').set_label(
21
+ I18n.t('student.middle_name'))
22
+
23
+ @builder.get_object('surname_reading.label').set_label(
24
+ I18n.t('student.surname_reading'))
25
+ @builder.get_object('name_reading.label').set_label(
26
+ I18n.t('student.name_reading'))
27
+ @builder.get_object('middle_name_reading.label').set_label(
28
+ I18n.t('student.middle_name_reading'))
29
+
30
+
31
+ @builder.get_object('sex.label').set_label(I18n.t('student.sex'))
32
+ sex_comboboxtext = @builder.get_object('sex.comboboxtext')
33
+ sex_comboboxtext.append_text(I18n.t('student.male'))
34
+ sex_comboboxtext.append_text(I18n.t('student.female'))
35
+ @builder.get_object('birth_date.label').set_label(I18n.t('student.dob'))
36
+
37
+ _show()
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,67 @@
1
+ require_relative 'base'
2
+ require_relative 'roster'
3
+ require 'manabu/client'
4
+ require 'emojidex-rasters'
5
+ require 'emojidex/data/utf'
6
+
7
+ module ManabuDesktop
8
+ module Screens
9
+ class ToolBox < ManabuDesktop::Screens::Base
10
+ attr_reader :activities
11
+
12
+ ICON_COL = 0
13
+ LABEL_COL = 1
14
+ ACTIVITY_COL = 2
15
+
16
+ def initialize(client)
17
+ @client = client
18
+ super('toolbox')
19
+
20
+ @activities = [:Roster, :Courses, :Exams, :Administration]
21
+
22
+ icon_view = @builder.get_object('tools.icons')
23
+ icon_view.set_pixbuf_column(ICON_COL)
24
+ icon_view.set_text_column(LABEL_COL)
25
+ list = Gtk::ListStore.new(GdkPixbuf::Pixbuf, String, String)
26
+
27
+ _fill_toolbox(list, icon_view)
28
+
29
+ icon_view.signal_connect('item-activated') do |_widget, tree_path|
30
+ iter = list.get_iter(tree_path)
31
+ ManabuDesktop::Screens.const_get(iter[ACTIVITY_COL]).new(@client)
32
+ end
33
+
34
+ _show()
35
+ end
36
+
37
+ def _fill_toolbox(list, icon_view)
38
+ @activities.each do |ability|
39
+ _create_ability_icon(ability, list, icon_view)
40
+ end
41
+ end
42
+
43
+ def _create_ability_icon(ability, list, icon_view)
44
+ emojidex = Emojidex::Data::UTF.new
45
+ case ability
46
+ when :Roster
47
+ pixbuf = GdkPixbuf::Pixbuf.new(file: emojidex.emoji[:student].paths[:png][:px64])
48
+ when :Courses
49
+ pixbuf = GdkPixbuf::Pixbuf.new(file: emojidex.emoji[:notebook].paths[:png][:px64])
50
+ when :Exams
51
+ pixbuf = GdkPixbuf::Pixbuf.new(file: emojidex.emoji[:white_check_mark].paths[:png][:px64])
52
+ when :Administration
53
+ pixbuf = GdkPixbuf::Pixbuf.new(file: emojidex.emoji[:wrench].paths[:png][:px64])
54
+ else
55
+ pixbuf = GdkPixbuf::Pixbuf.new(file: emojidex.emoji[:question].paths[:png][:px64])
56
+ end
57
+
58
+ iter = list.append
59
+ list.set_value(iter, ICON_COL, pixbuf)
60
+ list.set_value(iter, LABEL_COL, I18n.t("g.#{ability.to_s}"))
61
+ list.set_value(iter, ACTIVITY_COL, ability)
62
+ icon_view.set_model(list)
63
+ end
64
+ end
65
+ end
66
+ end
67
+
data/lib/sessions.rb ADDED
@@ -0,0 +1,4 @@
1
+ module ManabuDesktop
2
+ class Sessions
3
+ end
4
+ end
@@ -3,7 +3,7 @@ require 'i18n'
3
3
  I18n.load_path = Dir["#{__dir__}/../locales/*.yml"]
4
4
 
5
5
  # TODO there must be a better way to determine language
6
- @lang = (ENV['LANG'][/^([^_]*)/]).to_sym
6
+ @lang = (ENV['LANG'][0..1]).to_sym
7
7
  if I18n.available_locales.include? @lang
8
8
  I18n.locale = @lang
9
9
  else
data/lib/util/cache.rb ADDED
@@ -0,0 +1,23 @@
1
+ module ManabuDesktop
2
+ module Util
3
+ class Cache
4
+ @@cache_path_override = nil
5
+
6
+ def self.load(file)
7
+ if File.exist?("#{cache_path()}/login_cache.msgpack")
8
+ file = File.open("#{cache_path()}/login_cache.msgpack", 'rb')
9
+ content = file.read()
10
+ begin
11
+ return MessagePack.unpack(content)
12
+ rescue
13
+ end
14
+ end
15
+ {}
16
+ end
17
+
18
+ def self.cache_path()
19
+ @@cache_path_override || ENV['MANABU_DESKTOP_CACHE'] || "#{ENV['HOME']}/.manabu-desktop/"
20
+ end
21
+ end
22
+ end
23
+ end
@@ -1,18 +1,18 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'manabu-desktop'
3
- s.version = '0.0.1'
4
- s.licenses = ['GPLv3']
3
+ s.version = '0.0.2'
4
+ s.licenses = ['GPL-3.0']
5
5
  s.summary = 'GTK based GUI client for Manabu/GAKU Engine'
6
6
  s.description = 'Manabu Desktop is a GTK front end for the Manabu client.'
7
7
  s.post_install_message = \
8
- '╔═════════════════════════╼' +
9
- "║Manabu GTK GUI for ⚙学 GAKU Engine [学エンジン] " +
10
- '╟─────────────────────────╼' +
11
- '║©2015 (株)幻創社 [Phantom Creation Inc.]' +
12
- '║http://www.gakuengine.com' +
13
- '╟─────────────────────────╼' +
14
- '║Manabu GTK is Open Sourced under the GPLv3.' +
15
- '╚═════════════════════════╼'
8
+ "╔═════════════════════════╼\n" +
9
+ "║Manabu GTK GUI for ⚙学 GAKU Engine [学エンジン] \n" +
10
+ "╟─────────────────────────╼\n" +
11
+ "║©2015 (株)幻創社 [Phantom Creation Inc.]\n" +
12
+ "║http://www.gakuengine.com\n" +
13
+ "╟─────────────────────────╼\n" +
14
+ "║Manabu GTK is Open Sourced under the GPLv3.\n" +
15
+ "╚═════════════════════════╼\n"
16
16
  s.authors = ['Rei Kagetsuki']
17
17
  s.email = 'info@gakuengine.com'
18
18
  s.homepage = 'http://www.gakuengine.com'
@@ -28,4 +28,7 @@ Gem::Specification.new do |s|
28
28
  s.add_dependency 'manabu'
29
29
  s.add_dependency 'gtk3'
30
30
  s.add_dependency 'i18n'
31
+
32
+ s.add_dependency 'emojidex'
33
+ s.add_dependency 'emojidex-rasters'
31
34
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: manabu-desktop
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rei Kagetsuki
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-12-03 00:00:00.000000000 Z
11
+ date: 2018-02-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: manabu
@@ -52,6 +52,34 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: emojidex
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: emojidex-rasters
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
55
83
  description: Manabu Desktop is a GTK front end for the Manabu client.
56
84
  email: info@gakuengine.com
57
85
  executables:
@@ -66,18 +94,26 @@ files:
66
94
  - layouts/img/manabu-kun.png
67
95
  - layouts/login.glade
68
96
  - layouts/main_menu.glade
97
+ - layouts/roster.glade
98
+ - layouts/student_registration.glade
99
+ - layouts/toolbox.glade
69
100
  - lib/screens/base.rb
70
101
  - lib/screens/login.rb
71
102
  - lib/screens/main_menu.rb
72
- - lib/toolbox.rb
103
+ - lib/screens/roster.rb
104
+ - lib/screens/student/registration.rb
105
+ - lib/screens/toolbox.rb
106
+ - lib/sessions.rb
107
+ - lib/tools.rb
108
+ - lib/util/cache.rb
73
109
  - manabu-desktop.gemspec
74
110
  homepage: http://www.gakuengine.com
75
111
  licenses:
76
- - GPLv3
112
+ - GPL-3.0
77
113
  metadata: {}
78
- post_install_message: "╔═════════════════════════╼║Manabu GTK GUI for ⚙学 GAKU Engine
79
- [学エンジン] ╟─────────────────────────╼║©2015 (株)幻創社 [Phantom Creation Inc.]║http://www.gakuengine.com╟─────────────────────────╼║Manabu
80
- GTK is Open Sourced under the GPLv3.╚═════════════════════════╼"
114
+ post_install_message: "╔═════════════════════════╼\n║Manabu GTK GUI for ⚙学 GAKU Engine
115
+ [学エンジン] \n╟─────────────────────────╼\n║©2015 (株)幻創社 [Phantom Creation Inc.]\n║http://www.gakuengine.com\n╟─────────────────────────╼\n║Manabu
116
+ GTK is Open Sourced under the GPLv3.\n╚═════════════════════════╼\n"
81
117
  rdoc_options: []
82
118
  require_paths:
83
119
  - lib
@@ -93,7 +129,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
93
129
  version: '0'
94
130
  requirements: []
95
131
  rubyforge_project:
96
- rubygems_version: 2.6.14
132
+ rubygems_version: 2.7.3
97
133
  signing_key:
98
134
  specification_version: 4
99
135
  summary: GTK based GUI client for Manabu/GAKU Engine