@@ -165,14 +165,29 @@ impl GpuPage {
165
165
// TODO: Load config of gpu (use uuid as ID)
166
166
// TODO: needs to be a vector as may bed of variable size..
167
167
//let statistics: Vec<&str> = load_json_settings(&self.property("uuid"));//array?vector?json-type object?
168
- let statistics_data: Vec < & str > = vec ! [
169
- "util" ,
170
- "temp" ,
171
- "memory_usage" ,
172
- "memory_total" ,
173
- "fan_speed" ,
174
- "power_usage" ,
175
- ] ;
168
+ let statistics_data: Vec < & str > ; //TEST
169
+ match self . property :: < Provider > ( "provider" ) . property :: < i32 > ( "provider-type" ) {
170
+ 1 => {
171
+ statistics_data = vec ! [
172
+ "util" ,
173
+ "temp" ,
174
+ "memory_usage" ,
175
+ "memory_total" ,
176
+ "mem_ctrl_util" ,
177
+ ] ;
178
+ }
179
+ _ => {
180
+ statistics_data = vec ! [
181
+ "util" ,
182
+ "temp" ,
183
+ "memory_usage" ,
184
+ "memory_total" ,
185
+ "mem_ctrl_util" ,
186
+ "fan_speed" ,
187
+ "power_usage" ,
188
+ ] ;
189
+ }
190
+ }
176
191
let statistics_store: Arc < Mutex < Vec < & str > > > = Arc :: new ( Mutex :: new ( statistics_data) ) ;
177
192
178
193
// Edit button
@@ -220,38 +235,94 @@ impl GpuPage {
220
235
//child_manager.set_property("outline-width", 1);
221
236
//child_manager.set_property("border-radius", 3);
222
237
223
- // Fetch layout manager for this child grid
238
+ // Fetch layout manager for this ( grid) child
224
239
let internal_grid_manager = new_grid. layout_manager ( ) . expect ( "Fuck.." ) ;
225
240
226
- // Build label & add to grid
241
+ // Decide on title label size
242
+ let space: i32 ;
243
+ let pretty_label: & str ;
244
+ match statistic. to_owned ( ) {
245
+ "util" => {
246
+ pretty_label = "GPU Utilization" ;
247
+ space = 5
248
+ } ,
249
+ "mem_ctrl_util" => {
250
+ pretty_label = "Memory Controller Utilization" ;
251
+ space = 5
252
+ } ,
253
+ "encoder_util" => {
254
+ pretty_label = "Encoder Utilization" ;
255
+ space = 5
256
+ } ,
257
+ "decoder_util" => {
258
+ pretty_label = "Decoder Utilization" ;
259
+ space = 5
260
+ } ,
261
+ "fan_speed" => {
262
+ pretty_label = "Fan Speed" ;
263
+ space = 5
264
+ } ,
265
+ "temp" => {
266
+ pretty_label = "Temperature" ;
267
+ space = 5
268
+ } ,
269
+ "memory_usage" => {
270
+ pretty_label = "Memory Usage" ;
271
+ space = 8
272
+ } ,
273
+ "memory_total" => {
274
+ pretty_label = "Memory Total" ;
275
+ space = 8
276
+ } ,
277
+ "power_usage" => {
278
+ pretty_label = "Power Usage" ;
279
+ space = 8
280
+ } ,
281
+ _ => {
282
+ pretty_label = statistic;
283
+ space = 5
284
+ } ,
285
+ }
286
+
287
+ // Build title label & add to grid
227
288
let new_title: String = String :: from ( statistic. to_owned ( ) ) + "_label" ;
228
289
let new_title_label: Label = Label :: builder ( )
229
- . label ( statistic )
290
+ . label ( pretty_label )
230
291
. name ( & new_title)
231
292
. hexpand ( true )
232
293
. hexpand_set ( true )
233
294
. halign ( Align :: Center )
234
295
//.valign(Align::Center)
235
296
. margin_top ( 12 )
236
297
. margin_bottom ( 12 )
298
+ . width_chars ( space)
237
299
. build ( ) ;
238
300
new_grid. attach ( & new_title_label, 0 , 0 , 1 , 1 ) ;
239
301
240
- // Set layout properties of child
302
+ // Set layout properties of (title label) child
241
303
let title_manager: LayoutChild = internal_grid_manager. layout_child ( & new_title_label) ;
242
304
title_manager. set_property ( "row-span" , 1 ) ;
243
305
244
- // Build label & add to grid
306
+ // Decide on content label size
307
+ let space: i32 ;
308
+ match statistic. to_owned ( ) {
309
+ "util" | "fan_speed" | "temp" => space = 5 ,
310
+ "memory_usage" | "memory_total" => space = 8 ,
311
+ _ => space = 5 ,
312
+ }
313
+
314
+ // Build content label & add to grid
245
315
let new_content: String = String :: from ( statistic. to_owned ( ) ) ;
246
316
let new_content_label: Label = Label :: builder ( )
247
317
. label ( "" )
248
318
. name ( & new_content)
249
319
//.halign(Align::End)
250
320
//.valign(Align::Center)
321
+ . width_chars ( space)
251
322
. build ( ) ;
252
323
new_grid. attach ( & new_content_label, 1 , 0 , 1 , 1 ) ;
253
324
254
- // Set layout properties of child
325
+ // Set layout properties of (content label) child
255
326
let content_manager: LayoutChild = internal_grid_manager. layout_child ( & new_content_label) ;
256
327
content_manager. set_property ( "row-span" , 1 ) ;
257
328
@@ -266,7 +337,7 @@ impl GpuPage {
266
337
labels. push ( new_content_label) ;
267
338
}
268
339
269
- // Fetch uuid, needed for processor
340
+ // Create thread safe container for uuid, needed for processor
270
341
let uuid_store: Arc < Mutex < String > > = Arc :: new ( Mutex :: new ( self . property ( "uuid" ) ) ) ;
271
342
272
343
// Create thread safe container for provider
@@ -275,14 +346,13 @@ impl GpuPage {
275
346
// Async fill the labels
276
347
glib:: timeout_add_seconds_local ( refresh_rate, move || {
277
348
// Grab locked data
278
- // Get list of statistics
349
+ // list of statistics
279
350
let statistics_lock: Arc < Mutex < Vec < & str > > > = Arc :: clone ( & statistics_store) ;
280
351
let statistics: MutexGuard < Vec < & str > > = statistics_lock. lock ( ) . unwrap ( ) ;
281
- // Get uuid
352
+ // uuid
282
353
let uuid_lock: Arc < Mutex < String > > = Arc :: clone ( & uuid_store) ;
283
354
let uuid: String = uuid_lock. lock ( ) . unwrap ( ) . as_str ( ) . to_owned ( ) ;
284
-
285
- // Create provider for scanning gpu data
355
+ // current provider for scanning gpu data
286
356
let provider_lock: Arc < Mutex < Option < Provider > > > = Arc :: clone ( & provider_store) ;
287
357
let mut provider_container: MutexGuard < Option < Provider > > = provider_lock. lock ( ) . unwrap ( ) ;
288
358
0 commit comments